diff --git a/ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore b/ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore new file mode 100644 index 000000000..9ce745d95 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore @@ -0,0 +1,3 @@ + +bin/ +obj/ \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp.AstVerifier/AssemblyInfo.cs b/ICSharpCode.NRefactory.CSharp.AstVerifier/AssemblyInfo.cs new file mode 100644 index 000000000..7bd701bed --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp.AstVerifier/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("ICSharpCode.NRefactory.CSharp.AstVerifier")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("mike")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj b/ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj new file mode 100644 index 000000000..bd6e1e823 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj @@ -0,0 +1,49 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {961DADFA-7CE6-429F-BC22-47630D6DB826} + Exe + ICSharpCode.NRefactory.CSharp.AstVerifier + AstVerifier + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + + + none + false + bin\Release + prompt + 4 + true + + + + + + + + + + + + {53DCA265-3C3C-42F9-B647-F72BA678122B} + ICSharpCode.NRefactory.CSharp + + + {3B2A5653-EC97-4001-BB9B-D90F1AF2C371} + ICSharpCode.NRefactory + + + \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs b/ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs new file mode 100644 index 000000000..43d3531b7 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs @@ -0,0 +1,83 @@ +using System; +using System.IO; + +namespace ICSharpCode.NRefactory.CSharp.AstVerifier +{ + class MainClass + { + static bool IsMatch (string src1, string src2, out int i, out int j) + { + i = 0; + j = 0; + while (i < src1.Length && j < src2.Length) { + char c1 = src1 [i]; + char c2 = src2 [j]; + if (char.IsWhiteSpace (c1)) { + i++; + continue; + } + if (char.IsWhiteSpace (c2)) { + j++; + continue; + } + if (c1 != c2) + return false; + i++; + j++; + } + while (i < src1.Length && char.IsWhiteSpace (src1[i])) { + i++; + } + while (j < src2.Length && char.IsWhiteSpace (src2[j])) { + j++; + } + + return i == src1.Length && j == src2.Length; + } + + public static void Main (string[] args) + { + if (args.Length == 0) { + Console.WriteLine ("Usage: AstVerifier [-v|-verbose] [Directory]"); + return; + } + string directory = args[args.Length - 1]; + bool verboseOutput = args.Length > 1 && (args[0] == "-v" || args[0] == "-verbose"); + + try { + if (!Directory.Exists (directory)) { + Console.WriteLine ("Directory not found."); + return; + } + } catch (IOException) { + Console.WriteLine ("Exception while trying to access the directory."); + return; + } + int failed = 0, passed = 0; + Console.WriteLine ("search in " + directory); + foreach (var file in Directory.GetFileSystemEntries (directory, "*", SearchOption.AllDirectories)) { + if (!file.EndsWith (".cs")) + continue; + string text = File.ReadAllText (file); + var unit = CompilationUnit.Parse (text, file); + if (unit == null) + continue; + string generated = unit.GetText (); + int i, j; + if (!IsMatch (text, generated, out i, out j)) { + if (i > 0 && j > 0 && verboseOutput) { + Console.WriteLine ("fail :" + file + "----original:"); + Console.WriteLine (text.Substring (0, Math.Min (text.Length, i + 1))); + Console.WriteLine ("----generated:"); + Console.WriteLine (generated.Substring (0, Math.Min (generated.Length, j + 1))); + } + failed++; + } else { + passed++; + } + } + + Console.WriteLine ("{0} passed, {1} failed", passed, failed); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs b/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs index 4bf4e8bd7..2812375b1 100644 --- a/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs +++ b/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// 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 @@ -113,7 +113,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis /// Gets the try-finally statements that this control flow edge is leaving. /// public IEnumerable TryFinallyStatements { - get { return jumpOutOfTryFinally ?? EmptyList.Instance; } + get { return jumpOutOfTryFinally ?? Enumerable.Empty(); } } } @@ -420,7 +420,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis falseEnd = ifElseStatement.FalseStatement.AcceptVisitor(this, falseBegin); } ControlFlowNode end = builder.CreateEndNode(ifElseStatement); - Connect(trueEnd, end); + if (trueEnd != null) + Connect(trueEnd, end); if (falseEnd != null) { Connect(falseEnd, end); } else if (cond != true) { diff --git a/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs b/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs index 8d0832bed..fdcc4d717 100644 --- a/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs +++ b/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs @@ -304,54 +304,53 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis return DefiniteAssignmentStatus.PotentiallyAssigned; } - void ChangeNodeStatus(DefiniteAssignmentNode node, DefiniteAssignmentStatus inputStatus) + void ChangeNodeStatus (DefiniteAssignmentNode node, DefiniteAssignmentStatus inputStatus) { if (node.NodeStatus == inputStatus) return; node.NodeStatus = inputStatus; DefiniteAssignmentStatus outputStatus; switch (node.Type) { - case ControlFlowNodeType.StartNode: - case ControlFlowNodeType.BetweenStatements: - if (node.NextStatement is IfElseStatement) { - // Handle if-else as a condition node + case ControlFlowNodeType.StartNode: + case ControlFlowNodeType.BetweenStatements: + if (node.NextStatement is IfElseStatement) { + // Handle if-else as a condition node goto case ControlFlowNodeType.LoopCondition; - } - if (inputStatus == DefiniteAssignmentStatus.DefinitelyAssigned) { - // There isn't any way to un-assign variables, so we don't have to check the expression - // if the status already is definitely assigned. - outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned; - } else { - outputStatus = CleanSpecialValues(node.NextStatement.AcceptVisitor(visitor, inputStatus)); - } - break; - case ControlFlowNodeType.EndNode: - outputStatus = inputStatus; - if (node.PreviousStatement.Role == TryCatchStatement.FinallyBlockRole - && (outputStatus == DefiniteAssignmentStatus.DefinitelyAssigned || outputStatus == DefiniteAssignmentStatus.PotentiallyAssigned)) - { - TryCatchStatement tryFinally = (TryCatchStatement)node.PreviousStatement.Parent; - // Changing the status on a finally block potentially changes the status of all edges leaving that finally block: - foreach (ControlFlowEdge edge in allNodes.SelectMany(n => n.Outgoing)) { - if (edge.IsLeavingTryFinally && edge.TryFinallyStatements.Contains(tryFinally)) { - DefiniteAssignmentStatus s = edgeStatus[edge]; - if (s == DefiniteAssignmentStatus.PotentiallyAssigned) { - ChangeEdgeStatus(edge, outputStatus); - } + } + if (inputStatus == DefiniteAssignmentStatus.DefinitelyAssigned) { + // There isn't any way to un-assign variables, so we don't have to check the expression + // if the status already is definitely assigned. + outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned; + } else { + outputStatus = CleanSpecialValues (node.NextStatement.AcceptVisitor (visitor, inputStatus)); + } + break; + case ControlFlowNodeType.EndNode: + outputStatus = inputStatus; + if (node.PreviousStatement.Role == TryCatchStatement.FinallyBlockRole + && (outputStatus == DefiniteAssignmentStatus.DefinitelyAssigned || outputStatus == DefiniteAssignmentStatus.PotentiallyAssigned)) { + TryCatchStatement tryFinally = (TryCatchStatement)node.PreviousStatement.Parent; + // Changing the status on a finally block potentially changes the status of all edges leaving that finally block: + foreach (ControlFlowEdge edge in allNodes.SelectMany(n => n.Outgoing)) { + if (edge.IsLeavingTryFinally && edge.TryFinallyStatements.Contains (tryFinally)) { + DefiniteAssignmentStatus s = edgeStatus [edge]; + if (s == DefiniteAssignmentStatus.PotentiallyAssigned) { + ChangeEdgeStatus (edge, outputStatus); } } } + } + break; + case ControlFlowNodeType.LoopCondition: + ForeachStatement foreachStmt = node.NextStatement as ForeachStatement; + if (foreachStmt != null) { + outputStatus = CleanSpecialValues (foreachStmt.InExpression.AcceptVisitor (visitor, inputStatus)); + if (foreachStmt.VariableName == this.variableName) + outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned; break; - case ControlFlowNodeType.LoopCondition: - ForeachStatement foreachStmt = node.NextStatement as ForeachStatement; - if (foreachStmt != null) { - outputStatus = CleanSpecialValues(foreachStmt.InExpression.AcceptVisitor(visitor, inputStatus)); - if (foreachStmt.VariableName == this.variableName) - outputStatus = DefiniteAssignmentStatus.DefinitelyAssigned; - break; - } else { - Debug.Assert(node.NextStatement is IfElseStatement || node.NextStatement is WhileStatement || node.NextStatement is ForStatement || node.NextStatement is DoWhileStatement); - Expression condition = node.NextStatement.GetChildByRole(AstNode.Roles.Condition); + } else { + Debug.Assert (node.NextStatement is IfElseStatement || node.NextStatement is WhileStatement || node.NextStatement is ForStatement || node.NextStatement is DoWhileStatement); + Expression condition = node.NextStatement.GetChildByRole (Roles.Condition); if (condition.IsNull) outputStatus = inputStatus; else diff --git a/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs index 8e6d05a2d..bc4d27de0 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs @@ -1,4 +1,4 @@ -// +// // AstNode.cs // // Author: @@ -33,8 +33,11 @@ using System.Threading; namespace ICSharpCode.NRefactory.CSharp { - public abstract class AstNode : AbstractAnnotatable, PatternMatching.INode + public abstract class AstNode : AbstractAnnotatable, ICSharpCode.NRefactory.TypeSystem.IFreezable, PatternMatching.INode { + // the Root role must be available when creating the null nodes, so we can't put it in the Roles class + internal static readonly Role RootRole = new Role ("Root"); + #region Null public static readonly AstNode Null = new NullAstNode (); @@ -52,7 +55,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -83,7 +95,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder (this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder (this, child); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitPatternPlaceholder (this, child, data); } @@ -105,7 +127,42 @@ namespace ICSharpCode.NRefactory.CSharp AstNode nextSibling; AstNode firstChild; AstNode lastChild; - Role role = RootRole; + + // Flags, from least significant to most significant bits: + // - Role.RoleIndexBits: role index + // - 1 bit: IsFrozen + protected uint flags = RootRole.Index; + // Derived classes may also use a few bits, + // for example Identifier uses 1 bit for IsVerbatim + + const uint roleIndexMask = (1u << Role.RoleIndexBits) - 1; + const uint frozenBit = 1u << Role.RoleIndexBits; + protected const int AstNodeFlagsUsedBits = Role.RoleIndexBits + 1; + + protected AstNode() + { + if (IsNull) + Freeze(); + } + + public bool IsFrozen { + get { return (flags & frozenBit) != 0; } + } + + public void Freeze() + { + if (!IsFrozen) { + for (AstNode child = firstChild; child != null; child = child.nextSibling) + child.Freeze(); + flags |= frozenBit; + } + } + + protected void ThrowIfFrozen() + { + if (IsFrozen) + throw new InvalidOperationException("Cannot mutate frozen " + GetType().Name); + } public abstract NodeType NodeType { get; @@ -135,22 +192,6 @@ namespace ICSharpCode.NRefactory.CSharp } } - /// - /// Returns true, if the given coordinates are in the node. - /// - public bool IsInside (TextLocation location) - { - return StartLocation <= location && location <= EndLocation; - } - - /// - /// Returns true, if the given coordinates (line, column) are in the node. - /// - public bool IsInside(int line, int column) - { - return IsInside(new TextLocation (line, column)); - } - /// /// Gets the region from StartLocation to EndLocation for this node. /// The file name of the region is set based on the parent CompilationUnit's file name. @@ -168,7 +209,22 @@ namespace ICSharpCode.NRefactory.CSharp } public Role Role { - get { return role; } + get { + return Role.GetByIndex(flags & roleIndexMask); + } + set { + if (value == null) + throw new ArgumentNullException("value"); + if (!value.IsValid(this)) + throw new ArgumentException("This node is not valid in the new role."); + ThrowIfFrozen(); + SetRole(value); + } + } + + void SetRole(Role role) + { + flags = (flags & ~roleIndexMask) | role.Index; } public AstNode NextSibling { @@ -187,6 +243,12 @@ namespace ICSharpCode.NRefactory.CSharp get { return lastChild; } } + public bool HasChildren { + get { + return firstChild != null; + } + } + public IEnumerable Children { get { AstNode next; @@ -211,6 +273,17 @@ namespace ICSharpCode.NRefactory.CSharp } } + /// + /// Gets the ancestors of this node (including this node itself) + /// + public IEnumerable AncestorsAndSelf { + get { + for (AstNode cur = this; cur != null; cur = cur.parent) { + yield return cur; + } + } + } + /// /// Gets all descendants of this node (excluding this node itself). /// @@ -233,17 +306,23 @@ 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"); + uint roleIndex = role.Index; for (var cur = firstChild; cur != null; cur = cur.nextSibling) { - if (cur.role == role) + if ((cur.flags & roleIndexMask) == roleIndex) return (T)cur; } return role.NullObject; } + public T GetParent() where T : AstNode + { + return Ancestors.OfType().FirstOrDefault(); + } + public AstNodeCollection GetChildrenByRole (Role role) where T : AstNode { return new AstNodeCollection (this, role); @@ -264,10 +343,11 @@ namespace ICSharpCode.NRefactory.CSharp throw new ArgumentNullException ("role"); if (child == null || child.IsNull) return; - if (this.IsNull) - throw new InvalidOperationException ("Cannot add children to null nodes"); + ThrowIfFrozen(); if (child.parent != null) throw new ArgumentException ("Node is already used in another tree.", "child"); + if (child.IsFrozen) + throw new ArgumentException ("Cannot add a frozen node.", "child"); AddChildUnsafe (child, role); } @@ -277,7 +357,7 @@ namespace ICSharpCode.NRefactory.CSharp void AddChildUnsafe (AstNode child, Role role) { child.parent = this; - child.role = role; + child.SetRole(role); if (firstChild == null) { lastChild = firstChild = child; } else { @@ -286,6 +366,13 @@ namespace ICSharpCode.NRefactory.CSharp lastChild = child; } } + + public void InsertChildsBefore(AstNode nextSibling, Role role, params T[] child) where T : AstNode + { + foreach (var cur in child) { + InsertChildBefore(nextSibling, cur, role); + } + } public void InsertChildBefore (AstNode nextSibling, T child, Role role) where T : AstNode { @@ -298,8 +385,11 @@ namespace ICSharpCode.NRefactory.CSharp if (child == null || child.IsNull) return; + ThrowIfFrozen(); if (child.parent != null) throw new ArgumentException ("Node is already used in another tree.", "child"); + if (child.IsFrozen) + throw new ArgumentException ("Cannot add a frozen node.", "child"); if (nextSibling.parent != this) throw new ArgumentException ("NextSibling is not a child of this node.", "nextSibling"); // No need to test for "Cannot add children to null nodes", @@ -310,7 +400,7 @@ namespace ICSharpCode.NRefactory.CSharp void InsertChildBeforeUnsafe (AstNode nextSibling, AstNode child, Role role) { child.parent = this; - child.role = role; + child.SetRole(role); child.nextSibling = nextSibling; child.prevSibling = nextSibling.prevSibling; @@ -335,6 +425,7 @@ namespace ICSharpCode.NRefactory.CSharp public void Remove () { if (parent != null) { + ThrowIfFrozen(); if (prevSibling != null) { Debug.Assert (prevSibling.nextSibling == this); prevSibling.nextSibling = nextSibling; @@ -350,7 +441,6 @@ namespace ICSharpCode.NRefactory.CSharp parent.lastChild = prevSibling; } parent = null; - role = Roles.Root; prevSibling = null; nextSibling = null; } @@ -370,10 +460,11 @@ namespace ICSharpCode.NRefactory.CSharp if (parent == null) { throw new InvalidOperationException (this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node"); } + ThrowIfFrozen(); // 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 (!this.Role.IsValid (newNode)) { + throw new ArgumentException (string.Format ("The new node '{0}' is not valid in the role {1}", newNode.GetType ().Name, this.Role.ToString ()), "newNode"); } if (newNode.parent != null) { // newNode is used within this tree? @@ -385,9 +476,11 @@ namespace ICSharpCode.NRefactory.CSharp throw new ArgumentException ("Node is already used in another tree.", "newNode"); } } + if (newNode.IsFrozen) + throw new ArgumentException ("Cannot add a frozen node.", "newNode"); newNode.parent = parent; - newNode.role = role; + newNode.SetRole(this.Role); newNode.prevSibling = prevSibling; newNode.nextSibling = nextSibling; if (parent != null) { @@ -408,7 +501,6 @@ namespace ICSharpCode.NRefactory.CSharp parent = null; prevSibling = null; nextSibling = null; - role = Roles.Root; } } @@ -421,7 +513,7 @@ namespace ICSharpCode.NRefactory.CSharp } AstNode oldParent = parent; AstNode oldSuccessor = nextSibling; - Role oldRole = role; + Role oldRole = this.Role; Remove (); AstNode replacement = replaceFunction (this); if (oldSuccessor != null && oldSuccessor.parent != oldParent) @@ -450,26 +542,28 @@ namespace ICSharpCode.NRefactory.CSharp AstNode copy = (AstNode)MemberwiseClone (); // First, reset the shallow pointer copies copy.parent = null; - copy.role = Roles.Root; copy.firstChild = null; copy.lastChild = null; copy.prevSibling = null; copy.nextSibling = null; + copy.flags &= ~frozenBit; // unfreeze the copy // 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 copiedAnnotations = copy.annotations as ICloneable; // read from copy (for thread-safety) - if (copiedAnnotations != null) - copy.annotations = copiedAnnotations.Clone(); + copy.CloneAnnotations(); return copy; } - public abstract S AcceptVisitor (IAstVisitor visitor, T data = default(T)); + public abstract void AcceptVisitor (IAstVisitor visitor); + + public abstract T AcceptVisitor (IAstVisitor visitor); + + public abstract S AcceptVisitor (IAstVisitor visitor, T data); #region Pattern Matching protected static bool MatchString (string pattern, string text) @@ -519,7 +613,6 @@ namespace ICSharpCode.NRefactory.CSharp return Parent.GetPrevNode (); return null; } - // filters all non c# nodes (comments, white spaces or pre processor directives) public AstNode GetCSharpNodeBefore (AstNode node) { @@ -532,11 +625,22 @@ namespace ICSharpCode.NRefactory.CSharp return null; } + #region GetNodeAt + /// + /// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching + /// the current method declaration. + /// (End exclusive) + /// public AstNode GetNodeAt (int line, int column, Predicate pred = null) { return GetNodeAt (new TextLocation (line, column), pred); } + /// + /// Gets the node specified by pred at location. This is useful for getting a specific node from the tree. For example searching + /// the current method declaration. + /// (End exclusive) + /// public AstNode GetNodeAt (TextLocation location, Predicate pred = null) { AstNode result = null; @@ -559,6 +663,11 @@ namespace ICSharpCode.NRefactory.CSharp return result; } + /// + /// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching + /// the current method declaration. + /// (End exclusive) + /// public T GetNodeAt (int line, int column) where T : AstNode { return GetNodeAt (new TextLocation (line, column)); @@ -567,6 +676,7 @@ namespace ICSharpCode.NRefactory.CSharp /// /// 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. + /// (End exclusive) /// public T GetNodeAt (TextLocation location) where T : AstNode { @@ -589,6 +699,97 @@ namespace ICSharpCode.NRefactory.CSharp } return result; } + + #endregion + + #region GetAdjacentNodeAt + /// + /// Gets the node specified by pred at the location line, column. This is useful for getting a specific node from the tree. For example searching + /// the current method declaration. + /// (End inclusive) + /// + public AstNode GetAdjacentNodeAt(int line, int column, Predicate pred = null) + { + return GetAdjacentNodeAt (new TextLocation (line, column), pred); + } + + /// + /// Gets the node specified by pred at location. This is useful for getting a specific node from the tree. For example searching + /// the current method declaration. + /// (End inclusive) + /// + public AstNode GetAdjacentNodeAt (TextLocation 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; + } + + /// + /// Gets the node specified by T at the location line, column. This is useful for getting a specific node from the tree. For example searching + /// the current method declaration. + /// (End inclusive) + /// + public T GetAdjacentNodeAt(int line, int column) where T : AstNode + { + return GetAdjacentNodeAt (new TextLocation (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. + /// (End inclusive) + /// + public T GetAdjacentNodeAt (TextLocation 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; + } + #endregion + + + /// + /// Gets the node that fully contains the range from startLocation to endLocation. + /// + public AstNode GetNodeContaining(TextLocation startLocation, TextLocation endLocation) + { + for (AstNode child = firstChild; child != null; child = child.nextSibling) { + if (child.StartLocation <= startLocation && endLocation <= child.EndLocation) + return child.GetNodeContaining(startLocation, endLocation); + } + return this; + } public IEnumerable GetNodesBetween (int startLine, int startColumn, int endLine, int endColumn) { @@ -619,16 +820,65 @@ namespace ICSharpCode.NRefactory.CSharp } } + /// + /// Gets the node as formatted C# output. + /// + /// + /// Formatting options. + /// + public virtual string GetText (CSharpFormattingOptions formattingOptions = null) + { + if (IsNull) + return ""; + var w = new StringWriter (); + AcceptVisitor (new CSharpOutputVisitor (w, formattingOptions ?? FormattingOptionsFactory.CreateMono ())); + return w.ToString (); + } + + /// + /// Returns true, if the given coordinates (line, column) are in the node. + /// + /// + /// True, if the given coordinates are between StartLocation and EndLocation (exclusive); otherwise, false. + /// public bool Contains (int line, int column) { return Contains (new TextLocation (line, column)); } - + + /// + /// Returns true, if the given coordinates are in the node. + /// + /// + /// True, if location is between StartLocation and EndLocation (exclusive); otherwise, false. + /// public bool Contains (TextLocation location) { return this.StartLocation <= location && location < this.EndLocation; } + /// + /// Returns true, if the given coordinates (line, column) are in the node. + /// + /// + /// True, if the given coordinates are between StartLocation and EndLocation (inclusive); otherwise, false. + /// + public bool IsInside (int line, int column) + { + return IsInside (new TextLocation (line, column)); + } + + /// + /// Returns true, if the given coordinates are in the node. + /// + /// + /// True, if location is between StartLocation and EndLocation (inclusive); otherwise, false. + /// + public bool IsInside (TextLocation location) + { + return this.StartLocation <= location && location <= this.EndLocation; + } + public override void AddAnnotation (object annotation) { if (this.IsNull) @@ -640,60 +890,12 @@ namespace ICSharpCode.NRefactory.CSharp { if (IsNull) return "Null"; - StringWriter w = new StringWriter(); - AcceptVisitor(new CSharpOutputVisitor(w, new CSharpFormattingOptions()), null); - string text = w.ToString().TrimEnd().Replace("\t", "").Replace(w.NewLine, " "); + string text = GetText(); + text = text.TrimEnd().Replace("\t", "").Replace(Environment.NewLine, " "); if (text.Length > 100) return text.Substring(0, 97) + "..."; else return text; } - - // 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"); - - public static class Roles - { - /// - /// Root of an abstract syntax tree. - /// - 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); - - // 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 PreProcessorDirective = new Role ("PreProcessorDirective"); - public static readonly Role Error = new Role ("Error"); - - } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs b/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs index 205a76884..71d835709 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs @@ -39,7 +39,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -75,9 +84,19 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder (this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder (this, child); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { - return visitor.VisitPatternPlaceholder(this, child, data); + return visitor.VisitPatternPlaceholder (this, child, data); } public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode) @@ -153,6 +172,26 @@ namespace ICSharpCode.NRefactory.CSharp return new TypeReferenceExpression { Type = this }.Member(memberName); } + /// + /// Builds an expression that can be used to access a static member on this type. + /// + public MemberType MemberType(string memberName, params AstType[] typeArguments) + { + var memberType = new MemberType(this, memberName); + memberType.TypeArguments.AddRange(typeArguments); + return memberType; + } + + /// + /// Builds an expression that can be used to access a static member on this type. + /// + public MemberType MemberType(string memberName, IEnumerable typeArguments) + { + var memberType = new MemberType(this, memberName); + memberType.TypeArguments.AddRange(typeArguments); + return memberType; + } + /// /// Builds an invocation expression using this type as target. /// diff --git a/ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs b/ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs index e9cc00ebe..ac59c7246 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/CSharpModifierToken.cs @@ -29,19 +29,29 @@ using System.Linq; namespace ICSharpCode.NRefactory.CSharp { - public class CSharpModifierToken : CSharpTokenNode { Modifiers modifier; public Modifiers Modifier { get { return modifier; } - set { - this.tokenLength = GetModifierName(value).Length; - this.modifier = value; + set { + ThrowIfFrozen(); + this.modifier = value; } } + protected override int TokenLength { + get { + return GetModifierName (modifier).Length; + } + } + + public override string GetText (CSharpFormattingOptions formattingOptions = null) + { + return GetModifierName (Modifier); + } + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { CSharpModifierToken o = other as CSharpModifierToken; @@ -65,7 +75,7 @@ namespace ICSharpCode.NRefactory.CSharp get { return allModifiers; } } - public CSharpModifierToken (TextLocation location, Modifiers modifier) : base (location, 0) + public CSharpModifierToken (TextLocation location, Modifiers modifier) : base (location) { this.Modifier = modifier; } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/CSharpTokenNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/CSharpTokenNode.cs index 00bf53dfd..04910ae18 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/CSharpTokenNode.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/CSharpTokenNode.cs @@ -27,7 +27,13 @@ using System; namespace ICSharpCode.NRefactory.CSharp { - public class CSharpTokenNode : AstNode, IRelocatable + /// + /// Represents a token in C#. Note that the type of the token is defined through the TokenRole. + /// + /// + /// In all non null c# token nodes the Role of a CSharpToken must be a TokenRole. + /// + public class CSharpTokenNode : AstNode { public static new readonly CSharpTokenNode Null = new NullCSharpTokenNode (); class NullCSharpTokenNode : CSharpTokenNode @@ -38,11 +44,20 @@ namespace ICSharpCode.NRefactory.CSharp } } - public NullCSharpTokenNode () : base (TextLocation.Empty, 0) + public NullCSharpTokenNode () : base (TextLocation.Empty) { } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -53,7 +68,6 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override NodeType NodeType { get { return NodeType.Token; @@ -67,27 +81,43 @@ namespace ICSharpCode.NRefactory.CSharp } } - protected int tokenLength; + protected virtual int TokenLength { + get { + if (!(Role is TokenRole)) + return 0; + return ((TokenRole)Role).Length; + } + } + public override TextLocation EndLocation { get { - return new TextLocation (StartLocation.Line, StartLocation.Column + tokenLength); + return new TextLocation (StartLocation.Line, StartLocation.Column + TokenLength); } } - public CSharpTokenNode (TextLocation location, int tokenLength) + public CSharpTokenNode (TextLocation location) { this.startLocation = location; - this.tokenLength = tokenLength; } - #region IRelocationable implementation - void IRelocatable.SetStartLocation (TextLocation startLocation) + public override string GetText (CSharpFormattingOptions formattingOptions = null) + { + if (!(Role is TokenRole)) + return null; + return ((TokenRole)Role).Token; + } + + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitCSharpTokenNode (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) { - this.startLocation = startLocation; + return visitor.VisitCSharpTokenNode (this); } - #endregion - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + 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 index 46f528d46..e13bf334c 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs @@ -74,7 +74,6 @@ namespace ICSharpCode.NRefactory.CSharp return new UnaryOperatorExpression (UnaryOperatorType.Not, new ParenthesizedExpression (condition)); } } - if (condition is ConditionalExpression) { var cEx = condition as ConditionalExpression; cEx.Condition = InvertCondition (cEx.Condition); @@ -83,8 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp if (condition is PrimitiveExpression) { var pex = condition as PrimitiveExpression; if (pex.Value is bool) { - pex.Value = !((bool)pex.Value); - return pex; + return new PrimitiveExpression (!((bool)pex.Value)); } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs b/ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs index 3f3f0d08e..04dec11e7 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs @@ -28,6 +28,10 @@ using System.Collections.Generic; using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.CSharp.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; +using System.Threading; +using Mono.CSharp; +using System.IO; +using ICSharpCode.NRefactory.Editor; namespace ICSharpCode.NRefactory.CSharp { @@ -41,10 +45,22 @@ namespace ICSharpCode.NRefactory.CSharp } } + string fileName; + /// /// Gets/Sets the file name of this compilation unit. /// - public string FileName { get; set; } + public string FileName { + get { return fileName; } + set { + ThrowIfFrozen(); + fileName = value; + } + } + + public AstNodeCollection Members { + get { return GetChildrenByRole(MemberRole); } + } List errors = new List (); @@ -68,17 +84,18 @@ namespace ICSharpCode.NRefactory.CSharp { } - public IEnumerable GetTypes (bool includeInnerTypes = false) + public IEnumerable GetTypes(bool includeInnerTypes = false) { Stack nodeStack = new Stack (); - nodeStack.Push (this); + nodeStack.Push(this); while (nodeStack.Count > 0) { - var curNode = nodeStack.Pop (); - if (curNode is TypeDeclaration) + 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))) + (child.Role != Roles.TypeMemberRole || (child is TypeDeclaration && includeInnerTypes))) nodeStack.Push (child); } } @@ -90,7 +107,17 @@ namespace ICSharpCode.NRefactory.CSharp return o != null && GetChildrenByRole(MemberRole).DoMatch(o.GetChildrenByRole(MemberRole), match); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitCompilationUnit (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitCompilationUnit (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCompilationUnit (this, data); } @@ -98,14 +125,45 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Converts this compilation unit into a parsed file that can be stored in the type system. /// - public CSharpParsedFile ToTypeSystem() + public CSharpParsedFile ToTypeSystem () { - if (string.IsNullOrEmpty(this.FileName)) - throw new InvalidOperationException("Cannot use ToTypeSystem() on a compilation unit without file name."); - var v = new TypeSystemConvertVisitor(this.FileName); - v.VisitCompilationUnit(this, null); + if (string.IsNullOrEmpty (this.FileName)) + throw new InvalidOperationException ("Cannot use ToTypeSystem() on a compilation unit without file name."); + var v = new TypeSystemConvertVisitor (this.FileName); + v.VisitCompilationUnit (this); return v.ParsedFile; } + + public static CompilationUnit Parse (string text, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) + { + var parser = new CSharpParser (); + if (settings != null) + parser.CompilerSettings = settings; + return parser.Parse (text, fileName); + } + + public static CompilationUnit Parse (TextReader reader, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) + { + var parser = new CSharpParser (); + if (settings != null) + parser.CompilerSettings = settings; + return parser.Parse (reader, fileName, 0); + } + + public static CompilationUnit Parse (Stream stream, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) + { + var parser = new CSharpParser (); + if (settings != null) + parser.CompilerSettings = settings; + return parser.Parse (stream, fileName, 0); + } + + public static CompilationUnit Parse (ITextSource textSource, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) + { + var parser = new CSharpParser (); + if (settings != null) + parser.CompilerSettings = settings; + return parser.Parse (textSource, fileName, 0); + } } } - diff --git a/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs b/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs index 0ac460547..845f189d7 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs @@ -33,8 +33,8 @@ namespace ICSharpCode.NRefactory.CSharp { public class ComposedType : AstType { - public static readonly Role NullableRole = new Role("Nullable", CSharpTokenNode.Null); - public static readonly Role PointerRole = new Role("Pointer", CSharpTokenNode.Null); + public static readonly TokenRole NullableRole = new TokenRole("?"); + public static readonly TokenRole PointerRole = new TokenRole("*"); public static readonly Role ArraySpecifierRole = new Role("ArraySpecifier"); public AstType BaseType { @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.CSharp return !GetChildByRole(NullableRole).IsNull; } set { - SetChildByRole(NullableRole, value ? new CSharpTokenNode(TextLocation.Empty, 1) : null); + SetChildByRole(NullableRole, value ? new CSharpTokenNode(TextLocation.Empty) : null); } } @@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.CSharp d--; } while (d < value) { - InsertChildBefore(GetChildByRole(PointerRole), new CSharpTokenNode(TextLocation.Empty, 1), PointerRole); + InsertChildBefore(GetChildByRole(PointerRole), new CSharpTokenNode(TextLocation.Empty), PointerRole); d++; } } @@ -74,7 +74,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (ArraySpecifierRole); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitComposedType (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitComposedType (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitComposedType (this, data); } @@ -166,7 +176,7 @@ namespace ICSharpCode.NRefactory.CSharp d--; } while (d < value) { - InsertChildBefore(GetChildByRole(Roles.Comma), new CSharpTokenNode(TextLocation.Empty, 1), Roles.Comma); + InsertChildBefore(GetChildByRole(Roles.Comma), new CSharpTokenNode(TextLocation.Empty), Roles.Comma); d++; } } @@ -176,7 +186,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RBracket); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitArraySpecifier (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitArraySpecifier (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitArraySpecifier(this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs b/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs index ac04c5111..68bce6c35 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs @@ -28,6 +28,1201 @@ using System; namespace ICSharpCode.NRefactory.CSharp { + /// + /// AST visitor with a default implementation that visits all node depth-first. + /// + public abstract class DepthFirstAstVisitor : IAstVisitor + { + protected virtual void VisitChildren (AstNode node) + { + 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); + } + } + + public virtual void VisitCompilationUnit (CompilationUnit unit) + { + VisitChildren (unit); + } + + public virtual void VisitComment(Comment comment) + { + VisitChildren(comment); + } + + public virtual void VisitNewLine(NewLineNode newLineNode) + { + VisitChildren(newLineNode); + } + + public virtual void VisitWhitespace(WhitespaceNode whitespaceNode) + { + VisitChildren(whitespaceNode); + } + + public virtual void VisitText(TextNode textNode) + { + VisitChildren(textNode); + } + + public virtual void VisitDocumentationReference (DocumentationReference documentationReference) + { + VisitChildren (documentationReference); + } + + public virtual void VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective) + { + VisitChildren (preProcessorDirective); + } + + public virtual void VisitIdentifier (Identifier identifier) + { + VisitChildren (identifier); + } + + public virtual void VisitCSharpTokenNode (CSharpTokenNode token) + { + VisitChildren (token); + } + + public virtual void VisitPrimitiveType (PrimitiveType primitiveType) + { + VisitChildren (primitiveType); + } + + public virtual void VisitComposedType (ComposedType composedType) + { + VisitChildren (composedType); + } + + public virtual void VisitSimpleType(SimpleType simpleType) + { + VisitChildren (simpleType); + } + + public virtual void VisitMemberType(MemberType memberType) + { + VisitChildren (memberType); + } + + public virtual void VisitAttribute (Attribute attribute) + { + VisitChildren (attribute); + } + + public virtual void VisitAttributeSection (AttributeSection attributeSection) + { + VisitChildren (attributeSection); + } + + public virtual void VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration) + { + VisitChildren (delegateDeclaration); + } + + public virtual void VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration) + { + VisitChildren (namespaceDeclaration); + } + + public virtual void VisitTypeDeclaration (TypeDeclaration typeDeclaration) + { + VisitChildren (typeDeclaration); + } + + public virtual void VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration) + { + VisitChildren (typeParameterDeclaration); + } + + public virtual void VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration) + { + VisitChildren (enumMemberDeclaration); + } + + public virtual void VisitUsingDeclaration (UsingDeclaration usingDeclaration) + { + VisitChildren (usingDeclaration); + } + + public virtual void VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration) + { + VisitChildren (usingDeclaration); + } + + public virtual void VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration) + { + VisitChildren (externAliasDeclaration); + } + + public virtual void VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration) + { + VisitChildren (constructorDeclaration); + } + + public virtual void VisitConstructorInitializer (ConstructorInitializer constructorInitializer) + { + VisitChildren (constructorInitializer); + } + + public virtual void VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration) + { + VisitChildren (destructorDeclaration); + } + + public virtual void VisitEventDeclaration (EventDeclaration eventDeclaration) + { + VisitChildren (eventDeclaration); + } + + public virtual void VisitCustomEventDeclaration (CustomEventDeclaration eventDeclaration) + { + VisitChildren (eventDeclaration); + } + + public virtual void VisitFieldDeclaration (FieldDeclaration fieldDeclaration) + { + VisitChildren (fieldDeclaration); + } + + public virtual void VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration) + { + VisitChildren (fixedFieldDeclaration); + } + + public virtual void VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer) + { + VisitChildren (fixedVariableInitializer); + } + + public virtual void VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration) + { + VisitChildren (indexerDeclaration); + } + + public virtual void VisitMethodDeclaration (MethodDeclaration methodDeclaration) + { + VisitChildren (methodDeclaration); + } + + public virtual void VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration) + { + VisitChildren (operatorDeclaration); + } + + public virtual void VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration) + { + VisitChildren (propertyDeclaration); + } + + public virtual void VisitAccessor (Accessor accessor) + { + VisitChildren (accessor); + } + + public virtual void VisitVariableInitializer (VariableInitializer variableInitializer) + { + VisitChildren (variableInitializer); + } + + public virtual void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration) + { + VisitChildren (parameterDeclaration); + } + + public virtual void VisitConstraint (Constraint constraint) + { + VisitChildren (constraint); + } + + public virtual void VisitBlockStatement (BlockStatement blockStatement) + { + VisitChildren (blockStatement); + } + + public virtual void VisitExpressionStatement (ExpressionStatement expressionStatement) + { + VisitChildren (expressionStatement); + } + + public virtual void VisitBreakStatement (BreakStatement breakStatement) + { + VisitChildren (breakStatement); + } + + public virtual void VisitCheckedStatement (CheckedStatement checkedStatement) + { + VisitChildren (checkedStatement); + } + + public virtual void VisitContinueStatement (ContinueStatement continueStatement) + { + VisitChildren (continueStatement); + } + + public virtual void VisitDoWhileStatement (DoWhileStatement doWhileStatement) + { + VisitChildren (doWhileStatement); + } + + public virtual void VisitEmptyStatement (EmptyStatement emptyStatement) + { + VisitChildren (emptyStatement); + } + + public virtual void VisitFixedStatement (FixedStatement fixedStatement) + { + VisitChildren (fixedStatement); + } + + public virtual void VisitForeachStatement (ForeachStatement foreachStatement) + { + VisitChildren (foreachStatement); + } + + public virtual void VisitForStatement (ForStatement forStatement) + { + VisitChildren (forStatement); + } + + public virtual void VisitGotoCaseStatement (GotoCaseStatement gotoCaseStatement) + { + VisitChildren (gotoCaseStatement); + } + + public virtual void VisitGotoDefaultStatement (GotoDefaultStatement gotoDefaultStatement) + { + VisitChildren (gotoDefaultStatement); + } + + public virtual void VisitGotoStatement (GotoStatement gotoStatement) + { + VisitChildren (gotoStatement); + } + + public virtual void VisitIfElseStatement (IfElseStatement ifElseStatement) + { + VisitChildren (ifElseStatement); + } + + public virtual void VisitLabelStatement (LabelStatement labelStatement) + { + VisitChildren (labelStatement); + } + + public virtual void VisitLockStatement (LockStatement lockStatement) + { + VisitChildren (lockStatement); + } + + public virtual void VisitReturnStatement (ReturnStatement returnStatement) + { + VisitChildren (returnStatement); + } + + public virtual void VisitSwitchStatement (SwitchStatement switchStatement) + { + VisitChildren (switchStatement); + } + + public virtual void VisitSwitchSection (SwitchSection switchSection) + { + VisitChildren (switchSection); + } + + public virtual void VisitCaseLabel (CaseLabel caseLabel) + { + VisitChildren (caseLabel); + } + + public virtual void VisitThrowStatement (ThrowStatement throwStatement) + { + VisitChildren (throwStatement); + } + + public virtual void VisitTryCatchStatement (TryCatchStatement tryCatchStatement) + { + VisitChildren (tryCatchStatement); + } + + public virtual void VisitCatchClause (CatchClause catchClause) + { + VisitChildren (catchClause); + } + + public virtual void VisitUncheckedStatement (UncheckedStatement uncheckedStatement) + { + VisitChildren (uncheckedStatement); + } + + public virtual void VisitUnsafeStatement (UnsafeStatement unsafeStatement) + { + VisitChildren (unsafeStatement); + } + + public virtual void VisitUsingStatement (UsingStatement usingStatement) + { + VisitChildren (usingStatement); + } + + public virtual void VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement) + { + VisitChildren (variableDeclarationStatement); + } + + public virtual void VisitWhileStatement (WhileStatement whileStatement) + { + VisitChildren (whileStatement); + } + + public virtual void VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement) + { + VisitChildren (yieldBreakStatement); + } + + public virtual void VisitYieldReturnStatement (YieldReturnStatement yieldReturnStatement) + { + VisitChildren (yieldReturnStatement); + } + + public virtual void VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression) + { + VisitChildren (anonymousMethodExpression); + } + + public virtual void VisitLambdaExpression (LambdaExpression lambdaExpression) + { + VisitChildren (lambdaExpression); + } + + public virtual void VisitAssignmentExpression (AssignmentExpression assignmentExpression) + { + VisitChildren (assignmentExpression); + } + + public virtual void VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression) + { + VisitChildren (baseReferenceExpression); + } + + public virtual void VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression) + { + VisitChildren (binaryOperatorExpression); + } + + public virtual void VisitCastExpression (CastExpression castExpression) + { + VisitChildren (castExpression); + } + + public virtual void VisitCheckedExpression (CheckedExpression checkedExpression) + { + VisitChildren (checkedExpression); + } + + public virtual void VisitConditionalExpression (ConditionalExpression conditionalExpression) + { + VisitChildren (conditionalExpression); + } + + public virtual void VisitIdentifierExpression (IdentifierExpression identifierExpression) + { + VisitChildren (identifierExpression); + } + + public virtual void VisitIndexerExpression (IndexerExpression indexerExpression) + { + VisitChildren (indexerExpression); + } + + public virtual void VisitInvocationExpression (InvocationExpression invocationExpression) + { + VisitChildren (invocationExpression); + } + + public virtual void VisitDirectionExpression (DirectionExpression directionExpression) + { + VisitChildren (directionExpression); + } + + public virtual void VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression) + { + VisitChildren (memberReferenceExpression); + } + + public virtual void VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression) + { + VisitChildren (nullReferenceExpression); + } + + public virtual void VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression) + { + VisitChildren (objectCreateExpression); + } + + public virtual void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression) + { + VisitChildren (anonymousTypeCreateExpression); + } + + public virtual void VisitArrayCreateExpression (ArrayCreateExpression arrayCreateExpression) + { + VisitChildren (arrayCreateExpression); + } + + public virtual void VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression) + { + VisitChildren (parenthesizedExpression); + } + + public virtual void VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression) + { + VisitChildren (pointerReferenceExpression); + } + + public virtual void VisitPrimitiveExpression(PrimitiveExpression primitiveExpression) + { + VisitChildren (primitiveExpression); + } + + public virtual void VisitSizeOfExpression (SizeOfExpression sizeOfExpression) + { + VisitChildren (sizeOfExpression); + } + + public virtual void VisitStackAllocExpression (StackAllocExpression stackAllocExpression) + { + VisitChildren (stackAllocExpression); + } + + public virtual void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression) + { + VisitChildren (thisReferenceExpression); + } + + public virtual void VisitTypeOfExpression (TypeOfExpression typeOfExpression) + { + VisitChildren (typeOfExpression); + } + + public virtual void VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression) + { + VisitChildren (typeReferenceExpression); + } + + public virtual void VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression) + { + VisitChildren (unaryOperatorExpression); + } + + public virtual void VisitUncheckedExpression (UncheckedExpression uncheckedExpression) + { + VisitChildren (uncheckedExpression); + } + + public virtual void VisitQueryExpression(QueryExpression queryExpression) + { + VisitChildren (queryExpression); + } + + public virtual void VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause) + { + VisitChildren (queryContinuationClause); + } + + public virtual void VisitQueryFromClause(QueryFromClause queryFromClause) + { + VisitChildren (queryFromClause); + } + + public virtual void VisitQueryLetClause(QueryLetClause queryLetClause) + { + VisitChildren (queryLetClause); + } + + public virtual void VisitQueryWhereClause(QueryWhereClause queryWhereClause) + { + VisitChildren (queryWhereClause); + } + + public virtual void VisitQueryJoinClause(QueryJoinClause queryJoinClause) + { + VisitChildren (queryJoinClause); + } + + public virtual void VisitQueryOrderClause(QueryOrderClause queryOrderClause) + { + VisitChildren (queryOrderClause); + } + + public virtual void VisitQueryOrdering(QueryOrdering queryOrdering) + { + VisitChildren (queryOrdering); + } + + public virtual void VisitQuerySelectClause(QuerySelectClause querySelectClause) + { + VisitChildren (querySelectClause); + } + + public virtual void VisitQueryGroupClause(QueryGroupClause queryGroupClause) + { + VisitChildren (queryGroupClause); + } + + public virtual void VisitAsExpression (AsExpression asExpression) + { + VisitChildren (asExpression); + } + + public virtual void VisitIsExpression (IsExpression isExpression) + { + VisitChildren (isExpression); + } + + public virtual void VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression) + { + VisitChildren (defaultValueExpression); + } + + public virtual void VisitUndocumentedExpression (UndocumentedExpression undocumentedExpression) + { + VisitChildren (undocumentedExpression); + } + + public virtual void VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression) + { + VisitChildren (arrayInitializerExpression); + } + + public virtual void VisitArraySpecifier (ArraySpecifier arraySpecifier) + { + VisitChildren (arraySpecifier); + } + + public virtual void VisitNamedArgumentExpression (NamedArgumentExpression namedArgumentExpression) + { + VisitChildren (namedArgumentExpression); + } + + public virtual void VisitNamedExpression (NamedExpression namedExpression) + { + VisitChildren (namedExpression); + } + + public virtual void VisitEmptyExpression (EmptyExpression emptyExpression) + { + VisitChildren (emptyExpression); + } + + public virtual void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern) + { + VisitChildren (placeholder); + } + } + + /// + /// AST visitor with a default implementation that visits all node depth-first. + /// + public abstract class DepthFirstAstVisitor : IAstVisitor + { + protected virtual T VisitChildren (AstNode node) + { + 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); + } + return default (T); + } + + public virtual T VisitCompilationUnit (CompilationUnit unit) + { + return VisitChildren (unit); + } + + public virtual T VisitComment (Comment comment) + { + return VisitChildren (comment); + } + + public virtual T VisitNewLine(NewLineNode newLineNode) + { + return VisitChildren(newLineNode); + } + + public virtual T VisitWhitespace(WhitespaceNode whitespaceNode) + { + return VisitChildren(whitespaceNode); + } + + public virtual T VisitText(TextNode textNode) + { + return VisitChildren(textNode); + } + + public virtual T VisitDocumentationReference (DocumentationReference documentationReference) + { + return VisitChildren (documentationReference); + } + + public virtual T VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective) + { + return VisitChildren (preProcessorDirective); + } + + public virtual T VisitIdentifier (Identifier identifier) + { + return VisitChildren (identifier); + } + + public virtual T VisitCSharpTokenNode (CSharpTokenNode token) + { + return VisitChildren (token); + } + + public virtual T VisitPrimitiveType (PrimitiveType primitiveType) + { + return VisitChildren (primitiveType); + } + + public virtual T VisitComposedType (ComposedType composedType) + { + return VisitChildren (composedType); + } + + public virtual T VisitSimpleType(SimpleType simpleType) + { + return VisitChildren (simpleType); + } + + public virtual T VisitMemberType(MemberType memberType) + { + return VisitChildren (memberType); + } + + public virtual T VisitAttribute (Attribute attribute) + { + return VisitChildren (attribute); + } + + public virtual T VisitAttributeSection (AttributeSection attributeSection) + { + return VisitChildren (attributeSection); + } + + public virtual T VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration) + { + return VisitChildren (delegateDeclaration); + } + + public virtual T VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration) + { + return VisitChildren (namespaceDeclaration); + } + + public virtual T VisitTypeDeclaration (TypeDeclaration typeDeclaration) + { + return VisitChildren (typeDeclaration); + } + + public virtual T VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration) + { + return VisitChildren (typeParameterDeclaration); + } + + public virtual T VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration) + { + return VisitChildren (enumMemberDeclaration); + } + + public virtual T VisitUsingDeclaration (UsingDeclaration usingDeclaration) + { + return VisitChildren (usingDeclaration); + } + + public virtual T VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration) + { + return VisitChildren (usingDeclaration); + } + + public virtual T VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration) + { + return VisitChildren (externAliasDeclaration); + } + + public virtual T VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration) + { + return VisitChildren (constructorDeclaration); + } + + public virtual T VisitConstructorInitializer (ConstructorInitializer constructorInitializer) + { + return VisitChildren (constructorInitializer); + } + + public virtual T VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration) + { + return VisitChildren (destructorDeclaration); + } + + public virtual T VisitEventDeclaration (EventDeclaration eventDeclaration) + { + return VisitChildren (eventDeclaration); + } + + public virtual T VisitCustomEventDeclaration (CustomEventDeclaration eventDeclaration) + { + return VisitChildren (eventDeclaration); + } + + public virtual T VisitFieldDeclaration (FieldDeclaration fieldDeclaration) + { + return VisitChildren (fieldDeclaration); + } + + public virtual T VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration) + { + return VisitChildren (fixedFieldDeclaration); + } + + public virtual T VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer) + { + return VisitChildren (fixedVariableInitializer); + } + + public virtual T VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration) + { + return VisitChildren (indexerDeclaration); + } + + public virtual T VisitMethodDeclaration (MethodDeclaration methodDeclaration) + { + return VisitChildren (methodDeclaration); + } + + public virtual T VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration) + { + return VisitChildren (operatorDeclaration); + } + + public virtual T VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration) + { + return VisitChildren (propertyDeclaration); + } + + public virtual T VisitAccessor (Accessor accessor) + { + return VisitChildren (accessor); + } + + public virtual T VisitVariableInitializer (VariableInitializer variableInitializer) + { + return VisitChildren (variableInitializer); + } + + public virtual T VisitParameterDeclaration (ParameterDeclaration parameterDeclaration) + { + return VisitChildren (parameterDeclaration); + } + + public virtual T VisitConstraint (Constraint constraint) + { + return VisitChildren (constraint); + } + + public virtual T VisitBlockStatement (BlockStatement blockStatement) + { + return VisitChildren (blockStatement); + } + + public virtual T VisitExpressionStatement (ExpressionStatement expressionStatement) + { + return VisitChildren (expressionStatement); + } + + public virtual T VisitBreakStatement (BreakStatement breakStatement) + { + return VisitChildren (breakStatement); + } + + public virtual T VisitCheckedStatement (CheckedStatement checkedStatement) + { + return VisitChildren (checkedStatement); + } + + public virtual T VisitContinueStatement (ContinueStatement continueStatement) + { + return VisitChildren (continueStatement); + } + + public virtual T VisitDoWhileStatement (DoWhileStatement doWhileStatement) + { + return VisitChildren (doWhileStatement); + } + + public virtual T VisitEmptyStatement (EmptyStatement emptyStatement) + { + return VisitChildren (emptyStatement); + } + + public virtual T VisitFixedStatement (FixedStatement fixedStatement) + { + return VisitChildren (fixedStatement); + } + + public virtual T VisitForeachStatement (ForeachStatement foreachStatement) + { + return VisitChildren (foreachStatement); + } + + public virtual T VisitForStatement (ForStatement forStatement) + { + return VisitChildren (forStatement); + } + + public virtual T VisitGotoCaseStatement (GotoCaseStatement gotoCaseStatement) + { + return VisitChildren (gotoCaseStatement); + } + + public virtual T VisitGotoDefaultStatement (GotoDefaultStatement gotoDefaultStatement) + { + return VisitChildren (gotoDefaultStatement); + } + + public virtual T VisitGotoStatement (GotoStatement gotoStatement) + { + return VisitChildren (gotoStatement); + } + + public virtual T VisitIfElseStatement (IfElseStatement ifElseStatement) + { + return VisitChildren (ifElseStatement); + } + + public virtual T VisitLabelStatement (LabelStatement labelStatement) + { + return VisitChildren (labelStatement); + } + + public virtual T VisitLockStatement (LockStatement lockStatement) + { + return VisitChildren (lockStatement); + } + + public virtual T VisitReturnStatement (ReturnStatement returnStatement) + { + return VisitChildren (returnStatement); + } + + public virtual T VisitSwitchStatement (SwitchStatement switchStatement) + { + return VisitChildren (switchStatement); + } + + public virtual T VisitSwitchSection (SwitchSection switchSection) + { + return VisitChildren (switchSection); + } + + public virtual T VisitCaseLabel (CaseLabel caseLabel) + { + return VisitChildren (caseLabel); + } + + public virtual T VisitThrowStatement (ThrowStatement throwStatement) + { + return VisitChildren (throwStatement); + } + + public virtual T VisitTryCatchStatement (TryCatchStatement tryCatchStatement) + { + return VisitChildren (tryCatchStatement); + } + + public virtual T VisitCatchClause (CatchClause catchClause) + { + return VisitChildren (catchClause); + } + + public virtual T VisitUncheckedStatement (UncheckedStatement uncheckedStatement) + { + return VisitChildren (uncheckedStatement); + } + + public virtual T VisitUnsafeStatement (UnsafeStatement unsafeStatement) + { + return VisitChildren (unsafeStatement); + } + + public virtual T VisitUsingStatement (UsingStatement usingStatement) + { + return VisitChildren (usingStatement); + } + + public virtual T VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement) + { + return VisitChildren (variableDeclarationStatement); + } + + public virtual T VisitWhileStatement (WhileStatement whileStatement) + { + return VisitChildren (whileStatement); + } + + public virtual T VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement) + { + return VisitChildren (yieldBreakStatement); + } + + public virtual T VisitYieldReturnStatement (YieldReturnStatement yieldReturnStatement) + { + return VisitChildren (yieldReturnStatement); + } + + public virtual T VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression) + { + return VisitChildren (anonymousMethodExpression); + } + + public virtual T VisitLambdaExpression (LambdaExpression lambdaExpression) + { + return VisitChildren (lambdaExpression); + } + + public virtual T VisitAssignmentExpression (AssignmentExpression assignmentExpression) + { + return VisitChildren (assignmentExpression); + } + + public virtual T VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression) + { + return VisitChildren (baseReferenceExpression); + } + + public virtual T VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression) + { + return VisitChildren (binaryOperatorExpression); + } + + public virtual T VisitCastExpression (CastExpression castExpression) + { + return VisitChildren (castExpression); + } + + public virtual T VisitCheckedExpression (CheckedExpression checkedExpression) + { + return VisitChildren (checkedExpression); + } + + public virtual T VisitConditionalExpression (ConditionalExpression conditionalExpression) + { + return VisitChildren (conditionalExpression); + } + + public virtual T VisitIdentifierExpression (IdentifierExpression identifierExpression) + { + return VisitChildren (identifierExpression); + } + + public virtual T VisitIndexerExpression (IndexerExpression indexerExpression) + { + return VisitChildren (indexerExpression); + } + + public virtual T VisitInvocationExpression (InvocationExpression invocationExpression) + { + return VisitChildren (invocationExpression); + } + + public virtual T VisitDirectionExpression (DirectionExpression directionExpression) + { + return VisitChildren (directionExpression); + } + + public virtual T VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression) + { + return VisitChildren (memberReferenceExpression); + } + + public virtual T VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression) + { + return VisitChildren (nullReferenceExpression); + } + + public virtual T VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression) + { + return VisitChildren (objectCreateExpression); + } + + public virtual T VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression) + { + return VisitChildren (anonymousTypeCreateExpression); + } + + public virtual T VisitArrayCreateExpression (ArrayCreateExpression arrayCreateExpression) + { + return VisitChildren (arrayCreateExpression); + } + + public virtual T VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression) + { + return VisitChildren (parenthesizedExpression); + } + + public virtual T VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression) + { + return VisitChildren (pointerReferenceExpression); + } + + public virtual T VisitPrimitiveExpression(PrimitiveExpression primitiveExpression) + { + return VisitChildren (primitiveExpression); + } + + public virtual T VisitSizeOfExpression (SizeOfExpression sizeOfExpression) + { + return VisitChildren (sizeOfExpression); + } + + public virtual T VisitStackAllocExpression (StackAllocExpression stackAllocExpression) + { + return VisitChildren (stackAllocExpression); + } + + public virtual T VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression) + { + return VisitChildren (thisReferenceExpression); + } + + public virtual T VisitTypeOfExpression (TypeOfExpression typeOfExpression) + { + return VisitChildren (typeOfExpression); + } + + public virtual T VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression) + { + return VisitChildren (typeReferenceExpression); + } + + public virtual T VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression) + { + return VisitChildren (unaryOperatorExpression); + } + + public virtual T VisitUncheckedExpression (UncheckedExpression uncheckedExpression) + { + return VisitChildren (uncheckedExpression); + } + + public virtual T VisitQueryExpression(QueryExpression queryExpression) + { + return VisitChildren (queryExpression); + } + + public virtual T VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause) + { + return VisitChildren (queryContinuationClause); + } + + public virtual T VisitQueryFromClause(QueryFromClause queryFromClause) + { + return VisitChildren (queryFromClause); + } + + public virtual T VisitQueryLetClause(QueryLetClause queryLetClause) + { + return VisitChildren (queryLetClause); + } + + public virtual T VisitQueryWhereClause(QueryWhereClause queryWhereClause) + { + return VisitChildren (queryWhereClause); + } + + public virtual T VisitQueryJoinClause(QueryJoinClause queryJoinClause) + { + return VisitChildren (queryJoinClause); + } + + public virtual T VisitQueryOrderClause(QueryOrderClause queryOrderClause) + { + return VisitChildren (queryOrderClause); + } + + public virtual T VisitQueryOrdering(QueryOrdering queryOrdering) + { + return VisitChildren (queryOrdering); + } + + public virtual T VisitQuerySelectClause(QuerySelectClause querySelectClause) + { + return VisitChildren (querySelectClause); + } + + public virtual T VisitQueryGroupClause(QueryGroupClause queryGroupClause) + { + return VisitChildren (queryGroupClause); + } + + public virtual T VisitAsExpression (AsExpression asExpression) + { + return VisitChildren (asExpression); + } + + public virtual T VisitIsExpression (IsExpression isExpression) + { + return VisitChildren (isExpression); + } + + public virtual T VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression) + { + return VisitChildren (defaultValueExpression); + } + + public virtual T VisitUndocumentedExpression (UndocumentedExpression undocumentedExpression) + { + return VisitChildren (undocumentedExpression); + } + + public virtual T VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression) + { + return VisitChildren (arrayInitializerExpression); + } + + public virtual T VisitArraySpecifier (ArraySpecifier arraySpecifier) + { + return VisitChildren (arraySpecifier); + } + + public virtual T VisitNamedArgumentExpression (NamedArgumentExpression namedArgumentExpression) + { + return VisitChildren (namedArgumentExpression); + } + + public virtual T VisitNamedExpression (NamedExpression namedExpression) + { + return VisitChildren (namedExpression); + } + + public virtual T VisitEmptyExpression (EmptyExpression emptyExpression) + { + return VisitChildren (emptyExpression); + } + + public virtual T VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern) + { + return VisitChildren (placeholder); + } + } + /// /// AST visitor with a default implementation that visits all node depth-first. /// @@ -55,6 +1250,26 @@ namespace ICSharpCode.NRefactory.CSharp return VisitChildren (comment, data); } + public virtual S VisitNewLine(NewLineNode newLineNode, T data) + { + return VisitChildren(newLineNode, data); + } + + public virtual S VisitWhitespace(WhitespaceNode whitespaceNode, T data) + { + return VisitChildren(whitespaceNode, data); + } + + public virtual S VisitText(TextNode textNode, T data) + { + return VisitChildren(textNode, data); + } + + public virtual S VisitDocumentationReference (DocumentationReference documentationReference, T data) + { + return VisitChildren (documentationReference, data); + } + public virtual S VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective, T data) { return VisitChildren (preProcessorDirective, data); diff --git a/ICSharpCode.NRefactory.CSharp/Ast/DocumentationReference.cs b/ICSharpCode.NRefactory.CSharp/Ast/DocumentationReference.cs new file mode 100644 index 000000000..9c599ce6b --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Ast/DocumentationReference.cs @@ -0,0 +1,149 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// Represents a 'cref' reference in XML documentation. + /// + public class DocumentationReference : AstNode + { + public static readonly Role DeclaringTypeRole = new Role("DeclaringType", AstType.Null); + public static readonly Role ConversionOperatorReturnTypeRole = new Role("ConversionOperatorReturnType", AstType.Null); + + EntityType entityType; + OperatorType operatorType; + bool hasParameterList; + + /// + /// Gets/Sets the entity type. + /// Possible values are: + /// EntityType.Operator for operators, + /// EntityType.Indexer for indexers, + /// EntityType.TypeDefinition for references to primitive types, + /// and EntityType.None for everything else. + /// + public EntityType EntityType { + get { return entityType; } + set { + ThrowIfFrozen(); + entityType = value; + } + } + + /// + /// Gets/Sets the operator type. + /// This property is only used when EntityType==Operator. + /// + public OperatorType OperatorType { + get { return operatorType; } + set { + ThrowIfFrozen(); + operatorType = value; + } + } + + /// + /// Gets/Sets whether a parameter list was provided. + /// + public bool HasParameterList { + get { return hasParameterList; } + set { + ThrowIfFrozen(); + hasParameterList = value; + } + } + + public override NodeType NodeType { + get { return NodeType.Unknown; } + } + + /// + /// Gets/Sets the declaring type. + /// + public AstType DeclaringType { + get { return GetChildByRole(DeclaringTypeRole); } + set { SetChildByRole(DeclaringTypeRole, value); } + } + + /// + /// Gets/sets the member name. + /// This property is only used when EntityType==None. + /// + public string MemberName { + get { return GetChildByRole(Roles.Identifier).Name; } + set { SetChildByRole(Roles.Identifier, Identifier.Create(value)); } + } + + /// + /// Gets/Sets the return type of conversion operators. + /// This property is only used when EntityType==Operator and OperatorType is explicit or implicit. + /// + public AstType ConversionOperatorReturnType { + get { return GetChildByRole(ConversionOperatorReturnTypeRole); } + set { SetChildByRole(ConversionOperatorReturnTypeRole, value); } + } + + public AstNodeCollection TypeArguments { + get { return GetChildrenByRole (Roles.TypeArgument); } + } + + public AstNodeCollection Parameters { + get { return GetChildrenByRole (Roles.Parameter); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + DocumentationReference o = other as DocumentationReference; + if (!(o != null && this.EntityType == o.EntityType && this.HasParameterList == o.HasParameterList)) + return false; + if (this.EntityType == EntityType.Operator) { + if (this.OperatorType != o.OperatorType) + return false; + if (this.OperatorType == OperatorType.Implicit || this.OperatorType == OperatorType.Explicit) { + if (!this.ConversionOperatorReturnType.DoMatch(o.ConversionOperatorReturnType, match)) + return false; + } + } else if (this.EntityType == EntityType.None) { + if (!MatchString(this.MemberName, o.MemberName)) + return false; + if (!this.TypeArguments.DoMatch(o.TypeArguments, match)) + return false; + } + return this.Parameters.DoMatch(o.Parameters, match); + } + + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitDocumentationReference (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitDocumentationReference (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitDocumentationReference (this, data); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs index 53dfd7126..ee5f88521 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/ErrorNode.cs @@ -58,7 +58,16 @@ namespace ICSharpCode.NRefactory.CSharp { } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { // nothing return default (S); diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousMethodExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousMethodExpression.cs index 91fc0c417..07de16197 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousMethodExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousMethodExpression.cs @@ -34,17 +34,26 @@ namespace ICSharpCode.NRefactory.CSharp /// public class AnonymousMethodExpression : Expression { - public readonly static Role AsyncModifierRole = LambdaExpression.AsyncModifierRole; + public readonly static TokenRole DelegateKeywordRole = new TokenRole ("delegate"); + public readonly static TokenRole AsyncModifierRole = LambdaExpression.AsyncModifierRole; - public bool IsAsync { get; set; } + bool isAsync; + + public bool IsAsync { + get { return isAsync; } + set { ThrowIfFrozen(); isAsync = value; } + } // used to tell the difference between delegate {} and delegate () {} + bool hasParameterList; + public bool HasParameterList { - get; set; + get { return hasParameterList; } + set { ThrowIfFrozen(); hasParameterList = value; } } public CSharpTokenNode DelegateToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (DelegateKeywordRole); } } public CSharpTokenNode LParToken { @@ -82,7 +91,17 @@ namespace ICSharpCode.NRefactory.CSharp { } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitAnonymousMethodExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitAnonymousMethodExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitAnonymousMethodExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs index 496a2cfdb..944bf61f5 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs @@ -33,8 +33,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class AnonymousTypeCreateExpression : Expression { + public readonly static TokenRole NewKeywordRole = new TokenRole ("new"); + public CSharpTokenNode NewToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (NewKeywordRole); } } public CSharpTokenNode LParToken { @@ -64,7 +66,17 @@ namespace ICSharpCode.NRefactory.CSharp { } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitAnonymousTypeCreateExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitAnonymousTypeCreateExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitAnonymousTypeCreateExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayCreateExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayCreateExpression.cs index f9bee2a68..c9f1b2a62 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayCreateExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayCreateExpression.cs @@ -26,9 +26,14 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ArrayCreateExpression : Expression { + public readonly static TokenRole NewKeywordRole = new TokenRole ("new"); public readonly static Role AdditionalArraySpecifierRole = new Role("AdditionalArraySpecifier"); public readonly static Role InitializerRole = new Role("Initializer", ArrayInitializerExpression.Null); + public CSharpTokenNode NewToken { + get { return GetChildByRole (NewKeywordRole); } + } + public AstType Type { get { return GetChildByRole (Roles.Type); } set { SetChildByRole (Roles.Type, value); } @@ -51,7 +56,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (InitializerRole, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitArrayCreateExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitArrayCreateExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitArrayCreateExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs index d4858d8b2..ffb3712f2 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs @@ -58,7 +58,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -82,7 +91,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RBrace); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitArrayInitializerExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitArrayInitializerExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitArrayInitializerExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AsExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AsExpression.cs index 59f4652da..cf9cfb4f9 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AsExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AsExpression.cs @@ -31,13 +31,15 @@ namespace ICSharpCode.NRefactory.CSharp /// public class AsExpression : Expression { + public readonly static TokenRole AsKeywordRole = new TokenRole ("as"); + public Expression Expression { get { return GetChildByRole (Roles.Expression); } set { SetChildByRole(Roles.Expression, value); } } public CSharpTokenNode AsToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (AsKeywordRole); } } public AstType Type { @@ -55,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (type, Roles.Type); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitAsExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitAsExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitAsExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AssignmentExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AssignmentExpression.cs index c214eedc1..14021d323 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AssignmentExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/AssignmentExpression.cs @@ -36,9 +36,20 @@ namespace ICSharpCode.NRefactory.CSharp { // reuse roles from BinaryOperatorExpression public readonly static Role LeftRole = BinaryOperatorExpression.LeftRole; - public readonly static Role OperatorRole = BinaryOperatorExpression.OperatorRole; public readonly static Role RightRole = BinaryOperatorExpression.RightRole; + public readonly static TokenRole AssignRole = new TokenRole ("="); + public readonly static TokenRole AddRole = new TokenRole ("+="); + public readonly static TokenRole SubtractRole = new TokenRole ("-="); + public readonly static TokenRole MultiplyRole = new TokenRole ("*="); + public readonly static TokenRole DivideRole = new TokenRole ("/="); + public readonly static TokenRole ModulusRole = new TokenRole ("%="); + public readonly static TokenRole ShiftLeftRole = new TokenRole ("<<="); + public readonly static TokenRole ShiftRightRole = new TokenRole (">>="); + public readonly static TokenRole BitwiseAndRole = new TokenRole ("&="); + public readonly static TokenRole BitwiseOrRole = new TokenRole ("|="); + public readonly static TokenRole ExclusiveOrRole = new TokenRole ("^="); + public AssignmentExpression() { } @@ -67,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode OperatorToken { - get { return GetChildByRole (OperatorRole); } + get { return GetChildByRole (GetOperatorRole(Operator)); } } public Expression Right { @@ -75,7 +86,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole(RightRole, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitAssignmentExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitAssignmentExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitAssignmentExpression (this, data); } @@ -87,31 +108,31 @@ namespace ICSharpCode.NRefactory.CSharp && this.Left.DoMatch(o.Left, match) && this.Right.DoMatch(o.Right, match); } - public static string GetOperatorSymbol(AssignmentOperatorType op) + public static TokenRole GetOperatorRole(AssignmentOperatorType op) { switch (op) { case AssignmentOperatorType.Assign: - return "="; + return AssignRole; case AssignmentOperatorType.Add: - return "+="; + return AddRole; case AssignmentOperatorType.Subtract: - return "-="; + return SubtractRole; case AssignmentOperatorType.Multiply: - return "*="; + return MultiplyRole; case AssignmentOperatorType.Divide: - return "/="; + return DivideRole; case AssignmentOperatorType.Modulus: - return "%="; + return ModulusRole; case AssignmentOperatorType.ShiftLeft: - return "<<="; + return ShiftLeftRole; case AssignmentOperatorType.ShiftRight: - return ">>="; + return ShiftRightRole; case AssignmentOperatorType.BitwiseAnd: - return "&="; + return BitwiseAndRole; case AssignmentOperatorType.BitwiseOr: - return "|="; + return BitwiseOrRole; case AssignmentOperatorType.ExclusiveOr: - return "^="; + return ExclusiveOrRole; default: throw new NotSupportedException("Invalid value for AssignmentOperatorType"); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BaseReferenceExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BaseReferenceExpression.cs index 2214e3eaa..399c36c22 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BaseReferenceExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BaseReferenceExpression.cs @@ -47,7 +47,17 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitBaseReferenceExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitBaseReferenceExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitBaseReferenceExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BinaryOperatorExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BinaryOperatorExpression.cs index 6a2d94ed7..819d90f53 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BinaryOperatorExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/BinaryOperatorExpression.cs @@ -34,8 +34,27 @@ namespace ICSharpCode.NRefactory.CSharp /// public class BinaryOperatorExpression : Expression { + public readonly static TokenRole BitwiseAndRole = new TokenRole ("&"); + public readonly static TokenRole BitwiseOrRole = new TokenRole ("|"); + public readonly static TokenRole ConditionalAndRole = new TokenRole ("&&"); + public readonly static TokenRole ConditionalOrRole = new TokenRole ("||"); + public readonly static TokenRole ExclusiveOrRole = new TokenRole ("^"); + public readonly static TokenRole GreaterThanRole = new TokenRole (">"); + public readonly static TokenRole GreaterThanOrEqualRole = new TokenRole (">="); + public readonly static TokenRole EqualityRole = new TokenRole ("=="); + public readonly static TokenRole InEqualityRole = new TokenRole ("!="); + public readonly static TokenRole LessThanRole = new TokenRole ("<"); + public readonly static TokenRole LessThanOrEqualRole = new TokenRole ("<="); + public readonly static TokenRole AddRole = new TokenRole ("+"); + public readonly static TokenRole SubtractRole = new TokenRole ("-"); + public readonly static TokenRole MultiplyRole = new TokenRole ("*"); + public readonly static TokenRole DivideRole = new TokenRole ("/"); + public readonly static TokenRole ModulusRole = new TokenRole ("%"); + public readonly static TokenRole ShiftLeftRole = new TokenRole ("<<"); + public readonly static TokenRole ShiftRightRole = new TokenRole (">>"); + public readonly static TokenRole NullCoalescingRole = new TokenRole ("??"); + public readonly static Role LeftRole = new Role("Left", Expression.Null); - public readonly static Role OperatorRole = new Role("Operator", CSharpTokenNode.Null); public readonly static Role RightRole = new Role("Right", Expression.Null); public BinaryOperatorExpression() @@ -60,15 +79,25 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode OperatorToken { - get { return GetChildByRole (OperatorRole); } + get { return GetChildByRole (GetOperatorRole (Operator)); } } public Expression Right { get { return GetChildByRole (RightRole); } - set { SetChildByRole(RightRole, value); } + set { SetChildByRole (RightRole, value); } + } + + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitBinaryOperatorExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitBinaryOperatorExpression (this); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitBinaryOperatorExpression (this, data); } @@ -80,47 +109,47 @@ namespace ICSharpCode.NRefactory.CSharp && this.Left.DoMatch(o.Left, match) && this.Right.DoMatch(o.Right, match); } - public static string GetOperatorSymbol(BinaryOperatorType op) + public static TokenRole GetOperatorRole (BinaryOperatorType op) { switch (op) { case BinaryOperatorType.BitwiseAnd: - return "&"; + return BitwiseAndRole; case BinaryOperatorType.BitwiseOr: - return "|"; + return BitwiseOrRole; case BinaryOperatorType.ConditionalAnd: - return "&&"; + return ConditionalAndRole; case BinaryOperatorType.ConditionalOr: - return "||"; + return ConditionalOrRole; case BinaryOperatorType.ExclusiveOr: - return "^"; + return ExclusiveOrRole; case BinaryOperatorType.GreaterThan: - return ">"; + return GreaterThanRole; case BinaryOperatorType.GreaterThanOrEqual: - return ">="; + return GreaterThanOrEqualRole; case BinaryOperatorType.Equality: - return "=="; + return EqualityRole; case BinaryOperatorType.InEquality: - return "!="; + return InEqualityRole; case BinaryOperatorType.LessThan: - return "<"; + return LessThanRole; case BinaryOperatorType.LessThanOrEqual: - return "<="; + return LessThanOrEqualRole; case BinaryOperatorType.Add: - return "+"; + return AddRole; case BinaryOperatorType.Subtract: - return "-"; + return SubtractRole; case BinaryOperatorType.Multiply: - return "*"; + return MultiplyRole; case BinaryOperatorType.Divide: - return "/"; + return DivideRole; case BinaryOperatorType.Modulus: - return "%"; + return ModulusRole; case BinaryOperatorType.ShiftLeft: - return "<<"; + return ShiftLeftRole; case BinaryOperatorType.ShiftRight: - return ">>"; + return ShiftRightRole; case BinaryOperatorType.NullCoalescing: - return "??"; + return NullCoalescingRole; default: throw new NotSupportedException("Invalid value for BinaryOperatorType"); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/CastExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/CastExpression.cs index 6a3f1ceb9..96f41bcf3 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/CastExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/CastExpression.cs @@ -59,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (expression, Roles.Expression); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitCastExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitCastExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCastExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/CheckedExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/CheckedExpression.cs index f9fd9ab9d..66bdcb54d 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/CheckedExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/CheckedExpression.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class CheckedExpression : Expression { + public readonly static TokenRole CheckedKeywordRole = new TokenRole ("checked"); + public CSharpTokenNode CheckedToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (CheckedKeywordRole); } } public CSharpTokenNode LParToken { @@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (expression, Roles.Expression); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitCheckedExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitCheckedExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCheckedExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ConditionalExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ConditionalExpression.cs index 3a98ed7ed..fb2d5cb59 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ConditionalExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ConditionalExpression.cs @@ -32,9 +32,9 @@ namespace ICSharpCode.NRefactory.CSharp public class ConditionalExpression : Expression { public readonly static Role ConditionRole = Roles.Condition; - public readonly static Role QuestionMarkRole = new Role("QuestionMark", CSharpTokenNode.Null); + public readonly static TokenRole QuestionMarkRole = new TokenRole("?"); public readonly static Role TrueRole = new Role("True", Expression.Null); - public readonly static Role ColonRole = Roles.Colon; + public readonly static TokenRole ColonRole = Roles.Colon; public readonly static Role FalseRole = new Role("False", Expression.Null); public Expression Condition { @@ -71,7 +71,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (falseExpression, FalseRole); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitConditionalExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitConditionalExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitConditionalExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/DefaultValueExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/DefaultValueExpression.cs index 28fb4adc4..0aab343f3 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/DefaultValueExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/DefaultValueExpression.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class DefaultValueExpression : Expression { + public readonly static TokenRole DefaultKeywordRole = new TokenRole ("default"); + public CSharpTokenNode DefaultToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (DefaultKeywordRole); } } public CSharpTokenNode LParToken { @@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (type, Roles.Type); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitDefaultValueExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitDefaultValueExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitDefaultValueExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/DirectionExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/DirectionExpression.cs index d99182d33..a17c117bb 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/DirectionExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/DirectionExpression.cs @@ -38,13 +38,16 @@ namespace ICSharpCode.NRefactory.CSharp /// public class DirectionExpression : Expression { + public readonly static TokenRole RefKeywordRole = new TokenRole ("ref"); + public readonly static TokenRole OutKeywordRole = new TokenRole ("out"); + public FieldDirection FieldDirection { get; set; } public CSharpTokenNode FieldDirectionToken { - get { return GetChildByRole (Roles.Keyword); } + get { return FieldDirection == ICSharpCode.NRefactory.CSharp.FieldDirection.Ref ? GetChildByRole (RefKeywordRole) : GetChildByRole (OutKeywordRole); } } public Expression Expression { @@ -62,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (expression, Roles.Expression); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitDirectionExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitDirectionExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitDirectionExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/EmptyExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/EmptyExpression.cs index e333090eb..7dc5da777 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, IRelocatable + public class EmptyExpression : Expression { TextLocation location; @@ -55,14 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp this.location = location; } - #region IRelocationable implementation - void IRelocatable.SetStartLocation (TextLocation startLocation) + public override void AcceptVisitor (IAstVisitor visitor) { - this.location = startLocation; + visitor.VisitEmptyExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitEmptyExpression (this); } - #endregion - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitEmptyExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs index 0b8b0c727..bd6506c81 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ErrorExpression.cs @@ -1,4 +1,4 @@ -// +// // ErrorExpression.cs // // Author: @@ -52,8 +52,18 @@ namespace ICSharpCode.NRefactory.CSharp this.location = location; } + public override void AcceptVisitor (IAstVisitor visitor) + { + // nothing + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + // nothing + return default (T); + } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { // nothing return default(S); diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs index a74f6e591..d9bbed466 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/Expression.cs @@ -41,7 +41,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -72,7 +81,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder(this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder(this, child); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitPatternPlaceholder(this, child, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs index 892807fd3..1b567de94 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value)); } } @@ -60,7 +60,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (Roles.TypeArgument); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitIdentifierExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitIdentifierExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitIdentifierExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IndexerExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IndexerExpression.cs index 1d7d9a464..cbc80c2cf 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IndexerExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IndexerExpression.cs @@ -68,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp { } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitIndexerExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitIndexerExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitIndexerExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/InvocationExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/InvocationExpression.cs index b609ae886..ad768d541 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/InvocationExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/InvocationExpression.cs @@ -50,7 +50,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RPar); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitInvocationExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitInvocationExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitInvocationExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IsExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IsExpression.cs index d01fe48b1..163cef041 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IsExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IsExpression.cs @@ -31,13 +31,15 @@ namespace ICSharpCode.NRefactory.CSharp /// public class IsExpression : Expression { + public readonly static TokenRole IsKeywordRole = new TokenRole ("is"); + public Expression Expression { get { return GetChildByRole(Roles.Expression); } set { SetChildByRole(Roles.Expression, value); } } public CSharpTokenNode IsToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (IsKeywordRole); } } public AstType Type { @@ -45,7 +47,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole(Roles.Type, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitIsExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitIsExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitIsExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/LambdaExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/LambdaExpression.cs index 2b6a39d6b..001ffcb32 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/LambdaExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/LambdaExpression.cs @@ -33,11 +33,16 @@ namespace ICSharpCode.NRefactory.CSharp /// public class LambdaExpression : Expression { - public readonly static Role AsyncModifierRole = new Role("AsyncModifier", CSharpTokenNode.Null); - public readonly static Role ArrowRole = new Role("Arrow", CSharpTokenNode.Null); + public readonly static TokenRole AsyncModifierRole = new TokenRole ("async"); + public readonly static TokenRole ArrowRole = new TokenRole ("=>"); public static readonly Role BodyRole = new Role("Body", AstNode.Null); - public bool IsAsync { get; set; } + bool isAsync; + + public bool IsAsync { + get { return isAsync; } + set { ThrowIfFrozen(); isAsync = value; } + } public AstNodeCollection Parameters { get { return GetChildrenByRole (Roles.Parameter); } @@ -52,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (BodyRole, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitLambdaExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitLambdaExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitLambdaExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs index cf0c1808f..98bc50232 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs @@ -43,7 +43,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value)); } } @@ -87,7 +87,17 @@ namespace ICSharpCode.NRefactory.CSharp { } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitMemberReferenceExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitMemberReferenceExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitMemberReferenceExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs index 6b6303863..b7b8ada50 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value)); } } @@ -63,7 +63,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Expression, value); } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitNamedArgumentExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitNamedArgumentExpression (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitNamedArgumentExpression(this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs index eb57e75e1..663e3686d 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs @@ -51,7 +51,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value)); } } @@ -73,7 +73,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Expression, value); } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitNamedExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitNamedExpression (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitNamedExpression(this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NullReferenceExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NullReferenceExpression.cs index 3a92c97f3..a7a3ab7b5 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NullReferenceExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NullReferenceExpression.cs @@ -53,7 +53,17 @@ namespace ICSharpCode.NRefactory.CSharp this.location = location; } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitNullReferenceExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitNullReferenceExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitNullReferenceExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ObjectCreateExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ObjectCreateExpression.cs index 0e72c04b1..a9665f8c7 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ObjectCreateExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ObjectCreateExpression.cs @@ -33,10 +33,11 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ObjectCreateExpression : Expression { + public readonly static TokenRole NewKeywordRole = new TokenRole ("new"); public readonly static Role InitializerRole = ArrayCreateExpression.InitializerRole; public CSharpTokenNode NewToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (NewKeywordRole); } } public AstType Type { @@ -79,7 +80,17 @@ namespace ICSharpCode.NRefactory.CSharp { } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitObjectCreateExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitObjectCreateExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitObjectCreateExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ParenthesizedExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ParenthesizedExpression.cs index 596b6f968..7dddcb3fb 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ParenthesizedExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ParenthesizedExpression.cs @@ -53,7 +53,17 @@ namespace ICSharpCode.NRefactory.CSharp Expression = expr; } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitParenthesizedExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitParenthesizedExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitParenthesizedExpression (this, data); } @@ -81,7 +91,7 @@ namespace ICSharpCode.NRefactory.CSharp public static Expression UnpackParenthesizedExpression(Expression expr) { while (ActsAsParenthesizedExpression(expr)) - expr = expr.GetChildByRole(ParenthesizedExpression.Roles.Expression); + expr = expr.GetChildByRole(Roles.Expression); return expr; } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs index a1b7f051f..a7152fd1d 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs @@ -33,19 +33,23 @@ namespace ICSharpCode.NRefactory.CSharp /// public class PointerReferenceExpression : Expression { - public readonly static Role ArrowRole = new Role("Arrow", CSharpTokenNode.Null); + public readonly static TokenRole ArrowRole = new TokenRole ("->"); public Expression Target { get { return GetChildByRole (Roles.TargetExpression); } set { SetChildByRole(Roles.TargetExpression, value); } } + public CSharpTokenNode ArrowToken { + get { return GetChildByRole (ArrowRole); } + } + public string MemberName { get { return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value)); } } @@ -53,7 +57,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (Roles.TypeArgument); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPointerReferenceExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPointerReferenceExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitPointerReferenceExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PrimitiveExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PrimitiveExpression.cs index 6e39fc277..9f867fe1e 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PrimitiveExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PrimitiveExpression.cs @@ -24,12 +24,14 @@ // 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 literal value. /// - public class PrimitiveExpression : Expression, IRelocatable + public class PrimitiveExpression : Expression { public static readonly object AnyValue = new object(); @@ -47,20 +49,30 @@ namespace ICSharpCode.NRefactory.CSharp } } + object value; + public object Value { - get; - set; + get { return this.value; } + set { + ThrowIfFrozen(); + this.value = value; + } } public string LiteralValue { - get { - return literalValue; + get { return literalValue; } + set { + if (value == null) + throw new ArgumentNullException(); + ThrowIfFrozen(); + literalValue = value; } } public PrimitiveExpression (object value) { this.Value = value; + this.literalValue = ""; } public PrimitiveExpression (object value, string literalValue) @@ -76,14 +88,17 @@ namespace ICSharpCode.NRefactory.CSharp this.literalValue = literalValue ?? ""; } - #region IRelocationable implementation - void IRelocatable.SetStartLocation (TextLocation startLocation) + public override void AcceptVisitor (IAstVisitor visitor) { - this.startLocation = startLocation; + visitor.VisitPrimitiveExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPrimitiveExpression (this); } - #endregion - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitPrimitiveExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/QueryExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/QueryExpression.cs index 5e7ffaa67..e5f36ae10 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/QueryExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/QueryExpression.cs @@ -36,7 +36,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -52,7 +61,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole(ClauseRole); } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryExpression (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitQueryExpression (this, data); } @@ -92,7 +111,7 @@ namespace ICSharpCode.NRefactory.CSharp public class QueryContinuationClause : QueryClause { public static readonly Role PrecedingQueryRole = new Role("PrecedingQuery", QueryExpression.Null); - public static readonly Role IntoKeywordRole = Roles.Keyword; + public static readonly TokenRole IntoKeywordRole = new TokenRole ("into"); public QueryExpression PrecedingQuery { get { return GetChildByRole(PrecedingQueryRole); } @@ -104,7 +123,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value)); } } @@ -112,7 +131,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Identifier); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryContinuationClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryContinuationClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQueryContinuationClause (this, data); } @@ -126,8 +155,8 @@ namespace ICSharpCode.NRefactory.CSharp public class QueryFromClause : QueryClause { - public static readonly Role FromKeywordRole = Roles.Keyword; - public static readonly Role InKeywordRole = Roles.InKeyword; + public static readonly TokenRole FromKeywordRole = new TokenRole ("from"); + public static readonly TokenRole InKeywordRole = new TokenRole ("in"); public AstType Type { get { return GetChildByRole (Roles.Type); } @@ -139,7 +168,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value)); } } @@ -152,7 +181,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Expression, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryFromClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryFromClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQueryFromClause (this, data); } @@ -167,8 +206,10 @@ namespace ICSharpCode.NRefactory.CSharp public class QueryLetClause : QueryClause { + public readonly static TokenRole LetKeywordRole = new TokenRole ("let"); + public CSharpTokenNode LetKeyword { - get { return GetChildByRole(Roles.Keyword); } + get { return GetChildByRole(LetKeywordRole); } } public string Identifier { @@ -176,7 +217,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole(Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value)); } } @@ -193,7 +234,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole(Roles.Expression, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryLetClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryLetClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQueryLetClause (this, data); } @@ -208,8 +259,10 @@ namespace ICSharpCode.NRefactory.CSharp public class QueryWhereClause : QueryClause { + public readonly static TokenRole WhereKeywordRole = new TokenRole ("where"); + public CSharpTokenNode WhereKeyword { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (WhereKeywordRole); } } public Expression Condition { @@ -217,7 +270,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Condition, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryWhereClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryWhereClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQueryWhereClause (this, data); } @@ -234,16 +297,16 @@ namespace ICSharpCode.NRefactory.CSharp /// public class QueryJoinClause : QueryClause { - public static readonly Role JoinKeywordRole = Roles.Keyword; + public static readonly TokenRole JoinKeywordRole = new TokenRole ("join"); public static readonly Role TypeRole = Roles.Type; public static readonly Role JoinIdentifierRole = Roles.Identifier; - public static readonly Role InKeywordRole = Roles.InKeyword; + public static readonly TokenRole InKeywordRole = new TokenRole ("in"); public static readonly Role InExpressionRole = Roles.Expression; - public static readonly Role OnKeywordRole = new Role("OnKeyword", CSharpTokenNode.Null); + public static readonly TokenRole OnKeywordRole = new TokenRole ("on"); public static readonly Role OnExpressionRole = new Role("OnExpression", Expression.Null); - public static readonly Role EqualsKeywordRole = new Role("EqualsKeyword", CSharpTokenNode.Null); + public static readonly TokenRole EqualsKeywordRole = new TokenRole ("equals"); public static readonly Role EqualsExpressionRole = new Role("EqualsExpression", Expression.Null); - public static readonly Role IntoKeywordRole = new Role("IntoKeyword", CSharpTokenNode.Null); + public static readonly TokenRole IntoKeywordRole = new TokenRole ("into"); public static readonly Role IntoIdentifierRole = new Role("IntoIdentifier", Identifier.Null); public bool IsGroupJoin { @@ -264,7 +327,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole(JoinIdentifierRole).Name; } set { - SetChildByRole(JoinIdentifierRole, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(JoinIdentifierRole, Identifier.Create (value)); } } @@ -308,7 +371,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (IntoIdentifierRole).Name; } set { - SetChildByRole(IntoIdentifierRole, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(IntoIdentifierRole, Identifier.Create (value)); } } @@ -316,7 +379,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole(IntoIdentifierRole); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryJoinClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryJoinClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQueryJoinClause (this, data); } @@ -334,17 +407,28 @@ namespace ICSharpCode.NRefactory.CSharp public class QueryOrderClause : QueryClause { + public static readonly TokenRole OrderbyKeywordRole = new TokenRole ("orderby"); public static readonly Role OrderingRole = new Role("Ordering"); - public CSharpTokenNode Keyword { - get { return GetChildByRole (Roles.Keyword); } + public CSharpTokenNode OrderbyToken { + get { return GetChildByRole (OrderbyKeywordRole); } } public AstNodeCollection Orderings { get { return GetChildrenByRole (OrderingRole); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryOrderClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryOrderClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQueryOrderClause (this, data); } @@ -358,6 +442,9 @@ namespace ICSharpCode.NRefactory.CSharp public class QueryOrdering : AstNode { + public readonly static TokenRole AscendingKeywordRole = new TokenRole ("ascending"); + public readonly static TokenRole DescendingKeywordRole = new TokenRole ("descending"); + public override NodeType NodeType { get { return NodeType.Unknown; } } @@ -373,10 +460,20 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode DirectionToken { - get { return GetChildByRole (Roles.Keyword); } + get { return Direction == QueryOrderingDirection.Ascending ? GetChildByRole (AscendingKeywordRole) : GetChildByRole (DescendingKeywordRole); } + } + + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryOrdering (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryOrdering (this); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQueryOrdering (this, data); } @@ -397,8 +494,10 @@ namespace ICSharpCode.NRefactory.CSharp public class QuerySelectClause : QueryClause { + public readonly static TokenRole SelectKeywordRole = new TokenRole ("select"); + public CSharpTokenNode SelectKeyword { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (SelectKeywordRole); } } public Expression Expression { @@ -406,7 +505,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Expression, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQuerySelectClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQuerySelectClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQuerySelectClause (this, data); } @@ -420,9 +529,9 @@ namespace ICSharpCode.NRefactory.CSharp public class QueryGroupClause : QueryClause { - public static readonly Role GroupKeywordRole = Roles.Keyword; + public static readonly TokenRole GroupKeywordRole = new TokenRole ("group"); public static readonly Role ProjectionRole = new Role("Projection", Expression.Null); - public static readonly Role ByKeywordRole = new Role("ByKeyword", CSharpTokenNode.Null); + public static readonly TokenRole ByKeywordRole = new TokenRole ("by"); public static readonly Role KeyRole = new Role("Key", Expression.Null); public CSharpTokenNode GroupKeyword { @@ -443,7 +552,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (KeyRole, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitQueryGroupClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitQueryGroupClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitQueryGroupClause (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/SizeOfExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/SizeOfExpression.cs index eba12d3e0..8a794960c 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/SizeOfExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/SizeOfExpression.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class SizeOfExpression : Expression { + public readonly static TokenRole SizeofKeywordRole = new TokenRole ("sizeof"); + public CSharpTokenNode SizeOfToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (SizeofKeywordRole); } } public CSharpTokenNode LParToken { @@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (type, Roles.Type); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitSizeOfExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitSizeOfExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitSizeOfExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/StackAllocExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/StackAllocExpression.cs index f69d92286..ad9f58c1b 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/StackAllocExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/StackAllocExpression.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class StackAllocExpression : Expression { + public readonly static TokenRole StackallocKeywordRole = new TokenRole ("stackalloc"); + public CSharpTokenNode StackAllocToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (StackallocKeywordRole); } } public AstType Type { @@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RBracket); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitStackAllocExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitStackAllocExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitStackAllocExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ThisReferenceExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ThisReferenceExpression.cs index 7d2bd33eb..481ef6658 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ThisReferenceExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ThisReferenceExpression.cs @@ -46,8 +46,18 @@ namespace ICSharpCode.NRefactory.CSharp return new TextLocation (Location.Line, Location.Column + "this".Length); } } - - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitThisReferenceExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitThisReferenceExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitThisReferenceExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeOfExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeOfExpression.cs index 31e0b7bf3..fd2e93ab8 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeOfExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeOfExpression.cs @@ -32,8 +32,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class TypeOfExpression : Expression { + public readonly static TokenRole TypeofKeywordRole = new TokenRole ("typeof"); + public CSharpTokenNode TypeOfToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (TypeofKeywordRole); } } public CSharpTokenNode LParToken { @@ -58,7 +60,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (type, Roles.Type); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitTypeOfExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitTypeOfExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitTypeOfExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeReferenceExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeReferenceExpression.cs index c568f824a..129e1364a 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeReferenceExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/TypeReferenceExpression.cs @@ -31,7 +31,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole(Roles.Type, value); } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitTypeReferenceExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitTypeReferenceExpression (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitTypeReferenceExpression(this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UnaryOperatorExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UnaryOperatorExpression.cs index 4e6851d98..70d178728 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UnaryOperatorExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UnaryOperatorExpression.cs @@ -34,7 +34,15 @@ namespace ICSharpCode.NRefactory.CSharp /// public class UnaryOperatorExpression : Expression { - public readonly static Role OperatorRole = BinaryOperatorExpression.OperatorRole; + public readonly static TokenRole NotRole = new TokenRole ("!"); + public readonly static TokenRole BitNotRole = new TokenRole ("~"); + public readonly static TokenRole MinusRole = new TokenRole ("-"); + public readonly static TokenRole PlusRole = new TokenRole ("+"); + public readonly static TokenRole IncrementRole = new TokenRole ("++"); + public readonly static TokenRole DecrementRole = new TokenRole ("--"); + public readonly static TokenRole DereferenceRole = new TokenRole ("*"); + public readonly static TokenRole AddressOfRole = new TokenRole ("&"); + public readonly static TokenRole AwaitRole = new TokenRole ("await"); public UnaryOperatorExpression() { @@ -52,7 +60,7 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode OperatorToken { - get { return GetChildByRole (OperatorRole); } + get { return GetChildByRole (GetOperatorRole (Operator)); } } public Expression Expression { @@ -60,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Expression, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitUnaryOperatorExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitUnaryOperatorExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitUnaryOperatorExpression (this, data); } @@ -72,29 +90,29 @@ namespace ICSharpCode.NRefactory.CSharp && this.Expression.DoMatch(o.Expression, match); } - public static string GetOperatorSymbol(UnaryOperatorType op) + public static TokenRole GetOperatorRole(UnaryOperatorType op) { switch (op) { case UnaryOperatorType.Not: - return "!"; + return NotRole; case UnaryOperatorType.BitNot: - return "~"; + return BitNotRole; case UnaryOperatorType.Minus: - return "-"; + return MinusRole; case UnaryOperatorType.Plus: - return "+"; + return PlusRole; case UnaryOperatorType.Increment: case UnaryOperatorType.PostIncrement: - return "++"; + return IncrementRole; case UnaryOperatorType.PostDecrement: case UnaryOperatorType.Decrement: - return "--"; + return DecrementRole; case UnaryOperatorType.Dereference: - return "*"; + return DereferenceRole; case UnaryOperatorType.AddressOf: - return "&"; + return AddressOfRole; case UnaryOperatorType.Await: - return "await"; + return AwaitRole; default: throw new NotSupportedException("Invalid value for UnaryOperatorType"); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UncheckedExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UncheckedExpression.cs index 6bd835775..5b8686a26 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UncheckedExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UncheckedExpression.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class UncheckedExpression : Expression { + public readonly static TokenRole UncheckedKeywordRole = new TokenRole ("unchecked"); + public CSharpTokenNode UncheckedToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (UncheckedKeywordRole); } } public CSharpTokenNode LParToken { @@ -57,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (expression, Roles.Expression); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitUncheckedExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitUncheckedExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitUncheckedExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UndocumentedExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UndocumentedExpression.cs index 3a6d62855..0efc0d70f 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UndocumentedExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/UndocumentedExpression.cs @@ -42,12 +42,30 @@ namespace ICSharpCode.NRefactory.CSharp /// public class UndocumentedExpression : Expression { + public readonly static TokenRole ArglistKeywordRole = new TokenRole ("__arglist"); + public readonly static TokenRole RefvalueKeywordRole = new TokenRole ("__refvalue"); + public readonly static TokenRole ReftypeKeywordRole = new TokenRole ("__reftype"); + public readonly static TokenRole MakerefKeywordRole = new TokenRole ("__makeref"); + public UndocumentedExpressionType UndocumentedExpressionType { get; set; } public CSharpTokenNode UndocumentedToken { - get { return GetChildByRole (Roles.Keyword); } + get { + switch (UndocumentedExpressionType) { + case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.ArgListAccess: + case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.ArgList: + return GetChildByRole (ArglistKeywordRole); + case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.RefValue: + return GetChildByRole (RefvalueKeywordRole); + case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.RefType: + return GetChildByRole (ReftypeKeywordRole); + case ICSharpCode.NRefactory.CSharp.UndocumentedExpressionType.MakeRef: + return GetChildByRole (MakerefKeywordRole); + } + return CSharpTokenNode.Null; + } } public CSharpTokenNode LParToken { @@ -62,7 +80,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RPar); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitUndocumentedExpression (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitUndocumentedExpression (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitUndocumentedExpression (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Attribute.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Attribute.cs index 433510338..74fd9d7e3 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Attribute.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Attribute.cs @@ -54,7 +54,17 @@ namespace ICSharpCode.NRefactory.CSharp set; } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitAttribute (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitAttribute (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitAttribute (this, data); } @@ -69,9 +79,8 @@ namespace ICSharpCode.NRefactory.CSharp { if (IsNull) return "Null"; - var w = new System.IO.StringWriter (); - AcceptVisitor (new CSharpOutputVisitor (w, new CSharpFormattingOptions ()), null); - return w.ToString (); + else + return GetText(); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/AttributeSection.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/AttributeSection.cs index cf142593c..cd065b9c1 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/AttributeSection.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/AttributeSection.cs @@ -54,7 +54,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder (this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder (this, child); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitPatternPlaceholder(this, child, data); } @@ -71,9 +81,6 @@ namespace ICSharpCode.NRefactory.CSharp } #endregion - public static readonly Role AttributeRole = new Role("Attribute"); - public static readonly Role TargetRole = new Role("Target", CSharpTokenNode.Null); - public override NodeType NodeType { get { return NodeType.Unknown; @@ -89,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value)); } } @@ -103,14 +110,24 @@ namespace ICSharpCode.NRefactory.CSharp } public AstNodeCollection Attributes { - get { return base.GetChildrenByRole (AttributeRole); } + get { return base.GetChildrenByRole (Roles.Attribute); } } public CSharpTokenNode RBracketToken { get { return GetChildByRole (Roles.RBracket); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitAttributeSection (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitAttributeSection (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitAttributeSection (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs index b0e8ab5f2..83c00c9bf 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Comment.cs @@ -43,10 +43,14 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Inactive code (code in non-taken "#if") /// - InactiveCode + InactiveCode, + /// + /// "/** */" comment + /// + MultiLineDocumentation } - public class Comment : AstNode, IRelocatable + public class Comment : AstNode { public override NodeType NodeType { get { @@ -54,19 +58,25 @@ namespace ICSharpCode.NRefactory.CSharp } } + CommentType commentType; + public CommentType CommentType { - get; - set; + get { return commentType; } + set { ThrowIfFrozen(); commentType = value; } } + bool startsLine; + public bool StartsLine { - get; - set; + get { return startsLine; } + set { ThrowIfFrozen(); startsLine = value; } } + string content; + public string Content { - get; - set; + get { return content; } + set { ThrowIfFrozen(); content = value; } } TextLocation startLocation; @@ -96,16 +106,17 @@ namespace ICSharpCode.NRefactory.CSharp this.endLocation = endLocation; } - #region IRelocationable implementation - void IRelocatable.SetStartLocation (TextLocation startLocation) + public override void AcceptVisitor (IAstVisitor visitor) { - int lineDelta = startLocation.Line - this.startLocation.Line; - endLocation = new TextLocation (endLocation.Line + lineDelta, lineDelta != 0 ? endLocation.Column : endLocation.Column + startLocation.Column - this.startLocation.Column); - this.startLocation = startLocation; + visitor.VisitComment (this); } - #endregion - - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitComment (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitComment (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Constraint.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Constraint.cs index 4994c215c..cfd15f7af 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Constraint.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/Constraint.cs @@ -36,10 +36,6 @@ namespace ICSharpCode.NRefactory.CSharp /// public class Constraint : AstNode { - public readonly static Role ColonRole = TypeDeclaration.ColonRole; - public readonly static Role BaseTypeRole = TypeDeclaration.BaseTypeRole; - public readonly static Role TypeParameterRole = new Role ("TypeParameter", SimpleType.Null); - public override NodeType NodeType { get { return NodeType.Unknown; @@ -48,18 +44,29 @@ namespace ICSharpCode.NRefactory.CSharp public SimpleType TypeParameter { get { - return GetChildByRole (TypeParameterRole); + return GetChildByRole (Roles.ConstraintTypeParameter); } set { - SetChildByRole(TypeParameterRole, value); + SetChildByRole(Roles.ConstraintTypeParameter, value); } } public AstNodeCollection BaseTypes { - get { return GetChildrenByRole (BaseTypeRole); } + get { + return GetChildrenByRole(Roles.BaseType); } + } + + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitConstraint (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitConstraint (this); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitConstraint (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/DelegateDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/DelegateDeclaration.cs index c226d8ffd..088afa90b 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/DelegateDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/DelegateDeclaration.cs @@ -24,45 +24,27 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Collections.Generic; -using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { /// /// delegate ReturnType Name<TypeParameters>(Parameters) where Constraints; /// - public class DelegateDeclaration : AttributedNode + public class DelegateDeclaration : EntityDeclaration { public override NodeType NodeType { - get { - return NodeType.TypeDeclaration; - } + get { return NodeType.TypeDeclaration; } } - public AstType ReturnType { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole (Roles.Type, value); } + public override EntityType EntityType { + get { return EntityType.TypeDefinition; } } - public string Name { - get { - return GetChildByRole (Roles.Identifier).Name; - } - set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); - } + public CSharpTokenNode DelegateToken { + get { return GetChildByRole(Roles.DelegateKeyword); } } - - public Identifier NameToken { - get { - return GetChildByRole (Roles.Identifier); - } - set { - SetChildByRole (Roles.Identifier, value); - } - } - + public AstNodeCollection TypeParameters { get { return GetChildrenByRole (Roles.TypeParameter); } } @@ -83,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (Roles.Constraint); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitDelegateDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitDelegateDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitDelegateDeclaration (this, data); } @@ -91,8 +83,8 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { DelegateDeclaration o = other as DelegateDeclaration; - return o != null && this.MatchAttributesAndModifiers(o, match) - && this.ReturnType.DoMatch(o.ReturnType, match) && MatchString(this.Name, o.Name) + return o != null && MatchString(this.Name, o.Name) + && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) && this.TypeParameters.DoMatch(o.TypeParameters, match) && this.Parameters.DoMatch(o.Parameters, match) && this.Constraints.DoMatch(o.Constraints, match); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs index f238f1aa2..9404d417f 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/ExternAliasDeclaration.cs @@ -31,8 +31,6 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ExternAliasDeclaration : AstNode { - public static readonly Role AliasRole = new Role ("Alias", CSharpTokenNode.Null); - public override NodeType NodeType { get { return NodeType.Unknown; @@ -40,11 +38,11 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode ExternToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (Roles.ExternKeyword); } } public CSharpTokenNode AliasToken { - get { return GetChildByRole (AliasRole); } + get { return GetChildByRole (Roles.AliasKeyword); } } public string Name { @@ -52,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value)); } } @@ -69,7 +67,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitExternAliasDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitExternAliasDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitExternAliasDeclaration (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs index d8736adc4..01198222b 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs @@ -43,6 +43,10 @@ namespace ICSharpCode.NRefactory.CSharp } } + public CSharpTokenNode NamespaceToken { + get { return GetChildByRole (Roles.NamespaceKeyword); } + } + public string Name { get { StringBuilder builder = new StringBuilder (); @@ -54,7 +58,7 @@ namespace ICSharpCode.NRefactory.CSharp return builder.ToString (); } set { - GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => Identifier.Create (ident, TextLocation.Empty))); + GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => Identifier.Create (ident))); } } @@ -109,7 +113,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (child, MemberRole); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitNamespaceDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitNamespaceDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitNamespaceDeclaration (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NewLineNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NewLineNode.cs new file mode 100644 index 000000000..a2cba46c8 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NewLineNode.cs @@ -0,0 +1,132 @@ +using System; +namespace ICSharpCode.NRefactory.CSharp +{ + public enum NewLineType { + Unix, + Windows, + Mac + } + + /// + /// A New line node represents a line break in the text. + /// + public abstract class NewLineNode : AstNode + { + public override NodeType NodeType { + get { + return NodeType.Whitespace; + } + } + + public abstract NewLineType NewLineType { + get; + } + + TextLocation startLocation; + public override TextLocation StartLocation { + get { + return startLocation; + } + } + + public override TextLocation EndLocation { + get { + return new TextLocation (startLocation.Line + 1, 1); + } + } + + public NewLineNode() : this (TextLocation.Empty) + { + } + + public NewLineNode(TextLocation startLocation) + { + this.startLocation = startLocation; + } + + public override void AcceptVisitor(IAstVisitor visitor) + { + visitor.VisitNewLine (this); + } + + public override T AcceptVisitor(IAstVisitor visitor) + { + return visitor.VisitNewLine (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitNewLine (this, data); + } + } + + public class UnixNewLine : NewLineNode + { + public override NewLineType NewLineType { + get { + return NewLineType.Unix; + } + } + + public UnixNewLine() + { + } + + public UnixNewLine(TextLocation startLocation) : base (startLocation) + { + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + var o = other as UnixNewLine; + return o != null; + } + } + + public class WindowsNewLine : NewLineNode + { + public override NewLineType NewLineType { + get { + return NewLineType.Windows; + } + } + + public WindowsNewLine() + { + } + + public WindowsNewLine(TextLocation startLocation) : base (startLocation) + { + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + var o = other as WindowsNewLine; + return o != null; + } + } + + public class MacNewLine : NewLineNode + { + public override NewLineType NewLineType { + get { + return NewLineType.Mac; + } + } + + public MacNewLine() + { + } + + public MacNewLine(TextLocation startLocation) : base (startLocation) + { + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + var o = other as MacNewLine; + return o != null; + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs index 049755717..953f326c1 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp Line = 12 } - public class PreProcessorDirective : AstNode, IRelocatable + public class PreProcessorDirective : AstNode { public override NodeType NodeType { get { @@ -93,16 +93,17 @@ namespace ICSharpCode.NRefactory.CSharp this.endLocation = endLocation; } - #region IRelocationable implementation - void IRelocatable.SetStartLocation (TextLocation startLocation) + public override void AcceptVisitor (IAstVisitor visitor) { - int lineDelta = startLocation.Line - this.startLocation.Line; - endLocation = new TextLocation (endLocation.Line + lineDelta, lineDelta != 0 ? endLocation.Column : endLocation.Column + startLocation.Column - this.startLocation.Column); - this.startLocation = startLocation; + visitor.VisitPreProcessorDirective (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPreProcessorDirective (this); } - #endregion - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitPreProcessorDirective (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TextNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TextNode.cs new file mode 100644 index 000000000..4c7f9b942 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TextNode.cs @@ -0,0 +1,94 @@ +// +// TextNode.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin Inc. (http://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 +{ + /// + /// A text node contains text without syntactic or semantic information. + /// (non parseable part of a text) + /// + public class TextNode : AstNode + { + public override NodeType NodeType { + get { + return NodeType.Whitespace; + } + } + + public string Text { + get; + set; + } + + TextLocation startLocation; + public override TextLocation StartLocation { + get { + return startLocation; + } + } + + TextLocation endLocation; + public override TextLocation EndLocation { + get { + return endLocation; + } + } + + public TextNode(string text) : this (text, TextLocation.Empty, TextLocation.Empty) + { + } + + public TextNode(string text, TextLocation startLocation, TextLocation endLocation) + { + this.Text = text; + this.startLocation = startLocation; + this.endLocation = endLocation; + } + + public override void AcceptVisitor(IAstVisitor visitor) + { + visitor.VisitText (this); + } + + public override T AcceptVisitor(IAstVisitor visitor) + { + return visitor.VisitText (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitText (this, data); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + var o = other as TextNode; + return o != null && o.Text == Text; + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeDeclaration.cs index 018e0491e..d4ac6eaf6 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeDeclaration.cs @@ -41,66 +41,78 @@ namespace ICSharpCode.NRefactory.CSharp /// /// class Name<TypeParameters> : BaseTypes where Constraints; /// - public class TypeDeclaration : AttributedNode + public class TypeDeclaration : EntityDeclaration { - public readonly static Role ColonRole = Roles.Colon; - public readonly static Role BaseTypeRole = new Role("BaseType", AstType.Null); - public readonly static Role MemberRole = new Role("Member"); - public override NodeType NodeType { - get { - return NodeType.TypeDeclaration; - } + get { return NodeType.TypeDeclaration; } } - public ClassType ClassType { - get; - set; + public override EntityType EntityType { + get { return EntityType.TypeDefinition; } } - public string Name { + ClassType classType; + + public CSharpTokenNode TypeKeyword { get { - return GetChildByRole (Roles.Identifier).Name; - } - set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + switch (classType) { + case ClassType.Class: + return GetChildByRole(Roles.ClassKeyword); + case ClassType.Struct: + return GetChildByRole(Roles.StructKeyword); + case ClassType.Interface: + return GetChildByRole(Roles.InterfaceKeyword); + case ClassType.Enum: + return GetChildByRole(Roles.EnumKeyword); + default: + return CSharpTokenNode.Null; + } } } - public Identifier NameToken { - get { - return GetChildByRole (Roles.Identifier); - } + public ClassType ClassType { + get { return classType; } set { - SetChildByRole (Roles.Identifier, value); + ThrowIfFrozen(); + classType = value; } } - + public AstNodeCollection TypeParameters { get { return GetChildrenByRole (Roles.TypeParameter); } } public AstNodeCollection BaseTypes { - get { return GetChildrenByRole (BaseTypeRole); } + get { return GetChildrenByRole(Roles.BaseType); } } public AstNodeCollection Constraints { - get { return GetChildrenByRole (Roles.Constraint); } + get { return GetChildrenByRole(Roles.Constraint); } } public CSharpTokenNode LBraceToken { get { return GetChildByRole (Roles.LBrace); } } - public AstNodeCollection Members { - get { return GetChildrenByRole (MemberRole); } + public AstNodeCollection Members { + get { return GetChildrenByRole (Roles.TypeMemberRole); } } public CSharpTokenNode RBraceToken { get { return GetChildByRole (Roles.RBrace); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitTypeDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitTypeDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitTypeDeclaration (this, data); } @@ -108,8 +120,8 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { TypeDeclaration o = other as TypeDeclaration; - return o != null && this.ClassType == o.ClassType && this.MatchAttributesAndModifiers(o, match) - && MatchString(this.Name, o.Name) && this.TypeParameters.DoMatch(o.TypeParameters, match) + return o != null && this.ClassType == o.ClassType && MatchString(this.Name, o.Name) + && this.MatchAttributesAndModifiers(o, match) && this.TypeParameters.DoMatch(o.TypeParameters, match) && this.BaseTypes.DoMatch(o.BaseTypes, match) && this.Constraints.DoMatch(o.Constraints, match) && this.Members.DoMatch(o.Members, match); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs index d7a38e958..ede85f16a 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/TypeParameterDeclaration.cs @@ -30,8 +30,9 @@ namespace ICSharpCode.NRefactory.CSharp /// public class TypeParameterDeclaration : AstNode { - public static readonly Role AttributeRole = AttributedNode.AttributeRole; - public static readonly Role VarianceRole = new Role("Variance", CSharpTokenNode.Null); + public static readonly Role AttributeRole = EntityDeclaration.AttributeRole; + public static readonly TokenRole OutVarianceKeywordRole = new TokenRole ("out"); + public static readonly TokenRole InVarianceKeywordRole = new TokenRole ("in"); public override NodeType NodeType { get { return NodeType.Unknown; } @@ -41,8 +42,24 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (AttributeRole); } } + VarianceModifier variance; + public VarianceModifier Variance { - get; set; + get { return variance; } + set { ThrowIfFrozen(); variance = value; } + } + + public CSharpTokenNode VarianceToken { + get { + switch (Variance) { + case VarianceModifier.Covariant: + return GetChildByRole(OutVarianceKeywordRole); + case VarianceModifier.Contravariant: + return GetChildByRole(InVarianceKeywordRole); + default: + return CSharpTokenNode.Null; + } + } } public string Name { @@ -50,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value)); } } @@ -62,8 +79,27 @@ namespace ICSharpCode.NRefactory.CSharp SetChildByRole (Roles.Identifier, value); } } + + public TypeParameterDeclaration () + { + } + + public TypeParameterDeclaration (string name) + { + Name = name; + } + + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitTypeParameterDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitTypeParameterDeclaration (this); + } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitTypeParameterDeclaration(this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs index 8a69357c6..9924132d3 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs @@ -31,6 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp /// public class UsingAliasDeclaration : AstNode { + public static readonly TokenRole UsingKeywordRole = new TokenRole ("using"); public static readonly Role AliasRole = new Role("Alias", Identifier.Null); public static readonly Role ImportRole = UsingDeclaration.ImportRole; @@ -41,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode UsingToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (UsingKeywordRole); } } public string Alias { @@ -49,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (AliasRole).Name; } set { - SetChildByRole(AliasRole, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(AliasRole, Identifier.Create (value)); } } @@ -72,17 +73,27 @@ namespace ICSharpCode.NRefactory.CSharp public UsingAliasDeclaration (string alias, string nameSpace) { - AddChild (Identifier.Create (alias, TextLocation.Empty), AliasRole); + AddChild (Identifier.Create (alias), AliasRole); AddChild (new SimpleType (nameSpace), ImportRole); } public UsingAliasDeclaration (string alias, AstType import) { - AddChild (Identifier.Create (alias, TextLocation.Empty), AliasRole); + AddChild (Identifier.Create (alias), AliasRole); AddChild (import, ImportRole); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitUsingAliasDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitUsingAliasDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitUsingAliasDeclaration (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingDeclaration.cs index 31ae7ddfc..c5ae72351 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/UsingDeclaration.cs @@ -35,6 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp /// public class UsingDeclaration : AstNode { + public static readonly TokenRole UsingKeywordRole = new TokenRole ("using"); public static readonly Role ImportRole = new Role("Import", AstType.Null); public override NodeType NodeType { @@ -44,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode UsingToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (UsingKeywordRole); } } public AstType Import { @@ -74,7 +75,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (import, ImportRole); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitUsingDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitUsingDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitUsingDeclaration (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/WhitespaceNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/WhitespaceNode.cs new file mode 100644 index 000000000..c7e37f704 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/WhitespaceNode.cs @@ -0,0 +1,91 @@ +// +// WhitespaceNode.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin Inc. (http://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 +{ + /// + /// A Whitespace node contains only whitespaces. + /// + public class WhitespaceNode : AstNode + { + public override NodeType NodeType { + get { + return NodeType.Whitespace; + } + } + + public string WhiteSpaceText { + get; + set; + } + + TextLocation startLocation; + public override TextLocation StartLocation { + get { + return startLocation; + } + } + + public override TextLocation EndLocation { + get { + return new TextLocation (startLocation.Line, startLocation.Column + WhiteSpaceText.Length); + } + } + + public WhitespaceNode(string whiteSpaceText) : this (whiteSpaceText, TextLocation.Empty) + { + } + + public WhitespaceNode(string whiteSpaceText, TextLocation startLocation) + { + this.WhiteSpaceText = WhiteSpaceText; + this.startLocation = startLocation; + } + + public override void AcceptVisitor(IAstVisitor visitor) + { + visitor.VisitWhitespace (this); + } + + public override T AcceptVisitor(IAstVisitor visitor) + { + return visitor.VisitWhitespace (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitWhitespace (this, data); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + var o = other as WhitespaceNode; + return o != null && o.WhiteSpaceText == WhiteSpaceText; + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs b/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs index 00e804cce..58836e655 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs @@ -20,6 +20,268 @@ using System; namespace ICSharpCode.NRefactory.CSharp { + /// + /// AST visitor. + /// + public interface IAstVisitor + { + void VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression); + void VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression); + void VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression); + void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression); + void VisitAsExpression(AsExpression asExpression); + void VisitAssignmentExpression(AssignmentExpression assignmentExpression); + void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression); + void VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression); + void VisitCastExpression(CastExpression castExpression); + void VisitCheckedExpression(CheckedExpression checkedExpression); + void VisitConditionalExpression(ConditionalExpression conditionalExpression); + void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression); + void VisitDirectionExpression(DirectionExpression directionExpression); + void VisitIdentifierExpression(IdentifierExpression identifierExpression); + void VisitIndexerExpression(IndexerExpression indexerExpression); + void VisitInvocationExpression(InvocationExpression invocationExpression); + void VisitIsExpression(IsExpression isExpression); + void VisitLambdaExpression(LambdaExpression lambdaExpression); + void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression); + void VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression); + void VisitNamedExpression(NamedExpression namedExpression); + void VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression); + void VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression); + void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression); + void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression); + void VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression); + void VisitPrimitiveExpression(PrimitiveExpression primitiveExpression); + void VisitSizeOfExpression(SizeOfExpression sizeOfExpression); + void VisitStackAllocExpression(StackAllocExpression stackAllocExpression); + void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression); + void VisitTypeOfExpression(TypeOfExpression typeOfExpression); + void VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression); + void VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression); + void VisitUncheckedExpression(UncheckedExpression uncheckedExpression); + void VisitEmptyExpression (EmptyExpression emptyExpression); + + void VisitQueryExpression(QueryExpression queryExpression); + void VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause); + void VisitQueryFromClause(QueryFromClause queryFromClause); + void VisitQueryLetClause(QueryLetClause queryLetClause); + void VisitQueryWhereClause(QueryWhereClause queryWhereClause); + void VisitQueryJoinClause(QueryJoinClause queryJoinClause); + void VisitQueryOrderClause(QueryOrderClause queryOrderClause); + void VisitQueryOrdering(QueryOrdering queryOrdering); + void VisitQuerySelectClause(QuerySelectClause querySelectClause); + void VisitQueryGroupClause(QueryGroupClause queryGroupClause); + + void VisitAttribute(Attribute attribute); + void VisitAttributeSection(AttributeSection attributeSection); + void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration); + void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration); + void VisitTypeDeclaration(TypeDeclaration typeDeclaration); + void VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration); + void VisitUsingDeclaration(UsingDeclaration usingDeclaration); + void VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration); + + void VisitBlockStatement(BlockStatement blockStatement); + void VisitBreakStatement(BreakStatement breakStatement); + void VisitCheckedStatement(CheckedStatement checkedStatement); + void VisitContinueStatement(ContinueStatement continueStatement); + void VisitDoWhileStatement(DoWhileStatement doWhileStatement); + void VisitEmptyStatement(EmptyStatement emptyStatement); + void VisitExpressionStatement(ExpressionStatement expressionStatement); + void VisitFixedStatement(FixedStatement fixedStatement); + void VisitForeachStatement(ForeachStatement foreachStatement); + void VisitForStatement(ForStatement forStatement); + void VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement); + void VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement); + void VisitGotoStatement(GotoStatement gotoStatement); + void VisitIfElseStatement(IfElseStatement ifElseStatement); + void VisitLabelStatement(LabelStatement labelStatement); + void VisitLockStatement(LockStatement lockStatement); + void VisitReturnStatement(ReturnStatement returnStatement); + void VisitSwitchStatement(SwitchStatement switchStatement); + void VisitSwitchSection(SwitchSection switchSection); + void VisitCaseLabel(CaseLabel caseLabel); + void VisitThrowStatement(ThrowStatement throwStatement); + void VisitTryCatchStatement(TryCatchStatement tryCatchStatement); + void VisitCatchClause(CatchClause catchClause); + void VisitUncheckedStatement(UncheckedStatement uncheckedStatement); + void VisitUnsafeStatement(UnsafeStatement unsafeStatement); + void VisitUsingStatement(UsingStatement usingStatement); + void VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement); + void VisitWhileStatement(WhileStatement whileStatement); + void VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement); + void VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement); + + void VisitAccessor(Accessor accessor); + void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration); + void VisitConstructorInitializer(ConstructorInitializer constructorInitializer); + void VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration); + void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration); + void VisitEventDeclaration(EventDeclaration eventDeclaration); + void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration); + void VisitFieldDeclaration(FieldDeclaration fieldDeclaration); + void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration); + void VisitMethodDeclaration(MethodDeclaration methodDeclaration); + void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration); + void VisitParameterDeclaration(ParameterDeclaration parameterDeclaration); + void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration); + void VisitVariableInitializer(VariableInitializer variableInitializer); + void VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration); + void VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer); + + void VisitCompilationUnit(CompilationUnit compilationUnit); + void VisitSimpleType(SimpleType simpleType); + void VisitMemberType(MemberType memberType); + void VisitComposedType(ComposedType composedType); + void VisitArraySpecifier(ArraySpecifier arraySpecifier); + void VisitPrimitiveType(PrimitiveType primitiveType); + + void VisitComment(Comment comment); + void VisitNewLine(NewLineNode newLineNode); + void VisitWhitespace(WhitespaceNode whitespaceNode); + void VisitText(TextNode textNode); + void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective); + void VisitDocumentationReference(DocumentationReference documentationReference); + + void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration); + void VisitConstraint(Constraint constraint); + void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode); + void VisitIdentifier(Identifier identifier); + + void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern); + } + + /// + /// AST visitor. + /// + public interface IAstVisitor + { + S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression); + S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression); + S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression); + S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression); + S VisitAsExpression(AsExpression asExpression); + S VisitAssignmentExpression(AssignmentExpression assignmentExpression); + S VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression); + S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression); + S VisitCastExpression(CastExpression castExpression); + S VisitCheckedExpression(CheckedExpression checkedExpression); + S VisitConditionalExpression(ConditionalExpression conditionalExpression); + S VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression); + S VisitDirectionExpression(DirectionExpression directionExpression); + S VisitIdentifierExpression(IdentifierExpression identifierExpression); + S VisitIndexerExpression(IndexerExpression indexerExpression); + S VisitInvocationExpression(InvocationExpression invocationExpression); + S VisitIsExpression(IsExpression isExpression); + S VisitLambdaExpression(LambdaExpression lambdaExpression); + S VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression); + S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression); + S VisitNamedExpression(NamedExpression namedExpression); + S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression); + S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression); + S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression); + S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression); + S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression); + S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression); + S VisitSizeOfExpression(SizeOfExpression sizeOfExpression); + S VisitStackAllocExpression(StackAllocExpression stackAllocExpression); + S VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression); + S VisitTypeOfExpression(TypeOfExpression typeOfExpression); + S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression); + S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression); + S VisitUncheckedExpression(UncheckedExpression uncheckedExpression); + S VisitEmptyExpression (EmptyExpression emptyExpression); + + S VisitQueryExpression(QueryExpression queryExpression); + S VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause); + S VisitQueryFromClause(QueryFromClause queryFromClause); + S VisitQueryLetClause(QueryLetClause queryLetClause); + S VisitQueryWhereClause(QueryWhereClause queryWhereClause); + S VisitQueryJoinClause(QueryJoinClause queryJoinClause); + S VisitQueryOrderClause(QueryOrderClause queryOrderClause); + S VisitQueryOrdering(QueryOrdering queryOrdering); + S VisitQuerySelectClause(QuerySelectClause querySelectClause); + S VisitQueryGroupClause(QueryGroupClause queryGroupClause); + + S VisitAttribute(Attribute attribute); + S VisitAttributeSection(AttributeSection attributeSection); + S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration); + S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration); + S VisitTypeDeclaration(TypeDeclaration typeDeclaration); + S VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration); + S VisitUsingDeclaration(UsingDeclaration usingDeclaration); + S VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration); + + S VisitBlockStatement(BlockStatement blockStatement); + S VisitBreakStatement(BreakStatement breakStatement); + S VisitCheckedStatement(CheckedStatement checkedStatement); + S VisitContinueStatement(ContinueStatement continueStatement); + S VisitDoWhileStatement(DoWhileStatement doWhileStatement); + S VisitEmptyStatement(EmptyStatement emptyStatement); + S VisitExpressionStatement(ExpressionStatement expressionStatement); + S VisitFixedStatement(FixedStatement fixedStatement); + S VisitForeachStatement(ForeachStatement foreachStatement); + S VisitForStatement(ForStatement forStatement); + S VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement); + S VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement); + S VisitGotoStatement(GotoStatement gotoStatement); + S VisitIfElseStatement(IfElseStatement ifElseStatement); + S VisitLabelStatement(LabelStatement labelStatement); + S VisitLockStatement(LockStatement lockStatement); + S VisitReturnStatement(ReturnStatement returnStatement); + S VisitSwitchStatement(SwitchStatement switchStatement); + S VisitSwitchSection(SwitchSection switchSection); + S VisitCaseLabel(CaseLabel caseLabel); + S VisitThrowStatement(ThrowStatement throwStatement); + S VisitTryCatchStatement(TryCatchStatement tryCatchStatement); + S VisitCatchClause(CatchClause catchClause); + S VisitUncheckedStatement(UncheckedStatement uncheckedStatement); + S VisitUnsafeStatement(UnsafeStatement unsafeStatement); + S VisitUsingStatement(UsingStatement usingStatement); + S VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement); + S VisitWhileStatement(WhileStatement whileStatement); + S VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement); + S VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement); + + S VisitAccessor(Accessor accessor); + S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration); + S VisitConstructorInitializer(ConstructorInitializer constructorInitializer); + S VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration); + S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration); + S VisitEventDeclaration(EventDeclaration eventDeclaration); + S VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration); + S VisitFieldDeclaration(FieldDeclaration fieldDeclaration); + S VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration); + S VisitMethodDeclaration(MethodDeclaration methodDeclaration); + S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration); + S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration); + S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration); + S VisitVariableInitializer(VariableInitializer variableInitializer); + S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration); + S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer); + + S VisitCompilationUnit(CompilationUnit compilationUnit); + S VisitSimpleType(SimpleType simpleType); + S VisitMemberType(MemberType memberType); + S VisitComposedType(ComposedType composedType); + S VisitArraySpecifier(ArraySpecifier arraySpecifier); + S VisitPrimitiveType(PrimitiveType primitiveType); + + S VisitComment(Comment comment); + S VisitWhitespace(WhitespaceNode whitespaceNode); + S VisitText(TextNode textNode); + S VisitNewLine(NewLineNode newLineNode); + S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective); + S VisitDocumentationReference(DocumentationReference documentationReference); + + S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration); + S VisitConstraint(Constraint constraint); + S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode); + S VisitIdentifier(Identifier identifier); + + S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern); + } + /// /// AST visitor. /// @@ -137,7 +399,11 @@ namespace ICSharpCode.NRefactory.CSharp S VisitPrimitiveType(PrimitiveType primitiveType, T data); S VisitComment(Comment comment, T data); + S VisitNewLine(NewLineNode newLineNode, T data); + S VisitWhitespace(WhitespaceNode whitespaceNode, T data); + S VisitText(TextNode textNode, T data); S VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective, T data); + S VisitDocumentationReference(DocumentationReference documentationReference, T data); S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data); S VisitConstraint(Constraint constraint, T data); diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Identifier.cs b/ICSharpCode.NRefactory.CSharp/Ast/Identifier.cs index 3c692706d..3321de2a0 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Identifier.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Identifier.cs @@ -1,6 +1,6 @@ // // Identifier.cs -// +// // Author: // Mike Krüger // @@ -28,7 +28,7 @@ using System; namespace ICSharpCode.NRefactory.CSharp { - public class Identifier : AstNode, IRelocatable + public class Identifier : AstNode { public new static readonly Identifier Null = new NullIdentifier (); sealed class NullIdentifier : Identifier @@ -39,7 +39,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -59,9 +68,10 @@ namespace ICSharpCode.NRefactory.CSharp string name; public string Name { get { return this.name; } - set { + set { if (value == null) throw new ArgumentNullException("value"); + ThrowIfFrozen(); this.name = value; } } @@ -71,25 +81,26 @@ namespace ICSharpCode.NRefactory.CSharp get { return startLocation; } - } - public virtual bool IsVerbatim { + const uint verbatimBit = 1u << AstNodeFlagsUsedBits; + + public bool IsVerbatim { get { - return false; + return (flags & verbatimBit) != 0; + } + set { + ThrowIfFrozen(); + if (value) + flags |= verbatimBit; + else + flags &= ~verbatimBit; } } - #region IRelocationable implementation - void IRelocatable.SetStartLocation (TextLocation startLocation) - { - this.startLocation = startLocation; - } - #endregion - public override TextLocation EndLocation { get { - return new TextLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length); + return new TextLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + (IsVerbatim ? 1 : 0)); } } @@ -116,22 +127,32 @@ namespace ICSharpCode.NRefactory.CSharp if (string.IsNullOrEmpty(name)) return Identifier.Null; if (name[0] == '@') - return new VerbatimIdentifier(name.Substring (1), location); + return new Identifier (name.Substring (1), location) { IsVerbatim = true }; else return new Identifier (name, location); } public static Identifier Create (string name, TextLocation location, bool isVerbatim) { - if (string.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty (name)) return Identifier.Null; if (isVerbatim) - return new VerbatimIdentifier(name, location); + return new Identifier (name, location) { IsVerbatim = true }; return new Identifier (name, location); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitIdentifier (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitIdentifier (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitIdentifier (this, data); } @@ -141,24 +162,5 @@ namespace ICSharpCode.NRefactory.CSharp Identifier o = other as Identifier; return o != null && !o.IsNull && MatchString(this.Name, o.Name); } - - class VerbatimIdentifier : Identifier - { - public override TextLocation EndLocation { - get { - return new TextLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + 1); // @"..." - } - } - - public override bool IsVerbatim { - get { - return true; - } - } - - public VerbatimIdentifier(string name, TextLocation location) : base (name, location) - { - } - } } } \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp/Ast/IdentifierExpressionBackreference.cs b/ICSharpCode.NRefactory.CSharp/Ast/IdentifierExpressionBackreference.cs index 89da7231c..0ce09e244 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/IdentifierExpressionBackreference.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/IdentifierExpressionBackreference.cs @@ -48,7 +48,7 @@ namespace ICSharpCode.NRefactory.CSharp CSharp.AstNode referenced = (CSharp.AstNode)match.Get(referencedGroupName).Last(); if (referenced == null) return false; - return ident.Identifier == referenced.GetChildByRole(CSharp.AstNode.Roles.Identifier).Name; + return ident.Identifier == referenced.GetChildByRole(CSharp.Roles.Identifier).Name; } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs b/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs index 796d9bc42..b017d45ba 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs @@ -37,7 +37,15 @@ namespace ICSharpCode.NRefactory.CSharp { public static readonly Role TargetRole = new Role("Target", AstType.Null); - public bool IsDoubleColon { get; set; } + bool isDoubleColon; + + public bool IsDoubleColon { + get { return isDoubleColon; } + set { + ThrowIfFrozen(); + isDoubleColon = value; + } + } public AstType Target { get { return GetChildByRole(TargetRole); } @@ -49,7 +57,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value)); } } @@ -89,7 +97,17 @@ namespace ICSharpCode.NRefactory.CSharp { } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitMemberType (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitMemberType (this); + } + + 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 index e76575266..3d47dd81f 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs @@ -60,9 +60,38 @@ namespace ICSharpCode.NRefactory.CSharp handler (comment, data); return VisitChildren (comment, data); } - - public event Action PreProcessorDirectiveVisited; + public event Action NewLineVisited; + + S IAstVisitor.VisitNewLine(NewLineNode newLineNode, T data) + { + var handler = NewLineVisited; + if (handler != null) + handler(newLineNode, data); + return VisitChildren(newLineNode, data); + } + + public event Action WhitespaceVisited; + + S IAstVisitor.VisitWhitespace(WhitespaceNode whitespace, T data) + { + var handler = WhitespaceVisited; + if (handler != null) + handler(whitespace, data); + return VisitChildren(whitespace, data); + } + + public event Action TextVisited; + + S IAstVisitor.VisitText(TextNode textNode, T data) + { + var handler = TextVisited; + if (handler != null) + handler(textNode, data); + return VisitChildren(textNode, data); + } + + public event Action PreProcessorDirectiveVisited; S IAstVisitor.VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective, T data) { var handler = PreProcessorDirectiveVisited; @@ -71,6 +100,16 @@ namespace ICSharpCode.NRefactory.CSharp return VisitChildren (preProcessorDirective, data); } + public event Action DocumentationReferenceVisited; + + S IAstVisitor.VisitDocumentationReference (DocumentationReference documentationReference, T data) + { + var handler = DocumentationReferenceVisited; + if (handler != null) + handler (documentationReference, data); + return VisitChildren (documentationReference, data); + } + public event Action IdentifierVisited; S IAstVisitor.VisitIdentifier (Identifier identifier, T data) diff --git a/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs b/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs index 890a5564e..bc367b3b6 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs @@ -32,10 +32,20 @@ using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace ICSharpCode.NRefactory.CSharp { - public class PrimitiveType : AstType, IRelocatable + public class PrimitiveType : AstType { - public string Keyword { get; set; } - public TextLocation Location { get; set; } + TextLocation location; + string keyword = string.Empty; + + public string Keyword { + get { return keyword; } + set { + if (value == null) + throw new ArgumentNullException(); + ThrowIfFrozen(); + keyword = value; + } + } public KnownTypeCode KnownTypeCode { get { return GetTypeCodeForPrimitiveType(this.Keyword); } @@ -53,29 +63,31 @@ namespace ICSharpCode.NRefactory.CSharp public PrimitiveType(string keyword, TextLocation location) { this.Keyword = keyword; - this.Location = location; + this.location = location; } public override TextLocation StartLocation { get { - return Location; + return location; } } public override TextLocation EndLocation { get { - return new TextLocation (Location.Line, Location.Column + (Keyword != null ? Keyword.Length : 0)); + return new TextLocation (location.Line, location.Column + keyword.Length); } } - - #region IRelocationable implementation - void IRelocatable.SetStartLocation (TextLocation startLocation) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPrimitiveType (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) { - this.Location = startLocation; + return visitor.VisitPrimitiveType (this); } - #endregion - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitPrimitiveType (this, data); } @@ -88,7 +100,7 @@ namespace ICSharpCode.NRefactory.CSharp public override string ToString() { - return Keyword ?? base.ToString(); + return Keyword; } public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type) diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Roles.cs b/ICSharpCode.NRefactory.CSharp/Ast/Roles.cs new file mode 100644 index 000000000..a7408c91d --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Ast/Roles.cs @@ -0,0 +1,96 @@ +// +// Roles.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin +// +// 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 static class Roles + { + public static readonly Role Root = AstNode.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", VariableInitializer.Null); + public static readonly Role EmbeddedStatement = new Role ("EmbeddedStatement", CSharp.Statement.Null); + public readonly static Role TypeMemberRole = new Role ("TypeMember"); + + + // public static readonly TokenRole Keyword = new TokenRole ("Keyword", CSharpTokenNode.Null); +// public static readonly TokenRole InKeyword = new TokenRole ("InKeyword", CSharpTokenNode.Null); + + // some pre defined constants for most used punctuation + public static readonly TokenRole LPar = new TokenRole ("("); + public static readonly TokenRole RPar = new TokenRole (")"); + public static readonly TokenRole LBracket = new TokenRole ("["); + public static readonly TokenRole RBracket = new TokenRole ("]"); + public static readonly TokenRole LBrace = new TokenRole ("{"); + public static readonly TokenRole RBrace = new TokenRole ("}"); + public static readonly TokenRole LChevron = new TokenRole ("<"); + public static readonly TokenRole RChevron = new TokenRole (">"); + public static readonly TokenRole Comma = new TokenRole (","); + public static readonly TokenRole Dot = new TokenRole ("."); + public static readonly TokenRole Semicolon = new TokenRole (";"); + public static readonly TokenRole Assign = new TokenRole ("="); + public static readonly TokenRole Colon = new TokenRole (":"); + public static readonly TokenRole DoubleColon = new TokenRole ("::"); + public static readonly Role Comment = new Role ("Comment"); + public static readonly Role NewLine = new Role ("NewLine"); + public static readonly Role Whitespace = new Role ("Whitespace"); + public static readonly Role Text = new Role ("Text"); + public static readonly Role PreProcessorDirective = new Role ("PreProcessorDirective"); + public static readonly Role Error = new Role ("Error"); + + public readonly static Role BaseType = new Role ("BaseType", AstType.Null); + + public static readonly Role Attribute = new Role ("Attribute"); + public static readonly Role AttributeTargetRole = new Role ("AttributeTarget", CSharpTokenNode.Null); + + public readonly static TokenRole WhereKeyword = new TokenRole ("where"); + public readonly static Role ConstraintTypeParameter = new Role ("TypeParameter", SimpleType.Null); + public readonly static TokenRole DelegateKeyword = new TokenRole ("delegate"); + public static readonly TokenRole ExternKeyword = new TokenRole ("extern"); + public static readonly TokenRole AliasKeyword = new TokenRole ("alias"); + public static readonly TokenRole NamespaceKeyword = new TokenRole ("namespace"); + + public static readonly TokenRole EnumKeyword = new TokenRole ("enum"); + public static readonly TokenRole InterfaceKeyword = new TokenRole ("interface"); + public static readonly TokenRole StructKeyword = new TokenRole ("struct"); + public static readonly TokenRole ClassKeyword = new TokenRole ("class"); + + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs b/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs index f7ff3b759..072432b46 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs @@ -47,7 +47,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -100,7 +109,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, CSharp.Identifier.Create (value)); } } @@ -117,7 +126,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (Roles.TypeArgument); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitSimpleType (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitSimpleType (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitSimpleType (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/BlockStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/BlockStatement.cs index 066d38138..d30484d8d 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/BlockStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/BlockStatement.cs @@ -45,7 +45,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -76,7 +85,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder(this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder(this, child); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitPatternPlaceholder(this, child, data); } @@ -105,7 +124,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RBrace); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitBlockStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitBlockStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitBlockStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/BreakStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/BreakStatement.cs index 5c993f896..056cf55e4 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/BreakStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/BreakStatement.cs @@ -31,11 +31,27 @@ namespace ICSharpCode.NRefactory.CSharp /// public class BreakStatement : Statement { + public static readonly TokenRole BreakKeywordRole = new TokenRole ("break"); + + public CSharpTokenNode BreakToken { + get { return GetChildByRole (BreakKeywordRole); } + } + public CSharpTokenNode SemicolonToken { get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitBreakStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitBreakStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitBreakStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/CheckedStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/CheckedStatement.cs index c81724b91..803067aff 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/CheckedStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/CheckedStatement.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class CheckedStatement : Statement { + public static readonly TokenRole CheckedKeywordRole = new TokenRole ("checked"); + public CSharpTokenNode CheckedToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (CheckedKeywordRole); } } public BlockStatement Body { @@ -49,7 +51,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (body, Roles.Body); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitCheckedStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitCheckedStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCheckedStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ContinueStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ContinueStatement.cs index cb8cf30e6..aac1690b2 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ContinueStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ContinueStatement.cs @@ -31,11 +31,27 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ContinueStatement : Statement { + public static readonly TokenRole ContinueKeywordRole = new TokenRole ("continue"); + + public CSharpTokenNode ContinueToken { + get { return GetChildByRole (ContinueKeywordRole); } + } + public CSharpTokenNode SemicolonToken { get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitContinueStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitContinueStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitContinueStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/DoWhileStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/DoWhileStatement.cs index 9e0cc4a43..ec6e2ce26 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/DoWhileStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/DoWhileStatement.cs @@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp /// public class DoWhileStatement : Statement { - public static readonly Role DoKeywordRole = new Role("DoKeyword", CSharpTokenNode.Null); - public static readonly Role WhileKeywordRole = new Role("WhileKeyword", CSharpTokenNode.Null); + public static readonly TokenRole DoKeywordRole = new TokenRole ("do"); + public static readonly TokenRole WhileKeywordRole = new TokenRole ("while"); public CSharpTokenNode DoToken { get { return GetChildByRole (DoKeywordRole); } @@ -64,7 +64,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitDoWhileStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitDoWhileStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitDoWhileStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/EmptyStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/EmptyStatement.cs index e0c899983..deaa3a9c4 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/EmptyStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/EmptyStatement.cs @@ -29,7 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp /// /// ; /// - public class EmptyStatement : Statement, IRelocatable + public class EmptyStatement : Statement { public TextLocation Location { get; @@ -48,14 +48,17 @@ namespace ICSharpCode.NRefactory.CSharp } } - #region IRelocationable implementation - void IRelocatable.SetStartLocation (TextLocation startLocation) + public override void AcceptVisitor (IAstVisitor visitor) { - this.Location = startLocation; + visitor.VisitEmptyStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitEmptyStatement (this); } - #endregion - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitEmptyStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ExpressionStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ExpressionStatement.cs index 3954d5e42..1fdc4ddc4 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ExpressionStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ExpressionStatement.cs @@ -40,7 +40,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitExpressionStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitExpressionStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitExpressionStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/FixedStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/FixedStatement.cs index 263cf8fbd..d44366504 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/FixedStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/FixedStatement.cs @@ -33,8 +33,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class FixedStatement : Statement { + public static readonly TokenRole FixedKeywordRole = new TokenRole ("fixed"); + public CSharpTokenNode FixedToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (FixedKeywordRole); } } public CSharpTokenNode LParToken { @@ -59,7 +61,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.EmbeddedStatement, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitFixedStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitFixedStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitFixedStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ForStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ForStatement.cs index a6c91b322..d369536d0 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ForStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ForStatement.cs @@ -33,11 +33,12 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ForStatement : Statement { + public static readonly TokenRole ForKeywordRole = new TokenRole ("for"); public readonly static Role InitializerRole = new Role("Initializer", Statement.Null); public readonly static Role IteratorRole = new Role("Iterator", Statement.Null); public CSharpTokenNode ForToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (ForKeywordRole); } } public CSharpTokenNode LParToken { @@ -71,7 +72,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.EmbeddedStatement, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitForStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitForStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitForStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ForeachStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ForeachStatement.cs index ccd3ecdeb..b3a9c5f78 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ForeachStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ForeachStatement.cs @@ -31,8 +31,11 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ForeachStatement : Statement { + public static readonly TokenRole ForeachKeywordRole = new TokenRole ("foreach"); + public static readonly TokenRole InKeywordRole = new TokenRole ("in"); + public CSharpTokenNode ForeachToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (ForeachKeywordRole); } } public CSharpTokenNode LParToken { @@ -49,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value)); } } @@ -63,7 +66,7 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode InToken { - get { return GetChildByRole (Roles.InKeyword); } + get { return GetChildByRole (InKeywordRole); } } public Expression InExpression { @@ -80,7 +83,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.EmbeddedStatement, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitForeachStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitForeachStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitForeachStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/GotoStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/GotoStatement.cs index c02e223d6..7aff7a82f 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/GotoStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/GotoStatement.cs @@ -31,6 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp /// public class GotoStatement : Statement { + public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto"); + public GotoStatement () { } @@ -41,7 +43,7 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode GotoToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (GotoKeywordRole); } } public string Label { @@ -52,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp if (string.IsNullOrEmpty(value)) SetChildByRole(Roles.Identifier, null); else - SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value)); } } @@ -60,7 +62,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitGotoStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitGotoStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitGotoStatement (this, data); } @@ -77,10 +89,11 @@ namespace ICSharpCode.NRefactory.CSharp /// public class GotoCaseStatement : Statement { - public static readonly Role CaseKeywordRole = new Role("CaseKeyword", CSharpTokenNode.Null); + public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto"); + public static readonly TokenRole CaseKeywordRole = new TokenRole ("case"); public CSharpTokenNode GotoToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (GotoKeywordRole); } } public CSharpTokenNode CaseToken { @@ -99,7 +112,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitGotoCaseStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitGotoCaseStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitGotoCaseStatement (this, data); } @@ -116,10 +139,11 @@ namespace ICSharpCode.NRefactory.CSharp /// public class GotoDefaultStatement : Statement { - public static readonly Role DefaultKeywordRole = new Role("DefaultKeyword", CSharpTokenNode.Null); + public static readonly TokenRole GotoKeywordRole = new TokenRole ("goto"); + public static readonly TokenRole DefaultKeywordRole = new TokenRole ("default"); public CSharpTokenNode GotoToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (GotoKeywordRole); } } public CSharpTokenNode DefaultToken { @@ -130,7 +154,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitGotoDefaultStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitGotoDefaultStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitGotoDefaultStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/IfElseStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/IfElseStatement.cs index 803d7bf8a..70ece3fd5 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/IfElseStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/IfElseStatement.cs @@ -31,11 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class IfElseStatement : Statement { - public readonly static Role IfKeywordRole = Roles.Keyword; + public readonly static TokenRole IfKeywordRole = new TokenRole ("if"); public readonly static Role ConditionRole = Roles.Condition; - public readonly static Role QuestionMarkRole = new Role("QuestionMark", CSharpTokenNode.Null); public readonly static Role TrueRole = new Role("True", Statement.Null); - public readonly static Role ElseKeywordRole = new Role("ElseKeyword", CSharpTokenNode.Null); + public readonly static TokenRole ElseKeywordRole = new TokenRole ("else"); public readonly static Role FalseRole = new Role("False", Statement.Null); public CSharpTokenNode IfToken { @@ -69,7 +68,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (FalseRole, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitIfElseStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitIfElseStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitIfElseStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/LabelStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/LabelStatement.cs index 6b3a08cf8..ef2190bfe 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/LabelStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/LabelStatement.cs @@ -36,15 +36,30 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole(Roles.Identifier, Identifier.Create (value)); } } + public Identifier LabelToken { + get { return GetChildByRole (Roles.Identifier); } + set { SetChildByRole (Roles.Identifier, value); } + } + public CSharpTokenNode Colon { get { return GetChildByRole (Roles.Colon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitLabelStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitLabelStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitLabelStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/LockStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/LockStatement.cs index 8a5f2f76f..e59f99308 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/LockStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/LockStatement.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class LockStatement : Statement { + public static readonly TokenRole LockKeywordRole = new TokenRole ("lock"); + public CSharpTokenNode LockToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (LockKeywordRole); } } public CSharpTokenNode LParToken { @@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.EmbeddedStatement, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitLockStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitLockStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitLockStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ReturnStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ReturnStatement.cs index 8219490d7..0970bce43 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ReturnStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ReturnStatement.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ReturnStatement : Statement { + public static readonly TokenRole ReturnKeywordRole = new TokenRole ("return"); + public CSharpTokenNode ReturnToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (ReturnKeywordRole); } } public Expression Expression { @@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (returnExpression, Roles.Expression); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitReturnStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitReturnStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitReturnStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/Statement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/Statement.cs index 665a5dfd7..6d3ec7d1f 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/Statement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/Statement.cs @@ -25,7 +25,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -56,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder(this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder(this, child); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitPatternPlaceholder(this, child, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/SwitchStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/SwitchStatement.cs index bf5ca7a83..fa8e80cd5 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/SwitchStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/SwitchStatement.cs @@ -34,10 +34,11 @@ namespace ICSharpCode.NRefactory.CSharp /// public class SwitchStatement : Statement { + public static readonly TokenRole SwitchKeywordRole = new TokenRole ("switch"); public static readonly Role SwitchSectionRole = new Role("SwitchSection"); public CSharpTokenNode SwitchToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (SwitchKeywordRole); } } public CSharpTokenNode LParToken { @@ -65,7 +66,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RBrace); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitSwitchStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitSwitchStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitSwitchStatement (this, data); } @@ -98,7 +109,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder(this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder(this, child); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitPatternPlaceholder(this, child, data); } @@ -131,7 +152,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (Roles.EmbeddedStatement); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitSwitchSection (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitSwitchSection (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitSwitchSection (this, data); } @@ -145,6 +176,9 @@ namespace ICSharpCode.NRefactory.CSharp public class CaseLabel : AstNode { + public static readonly TokenRole CaseKeywordRole = new TokenRole ("case"); + public static readonly TokenRole DefaultKeywordRole = new TokenRole ("default"); + public override NodeType NodeType { get { return NodeType.Unknown; @@ -158,7 +192,11 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Expression); } set { SetChildByRole (Roles.Expression, value); } } - + + public CSharpTokenNode ColonToken { + get { return GetChildByRole (Roles.Colon); } + } + public CaseLabel () { } @@ -168,7 +206,17 @@ namespace ICSharpCode.NRefactory.CSharp this.Expression = expression; } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitCaseLabel (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitCaseLabel (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCaseLabel (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ThrowStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ThrowStatement.cs index 5d42af3cc..98e27d1e7 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/ThrowStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/ThrowStatement.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ThrowStatement : Statement { + public static readonly TokenRole ThrowKeywordRole = new TokenRole ("throw"); + public CSharpTokenNode ThrowToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (ThrowKeywordRole); } } public Expression Expression { @@ -53,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (expression, Roles.Expression); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitThrowStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitThrowStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitThrowStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs index 711a6f491..b19036495 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs @@ -34,10 +34,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class TryCatchStatement : Statement { - public static readonly Role TryKeywordRole = new Role("TryKeyword", CSharpTokenNode.Null); + public static readonly TokenRole TryKeywordRole = new TokenRole ("try"); public static readonly Role TryBlockRole = new Role("TryBlock", BlockStatement.Null); public static readonly Role CatchClauseRole = new Role("CatchClause"); - public static readonly Role FinallyKeywordRole = new Role("FinallyKeyword", CSharpTokenNode.Null); + public static readonly TokenRole FinallyKeywordRole = new TokenRole ("finally"); public static readonly Role FinallyBlockRole = new Role("FinallyBlock", BlockStatement.Null); public CSharpTokenNode TryToken { @@ -62,7 +62,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (FinallyBlockRole, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitTryCatchStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitTryCatchStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitTryCatchStatement (this, data); } @@ -79,6 +89,8 @@ namespace ICSharpCode.NRefactory.CSharp /// public class CatchClause : AstNode { + public static readonly TokenRole CatchKeywordRole = new TokenRole ("catch"); + #region PatternPlaceholder public static implicit operator CatchClause(PatternMatching.Pattern pattern) { @@ -98,7 +110,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder(this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder(this, child); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitPatternPlaceholder(this, child, data); } @@ -122,7 +144,7 @@ namespace ICSharpCode.NRefactory.CSharp } public CSharpTokenNode CatchToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (CatchKeywordRole); } } public CSharpTokenNode LParToken { @@ -140,7 +162,7 @@ namespace ICSharpCode.NRefactory.CSharp if (string.IsNullOrEmpty(value)) SetChildByRole (Roles.Identifier, null); else - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value)); } } @@ -162,7 +184,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Body, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitCatchClause (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitCatchClause (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCatchClause (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/UncheckedStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/UncheckedStatement.cs index 086cff854..765cd9ab3 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/UncheckedStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/UncheckedStatement.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class UncheckedStatement : Statement { + public static readonly TokenRole UncheckedKeywordRole = new TokenRole ("unchecked"); + public CSharpTokenNode UncheckedToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (UncheckedKeywordRole); } } public BlockStatement Body { @@ -49,7 +51,17 @@ namespace ICSharpCode.NRefactory.CSharp AddChild (body, Roles.Body); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitUncheckedStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitUncheckedStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitUncheckedStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/UnsafeStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/UnsafeStatement.cs index fba1ebe43..fa6421ae6 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/UnsafeStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/UnsafeStatement.cs @@ -31,8 +31,10 @@ namespace ICSharpCode.NRefactory.CSharp /// public class UnsafeStatement : Statement { + public static readonly TokenRole UnsafeKeywordRole = new TokenRole ("unsafe"); + public CSharpTokenNode UnsafeToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (UnsafeKeywordRole); } } public BlockStatement Body { @@ -40,7 +42,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Body, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitUnsafeStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitUnsafeStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitUnsafeStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/UsingStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/UsingStatement.cs index 030ce0368..c87304675 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/UsingStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/UsingStatement.cs @@ -31,10 +31,11 @@ namespace ICSharpCode.NRefactory.CSharp /// public class UsingStatement : Statement { + public static readonly TokenRole UsingKeywordRole = new TokenRole ("using"); public static readonly Role ResourceAcquisitionRole = new Role("ResourceAcquisition", AstNode.Null); public CSharpTokenNode UsingToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (UsingKeywordRole); } } public CSharpTokenNode LParToken { @@ -58,7 +59,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.EmbeddedStatement, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitUsingStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitUsingStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitUsingStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs index c9792125f..32c141d96 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/VariableDeclarationStatement.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp { public class VariableDeclarationStatement : Statement { - public static readonly Role ModifierRole = AttributedNode.ModifierRole; + public static readonly Role ModifierRole = EntityDeclaration.ModifierRole; public VariableDeclarationStatement() { @@ -44,8 +44,8 @@ namespace ICSharpCode.NRefactory.CSharp } public Modifiers Modifiers { - get { return AttributedNode.GetModifiers(this); } - set { AttributedNode.SetModifiers(this, value); } + get { return EntityDeclaration.GetModifiers(this); } + set { EntityDeclaration.SetModifiers(this, value); } } public AstType Type { @@ -63,10 +63,20 @@ namespace ICSharpCode.NRefactory.CSharp public VariableInitializer GetVariable (string name) { - return Variables.FirstOrDefault (vi => vi.Name == name); + return Variables.FirstOrNullObject (vi => vi.Name == name); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitVariableDeclarationStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitVariableDeclarationStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitVariableDeclarationStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/WhileStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/WhileStatement.cs index db71887c4..256ddb864 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/WhileStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/WhileStatement.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp /// public class WhileStatement : Statement { - public static readonly Role WhileKeywordRole = new Role("WhileKeyword", CSharpTokenNode.Null); + public static readonly TokenRole WhileKeywordRole = new TokenRole ("while"); public CSharpTokenNode WhileToken { get { return GetChildByRole (WhileKeywordRole); } @@ -55,7 +55,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.EmbeddedStatement, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitWhileStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitWhileStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitWhileStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/YieldBreakStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/YieldBreakStatement.cs index 253253fef..ea5cac4a6 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/YieldBreakStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/YieldBreakStatement.cs @@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp /// public class YieldBreakStatement : Statement { - public static readonly Role YieldKeywordRole = new Role("YieldKeyword", CSharpTokenNode.Null); - public static readonly Role BreakKeywordRole = new Role("BreakKeyword", CSharpTokenNode.Null); + public static readonly TokenRole YieldKeywordRole = new TokenRole ("yield"); + public static readonly TokenRole BreakKeywordRole = new TokenRole ("break"); public CSharpTokenNode YieldToken { get { return GetChildByRole (YieldKeywordRole); } @@ -46,7 +46,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitYieldBreakStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitYieldBreakStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitYieldBreakStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/YieldReturnStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/YieldReturnStatement.cs index a3b65ac2a..6539bf0c0 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/YieldReturnStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/YieldReturnStatement.cs @@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp /// public class YieldReturnStatement : Statement { - public static readonly Role YieldKeywordRole = new Role("YieldKeyword", CSharpTokenNode.Null); - public static readonly Role ReturnKeywordRole = new Role("ReturnKeyword", CSharpTokenNode.Null); + public static readonly TokenRole YieldKeywordRole = new TokenRole ("yield"); + public static readonly TokenRole ReturnKeywordRole = new TokenRole ("return"); public CSharpTokenNode YieldToken { get { return GetChildByRole (YieldKeywordRole); } @@ -51,7 +51,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.Semicolon); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitYieldReturnStatement (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitYieldReturnStatement (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitYieldReturnStatement (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TokenRole.cs b/ICSharpCode.NRefactory.CSharp/Ast/TokenRole.cs new file mode 100644 index 000000000..29a67ab27 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Ast/TokenRole.cs @@ -0,0 +1,33 @@ +using System; + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// A specific role only used for C# tokens + /// + public sealed class TokenRole : Role + { + /// + /// Gets the token as string. Note that the token Name and Token value may differ. + /// + public string Token { + get; + private set; + } + + /// + /// Gets the char length of the token. + /// + public int Length { + get; + private set; + } + + public TokenRole (string token) : base (token, CSharpTokenNode.Null) + { + this.Token = token; + this.Length = token.Length; + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/Accessor.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/Accessor.cs index 1da7986bb..a920a849c 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/Accessor.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/Accessor.cs @@ -1,6 +1,6 @@ // // PropertyDeclaration.cs -// +// // Author: // Mike Krüger // @@ -25,13 +25,14 @@ // THE SOFTWARE. using System; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { /// /// get/set/add/remove /// - public class Accessor : AttributedNode + public class Accessor : EntityDeclaration { public static readonly new Accessor Null = new NullAccessor (); sealed class NullAccessor : Accessor @@ -42,7 +43,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -57,12 +67,26 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Unknown; } } + public override EntityType EntityType { + get { return EntityType.Method; } + } + public BlockStatement Body { get { return GetChildByRole (Roles.Body); } set { SetChildByRole (Roles.Body, value); } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitAccessor (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitAccessor (this); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitAccessor (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.cs index 8f111e9a5..204776793 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.cs @@ -24,25 +24,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Collections.Generic; -using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { - public class ConstructorDeclaration : AttributedNode + public class ConstructorDeclaration : EntityDeclaration { public static readonly Role InitializerRole = new Role("Initializer", ConstructorInitializer.Null); - /// - /// Gets/Sets the name of the class containing the constructor. - /// This property can be used to inform the output visitor about the class name when writing a constructor declaration - /// without writing the complete type declaration. It is ignored when the constructor has a type declaration as parent. - /// - public string Name { get; set; } - - public Identifier IdentifierToken { - get { return GetChildByRole (Roles.Identifier); } - set { SetChildByRole (Roles.Identifier, value); } + public override EntityType EntityType { + get { return EntityType.Constructor; } } public CSharpTokenNode LParToken { @@ -71,11 +62,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Body, value); } } - public override NodeType NodeType { - get { return NodeType.Member; } + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitConstructorDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitConstructorDeclaration (this); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitConstructorDeclaration (this, data); } @@ -95,6 +92,9 @@ namespace ICSharpCode.NRefactory.CSharp public class ConstructorInitializer : AstNode { + public static readonly TokenRole BaseKeywordRole = new TokenRole ("base"); + public static readonly TokenRole ThisKeywordRole = new TokenRole ("this"); + public static readonly new ConstructorInitializer Null = new NullConstructorInitializer (); class NullConstructorInitializer : ConstructorInitializer { @@ -110,7 +110,16 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return default (S); } @@ -144,7 +153,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RPar); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitConstructorInitializer (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitConstructorInitializer (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitConstructorInitializer (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/DestructorDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/DestructorDeclaration.cs index 0e129e433..5f2411ec8 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/DestructorDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/DestructorDeclaration.cs @@ -24,26 +24,20 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using ICSharpCode.NRefactory.TypeSystem; + namespace ICSharpCode.NRefactory.CSharp { - public class DestructorDeclaration : AttributedNode + public class DestructorDeclaration : EntityDeclaration { - public static readonly Role TildeRole = new Role("Tilde", CSharpTokenNode.Null); + public static readonly TokenRole TildeRole = new TokenRole ("~"); public CSharpTokenNode TildeToken { get { return GetChildByRole (TildeRole); } } - /// - /// Gets/Sets the name of the class containing the destructor. - /// This property can be used to inform the output visitor about the class name when writing a destructor declaration - /// without writing the complete type declaration. It is ignored when the destructor has a type declaration as parent. - /// - public string Name { get; set; } - - public Identifier IdentifierToken { - get { return GetChildByRole (Roles.Identifier); } - set { SetChildByRole (Roles.Identifier, value); } + public override EntityType EntityType { + get { return EntityType.Destructor; } } public CSharpTokenNode LParToken { @@ -58,11 +52,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Body, value); } } - public override NodeType NodeType { - get { return NodeType.Member; } + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitDestructorDeclaration (this); } - - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitDestructorDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitDestructorDeclaration (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/AttributedNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EntityDeclaration.cs similarity index 77% rename from ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/AttributedNode.cs rename to ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EntityDeclaration.cs index 09617c007..ca8f69338 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/AttributedNode.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EntityDeclaration.cs @@ -22,11 +22,18 @@ using System.Linq; namespace ICSharpCode.NRefactory.CSharp { - public abstract class AttributedNode : AstNode + public abstract class EntityDeclaration : AstNode { public static readonly Role AttributeRole = new Role("Attribute"); public static readonly Role UnattachedAttributeRole = new Role("UnattachedAttribute"); public static readonly Role ModifierRole = new Role("Modifier"); + public static readonly Role PrivateImplementationTypeRole = new Role("PrivateImplementationType", AstType.Null); + + public override NodeType NodeType { + get { return NodeType.Member; } + } + + public abstract NRefactory.TypeSystem.EntityType EntityType { get; } public AstNodeCollection Attributes { get { return base.GetChildrenByRole (AttributeRole); } @@ -37,10 +44,34 @@ namespace ICSharpCode.NRefactory.CSharp set { SetModifiers(this, value); } } + public bool HasModifier (Modifiers mod) + { + return (Modifiers & mod) == mod; + } + public IEnumerable ModifierTokens { get { return GetChildrenByRole (ModifierRole); } } + public virtual string Name { + get { + return GetChildByRole (Roles.Identifier).Name; + } + set { + SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + } + } + + public virtual Identifier NameToken { + get { return GetChildByRole (Roles.Identifier); } + set { SetChildByRole (Roles.Identifier, value); } + } + + public virtual AstType ReturnType { + get { return GetChildByRole (Roles.Type); } + set { SetChildByRole(Roles.Type, value); } + } + internal static Modifiers GetModifiers(AstNode node) { Modifiers m = 0; @@ -74,14 +105,9 @@ namespace ICSharpCode.NRefactory.CSharp } } - protected bool MatchAttributesAndModifiers (AttributedNode o, PatternMatching.Match match) + protected bool MatchAttributesAndModifiers (EntityDeclaration o, PatternMatching.Match 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/EnumMemberDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs index f646a9385..8f05e4e2a 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs @@ -23,30 +23,18 @@ // 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 { - public class EnumMemberDeclaration : AttributedNode + public class EnumMemberDeclaration : EntityDeclaration { public static readonly Role InitializerRole = new Role("Initializer", Expression.Null); - public string Name { - get { - return GetChildByRole (Roles.Identifier).Name; - } - set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); - } - } - - public Identifier NameToken { - get { - return GetChildByRole (Roles.Identifier); - } - set { - SetChildByRole (Roles.Identifier, value); - } + public override EntityType EntityType { + get { return EntityType.Field; } } public Expression Initializer { @@ -54,11 +42,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (InitializerRole, value); } } - public override NodeType NodeType { - get { return NodeType.Member; } + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitEnumMemberDeclaration (this); } - - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitEnumMemberDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitEnumMemberDeclaration (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EventDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EventDeclaration.cs index 752463a2e..8c1958cf8 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EventDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EventDeclaration.cs @@ -25,25 +25,33 @@ // THE SOFTWARE. using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { - public class EventDeclaration : AttributedNode + public class EventDeclaration : EntityDeclaration { - public override NodeType NodeType { - get { return NodeType.Member; } - } + public static readonly TokenRole EventKeywordRole = new TokenRole ("event"); - public AstType ReturnType { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole(Roles.Type, value); } + public override EntityType EntityType { + get { return EntityType.Event; } } public AstNodeCollection Variables { get { return GetChildrenByRole (Roles.Variable); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitEventDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitEventDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitEventDeclaration (this, data); } @@ -56,11 +64,28 @@ namespace ICSharpCode.NRefactory.CSharp } } - public class CustomEventDeclaration : MemberDeclaration + public class CustomEventDeclaration : EntityDeclaration { + public static readonly TokenRole EventKeywordRole = new TokenRole ("event"); + public static readonly TokenRole AddKeywordRole = new TokenRole ("add"); + public static readonly TokenRole RemoveKeywordRole = new TokenRole ("remove"); + public static readonly Role AddAccessorRole = new Role("AddAccessor", Accessor.Null); public static readonly Role RemoveAccessorRole = new Role("RemoveAccessor", Accessor.Null); + public override EntityType EntityType { + get { return EntityType.Event; } + } + + /// + /// Gets/Sets the type reference of the interface that is explicitly implemented. + /// Null node if this member is not an explicit interface implementation. + /// + public AstType PrivateImplementationType { + get { return GetChildByRole (PrivateImplementationTypeRole); } + set { SetChildByRole (PrivateImplementationTypeRole, value); } + } + public CSharpTokenNode LBraceToken { get { return GetChildByRole (Roles.LBrace); } } @@ -79,7 +104,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RBrace); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitCustomEventDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitCustomEventDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitCustomEventDeclaration (this, data); } @@ -87,7 +122,9 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { CustomEventDeclaration o = other as CustomEventDeclaration; - return o != null && this.MatchMember(o, match) + return o != null && MatchString(this.Name, o.Name) + && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) + && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) && this.AddAccessor.DoMatch(o.AddAccessor, match) && this.RemoveAccessor.DoMatch(o.RemoveAccessor, match); } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FieldDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FieldDeclaration.cs index 2b30b2be3..16406d59d 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FieldDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FieldDeclaration.cs @@ -24,27 +24,31 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Collections.Generic; -using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { - public class FieldDeclaration : AttributedNode + public class FieldDeclaration : EntityDeclaration { - public override NodeType NodeType { - get { return NodeType.Member; } - } - - public AstType ReturnType { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole(Roles.Type, value); } + public override EntityType EntityType { + get { return EntityType.Field; } } public AstNodeCollection Variables { get { return GetChildrenByRole (Roles.Variable); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitFieldDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitFieldDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitFieldDeclaration (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FixedFieldDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FixedFieldDeclaration.cs index ea20b3585..ebc20c5ef 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FixedFieldDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FixedFieldDeclaration.cs @@ -24,31 +24,38 @@ // 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 { - public class FixedFieldDeclaration : AttributedNode + public class FixedFieldDeclaration : EntityDeclaration { + public static readonly TokenRole FixedKeywordRole = new TokenRole ("fixed"); public static readonly Role VariableRole = new Role ("FixedVariable"); - public override NodeType NodeType { - get { return NodeType.Member; } + public override EntityType EntityType { + get { return EntityType.Field; } } public CSharpTokenNode FixedToken { - get { return GetChildByRole (Roles.Keyword); } + get { return GetChildByRole (FixedKeywordRole); } } - public AstType ReturnType { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole (Roles.Type, value); } - } - public AstNodeCollection Variables { get { return GetChildrenByRole (VariableRole); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitFixedFieldDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitFixedFieldDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitFixedFieldDeclaration (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FixedVariableInitializer.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FixedVariableInitializer.cs index 11bbc138a..2c320a826 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FixedVariableInitializer.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/FixedVariableInitializer.cs @@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value)); } } @@ -79,8 +79,18 @@ namespace ICSharpCode.NRefactory.CSharp public CSharpTokenNode RBracketToken { get { return GetChildByRole (Roles.RBracket); } } + + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitFixedVariableInitializer (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitFixedVariableInitializer (this); + } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitFixedVariableInitializer (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs index 221a6dde8..c175485ab 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs @@ -24,16 +24,29 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Collections.Generic; -using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { - public class IndexerDeclaration : MemberDeclaration + public class IndexerDeclaration : EntityDeclaration { + public static readonly TokenRole ThisKeywordRole = new TokenRole ("this"); public static readonly Role GetterRole = PropertyDeclaration.GetterRole; public static readonly Role SetterRole = PropertyDeclaration.SetterRole; + public override EntityType EntityType { + get { return EntityType.Indexer; } + } + + /// + /// Gets/Sets the type reference of the interface that is explicitly implemented. + /// Null node if this member is not an explicit interface implementation. + /// + public AstType PrivateImplementationType { + get { return GetChildByRole (PrivateImplementationTypeRole); } + set { SetChildByRole (PrivateImplementationTypeRole, value); } + } + public CSharpTokenNode LBracketToken { get { return GetChildByRole (Roles.LBracket); } } @@ -64,7 +77,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RBrace); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitIndexerDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitIndexerDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitIndexerDeclaration (this, data); } @@ -72,7 +95,10 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { IndexerDeclaration o = other as IndexerDeclaration; - return o != null && this.MatchMember(o, match) && this.Parameters.DoMatch(o.Parameters, match) + return o != null && MatchString(this.Name, o.Name) + && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) + && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) + && this.Parameters.DoMatch(o.Parameters, match) && this.Getter.DoMatch(o.Getter, match) && this.Setter.DoMatch(o.Setter, match); } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/MemberDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/MemberDeclaration.cs deleted file mode 100644 index e1463c077..000000000 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/MemberDeclaration.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -// AbstractMember.cs -// -// Author: -// Mike Krüger -// -// Copyright (c) 2009 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -namespace ICSharpCode.NRefactory.CSharp -{ - public abstract class MemberDeclaration : AttributedNode - { - public static readonly Role PrivateImplementationTypeRole = new Role("PrivateImplementationType", AstType.Null); - - public AstType ReturnType { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - /// - /// Only supported on members that can be declared in an interface. - /// - public AstType PrivateImplementationType { - get { return GetChildByRole (PrivateImplementationTypeRole); } - set { SetChildByRole (PrivateImplementationTypeRole, value); } - } - - public string Name { - get { - return GetChildByRole (Roles.Identifier).Name; - } - set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); - } - } - - public Identifier NameToken { - get { - return GetChildByRole (Roles.Identifier); - } - set { - SetChildByRole (Roles.Identifier, value); - } - } - - public override NodeType NodeType { - get { return NodeType.Member; } - } - - protected bool MatchMember(MemberDeclaration o, PatternMatching.Match match) - { - return MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) - && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) && MatchString(this.Name, o.Name); - } - } -} diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/MethodDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/MethodDeclaration.cs index 129c87e26..0d4a2340b 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/MethodDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/MethodDeclaration.cs @@ -24,13 +24,25 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.Collections.Generic; -using System.Linq; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { - public class MethodDeclaration : MemberDeclaration + public class MethodDeclaration : EntityDeclaration { + public override EntityType EntityType { + get { return EntityType.Method; } + } + + /// + /// Gets/Sets the type reference of the interface that is explicitly implemented. + /// Null node if this member is not an explicit interface implementation. + /// + public AstType PrivateImplementationType { + get { return GetChildByRole (PrivateImplementationTypeRole); } + set { SetChildByRole (PrivateImplementationTypeRole, value); } + } + public AstNodeCollection TypeParameters { get { return GetChildrenByRole (Roles.TypeParameter); } } @@ -63,7 +75,17 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitMethodDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitMethodDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitMethodDeclaration (this, data); } @@ -71,7 +93,10 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { MethodDeclaration o = other as MethodDeclaration; - return o != null && this.MatchMember(o, match) && this.TypeParameters.DoMatch(o.TypeParameters, match) + return o != null && MatchString(this.Name, o.Name) + && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) + && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) + && this.TypeParameters.DoMatch(o.TypeParameters, match) && this.Parameters.DoMatch(o.Parameters, match) && this.Constraints.DoMatch(o.Constraints, match) && this.Body.DoMatch(o.Body, match); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/OperatorDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/OperatorDeclaration.cs index 35865d24c..8e0967357 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/OperatorDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/OperatorDeclaration.cs @@ -23,8 +23,9 @@ // 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; + +using System; +using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { @@ -69,19 +70,61 @@ namespace ICSharpCode.NRefactory.CSharp Explicit = Mono.CSharp.Operator.OpType.Explicit } - public class OperatorDeclaration : AttributedNode + public class OperatorDeclaration : EntityDeclaration { - public static readonly Role OperatorTypeRole = new Role ("OperatorType", CSharpTokenNode.Null); - public static readonly Role OperatorKeywordRole = Roles.Keyword; + public static readonly TokenRole OperatorKeywordRole = new TokenRole ("operator"); + + // Unary operators + public static readonly TokenRole LogicalNotRole = new TokenRole ("!"); + public static readonly TokenRole OnesComplementRole = new TokenRole ("~"); + public static readonly TokenRole IncrementRole = new TokenRole ("++"); + public static readonly TokenRole DecrementRole = new TokenRole ("--"); + public static readonly TokenRole TrueRole = new TokenRole ("true"); + public static readonly TokenRole FalseRole = new TokenRole ("false"); + + // Unary and Binary operators + public static readonly TokenRole AdditionRole = new TokenRole ("+"); + public static readonly TokenRole SubtractionRole = new TokenRole ("-"); + + // Binary operators + public static readonly TokenRole MultiplyRole = new TokenRole ("*"); + public static readonly TokenRole DivisionRole = new TokenRole ("/"); + public static readonly TokenRole ModulusRole = new TokenRole ("%"); + public static readonly TokenRole BitwiseAndRole = new TokenRole ("&"); + public static readonly TokenRole BitwiseOrRole = new TokenRole ("|"); + public static readonly TokenRole ExclusiveOrRole = new TokenRole ("^"); + public static readonly TokenRole LeftShiftRole = new TokenRole ("<<"); + public static readonly TokenRole RightShiftRole = new TokenRole (">>"); + public static readonly TokenRole EqualityRole = new TokenRole ("=="); + public static readonly TokenRole InequalityRole = new TokenRole ("!="); + public static readonly TokenRole GreaterThanRole = new TokenRole (">"); + public static readonly TokenRole LessThanRole = new TokenRole ("<"); + public static readonly TokenRole GreaterThanOrEqualRole = new TokenRole (">="); + public static readonly TokenRole LessThanOrEqualRole = new TokenRole ("<="); + + public static readonly TokenRole ExplicitRole = new TokenRole ("explicit"); + public static readonly TokenRole ImplicitRole = new TokenRole ("implicit"); + + public override EntityType EntityType { + get { return EntityType.Operator; } + } + + OperatorType operatorType; public OperatorType OperatorType { - get; - set; + get { return operatorType; } + set { + ThrowIfFrozen(); + operatorType = value; + } } - public AstType ReturnType { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole (Roles.Type, value); } + public CSharpTokenNode OperatorToken { + get { return GetChildByRole (OperatorKeywordRole); } + } + + public CSharpTokenNode OperatorTypeToken { + get { return GetChildByRole (GetRole (OperatorType)); } } public CSharpTokenNode LParToken { @@ -109,6 +152,68 @@ namespace ICSharpCode.NRefactory.CSharp return (OperatorType?)Mono.CSharp.Operator.GetType(methodName); } + public static TokenRole GetRole (OperatorType type) + { + switch (type) { + case OperatorType.LogicalNot: + return LogicalNotRole; + case OperatorType.OnesComplement: + return OnesComplementRole; + case OperatorType.Increment: + return IncrementRole; + case OperatorType.Decrement: + return DecrementRole; + case OperatorType.True: + return TrueRole; + case OperatorType.False: + return FalseRole; + + case OperatorType.Addition: + case OperatorType.UnaryPlus: + return AdditionRole; + case OperatorType.Subtraction: + case OperatorType.UnaryNegation: + return SubtractionRole; + + case OperatorType.Multiply: + return MultiplyRole; + case OperatorType.Division: + return DivisionRole; + case OperatorType.Modulus: + return ModulusRole; + case OperatorType.BitwiseAnd: + return BitwiseAndRole; + case OperatorType.BitwiseOr: + return BitwiseOrRole; + case OperatorType.ExclusiveOr: + return ExclusiveOrRole; + case OperatorType.LeftShift: + return LeftShiftRole; + case OperatorType.RightShift: + return RightShiftRole; + case OperatorType.Equality: + return EqualityRole; + case OperatorType.Inequality: + return InequalityRole; + case OperatorType.GreaterThan: + return GreaterThanRole; + case OperatorType.LessThan: + return LessThanRole; + case OperatorType.GreaterThanOrEqual: + return GreaterThanOrEqualRole; + case OperatorType.LessThanOrEqual: + return LessThanOrEqualRole; + + case OperatorType.Implicit: + return ImplicitRole; + case OperatorType.Explicit: + return ExplicitRole; + + default: + throw new System.ArgumentOutOfRangeException (); + } + } + /// /// Gets the method name for the operator type. ("op_Addition", "op_Implicit", etc.) /// @@ -125,17 +230,29 @@ namespace ICSharpCode.NRefactory.CSharp return Mono.CSharp.Operator.GetName ((Mono.CSharp.Operator.OpType)type); } - public override NodeType NodeType { - get { return NodeType.Member; } + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitOperatorDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitOperatorDeclaration (this); } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitOperatorDeclaration (this, data); } - public string Name { + public override string Name { get { return GetName (this.OperatorType); } + set { throw new NotSupportedException(); } + } + + public override Identifier NameToken { + get { return Identifier.Null; } + set { throw new NotSupportedException(); } } protected internal override bool DoMatch (AstNode other, PatternMatching.Match match) diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ParameterDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ParameterDeclaration.cs index 332973004..15b4993d2 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ParameterDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ParameterDeclaration.cs @@ -40,8 +40,11 @@ namespace ICSharpCode.NRefactory.CSharp public class ParameterDeclaration : AstNode { - public static readonly Role AttributeRole = AttributedNode.AttributeRole; - public static readonly Role ModifierRole = new Role("Modifier", CSharpTokenNode.Null); + public static readonly Role AttributeRole = EntityDeclaration.AttributeRole; + public static readonly TokenRole RefModifierRole = new TokenRole("ref"); + public static readonly TokenRole OutModifierRole = new TokenRole("out"); + public static readonly TokenRole ParamsModifierRole = new TokenRole("params"); + public static readonly TokenRole ThisModifierRole = new TokenRole("this"); public override NodeType NodeType { get { @@ -53,9 +56,14 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildrenByRole (AttributeRole); } } + ParameterModifier parameterModifier; + public ParameterModifier ParameterModifier { - get; - set; + get { return parameterModifier; } + set { + ThrowIfFrozen(); + parameterModifier = value; + } } public AstType Type { @@ -68,7 +76,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value)); } } @@ -86,7 +94,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Expression, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitParameterDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitParameterDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitParameterDeclaration (this, data); } @@ -103,10 +121,11 @@ namespace ICSharpCode.NRefactory.CSharp { } - public ParameterDeclaration(AstType type, string name) + public ParameterDeclaration(AstType type, string name, ParameterModifier modifier = ParameterModifier.None) { - this.Type = type; - this.Name = name; + Type = type; + Name = name; + ParameterModifier = modifier; } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/PropertyDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/PropertyDeclaration.cs index 536266750..df0fa9876 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/PropertyDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/PropertyDeclaration.cs @@ -23,14 +23,30 @@ // 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.TypeSystem; namespace ICSharpCode.NRefactory.CSharp { - public class PropertyDeclaration : MemberDeclaration + public class PropertyDeclaration : EntityDeclaration { + public static readonly TokenRole GetKeywordRole = new TokenRole ("get"); + public static readonly TokenRole SetKeywordRole = new TokenRole ("set"); public static readonly Role GetterRole = new Role("Getter", Accessor.Null); public static readonly Role SetterRole = new Role("Setter", Accessor.Null); + public override EntityType EntityType { + get { return EntityType.Property; } + } + + /// + /// Gets/Sets the type reference of the interface that is explicitly implemented. + /// Null node if this member is not an explicit interface implementation. + /// + public AstType PrivateImplementationType { + get { return GetChildByRole (PrivateImplementationTypeRole); } + set { SetChildByRole (PrivateImplementationTypeRole, value); } + } + public CSharpTokenNode LBraceToken { get { return GetChildByRole (Roles.LBrace); } } @@ -49,7 +65,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return GetChildByRole (Roles.RBrace); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPropertyDeclaration (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPropertyDeclaration (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitPropertyDeclaration (this, data); } @@ -57,7 +83,9 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { PropertyDeclaration o = other as PropertyDeclaration; - return o != null && this.MatchMember(o, match) + return o != null && MatchString(this.Name, o.Name) + && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) + && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) && this.Getter.DoMatch(o.Getter, match) && this.Setter.DoMatch(o.Setter, match); } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs index 314fca0c9..8b0c3fff2 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/VariableInitializer.cs @@ -28,6 +28,38 @@ namespace ICSharpCode.NRefactory.CSharp { public class VariableInitializer : AstNode { + #region Null + public new static readonly VariableInitializer Null = new NullVariableInitializer (); + + sealed class NullVariableInitializer : VariableInitializer + { + public override bool IsNull { + get { + return true; + } + } + + public override void AcceptVisitor (IAstVisitor visitor) + { + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return default (T); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) + { + return default (S); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + return other == null || other.IsNull; + } + } + #endregion + #region PatternPlaceholder public static implicit operator VariableInitializer(PatternMatching.Pattern pattern) { @@ -47,7 +79,17 @@ namespace ICSharpCode.NRefactory.CSharp get { return NodeType.Pattern; } } - public override S AcceptVisitor(IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitPatternPlaceholder (this, child); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitPatternPlaceholder (this, child); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) { return visitor.VisitPatternPlaceholder(this, child, data); } @@ -85,7 +127,7 @@ namespace ICSharpCode.NRefactory.CSharp return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole (Roles.Identifier, Identifier.Create (value, TextLocation.Empty)); + SetChildByRole (Roles.Identifier, Identifier.Create (value)); } } @@ -107,7 +149,17 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (Roles.Expression, value); } } - public override S AcceptVisitor (IAstVisitor visitor, T data = default(T)) + public override void AcceptVisitor (IAstVisitor visitor) + { + visitor.VisitVariableInitializer (this); + } + + public override T AcceptVisitor (IAstVisitor visitor) + { + return visitor.VisitVariableInitializer (this); + } + + public override S AcceptVisitor (IAstVisitor visitor, T data) { return visitor.VisitVariableInitializer (this, data); } diff --git a/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs b/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs index e3429861c..b7475d4ce 100644 --- a/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs +++ b/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs @@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.CSharp protected CSharpProjectContent(CSharpProjectContent pc) { this.assemblyName = pc.assemblyName; - this.parsedFiles = new Dictionary(pc.parsedFiles); + this.parsedFiles = new Dictionary(pc.parsedFiles, Platform.FileNameComparer); this.assemblyReferences = new List(pc.assemblyReferences); } diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index c0a7b1a71..8f1f98f00 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -1,4 +1,4 @@ -// +// // CSharpCompletionEngine.cs // // Author: @@ -59,218 +59,306 @@ namespace ICSharpCode.NRefactory.CSharp.Completion public CSharpCompletionEngine (IDocument document, ICompletionDataFactory factory, IProjectContent content, CSharpTypeResolveContext ctx, CompilationUnit unit, CSharpParsedFile parsedFile) : base (content, ctx, unit, parsedFile) { - if (document == null) + if (document == null) { throw new ArgumentNullException ("document"); - if (factory == null) + } + if (factory == null) { throw new ArgumentNullException ("factory"); + } this.document = document; this.factory = factory; // Set defaults for additional input properties - this.FormattingPolicy = new CSharpFormattingOptions(); + this.FormattingPolicy = FormattingOptionsFactory.CreateMono (); this.EolMarker = Environment.NewLine; this.IndentString = "\t"; } - public IEnumerable GetCompletionData (int offset, bool controlSpace) + public bool TryGetCompletionWord (int offset, out int startPos, out int wordLength) + { + startPos = wordLength = 0; + int pos = offset - 1; + while (pos >= 0) { + char c = document.GetCharAt (pos); + if (!char.IsLetterOrDigit (c) && c != '_') + break; + pos--; + } + if (pos == -1) + return false; + + pos++; + startPos = pos; + + while (pos < document.TextLength) { + char c = document.GetCharAt (pos); + if (!char.IsLetterOrDigit (c) && c != '_') + break; + pos++; + } + wordLength = pos - startPos; + return true; + } + + + + public IEnumerable GetCompletionData(int offset, bool controlSpace) { this.AutoCompleteEmptyMatch = true; this.AutoSelect = true; this.DefaultCompletionString = null; - SetOffset (offset); + SetOffset(offset); if (offset > 0) { - char lastChar = document.GetCharAt (offset - 1); - var result = MagicKeyCompletion (lastChar, controlSpace) ?? Enumerable.Empty (); - if (controlSpace && char.IsWhiteSpace (lastChar)) { + char lastChar = document.GetCharAt(offset - 1); + var result = MagicKeyCompletion(lastChar, controlSpace) ?? Enumerable.Empty(); + if (controlSpace && char.IsWhiteSpace(lastChar)) { offset -= 2; - while (offset >= 0 && char.IsWhiteSpace (document.GetCharAt (offset))) + while (offset >= 0 && char.IsWhiteSpace (document.GetCharAt (offset))) { offset--; + } if (offset > 0) { - var nonWsResult = MagicKeyCompletion (document.GetCharAt (offset), controlSpace); + var nonWsResult = MagicKeyCompletion(document.GetCharAt(offset), controlSpace); if (nonWsResult != null) { - var text = new HashSet (result.Select (r => r.CompletionText)); - result = result.Concat (nonWsResult.Where (r => !text.Contains (r.CompletionText))); + var text = new HashSet (result.Select(r => r.CompletionText)); + result = result.Concat(nonWsResult.Where(r => !text.Contains(r.CompletionText))); } } } return result; } - return Enumerable.Empty (); + return Enumerable.Empty(); } - IEnumerable GenerateNameProposals (AstType type) + IEnumerable GenerateNameProposals(AstType type) { if (type is PrimitiveType) { var pt = (PrimitiveType)type; switch (pt.Keyword) { - case "object": - yield return "o"; - yield return "obj"; - break; - case "bool": - yield return "b"; - yield return "pred"; - break; - case "double": - case "float": - case "decimal": - yield return "d"; - yield return "f"; - yield return "m"; - break; - default: - yield return "i"; - yield return "j"; - yield return "k"; - break; + case "object": + yield return "o"; + yield return "obj"; + break; + case "bool": + yield return "b"; + yield return "pred"; + break; + case "double": + case "float": + case "decimal": + yield return "d"; + yield return "f"; + yield return "m"; + break; + default: + yield return "i"; + yield return "j"; + yield return "k"; + break; } yield break; } - - var names = new List (); - int offset1 = document.GetOffset (type.StartLocation); - int offset2 = document.GetOffset (type.EndLocation); - - string name = document.GetText (offset1, offset2 - offset1); - int lastNameStart = 0; - for (int i = 1; i < name.Length; i++) { - if (Char.IsUpper (name [i])) { - names.Add (name.Substring (lastNameStart, i - lastNameStart)); - lastNameStart = i; - } + string name; + if (type is SimpleType) { + name = ((SimpleType)type).Identifier; + } else if (type is MemberType) { + name = ((SimpleType)type).Identifier; + } else { + yield break; } - - names.Add (name.Substring (lastNameStart, name.Length - lastNameStart)); - - var possibleName = new StringBuilder (); + + var names = WordParser.BreakWords(name); + + var possibleName = new StringBuilder(); for (int i = 0; i < names.Count; i++) { possibleName.Length = 0; for (int j = i; j < names.Count; j++) { - if (string.IsNullOrEmpty (names [j])) + if (string.IsNullOrEmpty(names [j])) { continue; - if (j == i) - names [j] = Char.ToLower (names [j] [0]) + names [j].Substring (1); - possibleName.Append (names [j]); + } + if (j == i) { + names [j] = Char.ToLower(names [j] [0]) + names [j].Substring(1); + } + possibleName.Append(names [j]); } - yield return possibleName.ToString (); + yield return possibleName.ToString(); } } - IEnumerable MagicKeyCompletion (char completionChar, bool controlSpace) + IEnumerable HandleMemberReferenceCompletion(ExpressionResult expr) { - switch (completionChar) { - // Magic key completion - case ':': - case '.': - if (IsInsideCommentOrString ()) - return Enumerable.Empty (); - var expr = GetExpressionBeforeCursor (); - if (expr == null) + if (expr == null) + return null; + + // do not complete . (but ..) + if (expr.Node is PrimitiveExpression) { + var pexpr = (PrimitiveExpression)expr.Node; + if (!(pexpr.Value is string || pexpr.Value is char) && !pexpr.LiteralValue.Contains('.')) { return null; - // do not complete . (but ..) - if (expr.Item2 is PrimitiveExpression) { - var pexpr = (PrimitiveExpression)expr.Item2; - if (!(pexpr.Value is string || pexpr.Value is char) && !pexpr.LiteralValue.Contains ('.')) - return null; } - - var resolveResult = ResolveExpression (expr.Item1, expr.Item2, expr.Item3); - if (resolveResult == null) - return null; - if (expr.Item2 is AstType) - return CreateTypeAndNamespaceCompletionData (location, resolveResult.Item1, expr.Item2, resolveResult.Item2); - return CreateCompletionData (location, resolveResult.Item1, expr.Item2, resolveResult.Item2); - case '#': - if (IsInsideCommentOrString ()) - return null; - return GetDirectiveCompletionData (); + } -// XML doc completion - case '<': - if (IsInsideDocComment ()) - return GetXmlDocumentationCompletionData (); - if (controlSpace) - return DefaultControlSpaceItems (); + var resolveResult = ResolveExpression (expr); + if (resolveResult == null) { return null; - case '>': - if (!IsInsideDocComment ()) + } + if (expr.Node is AstType) { + return CreateTypeAndNamespaceCompletionData(location, resolveResult.Item1, expr.Node, resolveResult.Item2); + } + return CreateCompletionData(location, resolveResult.Item1, expr.Node, resolveResult.Item2); + } + + bool IsInPreprocessorDirective() + { + var text = GetMemberTextToCaret().Item1; + var miniLexer = new MiniLexer(text); + miniLexer.Parse(); + return miniLexer.IsInPreprocessorDirective; + } + + IEnumerable HandleObjectInitializer(CompilationUnit unit, AstNode n) + { + var p = n.Parent; + while (p != null && !(p is ObjectCreateExpression)) { + p = p.Parent; + } + if (p != null) { + var contextList = new CompletionDataWrapper(this); + var initializerResult = ResolveExpression(p, unit); + if (initializerResult != null && initializerResult.Item1.Type.Kind != TypeKind.Unknown) { + + foreach (var m in initializerResult.Item1.Type.GetMembers (m => m.IsPublic && (m.EntityType == EntityType.Property || m.EntityType == EntityType.Field))) { + contextList.AddMember(m); + } + var enumerableType = typeof(IEnumerable<>).ToTypeReference().Resolve(ctx); + // check if we may be in a collection initializer, or enumerable initializer + if (enumerableType.Kind == TypeKind.Unknown || !initializerResult.Item1.Type.GetDefinition().IsDerivedFrom(enumerableType.GetDefinition())) { + return contextList.Result; + } + } + } + return null; + } + + IEnumerable MagicKeyCompletion(char completionChar, bool controlSpace) + { + ExpressionResult expr; + Tuple resolveResult; + switch (completionChar) { + // Magic key completion + case ':': + case '.': + if (IsInsideCommentStringOrDirective()) { + return Enumerable.Empty(); + } + return HandleMemberReferenceCompletion(GetExpressionBeforeCursor()); + case '#': + if (!IsInPreprocessorDirective()) + return null; + return GetDirectiveCompletionData(); + // XML doc completion + case '<': + if (IsInsideDocComment()) { + return GetXmlDocumentationCompletionData(); + } + if (controlSpace) { + return DefaultControlSpaceItems(); + } return null; - string lineText = document.GetText (document.GetLineByNumber (location.Line)); - int startIndex = Math.Min (location.Column - 1, lineText.Length - 1); + case '>': + if (!IsInsideDocComment()) { + return null; + } + string lineText = document.GetText(document.GetLineByNumber(location.Line)); + int startIndex = Math.Min(location.Column - 1, lineText.Length - 1); - while (startIndex >= 0 && lineText [startIndex] != '<') { - --startIndex; - if (lineText [startIndex] == '/') { // already closed. - startIndex = -1; - break; + while (startIndex >= 0 && lineText [startIndex] != '<') { + --startIndex; + if (lineText [startIndex] == '/') { + // already closed. + startIndex = -1; + break; + } } - } - if (startIndex >= 0) { - int endIndex = startIndex; - while (endIndex <= location.Column && endIndex < lineText.Length && !Char.IsWhiteSpace (lineText [endIndex])) { - endIndex++; + if (startIndex >= 0) { + int endIndex = startIndex; + while (endIndex <= location.Column && endIndex < lineText.Length && !Char.IsWhiteSpace (lineText [endIndex])) { + endIndex++; + } + string tag = endIndex - startIndex - 1 > 0 ? lineText.Substring(startIndex + 1, endIndex - startIndex - 2) : null; + if (!string.IsNullOrEmpty(tag) && commentTags.IndexOf(tag) >= 0) { + document.Insert(offset, ""); + } } - string tag = endIndex - startIndex - 1 > 0 ? lineText.Substring (startIndex + 1, endIndex - startIndex - 2) : null; - if (!string.IsNullOrEmpty (tag) && commentTags.IndexOf (tag) >= 0) - document.Insert (offset, ""); - } - return null; + return null; // Parameter completion - case '(': - if (IsInsideCommentOrString ()) - return null; - var invoke = GetInvocationBeforeCursor (true); - if (invoke == null) - return null; - if (invoke.Item2 is TypeOfExpression) - return CreateTypeList (); - var invocationResult = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); - if (invocationResult == null) - return null; - var methodGroup = invocationResult.Item1 as MethodGroupResolveResult; - if (methodGroup != null) - return CreateParameterCompletion (methodGroup, invocationResult.Item2, invoke.Item2, 0, controlSpace); - - if (controlSpace) - return DefaultControlSpaceItems (invoke); + case '(': + if (IsInsideCommentStringOrDirective()) { + return null; + } + var invoke = GetInvocationBeforeCursor(true); + if (invoke == null) { + if (controlSpace) + return DefaultControlSpaceItems(invoke); + return null; + } + if (invoke.Node is TypeOfExpression) { + return CreateTypeList(); + } + var invocationResult = ResolveExpression(invoke); + if (invocationResult == null) { + return null; + } + var methodGroup = invocationResult.Item1 as MethodGroupResolveResult; + if (methodGroup != null) { + return CreateParameterCompletion(methodGroup, invocationResult.Item2, invoke.Node, invoke.Unit, 0, controlSpace); + } - return null; - case '=': - return controlSpace ? DefaultControlSpaceItems () : null; - case ',': - int cpos2; - if (!GetParameterCompletionCommandOffset (out cpos2)) + if (controlSpace) { + return DefaultControlSpaceItems(invoke); + } return null; + case '=': + return controlSpace ? DefaultControlSpaceItems() : null; + case ',': + int cpos2; + if (!GetParameterCompletionCommandOffset(out cpos2)) { + return null; + } // completionContext = CompletionWidget.CreateCodeCompletionContext (cpos2); // int currentParameter2 = MethodParameterDataProvider.GetCurrentParameterIndex (CompletionWidget, completionContext) - 1; // return CreateParameterCompletion (CreateResolver (), location, ExpressionContext.MethodBody, provider.Methods, currentParameter); - break; + break; // Completion on space: - case ' ': - if (IsInsideCommentOrString ()) - return null; - - int tokenIndex = offset; - string token = GetPreviousToken (ref tokenIndex, false); + case ' ': + int tokenIndex = offset; + string token = GetPreviousToken(ref tokenIndex, false); + if (IsInsideCommentStringOrDirective()) { + if (IsInPreprocessorDirective()) + return HandleKeywordCompletion(tokenIndex, token); + return null; + } // check propose name, for context (but only in control space context) //IType isAsType = null; - var isAsExpression = GetExpressionAt (offset); - if (controlSpace && isAsExpression != null && isAsExpression.Item2 is VariableDeclarationStatement && token != "new") { - var parent = isAsExpression.Item2 as VariableDeclarationStatement; - var proposeNameList = new CompletionDataWrapper (this); + var isAsExpression = GetExpressionAt(offset); + if (controlSpace && isAsExpression != null && isAsExpression.Node is VariableDeclarationStatement && token != "new") { + var parent = isAsExpression.Node as VariableDeclarationStatement; + var proposeNameList = new CompletionDataWrapper(this); + if (parent.Variables.Count != 1) + return DefaultControlSpaceItems(isAsExpression, controlSpace); + + foreach (var possibleName in GenerateNameProposals (parent.Type)) { + if (possibleName.Length > 0) { + proposeNameList.Result.Add(factory.CreateLiteralCompletionData(possibleName.ToString())); + } + } - foreach (var possibleName in GenerateNameProposals (parent.Type)) { - if (possibleName.Length > 0) - proposeNameList.Result.Add (factory.CreateLiteralCompletionData (possibleName.ToString ())); + AutoSelect = false; + AutoCompleteEmptyMatch = false; + return proposeNameList.Result; } - - AutoSelect = false; - AutoCompleteEmptyMatch = false; - return proposeNameList.Result; - } // int tokenIndex = offset; // string token = GetPreviousToken (ref tokenIndex, false); // if (result.ExpressionContext == ExpressionContext.ObjectInitializer) { @@ -280,51 +368,58 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // if (objectInitializer != null && objectInitializer.ArrayDimensions == 0 && objectInitializer.PointerNestingLevel == 0 && (token == "{" || token == ",")) // return CreateCtrlSpaceCompletionData (completionContext, result); // } - if (token == "=") { - int j = tokenIndex; - string prevToken = GetPreviousToken (ref j, false); - if (prevToken == "=" || prevToken == "+" || prevToken == "-") { - token = prevToken + token; - tokenIndex = j; - } - } - switch (token) { - case "(": - case ",": - int cpos; - if (!GetParameterCompletionCommandOffset (out cpos)) - break; - int currentParameter = GetCurrentParameterIndex (cpos, 0) - 1; - if (currentParameter < 0) - return null; - invoke = GetInvocationBeforeCursor (token == "("); - if (invoke == null) - return null; - invocationResult = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); - if (invocationResult == null) - return null; - methodGroup = invocationResult.Item1 as MethodGroupResolveResult; - if (methodGroup != null) - return CreateParameterCompletion (methodGroup, invocationResult.Item2, invoke.Item2, currentParameter, controlSpace); - return null; - case "=": - case "==": - GetPreviousToken (ref tokenIndex, false); - var expressionOrVariableDeclaration = GetExpressionAt (tokenIndex); - if (expressionOrVariableDeclaration == null) - return null; + if (token == "=") { + int j = tokenIndex; + string prevToken = GetPreviousToken(ref j, false); + if (prevToken == "=" || prevToken == "+" || prevToken == "-") { + token = prevToken + token; + tokenIndex = j; + } + } + switch (token) { + case "(": + case ",": + int cpos; + if (!GetParameterCompletionCommandOffset(out cpos)) { + break; + } + int currentParameter = GetCurrentParameterIndex(cpos, 0) - 1; + if (currentParameter < 0) { + return null; + } + invoke = GetInvocationBeforeCursor(token == "("); + if (invoke == null) { + return null; + } + invocationResult = ResolveExpression(invoke); + if (invocationResult == null) { + return null; + } + methodGroup = invocationResult.Item1 as MethodGroupResolveResult; + if (methodGroup != null) { + return CreateParameterCompletion(methodGroup, invocationResult.Item2, invoke.Node, invoke.Unit, currentParameter, controlSpace); + } + return null; + case "=": + case "==": + GetPreviousToken(ref tokenIndex, false); + var expressionOrVariableDeclaration = GetExpressionAt(tokenIndex); + if (expressionOrVariableDeclaration == null) { + return null; + } - resolveResult = ResolveExpression (expressionOrVariableDeclaration.Item1, expressionOrVariableDeclaration.Item2, expressionOrVariableDeclaration.Item3); + resolveResult = ResolveExpression(expressionOrVariableDeclaration); - if (resolveResult == null) - return null; - if (resolveResult.Item1.Type.Kind == TypeKind.Enum) { - var wrapper = new CompletionDataWrapper (this); - AddContextCompletion (wrapper, resolveResult.Item2, expressionOrVariableDeclaration.Item2); - AddEnumMembers (wrapper, resolveResult.Item1.Type, resolveResult.Item2); - AutoCompleteEmptyMatch = false; - return wrapper.Result; - } + if (resolveResult == null) { + return null; + } + if (resolveResult.Item1.Type.Kind == TypeKind.Enum) { + var wrapper = new CompletionDataWrapper(this); + AddContextCompletion(wrapper, resolveResult.Item2, expressionOrVariableDeclaration.Node, expressionOrVariableDeclaration.Unit); + AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); + AutoCompleteEmptyMatch = false; + return wrapper.Result; + } // // if (resolvedType.FullName == DomReturnType.Bool.FullName) { // CompletionDataList completionList = new ProjectDomCompletionDataList (); @@ -349,280 +444,360 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // } // return completionList; // } - return null; - case "+=": - case "-=": - GetPreviousToken (ref tokenIndex, false); + return null; + case "+=": + case "-=": + GetPreviousToken(ref tokenIndex, false); - expressionOrVariableDeclaration = GetExpressionAt (tokenIndex); - if (expressionOrVariableDeclaration == null) - return null; + expressionOrVariableDeclaration = GetExpressionAt(tokenIndex); + if (expressionOrVariableDeclaration == null) { + return null; + } - resolveResult = ResolveExpression (expressionOrVariableDeclaration.Item1, expressionOrVariableDeclaration.Item2, expressionOrVariableDeclaration.Item3); - if (resolveResult == null) - return null; + resolveResult = ResolveExpression(expressionOrVariableDeclaration); + if (resolveResult == null) { + return null; + } - var mrr = resolveResult.Item1 as MemberResolveResult; - if (mrr != null) { - var evt = mrr.Member as IEvent; - if (evt == null) - return null; - var delegateType = evt.ReturnType; - if (delegateType.Kind != TypeKind.Delegate) - return null; + var mrr = resolveResult.Item1 as MemberResolveResult; + if (mrr != null) { + var evt = mrr.Member as IEvent; + if (evt == null) { + return null; + } + var delegateType = evt.ReturnType; + if (delegateType.Kind != TypeKind.Delegate) { + return null; + } - var wrapper = new CompletionDataWrapper (this); - if (currentType != null) { -// bool includeProtected = DomType.IncludeProtected (dom, typeFromDatabase, resolver.CallingType); - foreach (var method in currentType.Methods) { - if (MatchDelegate (delegateType, method) /*&& method.IsAccessibleFrom (dom, resolver.CallingType, resolver.CallingMember, includeProtected) &&*/) { - wrapper.AddMember (method); -// data.SetText (data.CompletionText + ";"); + var wrapper = new CompletionDataWrapper(this); + if (currentType != null) { + // bool includeProtected = DomType.IncludeProtected (dom, typeFromDatabase, resolver.CallingType); + foreach (var method in currentType.Methods) { + if (MatchDelegate(delegateType, method) /*&& method.IsAccessibleFrom (dom, resolver.CallingType, resolver.CallingMember, includeProtected) &&*/) { + wrapper.AddMember(method); + // data.SetText (data.CompletionText + ";"); + } + } + } + if (token == "+=") { + string parameterDefinition = AddDelegateHandlers(wrapper, delegateType); + string varName = GetPreviousMemberReferenceExpression(tokenIndex); + wrapper.Result.Add(factory.CreateEventCreationCompletionData(varName, delegateType, evt, parameterDefinition, currentMember, currentType)); } - } - } - if (token == "+=") { - string parameterDefinition = AddDelegateHandlers (wrapper, delegateType); - string varName = GetPreviousMemberReferenceExpression (tokenIndex); - wrapper.Result.Add (factory.CreateEventCreationCompletionData (varName, delegateType, evt, parameterDefinition, currentMember, currentType)); - } - return wrapper.Result; + return wrapper.Result; + } + return null; + case ":": + if (currentMember == null) { + token = GetPreviousToken(ref tokenIndex, false); + token = GetPreviousToken(ref tokenIndex, false); + if (token == "enum") + return HandleEnumContext(); + var wrapper = new CompletionDataWrapper(this); + + AddTypesAndNamespaces(wrapper, GetState(), null, t => currentType != null && !currentType.ReflectionName.Equals(t.ReflectionName) ? t : null); + return wrapper.Result; + } + return null; } - return null; - case ":": - -/* Breaks constructor initializer case: - * if (currentMember == null) { - var wrapper = new CompletionDataWrapper (this); - AddTypesAndNamespaces (wrapper, GetState (), null, t => currentType != null ? !currentType.Equals (t) : true); - return wrapper.Result; - }*/ - return null; - } - var keywordCompletion = HandleKeywordCompletion (tokenIndex, token); - if (keywordCompletion == null && controlSpace) - goto default; - return keywordCompletion; + var keywordCompletion = HandleKeywordCompletion(tokenIndex, token); + if (keywordCompletion == null && controlSpace) { + goto default; + } + return keywordCompletion; // Automatic completion - default: - if (IsInsideCommentOrString ()) - return null; - if (IsInLinqContext (offset)) { - if (!controlSpace && !(char.IsLetter (completionChar) || completionChar == '_')) + default: + if (IsInsideCommentStringOrDirective()) { return null; - tokenIndex = offset; - token = GetPreviousToken (ref tokenIndex, false); // token last typed - if (!char.IsWhiteSpace (completionChar) && !linqKeywords.Contains (token)) - token = GetPreviousToken (ref tokenIndex, false); // token last typed - - if (linqKeywords.Contains (token)) { - if (token == "from") // after from no auto code completion. + } + if (IsInLinqContext(offset)) { + if (!controlSpace && !(char.IsLetter(completionChar) || completionChar == '_')) { return null; - return DefaultControlSpaceItems (); + } + tokenIndex = offset; + token = GetPreviousToken(ref tokenIndex, false); + // token last typed + if (!char.IsWhiteSpace(completionChar) && !linqKeywords.Contains(token)) { + token = GetPreviousToken(ref tokenIndex, false); + } + // token last typed + + if (linqKeywords.Contains(token)) { + if (token == "from") { + // after from no auto code completion. + return null; + } + return DefaultControlSpaceItems(); + } + var dataList = new CompletionDataWrapper(this); + AddKeywords(dataList, linqKeywords); + return dataList.Result; } - var dataList = new CompletionDataWrapper (this); - AddKeywords (dataList, linqKeywords); - return dataList.Result; - } - if (currentType != null && currentType.Kind == TypeKind.Enum) - return HandleEnumContext (); - - var contextList = new CompletionDataWrapper (this); - var identifierStart = GetExpressionAtCursor (); - - if (identifierStart != null && identifierStart.Item2 is TypeParameterDeclaration) - return null; - - if (identifierStart != null && identifierStart.Item2 is VariableInitializer && location <= ((VariableInitializer)identifierStart.Item2).NameToken.EndLocation) { - return controlSpace ? HandleAccessorContext () ?? DefaultControlSpaceItems (identifierStart) : null; - } - if (!(char.IsLetter (completionChar) || completionChar == '_') && (!controlSpace || identifierStart == null || !(identifierStart.Item2 is ArrayInitializerExpression))) { - return controlSpace ? HandleAccessorContext () ?? DefaultControlSpaceItems (identifierStart) : null; - } - char prevCh = offset > 2 ? document.GetCharAt (offset - 2) : ';'; - char nextCh = offset < document.TextLength ? document.GetCharAt (offset) : ' '; - const string allowedChars = ";,[](){}+-*/%^?:&|~!<>="; - if (!Char.IsWhiteSpace (nextCh) && allowedChars.IndexOf (nextCh) < 0) - return null; - if (!(Char.IsWhiteSpace (prevCh) || allowedChars.IndexOf (prevCh) >= 0)) - return null; - // Do not pop up completion on identifier identifier (should be handled by keyword completion). - tokenIndex = offset - 1; - token = GetPreviousToken (ref tokenIndex, false); - if (token == "class" || token == "interface" || token == "struct" || token == "enum" || token == "namespace") // after these always follows a name - return null; - int prevTokenIndex = tokenIndex; - var prevToken2 = GetPreviousToken (ref prevTokenIndex, false); - if (prevToken2 == "delegate") // after these always follows a name - return null; - if (identifierStart == null && !string.IsNullOrEmpty (token) && !(IsInsideComment (tokenIndex) || IsInsideString (tokenIndex)) && (prevToken2 == ";" || prevToken2 == "{" || prevToken2 == "}")) { - char last = token [token.Length - 1]; - if (char.IsLetterOrDigit (last) || last == '_' || token == ">") { - return HandleKeywordCompletion (tokenIndex, token); + if (currentType != null && currentType.Kind == TypeKind.Enum) { + return HandleEnumContext(); } - } - if (identifierStart == null) { - var accCtx = HandleAccessorContext (); - if (accCtx != null) - return accCtx; - return DefaultControlSpaceItems (null, controlSpace); - } - CSharpResolver csResolver; - AstNode n = identifierStart.Item2; - - if (n != null && n.Parent is AnonymousTypeCreateExpression) { - AutoSelect = false; - } - // Handle foreach (type name _ - if (n is IdentifierExpression) { - var prev = n.GetPrevNode () as ForeachStatement; - if (prev != null && prev.InExpression.IsNull) { - if (controlSpace) { - contextList.AddCustom ("in"); - return contextList.Result; + var contextList = new CompletionDataWrapper(this); + var identifierStart = GetExpressionAtCursor(); + if (identifierStart != null) { + if (identifierStart.Node is TypeParameterDeclaration) { + return null; + } + + if (identifierStart.Node is MemberReferenceExpression) { + return HandleMemberReferenceCompletion(new ExpressionResult(((MemberReferenceExpression)identifierStart.Node).Target, identifierStart.Unit)); + } + + if (identifierStart.Node is Identifier) { + // May happen in variable names + return controlSpace ? DefaultControlSpaceItems(identifierStart) : null; + } + + if (identifierStart.Node is VariableInitializer && location <= ((VariableInitializer)identifierStart.Node).NameToken.EndLocation) { + return controlSpace ? HandleAccessorContext() ?? DefaultControlSpaceItems(identifierStart) : null; + } + + if (identifierStart.Node is CatchClause) { + if (((CatchClause)identifierStart.Node).VariableNameToken.Contains(location)) { + return null; + } + identifierStart = null; } + } + if (!(char.IsLetter(completionChar) || completionChar == '_') && (!controlSpace || identifierStart == null || !(identifierStart.Node.Parent is ArrayInitializerExpression))) { + return controlSpace ? HandleAccessorContext() ?? DefaultControlSpaceItems(identifierStart) : null; + } + + char prevCh = offset > 2 ? document.GetCharAt(offset - 2) : ';'; + char nextCh = offset < document.TextLength ? document.GetCharAt(offset) : ' '; + const string allowedChars = ";,.[](){}+-*/%^?:&|~!<>="; + if (!Char.IsWhiteSpace(nextCh) && allowedChars.IndexOf(nextCh) < 0) { return null; } - } - if (n != null && n.Parent is InvocationExpression) { - var invokeParent = (InvocationExpression)n.Parent; - var invokeResult = ResolveExpression (identifierStart.Item1, invokeParent.Target, identifierStart.Item3); - var mgr = invokeResult != null ? invokeResult.Item1 as MethodGroupResolveResult : null; - if (mgr != null) { - int idx = 0; - foreach (var arg in invokeParent.Arguments) { - if (arg == n) - break; - idx++; + if (!(Char.IsWhiteSpace(prevCh) || allowedChars.IndexOf(prevCh) >= 0)) { + return null; + } + + // Do not pop up completion on identifier identifier (should be handled by keyword completion). + tokenIndex = offset - 1; + token = GetPreviousToken(ref tokenIndex, false); + if (token == "class" || token == "interface" || token == "struct" || token == "enum" || token == "namespace") { + // after these always follows a name + return null; + } + var keywordresult = HandleKeywordCompletion(tokenIndex, token); + if (keywordresult != null) { + return keywordresult; + } + + int prevTokenIndex = tokenIndex; + var prevToken2 = GetPreviousToken(ref prevTokenIndex, false); + if (prevToken2 == "delegate") { + // after these always follows a name + return null; + } + + if (identifierStart == null && !string.IsNullOrEmpty(token) && !IsInsideCommentStringOrDirective() && (prevToken2 == ";" || prevToken2 == "{" || prevToken2 == "}")) { + char last = token [token.Length - 1]; + if (char.IsLetterOrDigit(last) || last == '_' || token == ">") { + return HandleKeywordCompletion(tokenIndex, token); } - - foreach (var method in mgr.Methods) { - if (idx < method.Parameters.Count && method.Parameters[idx].Type.Kind == TypeKind.Delegate) { - AutoSelect = false; - AutoCompleteEmptyMatch = false; - } - foreach (var p in method.Parameters) { - contextList.AddVariable (p); + } + + if (identifierStart == null) { + var accCtx = HandleAccessorContext(); + if (accCtx != null) { + return accCtx; + } + return DefaultControlSpaceItems(null, controlSpace); + } + CSharpResolver csResolver; + AstNode n = identifierStart.Node; + if (n != null && n.Parent is AnonymousTypeCreateExpression) { + AutoSelect = false; + } + + // Handle foreach (type name _ + if (n is IdentifierExpression) { + var prev = n.GetPrevNode() as ForeachStatement; + if (prev != null && prev.InExpression.IsNull) { + if (controlSpace) { + contextList.AddCustom("in"); + return contextList.Result; } + return null; } - idx++; - foreach (var list in mgr.GetExtensionMethods ()) { - foreach (var method in list) { - if (idx < method.Parameters.Count && method.Parameters[idx].Type.Kind == TypeKind.Delegate) { + } + + // Handle object/enumerable initialzer expressions: "new O () { P$" + if (n is IdentifierExpression && n.Parent is ArrayInitializerExpression) { + var result = HandleObjectInitializer(identifierStart.Unit, n); + if (result != null) + return result; + } + + if (n != null && n.Parent is InvocationExpression) { + var invokeParent = (InvocationExpression)n.Parent; + var invokeResult = ResolveExpression(invokeParent.Target, identifierStart.Unit); + var mgr = invokeResult != null ? invokeResult.Item1 as MethodGroupResolveResult : null; + if (mgr != null) { + int idx = 0; + foreach (var arg in invokeParent.Arguments) { + if (arg == n) { + break; + } + idx++; + } + + foreach (var method in mgr.Methods) { + if (idx < method.Parameters.Count && method.Parameters [idx].Type.Kind == TypeKind.Delegate) { AutoSelect = false; AutoCompleteEmptyMatch = false; } - + foreach (var p in method.Parameters) { + contextList.AddVariable(p); + } + } + idx++; + foreach (var list in mgr.GetExtensionMethods ()) { + foreach (var method in list) { + if (idx < method.Parameters.Count && method.Parameters [idx].Type.Kind == TypeKind.Delegate) { + AutoSelect = false; + AutoCompleteEmptyMatch = false; + } + + } } } } - } - - if (n != null && n.Parent is ObjectCreateExpression) { - var invokeResult = ResolveExpression (identifierStart.Item1, n.Parent, identifierStart.Item3); - var mgr = invokeResult != null ? invokeResult.Item1 as ResolveResult : null; - if (mgr != null) { - foreach (var constructor in mgr.Type.GetConstructors ()) { - foreach (var p in constructor.Parameters) { - contextList.AddVariable (p); + if (n != null && n.Parent is ObjectCreateExpression) { + var invokeResult = ResolveExpression(n.Parent, identifierStart.Unit); + var mgr = invokeResult != null ? invokeResult.Item1 as ResolveResult : null; + if (mgr != null) { + foreach (var constructor in mgr.Type.GetConstructors ()) { + foreach (var p in constructor.Parameters) { + contextList.AddVariable(p); + } } } } - } - - if (n is IdentifierExpression) { - var bop = n.Parent as BinaryOperatorExpression; - Expression evaluationExpr = null; - if (bop != null && bop.Right == n && (bop.Operator == BinaryOperatorType.Equality || bop.Operator == BinaryOperatorType.InEquality)) { - evaluationExpr = bop.Left; - } - // check for compare to enum case - if (evaluationExpr != null) { - resolveResult = ResolveExpression (identifierStart.Item1, evaluationExpr, identifierStart.Item3); - if (resolveResult != null && resolveResult.Item1.Type.Kind == TypeKind.Enum) { - var wrapper = new CompletionDataWrapper (this); - AddContextCompletion (wrapper, resolveResult.Item2, evaluationExpr); - AddEnumMembers (wrapper, resolveResult.Item1.Type, resolveResult.Item2); - AutoCompleteEmptyMatch = false; - return wrapper.Result; + if (n is IdentifierExpression) { + var bop = n.Parent as BinaryOperatorExpression; + Expression evaluationExpr = null; + + if (bop != null && bop.Right == n && (bop.Operator == BinaryOperatorType.Equality || bop.Operator == BinaryOperatorType.InEquality)) { + evaluationExpr = bop.Left; + } + // check for compare to enum case + if (evaluationExpr != null) { + resolveResult = ResolveExpression(evaluationExpr, identifierStart.Unit); + if (resolveResult != null && resolveResult.Item1.Type.Kind == TypeKind.Enum) { + var wrapper = new CompletionDataWrapper(this); + AddContextCompletion(wrapper, resolveResult.Item2, evaluationExpr, identifierStart.Unit); + AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); + AutoCompleteEmptyMatch = false; + return wrapper.Result; + } } } - } - - if (n is Identifier && n.Parent is ForeachStatement) { - if (controlSpace) - return DefaultControlSpaceItems (); - return null; - } - if (n is ArrayInitializerExpression) { - // check for new [] {...} expression -> no need to resolve the type there - var parent = n.Parent as ArrayCreateExpression; - if (parent != null && parent.Type.IsNull) - return DefaultControlSpaceItems (); + if (n is Identifier && n.Parent is ForeachStatement) { + if (controlSpace) { + return DefaultControlSpaceItems(); + } + return null; + } + if (n is ArrayInitializerExpression) { + // check for new [] {...} expression -> no need to resolve the type there + var parent = n.Parent as ArrayCreateExpression; + if (parent != null && parent.Type.IsNull) { + return DefaultControlSpaceItems(); + } - var initalizerResult = ResolveExpression (identifierStart.Item1, n.Parent, identifierStart.Item3); + var initalizerResult = ResolveExpression(n.Parent, identifierStart.Unit); - var concreteNode = identifierStart.Item3.GetNodeAt (location); - // check if we're on the right side of an initializer expression - if (concreteNode != null && concreteNode.Parent != null && concreteNode.Parent.Parent != null && concreteNode.Identifier != "a" && concreteNode.Parent.Parent is NamedExpression) { - return DefaultControlSpaceItems (); - } + var concreteNode = identifierStart.Unit.GetNodeAt(location); + // check if we're on the right side of an initializer expression + if (concreteNode != null && concreteNode.Parent != null && concreteNode.Parent.Parent != null && concreteNode.Identifier != "a" && concreteNode.Parent.Parent is NamedExpression) { + return DefaultControlSpaceItems(); + } - if (initalizerResult != null && initalizerResult.Item1.Type.Kind != TypeKind.Unknown) { - - foreach (var property in initalizerResult.Item1.Type.GetProperties ()) { - if (!property.IsPublic) - continue; - contextList.AddMember (property); + if (initalizerResult != null && initalizerResult.Item1.Type.Kind != TypeKind.Unknown) { + + foreach (var property in initalizerResult.Item1.Type.GetProperties ()) { + if (!property.IsPublic) { + continue; + } + contextList.AddMember(property); + } + foreach (var field in initalizerResult.Item1.Type.GetFields ()) { + if (!field.IsPublic) { + continue; + } + contextList.AddMember(field); + } + return contextList.Result; } - foreach (var field in initalizerResult.Item1.Type.GetFields ()) { - if (!field.IsPublic) - continue; - contextList.AddMember (field); + return DefaultControlSpaceItems(); + } + if (IsAttributeContext(n)) { + // add attribute targets + if (currentType == null) { + contextList.AddCustom("assembly"); + contextList.AddCustom("module"); + contextList.AddCustom("type"); + } else { + contextList.AddCustom("param"); + contextList.AddCustom("field"); + contextList.AddCustom("property"); + contextList.AddCustom("method"); + contextList.AddCustom("event"); } - return contextList.Result; + contextList.AddCustom("return"); } - return DefaultControlSpaceItems (); - } - if (n != null/* && !(identifierStart.Item2 is TypeDeclaration)*/) { - csResolver = new CSharpResolver (ctx); - var nodes = new List (); - nodes.Add (n); - if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) - nodes.Add (n.Parent); - var astResolver = new CSharpAstResolver (csResolver, identifierStart.Item3, identifierStart.Item1); - astResolver.ApplyNavigator (new NodeListResolveVisitorNavigator (nodes)); - try { - csResolver = astResolver.GetResolverStateBefore (n); - } catch (Exception) { - csResolver = GetState (); - } - // add attribute properties. - if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) { - var resolved = astResolver.Resolve (n.Parent); - if (resolved != null && resolved.Type != null) { - foreach (var property in resolved.Type.GetProperties (p => p.Accessibility == Accessibility.Public)) { - contextList.AddMember (property); - } - foreach (var field in resolved.Type.GetFields (p => p.Accessibility == Accessibility.Public)) { - contextList.AddMember (field); + if (n is MemberType) { + resolveResult = ResolveExpression(((MemberType)n).Target, identifierStart.Unit); + return CreateTypeAndNamespaceCompletionData(location, resolveResult.Item1, ((MemberType)n).Target, resolveResult.Item2); + } + if (n != null/* && !(identifierStart.Item2 is TypeDeclaration)*/) { + csResolver = new CSharpResolver (ctx); + var nodes = new List (); + nodes.Add(n); + if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) { + nodes.Add(n.Parent); + } + var astResolver = new CSharpAstResolver (csResolver, identifierStart.Unit, CSharpParsedFile); + astResolver.ApplyNavigator(new NodeListResolveVisitorNavigator (nodes)); + try { + csResolver = astResolver.GetResolverStateBefore(n); + } catch (Exception) { + csResolver = GetState(); + } + // add attribute properties. + if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) { + var resolved = astResolver.Resolve(n.Parent); + if (resolved != null && resolved.Type != null) { + foreach (var property in resolved.Type.GetProperties (p => p.Accessibility == Accessibility.Public)) { + contextList.AddMember(property); + } + foreach (var field in resolved.Type.GetFields (p => p.Accessibility == Accessibility.Public)) { + contextList.AddMember(field); + } } } + } else { + csResolver = GetState(); } - } else { - csResolver = GetState (); - } // identifier has already started with the first letter - offset--; - AddContextCompletion (contextList, csResolver, identifierStart.Item2); - return contextList.Result; + offset--; + AddContextCompletion(contextList, csResolver, identifierStart.Node, identifierStart.Unit); + return contextList.Result; // if (stub.Parent is BlockStatement) // result = FindExpression (dom, completionContext, -1); @@ -691,44 +866,62 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return null; } - - IEnumerable HandleEnumContext () + + string[] validEnumBaseTypes = { "byte", "sbyte", "short", "int", "long", "ushort", "uint", "ulong" }; + IEnumerable HandleEnumContext() { - var cu = ParseStub ("a", false); - if (cu == null) + var cu = ParseStub("a", false); + if (cu == null) { return null; - var member = cu.GetNodeAt (location); - if (member != null && member.NameToken.EndLocation < location) - return DefaultControlSpaceItems (); + } + + var curType = cu.GetNodeAt (location); + if (curType == null || curType.ClassType != ClassType.Enum) { + cu = ParseStub("a {}", false); + var node = cu.GetNodeAt(location); + if (node != null) { + var wrapper = new CompletionDataWrapper(this); + AddKeywords(wrapper, validEnumBaseTypes); + return wrapper.Result; + } + } + + var member = cu.GetNodeAt(location); + if (member != null && member.NameToken.EndLocation < location) { + return DefaultControlSpaceItems(); + } return null; } - bool IsInLinqContext (int offset) + bool IsInLinqContext(int offset) { string token; - while (null != (token = GetPreviousToken (ref offset, true)) && !IsInsideComment (offset) && !IsInsideString (offset)) { - if (token == "from") + while (null != (token = GetPreviousToken (ref offset, true)) && !IsInsideCommentStringOrDirective ()) { + if (token == "from") { return true; - if (token == ";" || token == "{") + } + if (token == ";" || token == "{") { return false; + } } return false; } - IEnumerable HandleAccessorContext () + IEnumerable HandleAccessorContext() { - var unit = ParseStub ("get; }", false); - var node = unit.GetNodeAt (location, cn => !(cn is CSharpTokenNode)); - if (node is Accessor) + var unit = ParseStub("get; }", false); + var node = unit.GetNodeAt(location, cn => !(cn is CSharpTokenNode)); + if (node is Accessor) { node = node.Parent; - var contextList = new CompletionDataWrapper (this); + } + var contextList = new CompletionDataWrapper(this); if (node is PropertyDeclaration) { - contextList.AddCustom ("get"); - contextList.AddCustom ("set"); - AddKeywords (contextList, accessorModifierKeywords); + contextList.AddCustom("get"); + contextList.AddCustom("set"); + AddKeywords(contextList, accessorModifierKeywords); } else if (node is CustomEventDeclaration) { - contextList.AddCustom ("add"); - contextList.AddCustom ("remove"); + contextList.AddCustom("add"); + contextList.AddCustom("remove"); } else { return null; } @@ -736,50 +929,57 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return contextList.Result; } - IEnumerable DefaultControlSpaceItems (Tuple xp = null, bool controlSpace = true) + IEnumerable DefaultControlSpaceItems(ExpressionResult xp = null, bool controlSpace = true) { - var wrapper = new CompletionDataWrapper (this); - if (offset >= document.TextLength) + var wrapper = new CompletionDataWrapper(this); + if (offset >= document.TextLength) { offset = document.TextLength - 1; + } while (offset > 1 && char.IsWhiteSpace (document.GetCharAt (offset))) { offset--; } - location = document.GetLocation (offset); + location = document.GetLocation(offset); - if (xp == null) - xp = GetExpressionAtCursor (); + if (xp == null) { + xp = GetExpressionAtCursor(); + } AstNode node; + CompilationUnit unit; Tuple rr; if (xp != null) { - node = xp.Item2; - rr = ResolveExpression (xp.Item1, node, xp.Item3); + node = xp.Node; + rr = ResolveExpression(node, xp.Unit); + unit = xp.Unit; } else { - var unit = ParseStub ("a"); - node = unit.GetNodeAt (location); - rr = ResolveExpression (CSharpParsedFile, node, unit); + unit = ParseStub("a", false); + node = unit.GetNodeAt(location); + rr = ResolveExpression(node, unit); } - + if (node is Identifier && node.Parent is ForeachStatement) { var foreachStmt = (ForeachStatement)node.Parent; foreach (var possibleName in GenerateNameProposals (foreachStmt.VariableType)) { - if (possibleName.Length > 0) - wrapper.Result.Add (factory.CreateLiteralCompletionData (possibleName.ToString ())); + if (possibleName.Length > 0) { + wrapper.Result.Add(factory.CreateLiteralCompletionData(possibleName.ToString())); + } } AutoSelect = false; AutoCompleteEmptyMatch = false; return wrapper.Result; } - + if (node is Identifier && node.Parent is ParameterDeclaration) { - if (!controlSpace) + if (!controlSpace) { return null; + } // Try Parameter name case var param = node.Parent as ParameterDeclaration; if (param != null) { foreach (var possibleName in GenerateNameProposals (param.Type)) { - if (possibleName.Length > 0) - wrapper.Result.Add (factory.CreateLiteralCompletionData (possibleName.ToString ())); + if (possibleName.Length > 0) { + wrapper.Result.Add(factory.CreateLiteralCompletionData(possibleName.ToString())); + } } AutoSelect = false; AutoCompleteEmptyMatch = false; @@ -787,210 +987,254 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } if (Unit != null && (node == null || node is TypeDeclaration)) { - var constructor = Unit.GetNodeAt (location.Line, location.Column - 3); + var constructor = Unit.GetNodeAt(location.Line, location.Column - 3); if (constructor != null && !constructor.ColonToken.IsNull && constructor.Initializer.IsNull) { - wrapper.AddCustom ("this"); - wrapper.AddCustom ("base"); + wrapper.AddCustom("this"); + wrapper.AddCustom("base"); return wrapper.Result; } } + + var initializer = node != null ? node.Parent as ArrayInitializerExpression : null; + if (initializer != null) { + var result = HandleObjectInitializer(unit, initializer); + if (result != null) + return result; + } CSharpResolver csResolver = null; - if (rr != null) + if (rr != null) { csResolver = rr.Item2; + } if (csResolver == null) { if (node != null) { - csResolver = GetState (); + csResolver = GetState(); //var astResolver = new CSharpAstResolver (csResolver, node, xp != null ? xp.Item1 : CSharpParsedFile); try { //csResolver = astResolver.GetResolverStateBefore (node); - Console.WriteLine (csResolver.LocalVariables.Count ()); - } catch (Exception e) { - Console.WriteLine ("E!!!" + e); + Console.WriteLine(csResolver.LocalVariables.Count()); + } catch (Exception e) { + Console.WriteLine("E!!!" + e); } } else { - csResolver = GetState (); + csResolver = GetState(); } } - AddContextCompletion (wrapper, csResolver, node); + AddContextCompletion(wrapper, csResolver, node, unit); return wrapper.Result; } - void AddContextCompletion (CompletionDataWrapper wrapper, CSharpResolver state, AstNode node) + void AddContextCompletion(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, CompilationUnit unit) { if (state != null && !(node is AstType)) { foreach (var variable in state.LocalVariables) { - if (variable.Region.IsInside (location.Line, location.Column - 1)) + if (variable.Region.IsInside(location.Line, location.Column - 1)) { continue; - wrapper.AddVariable (variable); + } + wrapper.AddVariable(variable); } } if (currentMember is IUnresolvedParameterizedMember && !(node is AstType)) { - var param = (IParameterizedMember)currentMember.CreateResolved (ctx); + var param = (IParameterizedMember)currentMember.CreateResolved(ctx); foreach (var p in param.Parameters) { - wrapper.AddVariable (p); + wrapper.AddVariable(p); } } if (currentMember is IUnresolvedMethod) { var method = (IUnresolvedMethod)currentMember; foreach (var p in method.TypeParameters) { - wrapper.AddTypeParameter (p); + wrapper.AddTypeParameter(p); } } - Predicate typePred = null; - if (node is Attribute) { - var attribute = Compilation.FindType (KnownTypeCode.Attribute); + Func typePred = null; + if (IsAttributeContext(node)) { + var attribute = Compilation.FindType(KnownTypeCode.Attribute); typePred = t => { - return t.GetAllBaseTypeDefinitions ().Any (bt => bt.Equals (attribute)); + return t.GetAllBaseTypeDefinitions().Any(bt => bt.Equals(attribute)) ? t : null; }; } - AddTypesAndNamespaces (wrapper, state, node, typePred); + AddTypesAndNamespaces(wrapper, state, node, typePred); - wrapper.Result.Add (factory.CreateLiteralCompletionData ("global")); + wrapper.Result.Add(factory.CreateLiteralCompletionData("global")); if (!(node is AstType)) { if (currentMember != null) { - AddKeywords (wrapper, statementStartKeywords); - AddKeywords (wrapper, expressionLevelKeywords); + AddKeywords(wrapper, statementStartKeywords); + AddKeywords(wrapper, expressionLevelKeywords); } else if (currentType != null) { - AddKeywords (wrapper, typeLevelKeywords); + AddKeywords(wrapper, typeLevelKeywords); } else { - AddKeywords (wrapper, globalLevelKeywords); + AddKeywords(wrapper, globalLevelKeywords); } var prop = currentMember as IUnresolvedProperty; - if (prop != null && prop.Setter != null && prop.Setter.Region.IsInside (location)) - wrapper.AddCustom ("value"); - if (currentMember is IUnresolvedEvent) - wrapper.AddCustom ("value"); + if (prop != null && prop.Setter != null && prop.Setter.Region.IsInside(location)) { + wrapper.AddCustom("value"); + } + if (currentMember is IUnresolvedEvent) { + wrapper.AddCustom("value"); + } - if (IsInSwitchContext (node)) { - wrapper.AddCustom ("case"); + if (IsInSwitchContext(node)) { + wrapper.AddCustom("case"); + } + } else { + if (((AstType)node).Parent is ParameterDeclaration) { + AddKeywords(wrapper, parameterTypePredecessorKeywords); } - } - AddKeywords (wrapper, primitiveTypesKeywords); - if (currentMember != null) - wrapper.AddCustom ("var"); - wrapper.Result.AddRange (factory.CreateCodeTemplateCompletionData ()); - if (node != null && node.Role == AstNode.Roles.Argument) { - var resolved = ResolveExpression (CSharpParsedFile, node.Parent, Unit); + AddKeywords(wrapper, primitiveTypesKeywords); + if (currentMember != null) { + wrapper.AddCustom("var"); + } + wrapper.Result.AddRange(factory.CreateCodeTemplateCompletionData()); + + if (node != null && node.Role == Roles.Argument) { + var resolved = ResolveExpression(node.Parent, unit); var invokeResult = resolved != null ? resolved.Item1 as CSharpInvocationResolveResult : null; if (invokeResult != null) { int argNum = 0; - foreach (var arg in node.Parent.Children.Where (c => c.Role == AstNode.Roles.Argument)) { - if (arg == node) + foreach (var arg in node.Parent.Children.Where (c => c.Role == Roles.Argument)) { + if (arg == node) { break; + } argNum++; } var param = argNum < invokeResult.Member.Parameters.Count ? invokeResult.Member.Parameters [argNum] : null; if (param != null && param.Type.Kind == TypeKind.Enum) { - AddEnumMembers (wrapper, param.Type, state); + AddEnumMembers(wrapper, param.Type, state); } } } } - static bool IsInSwitchContext (AstNode node) + static bool IsInSwitchContext(AstNode node) { var n = node; - while (n != null && !(n is MemberDeclaration)) { - if (n is SwitchStatement) + while (n != null && !(n is EntityDeclaration)) { + if (n is SwitchStatement) { return true; - if (n is BlockStatement) + } + if (n is BlockStatement) { return false; + } n = n.Parent; } return false; } - void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Predicate typePred = null, Predicate memberPred = null) + void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func typePred = null, Predicate memberPred = null) { if (currentType != null) { for (var ct = currentType; ct != null; ct = ct.DeclaringTypeDefinition) { foreach (var nestedType in ct.NestedTypes) { - if (typePred == null || typePred (nestedType.Resolve (ctx))) { - string name = nestedType.Name; - if (node is Attribute && name.EndsWith ("Attribute") && name.Length > "Attribute".Length) - name = name.Substring (0, name.Length - "Attribute".Length); - wrapper.AddType (nestedType, name); + string name = nestedType.Name; + if (IsAttributeContext(node) && name.EndsWith("Attribute") && name.Length > "Attribute".Length) + name = name.Substring(0, name.Length - "Attribute".Length); + + if (typePred == null) { + wrapper.AddType(nestedType, name); + continue; } + + wrapper.AddType(typePred(nestedType.Resolve(ctx)), name); + continue; } } if (this.currentMember != null && !(node is AstType)) { - var def = ctx.CurrentTypeDefinition ?? Compilation.MainAssembly.GetTypeDefinition (currentType); + var def = ctx.CurrentTypeDefinition ?? Compilation.MainAssembly.GetTypeDefinition(currentType); if (def != null) { foreach (var member in def.GetMembers ()) { - if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") + if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") { continue; - if (member.EntityType == EntityType.Operator) + } + if (member.EntityType == EntityType.Operator) { + continue; + } + if (member.IsExplicitInterfaceImplementation) { continue; - if (memberPred == null || memberPred (member)) - wrapper.AddMember (member); + } + if (memberPred == null || memberPred(member)) { + wrapper.AddMember(member); + } } var declaring = def.DeclaringTypeDefinition; while (declaring != null) { foreach (var member in declaring.GetMembers (m => m.IsStatic)) { - if (memberPred == null || memberPred (member)) - wrapper.AddMember (member); + if (memberPred == null || memberPred(member)) { + wrapper.AddMember(member); + } } declaring = declaring.DeclaringTypeDefinition; } } } foreach (var p in currentType.TypeParameters) { - wrapper.AddTypeParameter (p); + wrapper.AddTypeParameter(p); } } - var scope = CSharpParsedFile.GetUsingScope (location).Resolve (Compilation); + var scope = CSharpParsedFile.GetUsingScope(location).Resolve(Compilation); for (var n = scope; n != null; n = n.Parent) { foreach (var pair in n.UsingAliases) { - wrapper.AddNamespace (pair.Key); + wrapper.AddNamespace(pair.Key); } foreach (var u in n.Usings) { foreach (var type in u.Types) { - if (typePred == null || typePred (type)) { + IType addType = typePred != null ? typePred(type) : type; + if (addType != null) { string name = type.Name; - if (node is Attribute && name.EndsWith ("Attribute") && name.Length > "Attribute".Length) - name = name.Substring (0, name.Length - "Attribute".Length); - wrapper.AddType (type, name); + if (IsAttributeContext(node) && name.EndsWith("Attribute") && name.Length > "Attribute".Length) { + name = name.Substring(0, name.Length - "Attribute".Length); + } + wrapper.AddType(addType, name); } } } foreach (var type in n.Namespace.Types) { - if (typePred == null || typePred (type)) - wrapper.AddType (type, type.Name); + IType addType = typePred != null ? typePred(type) : type; + if (addType != null) { + wrapper.AddType(addType, addType.Name); + } } foreach (var curNs in n.Namespace.ChildNamespaces) { - wrapper.AddNamespace (curNs.Name); + wrapper.AddNamespace(curNs.Name); } } } - IEnumerable HandleKeywordCompletion (int wordStart, string word) + IEnumerable HandleKeywordCompletion(int wordStart, string word) { - if (IsInsideCommentOrString ()) + if (IsInsideCommentStringOrDirective()) { + if (IsInPreprocessorDirective()) { + if (word == "if" || word == "elif") { + if (wordStart > 0 && document.GetCharAt(wordStart - 1) == '#') { + return factory.CreatePreProcessorDefinesCompletionData(); + } + } + } return null; + } switch (word) { - case "using": - case "namespace": - if (currentType != null) - return null; - var wrapper = new CompletionDataWrapper (this); - AddTypesAndNamespaces (wrapper, GetState (), null, t => false); - return wrapper.Result; - case "case": - return CreateCaseCompletionData (location); + case "using": + case "namespace": + if (currentType != null) { + return null; + } + var wrapper = new CompletionDataWrapper(this); + AddTypesAndNamespaces(wrapper, GetState(), null, t => null); + return wrapper.Result; + case "case": + return CreateCaseCompletionData(location); // case ",": // case ":": // if (result.ExpressionContext == ExpressionContext.InheritableType) { @@ -1050,25 +1294,29 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // return completionList; // } // break; - case "is": - case "as": - if (currentType == null) - return null; - IType isAsType = null; - var isAsExpression = GetExpressionAt (wordStart); - if (isAsExpression != null) { - var parent = isAsExpression.Item2.Parent; - if (parent is VariableInitializer) - parent = parent.Parent; - if (parent is VariableDeclarationStatement) { - var resolved = ResolveExpression (isAsExpression.Item1, parent, isAsExpression.Item3); - if (resolved != null) - isAsType = resolved.Item1.Type; - } - } - var isAsWrapper = new CompletionDataWrapper (this); - AddTypesAndNamespaces (isAsWrapper, GetState (), null, t => isAsType == null || t.GetDefinition ().IsDerivedFrom (isAsType.GetDefinition ())); - return isAsWrapper.Result; + case "is": + case "as": + if (currentType == null) { + return null; + } + IType isAsType = null; + var isAsExpression = GetExpressionAt(wordStart); + if (isAsExpression != null) { + var parent = isAsExpression.Node.Parent; + if (parent is VariableInitializer) { + parent = parent.Parent; + } + if (parent is VariableDeclarationStatement) { + var resolved = ResolveExpression(parent, isAsExpression.Unit); + if (resolved != null) { + isAsType = resolved.Item1.Type; + } + } + } + var isAsWrapper = new CompletionDataWrapper(this); + var def = isAsType != null ? isAsType.GetDefinition() : null; + AddTypesAndNamespaces(isAsWrapper, GetState(), null, t => t.GetDefinition() == null || def == null || t.GetDefinition().IsDerivedFrom(def) ? t : null, m => false); + return isAsWrapper.Result; // { // CompletionDataList completionList = new ProjectDomCompletionDataList (); // ExpressionResult expressionResult = FindExpression (dom, completionContext, wordStart - document.Caret.Offset); @@ -1118,312 +1366,299 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // result.ExpressionContext = ExpressionContext.TypeName; // return CreateCtrlSpaceCompletionData (completionContext, result); // } - case "override": + case "override": // Look for modifiers, in order to find the beginning of the declaration - int firstMod = wordStart; - int i = wordStart; - for (int n = 0; n < 3; n++) { - string mod = GetPreviousToken (ref i, true); - if (mod == "public" || mod == "protected" || mod == "private" || mod == "internal" || mod == "sealed") { - firstMod = i; - } else if (mod == "static") { - // static methods are not overridable + int firstMod = wordStart; + int i = wordStart; + for (int n = 0; n < 3; n++) { + string mod = GetPreviousToken(ref i, true); + if (mod == "public" || mod == "protected" || mod == "private" || mod == "internal" || mod == "sealed") { + firstMod = i; + } else if (mod == "static") { + // static methods are not overridable + return null; + } else { + break; + } + } + if (!IsLineEmptyUpToEol()) { return null; - } else - break; - } - if (!IsLineEmptyUpToEol ()) + } + if (currentType != null && (currentType.Kind == TypeKind.Class || currentType.Kind == TypeKind.Struct)) { + string modifiers = document.GetText(firstMod, wordStart - firstMod); + return GetOverrideCompletionData(currentType, modifiers); + } return null; - if (currentType != null && (currentType.Kind == TypeKind.Class || currentType.Kind == TypeKind.Struct)) { - string modifiers = document.GetText (firstMod, wordStart - firstMod); - return GetOverrideCompletionData (currentType, modifiers); - } - return null; - case "partial": + case "partial": // Look for modifiers, in order to find the beginning of the declaration - firstMod = wordStart; - i = wordStart; - for (int n = 0; n < 3; n++) { - string mod = GetPreviousToken (ref i, true); - if (mod == "public" || mod == "protected" || mod == "private" || mod == "internal" || mod == "sealed") { - firstMod = i; - } else if (mod == "static") { - // static methods are not overridable + firstMod = wordStart; + i = wordStart; + for (int n = 0; n < 3; n++) { + string mod = GetPreviousToken(ref i, true); + if (mod == "public" || mod == "protected" || mod == "private" || mod == "internal" || mod == "sealed") { + firstMod = i; + } else if (mod == "static") { + // static methods are not overridable + return null; + } else { + break; + } + } + if (!IsLineEmptyUpToEol()) { return null; - } else - break; - } - if (!IsLineEmptyUpToEol ()) - return null; - var state = GetState (); + } + var state = GetState(); - if (state.CurrentTypeDefinition != null && (state.CurrentTypeDefinition.Kind == TypeKind.Class || state.CurrentTypeDefinition.Kind == TypeKind.Struct)) { - string modifiers = document.GetText (firstMod, wordStart - firstMod); - return GetPartialCompletionData (state.CurrentTypeDefinition, modifiers); - } - return null; + if (state.CurrentTypeDefinition != null && (state.CurrentTypeDefinition.Kind == TypeKind.Class || state.CurrentTypeDefinition.Kind == TypeKind.Struct)) { + string modifiers = document.GetText(firstMod, wordStart - firstMod); + return GetPartialCompletionData(state.CurrentTypeDefinition, modifiers); + } + return null; - case "public": - case "protected": - case "private": - case "internal": - case "sealed": - case "static": - var accessorContext = HandleAccessorContext (); - if (accessorContext != null) - return accessorContext; - wrapper = new CompletionDataWrapper (this); - state = GetState (); - AddTypesAndNamespaces (wrapper, state, null, null, m => false); - AddKeywords (wrapper, typeLevelKeywords); - AddKeywords (wrapper, primitiveTypesKeywords); - return wrapper.Result; - case "new": - int j = offset - 4; + case "public": + case "protected": + case "private": + case "internal": + case "sealed": + case "static": + var accessorContext = HandleAccessorContext(); + if (accessorContext != null) { + return accessorContext; + } + wrapper = new CompletionDataWrapper(this); + state = GetState(); + if (currentType != null) { + AddTypesAndNamespaces(wrapper, state, null, null, m => false); + AddKeywords(wrapper, primitiveTypesKeywords); + } + AddKeywords(wrapper, typeLevelKeywords); + return wrapper.Result; + case "new": + int j = offset - 4; // string token = GetPreviousToken (ref j, true); - IType hintType = null; - var expressionOrVariableDeclaration = GetNewExpressionAt (j); - AstNode newParentNode = null; - AstType hintTypeAst = null; - if (expressionOrVariableDeclaration != null) { - newParentNode = expressionOrVariableDeclaration.Item2.Parent; - if (newParentNode is VariableInitializer) - newParentNode = newParentNode.Parent; - } - if (newParentNode is InvocationExpression) { - var invoke = (InvocationExpression)newParentNode; - var resolved = ResolveExpression (expressionOrVariableDeclaration.Item1, invoke, expressionOrVariableDeclaration.Item3); - if (resolved != null) { - var mgr = resolved.Item1 as CSharpInvocationResolveResult; - if (mgr != null) { - int i1 = 0; - foreach (var a in invoke.Arguments) { - if (a == expressionOrVariableDeclaration.Item2) { - if (mgr.Member.Parameters.Count > i1) - hintType = mgr.Member.Parameters [i1].Type; - break; + IType hintType = null; + var expressionOrVariableDeclaration = GetNewExpressionAt(j); + AstNode newParentNode = null; + AstType hintTypeAst = null; + if (expressionOrVariableDeclaration != null) { + newParentNode = expressionOrVariableDeclaration.Node.Parent; + if (newParentNode is VariableInitializer) { + newParentNode = newParentNode.Parent; + } + } + if (newParentNode is InvocationExpression) { + var invoke = (InvocationExpression)newParentNode; + var resolved = ResolveExpression(invoke, expressionOrVariableDeclaration.Unit); + if (resolved != null) { + var mgr = resolved.Item1 as CSharpInvocationResolveResult; + if (mgr != null) { + int i1 = 0; + foreach (var a in invoke.Arguments) { + if (a == expressionOrVariableDeclaration.Node) { + if (mgr.Member.Parameters.Count > i1) { + hintType = mgr.Member.Parameters [i1].Type; + } + break; + } + i1++; } - i1++; } } } - } - if (newParentNode is ObjectCreateExpression) { - var invoke = (ObjectCreateExpression)newParentNode; - var resolved = ResolveExpression (expressionOrVariableDeclaration.Item1, invoke, expressionOrVariableDeclaration.Item3); - if (resolved != null) { - var mgr = resolved.Item1 as CSharpInvocationResolveResult; - if (mgr != null) { - int i1 = 0; - foreach (var a in invoke.Arguments) { - if (a == expressionOrVariableDeclaration.Item2) { - if (mgr.Member.Parameters.Count > i1) - hintType = mgr.Member.Parameters [i1].Type; - break; + if (newParentNode is ObjectCreateExpression) { + var invoke = (ObjectCreateExpression)newParentNode; + var resolved = ResolveExpression(invoke, expressionOrVariableDeclaration.Unit); + if (resolved != null) { + var mgr = resolved.Item1 as CSharpInvocationResolveResult; + if (mgr != null) { + int i1 = 0; + foreach (var a in invoke.Arguments) { + if (a == expressionOrVariableDeclaration.Node) { + if (mgr.Member.Parameters.Count > i1) { + hintType = mgr.Member.Parameters [i1].Type; + } + break; + } + i1++; } - i1++; } } } - } - - if (newParentNode is AssignmentExpression) { - var assign = (AssignmentExpression)newParentNode; - var resolved = ResolveExpression (expressionOrVariableDeclaration.Item1, assign.Left, expressionOrVariableDeclaration.Item3); - if (resolved != null) { - hintType = resolved.Item1.Type; + + if (newParentNode is AssignmentExpression) { + var assign = (AssignmentExpression)newParentNode; + var resolved = ResolveExpression(assign.Left, expressionOrVariableDeclaration.Unit); + if (resolved != null) { + hintType = resolved.Item1.Type; + } } - } - - if (newParentNode is VariableDeclarationStatement) { - var varDecl = (VariableDeclarationStatement)newParentNode; - hintTypeAst = varDecl.Type; - var resolved = ResolveExpression (expressionOrVariableDeclaration.Item1, varDecl.Type, expressionOrVariableDeclaration.Item3); - if (resolved != null) { - hintType = resolved.Item1.Type; + + if (newParentNode is VariableDeclarationStatement) { + var varDecl = (VariableDeclarationStatement)newParentNode; + hintTypeAst = varDecl.Type; + var resolved = ResolveExpression(varDecl.Type, expressionOrVariableDeclaration.Unit); + if (resolved != null) { + hintType = resolved.Item1.Type; + } } - } - - if (newParentNode is FieldDeclaration) { - var varDecl = (FieldDeclaration)newParentNode; - hintTypeAst = varDecl.ReturnType; - var resolved = ResolveExpression (expressionOrVariableDeclaration.Item1, varDecl.ReturnType, expressionOrVariableDeclaration.Item3); - if (resolved != null) - hintType = resolved.Item1.Type; - } - return CreateTypeCompletionData (hintType, hintTypeAst); -// IType callingType = NRefactoryResolver.GetTypeAtCursor (Document.CompilationUnit, Document.FileName, new TextLocation (document.Caret.Line, document.Caret.Column)); -// ExpressionContext newExactContext = new NewCSharpExpressionFinder (dom).FindExactContextForNewCompletion (document, Document.CompilationUnit, Document.FileName, callingType); -// if (newExactContext is ExpressionContext.TypeExpressionContext) -// return CreateTypeCompletionData (location, callingType, newExactContext, ((ExpressionContext.TypeExpressionContext)newExactContext).Type, ((ExpressionContext.TypeExpressionContext)newExactContext).UnresolvedType); -// if (newExactContext == null) { -// int j = offset - 4; -// -// string yieldToken = GetPreviousToken (ref j, true); -// if (token == "return") { -// NRefactoryResolver resolver = CreateResolver (); -// resolver.SetupResolver (new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset)); -// IReturnType returnType = resolver.CallingMember.ReturnType; -// if (yieldToken == "yield" && returnType.GenericArguments.Count > 0) -// returnType = returnType.GenericArguments [0]; -// if (resolver.CallingMember != null) -// return CreateTypeCompletionData (location, callingType, newExactContext, null, returnType); -// } -// } -// return CreateCtrlSpaceCompletionData (completionContext, null); - case "if": - case "elif": - if (wordStart > 0 && document.GetCharAt (wordStart - 1) == '#') - return factory.CreatePreProcessorDefinesCompletionData (); - return null; - case "yield": - var yieldDataList = new CompletionDataWrapper (this); - DefaultCompletionString = "return"; - yieldDataList.AddCustom ("break"); - yieldDataList.AddCustom ("return"); - return yieldDataList.Result; - case "in": - var inList = new CompletionDataWrapper (this); - var node = Unit.GetNodeAt (location); - var rr = ResolveExpression (CSharpParsedFile, node, Unit); - AddContextCompletion (inList, rr != null ? rr.Item2 : GetState (), node); - return inList.Result; -// case "where": -// CompletionDataList whereDataList = new CompletionDataList (); -// NRefactoryResolver constraintResolver = CreateResolver (); -// constraintResolver.SetupResolver (new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset)); -// if (constraintResolver.CallingMember is IMethod) { -// foreach (ITypeParameter tp in ((IMethod)constraintResolver.CallingMember).TypeParameters) { -// whereDataList.Add (tp.Name, "md-keyword"); -// } -// } else { -// if (constraintResolver.CallingType != null) { -// foreach (ITypeParameter tp in constraintResolver.CallingType.TypeParameters) { -// whereDataList.Add (tp.Name, "md-keyword"); -// } -// } -// } -// -// return whereDataList; + + if (newParentNode is FieldDeclaration) { + var varDecl = (FieldDeclaration)newParentNode; + hintTypeAst = varDecl.ReturnType; + var resolved = ResolveExpression(varDecl.ReturnType, expressionOrVariableDeclaration.Unit); + if (resolved != null) { + hintType = resolved.Item1.Type; + } + } + + if (newParentNode is ReturnStatement) { + //var varDecl = (ReturnStatement)newParentNode; + if (ctx.CurrentMember != null) { + hintType = ctx.CurrentMember.ReturnType; + } + } + + return CreateTypeCompletionData(hintType, hintTypeAst); + case "yield": + var yieldDataList = new CompletionDataWrapper(this); + DefaultCompletionString = "return"; + yieldDataList.AddCustom("break"); + yieldDataList.AddCustom("return"); + return yieldDataList.Result; + case "in": + var inList = new CompletionDataWrapper(this); + + var expr = GetExpressionAtCursor(); + var rr = ResolveExpression(expr); + + AddContextCompletion(inList, rr != null ? rr.Item2 : GetState(), expr.Node, Unit); + return inList.Result; } -// if (IsInLinqContext (result)) { -// if (linqKeywords.Contains (word)) { -// if (word == "from") // after from no auto code completion. -// return null; -// result.Expression = ""; -// return CreateCtrlSpaceCompletionData (completionContext, result); -// } -// CompletionDataList dataList = new ProjectDomCompletionDataList (); -// CompletionDataCollector col = new CompletionDataCollector (this, dom, dataList, Document.CompilationUnit, null, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset)); -// foreach (string kw in linqKeywords) { -// col.Add (kw, "md-keyword"); -// } -// return dataList; -// } return null; } - bool IsLineEmptyUpToEol () + bool IsLineEmptyUpToEol() { - var line = document.GetLineByNumber (location.Line); + var line = document.GetLineByNumber(location.Line); for (int j = offset; j < line.EndOffset; j++) { - char ch = document.GetCharAt (j); - if (!char.IsWhiteSpace (ch)) + char ch = document.GetCharAt(j); + if (!char.IsWhiteSpace(ch)) { return false; + } } return true; } - string GetLineIndent (int lineNr) + string GetLineIndent(int lineNr) { - var line = document.GetLineByNumber (lineNr); + var line = document.GetLineByNumber(lineNr); for (int j = offset; j < line.EndOffset; j++) { - char ch = document.GetCharAt (j); - if (!char.IsWhiteSpace (ch)) - return document.GetText (line.Offset, j - line.Offset - 1); + char ch = document.GetCharAt(j); + if (!char.IsWhiteSpace(ch)) { + return document.GetText(line.Offset, j - line.Offset - 1); + } } return ""; } - - IEnumerable CreateTypeCompletionData (IType hintType, AstType hintTypeAst) + static CSharpAmbience amb = new CSharpAmbience (); + + IEnumerable CreateTypeCompletionData(IType hintType, AstType hintTypeAst) { - var wrapper = new CompletionDataWrapper (this); - var state = GetState (); - Predicate pred = null; + var wrapper = new CompletionDataWrapper(this); + var state = GetState(); + Func pred = null; if (hintType != null) { if (hintType.Kind != TypeKind.Unknown) { - var lookup = new MemberLookup (ctx.CurrentTypeDefinition, Compilation.MainAssembly); + var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly); pred = t => { // check if type is in inheritance tree. - if (hintType.GetDefinition () != null && !t.GetDefinition ().IsDerivedFrom (hintType.GetDefinition ())) - return false; - + if (hintType.GetDefinition() != null && !t.GetDefinition().IsDerivedFrom(hintType.GetDefinition())) { + return null; + } + if (t.Kind == TypeKind.Interface && hintType.Kind != TypeKind.Array) { + return null; + } // check for valid constructors - if (t.GetConstructors ().Count () == 0) - return true; - bool isProtectedAllowed = currentType != null ? currentType.Resolve (ctx).GetDefinition ().IsDerivedFrom (t.GetDefinition ()) : false; - return t.GetConstructors ().Any (m => lookup.IsAccessible (m, isProtectedAllowed)); + if (t.GetConstructors().Count() > 0) { + bool isProtectedAllowed = currentType != null ? currentType.Resolve(ctx).GetDefinition().IsDerivedFrom(t.GetDefinition()) : false; + if (!t.GetConstructors().Any(m => lookup.IsAccessible(m, isProtectedAllowed))) + return null; + } + + var typeInference = new TypeInference(Compilation); + typeInference.Algorithm = TypeInferenceAlgorithm.ImprovedReturnAllResults; + var inferedType = typeInference.FindTypeInBounds(new [] { t }, new [] { hintType }); + wrapper.AddType(inferedType, amb.ConvertType(inferedType)); + return null; }; - DefaultCompletionString = GetShortType (hintType, GetState ()); - wrapper.AddType (hintType, DefaultCompletionString); + if (!(hintType.Kind == TypeKind.Interface && hintType.Kind != TypeKind.Array)) { + DefaultCompletionString = GetShortType(hintType, GetState()); + wrapper.AddType(hintType, DefaultCompletionString); + } + if (hintType is ParameterizedType && hintType.TypeParameterCount == 1 && hintType.FullName == "System.Collections.Generic.IEnumerable") { + var arg = ((ParameterizedType)hintType).TypeArguments.FirstOrDefault(); + var array = new ArrayTypeReference(arg.ToTypeReference(), 1).Resolve(ctx); + wrapper.AddType(array, amb.ConvertType(array)); + } } else { - DefaultCompletionString = hintTypeAst.ToString (); - wrapper.AddType (hintType, DefaultCompletionString); + DefaultCompletionString = hintTypeAst.ToString(); + wrapper.AddType(hintType, DefaultCompletionString); } } - AddTypesAndNamespaces (wrapper, state, null, pred, m => false); - AddKeywords (wrapper, primitiveTypesKeywords.Where (k => k != "void")); + AddTypesAndNamespaces(wrapper, state, null, pred, m => false); + if (hintType == null || hintType == SpecialType.UnknownType) + AddKeywords(wrapper, primitiveTypesKeywords.Where(k => k != "void")); CloseOnSquareBrackets = true; AutoCompleteEmptyMatch = true; return wrapper.Result; } - IEnumerable GetOverrideCompletionData (IUnresolvedTypeDefinition type, string modifiers) + IEnumerable GetOverrideCompletionData(IUnresolvedTypeDefinition type, string modifiers) { var wrapper = new CompletionDataWrapper (this); - var alreadyInserted = new Dictionary (); - bool addedVirtuals = false; + var alreadyInserted = new List (); + //bool addedVirtuals = false; int declarationBegin = offset; int j = declarationBegin; for (int i = 0; i < 3; i++) { - switch (GetPreviousToken (ref j, true)) { - case "public": - case "protected": - case "private": - case "internal": - case "sealed": - case "override": - declarationBegin = j; - break; - case "static": - return null; // don't add override completion for static members + switch (GetPreviousToken(ref j, true)) { + case "public": + case "protected": + case "private": + case "internal": + case "sealed": + case "override": + declarationBegin = j; + break; + case "static": + return null; // don't add override completion for static members } } - AddVirtuals (alreadyInserted, wrapper, modifiers, type.Resolve (ctx), declarationBegin); + AddVirtuals(alreadyInserted, wrapper, modifiers, type.Resolve(ctx), declarationBegin); return wrapper.Result; } - IEnumerable GetPartialCompletionData (ITypeDefinition type, string modifiers) + IEnumerable GetPartialCompletionData(ITypeDefinition type, string modifiers) { var wrapper = new CompletionDataWrapper (this); int declarationBegin = offset; int j = declarationBegin; for (int i = 0; i < 3; i++) { - switch (GetPreviousToken (ref j, true)) { - case "public": - case "protected": - case "private": - case "internal": - case "sealed": - case "override": - declarationBegin = j; - break; - case "static": - return null; // don't add override completion for static members + switch (GetPreviousToken(ref j, true)) { + case "public": + case "protected": + case "private": + case "internal": + case "sealed": + case "override": + declarationBegin = j; + break; + case "static": + return null; // don't add override completion for static members } } @@ -1432,21 +1667,22 @@ namespace ICSharpCode.NRefactory.CSharp.Completion foreach (var part in type.Parts) { foreach (var method in part.Methods) { if (method.BodyRegion.IsEmpty) { - if (GetImplementation (type, method) != null) + if (GetImplementation(type, method) != null) { continue; - methods.Add (method); + } + methods.Add(method); } } } foreach (var method in methods) { - wrapper.Add (factory.CreateNewPartialCompletionData (declarationBegin, method.DeclaringTypeDefinition, method)); + wrapper.Add(factory.CreateNewPartialCompletionData(declarationBegin, method.DeclaringTypeDefinition, method)); } return wrapper.Result; } - IMethod GetImplementation (ITypeDefinition type, IUnresolvedMethod method) + IMethod GetImplementation(ITypeDefinition type, IUnresolvedMethod method) { foreach (var cur in type.Methods) { if (cur.Name == method.Name && cur.Parameters.Count == method.Parameters.Count && !cur.BodyRegion.IsEmpty) { @@ -1457,77 +1693,73 @@ namespace ICSharpCode.NRefactory.CSharp.Completion break; } }*/ - if (equal) + if (equal) { return cur; + } } } return null; } - static string GetNameWithParamCount (IMember member) + void AddVirtuals(List alreadyInserted, CompletionDataWrapper col, string modifiers, IType curType, int declarationBegin) { - var e = member as IMethod; - if (e == null || e.TypeParameters.Count == 0) - return member.Name; - return e.Name + "`" + e.TypeParameters.Count; - } - - void AddVirtuals (Dictionary alreadyInserted, CompletionDataWrapper col, string modifiers, IType curType, int declarationBegin) - { - if (curType == null) + if (curType == null) { return; - foreach (var m in curType.GetMethods (m => !m.IsConstructor && !m.IsDestructor).Cast ().Concat (curType.GetProperties ().Cast ()).Reverse ()) { - if (m.IsSynthetic || curType.Kind != TypeKind.Interface && !m.IsOverridable) + } + foreach (var m in curType.GetMembers ().Reverse ()) { + if (m.IsSynthetic || curType.Kind != TypeKind.Interface && !m.IsOverridable) { continue; + } // filter out the "Finalize" methods, because finalizers should be done with destructors. - if (m is IMethod && m.Name == "Finalize") + if (m is IMethod && m.Name == "Finalize") { continue; + } - var data = factory.CreateNewOverrideCompletionData (declarationBegin, currentType, m); - string text = GetNameWithParamCount (m); - + var data = factory.CreateNewOverrideCompletionData(declarationBegin, currentType, m); // check if the member is already implemented - bool foundMember = curType.GetMembers ().Any (cm => GetNameWithParamCount (cm) == text && cm.DeclaringTypeDefinition == curType.GetDefinition ()); - if (foundMember) + bool foundMember = curType.GetMembers().Any(cm => SignatureComparer.Ordinal.Equals(cm, m) && cm.DeclaringTypeDefinition == curType.GetDefinition()); + if (foundMember) { continue; - if (alreadyInserted.ContainsKey (text)) + } + if (alreadyInserted.Any(cm => SignatureComparer.Ordinal.Equals(cm, m))) continue; - alreadyInserted [text] = true; - data.CompletionCategory = col.GetCompletionCategory (curType); - col.Add (data); + alreadyInserted.Add (m); + data.CompletionCategory = col.GetCompletionCategory(m.DeclaringTypeDefinition); + col.Add(data); } } - static void AddKeywords (CompletionDataWrapper wrapper, IEnumerable keywords) + static void AddKeywords(CompletionDataWrapper wrapper, IEnumerable keywords) { foreach (string keyword in keywords) { - wrapper.AddCustom (keyword); + wrapper.AddCustom(keyword); } } - public string GetPreviousMemberReferenceExpression (int tokenIndex) + public string GetPreviousMemberReferenceExpression(int tokenIndex) { - string result = GetPreviousToken (ref tokenIndex, false); - result = GetPreviousToken (ref tokenIndex, false); + string result = GetPreviousToken(ref tokenIndex, false); + result = GetPreviousToken(ref tokenIndex, false); if (result != ".") { result = null; } else { var names = new List (); while (result == ".") { - result = GetPreviousToken (ref tokenIndex, false); + result = GetPreviousToken(ref tokenIndex, false); if (result == "this") { - names.Add ("handle"); + names.Add("handle"); } else if (result != null) { - string trimmedName = result.Trim (); - if (trimmedName.Length == 0) + string trimmedName = result.Trim(); + if (trimmedName.Length == 0) { break; - names.Insert (0, trimmedName); + } + names.Insert(0, trimmedName); } - result = GetPreviousToken (ref tokenIndex, false); + result = GetPreviousToken(ref tokenIndex, false); } - result = String.Join ("", names.ToArray ()); + result = String.Join("", names.ToArray()); foreach (char ch in result) { - if (!char.IsLetterOrDigit (ch) && ch != '_') { + if (!char.IsLetterOrDigit(ch) && ch != '_') { result = ""; break; } @@ -1536,45 +1768,49 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return result; } - bool MatchDelegate (IType delegateType, IUnresolvedMethod method) + bool MatchDelegate(IType delegateType, IUnresolvedMethod method) { - var delegateMethod = delegateType.GetDelegateInvokeMethod (); - if (delegateMethod == null || delegateMethod.Parameters.Count != method.Parameters.Count) + var delegateMethod = delegateType.GetDelegateInvokeMethod(); + if (delegateMethod == null || delegateMethod.Parameters.Count != method.Parameters.Count) { return false; + } for (int i = 0; i < delegateMethod.Parameters.Count; i++) { - if (!delegateMethod.Parameters [i].Type.Equals (method.Parameters [i].Type.Resolve (ctx))) + if (!delegateMethod.Parameters [i].Type.Equals(method.Parameters [i].Type.Resolve(ctx))) { return false; + } } return true; } - string AddDelegateHandlers (CompletionDataWrapper completionList, IType delegateType, bool addSemicolon = true, bool addDefault = true) + string AddDelegateHandlers(CompletionDataWrapper completionList, IType delegateType, bool addSemicolon = true, bool addDefault = true) { - IMethod delegateMethod = delegateType.GetDelegateInvokeMethod (); - var thisLineIndent = GetLineIndent (location.Line); + IMethod delegateMethod = delegateType.GetDelegateInvokeMethod(); + var thisLineIndent = GetLineIndent(location.Line); string delegateEndString = EolMarker + thisLineIndent + "}" + (addSemicolon ? ";" : ""); - bool containsDelegateData = completionList.Result.Any (d => d.DisplayText.StartsWith ("delegate(")); - if (addDefault) - completionList.AddCustom ("delegate", "Creates anonymous delegate.", "delegate {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString); + //bool containsDelegateData = completionList.Result.Any(d => d.DisplayText.StartsWith("delegate(")); + if (addDefault) { + completionList.AddCustom("delegate", "Creates anonymous delegate.", "delegate {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString); + } var sb = new StringBuilder ("("); var sbWithoutTypes = new StringBuilder ("("); for (int k = 0; k < delegateMethod.Parameters.Count; k++) { if (k > 0) { - sb.Append (", "); - sbWithoutTypes.Append (", "); + sb.Append(", "); + sbWithoutTypes.Append(", "); } var parameterType = delegateMethod.Parameters [k].Type; - sb.Append (GetShortType (parameterType, GetState ())); - sb.Append (" "); - sb.Append (delegateMethod.Parameters [k].Name); - sbWithoutTypes.Append (delegateMethod.Parameters [k].Name); - } - sb.Append (")"); - sbWithoutTypes.Append (")"); - completionList.AddCustom ("delegate" + sb, "Creates anonymous delegate.", "delegate" + sb + " {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString); - if (!completionList.Result.Any (data => data.DisplayText == sbWithoutTypes.ToString ())) - completionList.AddCustom (sbWithoutTypes.ToString (), "Creates lambda expression.", sbWithoutTypes + " => |" + (addSemicolon ? ";" : "")); + sb.Append(GetShortType(parameterType, GetState())); + sb.Append(" "); + sb.Append(delegateMethod.Parameters [k].Name); + sbWithoutTypes.Append(delegateMethod.Parameters [k].Name); + } + sb.Append(")"); + sbWithoutTypes.Append(")"); + completionList.AddCustom("delegate" + sb, "Creates anonymous delegate.", "delegate" + sb + " {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString); + if (!completionList.Result.Any(data => data.DisplayText == sbWithoutTypes.ToString())) { + completionList.AddCustom(sbWithoutTypes.ToString(), "Creates lambda expression.", sbWithoutTypes + " => |" + (addSemicolon ? ";" : "")); + } /* TODO:Make factory method out of it. // It's needed to temporarly disable inserting auto matching bracket because the anonymous delegates are selectable with '(' // otherwise we would end up with () => ) @@ -1585,32 +1821,36 @@ namespace ICSharpCode.NRefactory.CSharp.Completion MonoDevelop.SourceEditor.DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket = savedValue; }; }*/ - return sb.ToString (); + return sb.ToString(); } - bool IsAccessibleFrom (IEntity member, ITypeDefinition calledType, IMember currentMember, bool includeProtected) + bool IsAccessibleFrom(IEntity member, ITypeDefinition calledType, IMember currentMember, bool includeProtected) { - if (currentMember == null) + if (currentMember == null) { return member.IsStatic || member.IsPublic; -// if (currentMember is MonoDevelop.Projects.Dom.BaseResolveResult.BaseMemberDecorator) -// return member.IsPublic | member.IsProtected; + } + // if (currentMember is MonoDevelop.Projects.Dom.BaseResolveResult.BaseMemberDecorator) + // return member.IsPublic | member.IsProtected; // if (member.IsStatic && !IsStatic) // return false; - if (member.IsPublic || calledType != null && calledType.Kind == TypeKind.Interface && !member.IsProtected) + if (member.IsPublic || calledType != null && calledType.Kind == TypeKind.Interface && !member.IsProtected) { return true; + } if (member.DeclaringTypeDefinition != null) { - if (member.DeclaringTypeDefinition.Kind == TypeKind.Interface) - return IsAccessibleFrom (member.DeclaringTypeDefinition, calledType, currentMember, includeProtected); + if (member.DeclaringTypeDefinition.Kind == TypeKind.Interface) { + return IsAccessibleFrom(member.DeclaringTypeDefinition, calledType, currentMember, includeProtected); + } - if (member.IsProtected && !(member.DeclaringTypeDefinition.IsProtectedOrInternal && !includeProtected)) + if (member.IsProtected && !(member.DeclaringTypeDefinition.IsProtectedOrInternal && !includeProtected)) { return includeProtected; + } } if (member.IsInternal || member.IsProtectedAndInternal || member.IsProtectedOrInternal) { - var type1 = member is ITypeDefinition ? (ITypeDefinition)member : member.DeclaringTypeDefinition; - var type2 = currentMember is ITypeDefinition ? (ITypeDefinition)currentMember : currentMember.DeclaringTypeDefinition; + //var type1 = member is ITypeDefinition ? (ITypeDefinition)member : member.DeclaringTypeDefinition; + //var type2 = currentMember is ITypeDefinition ? (ITypeDefinition)currentMember : currentMember.DeclaringTypeDefinition; bool result = true; // easy case, projects are the same -/*// if (type1.ProjectContent == type2.ProjectContent) { + /*// if (type1.ProjectContent == type2.ProjectContent) { // result = true; // } else if (type1.ProjectContent != null) { @@ -1629,14 +1869,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return member.IsProtectedAndInternal ? includeProtected && result : result; } - if (!(currentMember is IType) && (currentMember.DeclaringTypeDefinition == null || member.DeclaringTypeDefinition == null)) + if (!(currentMember is IType) && (currentMember.DeclaringTypeDefinition == null || member.DeclaringTypeDefinition == null)) { return false; + } // inner class var declaringType = currentMember.DeclaringTypeDefinition; while (declaringType != null) { - if (declaringType.ReflectionName == currentMember.DeclaringType.ReflectionName) + if (declaringType.ReflectionName == currentMember.DeclaringType.ReflectionName) { return true; + } declaringType = declaringType.DeclaringTypeDefinition; } @@ -1644,140 +1886,174 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return currentMember.DeclaringTypeDefinition != null && member.DeclaringTypeDefinition.FullName == currentMember.DeclaringTypeDefinition.FullName; } - IEnumerable CreateTypeAndNamespaceCompletionData (TextLocation location, ResolveResult resolveResult, AstNode resolvedNode, CSharpResolver state) + static bool IsAttributeContext(AstNode node) + { + AstNode n = node; + while (n is AstType) { + n = n.Parent; + } + return n is Attribute; + } + + IType GuessHintType(AstNode resolvedNode) + { + ObjectCreateExpression oce = resolvedNode.Parent as ObjectCreateExpression ?? (ObjectCreateExpression)resolvedNode.Ancestors.FirstOrDefault(n => n is ObjectCreateExpression); + if (oce != null && oce.Parent is ReturnStatement) { + return ctx.CurrentMember != null ? ctx.CurrentMember.ReturnType : null; + } + return null; + } + + IEnumerable CreateTypeAndNamespaceCompletionData(TextLocation location, ResolveResult resolveResult, AstNode resolvedNode, CSharpResolver state) { - if (resolveResult == null || resolveResult.IsError) + if (resolveResult == null || resolveResult.IsError) { return null; + } + + var hintType = GuessHintType(resolvedNode); var result = new CompletionDataWrapper (this); if (resolveResult is NamespaceResolveResult) { var nr = (NamespaceResolveResult)resolveResult; - foreach (var cl in nr.Namespace.Types) { - result.AddType (cl, cl.Name); + if (!(resolvedNode.Parent is UsingDeclaration || resolvedNode.Parent != null && resolvedNode.Parent.Parent is UsingDeclaration)) { + foreach (var cl in nr.Namespace.Types) { + string name = cl.Name; + if (hintType != null && hintType.Kind != TypeKind.Array && cl.Kind == TypeKind.Interface) { + continue; + } + if (IsAttributeContext(resolvedNode) && name.EndsWith("Attribute") && name.Length > "Attribute".Length) { + name = name.Substring(0, name.Length - "Attribute".Length); + } + result.AddType(cl, name); + } } foreach (var ns in nr.Namespace.ChildNamespaces) { - result.AddNamespace (ns.Name); + result.AddNamespace(ns.Name); } } else if (resolveResult is TypeResolveResult) { var type = resolveResult.Type; foreach (var nested in type.GetNestedTypes ()) { - result.AddType (nested, nested.Name); + if (hintType != null && hintType.Kind != TypeKind.Array && nested.Kind == TypeKind.Interface) { + continue; + } + result.AddType(nested, nested.Name); } } return result.Result; } - - IEnumerable CreateTypeList () + + IEnumerable CreateTypeList() { foreach (var cl in Compilation.RootNamespace.Types) { - yield return factory.CreateTypeCompletionData (cl, cl.Name); + yield return factory.CreateTypeCompletionData(cl, cl.Name); } foreach (var ns in Compilation.RootNamespace.ChildNamespaces) { - yield return factory.CreateNamespaceCompletionData (ns.Name); + yield return factory.CreateNamespaceCompletionData(ns.Name); } } - IEnumerable CreateParameterCompletion (MethodGroupResolveResult resolveResult, CSharpResolver state, AstNode invocation, int parameter, bool controlSpace) + IEnumerable CreateParameterCompletion(MethodGroupResolveResult resolveResult, CSharpResolver state, AstNode invocation, CompilationUnit unit, int parameter, bool controlSpace) { - var result = new CompletionDataWrapper (this); - var addedEnums = new HashSet (); - var addedDelegates = new HashSet (); + var result = new CompletionDataWrapper(this); + var addedEnums = new HashSet(); + var addedDelegates = new HashSet(); foreach (var method in resolveResult.Methods) { - if (method.Parameters.Count <= parameter) + if (method.Parameters.Count <= parameter) { continue; + } var resolvedType = method.Parameters [parameter].Type; if (resolvedType.Kind == TypeKind.Enum) { - if (addedEnums.Contains (resolvedType.ReflectionName)) + if (addedEnums.Contains(resolvedType.ReflectionName)) { continue; - addedEnums.Add (resolvedType.ReflectionName); - AddEnumMembers (result, resolvedType, state); + } + addedEnums.Add(resolvedType.ReflectionName); + AddEnumMembers(result, resolvedType, state); } else if (resolvedType.Kind == TypeKind.Delegate) { -// if (addedDelegates.Contains (resolvedType.DecoratedFullName)) -// continue; -// addedDelegates.Add (resolvedType.DecoratedFullName); -// string parameterDefinition = AddDelegateHandlers (completionList, resolvedType, false, addedDelegates.Count == 1); -// string varName = "Handle" + method.Parameters [parameter].ReturnType.Name + method.Parameters [parameter].Name; -// result.Add (new EventCreationCompletionData (document, varName, resolvedType, null, parameterDefinition, resolver.Unit.GetMemberAt (location), resolvedType) { AddSemicolon = false }); - + if (addedDelegates.Contains(resolvedType.ReflectionName)) + continue; + string parameterDefinition = AddDelegateHandlers(result, resolvedType); + string varName = "Handle" + method.Parameters [parameter].Type.Name + method.Parameters [parameter].Name; + result.Result.Add(factory.CreateEventCreationCompletionData(varName, resolvedType, null, parameterDefinition, currentMember, currentType)); } } if (!controlSpace) { - if (addedEnums.Count + addedDelegates.Count == 0) - return Enumerable.Empty (); + if (addedEnums.Count + addedDelegates.Count == 0) { + return Enumerable.Empty(); + } AutoCompleteEmptyMatch = false; AutoSelect = false; } - AddContextCompletion (result, state, invocation); + AddContextCompletion(result, state, invocation, unit); -// resolver.AddAccessibleCodeCompletionData (ExpressionContext.MethodBody, cdc); -// if (addedDelegates.Count > 0) { -// foreach (var data in result.Result) { -// if (data is MemberCompletionData) -// ((MemberCompletionData)data).IsDelegateExpected = true; -// } -// } + // resolver.AddAccessibleCodeCompletionData (ExpressionContext.MethodBody, cdc); + // if (addedDelegates.Count > 0) { + // foreach (var data in result.Result) { + // if (data is MemberCompletionData) + // ((MemberCompletionData)data).IsDelegateExpected = true; + // } + // } return result.Result; } - string GetShortType (IType type, CSharpResolver state) + string GetShortType(IType type, CSharpResolver state) { var builder = new TypeSystemAstBuilder (state); var dt = state.CurrentTypeDefinition; - var declaring = type.DeclaringType != null ? type.DeclaringType.GetDefinition () : null; + var declaring = type.DeclaringType != null ? type.DeclaringType.GetDefinition() : null; if (declaring != null) { while (dt != null) { - if (dt.Equals (declaring)) { + if (dt.Equals(declaring)) { builder.AlwaysUseShortTypeNames = true; break; } dt = dt.DeclaringTypeDefinition; } } - var shortType = builder.ConvertType (type); - using (var w = new System.IO.StringWriter ()) { - var visitor = new CSharpOutputVisitor (w, FormattingPolicy); - shortType.AcceptVisitor (visitor, null); - return w.ToString (); - } + var shortType = builder.ConvertType(type); + return shortType.GetText(FormattingPolicy); } - void AddEnumMembers (CompletionDataWrapper completionList, IType resolvedType, CSharpResolver state) + void AddEnumMembers(CompletionDataWrapper completionList, IType resolvedType, CSharpResolver state) { - if (resolvedType.Kind != TypeKind.Enum) + if (resolvedType.Kind != TypeKind.Enum) { return; - string typeString = GetShortType (resolvedType, state); - if (typeString.Contains (".")) - completionList.AddType (resolvedType, typeString); + } + string typeString = GetShortType(resolvedType, state); + if (typeString.Contains(".")) { + completionList.AddType(resolvedType, typeString); + } foreach (var field in resolvedType.GetFields ()) { - if (field.IsConst || field.IsStatic) - completionList.Result.Add (factory.CreateEntityCompletionData (field, typeString + "." + field.Name)); + if (field.IsConst || field.IsStatic) { + completionList.Result.Add(factory.CreateEntityCompletionData(field, typeString + "." + field.Name)); + } } DefaultCompletionString = typeString; } - IEnumerable CreateCompletionData (TextLocation location, ResolveResult resolveResult, AstNode resolvedNode, CSharpResolver state) + IEnumerable CreateCompletionData(TextLocation location, ResolveResult resolveResult, AstNode resolvedNode, CSharpResolver state) { - if (resolveResult == null /*|| resolveResult.IsError*/) + if (resolveResult == null /*|| resolveResult.IsError*/) { return null; + } if (resolveResult is NamespaceResolveResult) { var nr = (NamespaceResolveResult)resolveResult; - var namespaceContents = new CompletionDataWrapper (this); + var namespaceContents = new CompletionDataWrapper(this); foreach (var cl in nr.Namespace.Types) { - namespaceContents.AddType (cl, cl.Name); + namespaceContents.AddType(cl, cl.Name); } foreach (var ns in nr.Namespace.ChildNamespaces) { - namespaceContents.AddNamespace (ns.Name); + namespaceContents.AddNamespace(ns.Name); } return namespaceContents.Result; } IType type = resolveResult.Type; - var typeDef = resolveResult.Type.GetDefinition (); - var result = new CompletionDataWrapper (this); + //var typeDef = resolveResult.Type.GetDefinition(); + var result = new CompletionDataWrapper(this); bool includeStaticMembers = false; if (resolveResult is LocalResolveResult) { @@ -1788,30 +2064,53 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } if (resolveResult is TypeResolveResult && type.Kind == TypeKind.Enum) { foreach (var field in type.GetFields ()) { - result.AddMember (field); + result.AddMember(field); } foreach (var m in type.GetMethods ()) { - if (m.Name == "TryParse") - result.AddMember (m); + if (m.Name == "TryParse") { + result.AddMember(m); + } } return result.Result; } + var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly); + bool isProtectedAllowed = resolveResult is ThisResolveResult ? true : lookup.IsProtectedAccessAllowed(type); + bool skipNonStaticMembers = (resolveResult is TypeResolveResult); + if (resolveResult is MemberResolveResult && resolvedNode is IdentifierExpression) { var mrr = (MemberResolveResult)resolveResult; includeStaticMembers = mrr.Member.Name == mrr.Type.Name; + TypeResolveResult trr; + if (state.IsVariableReferenceWithSameType(resolveResult, ((IdentifierExpression)resolvedNode).Identifier, out trr)) { + if (currentMember != null && mrr.Member.IsStatic ^ currentMember.IsStatic) { + skipNonStaticMembers = true; + + if (trr.Type.Kind == TypeKind.Enum) { + foreach (var field in trr.Type.GetFields ()) { + result.AddMember(field); + } + foreach (var m in trr.Type.GetMethods ()) { + if (m.Name == "TryParse" && m.IsStatic) { + result.AddMember(m); + } + } + return result.Result; + } + } + } // ADD Aliases - var scope = CSharpParsedFile.GetUsingScope (location).Resolve (Compilation); + var scope = CSharpParsedFile.GetUsingScope(location).Resolve(Compilation); for (var n = scope; n != null; n = n.Parent) { foreach (var pair in n.UsingAliases) { if (pair.Key == mrr.Member.Name) { foreach (var r in CreateCompletionData (location, pair.Value, resolvedNode, state)) { if (r is IEntityCompletionData && ((IEntityCompletionData)r).Entity is IMember) { - result.AddMember ((IMember)((IEntityCompletionData)r).Entity); + result.AddMember((IMember)((IEntityCompletionData)r).Entity); } else { - result.Add (r); + result.Add(r); } } } @@ -1824,255 +2123,269 @@ namespace ICSharpCode.NRefactory.CSharp.Completion includeStaticMembers = true; } -// Console.WriteLine ("type:" + type +"/"+type.GetType ()); -// Console.WriteLine ("current:" + ctx.CurrentTypeDefinition); -// Console.WriteLine ("IS PROT ALLOWED:" + isProtectedAllowed + " static: "+ includeStaticMembers); -// Console.WriteLine (resolveResult); -// Console.WriteLine ("node:" + resolvedNode); -// Console.WriteLine (currentMember != null ? currentMember.IsStatic : "currentMember == null"); + // Console.WriteLine ("type:" + type +"/"+type.GetType ()); + // Console.WriteLine ("current:" + ctx.CurrentTypeDefinition); + // Console.WriteLine ("IS PROT ALLOWED:" + isProtectedAllowed + " static: "+ includeStaticMembers); + // Console.WriteLine (resolveResult); + // Console.WriteLine ("node:" + resolvedNode); + // Console.WriteLine (currentMember != null ? currentMember.IsStatic : "currentMember == null"); - if (resolvedNode.Annotation () == null) { //tags the created expression as part of an object create expression. - var lookup = new MemberLookup (ctx.CurrentTypeDefinition, Compilation.MainAssembly); - bool isProtectedAllowed = resolveResult is ThisResolveResult ? true : lookup.IsProtectedAccessAllowed (type); - - var filteredList = new List (); + if (resolvedNode.Annotation() == null) { + //tags the created expression as part of an object create expression. + + var filteredList = new List(); foreach (var member in type.GetMembers ()) { -// Console.WriteLine ("member:" + member + member.IsShadowing); - if (!lookup.IsAccessible (member, isProtectedAllowed)) { -// Console.WriteLine ("skip access: " + member.FullName); + if (member.EntityType == EntityType.Indexer || member.EntityType == EntityType.Operator || member.EntityType == EntityType.Constructor || member.EntityType == EntityType.Destructor) { + continue; + } + if (member.IsExplicitInterfaceImplementation) { continue; } - if (resolvedNode is BaseReferenceExpression && member.IsAbstract) + // Console.WriteLine ("member:" + member + member.IsShadowing); + if (!lookup.IsAccessible(member, isProtectedAllowed)) { + // Console.WriteLine ("skip access: " + member.FullName); continue; + } + if (resolvedNode is BaseReferenceExpression && member.IsAbstract) { + continue; + } bool memberIsStatic = member.IsStatic; if (!includeStaticMembers && memberIsStatic && !(resolveResult is TypeResolveResult)) { -// Console.WriteLine ("skip static member: " + member.FullName); + // Console.WriteLine ("skip static member: " + member.FullName); continue; } var field = member as IField; - if (field != null) + if (field != null) { memberIsStatic |= field.IsConst; + } - if (!memberIsStatic && (resolveResult is TypeResolveResult)) { + if (!memberIsStatic && skipNonStaticMembers) { continue; } - if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") + if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") { continue; - if (member.EntityType == EntityType.Operator) + } + if (member.EntityType == EntityType.Operator) { + continue; + } + if (member.IsExplicitInterfaceImplementation) { continue; - if (member.IsShadowing) - filteredList.RemoveAll (m => m.Name == member.Name); + } + if (member.IsShadowing) { + filteredList.RemoveAll(m => m.Name == member.Name); + } - filteredList.Add (member); + filteredList.Add(member); } foreach (var member in filteredList) { -// Console.WriteLine ("add : "+ member.FullName + " --- " + member.IsStatic); - result.AddMember (member); + // Console.WriteLine ("add:" + member + "/" + member.IsStatic); + result.AddMember(member); } } if (resolveResult is TypeResolveResult || includeStaticMembers) { foreach (var nested in type.GetNestedTypes ()) { - result.AddType (nested, nested.Name); + result.AddType(nested, nested.Name); } } else { foreach (var meths in state.GetExtensionMethods (type)) { foreach (var m in meths) { - result.AddMember (m); + result.AddMember(m); } } } -// IEnumerable objects = resolveResult.CreateResolveResult (dom, resolver != null ? resolver.CallingMember : null); -// CompletionDataCollector col = new CompletionDataCollector (this, dom, result, Document.CompilationUnit, resolver != null ? resolver.CallingType : null, location); -// col.HideExtensionParameter = !resolveResult.StaticResolve; -// col.NamePrefix = expressionResult.Expression; -// bool showOnlyTypes = expressionResult.Contexts.Any (ctx => ctx == ExpressionContext.InheritableType || ctx == ExpressionContext.Constraints); -// if (objects != null) { -// foreach (object obj in objects) { -// if (expressionResult.ExpressionContext != null && expressionResult.ExpressionContext.FilterEntry (obj)) -// continue; -// if (expressionResult.ExpressionContext == ExpressionContext.NamespaceNameExcepted && !(obj is Namespace)) -// continue; -// if (showOnlyTypes && !(obj is IType)) -// continue; -// CompletionData data = col.Add (obj); -// if (data != null && expressionResult.ExpressionContext == ExpressionContext.Attribute && data.CompletionText != null && data.CompletionText.EndsWith ("Attribute")) { -// string newText = data.CompletionText.Substring (0, data.CompletionText.Length - "Attribute".Length); -// data.SetText (newText); -// } -// } -// } + // IEnumerable objects = resolveResult.CreateResolveResult (dom, resolver != null ? resolver.CallingMember : null); + // CompletionDataCollector col = new CompletionDataCollector (this, dom, result, Document.CompilationUnit, resolver != null ? resolver.CallingType : null, location); + // col.HideExtensionParameter = !resolveResult.StaticResolve; + // col.NamePrefix = expressionResult.Expression; + // bool showOnlyTypes = expressionResult.Contexts.Any (ctx => ctx == ExpressionContext.InheritableType || ctx == ExpressionContext.Constraints); + // if (objects != null) { + // foreach (object obj in objects) { + // if (expressionResult.ExpressionContext != null && expressionResult.ExpressionContext.FilterEntry (obj)) + // continue; + // if (expressionResult.ExpressionContext == ExpressionContext.NamespaceNameExcepted && !(obj is Namespace)) + // continue; + // if (showOnlyTypes && !(obj is IType)) + // continue; + // CompletionData data = col.Add (obj); + // if (data != null && expressionResult.ExpressionContext == ExpressionContext.Attribute && data.CompletionText != null && data.CompletionText.EndsWith ("Attribute")) { + // string newText = data.CompletionText.Substring (0, data.CompletionText.Length - "Attribute".Length); + // data.SetText (newText); + // } + // } + // } return result.Result; } - IEnumerable CreateCaseCompletionData (TextLocation location) + IEnumerable CreateCaseCompletionData(TextLocation location) { - var unit = ParseStub ("a: break;"); - if (unit == null) + var unit = ParseStub("a: break;"); + if (unit == null) { return null; - var s = unit.GetNodeAt (location); - if (s == null) + } + var s = unit.GetNodeAt(location); + if (s == null) { return null; + } - var offset = document.GetOffset (s.Expression.StartLocation); - var expr = GetExpressionAt (offset); - if (expr == null) + var offset = document.GetOffset(s.Expression.StartLocation); + var expr = GetExpressionAt(offset); + if (expr == null) { return null; + } - var resolveResult = ResolveExpression (expr.Item1, expr.Item2, expr.Item3); - if (resolveResult == null || resolveResult.Item1.Type.Kind != TypeKind.Enum) + var resolveResult = ResolveExpression(expr); + if (resolveResult == null || resolveResult.Item1.Type.Kind != TypeKind.Enum) { return null; + } var wrapper = new CompletionDataWrapper (this); - AddEnumMembers (wrapper, resolveResult.Item1.Type, resolveResult.Item2); + AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); AutoCompleteEmptyMatch = false; return wrapper.Result; } #region Parsing methods - Tuple GetExpressionBeforeCursor () + ExpressionResult GetExpressionBeforeCursor() { CompilationUnit baseUnit; if (currentMember == null) { - baseUnit = ParseStub ("st {}", false); - var type = baseUnit.GetNodeAt (location); + baseUnit = ParseStub("a", false); + var type = baseUnit.GetNodeAt(location); if (type == null) { - baseUnit = ParseStub ("a;", false); - type = baseUnit.GetNodeAt (location); + baseUnit = ParseStub("a;", false); + type = baseUnit.GetNodeAt(location); } if (type == null) { - baseUnit = ParseStub ("A a;", false); - type = baseUnit.GetNodeAt (location); + baseUnit = ParseStub("A a;", false); + type = baseUnit.GetNodeAt(location); } - if (type != null) { - if (currentType == null) { - var tsvisitor2 = new TypeSystemConvertVisitor (this.CSharpParsedFile.FileName); - baseUnit.AcceptVisitor (tsvisitor2, null); - return Tuple.Create (tsvisitor2.ParsedFile, (AstNode)type.Target, baseUnit); - } - - var target = type.Target; - target.Remove (); - var node = Unit.GetNodeAt (location) ?? Unit; - node.AddChild (target, AstNode.Roles.Type); - return Tuple.Create (CSharpParsedFile, (AstNode)target, Unit); + return new ExpressionResult ((AstNode)type.Target, baseUnit); } } - if (currentMember == null && currentType == null) - return null; - baseUnit = ParseStub ("a()", false); - var curNode = baseUnit.GetNodeAt (location); + baseUnit = ParseStub("a()", false); + var curNode = baseUnit.GetNodeAt(location); // hack for local variable declaration missing ';' issue - remove that if it works. - if (curNode is AttributedNode || baseUnit.GetNodeAt (location) == null) { - baseUnit = ParseStub ("a()"); - curNode = baseUnit.GetNodeAt (location); + if (curNode is EntityDeclaration || baseUnit.GetNodeAt(location) == null) { + baseUnit = ParseStub("a()"); + curNode = baseUnit.GetNodeAt(location); } - + // Hack for handle object initializer continuation expressions - if (curNode is AttributedNode || baseUnit.GetNodeAt (location) == null) { - baseUnit = ParseStub ("a()};"); + if (curNode is EntityDeclaration || baseUnit.GetNodeAt(location) == null) { + baseUnit = ParseStub("a()};"); } - var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; - var mref = baseUnit.GetNodeAt (location); + var mref = baseUnit.GetNodeAt(location); + if (currentMember == null && currentType == null) { + if (mref != null) { + return new ExpressionResult ((AstNode)mref.Target, baseUnit); + } + return null; + } + //var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; if (mref == null) { - var invoke = baseUnit.GetNodeAt (location); - if (invoke != null) + var invoke = baseUnit.GetNodeAt(location); + if (invoke != null) { mref = invoke.Target as MemberReferenceExpression; + } } - Expression expr = null; + AstNode expr = null; if (mref != null) { - expr = mref.Target.Clone (); - mref.Parent.ReplaceWith (expr); + expr = mref.Target.Clone(); + mref.Parent.ReplaceWith(expr); } else { - Expression tref = baseUnit.GetNodeAt (location); + Expression tref = baseUnit.GetNodeAt(location); MemberType memberType = tref != null ? ((TypeReferenceExpression)tref).Type as MemberType : null; if (memberType == null) { - memberType = baseUnit.GetNodeAt (location); + memberType = baseUnit.GetNodeAt(location); if (memberType != null) { - tref = baseUnit.GetNodeAt (location); - if (tref == null) { - tref = new TypeReferenceExpression (memberType.Clone ()); - memberType.Parent.AddChild (tref, AstNode.Roles.Expression); + if (memberType.Parent is ObjectCreateExpression) { + var mt = memberType.Target.Clone(); + memberType.ReplaceWith(mt); + expr = mt; + goto exit; + } else { + tref = baseUnit.GetNodeAt(location); + if (tref == null) { + tref = new TypeReferenceExpression (memberType.Clone()); + memberType.Parent.AddChild(tref, Roles.Expression); + } + if (tref is ObjectCreateExpression) { + expr = new TypeReferenceExpression (memberType.Target.Clone()); + expr.AddAnnotation(new ObjectCreateExpression ()); + } } } - if (tref is ObjectCreateExpression) { - expr = new TypeReferenceExpression (memberType.Target.Clone ()); - expr.AddAnnotation (new ObjectCreateExpression ()); - } } - - if (memberType == null) + + if (memberType == null) { return null; - if (expr == null) - expr = new TypeReferenceExpression (memberType.Target.Clone ()); - tref.ReplaceWith (expr); + } + if (expr == null) { + expr = new TypeReferenceExpression (memberType.Target.Clone()); + } + tref.ReplaceWith(expr); } - - var member = Unit.GetNodeAt (memberLocation); - var member2 = baseUnit.GetNodeAt (memberLocation); - member2.Remove (); - member.ReplaceWith (member2); - var tsvisitor = new TypeSystemConvertVisitor (this.CSharpParsedFile.FileName); - Unit.AcceptVisitor (tsvisitor, null); - return Tuple.Create (tsvisitor.ParsedFile, (AstNode)expr, Unit); + exit: + return new ExpressionResult ((AstNode)expr, baseUnit); } - - Tuple GetExpressionAtCursor () + + ExpressionResult GetExpressionAtCursor() { -// if (currentMember == null && currentType == null) -// return null; + // TextLocation memberLocation; + // if (currentMember != null) { + // memberLocation = currentMember.Region.Begin; + // } else if (currentType != null) { + // memberLocation = currentType.Region.Begin; + // } else { + // memberLocation = location; + // } + var baseUnit = ParseStub("a"); - TextLocation memberLocation; - if (currentMember != null) { - memberLocation = currentMember.Region.Begin; - } else if (currentType != null) { - memberLocation = currentType.Region.Begin; - } else { - memberLocation = location; - } - var baseUnit = ParseStub (""); var tmpUnit = baseUnit; - AstNode expr = baseUnit.GetNodeAt (location.Line, location.Column - 1); - if (expr == null) - expr = baseUnit.GetNodeAt (location.Line, location.Column - 1); + AstNode expr = baseUnit.GetNodeAt(location, n => n is IdentifierExpression || n is MemberReferenceExpression); + if (expr == null) { + expr = baseUnit.GetNodeAt(location.Line, location.Column - 1); + } if (expr == null) - expr = baseUnit.GetNodeAt (location.Line, location.Column - 1); - + expr = baseUnit.GetNodeAt(location.Line, location.Column - 1); // try insertStatement - if (expr == null && baseUnit.GetNodeAt (location.Line, location.Column) != null) { - tmpUnit = baseUnit = ParseStub ("a();", false); - expr = baseUnit.GetNodeAt (location.Line, location.Column + 1); + if (expr == null && baseUnit.GetNodeAt(location.Line, location.Column) != null) { + tmpUnit = baseUnit = ParseStub("a();", false); + expr = baseUnit.GetNodeAt(location.Line, location.Column + 1); } - + if (expr == null) { - baseUnit = ParseStub ("()"); - expr = baseUnit.GetNodeAt (location.Line, location.Column - 1); + baseUnit = ParseStub("()"); + expr = baseUnit.GetNodeAt(location.Line, location.Column - 1); + if (expr == null) { + expr = baseUnit.GetNodeAt(location.Line, location.Column - 1); + } } - - // try initializer expression + if (expr == null) { - baseUnit = ParseStub ("a = b};", false); - expr = baseUnit.GetNodeAt (location.Line, location.Column - 1); + baseUnit = ParseStub("a", false); + expr = baseUnit.GetNodeAt(location, n => n is IdentifierExpression || n is MemberReferenceExpression || n is CatchClause); } - + // try statement if (expr == null) { - expr = tmpUnit.GetNodeAt (location.Line, location.Column - 1); + expr = tmpUnit.GetNodeAt(location.Line, location.Column - 1); baseUnit = tmpUnit; } - + if (expr == null) { - var block = tmpUnit.GetNodeAt (location); - var node = block != null ? block.Statements.LastOrDefault () : null; - + var block = tmpUnit.GetNodeAt(location); + var node = block != null ? block.Statements.LastOrDefault() : null; + var forStmt = node != null ? node.PrevSibling as ForStatement : null; if (forStmt != null && forStmt.EmbeddedStatement.IsNull) { expr = forStmt; @@ -2084,307 +2397,188 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } if (expr == null) { - var forStmt = tmpUnit.GetNodeAt (location.Line, location.Column - 3); + var forStmt = tmpUnit.GetNodeAt(location.Line, location.Column - 3); if (forStmt != null && forStmt.EmbeddedStatement.IsNull) { - forStmt.VariableNameToken = Identifier.Create ("stub"); + forStmt.VariableNameToken = Identifier.Create("stub"); expr = forStmt.VariableNameToken; baseUnit = tmpUnit; } } if (expr == null) { - expr = tmpUnit.GetNodeAt (location.Line, location.Column - 1); + expr = tmpUnit.GetNodeAt(location.Line, location.Column - 1); baseUnit = tmpUnit; } - + // try parameter declaration type if (expr == null) { - baseUnit = ParseStub (">", false, "{}"); - expr = baseUnit.GetNodeAt (location.Line, location.Column - 1); + baseUnit = ParseStub(">", false, "{}"); + expr = baseUnit.GetNodeAt(location.Line, location.Column - 1); } - + // try parameter declaration method if (expr == null) { - baseUnit = ParseStub ("> ()", false, "{}"); - expr = baseUnit.GetNodeAt (location.Line, location.Column - 1); + baseUnit = ParseStub("> ()", false, "{}"); + expr = baseUnit.GetNodeAt(location.Line, location.Column - 1); } - + // try expression in anonymous type "new { sample = x$" case if (expr == null) { - baseUnit = ParseStub ("a", false); - expr = baseUnit.GetNodeAt (location.Line, location.Column); - if (expr != null) - expr = baseUnit.GetNodeAt (location.Line, location.Column) ?? expr; + baseUnit = ParseStub("a", false); + expr = baseUnit.GetNodeAt(location.Line, location.Column); + if (expr != null) { + expr = baseUnit.GetNodeAt(location.Line, location.Column) ?? expr; + } + if (expr == null) { + expr = baseUnit.GetNodeAt(location.Line, location.Column); + } } - - if (expr == null) + if (expr == null) { return null; - var member = Unit.GetNodeAt (memberLocation); - var member2 = baseUnit.GetNodeAt (memberLocation); - if (member != null && member2 != null) { - member2.Remove (); - - if (member is TypeDeclaration) { - member.AddChild (member2, TypeDeclaration.MemberRole); - } else { - member.ReplaceWith (member2); - } - } else { - var tsvisitor2 = new TypeSystemConvertVisitor (CSharpParsedFile.FileName); - Unit.AcceptVisitor (tsvisitor2, null); - return Tuple.Create (tsvisitor2.ParsedFile, expr, baseUnit); } - var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName); - Unit.AcceptVisitor (tsvisitor, null); - return Tuple.Create (tsvisitor.ParsedFile, expr, Unit); + return new ExpressionResult (expr, baseUnit); } - Tuple GetExpressionAt (int offset) + ExpressionResult GetExpressionAt(int offset) { var parser = new CSharpParser (); - string text = this.document.GetText (0, this.offset); + string text = this.document.GetText(0, this.offset); var sb = new StringBuilder (text); - sb.Append ("a;"); - AppendMissingClosingBrackets (sb, text, false); - var stream = new System.IO.StringReader (sb.ToString ()); - var completionUnit = parser.Parse (stream, CSharpParsedFile.FileName, 0); - stream.Close (); - var loc = document.GetLocation (offset); - - var expr = completionUnit.GetNodeAt (loc, n => n is Expression || n is VariableDeclarationStatement); - if (expr == null) + sb.Append("a;"); + AppendMissingClosingBrackets(sb, text, false); + var stream = new System.IO.StringReader (sb.ToString()); + var completionUnit = parser.Parse(stream, CSharpParsedFile.FileName, 0); + stream.Close(); + var loc = document.GetLocation(offset); + + var expr = completionUnit.GetNodeAt(loc, n => n is Expression || n is VariableDeclarationStatement); + if (expr == null) { return null; - var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName); - completionUnit.AcceptVisitor (tsvisitor, null); - - return Tuple.Create (tsvisitor.ParsedFile, expr, completionUnit); + } + return new ExpressionResult (expr, completionUnit); } - Tuple GetNewExpressionAt (int offset) + ExpressionResult GetNewExpressionAt(int offset) { var parser = new CSharpParser (); - string text = this.document.GetText (0, this.offset); + string text = this.document.GetText(0, this.offset); var sb = new StringBuilder (text); - sb.Append ("a ();"); - AppendMissingClosingBrackets (sb, text, false); + sb.Append("a ();"); + AppendMissingClosingBrackets(sb, text, false); - var stream = new System.IO.StringReader (sb.ToString ()); - var completionUnit = parser.Parse (stream, CSharpParsedFile.FileName, 0); - stream.Close (); - var loc = document.GetLocation (offset); + var stream = new System.IO.StringReader (sb.ToString()); + var completionUnit = parser.Parse(stream, CSharpParsedFile.FileName, 0); + stream.Close(); + var loc = document.GetLocation(offset); - var expr = completionUnit.GetNodeAt (loc, n => n is Expression); + var expr = completionUnit.GetNodeAt(loc, n => n is Expression); if (expr == null) { // try without ";" sb = new StringBuilder (text); - sb.Append ("a ()"); - AppendMissingClosingBrackets (sb, text, false); - stream = new System.IO.StringReader (sb.ToString ()); - completionUnit = parser.Parse (stream, CSharpParsedFile.FileName, 0); - stream.Close (); - loc = document.GetLocation (offset); + sb.Append("a ()"); + AppendMissingClosingBrackets(sb, text, false); + stream = new System.IO.StringReader (sb.ToString()); + completionUnit = parser.Parse(stream, CSharpParsedFile.FileName, 0); + stream.Close(); + loc = document.GetLocation(offset); - expr = completionUnit.GetNodeAt (loc, n => n is Expression); - if (expr == null) + expr = completionUnit.GetNodeAt(loc, n => n is Expression); + if (expr == null) { return null; + } } - var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName); - completionUnit.AcceptVisitor (tsvisitor, null); - - return Tuple.Create (tsvisitor.ParsedFile, expr, completionUnit); + return new ExpressionResult (expr, completionUnit); } #endregion #region Helper methods - string GetPreviousToken (ref int i, bool allowLineChange) + string GetPreviousToken(ref int i, bool allowLineChange) { char c; - if (i <= 0) + if (i <= 0) { return null; + } do { - c = document.GetCharAt (--i); + c = document.GetCharAt(--i); } while (i > 0 && char.IsWhiteSpace (c) && (allowLineChange ? true : c != '\n')); - if (i == 0) + if (i == 0) { return null; + } - if (!char.IsLetterOrDigit (c)) + if (!char.IsLetterOrDigit(c)) { return new string (c, 1); + } int endOffset = i + 1; do { - c = document.GetCharAt (i - 1); - if (!(char.IsLetterOrDigit (c) || c == '_')) + c = document.GetCharAt(i - 1); + if (!(char.IsLetterOrDigit(c) || c == '_')) { break; + } i--; } while (i > 0); - return document.GetText (i, endOffset - i); - } - - bool GetParameterCompletionCommandOffset (out int cpos) - { - // Start calculating the parameter offset from the beginning of the - // current member, instead of the beginning of the file. - cpos = offset - 1; - var mem = currentMember; - if (mem == null || (mem is IType)) - return false; - int startPos = document.GetOffset (mem.Region.BeginLine, mem.Region.BeginColumn); - int parenDepth = 0; - int chevronDepth = 0; - while (cpos > startPos) { - char c = document.GetCharAt (cpos); - if (c == ')') - parenDepth++; - if (c == '>') - chevronDepth++; - if (parenDepth == 0 && c == '(' || chevronDepth == 0 && c == '<') { - int p = GetCurrentParameterIndex (cpos + 1, startPos); - if (p != -1) { - cpos++; - return true; - } else { - return false; - } - } - if (c == '(') - parenDepth--; - if (c == '<') - chevronDepth--; - cpos--; - } - return false; - } - - int GetCurrentParameterIndex (int offset, int memberStart) - { - int cursor = this.offset; - int i = offset; - - if (i > cursor) - return -1; - if (i == cursor) - return 1; // parameters are 1 based - int index = memberStart + 1; - int parentheses = 0; - int bracket = 0; - bool insideQuote = false, insideString = false, insideSingleLineComment = false, insideMultiLineComment = false; - do { - char c = document.GetCharAt (i - 1); - switch (c) { - case '\\': - if (insideString || insideQuote) - i++; - break; - case '\'': - if (!insideString && !insideSingleLineComment && !insideMultiLineComment) - insideQuote = !insideQuote; - break; - case '"': - if (!insideQuote && !insideSingleLineComment && !insideMultiLineComment) - insideString = !insideString; - break; - case '/': - if (!insideQuote && !insideString && !insideMultiLineComment) { - if (document.GetCharAt (i) == '/') - insideSingleLineComment = true; - if (document.GetCharAt (i) == '*') - insideMultiLineComment = true; - } - break; - case '*': - if (insideMultiLineComment && document.GetCharAt (i) == '/') - insideMultiLineComment = false; - break; - case '\n': - case '\r': - insideSingleLineComment = false; - break; - case '{': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) - bracket++; - break; - case '}': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) - bracket--; - break; - case '(': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) - parentheses++; - break; - case ')': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) - parentheses--; - break; - case ',': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment && parentheses == 1 && bracket == 0) - index++; - break; - } - i++; - } while (i <= cursor && parentheses >= 0); - - return parentheses != 1 || bracket > 0 ? -1 : index; + return document.GetText(i, endOffset - i); } - + #endregion #region Preprocessor - IEnumerable GetDirectiveCompletionData () + IEnumerable GetDirectiveCompletionData() { - yield return factory.CreateLiteralCompletionData ("if"); - yield return factory.CreateLiteralCompletionData ("else"); - yield return factory.CreateLiteralCompletionData ("elif"); - yield return factory.CreateLiteralCompletionData ("endif"); - yield return factory.CreateLiteralCompletionData ("define"); - yield return factory.CreateLiteralCompletionData ("undef"); - yield return factory.CreateLiteralCompletionData ("warning"); - yield return factory.CreateLiteralCompletionData ("error"); - yield return factory.CreateLiteralCompletionData ("pragma"); - yield return factory.CreateLiteralCompletionData ("line"); - yield return factory.CreateLiteralCompletionData ("line hidden"); - yield return factory.CreateLiteralCompletionData ("line default"); - yield return factory.CreateLiteralCompletionData ("region"); - yield return factory.CreateLiteralCompletionData ("endregion"); + yield return factory.CreateLiteralCompletionData("if"); + yield return factory.CreateLiteralCompletionData("else"); + yield return factory.CreateLiteralCompletionData("elif"); + yield return factory.CreateLiteralCompletionData("endif"); + yield return factory.CreateLiteralCompletionData("define"); + yield return factory.CreateLiteralCompletionData("undef"); + yield return factory.CreateLiteralCompletionData("warning"); + yield return factory.CreateLiteralCompletionData("error"); + yield return factory.CreateLiteralCompletionData("pragma"); + yield return factory.CreateLiteralCompletionData("line"); + yield return factory.CreateLiteralCompletionData("line hidden"); + yield return factory.CreateLiteralCompletionData("line default"); + yield return factory.CreateLiteralCompletionData("region"); + yield return factory.CreateLiteralCompletionData("endregion"); } #endregion #region Xml Comments static readonly List commentTags = new List (new string[] { "c", "code", "example", "exception", "include", "list", "listheader", "item", "term", "description", "para", "param", "paramref", "permission", "remarks", "returns", "see", "seealso", "summary", "value" }); - IEnumerable GetXmlDocumentationCompletionData () + IEnumerable GetXmlDocumentationCompletionData() { - yield return factory.CreateLiteralCompletionData ("c", "Set text in a code-like font"); - yield return factory.CreateLiteralCompletionData ("code", "Set one or more lines of source code or program output"); - yield return factory.CreateLiteralCompletionData ("example", "Indicate an example"); - yield return factory.CreateLiteralCompletionData ("exception", "Identifies the exceptions a method can throw", "exception cref=\"|\">"); - yield return factory.CreateLiteralCompletionData ("include", "Includes comments from a external file", "include file=\"|\" path=\"\">"); - yield return factory.CreateLiteralCompletionData ("list", "Create a list or table", "list type=\"|\">"); - yield return factory.CreateLiteralCompletionData ("listheader", "Define the heading row"); - yield return factory.CreateLiteralCompletionData ("item", "Defines list or table item"); - - yield return factory.CreateLiteralCompletionData ("term", "A term to define"); - yield return factory.CreateLiteralCompletionData ("description", "Describes a list item"); - yield return factory.CreateLiteralCompletionData ("para", "Permit structure to be added to text"); - - yield return factory.CreateLiteralCompletionData ("param", "Describe a parameter for a method or constructor", "param name=\"|\">"); - yield return factory.CreateLiteralCompletionData ("paramref", "Identify that a word is a parameter name", "paramref name=\"|\"/>"); - - yield return factory.CreateLiteralCompletionData ("permission", "Document the security accessibility of a member", "permission cref=\"|\""); - yield return factory.CreateLiteralCompletionData ("remarks", "Describe a type"); - yield return factory.CreateLiteralCompletionData ("returns", "Describe the return value of a method"); - yield return factory.CreateLiteralCompletionData ("see", "Specify a link", "see cref=\"|\"/>"); - yield return factory.CreateLiteralCompletionData ("seealso", "Generate a See Also entry", "seealso cref=\"|\"/>"); - yield return factory.CreateLiteralCompletionData ("summary", "Describe a member of a type"); - yield return factory.CreateLiteralCompletionData ("typeparam", "Describe a type parameter for a generic type or method"); - yield return factory.CreateLiteralCompletionData ("typeparamref", "Identify that a word is a type parameter name"); - yield return factory.CreateLiteralCompletionData ("value", "Describe a property"); + yield return factory.CreateLiteralCompletionData("c", "Set text in a code-like font"); + yield return factory.CreateLiteralCompletionData("code", "Set one or more lines of source code or program output"); + yield return factory.CreateLiteralCompletionData("example", "Indicate an example"); + yield return factory.CreateLiteralCompletionData("exception", "Identifies the exceptions a method can throw", "exception cref=\"|\">"); + yield return factory.CreateLiteralCompletionData("include", "Includes comments from a external file", "include file=\"|\" path=\"\">"); + yield return factory.CreateLiteralCompletionData("list", "Create a list or table", "list type=\"|\">"); + yield return factory.CreateLiteralCompletionData("listheader", "Define the heading row"); + yield return factory.CreateLiteralCompletionData("item", "Defines list or table item"); + + yield return factory.CreateLiteralCompletionData("term", "A term to define"); + yield return factory.CreateLiteralCompletionData("description", "Describes a list item"); + yield return factory.CreateLiteralCompletionData("para", "Permit structure to be added to text"); + + yield return factory.CreateLiteralCompletionData("param", "Describe a parameter for a method or constructor", "param name=\"|\">"); + yield return factory.CreateLiteralCompletionData("paramref", "Identify that a word is a parameter name", "paramref name=\"|\"/>"); + + yield return factory.CreateLiteralCompletionData("permission", "Document the security accessibility of a member", "permission cref=\"|\""); + yield return factory.CreateLiteralCompletionData("remarks", "Describe a type"); + yield return factory.CreateLiteralCompletionData("returns", "Describe the return value of a method"); + yield return factory.CreateLiteralCompletionData("see", "Specify a link", "see cref=\"|\"/>"); + yield return factory.CreateLiteralCompletionData("seealso", "Generate a See Also entry", "seealso cref=\"|\"/>"); + yield return factory.CreateLiteralCompletionData("summary", "Describe a member of a type"); + yield return factory.CreateLiteralCompletionData("typeparam", "Describe a type parameter for a generic type or method"); + yield return factory.CreateLiteralCompletionData("typeparamref", "Identify that a word is a type parameter name"); + yield return factory.CreateLiteralCompletionData("value", "Describe a property"); } #endregion @@ -2395,7 +2589,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion "true", "false", "typeof", "checked", "unchecked", "from", "break", "checked", "unchecked", "const", "continue", "do", "finally", "fixed", "for", "foreach", "goto", "if", "lock", "return", "stackalloc", "switch", "throw", "try", "unsafe", - "using", "while", "yield", "dynamic", "var", "dynamic" + "using", "while", "yield", "dynamic", "var", "dynamic", + "catch" }; static string[] globalLevelKeywords = new string [] { "namespace", "using", "extern", "public", "internal", @@ -2414,6 +2609,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion "override", "readonly", "virtual", "volatile" }; static string[] linqKeywords = new string[] { "from", "where", "select", "group", "into", "orderby", "join", "let", "in", "on", "equals", "by", "ascending", "descending" }; + static string[] parameterTypePredecessorKeywords = new string[] { "out", "ref", "params" }; #endregion } } diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs index 267fdb4b7..4bfa2f9d4 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs @@ -100,12 +100,265 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var provider = MemberProvider ?? new DefaultMemberProvider (this); provider.GetCurrentMembers (offset, out currentType, out currentMember); } + + protected bool GetParameterCompletionCommandOffset(out int cpos) + { + // Start calculating the parameter offset from the beginning of the + // current member, instead of the beginning of the file. + cpos = offset - 1; + var mem = currentMember; + if (mem == null || (mem is IType)) { + return false; + } + int startPos = document.GetOffset(mem.Region.BeginLine, mem.Region.BeginColumn); + int parenDepth = 0; + int chevronDepth = 0; + Stack indexStack = new Stack(); + while (cpos > startPos) { + char c = document.GetCharAt(cpos); + if (c == ')') { + parenDepth++; + } + if (c == '>') { + chevronDepth++; + } + if (c == '}') { + if (indexStack.Count > 0) { + parenDepth = indexStack.Pop(); + } else { + parenDepth = 0; + } + chevronDepth = 0; + } + if (indexStack.Count == 0 && (parenDepth == 0 && c == '(' || chevronDepth == 0 && c == '<')) { + int p = GetCurrentParameterIndex (cpos + 1, startPos); + if (p != -1) { + cpos++; + return true; + } else { + return false; + } + } + if (c == '(') { + parenDepth--; + } + if (c == '<') { + chevronDepth--; + } + if (c == '{') { + indexStack.Push (parenDepth); + chevronDepth = 0; + } + cpos--; + } + return false; + } + protected int GetCurrentParameterIndex (int offset, int memberStart) + { + int cursor = this.offset; + int i = offset; + + if (i > cursor) { + return -1; + } + if (i == cursor) { + return 1; + } + // parameters are 1 based + int index = memberStart + 1; + int parentheses = 0; + int bracket = 0; + bool insideQuote = false, insideString = false, insideSingleLineComment = false, insideMultiLineComment = false; + Stack indexStack = new Stack (); + do { + char c = document.GetCharAt (i - 1); + switch (c) { + case '\\': + if (insideString || insideQuote) { + i++; + } + break; + case '\'': + if (!insideString && !insideSingleLineComment && !insideMultiLineComment) { + insideQuote = !insideQuote; + } + break; + case '"': + if (!insideQuote && !insideSingleLineComment && !insideMultiLineComment) { + insideString = !insideString; + } + break; + case '/': + if (!insideQuote && !insideString && !insideMultiLineComment) { + if (document.GetCharAt (i) == '/') { + insideSingleLineComment = true; + } + if (document.GetCharAt (i) == '*') { + insideMultiLineComment = true; + } + } + break; + case '*': + if (insideMultiLineComment && document.GetCharAt (i) == '/') { + insideMultiLineComment = false; + } + break; + case '\n': + case '\r': + insideSingleLineComment = false; + break; + case '{': + if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) { + bracket++; + indexStack.Push (index); + } + break; + case '}': + if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) { + bracket--; + if (indexStack.Count > 0) + index = indexStack.Pop (); + } + break; + case '(': + if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) { + parentheses++; + } + break; + case ')': + if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) { + parentheses--; + } + break; + case ',': + if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment && parentheses == 1 && bracket == 0) { + index++; + } + break; + + } + i++; + } while (i <= cursor && parentheses >= 0); + Console.WriteLine (indexStack.Count >= 0 || parentheses != 1 || bracket > 0 ? -1 : index); + return indexStack.Count >= 0 || parentheses != 1 || bracket > 0 ? -1 : index; + } + #region Context helper methods - protected bool IsInsideCommentOrString () + public class MiniLexer + { + readonly string text; + + public bool IsFistNonWs = true; + public bool IsInSingleComment = false; + public bool IsInString = false; + public bool IsInVerbatimString = false; + public bool IsInChar = false; + public bool IsInMultiLineComment = false; + public bool IsInPreprocessorDirective = false; + + public MiniLexer(string text) + { + this.text = text; + } + + public void Parse(Action act = null) + { + Parse(0, text.Length, act); + } + + public void Parse(int start, int length, Action act = null) + { + for (int i = start; i < length; i++) { + char ch = text [i]; + char nextCh = i + 1 < text.Length ? text [i + 1] : '\0'; + switch (ch) { + case '#': + if (IsFistNonWs) + IsInPreprocessorDirective = true; + break; + case '/': + if (IsInString || IsInChar || IsInVerbatimString) + break; + if (nextCh == '/') { + i++; + IsInSingleComment = true; + } + if (nextCh == '*') + IsInMultiLineComment = true; + break; + case '*': + if (IsInString || IsInChar || IsInVerbatimString || IsInSingleComment) + break; + if (nextCh == '/') { + i++; + IsInMultiLineComment = false; + } + break; + case '@': + if (IsInString || IsInChar || IsInVerbatimString || IsInSingleComment || IsInMultiLineComment) + break; + if (nextCh == '"') { + i++; + IsInVerbatimString = true; + } + break; + case '\n': + case '\r': + IsInSingleComment = false; + IsInString = false; + IsInChar = false; + IsFistNonWs = true; + break; + case '\\': + if (IsInString || IsInChar) + i++; + break; + case '"': + if (IsInSingleComment || IsInMultiLineComment || IsInChar) + break; + if (IsInVerbatimString) { + if (nextCh == '"') { + i++; + break; + } + IsInVerbatimString = false; + break; + } + IsInString = !IsInString; + break; + case '\'': + if (IsInSingleComment || IsInMultiLineComment || IsInString || IsInVerbatimString) + break; + IsInChar = !IsInChar; + break; + } + if (act != null) + act(ch); + IsFistNonWs &= ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; + } + } + } + + protected bool IsInsideCommentStringOrDirective() + { + var text = GetMemberTextToCaret(); + var lexer = new MiniLexer(text.Item1); + lexer.Parse(); + return + lexer.IsInSingleComment || + lexer.IsInString || + lexer.IsInVerbatimString || + lexer.IsInChar || + lexer.IsInMultiLineComment || + lexer.IsInPreprocessorDirective; + } + + protected bool IsInsideDocComment () { var text = GetMemberTextToCaret (); bool inSingleComment = false, inString = false, inVerbatimString = false, inChar = false, inMultiLineComment = false; + bool singleLineIsDoc = false; for (int i = 0; i < text.Item1.Length - 1; i++) { char ch = text.Item1 [i]; @@ -118,6 +371,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (nextCh == '/') { i++; inSingleComment = true; + singleLineIsDoc = i + 1 < text.Item1.Length && text.Item1 [i + 1] == '/'; + if (singleLineIsDoc) { + i++; + } } if (nextCh == '*') inMultiLineComment = true; @@ -169,30 +426,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } - return inSingleComment || inString || inVerbatimString || inChar || inMultiLineComment; - } - - protected bool IsInsideComment (int offset) - { - var loc = document.GetLocation (offset); - return Unit.GetNodeAt (loc.Line, loc.Column) != null; - } - - protected bool IsInsideDocComment () - { - var loc = document.GetLocation (offset); - var cmt = Unit.GetNodeAt (loc.Line, loc.Column - 1); - return cmt != null && cmt.CommentType == CommentType.Documentation; - } - - protected bool IsInsideString (int offset) - { - - var loc = document.GetLocation (offset); - var expr = Unit.GetNodeAt (loc.Line, loc.Column); - return expr != null && expr.Value is string; + return inSingleComment && singleLineIsDoc; } - + protected CSharpResolver GetState () { return new CSharpResolver (ctx); @@ -221,7 +457,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion #endregion #region Basic parsing/resolving functions - Stack> GetBracketStack (string memberText) + static Stack> GetBracketStack (string memberText) { var bracketStack = new Stack> (); @@ -307,28 +543,31 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return bracketStack; } - protected void AppendMissingClosingBrackets (StringBuilder wrapper, string memberText, bool appendSemicolon) + public static void AppendMissingClosingBrackets (StringBuilder wrapper, string memberText, bool appendSemicolon) { var bracketStack = GetBracketStack (memberText); bool didAppendSemicolon = !appendSemicolon; - char lastBracket = '\0'; + //char lastBracket = '\0'; while (bracketStack.Count > 0) { var t = bracketStack.Pop (); switch (t.Item1) { case '(': wrapper.Append (')'); - didAppendSemicolon = false; - lastBracket = ')'; + if (appendSemicolon) + didAppendSemicolon = false; + //lastBracket = ')'; break; case '[': wrapper.Append (']'); - didAppendSemicolon = false; - lastBracket = ']'; + if (appendSemicolon) + didAppendSemicolon = false; + //lastBracket = ']'; break; case '<': wrapper.Append ('>'); - didAppendSemicolon = false; - lastBracket = '>'; + if (appendSemicolon) + didAppendSemicolon = false; + //lastBracket = '>'; break; case '{': int o = t.Item2 - 1; @@ -354,61 +593,44 @@ namespace ICSharpCode.NRefactory.CSharp.Completion break; } } - if (currentMember == null && lastBracket == ']') { - // attribute context - wrapper.Append ("class GenAttr {}"); - } else { - if (!didAppendSemicolon) - wrapper.Append (';'); - } + if (!didAppendSemicolon) + wrapper.Append (';'); } - protected CompilationUnit ParseStub (string continuation, bool appendSemicolon = true, string afterContinuation = null) + protected CompilationUnit ParseStub(string continuation, bool appendSemicolon = true, string afterContinuation = null) { - var mt = GetMemberTextToCaret (); - if (mt == null) + var mt = GetMemberTextToCaret(); + if (mt == null) { return null; - + } + string memberText = mt.Item1; - bool wrapInClass = mt.Item2; - - var wrapper = new StringBuilder (); - + var memberLocation = mt.Item2; + int closingBrackets = 1; + int generatedLines = 0; + var wrapper = new StringBuilder(); + bool wrapInClass = memberLocation != new TextLocation(1, 1); if (wrapInClass) { -/* foreach (var child in Unit.Children) { - if (child is UsingDeclaration) { - var offset = document.GetOffset (child.StartLocation); - wrapper.Append (document.GetText (offset, document.GetOffset (child.EndLocation) - offset)); - } - }*/ - wrapper.Append ("class Stub {"); - wrapper.AppendLine (); + wrapper.Append("class Stub {"); + wrapper.AppendLine(); + closingBrackets++; + generatedLines++; } - - wrapper.Append (memberText); - wrapper.Append (continuation); - AppendMissingClosingBrackets (wrapper, memberText, appendSemicolon); - wrapper.Append (afterContinuation); - - if (wrapInClass) - wrapper.Append ('}'); - - TextLocation memberLocation; - if (currentMember != null && currentType != null && currentType.Kind != TypeKind.Enum) { - memberLocation = currentMember.Region.Begin; - } else if (currentType != null) { - memberLocation = currentType.Region.Begin; - } else { - memberLocation = new TextLocation (1, 1); + wrapper.Append(memberText); + wrapper.Append(continuation); + AppendMissingClosingBrackets(wrapper, memberText, appendSemicolon); + wrapper.Append(afterContinuation); + if (closingBrackets > 0) { + wrapper.Append(new string('}', closingBrackets)); } - using (var stream = new System.IO.StringReader (wrapper.ToString ())) { try { var parser = new CSharpParser (); - return parser.Parse (stream, "stub.cs", wrapInClass ? memberLocation.Line - 2 : 0); + var result = parser.Parse(stream, "stub.cs", memberLocation.Line - 1 - generatedLines); + return result; } catch (Exception) { - Console.WriteLine ("------"); - Console.WriteLine (wrapper); + Console.WriteLine("------"); + Console.WriteLine(wrapper); throw; } } @@ -421,79 +643,111 @@ namespace ICSharpCode.NRefactory.CSharp.Completion cachedText = null; } - protected Tuple GetMemberTextToCaret () + protected Tuple GetMemberTextToCaret() { int startOffset; if (currentMember != null && currentType != null && currentType.Kind != TypeKind.Enum) { - startOffset = document.GetOffset (currentMember.Region.BeginLine, currentMember.Region.BeginColumn); + startOffset = document.GetOffset(currentMember.Region.Begin); } else if (currentType != null) { - startOffset = document.GetOffset (currentType.Region.BeginLine, currentType.Region.BeginColumn); + startOffset = document.GetOffset(currentType.Region.Begin); } else { startOffset = 0; } while (startOffset > 0) { - char ch = document.GetCharAt (startOffset - 1); - if (ch != ' ' && ch != '\t') + char ch = document.GetCharAt(startOffset - 1); + if (ch != ' ' && ch != '\t') { break; + } --startOffset; } if (cachedText == null) cachedText = document.GetText (startOffset, offset - startOffset); - return Tuple.Create (cachedText, startOffset != 0); + return Tuple.Create (cachedText, document.GetLocation (startOffset)); } - protected Tuple GetInvocationBeforeCursor (bool afterBracket) + protected ExpressionResult GetInvocationBeforeCursor(bool afterBracket) { CompilationUnit baseUnit; - if (currentMember == null) { - baseUnit = ParseStub ("", false); - var section = baseUnit.GetNodeAt (location.Line, location.Column - 2); - var attr = section != null ? section.Attributes.LastOrDefault () : null; - if (attr != null) { - // insert target type into compilation unit, to respect the - attr.Remove (); - var node = Unit.GetNodeAt (location) ?? Unit; - node.AddChild (attr, AttributeSection.AttributeRole); - return Tuple.Create (CSharpParsedFile, (AstNode)attr, Unit); - } - } - if (currentMember == null && currentType == null) { - return null; - } - baseUnit = ParseStub (afterBracket ? "" : "x"); + baseUnit = ParseStub("a", false); - var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; - var mref = baseUnit.GetNodeAt (location.Line, location.Column - 1, n => n is InvocationExpression || n is ObjectCreateExpression); + var section = baseUnit.GetNodeAt(location.Line, location.Column - 2); + var attr = section != null ? section.Attributes.LastOrDefault() : null; + if (attr != null) { + return new ExpressionResult((AstNode)attr, baseUnit); + } + + //var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; + var mref = baseUnit.GetNodeAt(location.Line, location.Column - 1, n => n is InvocationExpression || n is ObjectCreateExpression); AstNode expr = null; if (mref is InvocationExpression) { expr = ((InvocationExpression)mref).Target; } else if (mref is ObjectCreateExpression) { expr = mref; } else { - baseUnit = ParseStub (")};", false); - mref = baseUnit.GetNodeAt (location.Line, location.Column - 1, n => n is InvocationExpression || n is ObjectCreateExpression); + baseUnit = ParseStub(")};", false); + mref = baseUnit.GetNodeAt(location.Line, location.Column - 1, n => n is InvocationExpression || n is ObjectCreateExpression); if (mref is InvocationExpression) { expr = ((InvocationExpression)mref).Target; } else if (mref is ObjectCreateExpression) { expr = mref; } - if (expr == null) - return null; } - var member = Unit.GetNodeAt (memberLocation); - var member2 = baseUnit.GetNodeAt (memberLocation); - member2.Remove (); - member.ReplaceWith (member2); - var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName); - Unit.AcceptVisitor (tsvisitor, null); - return Tuple.Create (tsvisitor.ParsedFile, (AstNode)expr, Unit); + + if (expr == null) { + // work around for missing ';' bug in mcs: + baseUnit = ParseStub("a", true); + + section = baseUnit.GetNodeAt(location.Line, location.Column - 2); + attr = section != null ? section.Attributes.LastOrDefault() : null; + if (attr != null) { + return new ExpressionResult((AstNode)attr, baseUnit); + } + + //var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; + mref = baseUnit.GetNodeAt(location.Line, location.Column - 1, n => n is InvocationExpression || n is ObjectCreateExpression); + expr = null; + if (mref is InvocationExpression) { + expr = ((InvocationExpression)mref).Target; + } else if (mref is ObjectCreateExpression) { + expr = mref; + } + } + + if (expr == null) { + return null; + } + return new ExpressionResult ((AstNode)expr, baseUnit); + } + + public class ExpressionResult + { + public AstNode Node { get; private set; } + public CompilationUnit Unit { get; private set; } + + + public ExpressionResult (AstNode item2, CompilationUnit item3) + { + this.Node = item2; + this.Unit = item3; + } + + public override string ToString () + { + return string.Format ("[ExpressionResult: Node={0}, Unit={1}]", Node, Unit); + } } - protected Tuple ResolveExpression (CSharpParsedFile file, AstNode expr, CompilationUnit unit) + protected Tuple ResolveExpression (ExpressionResult tuple) + { + return ResolveExpression (tuple.Node, tuple.Unit); + } + + protected Tuple ResolveExpression(AstNode expr, CompilationUnit unit) { - if (expr == null) + if (expr == null) { return null; + } AstNode resolveNode; if (expr is Expression || expr is AstType) { resolveNode = expr; @@ -502,20 +756,20 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } else { resolveNode = expr; } - -// var newContent = ProjectContent.UpdateProjectContent (CSharpParsedFile, file); - - var csResolver = new CSharpAstResolver(new CSharpResolver (ctx), unit, CSharpParsedFile); - - var result = csResolver.Resolve (resolveNode); - var state = csResolver.GetResolverStateBefore (resolveNode); - return Tuple.Create (result, state); - } - - protected static void Print (AstNode node) - { - var v = new CSharpOutputVisitor (Console.Out, new CSharpFormattingOptions ()); - node.AcceptVisitor (v, null); + try { + var ctx = CSharpParsedFile.GetResolver(Compilation, location); + var root = expr.AncestorsAndSelf.FirstOrDefault(n => n is EntityDeclaration || n is CompilationUnit); + if (root == null) { + return null; + } + var csResolver = new CSharpAstResolver (ctx, root, CSharpParsedFile); + var result = csResolver.Resolve(resolveNode); + var state = csResolver.GetResolverStateBefore(resolveNode); + return Tuple.Create(result, state); + } catch (Exception e) { + Console.WriteLine(e); + return null; + } } #endregion @@ -532,7 +786,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion public void GetCurrentMembers (int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember) { - var document = engine.document; + //var document = engine.document; var location = engine.location; currentType = null; @@ -562,7 +816,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (!IsInsideType (currentMember, location)) currentMember = null; } - var stack = engine.GetBracketStack (engine.GetMemberTextToCaret ().Item1); + var stack = GetBracketStack (engine.GetMemberTextToCaret ().Item1); if (stack.Count == 0) currentMember = null; } @@ -586,7 +840,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion int startOffset = document.GetOffset (currentType.Region.Begin); int endOffset = document.GetOffset (location); - bool foundEndBracket = false; + //bool foundEndBracket = false; var bracketStack = new Stack (); @@ -640,6 +894,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return bracketStack.Any (t => t == '{'); } } + } } \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs index e0809eb73..76c266244 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs @@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.Semantics; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.CSharp.TypeSystem; +using System.Linq; namespace ICSharpCode.NRefactory.CSharp.Completion { @@ -38,27 +39,31 @@ namespace ICSharpCode.NRefactory.CSharp.Completion { internal IParameterCompletionDataFactory factory; - public CSharpParameterCompletionEngine (IDocument document, IParameterCompletionDataFactory factory, IProjectContent content, CSharpTypeResolveContext ctx, CompilationUnit unit, CSharpParsedFile parsedFile) : base (content, ctx, unit, parsedFile) + public CSharpParameterCompletionEngine(IDocument document, IParameterCompletionDataFactory factory, IProjectContent content, CSharpTypeResolveContext ctx, CompilationUnit unit, CSharpParsedFile parsedFile) : base (content, ctx, unit, parsedFile) { - if (document == null) - throw new ArgumentNullException ("document"); - if (factory == null) - throw new ArgumentNullException ("factory"); + if (document == null) { + throw new ArgumentNullException("document"); + } + if (factory == null) { + throw new ArgumentNullException("factory"); + } this.document = document; this.factory = factory; } - public Tuple GetIndexerBeforeCursor () + public ExpressionResult GetIndexerBeforeCursor() { CompilationUnit baseUnit; - if (currentMember == null && currentType == null) + if (currentMember == null && currentType == null) { return null; - if (Unit == null) + } + if (Unit == null) { return null; - baseUnit = ParseStub ("x] = a[1"); + } + baseUnit = ParseStub("x] = a[1"); - var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; - var mref = baseUnit.GetNodeAt (location, n => n is IndexerExpression); + //var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; + var mref = baseUnit.GetNodeAt(location, n => n is IndexerExpression); AstNode expr; if (mref is IndexerExpression) { expr = ((IndexerExpression)mref).Target; @@ -66,82 +71,138 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return null; } - var member = Unit.GetNodeAt (memberLocation); - var member2 = baseUnit.GetNodeAt (memberLocation); - if (member == null || member2 == null) - return null; - member2.Remove (); - member.ReplaceWith (member2); - var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName); - Unit.AcceptVisitor (tsvisitor, null); - return Tuple.Create (tsvisitor.ParsedFile, (AstNode)expr, Unit); + return new ExpressionResult((AstNode)expr, baseUnit); } - public Tuple GetTypeBeforeCursor () + public ExpressionResult GetConstructorInitializerBeforeCursor() { CompilationUnit baseUnit; - if (currentMember == null && currentType == null) + if (currentMember == null && currentType == null) { return null; - if (Unit == null) + } + if (Unit == null) { return null; - baseUnit = ParseStub ("x> a"); + } + baseUnit = ParseStub("a) {}", false); - var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; - var expr = baseUnit.GetNodeAt (location.Line, location.Column + 1); // '>' position - var member = Unit.GetNodeAt (memberLocation); - var member2 = baseUnit.GetNodeAt (memberLocation); - if (member == null || member2 == null) + var expr = baseUnit.GetNodeAt (location); + if (expr == null) { return null; - member2.Remove (); - member.ReplaceWith (member2); - var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName); - Unit.AcceptVisitor (tsvisitor, null); - return Tuple.Create (tsvisitor.ParsedFile, (AstNode)expr, Unit); + } + return new ExpressionResult((AstNode)expr, baseUnit); } - public IParameterDataProvider GetParameterDataProvider (int offset, char completionChar) + public ExpressionResult GetTypeBeforeCursor() { - if (offset <= 0) + CompilationUnit baseUnit; + if (currentMember == null && currentType == null) { return null; - if (completionChar != '(' && completionChar != '<' && completionChar != '[' && completionChar != ',') + } + if (Unit == null) { return null; + } + baseUnit = ParseStub("x> a"); - SetOffset (offset); - if (IsInsideCommentOrString ()) + //var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; + var expr = baseUnit.GetNodeAt(location.Line, location.Column + 1); + if (expr == null) return null; + // '>' position + return new ExpressionResult((AstNode)expr, baseUnit); + } + + IEnumerable CollectMethods(AstNode resolvedNode, MethodGroupResolveResult resolveResult) + { + // var lookup = new MemberLookup (ctx.CurrentTypeDefinition, Compilation.MainAssembly); + bool onlyStatic = false; + if (resolvedNode is IdentifierExpression && currentMember != null && currentMember.IsStatic) { + onlyStatic = true; + } + foreach (var method in resolveResult.Methods) { + if (method.IsConstructor) { + continue; + } + // if (!lookup.IsAccessible (member, true)) + // continue; + if (onlyStatic && !method.IsStatic) { + continue; + } + yield return method; + } + + foreach (var extMethods in resolveResult.GetExtensionMethods ()) { + foreach (var method in extMethods) { + yield return method; + } + } + } + + public IParameterDataProvider GetParameterDataProvider(int offset, char completionChar) + { + if (offset <= 0) { + return null; + } + if (completionChar != '(' && completionChar != '<' && completionChar != '[' && completionChar != ',') { + return null; + } + SetOffset(offset); + if (IsInsideCommentStringOrDirective()) { + return null; + } + ResolveResult resolveResult; switch (completionChar) { - case '(': - var invoke = GetInvocationBeforeCursor (true) ?? GetIndexerBeforeCursor (); - if (invoke == null) - return null; - if (invoke.Item2 is ObjectCreateExpression) { - var createType = ResolveExpression (invoke.Item1, ((ObjectCreateExpression)invoke.Item2).Type, invoke.Item3); - return factory.CreateConstructorProvider (createType.Item1.Type); - } + case '(': + var invoke = GetInvocationBeforeCursor(true) ?? GetConstructorInitializerBeforeCursor(); + if (invoke == null) { + return null; + } + if (invoke.Node is ConstructorInitializer) { + var init = (ConstructorInitializer)invoke.Node; + if (init.ConstructorInitializerType == ConstructorInitializerType.This) { + return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), ctx.CurrentTypeDefinition); + } else { + var baseType = ctx.CurrentTypeDefinition.DirectBaseTypes.FirstOrDefault(bt => bt.Kind != TypeKind.Interface); + if (baseType == null) { + return null; + } + return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), baseType); + } + } + if (invoke.Node is ObjectCreateExpression) { + var createType = ResolveExpression(((ObjectCreateExpression)invoke.Node).Type, invoke.Unit); + if (createType.Item1.Type.Kind == TypeKind.Unknown) + return null; + return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), createType.Item1.Type); + } - if (invoke.Item2 is ICSharpCode.NRefactory.CSharp.Attribute) { - var attribute = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); - if (attribute == null || attribute.Item1 == null) + if (invoke.Node is ICSharpCode.NRefactory.CSharp.Attribute) { + var attribute = ResolveExpression(invoke); + if (attribute == null || attribute.Item1 == null) { + return null; + } + return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), attribute.Item1.Type); + } + var invocationExpression = ResolveExpression(invoke); + if (invocationExpression == null || invocationExpression.Item1 == null || invocationExpression.Item1.IsError) { return null; - return factory.CreateConstructorProvider (attribute.Item1.Type); - } - var invocationExpression = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); - if (invocationExpression == null || invocationExpression.Item1 == null || invocationExpression.Item1.IsError) - return null; - resolveResult = invocationExpression.Item1; - if (resolveResult is MethodGroupResolveResult) - return factory.CreateMethodDataProvider (resolveResult as MethodGroupResolveResult); - if (resolveResult is MemberResolveResult) { - var mr = resolveResult as MemberResolveResult; - if (mr.Member is IMethod) - return factory.CreateMethodDataProvider ((IMethod)mr.Member); - } + } + resolveResult = invocationExpression.Item1; + if (resolveResult is MethodGroupResolveResult) { + return factory.CreateMethodDataProvider(document.GetOffset(invoke.Node.StartLocation), CollectMethods(invoke.Node, resolveResult as MethodGroupResolveResult)); + } + if (resolveResult is MemberResolveResult) { + var mr = resolveResult as MemberResolveResult; + if (mr.Member is IMethod) { + return factory.CreateMethodDataProvider(document.GetOffset(invoke.Node.StartLocation), new [] { (IMethod)mr.Member }); + } + } - if (resolveResult.Type.Kind == TypeKind.Delegate) - return factory.CreateDelegateDataProvider (resolveResult.Type); + if (resolveResult.Type.Kind == TypeKind.Delegate) { + return factory.CreateDelegateDataProvider(document.GetOffset(invoke.Node.StartLocation), resolveResult.Type); + } // // if (result.ExpressionContext == ExpressionContext.BaseConstructorCall) { @@ -154,250 +215,264 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // if (resolvedType != null && resolvedType.ClassType == ClassType.Delegate) { // return new NRefactoryParameterDataProvider (textEditorData, result.Expression, resolvedType); // } - break; - case ',': - invoke = GetInvocationBeforeCursor (true) ?? GetIndexerBeforeCursor (); - if (invoke == null) { - invoke = GetTypeBeforeCursor (); - if (invoke !=null) { - var typeExpression = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); - if (typeExpression == null || typeExpression.Item1 == null || typeExpression.Item1.IsError) - return null; + break; + case ',': + invoke = GetInvocationBeforeCursor(true) ?? GetIndexerBeforeCursor(); + if (invoke == null) { + invoke = GetTypeBeforeCursor(); + if (invoke != null) { + if (GetCurrentParameterIndex(document.GetOffset(invoke.Node.StartLocation), offset) < 0) + return null; + var typeExpression = ResolveExpression(invoke); + if (typeExpression == null || typeExpression.Item1 == null || typeExpression.Item1.IsError) { + return null; + } - return factory.CreateTypeParameterDataProvider (CollectAllTypes (typeExpression.Item1.Type)); + return factory.CreateTypeParameterDataProvider(document.GetOffset(invoke.Node.StartLocation), CollectAllTypes(typeExpression.Item1.Type)); + } + return null; } - return null; - } - if (invoke.Item2 is ObjectCreateExpression) { - var createType = ResolveExpression (invoke.Item1, ((ObjectCreateExpression)invoke.Item2).Type, invoke.Item3); - return factory.CreateConstructorProvider (createType.Item1.Type); - } - - if (invoke.Item2 is ICSharpCode.NRefactory.CSharp.Attribute) { - var attribute = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); - if (attribute == null || attribute.Item1 == null) + if (GetCurrentParameterIndex(document.GetOffset(invoke.Node.StartLocation), offset) < 0) return null; - return factory.CreateConstructorProvider (attribute.Item1.Type); - } + if (invoke.Node is ObjectCreateExpression) { + var createType = ResolveExpression(((ObjectCreateExpression)invoke.Node).Type, invoke.Unit); + return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), createType.Item1.Type); + } + + if (invoke.Node is ICSharpCode.NRefactory.CSharp.Attribute) { + var attribute = ResolveExpression(invoke); + if (attribute == null || attribute.Item1 == null) { + return null; + } + return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), attribute.Item1.Type); + } - invocationExpression = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); + invocationExpression = ResolveExpression(invoke); - if (invocationExpression == null || invocationExpression.Item1 == null || invocationExpression.Item1.IsError) - return null; + if (invocationExpression == null || invocationExpression.Item1 == null || invocationExpression.Item1.IsError) { + return null; + } - resolveResult = invocationExpression.Item1; - if (resolveResult is MethodGroupResolveResult) - return factory.CreateMethodDataProvider (resolveResult as MethodGroupResolveResult); - if (resolveResult is MemberResolveResult) { - if (resolveResult.Type.Kind == TypeKind.Delegate) - return factory.CreateDelegateDataProvider (resolveResult.Type); - var mr = resolveResult as MemberResolveResult; - if (mr.Member is IMethod) - return factory.CreateMethodDataProvider ((IMethod)mr.Member); - } - if (resolveResult != null) - return factory.CreateIndexerParameterDataProvider (resolveResult.Type, invoke.Item2); - break; - case '<': - invoke = GetTypeBeforeCursor (); - if (invoke == null) - return null; - var tExpr = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); - if (tExpr == null || tExpr.Item1 == null || tExpr.Item1.IsError) - return null; + resolveResult = invocationExpression.Item1; + if (resolveResult is MethodGroupResolveResult) { + return factory.CreateMethodDataProvider(document.GetOffset(invoke.Node.StartLocation), CollectMethods(invoke.Node, resolveResult as MethodGroupResolveResult)); + } + if (resolveResult is MemberResolveResult) { + if (resolveResult.Type.Kind == TypeKind.Delegate) { + return factory.CreateDelegateDataProvider(document.GetOffset(invoke.Node.StartLocation), resolveResult.Type); + } + var mr = resolveResult as MemberResolveResult; + if (mr.Member is IMethod) { + return factory.CreateMethodDataProvider(document.GetOffset(invoke.Node.StartLocation), new [] { (IMethod)mr.Member }); + } + } + if (resolveResult != null) { + return factory.CreateIndexerParameterDataProvider(document.GetOffset(invoke.Node.StartLocation), resolveResult.Type, invoke.Node); + } + break; + case '<': + invoke = GetTypeBeforeCursor(); + if (invoke == null) { + return null; + } + var tExpr = ResolveExpression(invoke); + if (tExpr == null || tExpr.Item1 == null || tExpr.Item1.IsError) { + return null; + } - return factory.CreateTypeParameterDataProvider (CollectAllTypes (tExpr.Item1.Type)); - case '[': - invoke = GetIndexerBeforeCursor (); - if (invoke == null) - return null; - var indexerExpression = ResolveExpression (invoke.Item1, invoke.Item2, invoke.Item3); - if (indexerExpression == null || indexerExpression.Item1 == null || indexerExpression.Item1.IsError) - return null; - return factory.CreateIndexerParameterDataProvider (indexerExpression.Item1.Type, invoke.Item2); + return factory.CreateTypeParameterDataProvider(document.GetOffset(invoke.Node.StartLocation), CollectAllTypes(tExpr.Item1.Type)); + case '[': + invoke = GetIndexerBeforeCursor(); + if (invoke == null) { + return null; + } + var indexerExpression = ResolveExpression(invoke); + if (indexerExpression == null || indexerExpression.Item1 == null || indexerExpression.Item1.IsError) { + return null; + } + return factory.CreateIndexerParameterDataProvider(document.GetOffset(invoke.Node.StartLocation), indexerExpression.Item1.Type, invoke.Node); } return null; } - IEnumerable CollectAllTypes (IType baseType) + IEnumerable CollectAllTypes(IType baseType) { - var state = GetState (); + var state = GetState(); for (var n = state.CurrentUsingScope; n != null; n = n.Parent) { foreach (var u in n.Usings) { foreach (var type in u.Types) { - if (type.TypeParameterCount > 0 && type.Name == baseType.Name) + if (type.TypeParameterCount > 0 && type.Name == baseType.Name) { yield return type; + } } } foreach (var type in n.Namespace.Types) { - if (type.TypeParameterCount > 0 && type.Name == baseType.Name) + if (type.TypeParameterCount > 0 && type.Name == baseType.Name) { yield return type; + } } } } - List GetUsedNamespaces () + List GetUsedNamespaces() { - var scope = CSharpParsedFile.GetUsingScope (location); - var result = new List (); - var resolver = new CSharpResolver (ctx); + var scope = CSharpParsedFile.GetUsingScope(location); + var result = new List(); + var resolver = new CSharpResolver(ctx); while (scope != null) { - result.Add (scope.NamespaceName); + result.Add(scope.NamespaceName); foreach (var u in scope.Usings) { - var ns = u.ResolveNamespace (resolver); - if (ns == null) + var ns = u.ResolveNamespace(resolver); + if (ns == null) { continue; - result.Add (ns.FullName); + } + result.Add(ns.FullName); } scope = scope.Parent; } return result; } - public int GetCurrentParameterIndex (int triggerOffset) + public int GetCurrentParameterIndex(int triggerOffset, int endOffset) { - SetOffset (triggerOffset); - var text = GetMemberTextToCaret (); - if (text.Item1.EndsWith ("(") || text.Item1.EndsWith ("<")) + char lastChar = document.GetCharAt(endOffset - 1); + if (lastChar == '(' || lastChar == '<') { return 0; - var parameter = new Stack (); - + } + var parameter = new Stack(); + var bracketStack = new Stack>(); bool inSingleComment = false, inString = false, inVerbatimString = false, inChar = false, inMultiLineComment = false; - - for (int i = 0; i < text.Item1.Length; i++) { - char ch = text.Item1 [i]; - char nextCh = i + 1 < text.Item1.Length ? text.Item1 [i + 1] : '\0'; - + for (int i = triggerOffset; i < endOffset; i++) { + char ch = document.GetCharAt(i); + char nextCh = i + 1 < document.TextLength ? document.GetCharAt(i + 1) : '\0'; switch (ch) { - case '(': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) + case '{': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + bracketStack.Push(parameter); + parameter = new Stack(); break; - parameter.Push (0); - break; - case ')': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) + case '[': + case '(': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + parameter.Push(0); break; - if (parameter.Count > 0) - parameter.Pop (); - break; - case '<': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) + case '}': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (bracketStack.Count > 0) { + parameter = bracketStack.Pop(); + } else { + return -1; + } break; - parameter.Push (0); - break; - case '>': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) + case ']': + case ')': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (parameter.Count > 0) { + parameter.Pop(); + } else { + return -1; + } break; - if (parameter.Count > 0) - parameter.Pop (); - break; - case ',': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) + case '<': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + parameter.Push(0); break; - if (parameter.Count > 0) - parameter.Push (parameter.Pop () + 1); - break; - case '/': - if (inString || inChar || inVerbatimString) + case '>': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (parameter.Count > 0) { + parameter.Pop(); + } break; - if (nextCh == '/') { - i++; - inSingleComment = true; - } - if (nextCh == '*') - inMultiLineComment = true; - break; - case '*': - if (inString || inChar || inVerbatimString || inSingleComment) + case ',': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (parameter.Count > 0) { + parameter.Push(parameter.Pop() + 1); + } break; - if (nextCh == '/') { - i++; - inMultiLineComment = false; - } - break; - case '@': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) + case '/': + if (inString || inChar || inVerbatimString) { + break; + } + if (nextCh == '/') { + i++; + inSingleComment = true; + } + if (nextCh == '*') { + inMultiLineComment = true; + } break; - if (nextCh == '"') { - i++; - inVerbatimString = true; - } - break; - case '\n': - case '\r': - inSingleComment = false; - inString = false; - inChar = false; - break; - case '\\': - if (inString || inChar) - i++; - break; - case '"': - if (inSingleComment || inMultiLineComment || inChar) + case '*': + if (inString || inChar || inVerbatimString || inSingleComment) { + break; + } + if (nextCh == '/') { + i++; + inMultiLineComment = false; + } break; - if (inVerbatimString) { + case '@': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } if (nextCh == '"') { i++; + inVerbatimString = true; + } + break; + case '\n': + case '\r': + inSingleComment = false; + inString = false; + inChar = false; + break; + case '\\': + if (inString || inChar) { + i++; + } + break; + case '"': + if (inSingleComment || inMultiLineComment || inChar) { + break; + } + if (inVerbatimString) { + if (nextCh == '"') { + i++; + break; + } + inVerbatimString = false; break; } - inVerbatimString = false; + inString = !inString; break; - } - inString = !inString; - break; - case '\'': - if (inSingleComment || inMultiLineComment || inString || inVerbatimString) + case '\'': + if (inSingleComment || inMultiLineComment || inString || inVerbatimString) { + break; + } + inChar = !inChar; break; - inChar = !inChar; - break; } } - if (parameter.Count == 0) + if (parameter.Count == 0 || bracketStack.Count > 0) { return -1; - return parameter.Pop () + 1; - } - - /* - public override bool GetParameterCompletionCommandOffset (out int cpos) - { - // Start calculating the parameter offset from the beginning of the - // current member, instead of the beginning of the file. - cpos = textEditorData.Caret.Offset - 1; - var parsedDocument = Document.ParsedDocument; - if (parsedDocument == null) - return false; - IMember mem = currentMember; - if (mem == null || (mem is IType)) - return false; - int startPos = textEditorData.LocationToOffset (mem.Region.BeginLine, mem.Region.BeginColumn); - int parenDepth = 0; - int chevronDepth = 0; - while (cpos > startPos) { - char c = textEditorData.GetCharAt (cpos); - if (c == ')') - parenDepth++; - if (c == '>') - chevronDepth++; - if (parenDepth == 0 && c == '(' || chevronDepth == 0 && c == '<') { - int p = MethodParameterDataProvider.GetCurrentParameterIndex (CompletionWidget, cpos + 1, startPos); - if (p != -1) { - cpos++; - return true; - } else { - return false; - } - } - if (c == '(') - parenDepth--; - if (c == '<') - chevronDepth--; - cpos--; } - return false; - }*/ + return parameter.Pop() + 1; + } } } diff --git a/ICSharpCode.NRefactory.CSharp/Completion/IParameterCompletionDataFactory.cs b/ICSharpCode.NRefactory.CSharp/Completion/IParameterCompletionDataFactory.cs index bea586049..54ebe1c84 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/IParameterCompletionDataFactory.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/IParameterCompletionDataFactory.cs @@ -33,17 +33,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion { public interface IParameterCompletionDataFactory { - IParameterDataProvider CreateConstructorProvider (IType type); + IParameterDataProvider CreateConstructorProvider (int startOffset, IType type); - IParameterDataProvider CreateMethodDataProvider (MethodGroupResolveResult par1); + IParameterDataProvider CreateMethodDataProvider (int startOffset, IEnumerable methods); - IParameterDataProvider CreateMethodDataProvider (IMethod method); - - IParameterDataProvider CreateDelegateDataProvider (IType type); + IParameterDataProvider CreateDelegateDataProvider (int startOffset, IType type); - IParameterDataProvider CreateIndexerParameterDataProvider (IType type, AstNode resolvedNode); + IParameterDataProvider CreateIndexerParameterDataProvider (int startOffset, IType type, AstNode resolvedNode); - IParameterDataProvider CreateTypeParameterDataProvider (IEnumerable types); + IParameterDataProvider CreateTypeParameterDataProvider (int startOffset, IEnumerable types); } } diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs index d4f7fef6e..a47de8058 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs @@ -1,6 +1,6 @@ -// +// // AstFormattingVisitor.cs -// +// // Author: // Mike Krüger // @@ -24,6 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; +using System.Diagnostics; using System.Text; using System.Collections.Generic; using System.Linq; @@ -33,33 +34,61 @@ using ICSharpCode.NRefactory.CSharp.Refactoring; namespace ICSharpCode.NRefactory.CSharp { - public class AstFormattingVisitor : DepthFirstAstVisitor - { - CSharpFormattingOptions policy; - IDocument document; - IActionFactory factory; - List changes = new List (); - Indent curIndent = new Indent (); + public enum FormattingMode { + OnTheFly, + Intrusive + } - public int IndentLevel { - get { - return curIndent.Level; + public class AstFormattingVisitor : DepthFirstAstVisitor + { + sealed class TextReplaceAction + { + internal readonly int Offset; + internal readonly int RemovalLength; + internal readonly string NewText; + internal TextReplaceAction DependsOn; + +#if DEBUG + internal readonly string StackTrace; +#endif + + public TextReplaceAction (int offset, int removalLength, string newText) + { + this.Offset = offset; + this.RemovalLength = removalLength; + this.NewText = newText ?? string.Empty; + #if DEBUG + this.StackTrace = Environment.StackTrace; + #endif } - set { - curIndent.Level = value; + + public override bool Equals(object obj) + { + TextReplaceAction other = obj as TextReplaceAction; + if (other == null) { + return false; + } + return this.Offset == other.Offset && this.RemovalLength == other.RemovalLength && this.NewText == other.NewText; + } + + public override int GetHashCode() + { + return 0; } - } - - public int CurrentSpaceIndents { - get; - set; - } - public List Changes { - get { return this.changes; } + public override string ToString() + { + return string.Format("[TextReplaceAction: Offset={0}, RemovalLength={1}, NewText={2}]", Offset, RemovalLength, NewText); + } } - - public bool CorrectBlankLines { + + CSharpFormattingOptions policy; + IDocument document; + List changes = new List (); + Indent curIndent; + readonly TextEditorOptions options; + + public FormattingMode FormattingMode { get; set; } @@ -69,206 +98,286 @@ namespace ICSharpCode.NRefactory.CSharp set; } - public string EolMarker { get; set; } - - public AstFormattingVisitor (CSharpFormattingOptions policy, IDocument document, IActionFactory factory, - bool tabsToSpaces = false, int indentationSize = 4) + public AstFormattingVisitor(CSharpFormattingOptions policy, IDocument document, TextEditorOptions options = null) { - if (factory == null) - throw new ArgumentNullException ("factory"); + if (policy == null) { + throw new ArgumentNullException("policy"); + } + if (document == null) { + throw new ArgumentNullException("document"); + } this.policy = policy; this.document = document; - this.curIndent.TabsToSpaces = tabsToSpaces; - this.curIndent.TabSize = indentationSize; - this.factory = factory; - this.EolMarker = Environment.NewLine; - CorrectBlankLines = true; + this.options = options ?? TextEditorOptions.Default; + curIndent = new Indent(this.options); + } + + /// + /// Applies the changes to the input document. + /// + public void ApplyChanges() + { + ApplyChanges(0, document.TextLength, document.Replace, (o, l, v) => document.GetText(o, l) == v); + } + + public void ApplyChanges(int startOffset, int length) + { + ApplyChanges(startOffset, length, document.Replace, (o, l, v) => document.GetText(o, l) == v); + } + + /// + /// Applies the changes to the given Script instance. + /// + public void ApplyChanges(Script script) + { + ApplyChanges(0, document.TextLength, script.Replace); + } + + public void ApplyChanges(int startOffset, int length, Script script) + { + ApplyChanges(startOffset, length, script.Replace); + } + + public void ApplyChanges(int startOffset, int length, Action documentReplace, Func filter = null) + { + int endOffset = startOffset + length; + TextReplaceAction previousChange = null; + int delta = 0; + var depChanges = new List (); + foreach (var change in changes.OrderBy(c => c.Offset)) { + if (previousChange != null) { + if (change.Equals(previousChange)) { + // ignore duplicate changes + continue; + } + if (change.Offset < previousChange.Offset + previousChange.RemovalLength) { + #if DEBUG + Console.WriteLine ("change 1:" + change); + Console.WriteLine (change.StackTrace); + + Console.WriteLine ("change 2:" + change); + Console.WriteLine (previousChange.StackTrace); + #endif + throw new InvalidOperationException ("Detected overlapping changes " + change + "/" + previousChange); + } + } + previousChange = change; + + bool skipChange = change.Offset < startOffset || change.Offset > endOffset; + skipChange |= filter != null && filter(change.Offset + delta, change.RemovalLength, change.NewText); + skipChange &= !depChanges.Contains(change); + + if (!skipChange) { + documentReplace(change.Offset + delta, change.RemovalLength, change.NewText); + delta += change.NewText.Length - change.RemovalLength; + if (change.DependsOn != null) { + depChanges.Add(change.DependsOn); + } + } + } + changes.Clear(); } - public override object VisitCompilationUnit (CompilationUnit unit, object data) + public override void VisitCompilationUnit(CompilationUnit unit) { - base.VisitCompilationUnit (unit, data); - return null; + base.VisitCompilationUnit(unit); } - public void EnsureBlankLinesAfter (AstNode node, int blankLines) + public void EnsureBlankLinesAfter(AstNode node, int blankLines) { - if (!CorrectBlankLines) + if (FormattingMode != FormattingMode.Intrusive) return; var loc = node.EndLocation; int line = loc.Line; do { line++; } while (line < document.LineCount && IsSpacing(document.GetLineByNumber(line))); - var start = document.GetOffset (node.EndLocation); + var start = document.GetOffset(node.EndLocation); int foundBlankLines = line - loc.Line - 1; - StringBuilder sb = new StringBuilder (); - for (int i = 0; i < blankLines - foundBlankLines; i++) - sb.Append (this.EolMarker); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < blankLines - foundBlankLines; i++) { + sb.Append(this.options.EolMarker); + } int ws = start; - while (ws < document.TextLength && IsSpacing (document.GetCharAt (ws))) + while (ws < document.TextLength && IsSpacing (document.GetCharAt (ws))) { ws++; + } int removedChars = ws - start; if (foundBlankLines > blankLines) { - removedChars += document.GetLineByNumber (loc.Line + foundBlankLines - blankLines).EndOffset - - document.GetLineByNumber (loc.Line).EndOffset; + removedChars += document.GetLineByNumber(loc.Line + foundBlankLines - blankLines).EndOffset + - document.GetLineByNumber(loc.Line).EndOffset; } - AddChange (start, removedChars, sb.ToString ()); + AddChange(start, removedChars, sb.ToString()); } - public void EnsureBlankLinesBefore (AstNode node, int blankLines) + public void EnsureBlankLinesBefore(AstNode node, int blankLines) { - if (!CorrectBlankLines) + if (FormattingMode != FormattingMode.Intrusive) return; var loc = node.StartLocation; int line = loc.Line; do { line--; } while (line > 0 && IsSpacing(document.GetLineByNumber(line))); - int end = document.GetOffset (loc.Line, 1); - int start = document.GetOffset (line + 1, 1); + int end = document.GetOffset(loc.Line, 1); + int start = document.GetOffset(line + 1, 1); StringBuilder sb = new StringBuilder (); - for (int i = 0; i < blankLines; i++) - sb.Append (this.EolMarker); - AddChange (start, end - start, sb.ToString ()); + for (int i = 0; i < blankLines; i++) { + sb.Append(this.options.EolMarker); + } + AddChange(start, end - start, sb.ToString()); } - public override object VisitUsingDeclaration (UsingDeclaration usingDeclaration, object data) + public override void VisitUsingDeclaration(UsingDeclaration usingDeclaration) { - 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; + 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); + } } - public override object VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration, object data) + public override void VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration) { - 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; + 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); + } } - public override object VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, object data) + public override void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration) { - var firstNsMember = namespaceDeclaration.Members.FirstOrDefault (); - if (firstNsMember != null) - EnsureBlankLinesBefore (firstNsMember, policy.BlankLinesBeforeFirstDeclaration); - FixIndentationForceNewLine (namespaceDeclaration.StartLocation); - EnforceBraceStyle (policy.NamespaceBraceStyle, namespaceDeclaration.LBraceToken, namespaceDeclaration.RBraceToken); - if (policy.IndentNamespaceBody) - IndentLevel++; - object result = base.VisitNamespaceDeclaration (namespaceDeclaration, data); - if (policy.IndentNamespaceBody) - IndentLevel--; - FixIndentation (namespaceDeclaration.RBraceToken.StartLocation); - return result; + var firstNsMember = namespaceDeclaration.Members.FirstOrDefault(); + if (firstNsMember != null) { + EnsureBlankLinesBefore(firstNsMember, policy.BlankLinesBeforeFirstDeclaration); + } + FixIndentationForceNewLine(namespaceDeclaration.StartLocation); + EnforceBraceStyle(policy.NamespaceBraceStyle, namespaceDeclaration.LBraceToken, namespaceDeclaration.RBraceToken); + if (policy.IndentNamespaceBody) { + curIndent.Push(IndentType.Block); + } + base.VisitNamespaceDeclaration(namespaceDeclaration); + if (policy.IndentNamespaceBody) { + curIndent.Pop (); + } + FixIndentation(namespaceDeclaration.RBraceToken.StartLocation); } - public override object VisitTypeDeclaration (TypeDeclaration typeDeclaration, object data) + public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration) { - FormatAttributedNode (typeDeclaration); + FormatAttributedNode(typeDeclaration); BraceStyle braceStyle; bool indentBody = false; switch (typeDeclaration.ClassType) { - case ClassType.Class: - braceStyle = policy.ClassBraceStyle; - indentBody = policy.IndentClassBody; - break; - case ClassType.Struct: - braceStyle = policy.StructBraceStyle; - indentBody = policy.IndentStructBody; - break; - case ClassType.Interface: - braceStyle = policy.InterfaceBraceStyle; - indentBody = policy.IndentInterfaceBody; - break; - case ClassType.Enum: - braceStyle = policy.EnumBraceStyle; - indentBody = policy.IndentEnumBody; - break; - default: - throw new InvalidOperationException ("unsupported class type : " + typeDeclaration.ClassType); - } - EnforceBraceStyle (braceStyle, typeDeclaration.LBraceToken, typeDeclaration.RBraceToken); + case ClassType.Class: + braceStyle = policy.ClassBraceStyle; + indentBody = policy.IndentClassBody; + break; + case ClassType.Struct: + braceStyle = policy.StructBraceStyle; + indentBody = policy.IndentStructBody; + break; + case ClassType.Interface: + braceStyle = policy.InterfaceBraceStyle; + indentBody = policy.IndentInterfaceBody; + break; + case ClassType.Enum: + braceStyle = policy.EnumBraceStyle; + indentBody = policy.IndentEnumBody; + break; + default: + throw new InvalidOperationException("unsupported class type : " + typeDeclaration.ClassType); + } + + EnforceBraceStyle(braceStyle, typeDeclaration.LBraceToken, typeDeclaration.RBraceToken); - if (indentBody) - IndentLevel++; - object result = base.VisitTypeDeclaration (typeDeclaration, data); - if (indentBody) - IndentLevel--; + if (indentBody) { + curIndent.Push(IndentType.Block); + } + base.VisitTypeDeclaration(typeDeclaration); + if (indentBody) { + curIndent.Pop (); + } - if (typeDeclaration.NextSibling is TypeDeclaration || typeDeclaration.NextSibling is DelegateDeclaration) - EnsureBlankLinesAfter (typeDeclaration, policy.BlankLinesBetweenTypes); - return result; + if (typeDeclaration.NextSibling is TypeDeclaration || typeDeclaration.NextSibling is DelegateDeclaration) { + EnsureBlankLinesAfter(typeDeclaration, policy.BlankLinesBetweenTypes); + } + } - bool IsSimpleAccessor (Accessor accessor) + bool IsSimpleAccessor(Accessor accessor) { - if (accessor.IsNull || accessor.Body.IsNull || accessor.Body.FirstChild == null) + if (accessor.IsNull || accessor.Body.IsNull || accessor.Body.FirstChild == null) { return true; - if (accessor.Body.Statements.Count () != 1) + } + if (accessor.Body.Statements.Count() != 1) { return false; - return !(accessor.Body.Statements.FirstOrDefault () is BlockStatement); + } + return !(accessor.Body.Statements.FirstOrDefault() is BlockStatement); } - bool IsSpacing (char ch) + bool IsSpacing(char ch) { return ch == ' ' || ch == '\t'; } - bool IsSpacing (ISegment segment) + bool IsSpacing(ISegment segment) { int endOffset = segment.EndOffset; for (int i = segment.Offset; i < endOffset; i++) { - if (!IsSpacing(document.GetCharAt(i))) + if (!IsSpacing(document.GetCharAt(i))) { return false; + } } return true; } - int SearchLastNonWsChar (int startOffset, int endOffset) + int SearchLastNonWsChar(int startOffset, int endOffset) { - startOffset = System.Math.Max (0, startOffset); - endOffset = System.Math.Max (startOffset, endOffset); - if (startOffset >= endOffset) + startOffset = System.Math.Max(0, startOffset); + endOffset = System.Math.Max(startOffset, endOffset); + if (startOffset >= endOffset) { return startOffset; + } int result = -1; bool inComment = false; for (int i = startOffset; i < endOffset && i < document.TextLength; i++) { - char ch = document.GetCharAt (i); - if (IsSpacing (ch)) + char ch = document.GetCharAt(i); + if (IsSpacing(ch)) { continue; - if (ch == '/' && i + 1 < document.TextLength && document.GetCharAt (i + 1) == '/') + } + if (ch == '/' && i + 1 < document.TextLength && document.GetCharAt(i + 1) == '/') { return result; - if (ch == '/' && i + 1 < document.TextLength && document.GetCharAt (i + 1) == '*') { + } + if (ch == '/' && i + 1 < document.TextLength && document.GetCharAt(i + 1) == '*') { inComment = true; i++; continue; } - if (inComment && ch == '*' && i + 1 < document.TextLength && document.GetCharAt (i + 1) == '/') { + if (inComment && ch == '*' && i + 1 < document.TextLength && document.GetCharAt(i + 1) == '/') { inComment = false; i++; continue; } - if (!inComment) + if (!inComment) { result = i; + } } return result; } - void ForceSpace (int startOffset, int endOffset, bool forceSpace) + void ForceSpace(int startOffset, int endOffset, bool forceSpace) { - int lastNonWs = SearchLastNonWsChar (startOffset, endOffset); - AddChange (lastNonWs + 1, System.Math.Max (0, endOffset - lastNonWs - 1), forceSpace ? " " : ""); + int lastNonWs = SearchLastNonWsChar(startOffset, endOffset); + AddChange(lastNonWs + 1, System.Math.Max(0, endOffset - lastNonWs - 1), forceSpace ? " " : ""); } // void ForceSpacesAfter (AstNode n, bool forceSpaces) // { @@ -283,19 +392,21 @@ namespace ICSharpCode.NRefactory.CSharp // ForceSpace (offset - 1, i, forceSpaces); // } - void ForceSpacesAfter (AstNode n, bool forceSpaces) + void ForceSpacesAfter(AstNode n, bool forceSpaces) { - if (n == null) + if (n == null) { return; + } TextLocation location = n.EndLocation; - int offset = document.GetOffset (location); - if (location.Column > document.GetLineByNumber (location.Line).Length) + int offset = document.GetOffset(location); + if (location.Column > document.GetLineByNumber(location.Line).Length) { return; + } int i = offset; while (i < document.TextLength && IsSpacing (document.GetCharAt (i))) { i++; } - ForceSpace (offset - 1, i, forceSpaces); + ForceSpace(offset - 1, i, forceSpaces); } // int ForceSpacesBefore (AstNode n, bool forceSpaces) @@ -303,10 +414,10 @@ namespace ICSharpCode.NRefactory.CSharp // if (n == null || n.IsNull) // return 0; // AstLocation location = n.StartLocation; -// +// // int offset = data.LocationToOffset (location.Line, location.Column); // int i = offset - 1; -// +// // while (i >= 0 && IsSpacing (data.GetCharAt (i))) { // i--; // } @@ -314,741 +425,811 @@ namespace ICSharpCode.NRefactory.CSharp // return i; // } - int ForceSpacesBefore (AstNode n, bool forceSpaces) + int ForceSpacesBefore(AstNode n, bool forceSpaces) { - if (n == null || n.IsNull) + if (n == null || n.IsNull) { return 0; + } TextLocation location = n.StartLocation; // respect manual line breaks. - if (location.Column <= 1 || GetIndentation (location.Line).Length == location.Column - 1) + if (location.Column <= 1 || GetIndentation(location.Line).Length == location.Column - 1) { return 0; - - int offset = document.GetOffset (location); + } + + int offset = document.GetOffset(location); int i = offset - 1; while (i >= 0 && IsSpacing (document.GetCharAt (i))) { i--; } - ForceSpace (i, offset, forceSpaces); + ForceSpace(i, offset, forceSpaces); return i; } - public override object VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, object data) + int ForceSpacesBeforeRemoveNewLines(AstNode n) { - FormatAttributedNode (propertyDeclaration); + if (n == null || n.IsNull) { + return 0; + } + int offset = document.GetOffset(n.StartLocation); + int i = offset - 1; + while (i >= 0) { + char ch = document.GetCharAt(i); + if (!IsSpacing(ch) && ch != '\r' && ch != '\n') + break; + i--; + } + var length = System.Math.Max(0, (offset - 1) - i); + AddChange(i + 1, length, " "); + return i; + } + + public override void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) + { + FormatAttributedNode(propertyDeclaration); bool oneLine = false; switch (policy.PropertyFormatting) { - case PropertyFormatting.AllowOneLine: - bool isSimple = IsSimpleAccessor (propertyDeclaration.Getter) && IsSimpleAccessor (propertyDeclaration.Setter); - if (!isSimple || propertyDeclaration.LBraceToken.StartLocation.Line != propertyDeclaration.RBraceToken.StartLocation.Line) { - EnforceBraceStyle (policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); - } else { - ForceSpacesBefore (propertyDeclaration.Getter, true); - ForceSpacesBefore (propertyDeclaration.Setter, true); - ForceSpacesBefore (propertyDeclaration.RBraceToken, true); - oneLine = true; - } - break; - case PropertyFormatting.ForceNewLine: - EnforceBraceStyle (policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); - break; - case PropertyFormatting.ForceOneLine: - isSimple = IsSimpleAccessor (propertyDeclaration.Getter) && IsSimpleAccessor (propertyDeclaration.Setter); - if (isSimple) { - int offset = this.document.GetOffset (propertyDeclaration.LBraceToken.StartLocation); + case PropertyFormatting.AllowOneLine: + bool isSimple = IsSimpleAccessor(propertyDeclaration.Getter) && IsSimpleAccessor(propertyDeclaration.Setter); + if (!isSimple || propertyDeclaration.LBraceToken.StartLocation.Line != propertyDeclaration.RBraceToken.StartLocation.Line) { + EnforceBraceStyle(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); + } else { + ForceSpacesBefore(propertyDeclaration.Getter, true); + ForceSpacesBefore(propertyDeclaration.Setter, true); + ForceSpacesBefore(propertyDeclaration.RBraceToken, true); + oneLine = true; + } + break; + case PropertyFormatting.ForceNewLine: + EnforceBraceStyle(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); + break; + case PropertyFormatting.ForceOneLine: + isSimple = IsSimpleAccessor(propertyDeclaration.Getter) && IsSimpleAccessor(propertyDeclaration.Setter); + if (isSimple) { + int offset = this.document.GetOffset(propertyDeclaration.LBraceToken.StartLocation); - int start = SearchWhitespaceStart (offset); - int end = SearchWhitespaceEnd (offset); - AddChange (start, offset - start, " "); - AddChange (offset + 1, end - offset - 2, " "); + int start = SearchWhitespaceStart(offset); + int end = SearchWhitespaceEnd(offset); + AddChange(start, offset - start, " "); + AddChange(offset + 1, end - offset - 2, " "); - offset = this.document.GetOffset (propertyDeclaration.RBraceToken.StartLocation); - start = SearchWhitespaceStart (offset); - AddChange (start, offset - start, " "); - oneLine = true; + offset = this.document.GetOffset(propertyDeclaration.RBraceToken.StartLocation); + start = SearchWhitespaceStart(offset); + AddChange(start, offset - start, " "); + oneLine = true; - } else { - EnforceBraceStyle (policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); - } - break; + } else { + EnforceBraceStyle(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); + } + break; + } + if (policy.IndentPropertyBody) { + curIndent.Push(IndentType.Block); } - if (policy.IndentPropertyBody) - IndentLevel++; ///System.Console.WriteLine ("one line: " + oneLine); if (!propertyDeclaration.Getter.IsNull) { if (!oneLine) { - if (!IsLineIsEmptyUpToEol (propertyDeclaration.Getter.StartLocation)) { - int offset = this.document.GetOffset (propertyDeclaration.Getter.StartLocation); - int start = SearchWhitespaceStart (offset); + if (!IsLineIsEmptyUpToEol(propertyDeclaration.Getter.StartLocation)) { + int offset = this.document.GetOffset(propertyDeclaration.Getter.StartLocation); + int start = SearchWhitespaceStart(offset); string indentString = this.curIndent.IndentString; - AddChange (start, offset - start, this.EolMarker + indentString); + AddChange(start, offset - start, this.options.EolMarker + indentString); } else { - FixIndentation (propertyDeclaration.Getter.StartLocation); + FixIndentation(propertyDeclaration.Getter.StartLocation); } } else { - int offset = this.document.GetOffset (propertyDeclaration.Getter.StartLocation); - int start = SearchWhitespaceStart (offset); - AddChange (start, offset - start, " "); + int offset = this.document.GetOffset(propertyDeclaration.Getter.StartLocation); + int start = SearchWhitespaceStart(offset); + AddChange(start, offset - start, " "); - ForceSpacesBefore (propertyDeclaration.Getter.Body.LBraceToken, true); - ForceSpacesBefore (propertyDeclaration.Getter.Body.RBraceToken, true); + ForceSpacesBefore(propertyDeclaration.Getter.Body.LBraceToken, true); + ForceSpacesBefore(propertyDeclaration.Getter.Body.RBraceToken, true); } if (!propertyDeclaration.Getter.Body.IsNull) { if (!policy.AllowPropertyGetBlockInline || propertyDeclaration.Getter.Body.LBraceToken.StartLocation.Line != propertyDeclaration.Getter.Body.RBraceToken.StartLocation.Line) { - EnforceBraceStyle (policy.PropertyGetBraceStyle, propertyDeclaration.Getter.Body.LBraceToken, propertyDeclaration.Getter.Body.RBraceToken); + EnforceBraceStyle(policy.PropertyGetBraceStyle, propertyDeclaration.Getter.Body.LBraceToken, propertyDeclaration.Getter.Body.RBraceToken); } else { nextStatementIndent = " "; } - VisitBlockWithoutFixIndentation (propertyDeclaration.Getter.Body, policy.IndentBlocks, data); + VisitBlockWithoutFixingBraces(propertyDeclaration.Getter.Body, policy.IndentBlocks); } } if (!propertyDeclaration.Setter.IsNull) { if (!oneLine) { - if (!IsLineIsEmptyUpToEol (propertyDeclaration.Setter.StartLocation)) { - int offset = this.document.GetOffset (propertyDeclaration.Setter.StartLocation); - int start = SearchWhitespaceStart (offset); + if (!IsLineIsEmptyUpToEol(propertyDeclaration.Setter.StartLocation)) { + int offset = this.document.GetOffset(propertyDeclaration.Setter.StartLocation); + int start = SearchWhitespaceStart(offset); string indentString = this.curIndent.IndentString; - AddChange (start, offset - start, this.EolMarker + indentString); + AddChange(start, offset - start, this.options.EolMarker + indentString); } else { - FixIndentation (propertyDeclaration.Setter.StartLocation); + FixIndentation(propertyDeclaration.Setter.StartLocation); } } else { - int offset = this.document.GetOffset (propertyDeclaration.Setter.StartLocation); - int start = SearchWhitespaceStart (offset); - AddChange (start, offset - start, " "); + int offset = this.document.GetOffset(propertyDeclaration.Setter.StartLocation); + int start = SearchWhitespaceStart(offset); + AddChange(start, offset - start, " "); - ForceSpacesBefore (propertyDeclaration.Setter.Body.LBraceToken, true); - ForceSpacesBefore (propertyDeclaration.Setter.Body.RBraceToken, true); + ForceSpacesBefore(propertyDeclaration.Setter.Body.LBraceToken, true); + ForceSpacesBefore(propertyDeclaration.Setter.Body.RBraceToken, true); } if (!propertyDeclaration.Setter.Body.IsNull) { if (!policy.AllowPropertySetBlockInline || propertyDeclaration.Setter.Body.LBraceToken.StartLocation.Line != propertyDeclaration.Setter.Body.RBraceToken.StartLocation.Line) { - EnforceBraceStyle (policy.PropertySetBraceStyle, propertyDeclaration.Setter.Body.LBraceToken, propertyDeclaration.Setter.Body.RBraceToken); + EnforceBraceStyle(policy.PropertySetBraceStyle, propertyDeclaration.Setter.Body.LBraceToken, propertyDeclaration.Setter.Body.RBraceToken); } else { nextStatementIndent = " "; } - VisitBlockWithoutFixIndentation (propertyDeclaration.Setter.Body, policy.IndentBlocks, data); + VisitBlockWithoutFixingBraces(propertyDeclaration.Setter.Body, policy.IndentBlocks); } } - if (policy.IndentPropertyBody) - IndentLevel--; - if (IsMember (propertyDeclaration.NextSibling)) - EnsureBlankLinesAfter (propertyDeclaration, policy.BlankLinesBetweenMembers); - return null; + if (policy.IndentPropertyBody) { + curIndent.Pop (); + } + if (IsMember(propertyDeclaration.NextSibling)) { + EnsureBlankLinesAfter(propertyDeclaration, policy.BlankLinesBetweenMembers); + } } - public override object VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, object data) + public override void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration) { - ForceSpacesBefore (indexerDeclaration.LBracketToken, policy.SpaceBeforeIndexerDeclarationBracket); - ForceSpacesAfter (indexerDeclaration.LBracketToken, policy.SpaceWithinIndexerDeclarationBracket); - ForceSpacesBefore (indexerDeclaration.RBracketToken, policy.SpaceWithinIndexerDeclarationBracket); + ForceSpacesBefore(indexerDeclaration.LBracketToken, policy.SpaceBeforeIndexerDeclarationBracket); + ForceSpacesAfter(indexerDeclaration.LBracketToken, policy.SpaceWithinIndexerDeclarationBracket); + ForceSpacesBefore(indexerDeclaration.RBracketToken, policy.SpaceWithinIndexerDeclarationBracket); - FormatCommas (indexerDeclaration, policy.SpaceBeforeIndexerDeclarationParameterComma, policy.SpaceAfterIndexerDeclarationParameterComma); + FormatCommas(indexerDeclaration, policy.SpaceBeforeIndexerDeclarationParameterComma, policy.SpaceAfterIndexerDeclarationParameterComma); - FormatAttributedNode (indexerDeclaration); - EnforceBraceStyle (policy.PropertyBraceStyle, indexerDeclaration.LBraceToken, indexerDeclaration.RBraceToken); - if (policy.IndentPropertyBody) - IndentLevel++; + FormatAttributedNode(indexerDeclaration); + EnforceBraceStyle(policy.PropertyBraceStyle, indexerDeclaration.LBraceToken, indexerDeclaration.RBraceToken); + if (policy.IndentPropertyBody) { + curIndent.Push(IndentType.Block); + } if (!indexerDeclaration.Getter.IsNull) { - FixIndentation (indexerDeclaration.Getter.StartLocation); + FixIndentation(indexerDeclaration.Getter.StartLocation); if (!indexerDeclaration.Getter.Body.IsNull) { if (!policy.AllowPropertyGetBlockInline || indexerDeclaration.Getter.Body.LBraceToken.StartLocation.Line != indexerDeclaration.Getter.Body.RBraceToken.StartLocation.Line) { - EnforceBraceStyle (policy.PropertyGetBraceStyle, indexerDeclaration.Getter.Body.LBraceToken, indexerDeclaration.Getter.Body.RBraceToken); + EnforceBraceStyle(policy.PropertyGetBraceStyle, indexerDeclaration.Getter.Body.LBraceToken, indexerDeclaration.Getter.Body.RBraceToken); } else { nextStatementIndent = " "; } - VisitBlockWithoutFixIndentation (indexerDeclaration.Getter.Body, policy.IndentBlocks, data); + VisitBlockWithoutFixingBraces(indexerDeclaration.Getter.Body, policy.IndentBlocks); } } if (!indexerDeclaration.Setter.IsNull) { - FixIndentation (indexerDeclaration.Setter.StartLocation); + FixIndentation(indexerDeclaration.Setter.StartLocation); if (!indexerDeclaration.Setter.Body.IsNull) { if (!policy.AllowPropertySetBlockInline || indexerDeclaration.Setter.Body.LBraceToken.StartLocation.Line != indexerDeclaration.Setter.Body.RBraceToken.StartLocation.Line) { - EnforceBraceStyle (policy.PropertySetBraceStyle, indexerDeclaration.Setter.Body.LBraceToken, indexerDeclaration.Setter.Body.RBraceToken); + EnforceBraceStyle(policy.PropertySetBraceStyle, indexerDeclaration.Setter.Body.LBraceToken, indexerDeclaration.Setter.Body.RBraceToken); } else { nextStatementIndent = " "; } - VisitBlockWithoutFixIndentation (indexerDeclaration.Setter.Body, policy.IndentBlocks, data); + VisitBlockWithoutFixingBraces(indexerDeclaration.Setter.Body, policy.IndentBlocks); } } - if (policy.IndentPropertyBody) - IndentLevel--; - if (IsMember (indexerDeclaration.NextSibling)) - EnsureBlankLinesAfter (indexerDeclaration, policy.BlankLinesBetweenMembers); - return null; + if (policy.IndentPropertyBody) { + curIndent.Pop (); + } + if (IsMember(indexerDeclaration.NextSibling)) { + EnsureBlankLinesAfter(indexerDeclaration, policy.BlankLinesBetweenMembers); + } } - static bool IsSimpleEvent (AstNode node) + static bool IsSimpleEvent(AstNode node) { return node is EventDeclaration; } - public override object VisitCustomEventDeclaration (CustomEventDeclaration eventDeclaration, object data) + public override void VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration) { - FormatAttributedNode (eventDeclaration); - EnforceBraceStyle (policy.EventBraceStyle, eventDeclaration.LBraceToken, eventDeclaration.RBraceToken); - if (policy.IndentEventBody) - IndentLevel++; + FormatAttributedNode(eventDeclaration); + EnforceBraceStyle(policy.EventBraceStyle, eventDeclaration.LBraceToken, eventDeclaration.RBraceToken); + if (policy.IndentEventBody) { + curIndent.Push(IndentType.Block); + } if (!eventDeclaration.AddAccessor.IsNull) { - FixIndentation (eventDeclaration.AddAccessor.StartLocation); + FixIndentation(eventDeclaration.AddAccessor.StartLocation); if (!eventDeclaration.AddAccessor.Body.IsNull) { if (!policy.AllowEventAddBlockInline || eventDeclaration.AddAccessor.Body.LBraceToken.StartLocation.Line != eventDeclaration.AddAccessor.Body.RBraceToken.StartLocation.Line) { - EnforceBraceStyle (policy.EventAddBraceStyle, eventDeclaration.AddAccessor.Body.LBraceToken, eventDeclaration.AddAccessor.Body.RBraceToken); + EnforceBraceStyle(policy.EventAddBraceStyle, eventDeclaration.AddAccessor.Body.LBraceToken, eventDeclaration.AddAccessor.Body.RBraceToken); } else { nextStatementIndent = " "; } - VisitBlockWithoutFixIndentation (eventDeclaration.AddAccessor.Body, policy.IndentBlocks, data); + VisitBlockWithoutFixingBraces(eventDeclaration.AddAccessor.Body, policy.IndentBlocks); } } if (!eventDeclaration.RemoveAccessor.IsNull) { - FixIndentation (eventDeclaration.RemoveAccessor.StartLocation); + FixIndentation(eventDeclaration.RemoveAccessor.StartLocation); if (!eventDeclaration.RemoveAccessor.Body.IsNull) { if (!policy.AllowEventRemoveBlockInline || eventDeclaration.RemoveAccessor.Body.LBraceToken.StartLocation.Line != eventDeclaration.RemoveAccessor.Body.RBraceToken.StartLocation.Line) { - EnforceBraceStyle (policy.EventRemoveBraceStyle, eventDeclaration.RemoveAccessor.Body.LBraceToken, eventDeclaration.RemoveAccessor.Body.RBraceToken); + EnforceBraceStyle(policy.EventRemoveBraceStyle, eventDeclaration.RemoveAccessor.Body.LBraceToken, eventDeclaration.RemoveAccessor.Body.RBraceToken); } else { nextStatementIndent = " "; } - VisitBlockWithoutFixIndentation (eventDeclaration.RemoveAccessor.Body, policy.IndentBlocks, data); + VisitBlockWithoutFixingBraces(eventDeclaration.RemoveAccessor.Body, policy.IndentBlocks); } } - if (policy.IndentEventBody) - IndentLevel--; + if (policy.IndentEventBody) { + curIndent.Pop (); + } - if (eventDeclaration.NextSibling is EventDeclaration && IsSimpleEvent (eventDeclaration) && IsSimpleEvent (eventDeclaration.NextSibling)) { - EnsureBlankLinesAfter (eventDeclaration, policy.BlankLinesBetweenEventFields); - } else if (IsMember (eventDeclaration.NextSibling)) { - EnsureBlankLinesAfter (eventDeclaration, policy.BlankLinesBetweenMembers); + if (eventDeclaration.NextSibling is EventDeclaration && IsSimpleEvent(eventDeclaration) && IsSimpleEvent(eventDeclaration.NextSibling)) { + EnsureBlankLinesAfter(eventDeclaration, policy.BlankLinesBetweenEventFields); + } else if (IsMember(eventDeclaration.NextSibling)) { + EnsureBlankLinesAfter(eventDeclaration, policy.BlankLinesBetweenMembers); } - return null; } - public override object VisitEventDeclaration (EventDeclaration eventDeclaration, object data) + public override void VisitEventDeclaration(EventDeclaration eventDeclaration) { - FormatAttributedNode (eventDeclaration); - if (eventDeclaration.NextSibling is EventDeclaration && IsSimpleEvent (eventDeclaration) && IsSimpleEvent (eventDeclaration.NextSibling)) { - EnsureBlankLinesAfter (eventDeclaration, policy.BlankLinesBetweenEventFields); - } else if (IsMember (eventDeclaration.NextSibling)) { - EnsureBlankLinesAfter (eventDeclaration, policy.BlankLinesBetweenMembers); + FormatAttributedNode(eventDeclaration); + if (eventDeclaration.NextSibling is EventDeclaration && IsSimpleEvent(eventDeclaration) && IsSimpleEvent(eventDeclaration.NextSibling)) { + EnsureBlankLinesAfter(eventDeclaration, policy.BlankLinesBetweenEventFields); + } else if (IsMember(eventDeclaration.NextSibling)) { + EnsureBlankLinesAfter(eventDeclaration, policy.BlankLinesBetweenMembers); } - return null; + + var lastLoc = eventDeclaration.StartLocation; + curIndent.Push(IndentType.Block); + foreach (var initializer in eventDeclaration.Variables) { + if (lastLoc.Line != initializer.StartLocation.Line) { + FixStatementIndentation(initializer.StartLocation); + lastLoc = initializer.StartLocation; + } + initializer.AcceptVisitor(this); + } + curIndent.Pop (); } - public override object VisitAccessor (Accessor accessor, object data) + public override void VisitAccessor(Accessor accessor) { - FixIndentationForceNewLine (accessor.StartLocation); - object result = base.VisitAccessor (accessor, data); - return result; + FixIndentationForceNewLine(accessor.StartLocation); + base.VisitAccessor(accessor); } - public override object VisitFieldDeclaration (FieldDeclaration fieldDeclaration, object data) + public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration) { - FormatAttributedNode (fieldDeclaration); - FormatCommas (fieldDeclaration, policy.SpaceBeforeFieldDeclarationComma, policy.SpaceAfterFieldDeclarationComma); + FormatAttributedNode(fieldDeclaration); + fieldDeclaration.ReturnType.AcceptVisitor(this); + FormatCommas(fieldDeclaration, policy.SpaceBeforeFieldDeclarationComma, policy.SpaceAfterFieldDeclarationComma); if (fieldDeclaration.NextSibling is FieldDeclaration || fieldDeclaration.NextSibling is FixedFieldDeclaration) { - EnsureBlankLinesAfter (fieldDeclaration, policy.BlankLinesBetweenFields); - } else if (IsMember (fieldDeclaration.NextSibling)) { - EnsureBlankLinesAfter (fieldDeclaration, policy.BlankLinesBetweenMembers); + EnsureBlankLinesAfter(fieldDeclaration, policy.BlankLinesBetweenFields); + } else if (IsMember(fieldDeclaration.NextSibling)) { + EnsureBlankLinesAfter(fieldDeclaration, policy.BlankLinesBetweenMembers); + } + + var lastLoc = fieldDeclaration.StartLocation; + curIndent.Push(IndentType.Block); + foreach (var initializer in fieldDeclaration.Variables) { + if (lastLoc.Line != initializer.StartLocation.Line) { + FixStatementIndentation(initializer.StartLocation); + lastLoc = initializer.StartLocation; + } + initializer.AcceptVisitor(this); } - return base.VisitFieldDeclaration (fieldDeclaration, data); + curIndent.Pop (); } - public override object VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, object data) + public override void VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration) { - FormatAttributedNode (fixedFieldDeclaration); - FormatCommas (fixedFieldDeclaration, policy.SpaceBeforeFieldDeclarationComma, policy.SpaceAfterFieldDeclarationComma); + FormatAttributedNode(fixedFieldDeclaration); + FormatCommas(fixedFieldDeclaration, policy.SpaceBeforeFieldDeclarationComma, policy.SpaceAfterFieldDeclarationComma); if (fixedFieldDeclaration.NextSibling is FieldDeclaration || fixedFieldDeclaration.NextSibling is FixedFieldDeclaration) { - EnsureBlankLinesAfter (fixedFieldDeclaration, policy.BlankLinesBetweenFields); - } else if (IsMember (fixedFieldDeclaration.NextSibling)) { - EnsureBlankLinesAfter (fixedFieldDeclaration, policy.BlankLinesBetweenMembers); + EnsureBlankLinesAfter(fixedFieldDeclaration, policy.BlankLinesBetweenFields); + } else if (IsMember(fixedFieldDeclaration.NextSibling)) { + EnsureBlankLinesAfter(fixedFieldDeclaration, policy.BlankLinesBetweenMembers); + } + + var lastLoc = fixedFieldDeclaration.StartLocation; + curIndent.Push(IndentType.Block); + foreach (var initializer in fixedFieldDeclaration.Variables) { + if (lastLoc.Line != initializer.StartLocation.Line) { + FixStatementIndentation(initializer.StartLocation); + lastLoc = initializer.StartLocation; + } + initializer.AcceptVisitor(this); } - return base.VisitFixedFieldDeclaration (fixedFieldDeclaration, data); + curIndent.Pop (); } - public override object VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, object data) + public override void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration) { - FormatAttributedNode (enumMemberDeclaration); - return base.VisitEnumMemberDeclaration (enumMemberDeclaration, data); + FormatAttributedNode(enumMemberDeclaration); + base.VisitEnumMemberDeclaration(enumMemberDeclaration); } - public override object VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, object data) + public override void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration) { - FormatAttributedNode (delegateDeclaration); + FormatAttributedNode(delegateDeclaration); - ForceSpacesBefore (delegateDeclaration.LParToken, policy.SpaceBeforeDelegateDeclarationParentheses); - if (delegateDeclaration.Parameters.Any ()) { - ForceSpacesAfter (delegateDeclaration.LParToken, policy.SpaceWithinDelegateDeclarationParentheses); - ForceSpacesBefore (delegateDeclaration.RParToken, policy.SpaceWithinDelegateDeclarationParentheses); + ForceSpacesBefore(delegateDeclaration.LParToken, policy.SpaceBeforeDelegateDeclarationParentheses); + if (delegateDeclaration.Parameters.Any()) { + ForceSpacesAfter(delegateDeclaration.LParToken, policy.SpaceWithinDelegateDeclarationParentheses); + ForceSpacesBefore(delegateDeclaration.RParToken, policy.SpaceWithinDelegateDeclarationParentheses); } else { - ForceSpacesAfter (delegateDeclaration.LParToken, policy.SpaceBetweenEmptyDelegateDeclarationParentheses); - ForceSpacesBefore (delegateDeclaration.RParToken, policy.SpaceBetweenEmptyDelegateDeclarationParentheses); + ForceSpacesAfter(delegateDeclaration.LParToken, policy.SpaceBetweenEmptyDelegateDeclarationParentheses); + ForceSpacesBefore(delegateDeclaration.RParToken, policy.SpaceBetweenEmptyDelegateDeclarationParentheses); } - FormatCommas (delegateDeclaration, policy.SpaceBeforeDelegateDeclarationParameterComma, policy.SpaceAfterDelegateDeclarationParameterComma); + FormatCommas(delegateDeclaration, policy.SpaceBeforeDelegateDeclarationParameterComma, policy.SpaceAfterDelegateDeclarationParameterComma); if (delegateDeclaration.NextSibling is TypeDeclaration || delegateDeclaration.NextSibling is DelegateDeclaration) { - EnsureBlankLinesAfter (delegateDeclaration, policy.BlankLinesBetweenTypes); - } else if (IsMember (delegateDeclaration.NextSibling)) { - EnsureBlankLinesAfter (delegateDeclaration, policy.BlankLinesBetweenMembers); + EnsureBlankLinesAfter(delegateDeclaration, policy.BlankLinesBetweenTypes); + } else if (IsMember(delegateDeclaration.NextSibling)) { + EnsureBlankLinesAfter(delegateDeclaration, policy.BlankLinesBetweenMembers); } - return base.VisitDelegateDeclaration (delegateDeclaration, data); + base.VisitDelegateDeclaration(delegateDeclaration); } - static bool IsMember (AstNode nextSibling) + static bool IsMember(AstNode nextSibling) { return nextSibling != null && nextSibling.NodeType == NodeType.Member; } - void FormatAttributedNode (AstNode node) + void FormatAttributedNode(AstNode node) { - if (node == null) + if (node == null) { return; + } AstNode child = node.FirstChild; while (child != null && child is AttributeSection) { - FixIndentationForceNewLine (child.StartLocation); + FixIndentationForceNewLine(child.StartLocation); child = child.NextSibling; } - if (child != null) - FixIndentationForceNewLine (child.StartLocation); + if (child != null) { + FixIndentationForceNewLine(child.StartLocation); + } } - public override object VisitMethodDeclaration (MethodDeclaration methodDeclaration, object data) + public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration) { - FormatAttributedNode (methodDeclaration); + FormatAttributedNode(methodDeclaration); - ForceSpacesBefore (methodDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses); - if (methodDeclaration.Parameters.Any ()) { - ForceSpacesAfter (methodDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses); - ForceSpacesBefore (methodDeclaration.RParToken, policy.SpaceWithinMethodDeclarationParentheses); + ForceSpacesBefore(methodDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses); + if (methodDeclaration.Parameters.Any()) { + ForceSpacesAfter(methodDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses); + ForceSpacesBefore(methodDeclaration.RParToken, policy.SpaceWithinMethodDeclarationParentheses); } else { - ForceSpacesAfter (methodDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); - ForceSpacesBefore (methodDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); + ForceSpacesAfter(methodDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); + ForceSpacesBefore(methodDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); } - FormatCommas (methodDeclaration, policy.SpaceBeforeMethodDeclarationParameterComma, policy.SpaceAfterMethodDeclarationParameterComma); + FormatCommas(methodDeclaration, policy.SpaceBeforeMethodDeclarationParameterComma, policy.SpaceAfterMethodDeclarationParameterComma); if (!methodDeclaration.Body.IsNull) { - EnforceBraceStyle (policy.MethodBraceStyle, methodDeclaration.Body.LBraceToken, methodDeclaration.Body.RBraceToken); - if (policy.IndentMethodBody) - IndentLevel++; - base.VisitBlockStatement (methodDeclaration.Body, data); - if (policy.IndentMethodBody) - IndentLevel--; + EnforceBraceStyle(policy.MethodBraceStyle, methodDeclaration.Body.LBraceToken, methodDeclaration.Body.RBraceToken); + VisitBlockWithoutFixingBraces(methodDeclaration.Body, policy.IndentMethodBody); + } + if (IsMember(methodDeclaration.NextSibling)) { + EnsureBlankLinesAfter(methodDeclaration, policy.BlankLinesBetweenMembers); } - if (IsMember (methodDeclaration.NextSibling)) - EnsureBlankLinesAfter (methodDeclaration, policy.BlankLinesBetweenMembers); - - return null; } - public override object VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, object data) + public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) { - FormatAttributedNode (operatorDeclaration); + FormatAttributedNode(operatorDeclaration); - ForceSpacesBefore (operatorDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses); - if (operatorDeclaration.Parameters.Any ()) { - ForceSpacesAfter (operatorDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses); - ForceSpacesBefore (operatorDeclaration.RParToken, policy.SpaceWithinMethodDeclarationParentheses); + ForceSpacesBefore(operatorDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses); + if (operatorDeclaration.Parameters.Any()) { + ForceSpacesAfter(operatorDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses); + ForceSpacesBefore(operatorDeclaration.RParToken, policy.SpaceWithinMethodDeclarationParentheses); } else { - ForceSpacesAfter (operatorDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); - ForceSpacesBefore (operatorDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); + ForceSpacesAfter(operatorDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); + ForceSpacesBefore(operatorDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); } - FormatCommas (operatorDeclaration, policy.SpaceBeforeMethodDeclarationParameterComma, policy.SpaceAfterMethodDeclarationParameterComma); + FormatCommas(operatorDeclaration, policy.SpaceBeforeMethodDeclarationParameterComma, policy.SpaceAfterMethodDeclarationParameterComma); if (!operatorDeclaration.Body.IsNull) { - EnforceBraceStyle (policy.MethodBraceStyle, operatorDeclaration.Body.LBraceToken, operatorDeclaration.Body.RBraceToken); - if (policy.IndentMethodBody) - IndentLevel++; - base.VisitBlockStatement (operatorDeclaration.Body, data); - if (policy.IndentMethodBody) - IndentLevel--; - } - if (IsMember (operatorDeclaration.NextSibling)) - EnsureBlankLinesAfter (operatorDeclaration, policy.BlankLinesBetweenMembers); - - return null; + EnforceBraceStyle(policy.MethodBraceStyle, operatorDeclaration.Body.LBraceToken, operatorDeclaration.Body.RBraceToken); + VisitBlockWithoutFixingBraces(operatorDeclaration.Body, policy.IndentMethodBody); + } + if (IsMember(operatorDeclaration.NextSibling)) { + EnsureBlankLinesAfter(operatorDeclaration, policy.BlankLinesBetweenMembers); + } } - public override object VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, object data) + public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration) { - FormatAttributedNode (constructorDeclaration); + FormatAttributedNode(constructorDeclaration); - ForceSpacesBefore (constructorDeclaration.LParToken, policy.SpaceBeforeConstructorDeclarationParentheses); - if (constructorDeclaration.Parameters.Any ()) { - ForceSpacesAfter (constructorDeclaration.LParToken, policy.SpaceWithinConstructorDeclarationParentheses); - ForceSpacesBefore (constructorDeclaration.RParToken, policy.SpaceWithinConstructorDeclarationParentheses); + ForceSpacesBefore(constructorDeclaration.LParToken, policy.SpaceBeforeConstructorDeclarationParentheses); + if (constructorDeclaration.Parameters.Any()) { + ForceSpacesAfter(constructorDeclaration.LParToken, policy.SpaceWithinConstructorDeclarationParentheses); + ForceSpacesBefore(constructorDeclaration.RParToken, policy.SpaceWithinConstructorDeclarationParentheses); } else { - ForceSpacesAfter (constructorDeclaration.LParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses); - ForceSpacesBefore (constructorDeclaration.RParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses); + ForceSpacesAfter(constructorDeclaration.LParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses); + ForceSpacesBefore(constructorDeclaration.RParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses); } - FormatCommas (constructorDeclaration, policy.SpaceBeforeConstructorDeclarationParameterComma, policy.SpaceAfterConstructorDeclarationParameterComma); - - object result = null; + FormatCommas(constructorDeclaration, policy.SpaceBeforeConstructorDeclarationParameterComma, policy.SpaceAfterConstructorDeclarationParameterComma); + if (!constructorDeclaration.Body.IsNull) { - EnforceBraceStyle (policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken, constructorDeclaration.Body.RBraceToken); - if (policy.IndentMethodBody) - IndentLevel++; - result = base.VisitBlockStatement (constructorDeclaration.Body, data); - if (policy.IndentMethodBody) - IndentLevel--; - } - if (IsMember (constructorDeclaration.NextSibling)) - EnsureBlankLinesAfter (constructorDeclaration, policy.BlankLinesBetweenMembers); - return result; + EnforceBraceStyle(policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken, constructorDeclaration.Body.RBraceToken); + VisitBlockWithoutFixingBraces(constructorDeclaration.Body, policy.IndentMethodBody); + } + if (IsMember(constructorDeclaration.NextSibling)) { + EnsureBlankLinesAfter(constructorDeclaration, policy.BlankLinesBetweenMembers); + } } - public override object VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, object data) + public override void VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration) { - FormatAttributedNode (destructorDeclaration); + FormatAttributedNode(destructorDeclaration); CSharpTokenNode lParen = destructorDeclaration.LParToken; - int offset = this.document.GetOffset (lParen.StartLocation); - ForceSpaceBefore (offset, policy.SpaceBeforeConstructorDeclarationParentheses); + int offset = this.document.GetOffset(lParen.StartLocation); + ForceSpaceBefore(offset, policy.SpaceBeforeConstructorDeclarationParentheses); - object result = null; if (!destructorDeclaration.Body.IsNull) { - EnforceBraceStyle (policy.DestructorBraceStyle, destructorDeclaration.Body.LBraceToken, destructorDeclaration.Body.RBraceToken); - if (policy.IndentMethodBody) - IndentLevel++; - result = base.VisitBlockStatement (destructorDeclaration.Body, data); - if (policy.IndentMethodBody) - IndentLevel--; - } - if (IsMember (destructorDeclaration.NextSibling)) - EnsureBlankLinesAfter (destructorDeclaration, policy.BlankLinesBetweenMembers); - return result; + EnforceBraceStyle(policy.DestructorBraceStyle, destructorDeclaration.Body.LBraceToken, destructorDeclaration.Body.RBraceToken); + VisitBlockWithoutFixingBraces(destructorDeclaration.Body, policy.IndentMethodBody); + } + if (IsMember(destructorDeclaration.NextSibling)) { + EnsureBlankLinesAfter(destructorDeclaration, policy.BlankLinesBetweenMembers); + } } #region Statements - public override object VisitExpressionStatement (ExpressionStatement expressionStatement, object data) + public override void VisitExpressionStatement(ExpressionStatement expressionStatement) { - FixStatementIndentation (expressionStatement.StartLocation); - FixSemicolon (expressionStatement.SemicolonToken); - return base.VisitExpressionStatement (expressionStatement, data); + base.VisitExpressionStatement(expressionStatement); + FixSemicolon(expressionStatement.SemicolonToken); } - object VisitBlockWithoutFixIndentation (BlockStatement blockStatement, bool indent, object data) + void VisitBlockWithoutFixingBraces(BlockStatement blockStatement, bool indent) { - if (indent) - IndentLevel++; - object result = base.VisitBlockStatement (blockStatement, data); - if (indent) - IndentLevel--; - return result; + if (indent) { + curIndent.Push(IndentType.Block); + } + foreach (var child in blockStatement.Children) { + if (child.Role == Roles.LBrace || child.Role == Roles.RBrace) { + continue; + } + if (child is Statement) { + FixStatementIndentation(child.StartLocation); + child.AcceptVisitor(this); + } else if (child is Comment) { + child.AcceptVisitor(this); + } else { + // pre processor directives at line start, if they are there. + if (child.StartLocation.Column > 1) + FixStatementIndentation(child.StartLocation); + } + } + if (indent) { + curIndent.Pop (); + } } - public override object VisitBlockStatement (BlockStatement blockStatement, object data) + public override void VisitBlockStatement(BlockStatement blockStatement) { - FixIndentation (blockStatement.StartLocation); - object result = VisitBlockWithoutFixIndentation (blockStatement, policy.IndentBlocks, data); - FixIndentation (blockStatement.EndLocation, -1); - return result; + FixIndentation(blockStatement.StartLocation); + VisitBlockWithoutFixingBraces(blockStatement, policy.IndentBlocks); + FixIndentation(blockStatement.EndLocation, -1); } - public override object VisitComment (Comment comment, object data) + public override void VisitComment(Comment comment) { - if (comment.StartsLine && !HadErrors && comment.StartLocation.Column > 1) - FixIndentation (comment.StartLocation); - return null; + if (comment.StartsLine && !HadErrors && (!policy.KeepCommentsAtFirstColumn || comment.StartLocation.Column > 1)) { + FixIndentation(comment.StartLocation); + } } - public override object VisitBreakStatement (BreakStatement breakStatement, object data) + public override void VisitBreakStatement(BreakStatement breakStatement) { - FixStatementIndentation (breakStatement.StartLocation); - return null; + FixSemicolon(breakStatement.SemicolonToken); } - public override object VisitCheckedStatement (CheckedStatement checkedStatement, object data) + public override void VisitCheckedStatement(CheckedStatement checkedStatement) { - FixStatementIndentation (checkedStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, checkedStatement.Body); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.FixedBraceForcement, checkedStatement.Body); } - public override object VisitContinueStatement (ContinueStatement continueStatement, object data) + public override void VisitContinueStatement(ContinueStatement continueStatement) { - FixStatementIndentation (continueStatement.StartLocation); - return null; + FixSemicolon(continueStatement.SemicolonToken); } - public override object VisitEmptyStatement (EmptyStatement emptyStatement, object data) + public override void VisitEmptyStatement(EmptyStatement emptyStatement) { - FixStatementIndentation (emptyStatement.StartLocation); - return null; + // Empty } - public override object VisitFixedStatement (FixedStatement fixedStatement, object data) + public override void VisitFixedStatement(FixedStatement fixedStatement) { - FixStatementIndentation (fixedStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, fixedStatement.EmbeddedStatement); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.FixedBraceForcement, fixedStatement.EmbeddedStatement); } - public override object VisitForeachStatement (ForeachStatement foreachStatement, object data) + public override void VisitForeachStatement(ForeachStatement foreachStatement) { - FixStatementIndentation (foreachStatement.StartLocation); - ForceSpacesBefore (foreachStatement.LParToken, policy.SpaceBeforeForeachParentheses); + ForceSpacesBefore(foreachStatement.LParToken, policy.SpaceBeforeForeachParentheses); - ForceSpacesAfter (foreachStatement.LParToken, policy.SpacesWithinForeachParentheses); - ForceSpacesBefore (foreachStatement.RParToken, policy.SpacesWithinForeachParentheses); + ForceSpacesAfter(foreachStatement.LParToken, policy.SpacesWithinForeachParentheses); + ForceSpacesBefore(foreachStatement.RParToken, policy.SpacesWithinForeachParentheses); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.ForEachBraceForcement, foreachStatement.EmbeddedStatement); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.ForEachBraceForcement, foreachStatement.EmbeddedStatement); } - object FixEmbeddedStatment (BraceStyle braceStyle, BraceForcement braceForcement, AstNode node) + void FixEmbeddedStatment(BraceStyle braceStyle, BraceForcement braceForcement, AstNode node) { - return FixEmbeddedStatment (braceStyle, braceForcement, null, false, node); + FixEmbeddedStatment(braceStyle, braceForcement, null, false, node); } - object FixEmbeddedStatment (BraceStyle braceStyle, BraceForcement braceForcement, CSharpTokenNode token, bool allowInLine, AstNode node) + void FixEmbeddedStatment(BraceStyle braceStyle, BraceForcement braceForcement, CSharpTokenNode token, bool allowInLine, AstNode node, bool statementAlreadyIndented = false) { - if (node == null) - return null; - int originalLevel = curIndent.Level; + if (node == null) { + return; + } bool isBlock = node is BlockStatement; + TextReplaceAction beginBraceAction = null; + TextReplaceAction endBraceAction = null; + switch (braceForcement) { - case BraceForcement.DoNotChange: - //nothing - break; - case BraceForcement.AddBraces: - if (!isBlock) { - AstNode n = node.Parent.GetCSharpNodeBefore (node); - int start = document.GetOffset (n.EndLocation); - var next = n.GetNextNode (); - int offset = document.GetOffset (next.StartLocation); - string startBrace = ""; - switch (braceStyle) { - case BraceStyle.EndOfLineWithoutSpace: - startBrace = "{"; - break; - case BraceStyle.EndOfLine: - startBrace = " {"; - break; - case BraceStyle.NextLine: - startBrace = this.EolMarker + curIndent.IndentString + "{"; - break; - case BraceStyle.NextLineShifted2: - case BraceStyle.NextLineShifted: - startBrace = this.EolMarker + curIndent.IndentString + curIndent.SingleIndent + "{"; - break; + case BraceForcement.DoNotChange: + //nothing + break; + case BraceForcement.AddBraces: + if (!isBlock) { + AstNode n = node.Parent.GetCSharpNodeBefore(node); + int start = document.GetOffset(n.EndLocation); + string startBrace = ""; + switch (braceStyle) { + case BraceStyle.EndOfLineWithoutSpace: + startBrace = "{"; + break; + case BraceStyle.BannerStyle: + case BraceStyle.EndOfLine: + startBrace = " {"; + break; + case BraceStyle.NextLine: + startBrace = this.options.EolMarker + curIndent.IndentString + "{"; + break; + case BraceStyle.NextLineShifted2: + case BraceStyle.NextLineShifted: + curIndent.Push(IndentType.Block); + startBrace = this.options.EolMarker + curIndent.IndentString + "{"; + curIndent.Pop(); + break; + } + beginBraceAction = AddChange(start, 0, startBrace); } - if (IsLineIsEmptyUpToEol (document.GetOffset (node.StartLocation))) - startBrace += this.EolMarker + GetIndentation (node.StartLocation.Line); - AddChange (start, offset - start, startBrace); - } - break; - case BraceForcement.RemoveBraces: - if (isBlock) { - BlockStatement block = node as BlockStatement; - if (block.Statements.Count () == 1) { - int offset1 = document.GetOffset (node.StartLocation); - int start = SearchWhitespaceStart (offset1); - - int offset2 = document.GetOffset (node.EndLocation); - int end = SearchWhitespaceStart (offset2 - 1); - - AddChange (start, offset1 - start + 1, null); - AddChange (end + 1, offset2 - end, null); - node = block.FirstChild; - isBlock = false; + break; + case BraceForcement.RemoveBraces: + if (isBlock) { + BlockStatement block = node as BlockStatement; + if (block.Statements.Count() == 1) { + int offset1 = document.GetOffset(node.StartLocation); + int start = SearchWhitespaceStart(offset1); + + int offset2 = document.GetOffset(node.EndLocation); + int end = SearchWhitespaceStart(offset2 - 1); + + beginBraceAction = AddChange(start, offset1 - start + 1, null); + endBraceAction = AddChange(end + 1, offset2 - end, null); + node = block.FirstChild; + isBlock = false; + } } - } - break; + break; } if (isBlock) { BlockStatement block = node as BlockStatement; - if (allowInLine && block.StartLocation.Line == block.EndLocation.Line && block.Statements.Count () <= 1) { - if (block.Statements.Count () == 1) + if (allowInLine && block.StartLocation.Line == block.EndLocation.Line && block.Statements.Count() <= 1) { + if (block.Statements.Count() == 1) { nextStatementIndent = " "; + } } else { - EnforceBraceStyle (braceStyle, block.LBraceToken, block.RBraceToken); + if (!statementAlreadyIndented) { + EnforceBraceStyle(braceStyle, block.LBraceToken, block.RBraceToken); + } + } + if (braceStyle == BraceStyle.NextLineShifted2) { + curIndent.Push(IndentType.Block); } - if (braceStyle == BraceStyle.NextLineShifted2) - curIndent.Level++; } else { if (allowInLine && token.StartLocation.Line == node.EndLocation.Line) { nextStatementIndent = " "; } } - if (policy.IndentBlocks && - !(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement || - policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement)) - curIndent.Level++; - object result = isBlock ? base.VisitBlockStatement ((BlockStatement)node, null) : node.AcceptVisitor (this, null); - curIndent.Level = originalLevel; + if (policy.IndentBlocks && !(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement || policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement)) { + curIndent.Push(IndentType.Block); + } + if (isBlock) { + VisitBlockWithoutFixingBraces((BlockStatement)node, false); + } else { + if (!statementAlreadyIndented) { + FixStatementIndentation(node.StartLocation); + } + node.AcceptVisitor(this); + } + if (policy.IndentBlocks && !(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement || policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement)) { + curIndent.Pop(); + } switch (braceForcement) { - case BraceForcement.DoNotChange: - break; - case BraceForcement.AddBraces: - if (!isBlock) { - int offset = document.GetOffset (node.EndLocation); - if (!char.IsWhiteSpace (document.GetCharAt (offset))) - offset++; - string startBrace = ""; - switch (braceStyle) { - case BraceStyle.DoNotChange: - startBrace = null; - break; - case BraceStyle.EndOfLineWithoutSpace: - startBrace = this.EolMarker + curIndent.IndentString + "}"; - break; - case BraceStyle.EndOfLine: - startBrace = this.EolMarker + curIndent.IndentString + "}"; - break; - case BraceStyle.NextLine: - startBrace = this.EolMarker + curIndent.IndentString + "}"; - break; - case BraceStyle.NextLineShifted2: - case BraceStyle.NextLineShifted: - startBrace = this.EolMarker + curIndent.IndentString + curIndent.SingleIndent + "}"; - break; + case BraceForcement.DoNotChange: + break; + case BraceForcement.AddBraces: + if (!isBlock) { + int offset = document.GetOffset(node.EndLocation); + if (!char.IsWhiteSpace(document.GetCharAt(offset))) { + offset++; + } + string startBrace = ""; + switch (braceStyle) { + case BraceStyle.DoNotChange: + startBrace = null; + break; + case BraceStyle.EndOfLineWithoutSpace: + startBrace = this.options.EolMarker + curIndent.IndentString + "}"; + break; + case BraceStyle.EndOfLine: + startBrace = this.options.EolMarker + curIndent.IndentString + "}"; + break; + case BraceStyle.NextLine: + startBrace = this.options.EolMarker + curIndent.IndentString + "}"; + break; + case BraceStyle.BannerStyle: + case BraceStyle.NextLineShifted2: + case BraceStyle.NextLineShifted: + curIndent.Push(IndentType.Block); + startBrace = this.options.EolMarker + curIndent.IndentString + "}"; + curIndent.Pop (); + break; + + } + if (startBrace != null) { + endBraceAction = AddChange(offset, 0, startBrace); + } } - if (startBrace != null) - AddChange (offset, 0, startBrace); - } - break; + break; + } + if (beginBraceAction != null && endBraceAction != null) { + beginBraceAction.DependsOn = endBraceAction; + endBraceAction.DependsOn = beginBraceAction; } - return result; } - void EnforceBraceStyle (BraceStyle braceStyle, AstNode lbrace, AstNode rbrace) + void EnforceBraceStyle(BraceStyle braceStyle, AstNode lbrace, AstNode rbrace) { - if (lbrace.IsNull || rbrace.IsNull) + if (lbrace.IsNull || rbrace.IsNull) { return; + } -// LineSegment lbraceLineSegment = data.Document.GetLine (lbrace.StartLocation.Line); - int lbraceOffset = document.GetOffset (lbrace.StartLocation); + // LineSegment lbraceLineSegment = data.Document.GetLine (lbrace.StartLocation.Line); + int lbraceOffset = document.GetOffset(lbrace.StartLocation); -// LineSegment rbraceLineSegment = data.Document.GetLine (rbrace.StartLocation.Line); - int rbraceOffset = document.GetOffset (rbrace.StartLocation); - int whitespaceStart = SearchWhitespaceStart (lbraceOffset); - int whitespaceEnd = SearchWhitespaceLineStart (rbraceOffset); + // LineSegment rbraceLineSegment = data.Document.GetLine (rbrace.StartLocation.Line); + int rbraceOffset = document.GetOffset(rbrace.StartLocation); + int whitespaceStart = SearchWhitespaceStart(lbraceOffset); + int whitespaceEnd = SearchWhitespaceLineStart(rbraceOffset); string startIndent = ""; string endIndent = ""; switch (braceStyle) { - case BraceStyle.DoNotChange: - startIndent = endIndent = null; - break; - case BraceStyle.EndOfLineWithoutSpace: - startIndent = ""; - endIndent = IsLineIsEmptyUpToEol (rbraceOffset) ? curIndent.IndentString : this.EolMarker + curIndent.IndentString; - break; - case BraceStyle.EndOfLine: - var prevNode = lbrace.GetPrevNode (); - if (prevNode is Comment) { - // delete old bracket - AddChange (whitespaceStart, lbraceOffset - whitespaceStart + 1, ""); + case BraceStyle.DoNotChange: + startIndent = endIndent = null; + break; + case BraceStyle.EndOfLineWithoutSpace: + startIndent = ""; + endIndent = IsLineIsEmptyUpToEol(rbraceOffset) ? curIndent.IndentString : this.options.EolMarker + curIndent.IndentString; + break; + case BraceStyle.BannerStyle: + var prevNode = lbrace.GetPrevNode(); + if (prevNode is Comment) { + // delete old bracket + AddChange(whitespaceStart, lbraceOffset - whitespaceStart + 1, ""); - while (prevNode is Comment) { - prevNode = prevNode.GetPrevNode (); + while (prevNode is Comment) { + prevNode = prevNode.GetPrevNode(); + } + whitespaceStart = document.GetOffset(prevNode.EndLocation); + lbraceOffset = whitespaceStart; + startIndent = " {"; + } else { + startIndent = " "; } - whitespaceStart = document.GetOffset (prevNode.EndLocation); - lbraceOffset = whitespaceStart; - startIndent = " {"; - } else { - startIndent = " "; - } - endIndent = IsLineIsEmptyUpToEol (rbraceOffset) ? curIndent.IndentString : this.EolMarker + curIndent.IndentString; - break; - case BraceStyle.NextLine: - startIndent = this.EolMarker + curIndent.IndentString; - endIndent = IsLineIsEmptyUpToEol (rbraceOffset) ? curIndent.IndentString : this.EolMarker + curIndent.IndentString; - break; - case BraceStyle.NextLineShifted2: - case BraceStyle.NextLineShifted: - startIndent = this.EolMarker + curIndent.IndentString + curIndent.SingleIndent; - endIndent = IsLineIsEmptyUpToEol (rbraceOffset) ? curIndent.IndentString + curIndent.SingleIndent : this.EolMarker + curIndent.IndentString + curIndent.SingleIndent; - break; + curIndent.Push(IndentType.Block); + endIndent = IsLineIsEmptyUpToEol(rbraceOffset) ? curIndent.IndentString : this.options.EolMarker + curIndent.IndentString; + curIndent.Pop(); + break; + case BraceStyle.EndOfLine: + prevNode = lbrace.GetPrevNode(); + if (prevNode is Comment) { + // delete old bracket + AddChange(whitespaceStart, lbraceOffset - whitespaceStart + 1, ""); + + while (prevNode is Comment) { + prevNode = prevNode.GetPrevNode(); + } + whitespaceStart = document.GetOffset(prevNode.EndLocation); + lbraceOffset = whitespaceStart; + startIndent = " {"; + } else { + startIndent = " "; + } + endIndent = IsLineIsEmptyUpToEol(rbraceOffset) ? curIndent.IndentString : this.options.EolMarker + curIndent.IndentString; + break; + case BraceStyle.NextLine: + startIndent = this.options.EolMarker + curIndent.IndentString; + endIndent = IsLineIsEmptyUpToEol(rbraceOffset) ? curIndent.IndentString : this.options.EolMarker + curIndent.IndentString; + break; + case BraceStyle.NextLineShifted2: + case BraceStyle.NextLineShifted: + curIndent.Push(IndentType.Block); + startIndent = this.options.EolMarker + curIndent.IndentString; + endIndent = IsLineIsEmptyUpToEol(rbraceOffset) ? curIndent.IndentString : this.options.EolMarker + curIndent.IndentString; + curIndent.Pop (); + break; } - if (lbraceOffset > 0 && startIndent != null) - AddChange (whitespaceStart, lbraceOffset - whitespaceStart, startIndent); - if (rbraceOffset > 0 && endIndent != null) - AddChange (whitespaceEnd, rbraceOffset - whitespaceEnd, endIndent); + if (lbraceOffset > 0 && startIndent != null) { + AddChange(whitespaceStart, lbraceOffset - whitespaceStart, startIndent); + } + if (rbraceOffset > 0 && endIndent != null) { + AddChange(whitespaceEnd, rbraceOffset - whitespaceEnd, endIndent); + } } - void AddChange (int offset, int removedChars, string insertedText) + TextReplaceAction AddChange(int offset, int removedChars, string insertedText) { - if (changes.Any (c => c.Offset == offset && c.RemovedChars == removedChars - && c.InsertedText == insertedText)) - return; - string currentText = document.GetText (offset, removedChars); - if (currentText == insertedText) - return; - if (currentText.Any (c => !(char.IsWhiteSpace (c) || c == '\r' || c == '\t' || c == '{' || c == '}'))) - throw new InvalidOperationException ("Tried to remove non ws chars: '" + currentText + "'"); - foreach (var change in changes) { - if (change.Offset == offset) { - if (removedChars > 0 && insertedText == change.InsertedText) { - change.RemovedChars = removedChars; -// change.InsertedText = insertedText; - return; - } - if (!string.IsNullOrEmpty (change.InsertedText)) { - change.InsertedText += insertedText; - } else { - change.InsertedText = insertedText; - } - change.RemovedChars = System.Math.Max (removedChars, change.RemovedChars); - return; - } - } - //Console.WriteLine ("offset={0}, removedChars={1}, insertedText={2}", offset, removedChars, insertedText == null ? "" : insertedText.Replace ("\n", "\\n").Replace ("\r", "\\r").Replace ("\t", "\\t").Replace (" ", ".")); - //Console.WriteLine (Environment.StackTrace); - - changes.Add (factory.CreateTextReplaceAction (offset, removedChars, insertedText)); + var action = new TextReplaceAction (offset, removedChars, insertedText); + changes.Add(action); + return action; } - public bool IsLineIsEmptyUpToEol (TextLocation startLocation) + public bool IsLineIsEmptyUpToEol(TextLocation startLocation) { - return IsLineIsEmptyUpToEol (document.GetOffset (startLocation) - 1); + return IsLineIsEmptyUpToEol(document.GetOffset(startLocation) - 1); } - bool IsLineIsEmptyUpToEol (int startOffset) + bool IsLineIsEmptyUpToEol(int startOffset) { for (int offset = startOffset - 1; offset >= 0; offset--) { - char ch = document.GetCharAt (offset); - if (ch != ' ' && ch != '\t') + char ch = document.GetCharAt(offset); + if (ch != ' ' && ch != '\t') { return ch == '\n' || ch == '\r'; + } } return true; } - int SearchWhitespaceStart (int startOffset) + int SearchWhitespaceStart(int startOffset) { - if (startOffset < 0) + if (startOffset < 0) { throw new ArgumentOutOfRangeException ("startoffset", "value : " + startOffset); + } for (int offset = startOffset - 1; offset >= 0; offset--) { - char ch = document.GetCharAt (offset); - if (!Char.IsWhiteSpace (ch)) { + char ch = document.GetCharAt(offset); + if (!Char.IsWhiteSpace(ch)) { return offset + 1; } } return 0; } - int SearchWhitespaceEnd (int startOffset) + int SearchWhitespaceEnd(int startOffset) { - if (startOffset > document.TextLength) + if (startOffset > document.TextLength) { throw new ArgumentOutOfRangeException ("startoffset", "value : " + startOffset); + } for (int offset = startOffset + 1; offset < document.TextLength; offset++) { - char ch = document.GetCharAt (offset); - if (!Char.IsWhiteSpace (ch)) { + char ch = document.GetCharAt(offset); + if (!Char.IsWhiteSpace(ch)) { return offset + 1; } } return document.TextLength - 1; } - int SearchWhitespaceLineStart (int startOffset) + int SearchWhitespaceLineStart(int startOffset) { - if (startOffset < 0) + if (startOffset < 0) { throw new ArgumentOutOfRangeException ("startoffset", "value : " + startOffset); + } for (int offset = startOffset - 1; offset >= 0; offset--) { - char ch = document.GetCharAt (offset); + char ch = document.GetCharAt(offset); if (ch != ' ' && ch != '\t') { return offset + 1; } @@ -1056,469 +1237,520 @@ namespace ICSharpCode.NRefactory.CSharp return 0; } - public override object VisitForStatement (ForStatement forStatement, object data) + public override void VisitForStatement(ForStatement forStatement) { - FixStatementIndentation (forStatement.StartLocation); foreach (AstNode node in forStatement.Children) { - if (node.Role == ForStatement.Roles.Semicolon) { - if (node.NextSibling is CSharpTokenNode || node.NextSibling is EmptyStatement) + if (node.Role == Roles.Semicolon) { + if (node.NextSibling is CSharpTokenNode || node.NextSibling is EmptyStatement) { continue; - ForceSpacesBefore (node, policy.SpaceBeforeForSemicolon); - ForceSpacesAfter (node, policy.SpaceAfterForSemicolon); + } + ForceSpacesBefore(node, policy.SpaceBeforeForSemicolon); + ForceSpacesAfter(node, policy.SpaceAfterForSemicolon); } } - ForceSpacesBefore (forStatement.LParToken, policy.SpaceBeforeForParentheses); + ForceSpacesBefore(forStatement.LParToken, policy.SpaceBeforeForParentheses); - ForceSpacesAfter (forStatement.LParToken, policy.SpacesWithinForParentheses); - ForceSpacesBefore (forStatement.RParToken, policy.SpacesWithinForParentheses); + ForceSpacesAfter(forStatement.LParToken, policy.SpacesWithinForParentheses); + ForceSpacesBefore(forStatement.RParToken, policy.SpacesWithinForParentheses); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.ForBraceForcement, forStatement.EmbeddedStatement); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.ForBraceForcement, forStatement.EmbeddedStatement); } - public override object VisitGotoStatement (GotoStatement gotoStatement, object data) + public override void VisitGotoStatement(GotoStatement gotoStatement) { - FixStatementIndentation (gotoStatement.StartLocation); - return VisitChildren (gotoStatement, data); + VisitChildren(gotoStatement); + FixSemicolon(gotoStatement.SemicolonToken); } - public override object VisitIfElseStatement (IfElseStatement ifElseStatement, object data) + public override void VisitIfElseStatement(IfElseStatement ifElseStatement) { - ForceSpacesBefore (ifElseStatement.LParToken, policy.SpaceBeforeIfParentheses); + ForceSpacesBefore(ifElseStatement.LParToken, policy.SpaceBeforeIfParentheses); - ForceSpacesAfter (ifElseStatement.LParToken, policy.SpacesWithinIfParentheses); - ForceSpacesBefore (ifElseStatement.RParToken, policy.SpacesWithinIfParentheses); + ForceSpacesAfter(ifElseStatement.LParToken, policy.SpacesWithinIfParentheses); + ForceSpacesBefore(ifElseStatement.RParToken, policy.SpacesWithinIfParentheses); - if (!(ifElseStatement.Parent is IfElseStatement && ((IfElseStatement)ifElseStatement.Parent).FalseStatement == ifElseStatement)) - FixStatementIndentation (ifElseStatement.StartLocation); + if (!(ifElseStatement.Parent is IfElseStatement && ((IfElseStatement)ifElseStatement.Parent).FalseStatement == ifElseStatement)) { + FixStatementIndentation(ifElseStatement.StartLocation); + } - if (!ifElseStatement.Condition.IsNull) - ifElseStatement.Condition.AcceptVisitor (this, data); + if (!ifElseStatement.Condition.IsNull) { + ifElseStatement.Condition.AcceptVisitor(this); + } - if (!ifElseStatement.TrueStatement.IsNull) - FixEmbeddedStatment (policy.StatementBraceStyle, policy.IfElseBraceForcement, ifElseStatement.IfToken, policy.AllowIfBlockInline, ifElseStatement.TrueStatement); + if (!ifElseStatement.TrueStatement.IsNull) { + FixEmbeddedStatment(policy.StatementBraceStyle, policy.IfElseBraceForcement, ifElseStatement.IfToken, policy.AllowIfBlockInline, ifElseStatement.TrueStatement); + } if (!ifElseStatement.FalseStatement.IsNull) { - PlaceOnNewLine (policy.PlaceElseOnNewLine || !(ifElseStatement.TrueStatement is BlockStatement) && policy.IfElseBraceForcement != BraceForcement.AddBraces, ifElseStatement.ElseToken); + PlaceOnNewLine(policy.PlaceElseOnNewLine || !(ifElseStatement.TrueStatement is BlockStatement) && policy.IfElseBraceForcement != BraceForcement.AddBraces, ifElseStatement.ElseToken); var forcement = policy.IfElseBraceForcement; if (ifElseStatement.FalseStatement is IfElseStatement) { forcement = BraceForcement.DoNotChange; - PlaceOnNewLine (policy.PlaceElseIfOnNewLine, ((IfElseStatement)ifElseStatement.FalseStatement).IfToken); + PlaceOnNewLine(policy.PlaceElseIfOnNewLine, ((IfElseStatement)ifElseStatement.FalseStatement).IfToken); } - FixEmbeddedStatment (policy.StatementBraceStyle, forcement, ifElseStatement.ElseToken, policy.AllowIfBlockInline, ifElseStatement.FalseStatement); + FixEmbeddedStatment(policy.StatementBraceStyle, forcement, ifElseStatement.ElseToken, policy.AllowIfBlockInline, ifElseStatement.FalseStatement, ifElseStatement.FalseStatement is IfElseStatement); } - - return null; } - public override object VisitLabelStatement (LabelStatement labelStatement, object data) + public override void VisitLabelStatement(LabelStatement labelStatement) { // TODO - return VisitChildren (labelStatement, data); + VisitChildren(labelStatement); } - public override object VisitLockStatement (LockStatement lockStatement, object data) + public override void VisitLockStatement(LockStatement lockStatement) { - FixStatementIndentation (lockStatement.StartLocation); - ForceSpacesBefore (lockStatement.LParToken, policy.SpaceBeforeLockParentheses); + ForceSpacesBefore(lockStatement.LParToken, policy.SpaceBeforeLockParentheses); - ForceSpacesAfter (lockStatement.LParToken, policy.SpacesWithinLockParentheses); - ForceSpacesBefore (lockStatement.RParToken, policy.SpacesWithinLockParentheses); + ForceSpacesAfter(lockStatement.LParToken, policy.SpacesWithinLockParentheses); + ForceSpacesBefore(lockStatement.RParToken, policy.SpacesWithinLockParentheses); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, lockStatement.EmbeddedStatement); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.FixedBraceForcement, lockStatement.EmbeddedStatement); } - public override object VisitReturnStatement (ReturnStatement returnStatement, object data) + public override void VisitReturnStatement(ReturnStatement returnStatement) { - FixStatementIndentation (returnStatement.StartLocation); - return VisitChildren (returnStatement, data); + VisitChildren(returnStatement); + FixSemicolon(returnStatement.SemicolonToken); } - public override object VisitSwitchStatement (SwitchStatement switchStatement, object data) + public override void VisitSwitchStatement(SwitchStatement switchStatement) { - FixStatementIndentation (switchStatement.StartLocation); - ForceSpacesBefore (switchStatement.LParToken, policy.SpaceBeforeSwitchParentheses); + ForceSpacesBefore(switchStatement.LParToken, policy.SpaceBeforeSwitchParentheses); - ForceSpacesAfter (switchStatement.LParToken, policy.SpacesWithinSwitchParentheses); - ForceSpacesBefore (switchStatement.RParToken, policy.SpacesWithinSwitchParentheses); + ForceSpacesAfter(switchStatement.LParToken, policy.SpacesWithinSwitchParentheses); + ForceSpacesBefore(switchStatement.RParToken, policy.SpacesWithinSwitchParentheses); - EnforceBraceStyle (policy.StatementBraceStyle, switchStatement.LBraceToken, switchStatement.RBraceToken); - object result = VisitChildren (switchStatement, data); - return result; + EnforceBraceStyle(policy.StatementBraceStyle, switchStatement.LBraceToken, switchStatement.RBraceToken); + VisitChildren(switchStatement); } - public override object VisitSwitchSection (SwitchSection switchSection, object data) + public override void VisitSwitchSection(SwitchSection switchSection) { - if (policy.IndentSwitchBody) - curIndent.Level++; + if (policy.IndentSwitchBody) { + curIndent.Push(IndentType.Block); + } foreach (CaseLabel label in switchSection.CaseLabels) { - FixStatementIndentation (label.StartLocation); + FixStatementIndentation(label.StartLocation); + label.AcceptVisitor(this); + } + if (policy.IndentCaseBody) { + curIndent.Push(IndentType.Block); } - if (policy.IndentCaseBody) - curIndent.Level++; foreach (var stmt in switchSection.Statements) { if (stmt is BreakStatement && !policy.IndentBreakStatements && policy.IndentCaseBody) { - curIndent.Level--; - stmt.AcceptVisitor (this, null); - curIndent.Level++; + curIndent.Pop(); + FixStatementIndentation(stmt.StartLocation); + stmt.AcceptVisitor(this); + curIndent.Push(IndentType.Block); continue; } - stmt.AcceptVisitor (this, null); + FixStatementIndentation(stmt.StartLocation); + stmt.AcceptVisitor(this); + } + if (policy.IndentCaseBody) { + curIndent.Pop (); + } + + if (policy.IndentSwitchBody) { + curIndent.Pop (); } - if (policy.IndentCaseBody) - curIndent.Level--; - - if (policy.IndentSwitchBody) - curIndent.Level--; - return null; } - public override object VisitCaseLabel (CaseLabel caseLabel, object data) + public override void VisitCaseLabel(CaseLabel caseLabel) { - // handled in switchsection - return null; + FixSemicolon(caseLabel.ColonToken); } - public override object VisitThrowStatement (ThrowStatement throwStatement, object data) + public override void VisitThrowStatement(ThrowStatement throwStatement) { - FixStatementIndentation (throwStatement.StartLocation); - return VisitChildren (throwStatement, data); + VisitChildren(throwStatement); + FixSemicolon(throwStatement.SemicolonToken); } - public override object VisitTryCatchStatement (TryCatchStatement tryCatchStatement, object data) + public override void VisitTryCatchStatement(TryCatchStatement tryCatchStatement) { - FixStatementIndentation (tryCatchStatement.StartLocation); - - if (!tryCatchStatement.TryBlock.IsNull) - FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.TryBlock); + if (!tryCatchStatement.TryBlock.IsNull) { + FixEmbeddedStatment(policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.TryBlock); + } foreach (CatchClause clause in tryCatchStatement.CatchClauses) { - PlaceOnNewLine (policy.PlaceCatchOnNewLine, clause.CatchToken); + PlaceOnNewLine(policy.PlaceCatchOnNewLine, clause.CatchToken); if (!clause.LParToken.IsNull) { - ForceSpacesBefore (clause.LParToken, policy.SpaceBeforeCatchParentheses); + ForceSpacesBefore(clause.LParToken, policy.SpaceBeforeCatchParentheses); - ForceSpacesAfter (clause.LParToken, policy.SpacesWithinCatchParentheses); - ForceSpacesBefore (clause.RParToken, policy.SpacesWithinCatchParentheses); + ForceSpacesAfter(clause.LParToken, policy.SpacesWithinCatchParentheses); + ForceSpacesBefore(clause.RParToken, policy.SpacesWithinCatchParentheses); } - FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, clause.Body); + FixEmbeddedStatment(policy.StatementBraceStyle, BraceForcement.DoNotChange, clause.Body); } if (!tryCatchStatement.FinallyBlock.IsNull) { - PlaceOnNewLine (policy.PlaceFinallyOnNewLine, tryCatchStatement.FinallyToken); + PlaceOnNewLine(policy.PlaceFinallyOnNewLine, tryCatchStatement.FinallyToken); - FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.FinallyBlock); + FixEmbeddedStatment(policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.FinallyBlock); } - return VisitChildren (tryCatchStatement, data); } - public override object VisitCatchClause (CatchClause catchClause, object data) + public override void VisitCatchClause(CatchClause catchClause) { // Handled in TryCatchStatement - return null; } - public override object VisitUncheckedStatement (UncheckedStatement uncheckedStatement, object data) + public override void VisitUncheckedStatement(UncheckedStatement uncheckedStatement) { - FixStatementIndentation (uncheckedStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.FixedBraceForcement, uncheckedStatement.Body); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.FixedBraceForcement, uncheckedStatement.Body); } - public override object VisitUnsafeStatement (UnsafeStatement unsafeStatement, object data) + public override void VisitUnsafeStatement(UnsafeStatement unsafeStatement) { - FixStatementIndentation (unsafeStatement.StartLocation); - return FixEmbeddedStatment (policy.StatementBraceStyle, BraceForcement.DoNotChange, unsafeStatement.Body); + FixEmbeddedStatment(policy.StatementBraceStyle, BraceForcement.DoNotChange, unsafeStatement.Body); } - public override object VisitUsingStatement (UsingStatement usingStatement, object data) + public override void VisitUsingStatement(UsingStatement usingStatement) { - FixStatementIndentation (usingStatement.StartLocation); - ForceSpacesBefore (usingStatement.LParToken, policy.SpaceBeforeUsingParentheses); + ForceSpacesBefore(usingStatement.LParToken, policy.SpaceBeforeUsingParentheses); - ForceSpacesAfter (usingStatement.LParToken, policy.SpacesWithinUsingParentheses); - ForceSpacesBefore (usingStatement.RParToken, policy.SpacesWithinUsingParentheses); + ForceSpacesAfter(usingStatement.LParToken, policy.SpacesWithinUsingParentheses); + ForceSpacesBefore(usingStatement.RParToken, policy.SpacesWithinUsingParentheses); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.UsingBraceForcement, usingStatement.EmbeddedStatement); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.UsingBraceForcement, usingStatement.EmbeddedStatement); } - public override object VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, object data) + public override void VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement) { - if (!variableDeclarationStatement.SemicolonToken.IsNull) - FixStatementIndentation (variableDeclarationStatement.StartLocation); - if ((variableDeclarationStatement.Modifiers & Modifiers.Const) == Modifiers.Const) { - ForceSpacesAround (variableDeclarationStatement.Type, true); + ForceSpacesAround(variableDeclarationStatement.Type, true); } else { - ForceSpacesAfter (variableDeclarationStatement.Type, true); + ForceSpacesAfter(variableDeclarationStatement.Type, true); } + var lastLoc = variableDeclarationStatement.StartLocation; foreach (var initializer in variableDeclarationStatement.Variables) { - initializer.AcceptVisitor (this, data); + if (lastLoc.Line != initializer.StartLocation.Line) { + FixStatementIndentation(initializer.StartLocation); + lastLoc = initializer.StartLocation; + } + initializer.AcceptVisitor(this); } - FormatCommas (variableDeclarationStatement, policy.SpaceBeforeLocalVariableDeclarationComma, policy.SpaceAfterLocalVariableDeclarationComma); - FixSemicolon (variableDeclarationStatement.SemicolonToken); - return null; + + FormatCommas(variableDeclarationStatement, policy.SpaceBeforeLocalVariableDeclarationComma, policy.SpaceAfterLocalVariableDeclarationComma); + FixSemicolon(variableDeclarationStatement.SemicolonToken); } - public override object VisitDoWhileStatement (DoWhileStatement doWhileStatement, object data) + public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement) { - FixStatementIndentation (doWhileStatement.StartLocation); - PlaceOnNewLine (policy.PlaceWhileOnNewLine, doWhileStatement.WhileToken); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.WhileBraceForcement, doWhileStatement.EmbeddedStatement); + PlaceOnNewLine(policy.PlaceWhileOnNewLine, doWhileStatement.WhileToken); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.WhileBraceForcement, doWhileStatement.EmbeddedStatement); } - public override object VisitWhileStatement (WhileStatement whileStatement, object data) + public override void VisitWhileStatement(WhileStatement whileStatement) { - FixStatementIndentation (whileStatement.StartLocation); - ForceSpacesBefore (whileStatement.LParToken, policy.SpaceBeforeWhileParentheses); + ForceSpacesBefore(whileStatement.LParToken, policy.SpaceBeforeWhileParentheses); - ForceSpacesAfter (whileStatement.LParToken, policy.SpacesWithinWhileParentheses); - ForceSpacesBefore (whileStatement.RParToken, policy.SpacesWithinWhileParentheses); + ForceSpacesAfter(whileStatement.LParToken, policy.SpacesWithinWhileParentheses); + ForceSpacesBefore(whileStatement.RParToken, policy.SpacesWithinWhileParentheses); - return FixEmbeddedStatment (policy.StatementBraceStyle, policy.WhileBraceForcement, whileStatement.EmbeddedStatement); + FixEmbeddedStatment(policy.StatementBraceStyle, policy.WhileBraceForcement, whileStatement.EmbeddedStatement); } - public override object VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement, object data) + public override void VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement) { - FixStatementIndentation (yieldBreakStatement.StartLocation); - return null; + FixSemicolon(yieldBreakStatement.SemicolonToken); } - public override object VisitYieldReturnStatement (YieldReturnStatement yieldStatement, object data) + public override void VisitYieldReturnStatement(YieldReturnStatement yieldStatement) { - FixStatementIndentation (yieldStatement.StartLocation); - return null; + yieldStatement.Expression.AcceptVisitor(this); + FixSemicolon(yieldStatement.SemicolonToken); } - public override object VisitVariableInitializer (VariableInitializer variableInitializer, object data) + public override void VisitVariableInitializer(VariableInitializer variableInitializer) { - if (!variableInitializer.AssignToken.IsNull) - ForceSpacesAround (variableInitializer.AssignToken, policy.SpaceAroundAssignment); - if (!variableInitializer.Initializer.IsNull) - variableInitializer.Initializer.AcceptVisitor (this, data); - return data; + if (!variableInitializer.AssignToken.IsNull) { + ForceSpacesAround(variableInitializer.AssignToken, policy.SpaceAroundAssignment); + } + if (!variableInitializer.Initializer.IsNull) { + variableInitializer.Initializer.AcceptVisitor(this); + } } #endregion #region Expressions - public override object VisitComposedType (ComposedType composedType, object data) + public override void VisitComposedType(ComposedType composedType) { - var spec = composedType.ArraySpecifiers.FirstOrDefault (); - if (spec != null) - ForceSpacesBefore (spec.LBracketToken, policy.SpaceBeforeArrayDeclarationBrackets); + var spec = composedType.ArraySpecifiers.FirstOrDefault(); + if (spec != null) { + ForceSpacesBefore(spec.LBracketToken, policy.SpaceBeforeArrayDeclarationBrackets); + } - return base.VisitComposedType (composedType, data); + base.VisitComposedType(composedType); } - public override object VisitAssignmentExpression (AssignmentExpression assignmentExpression, object data) + public override void VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression) { - ForceSpacesAround (assignmentExpression.OperatorToken, policy.SpaceAroundAssignment); - return base.VisitAssignmentExpression (assignmentExpression, data); + if (!anonymousMethodExpression.Body.IsNull) { + EnforceBraceStyle(policy.AnonymousMethodBraceStyle, anonymousMethodExpression.Body.LBraceToken, anonymousMethodExpression.Body.RBraceToken); + } + base.VisitAnonymousMethodExpression(anonymousMethodExpression); } - public override object VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, object data) + public override void VisitAssignmentExpression(AssignmentExpression assignmentExpression) + { + ForceSpacesAround(assignmentExpression.OperatorToken, policy.SpaceAroundAssignment); + base.VisitAssignmentExpression(assignmentExpression); + } + + public override void VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression) { bool forceSpaces = false; switch (binaryOperatorExpression.Operator) { - case BinaryOperatorType.Equality: - case BinaryOperatorType.InEquality: - forceSpaces = policy.SpaceAroundEqualityOperator; - break; - case BinaryOperatorType.GreaterThan: - case BinaryOperatorType.GreaterThanOrEqual: - case BinaryOperatorType.LessThan: - case BinaryOperatorType.LessThanOrEqual: - forceSpaces = policy.SpaceAroundRelationalOperator; - break; - case BinaryOperatorType.ConditionalAnd: - case BinaryOperatorType.ConditionalOr: - forceSpaces = policy.SpaceAroundLogicalOperator; - break; - case BinaryOperatorType.BitwiseAnd: - case BinaryOperatorType.BitwiseOr: - case BinaryOperatorType.ExclusiveOr: - forceSpaces = policy.SpaceAroundBitwiseOperator; - break; - case BinaryOperatorType.Add: - case BinaryOperatorType.Subtract: - forceSpaces = policy.SpaceAroundAdditiveOperator; - break; - case BinaryOperatorType.Multiply: - case BinaryOperatorType.Divide: - case BinaryOperatorType.Modulus: - forceSpaces = policy.SpaceAroundMultiplicativeOperator; - break; - case BinaryOperatorType.ShiftLeft: - case BinaryOperatorType.ShiftRight: - forceSpaces = policy.SpaceAroundShiftOperator; - break; - case BinaryOperatorType.NullCoalescing: - forceSpaces = policy.SpaceAroundNullCoalescingOperator; - break; - } - ForceSpacesAround (binaryOperatorExpression.OperatorToken, forceSpaces); - - return base.VisitBinaryOperatorExpression (binaryOperatorExpression, data); - } - - public override object VisitConditionalExpression (ConditionalExpression conditionalExpression, object data) - { - ForceSpacesBefore (conditionalExpression.QuestionMarkToken, policy.SpaceBeforeConditionalOperatorCondition); - ForceSpacesAfter (conditionalExpression.QuestionMarkToken, policy.SpaceAfterConditionalOperatorCondition); - ForceSpacesBefore (conditionalExpression.ColonToken, policy.SpaceBeforeConditionalOperatorSeparator); - ForceSpacesAfter (conditionalExpression.ColonToken, policy.SpaceAfterConditionalOperatorSeparator); - return base.VisitConditionalExpression (conditionalExpression, data); - } - - public override object VisitCastExpression (CastExpression castExpression, object data) + case BinaryOperatorType.Equality: + case BinaryOperatorType.InEquality: + forceSpaces = policy.SpaceAroundEqualityOperator; + break; + case BinaryOperatorType.GreaterThan: + case BinaryOperatorType.GreaterThanOrEqual: + case BinaryOperatorType.LessThan: + case BinaryOperatorType.LessThanOrEqual: + forceSpaces = policy.SpaceAroundRelationalOperator; + break; + case BinaryOperatorType.ConditionalAnd: + case BinaryOperatorType.ConditionalOr: + forceSpaces = policy.SpaceAroundLogicalOperator; + break; + case BinaryOperatorType.BitwiseAnd: + case BinaryOperatorType.BitwiseOr: + case BinaryOperatorType.ExclusiveOr: + forceSpaces = policy.SpaceAroundBitwiseOperator; + break; + case BinaryOperatorType.Add: + case BinaryOperatorType.Subtract: + forceSpaces = policy.SpaceAroundAdditiveOperator; + break; + case BinaryOperatorType.Multiply: + case BinaryOperatorType.Divide: + case BinaryOperatorType.Modulus: + forceSpaces = policy.SpaceAroundMultiplicativeOperator; + break; + case BinaryOperatorType.ShiftLeft: + case BinaryOperatorType.ShiftRight: + forceSpaces = policy.SpaceAroundShiftOperator; + break; + case BinaryOperatorType.NullCoalescing: + forceSpaces = policy.SpaceAroundNullCoalescingOperator; + break; + } + ForceSpacesAround(binaryOperatorExpression.OperatorToken, forceSpaces); + + base.VisitBinaryOperatorExpression(binaryOperatorExpression); + // Handle line breaks in binary opeartor expression. + if (binaryOperatorExpression.Left.EndLocation.Line != binaryOperatorExpression.Right.StartLocation.Line) { + curIndent.Push(IndentType.Block); + if (binaryOperatorExpression.OperatorToken.StartLocation.Line == binaryOperatorExpression.Right.StartLocation.Line) { + FixStatementIndentation(binaryOperatorExpression.OperatorToken.StartLocation); + } else { + FixStatementIndentation(binaryOperatorExpression.Right.StartLocation); + } + curIndent.Pop (); + } + } + + public override void VisitConditionalExpression(ConditionalExpression conditionalExpression) + { + ForceSpacesBefore(conditionalExpression.QuestionMarkToken, policy.SpaceBeforeConditionalOperatorCondition); + ForceSpacesAfter(conditionalExpression.QuestionMarkToken, policy.SpaceAfterConditionalOperatorCondition); + ForceSpacesBefore(conditionalExpression.ColonToken, policy.SpaceBeforeConditionalOperatorSeparator); + ForceSpacesAfter(conditionalExpression.ColonToken, policy.SpaceAfterConditionalOperatorSeparator); + base.VisitConditionalExpression(conditionalExpression); + } + + public override void VisitCastExpression(CastExpression castExpression) { if (castExpression.RParToken != null) { - ForceSpacesAfter (castExpression.LParToken, policy.SpacesWithinCastParentheses); - ForceSpacesBefore (castExpression.RParToken, policy.SpacesWithinCastParentheses); + ForceSpacesAfter(castExpression.LParToken, policy.SpacesWithinCastParentheses); + ForceSpacesBefore(castExpression.RParToken, policy.SpacesWithinCastParentheses); - ForceSpacesAfter (castExpression.RParToken, policy.SpaceAfterTypecast); + ForceSpacesAfter(castExpression.RParToken, policy.SpaceAfterTypecast); } - return base.VisitCastExpression (castExpression, data); + base.VisitCastExpression(castExpression); } - void ForceSpacesAround (AstNode node, bool forceSpaces) + void ForceSpacesAround(AstNode node, bool forceSpaces) { - if (node.IsNull) + if (node.IsNull) { return; - ForceSpacesBefore (node, forceSpaces); - ForceSpacesAfter (node, forceSpaces); + } + ForceSpacesBefore(node, forceSpaces); + ForceSpacesAfter(node, forceSpaces); } - void FormatCommas (AstNode parent, bool before, bool after) + void FormatCommas(AstNode parent, bool before, bool after) { - if (parent.IsNull) + if (parent.IsNull) { return; - foreach (CSharpTokenNode comma in parent.Children.Where (node => node.Role == FieldDeclaration.Roles.Comma)) { - ForceSpacesAfter (comma, after); - ForceSpacesBefore (comma, before); + } + foreach (CSharpTokenNode comma in parent.Children.Where (node => node.Role == Roles.Comma)) { + ForceSpacesAfter(comma, after); + ForceSpacesBefore(comma, before); } } - public override object VisitInvocationExpression (InvocationExpression invocationExpression, object data) + public override void VisitInvocationExpression(InvocationExpression invocationExpression) { - ForceSpacesBefore (invocationExpression.LParToken, policy.SpaceBeforeMethodCallParentheses); - if (invocationExpression.Arguments.Any ()) { - ForceSpacesAfter (invocationExpression.LParToken, policy.SpaceWithinMethodCallParentheses); - ForceSpacesBefore (invocationExpression.RParToken, policy.SpaceWithinMethodCallParentheses); + ForceSpacesBefore(invocationExpression.LParToken, policy.SpaceBeforeMethodCallParentheses); + if (invocationExpression.Arguments.Any()) { + ForceSpacesAfter(invocationExpression.LParToken, policy.SpaceWithinMethodCallParentheses); + ForceSpacesBefore(invocationExpression.RParToken, policy.SpaceWithinMethodCallParentheses); } else { - ForceSpacesAfter (invocationExpression.LParToken, policy.SpaceBetweenEmptyMethodCallParentheses); - ForceSpacesBefore (invocationExpression.RParToken, policy.SpaceBetweenEmptyMethodCallParentheses); + ForceSpacesAfter(invocationExpression.LParToken, policy.SpaceBetweenEmptyMethodCallParentheses); + ForceSpacesBefore(invocationExpression.RParToken, policy.SpaceBetweenEmptyMethodCallParentheses); } - FormatCommas (invocationExpression, policy.SpaceBeforeMethodCallParameterComma, policy.SpaceAfterMethodCallParameterComma); + FormatCommas(invocationExpression, policy.SpaceBeforeMethodCallParameterComma, policy.SpaceAfterMethodCallParameterComma); - return base.VisitInvocationExpression (invocationExpression, data); + base.VisitInvocationExpression(invocationExpression); } - public override object VisitIndexerExpression (IndexerExpression indexerExpression, object data) + public override void VisitIndexerExpression(IndexerExpression indexerExpression) { - ForceSpacesBefore (indexerExpression.LBracketToken, policy.SpacesBeforeBrackets); - ForceSpacesAfter (indexerExpression.LBracketToken, policy.SpacesWithinBrackets); - ForceSpacesBefore (indexerExpression.RBracketToken, policy.SpacesWithinBrackets); - FormatCommas (indexerExpression, policy.SpaceBeforeBracketComma, policy.SpaceAfterBracketComma); + ForceSpacesBefore(indexerExpression.LBracketToken, policy.SpacesBeforeBrackets); + ForceSpacesAfter(indexerExpression.LBracketToken, policy.SpacesWithinBrackets); + ForceSpacesBefore(indexerExpression.RBracketToken, policy.SpacesWithinBrackets); + FormatCommas(indexerExpression, policy.SpaceBeforeBracketComma, policy.SpaceAfterBracketComma); - return base.VisitIndexerExpression (indexerExpression, data); + base.VisitIndexerExpression(indexerExpression); } - public override object VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, object data) + public override void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression) { - ForceSpacesAfter (parenthesizedExpression.LParToken, policy.SpacesWithinParentheses); - ForceSpacesBefore (parenthesizedExpression.RParToken, policy.SpacesWithinParentheses); - return base.VisitParenthesizedExpression (parenthesizedExpression, data); + ForceSpacesAfter(parenthesizedExpression.LParToken, policy.SpacesWithinParentheses); + ForceSpacesBefore(parenthesizedExpression.RParToken, policy.SpacesWithinParentheses); + base.VisitParenthesizedExpression(parenthesizedExpression); } - public override object VisitSizeOfExpression (SizeOfExpression sizeOfExpression, object data) + public override void VisitSizeOfExpression(SizeOfExpression sizeOfExpression) { - ForceSpacesBefore (sizeOfExpression.LParToken, policy.SpaceBeforeSizeOfParentheses); - ForceSpacesAfter (sizeOfExpression.LParToken, policy.SpacesWithinSizeOfParentheses); - ForceSpacesBefore (sizeOfExpression.RParToken, policy.SpacesWithinSizeOfParentheses); - return base.VisitSizeOfExpression (sizeOfExpression, data); + ForceSpacesBefore(sizeOfExpression.LParToken, policy.SpaceBeforeSizeOfParentheses); + ForceSpacesAfter(sizeOfExpression.LParToken, policy.SpacesWithinSizeOfParentheses); + ForceSpacesBefore(sizeOfExpression.RParToken, policy.SpacesWithinSizeOfParentheses); + base.VisitSizeOfExpression(sizeOfExpression); } - public override object VisitTypeOfExpression (TypeOfExpression typeOfExpression, object data) + public override void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { - ForceSpacesBefore (typeOfExpression.LParToken, policy.SpaceBeforeTypeOfParentheses); - ForceSpacesAfter (typeOfExpression.LParToken, policy.SpacesWithinTypeOfParentheses); - ForceSpacesBefore (typeOfExpression.RParToken, policy.SpacesWithinTypeOfParentheses); - return base.VisitTypeOfExpression (typeOfExpression, data); + ForceSpacesBefore(typeOfExpression.LParToken, policy.SpaceBeforeTypeOfParentheses); + ForceSpacesAfter(typeOfExpression.LParToken, policy.SpacesWithinTypeOfParentheses); + ForceSpacesBefore(typeOfExpression.RParToken, policy.SpacesWithinTypeOfParentheses); + base.VisitTypeOfExpression(typeOfExpression); } - public override object VisitCheckedExpression (CheckedExpression checkedExpression, object data) + public override void VisitCheckedExpression(CheckedExpression checkedExpression) { - ForceSpacesAfter (checkedExpression.LParToken, policy.SpacesWithinCheckedExpressionParantheses); - ForceSpacesBefore (checkedExpression.RParToken, policy.SpacesWithinCheckedExpressionParantheses); - return base.VisitCheckedExpression (checkedExpression, data); + ForceSpacesAfter(checkedExpression.LParToken, policy.SpacesWithinCheckedExpressionParantheses); + ForceSpacesBefore(checkedExpression.RParToken, policy.SpacesWithinCheckedExpressionParantheses); + base.VisitCheckedExpression(checkedExpression); } - public override object VisitUncheckedExpression (UncheckedExpression uncheckedExpression, object data) + public override void VisitUncheckedExpression(UncheckedExpression uncheckedExpression) { - ForceSpacesAfter (uncheckedExpression.LParToken, policy.SpacesWithinCheckedExpressionParantheses); - ForceSpacesBefore (uncheckedExpression.RParToken, policy.SpacesWithinCheckedExpressionParantheses); - return base.VisitUncheckedExpression (uncheckedExpression, data); + ForceSpacesAfter(uncheckedExpression.LParToken, policy.SpacesWithinCheckedExpressionParantheses); + ForceSpacesBefore(uncheckedExpression.RParToken, policy.SpacesWithinCheckedExpressionParantheses); + base.VisitUncheckedExpression(uncheckedExpression); } - public override object VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, object data) + public override void VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression) { - ForceSpacesBefore (objectCreateExpression.LParToken, policy.SpaceBeforeNewParentheses); + ForceSpacesBefore(objectCreateExpression.LParToken, policy.SpaceBeforeNewParentheses); - if (objectCreateExpression.Arguments.Any ()) { - if (!objectCreateExpression.LParToken.IsNull) - ForceSpacesAfter (objectCreateExpression.LParToken, policy.SpacesWithinNewParentheses); - if (!objectCreateExpression.RParToken.IsNull) - ForceSpacesBefore (objectCreateExpression.RParToken, policy.SpacesWithinNewParentheses); + if (objectCreateExpression.Arguments.Any()) { + if (!objectCreateExpression.LParToken.IsNull) { + ForceSpacesAfter(objectCreateExpression.LParToken, policy.SpacesWithinNewParentheses); + } + if (!objectCreateExpression.RParToken.IsNull) { + ForceSpacesBefore(objectCreateExpression.RParToken, policy.SpacesWithinNewParentheses); + } } else { - if (!objectCreateExpression.LParToken.IsNull) - ForceSpacesAfter (objectCreateExpression.LParToken, policy.SpacesBetweenEmptyNewParentheses); - if (!objectCreateExpression.RParToken.IsNull) - ForceSpacesBefore (objectCreateExpression.RParToken, policy.SpacesBetweenEmptyNewParentheses); + if (!objectCreateExpression.LParToken.IsNull) { + ForceSpacesAfter(objectCreateExpression.LParToken, policy.SpacesBetweenEmptyNewParentheses); + } + if (!objectCreateExpression.RParToken.IsNull) { + ForceSpacesBefore(objectCreateExpression.RParToken, policy.SpacesBetweenEmptyNewParentheses); + } } - FormatCommas (objectCreateExpression, policy.SpaceBeforeNewParameterComma, policy.SpaceAfterNewParameterComma); + FormatCommas(objectCreateExpression, policy.SpaceBeforeNewParameterComma, policy.SpaceAfterNewParameterComma); - return base.VisitObjectCreateExpression (objectCreateExpression, data); + base.VisitObjectCreateExpression(objectCreateExpression); } - public override object VisitArrayCreateExpression (ArrayCreateExpression arrayObjectCreateExpression, object data) + public override void VisitArrayCreateExpression(ArrayCreateExpression arrayObjectCreateExpression) { - FormatCommas (arrayObjectCreateExpression, policy.SpaceBeforeMethodCallParameterComma, policy.SpaceAfterMethodCallParameterComma); - return base.VisitArrayCreateExpression (arrayObjectCreateExpression, data); + FormatCommas(arrayObjectCreateExpression, policy.SpaceBeforeMethodCallParameterComma, policy.SpaceAfterMethodCallParameterComma); + base.VisitArrayCreateExpression(arrayObjectCreateExpression); } - public override object VisitLambdaExpression (LambdaExpression lambdaExpression, object data) + public override void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression) { - ForceSpacesAfter (lambdaExpression.ArrowToken, true); - ForceSpacesBefore (lambdaExpression.ArrowToken, true); + if (policy.ArrayInitializerWrapping == Wrapping.WrapAlways) { + EnforceBraceStyle(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.LBraceToken, arrayInitializerExpression.RBraceToken); + curIndent.Push(IndentType.Block); + foreach (var init in arrayInitializerExpression.Elements) { + FixStatementIndentation(init.StartLocation); + init.AcceptVisitor(this); + } + curIndent.Pop(); + } else if (policy.ArrayInitializerWrapping == Wrapping.DoNotWrap) { + ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.LBraceToken); + ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.RBraceToken); + foreach (var init in arrayInitializerExpression.Elements) { + ForceSpacesBeforeRemoveNewLines(init); + init.AcceptVisitor(this); + } + } else { + base.VisitArrayInitializerExpression(arrayInitializerExpression); + } + } + + public override void VisitLambdaExpression(LambdaExpression lambdaExpression) + { + ForceSpacesAfter(lambdaExpression.ArrowToken, true); + ForceSpacesBefore(lambdaExpression.ArrowToken, true); - return base.VisitLambdaExpression (lambdaExpression, data); + base.VisitLambdaExpression(lambdaExpression); + } + + public override void VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression) + { + ForceSpacesAfter(namedArgumentExpression.ColonToken, policy.SpaceInNamedArgumentAfterDoubleColon); + base.VisitNamedArgumentExpression(namedArgumentExpression); } #endregion - void ForceSpaceBefore (int offset, bool forceSpace) + void ForceSpaceBefore(int offset, bool forceSpace) { bool insertedSpace = false; do { - char ch = document.GetCharAt (offset); + char ch = document.GetCharAt(offset); //Console.WriteLine (ch); - if (!IsSpacing (ch) && (insertedSpace || !forceSpace)) + if (!IsSpacing(ch) && (insertedSpace || !forceSpace)) { break; + } if (ch == ' ' && forceSpace) { if (insertedSpace) { - AddChange (offset, 1, null); + AddChange(offset, 1, null); } else { insertedSpace = true; } } else if (forceSpace) { if (!insertedSpace) { - AddChange (offset, IsSpacing (ch) ? 1 : 0, " "); + AddChange(offset, IsSpacing(ch) ? 1 : 0, " "); insertedSpace = true; - } else if (IsSpacing (ch)) { - AddChange (offset, 1, null); + } else if (IsSpacing(ch)) { + AddChange(offset, 1, null); } } @@ -1554,90 +1786,93 @@ namespace ICSharpCode.NRefactory.CSharp } return result; } - */ + */ - public void FixSemicolon (CSharpTokenNode semicolon) + public void FixSemicolon(CSharpTokenNode semicolon) { - if (semicolon.IsNull) + if (semicolon.IsNull) { return; - int endOffset = document.GetOffset (semicolon.StartLocation); + } + int endOffset = document.GetOffset(semicolon.StartLocation); int offset = endOffset; while (offset - 1 > 0 && char.IsWhiteSpace (document.GetCharAt (offset - 1))) { offset--; } if (offset < endOffset) { - AddChange (offset, endOffset - offset, null); + AddChange(offset, endOffset - offset, null); } - } + } - void PlaceOnNewLine (bool newLine, AstNode keywordNode) + void PlaceOnNewLine(bool newLine, AstNode keywordNode) { - if (keywordNode == null) + if (keywordNode == null) { return; - int offset = document.GetOffset (keywordNode.StartLocation); + } + int offset = document.GetOffset(keywordNode.StartLocation); - int whitespaceStart = SearchWhitespaceStart (offset); - string indentString = newLine ? this.EolMarker + this.curIndent.IndentString : " "; - AddChange (whitespaceStart, offset - whitespaceStart, indentString); + int whitespaceStart = SearchWhitespaceStart(offset); + string indentString = newLine ? this.options.EolMarker + this.curIndent.IndentString : " "; + AddChange(whitespaceStart, offset - whitespaceStart, indentString); } string nextStatementIndent = null; - void FixStatementIndentation (TextLocation location) + void FixStatementIndentation(TextLocation location) { - int offset = document.GetOffset (location); + int offset = document.GetOffset(location); if (offset <= 0) { - Console.WriteLine ("possible wrong offset"); - Console.WriteLine (Environment.StackTrace); + Console.WriteLine("possible wrong offset"); + Console.WriteLine(Environment.StackTrace); return; } - bool isEmpty = IsLineIsEmptyUpToEol (offset); - int lineStart = SearchWhitespaceLineStart (offset); - string indentString = nextStatementIndent == null ? (isEmpty ? "" : this.EolMarker) + this.curIndent.IndentString : nextStatementIndent; + bool isEmpty = IsLineIsEmptyUpToEol(offset); + int lineStart = SearchWhitespaceLineStart(offset); + string indentString = nextStatementIndent == null ? (isEmpty ? "" : this.options.EolMarker) + this.curIndent.IndentString : nextStatementIndent; nextStatementIndent = null; - AddChange (lineStart, offset - lineStart, indentString); + AddChange(lineStart, offset - lineStart, indentString); } - void FixIndentation (TextLocation location) + void FixIndentation(TextLocation location) { - FixIndentation (location, 0); + FixIndentation(location, 0); } - void FixIndentation (TextLocation location, int relOffset) + void FixIndentation(TextLocation location, int relOffset) { if (location.Line < 1 || location.Line > document.LineCount) { - Console.WriteLine ("Invalid location " + location); - Console.WriteLine (Environment.StackTrace); + Console.WriteLine("Invalid location " + location); + Console.WriteLine(Environment.StackTrace); return; } - - string lineIndent = GetIndentation (location.Line); + + string lineIndent = GetIndentation(location.Line); string indentString = this.curIndent.IndentString; if (indentString != lineIndent && location.Column - 1 + relOffset == lineIndent.Length) { - AddChange (document.GetOffset (location.Line, 1), lineIndent.Length, indentString); + AddChange(document.GetOffset(location.Line, 1), lineIndent.Length, indentString); } } - void FixIndentationForceNewLine (TextLocation location) + void FixIndentationForceNewLine(TextLocation location) { - string lineIndent = GetIndentation (location.Line); + string lineIndent = GetIndentation(location.Line); string indentString = this.curIndent.IndentString; if (location.Column - 1 == lineIndent.Length) { - AddChange (document.GetOffset (location.Line, 1), lineIndent.Length, indentString); - } else { - int offset = document.GetOffset (location); - int start = SearchWhitespaceLineStart (offset); - if (start > 0) { - char ch = document.GetCharAt (start - 1); + AddChange(document.GetOffset(location.Line, 1), lineIndent.Length, indentString); + } else { + int offset = document.GetOffset(location); + int start = SearchWhitespaceLineStart(offset); + if (start > 0) { + char ch = document.GetCharAt(start - 1); if (ch == '\n') { start--; - if (start > 1 && document.GetCharAt (start - 1) == '\r') + if (start > 1 && document.GetCharAt(start - 1) == '\r') { start--; + } } else if (ch == '\r') { start--; } - AddChange (start, offset - start, this.EolMarker + indentString); + AddChange(start, offset - start, this.options.EolMarker + indentString); } } } @@ -1645,15 +1880,17 @@ namespace ICSharpCode.NRefactory.CSharp string GetIndentation(int lineNumber) { IDocumentLine line = document.GetLineByNumber(lineNumber); - StringBuilder b = new StringBuilder(); + StringBuilder b = new StringBuilder (); int endOffset = line.EndOffset; for (int i = line.Offset; i < endOffset; i++) { char c = document.GetCharAt(i); - if (!IsSpacing(c)) + if (!IsSpacing(c)) { break; + } b.Append(c); } return b.ToString(); } } } + diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs b/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs index 17c4a5899..0cf8d42a0 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs @@ -37,7 +37,8 @@ namespace ICSharpCode.NRefactory.CSharp EndOfLineWithoutSpace, NextLine, NextLineShifted, - NextLineShifted2 + NextLineShifted2, + BannerStyle } public enum BraceForcement @@ -47,12 +48,6 @@ namespace ICSharpCode.NRefactory.CSharp AddBraces } - public enum ArrayInitializerPlacement - { - AlwaysNewLine, - AlwaysSameLine - } - public enum PropertyFormatting { AllowOneLine, @@ -60,6 +55,12 @@ namespace ICSharpCode.NRefactory.CSharp ForceNewLine } + public enum Wrapping { + DoNotWrap, + WrapAlways, + WrapIfTooLong + } + public class CSharpFormattingOptions { public string Name { @@ -321,11 +322,6 @@ namespace ICSharpCode.NRefactory.CSharp get; set; } - - public ArrayInitializerPlacement PlaceArrayInitializersOnNewLine { - get; - set; - } #endregion #region Spaces @@ -726,6 +722,10 @@ namespace ICSharpCode.NRefactory.CSharp set; } + public bool SpaceInNamedArgumentAfterDoubleColon { + get; + set; + } #endregion #region Blank Lines @@ -765,119 +765,31 @@ namespace ICSharpCode.NRefactory.CSharp } #endregion - - public CSharpFormattingOptions () + + + #region Keep formatting + public bool KeepCommentsAtFirstColumn { + get; + set; + } + #endregion + + #region Wrapping + + public Wrapping ArrayInitializerWrapping { + get; + set; + } + + public BraceStyle ArrayInitializerBraceStyle { + get; + set; + } + + #endregion + + internal CSharpFormattingOptions() { - IndentNamespaceBody = true; - IndentClassBody = IndentInterfaceBody = IndentStructBody = IndentEnumBody = true; - IndentMethodBody = IndentPropertyBody = IndentEventBody = true; - IndentBlocks = true; - IndentSwitchBody = false; - IndentCaseBody = true; - IndentBreakStatements = true; - NamespaceBraceStyle = BraceStyle.NextLine; - ClassBraceStyle = InterfaceBraceStyle = StructBraceStyle = EnumBraceStyle = BraceStyle.NextLine; - MethodBraceStyle = ConstructorBraceStyle = DestructorBraceStyle = BraceStyle.NextLine; - AnonymousMethodBraceStyle = BraceStyle.EndOfLine; - - PropertyBraceStyle = PropertyGetBraceStyle = PropertySetBraceStyle = BraceStyle.EndOfLine; - AllowPropertyGetBlockInline = AllowPropertySetBlockInline = true; - - EventBraceStyle = EventAddBraceStyle = EventRemoveBraceStyle = BraceStyle.EndOfLine; - AllowEventAddBlockInline = AllowEventRemoveBlockInline = true; - StatementBraceStyle = BraceStyle.EndOfLine; - - PlaceElseOnNewLine = false; - PlaceCatchOnNewLine = false; - PlaceFinallyOnNewLine = false; - PlaceWhileOnNewLine = false; - PlaceArrayInitializersOnNewLine = ArrayInitializerPlacement.AlwaysSameLine; - - SpaceBeforeMethodCallParentheses = true; - SpaceBeforeMethodDeclarationParentheses = true; - SpaceBeforeConstructorDeclarationParentheses = true; - SpaceBeforeDelegateDeclarationParentheses = true; - SpaceAfterMethodCallParameterComma = true; - SpaceAfterConstructorDeclarationParameterComma = true; - - SpaceBeforeNewParentheses = true; - SpacesWithinNewParentheses = false; - SpacesBetweenEmptyNewParentheses = false; - SpaceBeforeNewParameterComma = false; - SpaceAfterNewParameterComma = true; - - SpaceBeforeIfParentheses = true; - SpaceBeforeWhileParentheses = true; - SpaceBeforeForParentheses = true; - SpaceBeforeForeachParentheses = true; - SpaceBeforeCatchParentheses = true; - SpaceBeforeSwitchParentheses = true; - SpaceBeforeLockParentheses = true; - SpaceBeforeUsingParentheses = true; - SpaceAroundAssignment = true; - SpaceAroundLogicalOperator = true; - SpaceAroundEqualityOperator = true; - SpaceAroundRelationalOperator = true; - SpaceAroundBitwiseOperator = true; - SpaceAroundAdditiveOperator = true; - SpaceAroundMultiplicativeOperator = true; - SpaceAroundShiftOperator = true; - SpaceAroundNullCoalescingOperator = true; - SpacesWithinParentheses = false; - SpaceWithinMethodCallParentheses = false; - SpaceWithinMethodDeclarationParentheses = false; - SpacesWithinIfParentheses = false; - SpacesWithinWhileParentheses = false; - SpacesWithinForParentheses = false; - SpacesWithinForeachParentheses = false; - SpacesWithinCatchParentheses = false; - SpacesWithinSwitchParentheses = false; - SpacesWithinLockParentheses = false; - SpacesWithinUsingParentheses = false; - SpacesWithinCastParentheses = false; - SpacesWithinSizeOfParentheses = false; - SpacesWithinTypeOfParentheses = false; - SpacesWithinCheckedExpressionParantheses = false; - SpaceBeforeConditionalOperatorCondition = true; - SpaceAfterConditionalOperatorCondition = true; - SpaceBeforeConditionalOperatorSeparator = true; - SpaceAfterConditionalOperatorSeparator = true; - - SpacesWithinBrackets = false; - SpacesBeforeBrackets = true; - SpaceBeforeBracketComma = false; - SpaceAfterBracketComma = true; - - SpaceBeforeForSemicolon = false; - SpaceAfterForSemicolon = true; - SpaceAfterTypecast = false; - - AlignEmbeddedIfStatements = true; - AlignEmbeddedUsingStatements = true; - PropertyFormatting = PropertyFormatting.AllowOneLine; - SpaceBeforeMethodDeclarationParameterComma = false; - SpaceAfterMethodDeclarationParameterComma = true; - SpaceBeforeFieldDeclarationComma = false; - SpaceAfterFieldDeclarationComma = true; - SpaceBeforeLocalVariableDeclarationComma = false; - SpaceAfterLocalVariableDeclarationComma = true; - - SpaceBeforeIndexerDeclarationBracket = true; - SpaceWithinIndexerDeclarationBracket = false; - SpaceBeforeIndexerDeclarationParameterComma = false; - - - SpaceAfterIndexerDeclarationParameterComma = true; - - BlankLinesBeforeUsings = 0; - BlankLinesAfterUsings = 1; - - - BlankLinesBeforeFirstDeclaration = 0; - BlankLinesBetweenTypes = 1; - BlankLinesBetweenFields = 0; - BlankLinesBetweenEventFields = 0; - BlankLinesBetweenMembers = 1; } /*public static CSharpFormattingOptions Load (FilePath selectedFile) @@ -889,7 +801,7 @@ namespace ICSharpCode.NRefactory.CSharp public static CSharpFormattingOptions Load (System.IO.Stream input) { - CSharpFormattingOptions result = new CSharpFormattingOptions (); + CSharpFormattingOptions result = FormattingOptionsFactory.CreateMonoOptions (); result.Name = "noname"; using (XmlTextReader reader = new XmlTextReader (input)) { while (reader.Read ()) { diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/FormattingOptionsFactory.cs b/ICSharpCode.NRefactory.CSharp/Formatter/FormattingOptionsFactory.cs new file mode 100644 index 000000000..331a1579c --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Formatter/FormattingOptionsFactory.cs @@ -0,0 +1,339 @@ +// +// FormattingOptionsFactory.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin Inc. (http://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 +{ + /// + /// The formatting options factory creates pre defined formatting option styles. + /// + public static class FormattingOptionsFactory + { + /// + /// Creates empty CSharpFormatting options. + /// + public static CSharpFormattingOptions CreateEmpty() + { + return new CSharpFormattingOptions(); + } + + /// + /// Creates mono indent style CSharpFormatting options. + /// + public static CSharpFormattingOptions CreateMono() + { + return new CSharpFormattingOptions() { + IndentNamespaceBody = true, + IndentClassBody = true, + IndentInterfaceBody = true, + IndentStructBody = true, + IndentEnumBody = true, + IndentMethodBody = true, + IndentPropertyBody = true, + IndentEventBody = true, + IndentBlocks = true, + IndentSwitchBody = false, + IndentCaseBody = true, + IndentBreakStatements = true, + NamespaceBraceStyle = BraceStyle.NextLine, + ClassBraceStyle = BraceStyle.NextLine, + InterfaceBraceStyle = BraceStyle.NextLine, + StructBraceStyle = BraceStyle.NextLine, + EnumBraceStyle = BraceStyle.NextLine, + MethodBraceStyle = BraceStyle.NextLine, + ConstructorBraceStyle = BraceStyle.NextLine, + DestructorBraceStyle = BraceStyle.NextLine, + AnonymousMethodBraceStyle = BraceStyle.EndOfLine, + + PropertyBraceStyle = BraceStyle.EndOfLine, + PropertyGetBraceStyle = BraceStyle.EndOfLine, + PropertySetBraceStyle = BraceStyle.EndOfLine, + AllowPropertyGetBlockInline = true, + AllowPropertySetBlockInline = true, + + EventBraceStyle = BraceStyle.EndOfLine, + EventAddBraceStyle = BraceStyle.EndOfLine, + EventRemoveBraceStyle = BraceStyle.EndOfLine, + AllowEventAddBlockInline = true, + AllowEventRemoveBlockInline = true, + StatementBraceStyle = BraceStyle.EndOfLine, + + PlaceElseOnNewLine = false, + PlaceCatchOnNewLine = false, + PlaceFinallyOnNewLine = false, + PlaceWhileOnNewLine = false, + ArrayInitializerWrapping = Wrapping.WrapIfTooLong, + ArrayInitializerBraceStyle = BraceStyle.EndOfLine, + + SpaceBeforeMethodCallParentheses = true, + SpaceBeforeMethodDeclarationParentheses = true, + SpaceBeforeConstructorDeclarationParentheses = true, + SpaceBeforeDelegateDeclarationParentheses = true, + SpaceAfterMethodCallParameterComma = true, + SpaceAfterConstructorDeclarationParameterComma = true, + + SpaceBeforeNewParentheses = true, + SpacesWithinNewParentheses = false, + SpacesBetweenEmptyNewParentheses = false, + SpaceBeforeNewParameterComma = false, + SpaceAfterNewParameterComma = true, + + SpaceBeforeIfParentheses = true, + SpaceBeforeWhileParentheses = true, + SpaceBeforeForParentheses = true, + SpaceBeforeForeachParentheses = true, + SpaceBeforeCatchParentheses = true, + SpaceBeforeSwitchParentheses = true, + SpaceBeforeLockParentheses = true, + SpaceBeforeUsingParentheses = true, + SpaceAroundAssignment = true, + SpaceAroundLogicalOperator = true, + SpaceAroundEqualityOperator = true, + SpaceAroundRelationalOperator = true, + SpaceAroundBitwiseOperator = true, + SpaceAroundAdditiveOperator = true, + SpaceAroundMultiplicativeOperator = true, + SpaceAroundShiftOperator = true, + SpaceAroundNullCoalescingOperator = true, + SpacesWithinParentheses = false, + SpaceWithinMethodCallParentheses = false, + SpaceWithinMethodDeclarationParentheses = false, + SpacesWithinIfParentheses = false, + SpacesWithinWhileParentheses = false, + SpacesWithinForParentheses = false, + SpacesWithinForeachParentheses = false, + SpacesWithinCatchParentheses = false, + SpacesWithinSwitchParentheses = false, + SpacesWithinLockParentheses = false, + SpacesWithinUsingParentheses = false, + SpacesWithinCastParentheses = false, + SpacesWithinSizeOfParentheses = false, + SpacesWithinTypeOfParentheses = false, + SpacesWithinCheckedExpressionParantheses = false, + SpaceBeforeConditionalOperatorCondition = true, + SpaceAfterConditionalOperatorCondition = true, + SpaceBeforeConditionalOperatorSeparator = true, + SpaceAfterConditionalOperatorSeparator = true, + + SpacesWithinBrackets = false, + SpacesBeforeBrackets = true, + SpaceBeforeBracketComma = false, + SpaceAfterBracketComma = true, + + SpaceBeforeForSemicolon = false, + SpaceAfterForSemicolon = true, + SpaceAfterTypecast = false, + + AlignEmbeddedIfStatements = true, + AlignEmbeddedUsingStatements = true, + PropertyFormatting = PropertyFormatting.AllowOneLine, + SpaceBeforeMethodDeclarationParameterComma = false, + SpaceAfterMethodDeclarationParameterComma = true, + SpaceBeforeFieldDeclarationComma = false, + SpaceAfterFieldDeclarationComma = true, + SpaceBeforeLocalVariableDeclarationComma = false, + SpaceAfterLocalVariableDeclarationComma = true, + + SpaceBeforeIndexerDeclarationBracket = true, + SpaceWithinIndexerDeclarationBracket = false, + SpaceBeforeIndexerDeclarationParameterComma = false, + SpaceInNamedArgumentAfterDoubleColon = true, + + SpaceAfterIndexerDeclarationParameterComma = true, + + BlankLinesBeforeUsings = 0, + BlankLinesAfterUsings = 1, + + + BlankLinesBeforeFirstDeclaration = 0, + BlankLinesBetweenTypes = 1, + BlankLinesBetweenFields = 0, + BlankLinesBetweenEventFields = 0, + BlankLinesBetweenMembers = 1, + + KeepCommentsAtFirstColumn = true, + }; + } + + /// + /// Creates sharp develop indent style CSharpFormatting options. + /// + public static CSharpFormattingOptions CreateSharpDevelop() + { + return new CSharpFormattingOptions() { + IndentNamespaceBody = true, + IndentClassBody = true, + IndentInterfaceBody = true, + IndentStructBody = true, + IndentEnumBody = true, + IndentMethodBody = true, + IndentPropertyBody = true, + IndentEventBody = true, + IndentBlocks = true, + IndentSwitchBody = true, + IndentCaseBody = true, + IndentBreakStatements = true, + + NamespaceBraceStyle = BraceStyle.NextLine, + ClassBraceStyle = BraceStyle.NextLine, + InterfaceBraceStyle = BraceStyle.NextLine, + StructBraceStyle = BraceStyle.NextLine, + EnumBraceStyle = BraceStyle.NextLine, + MethodBraceStyle = BraceStyle.NextLine, + ConstructorBraceStyle = BraceStyle.NextLine, + DestructorBraceStyle = BraceStyle.NextLine, + AnonymousMethodBraceStyle = BraceStyle.EndOfLine, + PropertyBraceStyle = BraceStyle.EndOfLine, + PropertyGetBraceStyle = BraceStyle.EndOfLine, + PropertySetBraceStyle = BraceStyle.EndOfLine, + AllowPropertyGetBlockInline = true, + AllowPropertySetBlockInline = true, + + EventBraceStyle = BraceStyle.EndOfLine, + EventAddBraceStyle = BraceStyle.EndOfLine, + EventRemoveBraceStyle = BraceStyle.EndOfLine, + AllowEventAddBlockInline = true, + AllowEventRemoveBlockInline = true, + StatementBraceStyle = BraceStyle.EndOfLine, + + PlaceElseOnNewLine = false, + PlaceCatchOnNewLine = false, + PlaceFinallyOnNewLine = false, + PlaceWhileOnNewLine = false, + ArrayInitializerWrapping = Wrapping.WrapIfTooLong, + ArrayInitializerBraceStyle = BraceStyle.EndOfLine, + + SpaceBeforeMethodCallParentheses = false, + SpaceBeforeMethodDeclarationParentheses = false, + SpaceBeforeConstructorDeclarationParentheses = false, + SpaceBeforeDelegateDeclarationParentheses = false, + SpaceAfterMethodCallParameterComma = true, + SpaceAfterConstructorDeclarationParameterComma = true, + + SpaceBeforeNewParentheses = false, + SpacesWithinNewParentheses = false, + SpacesBetweenEmptyNewParentheses = false, + SpaceBeforeNewParameterComma = false, + SpaceAfterNewParameterComma = true, + + SpaceBeforeIfParentheses = true, + SpaceBeforeWhileParentheses = true, + SpaceBeforeForParentheses = true, + SpaceBeforeForeachParentheses = true, + SpaceBeforeCatchParentheses = true, + SpaceBeforeSwitchParentheses = true, + SpaceBeforeLockParentheses = true, + SpaceBeforeUsingParentheses = true, + + SpaceAroundAssignment = true, + SpaceAroundLogicalOperator = true, + SpaceAroundEqualityOperator = true, + SpaceAroundRelationalOperator = true, + SpaceAroundBitwiseOperator = true, + SpaceAroundAdditiveOperator = true, + SpaceAroundMultiplicativeOperator = true, + SpaceAroundShiftOperator = true, + SpaceAroundNullCoalescingOperator = true, + SpacesWithinParentheses = false, + SpaceWithinMethodCallParentheses = false, + SpaceWithinMethodDeclarationParentheses = false, + SpacesWithinIfParentheses = false, + SpacesWithinWhileParentheses = false, + SpacesWithinForParentheses = false, + SpacesWithinForeachParentheses = false, + SpacesWithinCatchParentheses = false, + SpacesWithinSwitchParentheses = false, + SpacesWithinLockParentheses = false, + SpacesWithinUsingParentheses = false, + SpacesWithinCastParentheses = false, + SpacesWithinSizeOfParentheses = false, + SpacesWithinTypeOfParentheses = false, + SpacesWithinCheckedExpressionParantheses = false, + SpaceBeforeConditionalOperatorCondition = true, + SpaceAfterConditionalOperatorCondition = true, + SpaceBeforeConditionalOperatorSeparator = true, + SpaceAfterConditionalOperatorSeparator = true, + + SpacesWithinBrackets = false, + SpacesBeforeBrackets = true, + SpaceBeforeBracketComma = false, + SpaceAfterBracketComma = true, + + SpaceBeforeForSemicolon = false, + SpaceAfterForSemicolon = true, + SpaceAfterTypecast = false, + + AlignEmbeddedIfStatements = true, + AlignEmbeddedUsingStatements = true, + PropertyFormatting = PropertyFormatting.AllowOneLine, + SpaceBeforeMethodDeclarationParameterComma = false, + SpaceAfterMethodDeclarationParameterComma = true, + SpaceBeforeFieldDeclarationComma = false, + SpaceAfterFieldDeclarationComma = true, + SpaceBeforeLocalVariableDeclarationComma = false, + SpaceAfterLocalVariableDeclarationComma = true, + + SpaceBeforeIndexerDeclarationBracket = true, + SpaceWithinIndexerDeclarationBracket = false, + SpaceBeforeIndexerDeclarationParameterComma = false, + SpaceInNamedArgumentAfterDoubleColon = true, + + SpaceAfterIndexerDeclarationParameterComma = true, + + BlankLinesBeforeUsings = 0, + BlankLinesAfterUsings = 1, + + BlankLinesBeforeFirstDeclaration = 0, + BlankLinesBetweenTypes = 1, + BlankLinesBetweenFields = 0, + BlankLinesBetweenEventFields = 0, + BlankLinesBetweenMembers = 1, + + KeepCommentsAtFirstColumn = true, + }; + } + + /// + /// Creates allman indent style CSharpFormatting options used in Visual Studio. + /// + public static CSharpFormattingOptions CreateAllman() + { + var baseOptions = CreateSharpDevelop(); + baseOptions.AnonymousMethodBraceStyle = BraceStyle.EndOfLine; + baseOptions.PropertyBraceStyle = BraceStyle.EndOfLine; + baseOptions.PropertyGetBraceStyle = BraceStyle.EndOfLine; + baseOptions.PropertySetBraceStyle = BraceStyle.EndOfLine; + + baseOptions.EventBraceStyle = BraceStyle.EndOfLine; + baseOptions.EventAddBraceStyle = BraceStyle.EndOfLine; + baseOptions.EventRemoveBraceStyle = BraceStyle.EndOfLine; + baseOptions.StatementBraceStyle = BraceStyle.EndOfLine; + baseOptions.ArrayInitializerBraceStyle = BraceStyle.EndOfLine; + return baseOptions; + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/GeneratedCodeSettings.cs b/ICSharpCode.NRefactory.CSharp/Formatter/GeneratedCodeSettings.cs new file mode 100644 index 000000000..827a3dc94 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Formatter/GeneratedCodeSettings.cs @@ -0,0 +1,216 @@ +// +// GeneratedCodeSettings.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin Inc. (http://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; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp +{ + public enum GeneratedCodeMember + { + Unknown, + + StaticFields, + InstanceFields, + StaticProperties, + InstanceProperties, + Indexer, + Constructors, + StaticMethods, + InstanceMethods, + StaticEvents, + InstanceEvents, + Operators, + NestedTypes + } + + public class GeneratedCodeSettings + { + List codeMemberOrder; + + public List CodeMemberOrder { + get { + return codeMemberOrder; + } + set { + codeMemberOrder = value; + } + } + + public bool GenerateCategoryComments { + get; + set; + } + + public bool SubOrderAlphabetical { + get; + set; + } + + public void Apply (AstNode rootNode) + { + if (rootNode == null) + throw new ArgumentNullException ("rootNode"); + rootNode.AcceptVisitor (new GenerateCodeVisitior (this)); + } + + public virtual string GetCategoryLabel(GeneratedCodeMember memberCategory) + { + switch (memberCategory) { + case GeneratedCodeMember.StaticFields: + return "Static Fields"; + case GeneratedCodeMember.InstanceFields: + return "Fields"; + case GeneratedCodeMember.StaticProperties: + return "Static Properties"; + case GeneratedCodeMember.InstanceProperties: + return "Properties"; + case GeneratedCodeMember.Indexer: + return "Indexer"; + case GeneratedCodeMember.Constructors: + return "Constructors"; + case GeneratedCodeMember.StaticMethods: + return "Static Methods"; + case GeneratedCodeMember.InstanceMethods: + return "Methods"; + case GeneratedCodeMember.StaticEvents: + return "Static Events"; + case GeneratedCodeMember.InstanceEvents: + return "Events"; + case GeneratedCodeMember.Operators: + return "Operators"; + case GeneratedCodeMember.NestedTypes: + return "Nested Types"; + } + return null; + } + + class GenerateCodeVisitior : DepthFirstAstVisitor + { + GeneratedCodeSettings settings; + + public GenerateCodeVisitior(GeneratedCodeSettings settings) + { + if (settings == null) + throw new ArgumentNullException("settings"); + this.settings = settings; + } + + GeneratedCodeMember GetCodeMemberCategory(EntityDeclaration x) + { + bool isStatic = x.HasModifier(Modifiers.Static) || x.HasModifier(Modifiers.Const); + if (x is FieldDeclaration) + return isStatic ? GeneratedCodeMember.StaticFields : GeneratedCodeMember.InstanceFields; + if (x is IndexerDeclaration) + return GeneratedCodeMember.Indexer; + if (x is PropertyDeclaration) + return isStatic ? GeneratedCodeMember.StaticProperties : GeneratedCodeMember.InstanceProperties; + if (x is ConstructorDeclaration || x is DestructorDeclaration) + return GeneratedCodeMember.Constructors; + if (x is MethodDeclaration) + return isStatic ? GeneratedCodeMember.StaticMethods : GeneratedCodeMember.InstanceMethods; + if (x is OperatorDeclaration) + return GeneratedCodeMember.Operators; + if (x is EventDeclaration || x is CustomEventDeclaration) + return isStatic ? GeneratedCodeMember.StaticEvents : GeneratedCodeMember.InstanceEvents; + + if (x is TypeDeclaration) + return GeneratedCodeMember.NestedTypes; + + return GeneratedCodeMember.Unknown; + } + + public override void VisitTypeDeclaration (TypeDeclaration typeDeclaration) + { + if (typeDeclaration.ClassType == ClassType.Enum) + return; + var entities = new List (typeDeclaration.Members); + entities.Sort ((x, y) => { + int i1 = settings.CodeMemberOrder.IndexOf (GetCodeMemberCategory (x)); + int i2 = settings.CodeMemberOrder.IndexOf (GetCodeMemberCategory (y)); + if (i1 != i2) + return i1.CompareTo (i2); + if (settings.SubOrderAlphabetical) + return (x.Name ?? "").CompareTo ((y.Name ?? "")); + return entities.IndexOf (x).CompareTo (entities.IndexOf (y)); + }); + typeDeclaration.Members.Clear (); + typeDeclaration.Members.AddRange (entities); + + if (settings.GenerateCategoryComments) { + var curCat = GeneratedCodeMember.Unknown; + foreach (var mem in entities) { + if (mem.NextSibling is EntityDeclaration) + mem.Parent.InsertChildAfter (mem, new UnixNewLine (), Roles.NewLine); + + var cat = GetCodeMemberCategory (mem); + if (cat == curCat) + continue; + curCat = cat; + var label = settings.GetCategoryLabel (curCat); + if (string.IsNullOrEmpty (label)) + continue; + + var cmt = new Comment ("", CommentType.SingleLine); + var cmt2 = new Comment (" " + label, CommentType.SingleLine); + var cmt3 = new Comment ("", CommentType.SingleLine); + mem.Parent.InsertChildsBefore (mem, Roles.Comment, cmt, cmt2, cmt3); + if (cmt.PrevSibling is EntityDeclaration) + mem.Parent.InsertChildBefore (cmt, new UnixNewLine (), Roles.NewLine); + + mem.Parent.InsertChildAfter (cmt3, new UnixNewLine (), Roles.NewLine); + } + } + } + } + + static Lazy defaultSettings = new Lazy( + () => new GeneratedCodeSettings() { + CodeMemberOrder = new List() { + GeneratedCodeMember.StaticFields, + GeneratedCodeMember.InstanceFields, + GeneratedCodeMember.StaticProperties, + GeneratedCodeMember.InstanceProperties, + GeneratedCodeMember.Indexer, + GeneratedCodeMember.Constructors, + GeneratedCodeMember.StaticMethods, + GeneratedCodeMember.InstanceMethods, + GeneratedCodeMember.StaticEvents, + GeneratedCodeMember.InstanceEvents, + GeneratedCodeMember.Operators, + GeneratedCodeMember.NestedTypes + }, + GenerateCategoryComments = true, + SubOrderAlphabetical = true + }); + + public static GeneratedCodeSettings Default { + get { + return defaultSettings.Value; + } + } + } +} \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs b/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs index 017d8c9b4..322aa211d 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs @@ -1,4 +1,4 @@ -// +// // Indent.cs // // Author: @@ -24,66 +24,75 @@ // 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 { + public enum IndentType { + Block, + Continuation, + Label + } + public class Indent { - public int Level { - get; - set; - } + readonly Stack indentStack = new Stack (); + readonly TextEditorOptions options; + + int curIndent; - public int ExtraSpaces { - get; - set; - } - - public bool TabsToSpaces { - get; - set; + public Indent(TextEditorOptions options) + { + this.options = options; } - public int TabSize { - get; - set; - } - public Indent () + public void Push(IndentType type) { + indentStack.Push(type); + curIndent += GetIndent(type); + Update(); } - public Indent (int level, int extraSpaces) + public void Pop() { - this.Level = level; - this.ExtraSpaces = extraSpaces; + curIndent -= GetIndent(indentStack.Pop()); + Update(); } - public static Indent operator+ (Indent left, Indent right) + int GetIndent(IndentType indentType) { - return new Indent (left.Level + right.Level, left.ExtraSpaces + right.ExtraSpaces); + switch (indentType) { + case IndentType.Block: + return options.IndentSize; + case IndentType.Continuation: + return options.ContinuationIndent; + case IndentType.Label: + return options.LabelIndent; + default: + throw new ArgumentOutOfRangeException(); + } } - public static Indent operator- (Indent left, Indent right) + void Update() { - return new Indent (left.Level - right.Level, left.ExtraSpaces - right.ExtraSpaces); - } - - public string IndentString { - get { - return (TabsToSpaces ? new string (' ', Level * TabSize) : new string ('\t', Level)) + new string (' ', ExtraSpaces); + if (options.TabsToSpaces) { + indentString = new string(' ', curIndent); + return; } + indentString = new string('\t', curIndent / options.TabSize) + new string(' ', curIndent % options.TabSize); } - public string SingleIndent { + string indentString; + public string IndentString { get { - return TabsToSpaces ? new string (' ', TabSize) : "\t"; + return indentString; } } - public override string ToString () + public override string ToString() { - return string.Format ("[Indent: Level={0}, ExtraSpaces={1}]", Level, ExtraSpaces); + return string.Format("[Indent: curIndent={0}]", curIndent); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/TextEditorOptions.cs b/ICSharpCode.NRefactory.CSharp/Formatter/TextEditorOptions.cs new file mode 100644 index 000000000..6ea176374 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Formatter/TextEditorOptions.cs @@ -0,0 +1,106 @@ +// +// TextEditorOptions.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin Inc. (http://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 +{ + /// + /// The text editor options class holds basic information about the text editor settings that influences code generation and formatting beside + /// the CSharpFormattingOptions. + /// + public class TextEditorOptions + { + public static readonly TextEditorOptions Default = new TextEditorOptions (); + + /// + /// Gets or sets a value indicating if tabs need to be replaced by spaces. If that is true, all indenting will be done with spaces only, + /// otherwise the indenting will start with tabs. + /// + public bool TabsToSpaces { + get; + set; + } + + /// + /// Gets or sets the size of the tab chacter as spaces. + /// + public int TabSize { + get; + set; + } + + /// + /// Gets or sets the size of a single indent as spaces. + /// + public int IndentSize { + get; + set; + } + + /// + /// Gets or sets the continuation indent. A continuation indent is the indent that will be put after an embedded statement that is no block. + /// + public int ContinuationIndent { + get; + set; + } + + /// + /// Gets or sets the label indent. A label indent is the indent that will be put before an label. + /// (Note: it may be negative -IndentSize would cause that labels are unindented) + /// + public int LabelIndent { + get; + set; + } + + /// + /// Gets or sets the eol marker. + /// + public string EolMarker { + get; + set; + } + + /// + /// If true blank lines will be indented up to the indent level, otherwise blank lines will have the length 0. + /// + public bool IndentBlankLines { + get; + set; + } + + public TextEditorOptions() + { + TabsToSpaces = false; + TabSize = 4; + IndentSize = 4; + ContinuationIndent = 4; + EolMarker = Environment.NewLine; + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj b/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj index 8e79d0e79..290699e9e 100644 --- a/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj +++ b/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj @@ -7,7 +7,6 @@ Library ICSharpCode.NRefactory.CSharp ICSharpCode.NRefactory.CSharp - v4.0 Properties False False @@ -31,20 +30,24 @@ ..\ICSharpCode.NRefactory\bin\Debug\ - true - Full False False DEBUG;TRACE;FULL_AST ..\ICSharpCode.NRefactory\bin\Release\ - false - PdbOnly True False TRACE;FULL_AST + + PdbOnly + false + + + full + true + @@ -56,12 +59,16 @@ + + Properties\GlobalAssemblyInfo.cs + + @@ -120,7 +127,6 @@ - @@ -154,7 +160,7 @@ - + @@ -163,7 +169,6 @@ - @@ -236,42 +241,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - + @@ -299,6 +277,7 @@ + @@ -318,6 +297,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -328,14 +380,22 @@ + + + + + + + + \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs index f35db3766..c370e58e4 100644 --- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs +++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// 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 @@ -32,175 +32,213 @@ namespace ICSharpCode.NRefactory.CSharp public ConversionFlags ConversionFlags { get; set; } #region ConvertEntity - public string ConvertEntity(IEntity e) + public string ConvertEntity(IEntity entity) { - StringWriter writer = new StringWriter(); - - if (e.EntityType == EntityType.TypeDefinition) { - ConvertTypeDeclaration((ITypeDefinition)e, writer); - } else { - ConvertMember((IMember)e, writer); - } + if (entity == null) + throw new ArgumentNullException("entity"); - return writer.ToString().TrimEnd(); + StringWriter writer = new StringWriter(); + ConvertEntity(entity, new TextWriterOutputFormatter(writer), FormattingOptionsFactory.CreateMono ()); + return writer.ToString(); } - void ConvertMember(IMember member, StringWriter writer) + public void ConvertEntity(IEntity entity, IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { + if (entity == null) + throw new ArgumentNullException("entity"); + if (formatter == null) + throw new ArgumentNullException("formatter"); + if (formattingPolicy == null) + throw new ArgumentNullException("options"); + TypeSystemAstBuilder astBuilder = CreateAstBuilder(); - astBuilder.ShowParameterNames = (ConversionFlags & ConversionFlags.ShowParameterNames) == ConversionFlags.ShowParameterNames; + EntityDeclaration node = astBuilder.ConvertEntity(entity); + PrintModifiers(node.Modifiers, formatter); - AttributedNode node = (AttributedNode)astBuilder.ConvertEntity(member); - PrintModifiers(node.Modifiers, writer); + if ((ConversionFlags & ConversionFlags.ShowDefinitionKeyword) == ConversionFlags.ShowDefinitionKeyword) { + if (node is TypeDeclaration) { + switch (((TypeDeclaration)node).ClassType) { + case ClassType.Class: + formatter.WriteKeyword("class"); + break; + case ClassType.Struct: + formatter.WriteKeyword("struct"); + break; + case ClassType.Interface: + formatter.WriteKeyword("interface"); + break; + case ClassType.Enum: + formatter.WriteKeyword("enum"); + break; + default: + throw new Exception("Invalid value for ClassType"); + } + formatter.Space(); + } else if (node is DelegateDeclaration) { + formatter.WriteKeyword("delegate"); + formatter.Space(); + } else if (node is EventDeclaration) { + formatter.WriteKeyword("event"); + formatter.Space(); + } + } if ((ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType) { - var rt = node.GetChildByRole(AstNode.Roles.Type); - if (rt != AstNode.Roles.Type.NullObject) { - writer.Write(rt.AcceptVisitor(CreatePrinter(writer), null)); - writer.Write(' '); + var rt = node.GetChildByRole(Roles.Type); + if (!rt.IsNull) { + rt.AcceptVisitor(new CSharpOutputVisitor(formatter, formattingPolicy)); + formatter.Space(); } } - WriteMemberDeclarationName(member, writer); + if (entity is ITypeDefinition) + WriteTypeDeclarationName((ITypeDefinition)entity, formatter, formattingPolicy); + else + WriteMemberDeclarationName((IMember)entity, formatter, formattingPolicy); - if ((ConversionFlags & ConversionFlags.ShowParameterList) == ConversionFlags.ShowParameterList - && member is IParameterizedMember && member.EntityType != EntityType.Property) { - writer.Write((node is IndexerDeclaration) ? '[' : '('); + if ((ConversionFlags & ConversionFlags.ShowParameterList) == ConversionFlags.ShowParameterList && HasParameters(entity)) { + formatter.WriteToken(entity.EntityType == EntityType.Indexer ? "[" : "("); bool first = true; - foreach (var param in node.GetChildrenByRole(AstNode.Roles.Parameter)) { - if (first) + foreach (var param in node.GetChildrenByRole(Roles.Parameter)) { + if (first) { first = false; - else - writer.Write(", "); - param.AcceptVisitor(CreatePrinter(writer), null); + } else { + formatter.WriteToken(","); + formatter.Space(); + } + param.AcceptVisitor(new CSharpOutputVisitor(formatter, formattingPolicy)); } - writer.Write((node is IndexerDeclaration) ? ']' : ')'); + formatter.WriteToken(entity.EntityType == EntityType.Indexer ? "]" : ")"); } - if ((ConversionFlags & ConversionFlags.ShowBody) == ConversionFlags.ShowBody) { - IProperty property = member as IProperty; + + if ((ConversionFlags & ConversionFlags.ShowBody) == ConversionFlags.ShowBody && !(node is TypeDeclaration)) { + IProperty property = entity as IProperty; if (property != null) { - writer.Write(" { "); - if (property.CanGet) - writer.Write("get; "); - if (property.CanSet) - writer.Write("set; "); - writer.Write('}'); + formatter.Space(); + formatter.WriteToken("{"); + formatter.Space(); + if (property.CanGet) { + formatter.WriteKeyword("get"); + formatter.WriteToken(";"); + formatter.Space(); + } + if (property.CanSet) { + formatter.WriteKeyword("set"); + formatter.WriteToken(";"); + formatter.Space(); + } + formatter.WriteToken("}"); } else { - writer.Write(';'); + formatter.WriteToken(";"); } } } - + + bool HasParameters(IEntity e) + { + switch (e.EntityType) { + case EntityType.TypeDefinition: + return ((ITypeDefinition)e).Kind == TypeKind.Delegate; + case EntityType.Indexer: + case EntityType.Method: + case EntityType.Operator: + case EntityType.Constructor: + case EntityType.Destructor: + return true; + default: + return false; + } + } + TypeSystemAstBuilder CreateAstBuilder() { TypeSystemAstBuilder astBuilder = new TypeSystemAstBuilder(); + astBuilder.AddAnnotations = true; astBuilder.ShowModifiers = (ConversionFlags & ConversionFlags.ShowModifiers) == ConversionFlags.ShowModifiers; astBuilder.ShowAccessibility = (ConversionFlags & ConversionFlags.ShowAccessibility) == ConversionFlags.ShowAccessibility; astBuilder.AlwaysUseShortTypeNames = (ConversionFlags & ConversionFlags.UseFullyQualifiedTypeNames) != ConversionFlags.UseFullyQualifiedTypeNames; + astBuilder.ShowParameterNames = (ConversionFlags & ConversionFlags.ShowParameterNames) == ConversionFlags.ShowParameterNames; return astBuilder; } - void ConvertTypeDeclaration(ITypeDefinition typeDef, StringWriter writer) - { - TypeSystemAstBuilder astBuilder = CreateAstBuilder(); - TypeDeclaration typeDeclaration = (TypeDeclaration)astBuilder.ConvertEntity(typeDef); - PrintModifiers(typeDeclaration.Modifiers, writer); - if ((ConversionFlags & ConversionFlags.ShowDefinitionKeyWord) == ConversionFlags.ShowDefinitionKeyWord) { - switch (typeDeclaration.ClassType) { - case ClassType.Class: - writer.Write("class"); - break; - case ClassType.Struct: - writer.Write("struct"); - break; - case ClassType.Interface: - writer.Write("interface"); - break; - case ClassType.Enum: - writer.Write("enum"); - break; - default: - throw new Exception("Invalid value for ClassType"); - } - writer.Write(' '); - } - WriteTypeDeclarationName(typeDef, writer); - } - - void WriteTypeDeclarationName(ITypeDefinition typeDef, StringWriter writer) + void WriteTypeDeclarationName(ITypeDefinition typeDef, IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); if (typeDef.DeclaringTypeDefinition != null) { - WriteTypeDeclarationName(typeDef.DeclaringTypeDefinition, writer); - writer.Write('.'); - } else if ((ConversionFlags & ConversionFlags.UseFullyQualifiedMemberNames) == ConversionFlags.UseFullyQualifiedMemberNames) { - writer.Write(typeDef.Namespace); - writer.Write('.'); + WriteTypeDeclarationName(typeDef.DeclaringTypeDefinition, formatter, formattingPolicy); + formatter.WriteToken("."); + } else if ((ConversionFlags & ConversionFlags.UseFullyQualifiedTypeNames) == ConversionFlags.UseFullyQualifiedTypeNames) { + formatter.WriteIdentifier(typeDef.Namespace); + formatter.WriteToken("."); } - writer.Write(typeDef.Name); + formatter.WriteIdentifier(typeDef.Name); if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList) { - CreatePrinter(writer).WriteTypeParameters(((TypeDeclaration)astBuilder.ConvertEntity(typeDef)).TypeParameters); + var outputVisitor = new CSharpOutputVisitor(formatter, formattingPolicy); + outputVisitor.WriteTypeParameters(astBuilder.ConvertEntity(typeDef).GetChildrenByRole(Roles.TypeParameter)); } } - void WriteMemberDeclarationName(IMember member, StringWriter writer) + void WriteMemberDeclarationName(IMember member, IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); - if ((ConversionFlags & ConversionFlags.UseFullyQualifiedMemberNames) == ConversionFlags.UseFullyQualifiedMemberNames) { - writer.Write(ConvertType(member.DeclaringType)); - writer.Write('.'); + if ((ConversionFlags & ConversionFlags.ShowDeclaringType) == ConversionFlags.ShowDeclaringType) { + ConvertType(member.DeclaringType, formatter, formattingPolicy); + formatter.WriteToken("."); } switch (member.EntityType) { case EntityType.Indexer: - writer.Write("this"); + formatter.WriteKeyword("this"); break; case EntityType.Constructor: - writer.Write(member.DeclaringType.Name); + formatter.WriteIdentifier(member.DeclaringType.Name); break; case EntityType.Destructor: - writer.Write('~'); - writer.Write(member.DeclaringType.Name); + formatter.WriteToken("~"); + formatter.WriteIdentifier(member.DeclaringType.Name); break; case EntityType.Operator: switch (member.Name) { case "op_Implicit": - writer.Write("implicit operator "); - writer.Write(ConvertType(member.ReturnType)); + formatter.WriteKeyword("implicit"); + formatter.Space(); + formatter.WriteKeyword("operator"); + formatter.Space(); + ConvertType(member.ReturnType, formatter, formattingPolicy); break; case "op_Explicit": - writer.Write("explicit operator "); - writer.Write(ConvertType(member.ReturnType)); + formatter.WriteKeyword("explicit"); + formatter.Space(); + formatter.WriteKeyword("operator"); + formatter.Space(); + ConvertType(member.ReturnType, formatter, formattingPolicy); break; default: - writer.Write("operator "); + formatter.WriteKeyword("operator"); + formatter.Space(); var operatorType = OperatorDeclaration.GetOperatorType(member.Name); if (operatorType.HasValue) - writer.Write(OperatorDeclaration.GetToken(operatorType.Value)); + formatter.WriteToken(OperatorDeclaration.GetToken(operatorType.Value)); else - writer.Write(member.Name); + formatter.WriteIdentifier(member.Name); break; } break; default: - writer.Write(member.Name); + formatter.WriteIdentifier(member.Name); break; } if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList && member.EntityType == EntityType.Method) { - CreatePrinter(writer).WriteTypeParameters(astBuilder.ConvertEntity(member).GetChildrenByRole(AstNode.Roles.TypeParameter)); + var outputVisitor = new CSharpOutputVisitor(formatter, formattingPolicy); + outputVisitor.WriteTypeParameters(astBuilder.ConvertEntity(member).GetChildrenByRole(Roles.TypeParameter)); } } - CSharpOutputVisitor CreatePrinter(StringWriter writer) - { - return new CSharpOutputVisitor(writer, new CSharpFormattingOptions()); - } - - void PrintModifiers(Modifiers modifiers, StringWriter writer) + void PrintModifiers(Modifiers modifiers, IOutputFormatter formatter) { foreach (var m in CSharpModifierToken.AllModifiers) { if ((modifiers & m) == m) { - writer.Write(CSharpModifierToken.GetModifierName(m)); - writer.Write(' '); + formatter.WriteKeyword(CSharpModifierToken.GetModifierName(m)); + formatter.Space(); } } } @@ -210,25 +248,24 @@ namespace ICSharpCode.NRefactory.CSharp { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); AstNode astNode = astBuilder.ConvertVariable(v); - CSharpFormattingOptions formatting = new CSharpFormattingOptions(); - StringWriter writer = new StringWriter(); - astNode.AcceptVisitor(new CSharpOutputVisitor(writer, formatting), null); - return writer.ToString().TrimEnd(';', '\r', '\n'); + return astNode.GetText().TrimEnd(';', '\r', '\n'); } public string ConvertType(IType type) { + if (type == null) + throw new ArgumentNullException("type"); + TypeSystemAstBuilder astBuilder = CreateAstBuilder(); AstType astType = astBuilder.ConvertType(type); - CSharpFormattingOptions formatting = new CSharpFormattingOptions(); - StringWriter writer = new StringWriter(); - astType.AcceptVisitor(new CSharpOutputVisitor(writer, formatting), null); - return writer.ToString(); + return astType.GetText(); } - public string WrapAttribute(string attribute) + public void ConvertType(IType type, IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { - return "[" + attribute + "]"; + TypeSystemAstBuilder astBuilder = CreateAstBuilder(); + AstType astType = astBuilder.ConvertType(type); + astType.AcceptVisitor(new CSharpOutputVisitor(formatter, formattingPolicy)); } public string WrapComment(string comment) diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs index d96dd3466..4ee6ad30e 100644 --- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs @@ -15,7 +15,6 @@ // 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; using System.Diagnostics; @@ -32,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Outputs the AST. /// - public class CSharpOutputVisitor : IAstVisitor + public class CSharpOutputVisitor : IAstVisitor { readonly IOutputFormatter formatter; readonly CSharpFormattingOptions policy; @@ -58,46 +57,50 @@ namespace ICSharpCode.NRefactory.CSharp public CSharpOutputVisitor (TextWriter textWriter, CSharpFormattingOptions formattingPolicy) { - if (textWriter == null) + if (textWriter == null) { throw new ArgumentNullException ("textWriter"); - if (formattingPolicy == null) + } + if (formattingPolicy == null) { throw new ArgumentNullException ("formattingPolicy"); + } this.formatter = new TextWriterOutputFormatter (textWriter); this.policy = formattingPolicy; } public CSharpOutputVisitor (IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { - if (formatter == null) + if (formatter == null) { throw new ArgumentNullException ("formatter"); - if (formattingPolicy == null) + } + if (formattingPolicy == null) { throw new ArgumentNullException ("formattingPolicy"); + } this.formatter = formatter; this.policy = formattingPolicy; } #region StartNode/EndNode - void StartNode (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); - formatter.StartNode (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); } - object EndNode (AstNode node) + void EndNode(AstNode node) { - Debug.Assert (node == containerStack.Peek ()); - AstNode pos = positionStack.Pop (); - Debug.Assert (pos == null || pos.Parent == node); - WriteSpecials (pos, null); - containerStack.Pop (); - formatter.EndNode (node); - return null; + Debug.Assert(node == containerStack.Peek()); + AstNode pos = positionStack.Pop(); + Debug.Assert(pos == null || pos.Parent == node); + WriteSpecials(pos, null); + containerStack.Pop(); + formatter.EndNode(node); } #endregion @@ -105,11 +108,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.Role == AstNode.Roles.PreProcessorDirective) { - pos.AcceptVisitor (this, null); + if (pos.Role == Roles.Comment || pos.Role == Roles.NewLine || pos.Role == Roles.PreProcessorDirective) { + pos.AcceptVisitor(this); } } } @@ -118,22 +121,23 @@ 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) { - WriteSpecialsUpToRole (role, null); + WriteSpecialsUpToRole(role, null); } - void WriteSpecialsUpToRole (Role role, AstNode nextNode) + void WriteSpecialsUpToRole(Role role, AstNode nextNode) { - if (positionStack.Count == 0) + if (positionStack.Count == 0) { return; + } // 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 == role) { - WriteSpecials (positionStack.Pop (), pos); + WriteSpecials(positionStack.Pop(), pos); // Push the next sibling because the node matching the role is not a special, // and should be considered to be already handled. - positionStack.Push (pos.NextSibling); + positionStack.Push(pos.NextSibling); // This is necessary for OptionalComma() to work correctly. break; } @@ -144,16 +148,17 @@ 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) { - if (positionStack.Count == 0) + if (positionStack.Count == 0) { return; + } for (AstNode pos = positionStack.Peek(); pos != null; pos = pos.NextSibling) { if (pos == node) { - WriteSpecials (positionStack.Pop (), pos); + WriteSpecials(positionStack.Pop(), pos); // Push the next sibling because the node itself is not a special, // and should be considered to be already handled. - positionStack.Push (pos.NextSibling); + positionStack.Push(pos.NextSibling); // This is necessary for OptionalComma() to work correctly. break; } @@ -167,13 +172,15 @@ 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(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. } /// @@ -183,10 +190,12 @@ namespace ICSharpCode.NRefactory.CSharp { // Look if there's a comma after the current node, and insert it if it exists. AstNode pos = positionStack.Peek(); - while (pos != null && pos.NodeType == NodeType.Whitespace) + while (pos != null && pos.NodeType == NodeType.Whitespace) { pos = pos.NextSibling; - if (pos != null && pos.Role == AstNode.Roles.Comma) + } + if (pos != null && pos.Role == Roles.Comma) { Comma(null, noSpaceAfterComma: true); + } } /// @@ -196,34 +205,36 @@ namespace ICSharpCode.NRefactory.CSharp { // Look if there's a semicolon after the current node, and insert it if it exists. AstNode pos = positionStack.Peek(); - while (pos != null && pos.NodeType == NodeType.Whitespace) + while (pos != null && pos.NodeType == NodeType.Whitespace) { pos = pos.NextSibling; - if (pos != null && pos.Role == AstNode.Roles.Semicolon) + } + if (pos != null && pos.Role == Roles.Semicolon) { Semicolon(); + } } - 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); } } - 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 @@ -249,26 +260,26 @@ 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); - Space (spaceWithin); + WriteToken(Roles.LBracket); + if (list.Any()) { + Space(spaceWithin); + WriteCommaSeparatedList(list); + Space(spaceWithin); } - WriteToken ("]", AstNode.Roles.RBracket); + WriteToken(Roles.RBracket); } - void WriteCommaSeparatedListInBrackets (IEnumerable list) + void WriteCommaSeparatedListInBrackets(IEnumerable list) { - WriteToken ("[", AstNode.Roles.LBracket); - if (list.Any ()) { - Space (policy.SpacesWithinBrackets); - WriteCommaSeparatedList (list); - Space (policy.SpacesWithinBrackets); + WriteToken(Roles.LBracket); + if (list.Any()) { + Space(policy.SpacesWithinBrackets); + WriteCommaSeparatedList(list); + Space(policy.SpacesWithinBrackets); } - WriteToken ("]", AstNode.Roles.RBracket); + WriteToken(Roles.RBracket); } #endregion @@ -276,32 +287,57 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Writes a keyword, and all specials up to /// - void WriteKeyword (string keyword, Role tokenRole = null) + void WriteKeyword(TokenRole tokenRole) + { + WriteKeyword(tokenRole.Token, tokenRole); + } + + void WriteKeyword(string token, Role tokenRole = null) { - WriteSpecialsUpToRole (tokenRole ?? AstNode.Roles.Keyword); + if (tokenRole != null) { + WriteSpecialsUpToRole(tokenRole); + } + if (lastWritten == LastWritten.KeywordOrIdentifier) { + formatter.Space(); + } + formatter.WriteKeyword(token); + lastWritten = LastWritten.KeywordOrIdentifier; + } + +/* void WriteKeyword (string keyword, Role tokenRole) + { + WriteSpecialsUpToRole (tokenRole); if (lastWritten == LastWritten.KeywordOrIdentifier) 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 ())) { - if (lastWritten == LastWritten.KeywordOrIdentifier) - Space (); // this space is not strictly required, so we call Space() - formatter.WriteToken ("@"); + WriteSpecialsUpToRole(identifierRole ?? Roles.Identifier); + if (IsKeyword(identifier, containerStack.Peek())) { + if (lastWritten == LastWritten.KeywordOrIdentifier) { + 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(TokenRole tokenRole) { - WriteSpecialsUpToRole (tokenRole); + WriteToken(tokenRole.Token, tokenRole); + } + + void WriteToken(string token, Role 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. @@ -309,77 +345,79 @@ namespace ICSharpCode.NRefactory.CSharp // 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 (token == "+") + || 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 == "-") + } else if (token == "-") { lastWritten = LastWritten.Minus; - else if (token == "&") + } else if (token == "&") { lastWritten = LastWritten.Ampersand; - else if (token == "?") + } else if (token == "?") { lastWritten = LastWritten.QuestionMark; - else if (token == "/") + } else if (token == "/") { lastWritten = LastWritten.Division; - else + } else { lastWritten = LastWritten.Other; + } } - void LPar () + void LPar() { - WriteToken ("(", AstNode.Roles.LPar); + WriteToken(Roles.LPar); } - void RPar () + void RPar() { - WriteToken (")", AstNode.Roles.RPar); + WriteToken(Roles.RPar); } /// /// 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(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(Roles.LBrace); + formatter.OpenBrace(style); lastWritten = LastWritten.Other; } - void CloseBrace (BraceStyle style) + void CloseBrace(BraceStyle style) { - WriteSpecialsUpToRole (AstNode.Roles.RBrace); - formatter.CloseBrace (style); + WriteSpecialsUpToRole(Roles.RBrace); + formatter.CloseBrace(style); lastWritten = LastWritten.Other; } @@ -406,21 +444,26 @@ 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; + } foreach (AstNode ancestor in context.Ancestors) { - if (ancestor is QueryExpression && queryKeywords.Contains (identifier)) + if (ancestor is QueryExpression && queryKeywords.Contains(identifier)) { return true; + } if (identifier == "await") { // with lambdas/anonymous methods, - if (ancestor is LambdaExpression) + if (ancestor is LambdaExpression) { return ((LambdaExpression)ancestor).IsAsync; - if (ancestor is AnonymousMethodExpression) + } + if (ancestor is AnonymousMethodExpression) { return ((AnonymousMethodExpression)ancestor).IsAsync; - if (ancestor is AttributedNode) - return (((AttributedNode)ancestor).Modifiers & Modifiers.Async) == Modifiers.Async; + } + if (ancestor is EntityDeclaration) { + return (((EntityDeclaration)ancestor).Modifiers & Modifiers.Async) == Modifiers.Async; + } } } return false; @@ -428,162 +471,168 @@ namespace ICSharpCode.NRefactory.CSharp #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(Roles.LChevron); + WriteCommaSeparatedList(typeArguments); + WriteToken(Roles.RChevron); } } - public void WriteTypeParameters (IEnumerable typeParameters) + public void WriteTypeParameters(IEnumerable typeParameters) { - if (typeParameters.Any ()) { - WriteToken ("<", AstNode.Roles.LChevron); - WriteCommaSeparatedList (typeParameters); - WriteToken (">", AstNode.Roles.RChevron); + if (typeParameters.Any()) { + WriteToken(Roles.LChevron); + WriteCommaSeparatedList(typeParameters); + WriteToken(Roles.RChevron); } } - void WriteModifiers (IEnumerable modifierTokens) + void WriteModifiers(IEnumerable modifierTokens) { foreach (CSharpModifierToken modifier in modifierTokens) { - modifier.AcceptVisitor (this, null); + modifier.AcceptVisitor(this); } } - 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 (); + if (lastWritten == LastWritten.KeywordOrIdentifier) { + formatter.Space(); + } } else { - WriteSpecialsUpToRole (AstNode.Roles.Dot, ident); - formatter.WriteToken ("."); + WriteSpecialsUpToRole(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) + if (embeddedStatement.IsNull) { + NewLine(); return; + } BlockStatement block = embeddedStatement as BlockStatement; - if (block != null) - VisitBlockStatement (block, null); - else { - NewLine (); - formatter.Indent (); - embeddedStatement.AcceptVisitor (this, null); - formatter.Unindent (); + if (block != null) { + VisitBlockStatement(block); + } else { + NewLine(); + formatter.Indent(); + embeddedStatement.AcceptVisitor(this); + formatter.Unindent(); } } - void WriteMethodBody (BlockStatement body) + void WriteMethodBody(BlockStatement body) { - if (body.IsNull) - Semicolon (); - else - VisitBlockStatement (body, null); + if (body.IsNull) { + Semicolon(); + } else { + VisitBlockStatement(body); + } } - void WriteAttributes (IEnumerable attributes) + void WriteAttributes(IEnumerable attributes) { foreach (AttributeSection attr in attributes) { - attr.AcceptVisitor (this, null); + attr.AcceptVisitor(this); } } - void WritePrivateImplementationType (AstType privateImplementationType) + void WritePrivateImplementationType(AstType privateImplementationType) { if (!privateImplementationType.IsNull) { - privateImplementationType.AcceptVisitor (this, null); - WriteToken (".", AstNode.Roles.Dot); + privateImplementationType.AcceptVisitor(this); + WriteToken(Roles.Dot); } } #endregion #region Expressions - public object VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression, object data) + public void VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression) { - StartNode (anonymousMethodExpression); + StartNode(anonymousMethodExpression); if (anonymousMethodExpression.IsAsync) { - WriteKeyword ("async", AnonymousMethodExpression.AsyncModifierRole); - Space (); + WriteKeyword(AnonymousMethodExpression.AsyncModifierRole); + Space(); } - WriteKeyword ("delegate"); + WriteKeyword(AnonymousMethodExpression.DelegateKeywordRole); 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); + EndNode(anonymousMethodExpression); } - public object VisitUndocumentedExpression (UndocumentedExpression undocumentedExpression, object data) + public void VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression) { - StartNode (undocumentedExpression); + StartNode(undocumentedExpression); switch (undocumentedExpression.UndocumentedExpressionType) { case UndocumentedExpressionType.ArgList: case UndocumentedExpressionType.ArgListAccess: - WriteKeyword ("__arglist"); + WriteKeyword(UndocumentedExpression.ArglistKeywordRole); break; case UndocumentedExpressionType.MakeRef: - WriteKeyword ("__makeref"); + WriteKeyword(UndocumentedExpression.MakerefKeywordRole); break; case UndocumentedExpressionType.RefType: - WriteKeyword ("__reftype"); + WriteKeyword(UndocumentedExpression.ReftypeKeywordRole); break; case UndocumentedExpressionType.RefValue: - WriteKeyword ("__refvalue"); + WriteKeyword(UndocumentedExpression.RefvalueKeywordRole); 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); + EndNode(undocumentedExpression); } - public object VisitArrayCreateExpression (ArrayCreateExpression arrayCreateExpression, object data) + public void VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression) { - StartNode (arrayCreateExpression); - WriteKeyword ("new"); - arrayCreateExpression.Type.AcceptVisitor (this, data); - if (arrayCreateExpression.Arguments.Count > 0) - WriteCommaSeparatedListInBrackets (arrayCreateExpression.Arguments); - foreach (var specifier in arrayCreateExpression.AdditionalArraySpecifiers) - specifier.AcceptVisitor (this, data); - arrayCreateExpression.Initializer.AcceptVisitor (this, data); - return EndNode (arrayCreateExpression); + StartNode(arrayCreateExpression); + WriteKeyword(ArrayCreateExpression.NewKeywordRole); + arrayCreateExpression.Type.AcceptVisitor(this); + if (arrayCreateExpression.Arguments.Count > 0) { + WriteCommaSeparatedListInBrackets(arrayCreateExpression.Arguments); + } + foreach (var specifier in arrayCreateExpression.AdditionalArraySpecifiers) { + specifier.AcceptVisitor(this); + } + arrayCreateExpression.Initializer.AcceptVisitor(this); + EndNode(arrayCreateExpression); } - public object VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression, object data) + public void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression) { - StartNode (arrayInitializerExpression); + StartNode(arrayInitializerExpression); // "new List { { 1 } }" and "new List { 1 }" are the same semantically. // We also use the same AST for both: we always use two nested ArrayInitializerExpressions // for collection initializers, even if the user did not write nested brackets. // The output visitor will output nested braces only if they are necessary, // or if the braces tokens exist in the AST. bool bracesAreOptional = arrayInitializerExpression.Elements.Count == 1 - && IsObjectOrCollectionInitializer(arrayInitializerExpression.Parent) - && !CanBeConfusedWithObjectInitializer(arrayInitializerExpression.Elements.Single()); + && IsObjectOrCollectionInitializer(arrayInitializerExpression.Parent) + && !CanBeConfusedWithObjectInitializer(arrayInitializerExpression.Elements.Single()); if (bracesAreOptional && arrayInitializerExpression.LBraceToken.IsNull) { - arrayInitializerExpression.Elements.Single().AcceptVisitor(this, data); + arrayInitializerExpression.Elements.Single().AcceptVisitor(this); } else { PrintInitializerElements(arrayInitializerExpression.Elements); } - return EndNode (arrayInitializerExpression); + EndNode(arrayInitializerExpression); } bool CanBeConfusedWithObjectInitializer(Expression expr) @@ -596,22 +645,26 @@ namespace ICSharpCode.NRefactory.CSharp bool IsObjectOrCollectionInitializer(AstNode node) { - if (!(node is ArrayInitializerExpression)) + if (!(node is ArrayInitializerExpression)) { return false; - if (node.Parent is ObjectCreateExpression) + } + if (node.Parent is ObjectCreateExpression) { return node.Role == ObjectCreateExpression.InitializerRole; - if (node.Parent is NamedExpression) - return node.Role == NamedExpression.Roles.Expression; + } + if (node.Parent is NamedExpression) { + return node.Role == Roles.Expression; + } return false; } void PrintInitializerElements(AstNodeCollection elements) { BraceStyle style; - if (policy.PlaceArrayInitializersOnNewLine == ArrayInitializerPlacement.AlwaysNewLine) + if (policy.ArrayInitializerWrapping == Wrapping.WrapAlways) { style = BraceStyle.NextLine; - else + } else { style = BraceStyle.EndOfLine; + } OpenBrace(style); bool isFirst = true; foreach (AstNode node in elements) { @@ -621,46 +674,46 @@ namespace ICSharpCode.NRefactory.CSharp Comma(node, noSpaceAfterComma: true); NewLine(); } - node.AcceptVisitor(this, null); + node.AcceptVisitor(this); } OptionalComma(); NewLine(); CloseBrace(style); } - public object VisitAsExpression (AsExpression asExpression, object data) + public void VisitAsExpression(AsExpression asExpression) { - 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); + Space(); + WriteKeyword(AsExpression.AsKeywordRole); + Space(); + asExpression.Type.AcceptVisitor(this); + EndNode(asExpression); } - public object VisitAssignmentExpression (AssignmentExpression assignmentExpression, object data) + public void VisitAssignmentExpression(AssignmentExpression 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); + StartNode(assignmentExpression); + assignmentExpression.Left.AcceptVisitor(this); + Space(policy.SpaceAroundAssignment); + WriteToken(AssignmentExpression.GetOperatorRole(assignmentExpression.Operator)); + Space(policy.SpaceAroundAssignment); + assignmentExpression.Right.AcceptVisitor(this); + EndNode(assignmentExpression); } - public object VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression, object data) + public void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression) { - StartNode (baseReferenceExpression); - WriteKeyword ("base"); - return EndNode (baseReferenceExpression); + StartNode(baseReferenceExpression); + WriteKeyword("base", baseReferenceExpression.Role); + EndNode(baseReferenceExpression); } - public object VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, object data) + public void VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression) { - StartNode (binaryOperatorExpression); - binaryOperatorExpression.Left.AcceptVisitor (this, data); + StartNode(binaryOperatorExpression); + binaryOperatorExpression.Left.AcceptVisitor(this); bool spacePolicy; switch (binaryOperatorExpression.Operator) { case BinaryOperatorType.BitwiseAnd: @@ -701,349 +754,355 @@ namespace ICSharpCode.NRefactory.CSharp 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.GetOperatorRole(binaryOperatorExpression.Operator)); + Space(spacePolicy); + binaryOperatorExpression.Right.AcceptVisitor(this); + EndNode(binaryOperatorExpression); } - public object VisitCastExpression (CastExpression castExpression, object data) + public void VisitCastExpression(CastExpression 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); + StartNode(castExpression); + LPar(); + Space(policy.SpacesWithinCastParentheses); + castExpression.Type.AcceptVisitor(this); + Space(policy.SpacesWithinCastParentheses); + RPar(); + Space(policy.SpaceAfterTypecast); + castExpression.Expression.AcceptVisitor(this); + EndNode(castExpression); } - public object VisitCheckedExpression (CheckedExpression checkedExpression, object data) + public void VisitCheckedExpression(CheckedExpression checkedExpression) { - StartNode (checkedExpression); - WriteKeyword ("checked"); - LPar (); - Space (policy.SpacesWithinCheckedExpressionParantheses); - checkedExpression.Expression.AcceptVisitor (this, data); - Space (policy.SpacesWithinCheckedExpressionParantheses); - RPar (); - return EndNode (checkedExpression); + StartNode(checkedExpression); + WriteKeyword(CheckedExpression.CheckedKeywordRole); + LPar(); + Space(policy.SpacesWithinCheckedExpressionParantheses); + checkedExpression.Expression.AcceptVisitor(this); + Space(policy.SpacesWithinCheckedExpressionParantheses); + RPar(); + EndNode(checkedExpression); } - public object VisitConditionalExpression (ConditionalExpression conditionalExpression, object data) + public void VisitConditionalExpression(ConditionalExpression conditionalExpression) { - StartNode (conditionalExpression); - conditionalExpression.Condition.AcceptVisitor (this, data); + StartNode(conditionalExpression); + conditionalExpression.Condition.AcceptVisitor(this); - 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); - 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); - return EndNode (conditionalExpression); + EndNode(conditionalExpression); } - public object VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression, object data) + public void VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression) { - StartNode (defaultValueExpression); + StartNode(defaultValueExpression); - WriteKeyword ("default"); - LPar (); - Space (policy.SpacesWithinTypeOfParentheses); - defaultValueExpression.Type.AcceptVisitor (this, data); - Space (policy.SpacesWithinTypeOfParentheses); - RPar (); + WriteKeyword(DefaultValueExpression.DefaultKeywordRole); + LPar(); + Space(policy.SpacesWithinTypeOfParentheses); + defaultValueExpression.Type.AcceptVisitor(this); + Space(policy.SpacesWithinTypeOfParentheses); + RPar(); - return EndNode (defaultValueExpression); + EndNode(defaultValueExpression); } - public object VisitDirectionExpression (DirectionExpression directionExpression, object data) + public void VisitDirectionExpression(DirectionExpression directionExpression) { - StartNode (directionExpression); + StartNode(directionExpression); switch (directionExpression.FieldDirection) { case FieldDirection.Out: - WriteKeyword ("out"); + WriteKeyword(DirectionExpression.OutKeywordRole); break; case FieldDirection.Ref: - WriteKeyword ("ref"); + WriteKeyword(DirectionExpression.RefKeywordRole); break; default: throw new NotSupportedException ("Invalid value for FieldDirection"); } - Space (); - directionExpression.Expression.AcceptVisitor (this, data); + Space(); + directionExpression.Expression.AcceptVisitor(this); - return EndNode (directionExpression); + EndNode(directionExpression); } - public object VisitIdentifierExpression (IdentifierExpression identifierExpression, object data) + public void VisitIdentifierExpression(IdentifierExpression identifierExpression) { - StartNode (identifierExpression); - WriteIdentifier (identifierExpression.Identifier); - WriteTypeArguments (identifierExpression.TypeArguments); - return EndNode (identifierExpression); + StartNode(identifierExpression); + WriteIdentifier(identifierExpression.Identifier); + WriteTypeArguments(identifierExpression.TypeArguments); + EndNode(identifierExpression); } - public object VisitIndexerExpression (IndexerExpression indexerExpression, object data) + public void VisitIndexerExpression(IndexerExpression indexerExpression) { - StartNode (indexerExpression); - indexerExpression.Target.AcceptVisitor (this, data); - Space (policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInBrackets (indexerExpression.Arguments); - return EndNode (indexerExpression); + StartNode(indexerExpression); + indexerExpression.Target.AcceptVisitor(this); + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInBrackets(indexerExpression.Arguments); + EndNode(indexerExpression); } - public object VisitInvocationExpression (InvocationExpression invocationExpression, object data) + public void VisitInvocationExpression(InvocationExpression invocationExpression) { - StartNode (invocationExpression); - invocationExpression.Target.AcceptVisitor (this, data); - Space (policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis (invocationExpression.Arguments, policy.SpaceWithinMethodCallParentheses); - return EndNode (invocationExpression); + StartNode(invocationExpression); + invocationExpression.Target.AcceptVisitor(this); + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(invocationExpression.Arguments, policy.SpaceWithinMethodCallParentheses); + EndNode(invocationExpression); } - public object VisitIsExpression (IsExpression isExpression, object data) + public void VisitIsExpression(IsExpression isExpression) { - StartNode (isExpression); - isExpression.Expression.AcceptVisitor (this, data); - Space (); - WriteKeyword ("is"); - isExpression.Type.AcceptVisitor (this, data); - return EndNode (isExpression); + StartNode(isExpression); + isExpression.Expression.AcceptVisitor(this); + Space(); + WriteKeyword(IsExpression.IsKeywordRole); + isExpression.Type.AcceptVisitor(this); + EndNode(isExpression); } - public object VisitLambdaExpression (LambdaExpression lambdaExpression, object data) + public void VisitLambdaExpression(LambdaExpression lambdaExpression) { - StartNode (lambdaExpression); + StartNode(lambdaExpression); if (lambdaExpression.IsAsync) { - WriteKeyword ("async", LambdaExpression.AsyncModifierRole); - Space (); + WriteKeyword(LambdaExpression.AsyncModifierRole); + Space(); } - if (LambdaNeedsParenthesis (lambdaExpression)) { - WriteCommaSeparatedListInParenthesis (lambdaExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + if (LambdaNeedsParenthesis(lambdaExpression)) { + WriteCommaSeparatedListInParenthesis(lambdaExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); } else { - lambdaExpression.Parameters.Single ().AcceptVisitor (this, data); + lambdaExpression.Parameters.Single().AcceptVisitor(this); } - Space (); - WriteToken ("=>", LambdaExpression.ArrowRole); - Space (); - lambdaExpression.Body.AcceptVisitor (this, data); - return EndNode (lambdaExpression); + Space(); + WriteToken(LambdaExpression.ArrowRole); + Space(); + lambdaExpression.Body.AcceptVisitor(this); + EndNode(lambdaExpression); } - bool LambdaNeedsParenthesis (LambdaExpression lambdaExpression) + bool LambdaNeedsParenthesis(LambdaExpression lambdaExpression) { - if (lambdaExpression.Parameters.Count != 1) + 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 void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression) { - 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); + WriteToken(Roles.Dot); + WriteIdentifier(memberReferenceExpression.MemberName); + WriteTypeArguments(memberReferenceExpression.TypeArguments); + EndNode(memberReferenceExpression); } - public object VisitNamedArgumentExpression (NamedArgumentExpression namedArgumentExpression, object data) + public void VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression) { - StartNode (namedArgumentExpression); - WriteIdentifier (namedArgumentExpression.Identifier); - WriteToken(":", NamedArgumentExpression.Roles.Colon); - Space (); - namedArgumentExpression.Expression.AcceptVisitor (this, data); - return EndNode (namedArgumentExpression); + StartNode(namedArgumentExpression); + namedArgumentExpression.IdentifierToken.AcceptVisitor(this); + WriteToken(Roles.Colon); + Space(); + namedArgumentExpression.Expression.AcceptVisitor(this); + EndNode(namedArgumentExpression); } - public object VisitNamedExpression (NamedExpression namedExpression, object data) + public void VisitNamedExpression(NamedExpression namedExpression) { - StartNode (namedExpression); - WriteIdentifier (namedExpression.Identifier); + StartNode(namedExpression); + namedExpression.IdentifierToken.AcceptVisitor(this); Space(); - WriteToken("=", NamedArgumentExpression.Roles.Assign); - Space (); - namedExpression.Expression.AcceptVisitor (this, data); - return EndNode (namedExpression); + WriteToken(Roles.Assign); + Space(); + namedExpression.Expression.AcceptVisitor(this); + EndNode(namedExpression); } - public object VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression, object data) + public void VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression) { - StartNode (nullReferenceExpression); - WriteKeyword ("null"); - return EndNode (nullReferenceExpression); + StartNode(nullReferenceExpression); + WriteKeyword("null", nullReferenceExpression.Role); + EndNode(nullReferenceExpression); } - public object VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, object data) + public void VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression) { - StartNode (objectCreateExpression); - WriteKeyword ("new"); - objectCreateExpression.Type.AcceptVisitor (this, data); + StartNode(objectCreateExpression); + WriteKeyword(ObjectCreateExpression.NewKeywordRole); + objectCreateExpression.Type.AcceptVisitor(this); bool useParenthesis = objectCreateExpression.Arguments.Any() || objectCreateExpression.Initializer.IsNull; // also use parenthesis if there is an '(' token - if (!objectCreateExpression.LParToken.IsNull) + if (!objectCreateExpression.LParToken.IsNull) { useParenthesis = true; + } if (useParenthesis) { - Space (policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis (objectCreateExpression.Arguments, policy.SpaceWithinMethodCallParentheses); + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(objectCreateExpression.Arguments, policy.SpaceWithinMethodCallParentheses); } - objectCreateExpression.Initializer.AcceptVisitor (this, data); - return EndNode (objectCreateExpression); + objectCreateExpression.Initializer.AcceptVisitor(this); + EndNode(objectCreateExpression); } - public object VisitAnonymousTypeCreateExpression (AnonymousTypeCreateExpression anonymousTypeCreateExpression, object data) + public void VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression) { - StartNode (anonymousTypeCreateExpression); - WriteKeyword ("new"); + StartNode(anonymousTypeCreateExpression); + WriteKeyword(AnonymousTypeCreateExpression.NewKeywordRole); PrintInitializerElements(anonymousTypeCreateExpression.Initializers); - return EndNode (anonymousTypeCreateExpression); + EndNode(anonymousTypeCreateExpression); } - public object VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, object data) + public void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression) { - 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); + Space(policy.SpacesWithinParentheses); + RPar(); + EndNode(parenthesizedExpression); } - public object VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression, object data) + public void VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression) { - StartNode (pointerReferenceExpression); - pointerReferenceExpression.Target.AcceptVisitor (this, data); - WriteToken ("->", PointerReferenceExpression.ArrowRole); - WriteIdentifier (pointerReferenceExpression.MemberName); - WriteTypeArguments (pointerReferenceExpression.TypeArguments); - return EndNode (pointerReferenceExpression); + StartNode(pointerReferenceExpression); + pointerReferenceExpression.Target.AcceptVisitor(this); + WriteToken(PointerReferenceExpression.ArrowRole); + WriteIdentifier(pointerReferenceExpression.MemberName); + WriteTypeArguments(pointerReferenceExpression.TypeArguments); + EndNode(pointerReferenceExpression); } - public object VisitEmptyExpression (EmptyExpression emptyExpression, object data) + public void VisitEmptyExpression(EmptyExpression emptyExpression) { - StartNode (emptyExpression); - return EndNode (emptyExpression); + StartNode(emptyExpression); + EndNode(emptyExpression); } #region VisitPrimitiveExpression - public object VisitPrimitiveExpression (PrimitiveExpression primitiveExpression, object data) + public void VisitPrimitiveExpression(PrimitiveExpression primitiveExpression) { - StartNode (primitiveExpression); - if (!string.IsNullOrEmpty (primitiveExpression.LiteralValue)) { - formatter.WriteToken (primitiveExpression.LiteralValue); + StartNode(primitiveExpression); + if (!string.IsNullOrEmpty(primitiveExpression.LiteralValue)) { + formatter.WriteToken(primitiveExpression.LiteralValue); } else { - WritePrimitiveValue (primitiveExpression.Value); + WritePrimitiveValue(primitiveExpression.Value); } - return EndNode (primitiveExpression); + 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"); - else - WriteIdentifier ("NaN"); + WriteKeyword("float"); + WriteToken(Roles.Dot); + if (float.IsPositiveInfinity(f)) { + WriteIdentifier("PositiveInfinity"); + } else if (float.IsNegativeInfinity(f)) { + WriteIdentifier("NegativeInfinity"); + } else { + 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"); - else - WriteIdentifier ("NaN"); + WriteKeyword("double"); + WriteToken(Roles.Dot); + if (double.IsPositiveInfinity(f)) { + WriteIdentifier("PositiveInfinity"); + } else if (double.IsNegativeInfinity(f)) { + WriteIdentifier("NegativeInfinity"); + } else { + 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 (); -// 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)); -// } + // 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)); + // } 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 == '\'') + if (ch == '\'') { return "\\'"; - return ConvertChar (ch); + } + return ConvertChar(ch); } /// @@ -1073,11 +1132,11 @@ namespace ICSharpCode.NRefactory.CSharp 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"); + // print all uncommon white spaces as numbers + (char.IsWhiteSpace(ch) && ch != ' ')) { + return "\\u" + ((int)ch).ToString("x4"); } else { - return ch.ToString (); + return ch.ToString(); } } } @@ -1089,101 +1148,103 @@ namespace ICSharpCode.NRefactory.CSharp { StringBuilder sb = new StringBuilder (); foreach (char ch in str) { - if (ch == '"') - sb.Append ("\\\""); - else - sb.Append (ConvertChar (ch)); + if (ch == '"') { + sb.Append("\\\""); + } else { + sb.Append(ConvertChar(ch)); + } } - return sb.ToString (); + return sb.ToString(); } #endregion - public object VisitSizeOfExpression (SizeOfExpression sizeOfExpression, object data) + public void VisitSizeOfExpression(SizeOfExpression sizeOfExpression) { - StartNode (sizeOfExpression); + StartNode(sizeOfExpression); - WriteKeyword ("sizeof"); - LPar (); - Space (policy.SpacesWithinSizeOfParentheses); - sizeOfExpression.Type.AcceptVisitor (this, data); - Space (policy.SpacesWithinSizeOfParentheses); - RPar (); + WriteKeyword(SizeOfExpression.SizeofKeywordRole); + LPar(); + Space(policy.SpacesWithinSizeOfParentheses); + sizeOfExpression.Type.AcceptVisitor(this); + Space(policy.SpacesWithinSizeOfParentheses); + RPar(); - return EndNode (sizeOfExpression); + EndNode(sizeOfExpression); } - public object VisitStackAllocExpression (StackAllocExpression stackAllocExpression, object data) + public void VisitStackAllocExpression(StackAllocExpression stackAllocExpression) { - StartNode (stackAllocExpression); - WriteKeyword ("stackalloc"); - stackAllocExpression.Type.AcceptVisitor (this, data); - WriteCommaSeparatedListInBrackets (new[] { stackAllocExpression.CountExpression }); - return EndNode (stackAllocExpression); + StartNode(stackAllocExpression); + WriteKeyword(StackAllocExpression.StackallocKeywordRole); + stackAllocExpression.Type.AcceptVisitor(this); + WriteCommaSeparatedListInBrackets(new[] { stackAllocExpression.CountExpression }); + EndNode(stackAllocExpression); } - public object VisitThisReferenceExpression (ThisReferenceExpression thisReferenceExpression, object data) + public void VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression) { - StartNode (thisReferenceExpression); - WriteKeyword ("this"); - return EndNode (thisReferenceExpression); + StartNode(thisReferenceExpression); + WriteKeyword("this", thisReferenceExpression.Role); + EndNode(thisReferenceExpression); } - public object VisitTypeOfExpression (TypeOfExpression typeOfExpression, object data) + public void VisitTypeOfExpression(TypeOfExpression typeOfExpression) { - StartNode (typeOfExpression); + StartNode(typeOfExpression); - WriteKeyword ("typeof"); - LPar (); - Space (policy.SpacesWithinTypeOfParentheses); - typeOfExpression.Type.AcceptVisitor (this, data); - Space (policy.SpacesWithinTypeOfParentheses); - RPar (); + WriteKeyword(TypeOfExpression.TypeofKeywordRole); + LPar(); + Space(policy.SpacesWithinTypeOfParentheses); + typeOfExpression.Type.AcceptVisitor(this); + Space(policy.SpacesWithinTypeOfParentheses); + RPar(); - return EndNode (typeOfExpression); + EndNode(typeOfExpression); } - public object VisitTypeReferenceExpression (TypeReferenceExpression typeReferenceExpression, object data) + public void VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression) { - StartNode (typeReferenceExpression); - typeReferenceExpression.Type.AcceptVisitor (this, data); - return EndNode (typeReferenceExpression); + StartNode(typeReferenceExpression); + typeReferenceExpression.Type.AcceptVisitor(this); + EndNode(typeReferenceExpression); } - public object VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression, object data) + public void VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression) { - StartNode (unaryOperatorExpression); + StartNode(unaryOperatorExpression); UnaryOperatorType opType = unaryOperatorExpression.Operator; - string opSymbol = UnaryOperatorExpression.GetOperatorSymbol (opType); + var opSymbol = UnaryOperatorExpression.GetOperatorRole(opType); if (opType == UnaryOperatorType.Await) { - WriteKeyword (opSymbol, UnaryOperatorExpression.OperatorRole); + WriteKeyword(opSymbol); } else if (!(opType == UnaryOperatorType.PostIncrement || opType == UnaryOperatorType.PostDecrement)) { - WriteToken (opSymbol, UnaryOperatorExpression.OperatorRole); + WriteToken(opSymbol); + } + unaryOperatorExpression.Expression.AcceptVisitor(this); + if (opType == UnaryOperatorType.PostIncrement || opType == UnaryOperatorType.PostDecrement) { + WriteToken(opSymbol); } - unaryOperatorExpression.Expression.AcceptVisitor (this, data); - if (opType == UnaryOperatorType.PostIncrement || opType == UnaryOperatorType.PostDecrement) - WriteToken (opSymbol, UnaryOperatorExpression.OperatorRole); - return EndNode (unaryOperatorExpression); + EndNode(unaryOperatorExpression); } - public object VisitUncheckedExpression (UncheckedExpression uncheckedExpression, object data) + public void VisitUncheckedExpression(UncheckedExpression uncheckedExpression) { - StartNode (uncheckedExpression); - WriteKeyword ("unchecked"); - LPar (); - Space (policy.SpacesWithinCheckedExpressionParantheses); - uncheckedExpression.Expression.AcceptVisitor (this, data); - Space (policy.SpacesWithinCheckedExpressionParantheses); - RPar (); - return EndNode (uncheckedExpression); + StartNode(uncheckedExpression); + WriteKeyword(UncheckedExpression.UncheckedKeywordRole); + LPar(); + Space(policy.SpacesWithinCheckedExpressionParantheses); + uncheckedExpression.Expression.AcceptVisitor(this); + Space(policy.SpacesWithinCheckedExpressionParantheses); + RPar(); + EndNode(uncheckedExpression); } #endregion #region Query Expressions - public object VisitQueryExpression (QueryExpression queryExpression, object data) + public void VisitQueryExpression(QueryExpression queryExpression) { - StartNode (queryExpression); + StartNode(queryExpression); bool indent = !(queryExpression.Parent is QueryContinuationClause); if (indent) { formatter.Indent(); @@ -1194,303 +1255,307 @@ namespace ICSharpCode.NRefactory.CSharp if (first) { first = false; } else { - if (!(clause is QueryContinuationClause)) - NewLine (); + if (!(clause is QueryContinuationClause)) { + NewLine(); + } } - clause.AcceptVisitor (this, data); + clause.AcceptVisitor(this); } - if (indent) + 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); + } + EndNode(queryExpression); + } + + public void VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause) + { + StartNode(queryContinuationClause); + queryContinuationClause.PrecedingQuery.AcceptVisitor(this); + Space(); + WriteKeyword(QueryContinuationClause.IntoKeywordRole); + Space(); + queryContinuationClause.IdentifierToken.AcceptVisitor(this); + EndNode(queryContinuationClause); + } + + public void VisitQueryFromClause(QueryFromClause queryFromClause) + { + StartNode(queryFromClause); + WriteKeyword(QueryFromClause.FromKeywordRole); + queryFromClause.Type.AcceptVisitor(this); + Space(); + queryFromClause.IdentifierToken.AcceptVisitor(this); + Space(); + WriteKeyword(QueryFromClause.InKeywordRole); + Space(); + queryFromClause.Expression.AcceptVisitor(this); + EndNode(queryFromClause); + } + + public void VisitQueryLetClause(QueryLetClause queryLetClause) + { + StartNode(queryLetClause); + WriteKeyword(QueryLetClause.LetKeywordRole); + Space(); + queryLetClause.IdentifierToken.AcceptVisitor(this); + Space(policy.SpaceAroundAssignment); + WriteToken(Roles.Assign); + Space(policy.SpaceAroundAssignment); + queryLetClause.Expression.AcceptVisitor(this); + EndNode(queryLetClause); + } + + public void VisitQueryWhereClause(QueryWhereClause queryWhereClause) + { + StartNode(queryWhereClause); + WriteKeyword(QueryWhereClause.WhereKeywordRole); + Space(); + queryWhereClause.Condition.AcceptVisitor(this); + EndNode(queryWhereClause); + } + + public void VisitQueryJoinClause(QueryJoinClause queryJoinClause) + { + StartNode(queryJoinClause); + WriteKeyword(QueryJoinClause.JoinKeywordRole); + queryJoinClause.Type.AcceptVisitor(this); + Space(); + WriteIdentifier(queryJoinClause.JoinIdentifier, QueryJoinClause.JoinIdentifierRole); + Space(); + WriteKeyword(QueryJoinClause.InKeywordRole); + Space(); + queryJoinClause.InExpression.AcceptVisitor(this); + Space(); + WriteKeyword(QueryJoinClause.OnKeywordRole); + Space(); + queryJoinClause.OnExpression.AcceptVisitor(this); + Space(); + WriteKeyword(QueryJoinClause.EqualsKeywordRole); + Space(); + queryJoinClause.EqualsExpression.AcceptVisitor(this); if (queryJoinClause.IsGroupJoin) { - Space (); - WriteKeyword ("into", QueryJoinClause.IntoKeywordRole); - WriteIdentifier (queryJoinClause.IntoIdentifier, QueryJoinClause.IntoIdentifierRole); + Space(); + WriteKeyword(QueryJoinClause.IntoKeywordRole); + WriteIdentifier(queryJoinClause.IntoIdentifier, QueryJoinClause.IntoIdentifierRole); } - return EndNode (queryJoinClause); + EndNode(queryJoinClause); } - public object VisitQueryOrderClause (QueryOrderClause queryOrderClause, object data) + public void VisitQueryOrderClause(QueryOrderClause queryOrderClause) { - StartNode (queryOrderClause); - WriteKeyword ("orderby"); - Space (); - WriteCommaSeparatedList (queryOrderClause.Orderings); - return EndNode (queryOrderClause); + StartNode(queryOrderClause); + WriteKeyword(QueryOrderClause.OrderbyKeywordRole); + Space(); + WriteCommaSeparatedList(queryOrderClause.Orderings); + EndNode(queryOrderClause); } - public object VisitQueryOrdering (QueryOrdering queryOrdering, object data) + public void VisitQueryOrdering(QueryOrdering queryOrdering) { - StartNode (queryOrdering); - queryOrdering.Expression.AcceptVisitor (this, data); + StartNode(queryOrdering); + queryOrdering.Expression.AcceptVisitor(this); switch (queryOrdering.Direction) { case QueryOrderingDirection.Ascending: - Space (); - WriteKeyword ("ascending"); + Space(); + WriteKeyword(QueryOrdering.AscendingKeywordRole); break; case QueryOrderingDirection.Descending: - Space (); - WriteKeyword ("descending"); + Space(); + WriteKeyword(QueryOrdering.DescendingKeywordRole); break; } - return EndNode (queryOrdering); + EndNode(queryOrdering); } - public object VisitQuerySelectClause (QuerySelectClause querySelectClause, object data) + public void VisitQuerySelectClause(QuerySelectClause querySelectClause) { - StartNode (querySelectClause); - WriteKeyword ("select"); - Space (); - querySelectClause.Expression.AcceptVisitor (this, data); - return EndNode (querySelectClause); + StartNode(querySelectClause); + WriteKeyword(QuerySelectClause.SelectKeywordRole); + Space(); + querySelectClause.Expression.AcceptVisitor(this); + EndNode(querySelectClause); } - public object VisitQueryGroupClause (QueryGroupClause queryGroupClause, object data) + public void VisitQueryGroupClause(QueryGroupClause 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); + StartNode(queryGroupClause); + WriteKeyword(QueryGroupClause.GroupKeywordRole); + Space(); + queryGroupClause.Projection.AcceptVisitor(this); + Space(); + WriteKeyword(QueryGroupClause.ByKeywordRole); + Space(); + queryGroupClause.Key.AcceptVisitor(this); + EndNode(queryGroupClause); } #endregion #region GeneralScope - public object VisitAttribute (Attribute attribute, object data) - { - StartNode (attribute); - attribute.Type.AcceptVisitor (this, data); - if (attribute.Arguments.Count != 0 || !attribute.GetChildByRole (AstNode.Roles.LPar).IsNull) { - Space (policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis (attribute.Arguments, policy.SpaceWithinMethodCallParentheses); - } - return EndNode (attribute); - } - - public object VisitAttributeSection (AttributeSection attributeSection, object data) - { - StartNode (attributeSection); - WriteToken ("[", AstNode.Roles.LBracket); - if (!string.IsNullOrEmpty (attributeSection.AttributeTarget)) { - WriteToken (attributeSection.AttributeTarget, AttributeSection.TargetRole); - WriteToken (":", AttributeSection.Roles.Colon); - Space (); - } - WriteCommaSeparatedList (attributeSection.Attributes); - WriteToken ("]", AstNode.Roles.RBracket); - if (attributeSection.Parent is ParameterDeclaration || attributeSection.Parent is TypeParameterDeclaration) - Space (); - else - NewLine (); - return EndNode (attributeSection); - } - - 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); + public void VisitAttribute(Attribute attribute) + { + StartNode(attribute); + attribute.Type.AcceptVisitor(this); + if (attribute.Arguments.Count != 0 || !attribute.GetChildByRole(Roles.LPar).IsNull) { + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(attribute.Arguments, policy.SpaceWithinMethodCallParentheses); + } + EndNode(attribute); + } + + public void VisitAttributeSection(AttributeSection attributeSection) + { + StartNode(attributeSection); + WriteToken(Roles.LBracket); + if (!string.IsNullOrEmpty(attributeSection.AttributeTarget)) { + WriteToken(attributeSection.AttributeTarget, Roles.AttributeTargetRole); + WriteToken(Roles.Colon); + Space(); + } + WriteCommaSeparatedList(attributeSection.Attributes); + WriteToken(Roles.RBracket); + if (attributeSection.Parent is ParameterDeclaration || attributeSection.Parent is TypeParameterDeclaration) { + Space(); + } else { + NewLine(); + } + EndNode(attributeSection); + } + + public void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration) + { + StartNode(delegateDeclaration); + WriteAttributes(delegateDeclaration.Attributes); + WriteModifiers(delegateDeclaration.ModifierTokens); + WriteKeyword(Roles.DelegateKeyword); + delegateDeclaration.ReturnType.AcceptVisitor(this); + Space(); + delegateDeclaration.NameToken.AcceptVisitor(this); + WriteTypeParameters(delegateDeclaration.TypeParameters); + Space(policy.SpaceBeforeDelegateDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(delegateDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); foreach (Constraint constraint in delegateDeclaration.Constraints) { - constraint.AcceptVisitor (this, data); + constraint.AcceptVisitor(this); } - Semicolon (); - return EndNode (delegateDeclaration); + Semicolon(); + EndNode(delegateDeclaration); } - public object VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, object data) + public void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration) { - StartNode (namespaceDeclaration); - WriteKeyword ("namespace"); - WriteQualifiedIdentifier (namespaceDeclaration.Identifiers); - OpenBrace (policy.NamespaceBraceStyle); - foreach (var member in namespaceDeclaration.Members) - member.AcceptVisitor (this, data); - CloseBrace (policy.NamespaceBraceStyle); - OptionalSemicolon (); - NewLine (); - return EndNode (namespaceDeclaration); + StartNode(namespaceDeclaration); + WriteKeyword(Roles.NamespaceKeyword); + WriteQualifiedIdentifier(namespaceDeclaration.Identifiers); + OpenBrace(policy.NamespaceBraceStyle); + foreach (var member in namespaceDeclaration.Members) { + member.AcceptVisitor(this); + } + CloseBrace(policy.NamespaceBraceStyle); + OptionalSemicolon(); + NewLine(); + EndNode(namespaceDeclaration); } - public object VisitTypeDeclaration (TypeDeclaration typeDeclaration, object data) + public void VisitTypeDeclaration(TypeDeclaration typeDeclaration) { - 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"); + WriteKeyword(Roles.EnumKeyword); braceStyle = policy.EnumBraceStyle; break; case ClassType.Interface: - WriteKeyword ("interface"); + WriteKeyword(Roles.InterfaceKeyword); braceStyle = policy.InterfaceBraceStyle; break; case ClassType.Struct: - WriteKeyword ("struct"); + WriteKeyword(Roles.StructKeyword); braceStyle = policy.StructBraceStyle; break; default: - WriteKeyword ("class"); + WriteKeyword(Roles.ClassKeyword); braceStyle = policy.ClassBraceStyle; break; } - WriteIdentifier (typeDeclaration.Name); - WriteTypeParameters (typeDeclaration.TypeParameters); - if (typeDeclaration.BaseTypes.Any ()) { - Space (); - WriteToken (":", TypeDeclaration.ColonRole); - Space (); - WriteCommaSeparatedList (typeDeclaration.BaseTypes); + typeDeclaration.NameToken.AcceptVisitor(this); + WriteTypeParameters(typeDeclaration.TypeParameters); + if (typeDeclaration.BaseTypes.Any()) { + Space(); + WriteToken(Roles.Colon); + Space(); + WriteCommaSeparatedList(typeDeclaration.BaseTypes); } foreach (Constraint constraint in typeDeclaration.Constraints) { - constraint.AcceptVisitor (this, data); + constraint.AcceptVisitor(this); } - 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); } OptionalComma(); - NewLine (); + NewLine(); } else { foreach (var member in typeDeclaration.Members) { - member.AcceptVisitor (this, data); + member.AcceptVisitor(this); } } - CloseBrace (braceStyle); - OptionalSemicolon (); - NewLine (); - return EndNode (typeDeclaration); + CloseBrace(braceStyle); + OptionalSemicolon(); + NewLine(); + EndNode(typeDeclaration); } - public object VisitUsingAliasDeclaration (UsingAliasDeclaration usingAliasDeclaration, object data) + public void VisitUsingAliasDeclaration(UsingAliasDeclaration 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); + StartNode(usingAliasDeclaration); + WriteKeyword(UsingAliasDeclaration.UsingKeywordRole); + WriteIdentifier(usingAliasDeclaration.Alias, UsingAliasDeclaration.AliasRole); + Space(policy.SpaceAroundEqualityOperator); + WriteToken(Roles.Assign); + Space(policy.SpaceAroundEqualityOperator); + usingAliasDeclaration.Import.AcceptVisitor(this); + Semicolon(); + EndNode(usingAliasDeclaration); } - public object VisitUsingDeclaration (UsingDeclaration usingDeclaration, object data) + public void VisitUsingDeclaration(UsingDeclaration usingDeclaration) { - StartNode (usingDeclaration); - WriteKeyword ("using"); - usingDeclaration.Import.AcceptVisitor (this, data); - Semicolon (); - return EndNode (usingDeclaration); + StartNode(usingDeclaration); + WriteKeyword(UsingDeclaration.UsingKeywordRole); + usingDeclaration.Import.AcceptVisitor(this); + Semicolon(); + EndNode(usingDeclaration); } - public object VisitExternAliasDeclaration (ExternAliasDeclaration externAliasDeclaration, object data) + public void VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration) { - StartNode (externAliasDeclaration); - WriteKeyword ("extern"); - Space (); - WriteKeyword ("alias"); - Space (); - externAliasDeclaration.NameToken.AcceptVisitor (this, data); - Semicolon (); - return EndNode (externAliasDeclaration); + StartNode(externAliasDeclaration); + WriteKeyword(Roles.ExternKeyword); + Space(); + WriteKeyword(Roles.AliasKeyword); + Space(); + externAliasDeclaration.NameToken.AcceptVisitor(this); + Semicolon(); + EndNode(externAliasDeclaration); } #endregion #region Statements - public object VisitBlockStatement (BlockStatement blockStatement, object data) + public void VisitBlockStatement(BlockStatement blockStatement) { - StartNode (blockStatement); + StartNode(blockStatement); BraceStyle style; if (blockStatement.Parent is AnonymousMethodExpression || blockStatement.Parent is LambdaExpression) { style = policy.AnonymousMethodBraceStyle; @@ -1501,196 +1566,199 @@ namespace ICSharpCode.NRefactory.CSharp } else if (blockStatement.Parent is MethodDeclaration) { style = policy.MethodBraceStyle; } else if (blockStatement.Parent is Accessor) { - if (blockStatement.Parent.Role == PropertyDeclaration.GetterRole) + if (blockStatement.Parent.Role == PropertyDeclaration.GetterRole) { style = policy.PropertyGetBraceStyle; - else if (blockStatement.Parent.Role == PropertyDeclaration.SetterRole) + } else if (blockStatement.Parent.Role == PropertyDeclaration.SetterRole) { style = policy.PropertySetBraceStyle; - else if (blockStatement.Parent.Role == CustomEventDeclaration.AddAccessorRole) + } else if (blockStatement.Parent.Role == CustomEventDeclaration.AddAccessorRole) { style = policy.EventAddBraceStyle; - else if (blockStatement.Parent.Role == CustomEventDeclaration.RemoveAccessorRole) + } else if (blockStatement.Parent.Role == CustomEventDeclaration.RemoveAccessorRole) { style = policy.EventRemoveBraceStyle; - else - throw new NotSupportedException ("Unknown type of accessor"); + } else { + style = policy.StatementBraceStyle; + } } else { style = policy.StatementBraceStyle; } - OpenBrace (style); + OpenBrace(style); foreach (var node in blockStatement.Statements) { - node.AcceptVisitor (this, data); + node.AcceptVisitor(this); } - CloseBrace (style); - NewLine (); - return EndNode (blockStatement); + CloseBrace(style); + if (!(blockStatement.Parent is Expression)) + NewLine(); + EndNode(blockStatement); } - public object VisitBreakStatement (BreakStatement breakStatement, object data) + public void VisitBreakStatement(BreakStatement breakStatement) { - StartNode (breakStatement); - WriteKeyword ("break"); - Semicolon (); - return EndNode (breakStatement); + StartNode(breakStatement); + WriteKeyword("break"); + Semicolon(); + EndNode(breakStatement); } - public object VisitCheckedStatement (CheckedStatement checkedStatement, object data) + public void VisitCheckedStatement(CheckedStatement checkedStatement) { - StartNode (checkedStatement); - WriteKeyword ("checked"); - checkedStatement.Body.AcceptVisitor (this, data); - return EndNode (checkedStatement); + StartNode(checkedStatement); + WriteKeyword(CheckedStatement.CheckedKeywordRole); + checkedStatement.Body.AcceptVisitor(this); + EndNode(checkedStatement); } - public object VisitContinueStatement (ContinueStatement continueStatement, object data) + public void VisitContinueStatement(ContinueStatement continueStatement) { - StartNode (continueStatement); - WriteKeyword ("continue"); - Semicolon (); - return EndNode (continueStatement); + StartNode(continueStatement); + WriteKeyword("continue"); + Semicolon(); + EndNode(continueStatement); } - public object VisitDoWhileStatement (DoWhileStatement doWhileStatement, object data) + public void VisitDoWhileStatement(DoWhileStatement 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); + StartNode(doWhileStatement); + WriteKeyword(DoWhileStatement.DoKeywordRole); + WriteEmbeddedStatement(doWhileStatement.EmbeddedStatement); + WriteKeyword(DoWhileStatement.WhileKeywordRole); + Space(policy.SpaceBeforeWhileParentheses); + LPar(); + Space(policy.SpacesWithinWhileParentheses); + doWhileStatement.Condition.AcceptVisitor(this); + Space(policy.SpacesWithinWhileParentheses); + RPar(); + Semicolon(); + EndNode(doWhileStatement); } - public object VisitEmptyStatement (EmptyStatement emptyStatement, object data) + public void VisitEmptyStatement(EmptyStatement emptyStatement) { - StartNode (emptyStatement); - Semicolon (); - return EndNode (emptyStatement); + StartNode(emptyStatement); + Semicolon(); + EndNode(emptyStatement); } - public object VisitExpressionStatement (ExpressionStatement expressionStatement, object data) + public void VisitExpressionStatement(ExpressionStatement expressionStatement) { - StartNode (expressionStatement); - expressionStatement.Expression.AcceptVisitor (this, data); - Semicolon (); - return EndNode (expressionStatement); + StartNode(expressionStatement); + expressionStatement.Expression.AcceptVisitor(this); + Semicolon(); + EndNode(expressionStatement); } - public object VisitFixedStatement (FixedStatement fixedStatement, object data) + public void VisitFixedStatement(FixedStatement 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); + StartNode(fixedStatement); + WriteKeyword(FixedStatement.FixedKeywordRole); + Space(policy.SpaceBeforeUsingParentheses); + LPar(); + Space(policy.SpacesWithinUsingParentheses); + fixedStatement.Type.AcceptVisitor(this); + Space(); + WriteCommaSeparatedList(fixedStatement.Variables); + Space(policy.SpacesWithinUsingParentheses); + RPar(); + WriteEmbeddedStatement(fixedStatement.EmbeddedStatement); + EndNode(fixedStatement); } - public object VisitForeachStatement (ForeachStatement foreachStatement, object data) + public void VisitForeachStatement(ForeachStatement 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); + StartNode(foreachStatement); + WriteKeyword(ForeachStatement.ForeachKeywordRole); + Space(policy.SpaceBeforeForeachParentheses); + LPar(); + Space(policy.SpacesWithinForeachParentheses); + foreachStatement.VariableType.AcceptVisitor(this); + Space(); + foreachStatement.VariableNameToken.AcceptVisitor(this); + WriteKeyword(ForeachStatement.InKeywordRole); + Space(); + foreachStatement.InExpression.AcceptVisitor(this); + Space(policy.SpacesWithinForeachParentheses); + RPar(); + WriteEmbeddedStatement(foreachStatement.EmbeddedStatement); + EndNode(foreachStatement); } - public object VisitForStatement (ForStatement forStatement, object data) + public void VisitForStatement(ForStatement forStatement) { - StartNode (forStatement); - WriteKeyword ("for"); - Space (policy.SpaceBeforeForParentheses); - LPar (); - Space (policy.SpacesWithinForParentheses); + StartNode(forStatement); + WriteKeyword(ForStatement.ForKeywordRole); + Space(policy.SpaceBeforeForParentheses); + LPar(); + Space(policy.SpacesWithinForParentheses); - WriteCommaSeparatedList (forStatement.Initializers); - Space (policy.SpaceBeforeForSemicolon); - WriteToken (";", AstNode.Roles.Semicolon); - Space (policy.SpaceAfterForSemicolon); + WriteCommaSeparatedList(forStatement.Initializers); + Space(policy.SpaceBeforeForSemicolon); + WriteToken(Roles.Semicolon); + Space(policy.SpaceAfterForSemicolon); - forStatement.Condition.AcceptVisitor (this, data); - Space (policy.SpaceBeforeForSemicolon); - WriteToken (";", AstNode.Roles.Semicolon); - Space (policy.SpaceAfterForSemicolon); - - WriteCommaSeparatedList (forStatement.Iterators); + forStatement.Condition.AcceptVisitor(this); + Space(policy.SpaceBeforeForSemicolon); + WriteToken(Roles.Semicolon); + if (forStatement.Iterators.Any()) { + Space(policy.SpaceAfterForSemicolon); + WriteCommaSeparatedList(forStatement.Iterators); + } - Space (policy.SpacesWithinForParentheses); - RPar (); - WriteEmbeddedStatement (forStatement.EmbeddedStatement); - return EndNode (forStatement); + Space(policy.SpacesWithinForParentheses); + RPar(); + WriteEmbeddedStatement(forStatement.EmbeddedStatement); + EndNode(forStatement); } - public object VisitGotoCaseStatement (GotoCaseStatement gotoCaseStatement, object data) + public void VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement) { - StartNode (gotoCaseStatement); - WriteKeyword ("goto"); - WriteKeyword ("case", GotoCaseStatement.CaseKeywordRole); - Space (); - gotoCaseStatement.LabelExpression.AcceptVisitor (this, data); - Semicolon (); - return EndNode (gotoCaseStatement); + StartNode(gotoCaseStatement); + WriteKeyword(GotoCaseStatement.GotoKeywordRole); + WriteKeyword(GotoCaseStatement.CaseKeywordRole); + Space(); + gotoCaseStatement.LabelExpression.AcceptVisitor(this); + Semicolon(); + EndNode(gotoCaseStatement); } - public object VisitGotoDefaultStatement (GotoDefaultStatement gotoDefaultStatement, object data) + public void VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement) { - StartNode (gotoDefaultStatement); - WriteKeyword ("goto"); - WriteKeyword ("default", GotoDefaultStatement.DefaultKeywordRole); - Semicolon (); - return EndNode (gotoDefaultStatement); + StartNode(gotoDefaultStatement); + WriteKeyword(GotoDefaultStatement.GotoKeywordRole); + WriteKeyword(GotoDefaultStatement.DefaultKeywordRole); + Semicolon(); + EndNode(gotoDefaultStatement); } - public object VisitGotoStatement (GotoStatement gotoStatement, object data) + public void VisitGotoStatement(GotoStatement gotoStatement) { - StartNode (gotoStatement); - WriteKeyword ("goto"); - WriteIdentifier (gotoStatement.Label); - Semicolon (); - return EndNode (gotoStatement); + StartNode(gotoStatement); + WriteKeyword(GotoStatement.GotoKeywordRole); + WriteIdentifier(gotoStatement.Label); + Semicolon(); + EndNode(gotoStatement); } - public object VisitIfElseStatement (IfElseStatement ifElseStatement, object data) + public void VisitIfElseStatement(IfElseStatement ifElseStatement) { - 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(IfElseStatement.IfKeywordRole); + Space(policy.SpaceBeforeIfParentheses); + LPar(); + Space(policy.SpacesWithinIfParentheses); + ifElseStatement.Condition.AcceptVisitor(this); + Space(policy.SpacesWithinIfParentheses); + RPar(); + WriteEmbeddedStatement(ifElseStatement.TrueStatement); if (!ifElseStatement.FalseStatement.IsNull) { - WriteKeyword ("else", IfElseStatement.ElseKeywordRole); - WriteEmbeddedStatement (ifElseStatement.FalseStatement); + WriteKeyword(IfElseStatement.ElseKeywordRole); + WriteEmbeddedStatement(ifElseStatement.FalseStatement); } - return EndNode (ifElseStatement); + EndNode(ifElseStatement); } - public object VisitLabelStatement (LabelStatement labelStatement, object data) + public void VisitLabelStatement(LabelStatement labelStatement) { - StartNode (labelStatement); - WriteIdentifier (labelStatement.Label); - WriteToken (":", LabelStatement.Roles.Colon); + StartNode(labelStatement); + WriteIdentifier(labelStatement.Label); + WriteToken(Roles.Colon); bool foundLabelledStatement = false; for (AstNode tmp = labelStatement.NextSibling; tmp != null; tmp = tmp.NextSibling) { if (tmp.Role == labelStatement.Role) { @@ -1699,765 +1767,847 @@ namespace ICSharpCode.NRefactory.CSharp } if (!foundLabelledStatement) { // introduce an EmptyStatement so that the output becomes syntactically valid - WriteToken(";", LabelStatement.Roles.Semicolon); + WriteToken(Roles.Semicolon); } - NewLine (); - return EndNode (labelStatement); + NewLine(); + EndNode(labelStatement); } - public object VisitLockStatement (LockStatement lockStatement, object data) + public void VisitLockStatement(LockStatement 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); + StartNode(lockStatement); + WriteKeyword(LockStatement.LockKeywordRole); + Space(policy.SpaceBeforeLockParentheses); + LPar(); + Space(policy.SpacesWithinLockParentheses); + lockStatement.Expression.AcceptVisitor(this); + Space(policy.SpacesWithinLockParentheses); + RPar(); + WriteEmbeddedStatement(lockStatement.EmbeddedStatement); + EndNode(lockStatement); } - public object VisitReturnStatement (ReturnStatement returnStatement, object data) + public void VisitReturnStatement(ReturnStatement returnStatement) { - StartNode (returnStatement); - WriteKeyword ("return"); + StartNode(returnStatement); + WriteKeyword(ReturnStatement.ReturnKeywordRole); if (!returnStatement.Expression.IsNull) { - 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); - if (!policy.IndentSwitchBody) - formatter.Unindent (); + Space(); + returnStatement.Expression.AcceptVisitor(this); + } + Semicolon(); + EndNode(returnStatement); + } + + public void VisitSwitchStatement(SwitchStatement switchStatement) + { + StartNode(switchStatement); + WriteKeyword(SwitchStatement.SwitchKeywordRole); + Space(policy.SpaceBeforeSwitchParentheses); + LPar(); + Space(policy.SpacesWithinSwitchParentheses); + switchStatement.Expression.AcceptVisitor(this); + Space(policy.SpacesWithinSwitchParentheses); + RPar(); + OpenBrace(policy.StatementBraceStyle); + if (!policy.IndentSwitchBody) { + formatter.Unindent(); + } - foreach (var section in switchStatement.SwitchSections) - section.AcceptVisitor (this, data); + foreach (var section in switchStatement.SwitchSections) { + section.AcceptVisitor(this); + } - if (!policy.IndentSwitchBody) - formatter.Indent (); - CloseBrace (policy.StatementBraceStyle); - NewLine (); - return EndNode (switchStatement); + if (!policy.IndentSwitchBody) { + formatter.Indent(); + } + CloseBrace(policy.StatementBraceStyle); + NewLine(); + EndNode(switchStatement); } - public object VisitSwitchSection (SwitchSection switchSection, object data) + public void VisitSwitchSection(SwitchSection switchSection) { - StartNode (switchSection); + StartNode(switchSection); bool first = true; foreach (var label in switchSection.CaseLabels) { - if (!first) - NewLine (); - label.AcceptVisitor (this, data); + if (!first) { + NewLine(); + } + label.AcceptVisitor(this); first = false; } - if (policy.IndentCaseBody) - formatter.Indent (); + if (policy.IndentCaseBody) { + formatter.Indent(); + } foreach (var statement in switchSection.Statements) { - NewLine (); - statement.AcceptVisitor (this, data); + NewLine(); + statement.AcceptVisitor(this); } - if (policy.IndentCaseBody) - formatter.Unindent (); + if (policy.IndentCaseBody) { + formatter.Unindent(); + } - return EndNode (switchSection); + EndNode(switchSection); } - public object VisitCaseLabel (CaseLabel caseLabel, object data) + public void VisitCaseLabel(CaseLabel caseLabel) { - StartNode (caseLabel); + StartNode(caseLabel); if (caseLabel.Expression.IsNull) { - WriteKeyword ("default"); + WriteKeyword(CaseLabel.DefaultKeywordRole); } else { - WriteKeyword ("case"); - Space (); - caseLabel.Expression.AcceptVisitor (this, data); + WriteKeyword(CaseLabel.CaseKeywordRole); + Space(); + caseLabel.Expression.AcceptVisitor(this); } - WriteToken (":", CaseLabel.Roles.Colon); - return EndNode (caseLabel); + WriteToken(Roles.Colon); + EndNode(caseLabel); } - public object VisitThrowStatement (ThrowStatement throwStatement, object data) + public void VisitThrowStatement(ThrowStatement throwStatement) { - StartNode (throwStatement); - WriteKeyword ("throw"); + StartNode(throwStatement); + WriteKeyword(ThrowStatement.ThrowKeywordRole); if (!throwStatement.Expression.IsNull) { - Space (); - throwStatement.Expression.AcceptVisitor (this, data); + Space(); + throwStatement.Expression.AcceptVisitor(this); } - Semicolon (); - return EndNode (throwStatement); + Semicolon(); + EndNode(throwStatement); } - public object VisitTryCatchStatement (TryCatchStatement tryCatchStatement, object data) + public void VisitTryCatchStatement(TryCatchStatement tryCatchStatement) { - StartNode (tryCatchStatement); - WriteKeyword ("try", TryCatchStatement.TryKeywordRole); - tryCatchStatement.TryBlock.AcceptVisitor (this, data); - foreach (var catchClause in tryCatchStatement.CatchClauses) - catchClause.AcceptVisitor (this, data); + StartNode(tryCatchStatement); + WriteKeyword(TryCatchStatement.TryKeywordRole); + tryCatchStatement.TryBlock.AcceptVisitor(this); + foreach (var catchClause in tryCatchStatement.CatchClauses) { + catchClause.AcceptVisitor(this); + } if (!tryCatchStatement.FinallyBlock.IsNull) { - WriteKeyword ("finally", TryCatchStatement.FinallyKeywordRole); - tryCatchStatement.FinallyBlock.AcceptVisitor (this, data); + WriteKeyword(TryCatchStatement.FinallyKeywordRole); + tryCatchStatement.FinallyBlock.AcceptVisitor(this); } - return EndNode (tryCatchStatement); + EndNode(tryCatchStatement); } - public object VisitCatchClause (CatchClause catchClause, object data) + public void VisitCatchClause(CatchClause catchClause) { - StartNode (catchClause); - WriteKeyword ("catch"); + StartNode(catchClause); + WriteKeyword(CatchClause.CatchKeywordRole); if (!catchClause.Type.IsNull) { - Space (policy.SpaceBeforeCatchParentheses); - LPar (); - Space (policy.SpacesWithinCatchParentheses); - catchClause.Type.AcceptVisitor (this, data); + Space(policy.SpaceBeforeCatchParentheses); + LPar(); + Space(policy.SpacesWithinCatchParentheses); + catchClause.Type.AcceptVisitor(this); if (!string.IsNullOrEmpty(catchClause.VariableName)) { - Space (); - WriteIdentifier (catchClause.VariableName); + Space(); + catchClause.VariableNameToken.AcceptVisitor(this); } - Space (policy.SpacesWithinCatchParentheses); - RPar (); + Space(policy.SpacesWithinCatchParentheses); + RPar(); } - catchClause.Body.AcceptVisitor (this, data); - return EndNode (catchClause); + catchClause.Body.AcceptVisitor(this); + EndNode(catchClause); } - public object VisitUncheckedStatement (UncheckedStatement uncheckedStatement, object data) + public void VisitUncheckedStatement(UncheckedStatement uncheckedStatement) { - StartNode (uncheckedStatement); - WriteKeyword ("unchecked"); - uncheckedStatement.Body.AcceptVisitor (this, data); - return EndNode (uncheckedStatement); + StartNode(uncheckedStatement); + WriteKeyword(UncheckedStatement.UncheckedKeywordRole); + uncheckedStatement.Body.AcceptVisitor(this); + EndNode(uncheckedStatement); } - public object VisitUnsafeStatement (UnsafeStatement unsafeStatement, object data) + public void VisitUnsafeStatement(UnsafeStatement unsafeStatement) { - StartNode (unsafeStatement); - WriteKeyword ("unsafe"); - unsafeStatement.Body.AcceptVisitor (this, data); - return EndNode (unsafeStatement); + StartNode(unsafeStatement); + WriteKeyword(UnsafeStatement.UnsafeKeywordRole); + unsafeStatement.Body.AcceptVisitor(this); + EndNode(unsafeStatement); } - public object VisitUsingStatement (UsingStatement usingStatement, object data) + public void VisitUsingStatement(UsingStatement usingStatement) { - StartNode (usingStatement); - WriteKeyword ("using"); - Space (policy.SpaceBeforeUsingParentheses); - LPar (); - Space (policy.SpacesWithinUsingParentheses); + StartNode(usingStatement); + WriteKeyword(UsingStatement.UsingKeywordRole); + Space(policy.SpaceBeforeUsingParentheses); + LPar(); + Space(policy.SpacesWithinUsingParentheses); - usingStatement.ResourceAcquisition.AcceptVisitor (this, data); + usingStatement.ResourceAcquisition.AcceptVisitor(this); - Space (policy.SpacesWithinUsingParentheses); - RPar (); + Space(policy.SpacesWithinUsingParentheses); + RPar(); - WriteEmbeddedStatement (usingStatement.EmbeddedStatement); + WriteEmbeddedStatement(usingStatement.EmbeddedStatement); - return EndNode (usingStatement); + EndNode(usingStatement); } - public object VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, object data) + public void VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement) { - StartNode (variableDeclarationStatement); - WriteModifiers (variableDeclarationStatement.GetChildrenByRole (VariableDeclarationStatement.ModifierRole)); - variableDeclarationStatement.Type.AcceptVisitor (this, data); - Space (); - WriteCommaSeparatedList (variableDeclarationStatement.Variables); - Semicolon (); - return EndNode (variableDeclarationStatement); + StartNode(variableDeclarationStatement); + WriteModifiers(variableDeclarationStatement.GetChildrenByRole(VariableDeclarationStatement.ModifierRole)); + variableDeclarationStatement.Type.AcceptVisitor(this); + Space(); + WriteCommaSeparatedList(variableDeclarationStatement.Variables); + Semicolon(); + EndNode(variableDeclarationStatement); } - public object VisitWhileStatement (WhileStatement whileStatement, object data) + public void VisitWhileStatement(WhileStatement 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); + StartNode(whileStatement); + WriteKeyword(WhileStatement.WhileKeywordRole); + Space(policy.SpaceBeforeWhileParentheses); + LPar(); + Space(policy.SpacesWithinWhileParentheses); + whileStatement.Condition.AcceptVisitor(this); + Space(policy.SpacesWithinWhileParentheses); + RPar(); + WriteEmbeddedStatement(whileStatement.EmbeddedStatement); + EndNode(whileStatement); } - public object VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement, object data) + public void VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement) { - StartNode (yieldBreakStatement); - WriteKeyword ("yield", YieldBreakStatement.YieldKeywordRole); - WriteKeyword ("break", YieldBreakStatement.BreakKeywordRole); - Semicolon (); - return EndNode (yieldBreakStatement); + StartNode(yieldBreakStatement); + WriteKeyword(YieldBreakStatement.YieldKeywordRole); + WriteKeyword(YieldBreakStatement.BreakKeywordRole); + Semicolon(); + EndNode(yieldBreakStatement); } - public object VisitYieldReturnStatement (YieldReturnStatement yieldReturnStatement, object data) + public void VisitYieldReturnStatement(YieldReturnStatement yieldReturnStatement) { - StartNode (yieldReturnStatement); - WriteKeyword ("yield", YieldReturnStatement.YieldKeywordRole); - WriteKeyword ("return", YieldReturnStatement.ReturnKeywordRole); - Space (); - yieldReturnStatement.Expression.AcceptVisitor (this, data); - Semicolon (); - return EndNode (yieldReturnStatement); + StartNode(yieldReturnStatement); + WriteKeyword(YieldReturnStatement.YieldKeywordRole); + WriteKeyword(YieldReturnStatement.ReturnKeywordRole); + Space(); + yieldReturnStatement.Expression.AcceptVisitor(this); + Semicolon(); + EndNode(yieldReturnStatement); } #endregion #region TypeMembers - public object VisitAccessor (Accessor accessor, object data) + public void VisitAccessor(Accessor accessor) { - 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); + EndNode(accessor); } - public object VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, object data) + public void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration) { - 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); + StartNode(constructorDeclaration.NameToken); + WriteIdentifier(type != null ? type.Name : constructorDeclaration.Name); + EndNode(constructorDeclaration.NameToken); + Space(policy.SpaceBeforeConstructorDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(constructorDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); if (!constructorDeclaration.Initializer.IsNull) { - Space (); - constructorDeclaration.Initializer.AcceptVisitor (this, data); + Space(); + constructorDeclaration.Initializer.AcceptVisitor(this); } - WriteMethodBody (constructorDeclaration.Body); - return EndNode (constructorDeclaration); + WriteMethodBody(constructorDeclaration.Body); + EndNode(constructorDeclaration); } - public object VisitConstructorInitializer (ConstructorInitializer constructorInitializer, object data) + public void VisitConstructorInitializer(ConstructorInitializer constructorInitializer) { - StartNode (constructorInitializer); - WriteToken (":", ConstructorInitializer.Roles.Colon); - Space (); + StartNode(constructorInitializer); + WriteToken(Roles.Colon); + Space(); if (constructorInitializer.ConstructorInitializerType == ConstructorInitializerType.This) { - WriteKeyword ("this"); + WriteKeyword(ConstructorInitializer.ThisKeywordRole); } else { - WriteKeyword ("base"); + WriteKeyword(ConstructorInitializer.BaseKeywordRole); } - Space (policy.SpaceBeforeMethodCallParentheses); - WriteCommaSeparatedListInParenthesis (constructorInitializer.Arguments, policy.SpaceWithinMethodCallParentheses); - return EndNode (constructorInitializer); + Space(policy.SpaceBeforeMethodCallParentheses); + WriteCommaSeparatedListInParenthesis(constructorInitializer.Arguments, policy.SpaceWithinMethodCallParentheses); + EndNode(constructorInitializer); } - public object VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, object data) + public void VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration) { - 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); + StartNode(destructorDeclaration.NameToken); + WriteIdentifier(type != null ? type.Name : destructorDeclaration.Name); + EndNode(destructorDeclaration.NameToken); + Space(policy.SpaceBeforeConstructorDeclarationParentheses); + LPar(); + RPar(); + WriteMethodBody(destructorDeclaration.Body); + EndNode(destructorDeclaration); + } + + public void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration) + { + StartNode(enumMemberDeclaration); + WriteAttributes(enumMemberDeclaration.Attributes); + WriteModifiers(enumMemberDeclaration.ModifierTokens); + enumMemberDeclaration.NameToken.AcceptVisitor(this); + if (!enumMemberDeclaration.Initializer.IsNull) { + Space(policy.SpaceAroundAssignment); + WriteToken(Roles.Assign); + Space(policy.SpaceAroundAssignment); + enumMemberDeclaration.Initializer.AcceptVisitor(this); + } + EndNode(enumMemberDeclaration); } - public object VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, object data) + public void VisitEventDeclaration(EventDeclaration eventDeclaration) { - 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); + StartNode(eventDeclaration); + WriteAttributes(eventDeclaration.Attributes); + WriteModifiers(eventDeclaration.ModifierTokens); + WriteKeyword(EventDeclaration.EventKeywordRole); + eventDeclaration.ReturnType.AcceptVisitor(this); + Space(); + WriteCommaSeparatedList(eventDeclaration.Variables); + Semicolon(); + EndNode(eventDeclaration); + } + + public void VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration) + { + StartNode(customEventDeclaration); + WriteAttributes(customEventDeclaration.Attributes); + WriteModifiers(customEventDeclaration.ModifierTokens); + WriteKeyword(CustomEventDeclaration.EventKeywordRole); + customEventDeclaration.ReturnType.AcceptVisitor(this); + Space(); + WritePrivateImplementationType(customEventDeclaration.PrivateImplementationType); + customEventDeclaration.NameToken.AcceptVisitor(this); + 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); } } - CloseBrace (policy.EventBraceStyle); - NewLine (); - return EndNode (customEventDeclaration); + CloseBrace(policy.EventBraceStyle); + NewLine(); + EndNode(customEventDeclaration); } - public object VisitFieldDeclaration (FieldDeclaration fieldDeclaration, object data) + public void VisitFieldDeclaration(FieldDeclaration fieldDeclaration) { - StartNode (fieldDeclaration); - WriteAttributes (fieldDeclaration.Attributes); - WriteModifiers (fieldDeclaration.ModifierTokens); - fieldDeclaration.ReturnType.AcceptVisitor (this, data); - Space (); - WriteCommaSeparatedList (fieldDeclaration.Variables); - Semicolon (); - return EndNode (fieldDeclaration); + StartNode(fieldDeclaration); + WriteAttributes(fieldDeclaration.Attributes); + WriteModifiers(fieldDeclaration.ModifierTokens); + fieldDeclaration.ReturnType.AcceptVisitor(this); + Space(); + WriteCommaSeparatedList(fieldDeclaration.Variables); + Semicolon(); + EndNode(fieldDeclaration); } - public object VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, object data) + public void VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration) { - StartNode (fixedFieldDeclaration); - WriteAttributes (fixedFieldDeclaration.Attributes); - WriteModifiers (fixedFieldDeclaration.ModifierTokens); - WriteKeyword ("fixed"); - Space (); - fixedFieldDeclaration.ReturnType.AcceptVisitor (this, data); - Space (); - WriteCommaSeparatedList (fixedFieldDeclaration.Variables); - Semicolon (); - return EndNode (fixedFieldDeclaration); + StartNode(fixedFieldDeclaration); + WriteAttributes(fixedFieldDeclaration.Attributes); + WriteModifiers(fixedFieldDeclaration.ModifierTokens); + WriteKeyword(FixedFieldDeclaration.FixedKeywordRole); + Space(); + fixedFieldDeclaration.ReturnType.AcceptVisitor(this); + Space(); + WriteCommaSeparatedList(fixedFieldDeclaration.Variables); + Semicolon(); + EndNode(fixedFieldDeclaration); } - public object VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer, object data) + public void VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer) { - StartNode (fixedVariableInitializer); - WriteIdentifier (fixedVariableInitializer.Name); + StartNode(fixedVariableInitializer); + fixedVariableInitializer.NameToken.AcceptVisitor(this); if (!fixedVariableInitializer.CountExpression.IsNull) { - WriteToken ("[", AstNode.Roles.LBracket); - Space (policy.SpacesWithinBrackets); - fixedVariableInitializer.CountExpression.AcceptVisitor (this, data); - Space (policy.SpacesWithinBrackets); - WriteToken ("]", AstNode.Roles.RBracket); - } - return EndNode (fixedVariableInitializer); - } - - public object VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, object data) - { - 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); + WriteToken(Roles.LBracket); + Space(policy.SpacesWithinBrackets); + fixedVariableInitializer.CountExpression.AcceptVisitor(this); + Space(policy.SpacesWithinBrackets); + WriteToken(Roles.RBracket); + } + EndNode(fixedVariableInitializer); + } + + public void VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration) + { + StartNode(indexerDeclaration); + WriteAttributes(indexerDeclaration.Attributes); + WriteModifiers(indexerDeclaration.ModifierTokens); + indexerDeclaration.ReturnType.AcceptVisitor(this); + WritePrivateImplementationType(indexerDeclaration.PrivateImplementationType); + WriteKeyword(IndexerDeclaration.ThisKeywordRole); + 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); } } - CloseBrace (policy.PropertyBraceStyle); - NewLine (); - return EndNode (indexerDeclaration); + CloseBrace(policy.PropertyBraceStyle); + NewLine(); + EndNode(indexerDeclaration); } - public object VisitMethodDeclaration (MethodDeclaration methodDeclaration, object data) + public void VisitMethodDeclaration(MethodDeclaration methodDeclaration) { - 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); + Space(); + WritePrivateImplementationType(methodDeclaration.PrivateImplementationType); + methodDeclaration.NameToken.AcceptVisitor(this); + WriteTypeParameters(methodDeclaration.TypeParameters); + Space(policy.SpaceBeforeMethodDeclarationParentheses); + WriteCommaSeparatedListInParenthesis(methodDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses); foreach (Constraint constraint in methodDeclaration.Constraints) { - constraint.AcceptVisitor (this, data); + constraint.AcceptVisitor(this); } - WriteMethodBody (methodDeclaration.Body); - return EndNode (methodDeclaration); + WriteMethodBody(methodDeclaration.Body); + EndNode(methodDeclaration); } - public object VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, object data) + public void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) { - 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(OperatorDeclaration.ExplicitRole); } else if (operatorDeclaration.OperatorType == OperatorType.Implicit) { - WriteKeyword ("implicit", OperatorDeclaration.OperatorTypeRole); + WriteKeyword(OperatorDeclaration.ImplicitRole); } else { - operatorDeclaration.ReturnType.AcceptVisitor (this, data); + operatorDeclaration.ReturnType.AcceptVisitor(this); } - WriteKeyword ("operator", OperatorDeclaration.OperatorKeywordRole); - Space (); + WriteKeyword(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); } else { - WriteToken (OperatorDeclaration.GetToken (operatorDeclaration.OperatorType), OperatorDeclaration.OperatorTypeRole); + WriteToken(OperatorDeclaration.GetToken(operatorDeclaration.OperatorType), OperatorDeclaration.GetRole(operatorDeclaration.OperatorType)); } - 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); + EndNode(operatorDeclaration); } - public object VisitParameterDeclaration (ParameterDeclaration parameterDeclaration, object data) + public void VisitParameterDeclaration(ParameterDeclaration parameterDeclaration) { - StartNode (parameterDeclaration); - WriteAttributes (parameterDeclaration.Attributes); + StartNode(parameterDeclaration); + WriteAttributes(parameterDeclaration.Attributes); switch (parameterDeclaration.ParameterModifier) { case ParameterModifier.Ref: - WriteKeyword ("ref", ParameterDeclaration.ModifierRole); + WriteKeyword(ParameterDeclaration.RefModifierRole); break; case ParameterModifier.Out: - WriteKeyword ("out", ParameterDeclaration.ModifierRole); + WriteKeyword(ParameterDeclaration.OutModifierRole); break; case ParameterModifier.Params: - WriteKeyword ("params", ParameterDeclaration.ModifierRole); + WriteKeyword(ParameterDeclaration.ParamsModifierRole); break; case ParameterModifier.This: - WriteKeyword ("this", ParameterDeclaration.ModifierRole); + WriteKeyword(ParameterDeclaration.ThisModifierRole); 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); + if (!parameterDeclaration.Type.IsNull && !string.IsNullOrEmpty(parameterDeclaration.Name)) { + Space(); + } + if (!string.IsNullOrEmpty(parameterDeclaration.Name)) { + parameterDeclaration.NameToken.AcceptVisitor(this); + } if (!parameterDeclaration.DefaultExpression.IsNull) { - Space (policy.SpaceAroundAssignment); - WriteToken ("=", ParameterDeclaration.Roles.Assign); - Space (policy.SpaceAroundAssignment); - parameterDeclaration.DefaultExpression.AcceptVisitor (this, data); + Space(policy.SpaceAroundAssignment); + WriteToken(Roles.Assign); + Space(policy.SpaceAroundAssignment); + parameterDeclaration.DefaultExpression.AcceptVisitor(this); } - return EndNode (parameterDeclaration); + EndNode(parameterDeclaration); } - public object VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, object data) + public void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { - 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); + Space(); + WritePrivateImplementationType(propertyDeclaration.PrivateImplementationType); + propertyDeclaration.NameToken.AcceptVisitor(this); + 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); } } - CloseBrace (policy.PropertyBraceStyle); - NewLine (); - return EndNode (propertyDeclaration); + CloseBrace(policy.PropertyBraceStyle); + NewLine(); + EndNode(propertyDeclaration); } #endregion #region Other nodes - public object VisitVariableInitializer (VariableInitializer variableInitializer, object data) + public void VisitVariableInitializer(VariableInitializer variableInitializer) { - StartNode (variableInitializer); - WriteIdentifier (variableInitializer.Name); + StartNode(variableInitializer); + variableInitializer.NameToken.AcceptVisitor(this); if (!variableInitializer.Initializer.IsNull) { - Space (policy.SpaceAroundAssignment); - WriteToken ("=", VariableInitializer.Roles.Assign); - Space (policy.SpaceAroundAssignment); - variableInitializer.Initializer.AcceptVisitor (this, data); + Space(policy.SpaceAroundAssignment); + WriteToken(Roles.Assign); + Space(policy.SpaceAroundAssignment); + variableInitializer.Initializer.AcceptVisitor(this); } - return EndNode (variableInitializer); + EndNode(variableInitializer); } - public object VisitCompilationUnit (CompilationUnit compilationUnit, object data) + public void VisitCompilationUnit(CompilationUnit compilationUnit) { // don't do node tracking as we visit all children directly - foreach (AstNode node in compilationUnit.Children) - node.AcceptVisitor (this, data); - return null; + foreach (AstNode node in compilationUnit.Children) { + node.AcceptVisitor(this); + } } - public object VisitSimpleType (SimpleType simpleType, object data) + public void VisitSimpleType(SimpleType simpleType) { - StartNode (simpleType); - WriteIdentifier (simpleType.Identifier); - WriteTypeArguments (simpleType.TypeArguments); - return EndNode (simpleType); + StartNode(simpleType); + WriteIdentifier(simpleType.Identifier); + WriteTypeArguments(simpleType.TypeArguments); + EndNode(simpleType); } - public object VisitMemberType (MemberType memberType, object data) + public void VisitMemberType(MemberType memberType) { - StartNode (memberType); - memberType.Target.AcceptVisitor (this, data); - if (memberType.IsDoubleColon) - WriteToken ("::", MemberType.Roles.Dot); - else - WriteToken (".", MemberType.Roles.Dot); - WriteIdentifier (memberType.MemberName); - WriteTypeArguments (memberType.TypeArguments); - return EndNode (memberType); + StartNode(memberType); + memberType.Target.AcceptVisitor(this); + if (memberType.IsDoubleColon) { + WriteToken(Roles.DoubleColon); + } else { + WriteToken(Roles.Dot); + } + WriteIdentifier(memberType.MemberName); + WriteTypeArguments(memberType.TypeArguments); + EndNode(memberType); } - public object VisitComposedType (ComposedType composedType, object data) + public void VisitComposedType(ComposedType composedType) { - StartNode (composedType); - composedType.BaseType.AcceptVisitor (this, data); - if (composedType.HasNullableSpecifier) - WriteToken ("?", ComposedType.NullableRole); - for (int i = 0; i < composedType.PointerRank; i++) - WriteToken ("*", ComposedType.PointerRole); - foreach (var node in composedType.ArraySpecifiers) - node.AcceptVisitor (this, data); - return EndNode (composedType); + StartNode(composedType); + composedType.BaseType.AcceptVisitor(this); + if (composedType.HasNullableSpecifier) { + WriteToken(ComposedType.NullableRole); + } + for (int i = 0; i < composedType.PointerRank; i++) { + WriteToken(ComposedType.PointerRole); + } + foreach (var node in composedType.ArraySpecifiers) { + node.AcceptVisitor(this); + } + EndNode(composedType); } - public object VisitArraySpecifier (ArraySpecifier arraySpecifier, object data) + public void VisitArraySpecifier(ArraySpecifier arraySpecifier) { - StartNode (arraySpecifier); - WriteToken ("[", ArraySpecifier.Roles.LBracket); - foreach (var comma in arraySpecifier.GetChildrenByRole(ArraySpecifier.Roles.Comma)) { - WriteSpecialsUpToNode (comma); - formatter.WriteToken (","); + StartNode(arraySpecifier); + WriteToken(Roles.LBracket); + foreach (var comma in arraySpecifier.GetChildrenByRole(Roles.Comma)) { + WriteSpecialsUpToNode(comma); + formatter.WriteToken(","); lastWritten = LastWritten.Other; } - WriteToken ("]", ArraySpecifier.Roles.RBracket); - return EndNode (arraySpecifier); + WriteToken(Roles.RBracket); + EndNode(arraySpecifier); } - public object VisitPrimitiveType (PrimitiveType primitiveType, object data) + public void VisitPrimitiveType(PrimitiveType primitiveType) { - StartNode (primitiveType); - WriteKeyword (primitiveType.Keyword); + StartNode(primitiveType); + WriteKeyword(primitiveType.Keyword); if (primitiveType.Keyword == "new") { // new() constraint - LPar (); - RPar (); + LPar(); + RPar(); } - return EndNode (primitiveType); + EndNode(primitiveType); } - public object VisitComment (Comment comment, object data) + public void VisitComment(Comment comment) { 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.StartNode(comment); - formatter.WriteComment (comment.CommentType, comment.Content); + formatter.WriteComment(comment.CommentType, comment.Content); formatter.EndNode(comment); lastWritten = LastWritten.Whitespace; - return null; } - - public object VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective, object data) + + public void VisitNewLine(NewLineNode newLineNode) + { + formatter.StartNode(newLineNode); + formatter.NewLine(); + formatter.EndNode(newLineNode); + } + + public void VisitWhitespace(WhitespaceNode whitespaceNode) + { + // unused + } + + public void VisitText(TextNode textNode) { - formatter.StartNode (preProcessorDirective); + // unused + } + + public void VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective) + { + formatter.StartNode(preProcessorDirective); formatter.WritePreProcessorDirective(preProcessorDirective.Type, preProcessorDirective.Argument); - formatter.EndNode (preProcessorDirective); + formatter.EndNode(preProcessorDirective); lastWritten = LastWritten.Whitespace; - return null; } - public object VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration, object data) + public void VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration) { - StartNode (typeParameterDeclaration); - WriteAttributes (typeParameterDeclaration.Attributes); + StartNode(typeParameterDeclaration); + WriteAttributes(typeParameterDeclaration.Attributes); switch (typeParameterDeclaration.Variance) { case VarianceModifier.Invariant: break; case VarianceModifier.Covariant: - WriteKeyword ("out"); + WriteKeyword(TypeParameterDeclaration.OutVarianceKeywordRole); break; case VarianceModifier.Contravariant: - WriteKeyword ("in"); + WriteKeyword(TypeParameterDeclaration.InVarianceKeywordRole); break; default: throw new NotSupportedException ("Invalid value for VarianceModifier"); } - WriteIdentifier (typeParameterDeclaration.Name); - return EndNode (typeParameterDeclaration); + typeParameterDeclaration.NameToken.AcceptVisitor(this); + EndNode(typeParameterDeclaration); } - public object VisitConstraint (Constraint constraint, object data) + public void VisitConstraint(Constraint constraint) { - StartNode (constraint); - Space (); - WriteKeyword ("where"); - WriteIdentifier (constraint.TypeParameter.Identifier); - Space (); - WriteToken (":", Constraint.ColonRole); - Space (); - WriteCommaSeparatedList (constraint.BaseTypes); - return EndNode (constraint); + StartNode(constraint); + Space(); + WriteKeyword(Roles.WhereKeyword); + WriteIdentifier(constraint.TypeParameter.Identifier); + Space(); + WriteToken(Roles.Colon); + Space(); + WriteCommaSeparatedList(constraint.BaseTypes); + EndNode(constraint); } - public object VisitCSharpTokenNode (CSharpTokenNode cSharpTokenNode, object data) + public void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode) { 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)); + EndNode(mod); } else { throw new NotSupportedException ("Should never visit individual tokens"); } } - public object VisitIdentifier (Identifier identifier, object data) + public void VisitIdentifier(Identifier identifier) { - StartNode (identifier); - WriteIdentifier (identifier.Name); - return EndNode (identifier); + StartNode(identifier); + WriteIdentifier(identifier.Name); + EndNode(identifier); } #endregion #region Pattern Nodes - public object VisitPatternPlaceholder (AstNode placeholder, PatternMatching.Pattern pattern, object data) + public void VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern) { - StartNode (placeholder); - VisitNodeInPattern(pattern, data); - return EndNode (placeholder); + StartNode(placeholder); + VisitNodeInPattern(pattern); + EndNode(placeholder); } - void VisitAnyNode (AnyNode anyNode, object data) + void VisitAnyNode(AnyNode anyNode) { - if (!string.IsNullOrEmpty (anyNode.GroupName)) { - WriteIdentifier (anyNode.GroupName); - WriteToken (":", AstNode.Roles.Colon); + if (!string.IsNullOrEmpty(anyNode.GroupName)) { + WriteIdentifier(anyNode.GroupName); + WriteToken(Roles.Colon); } } - void VisitBackreference (Backreference backreference, object data) + void VisitBackreference(Backreference backreference) { - WriteKeyword ("backreference"); - LPar (); - WriteIdentifier (backreference.ReferencedGroupName); - RPar (); + WriteKeyword("backreference"); + LPar(); + WriteIdentifier(backreference.ReferencedGroupName); + RPar(); } - void VisitIdentifierExpressionBackreference (IdentifierExpressionBackreference identifierExpressionBackreference, object data) + void VisitIdentifierExpressionBackreference(IdentifierExpressionBackreference identifierExpressionBackreference) { - WriteKeyword ("identifierBackreference"); - LPar (); - WriteIdentifier (identifierExpressionBackreference.ReferencedGroupName); - RPar (); + WriteKeyword("identifierBackreference"); + LPar(); + WriteIdentifier(identifierExpressionBackreference.ReferencedGroupName); + RPar(); } - void VisitChoice (Choice choice, object data) + void VisitChoice(Choice choice) { - 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); + if (alternative != choice.Last()) { + WriteToken(Roles.Comma); + } + NewLine(); } - formatter.Unindent (); - RPar (); + formatter.Unindent(); + RPar(); } - void VisitNamedNode (NamedNode namedNode, object data) + void VisitNamedNode(NamedNode namedNode) { - if (!string.IsNullOrEmpty (namedNode.GroupName)) { - WriteIdentifier (namedNode.GroupName); - WriteToken (":", AstNode.Roles.Colon); + if (!string.IsNullOrEmpty(namedNode.GroupName)) { + WriteIdentifier(namedNode.GroupName); + WriteToken(Roles.Colon); } - VisitNodeInPattern (namedNode.ChildNode, data); + VisitNodeInPattern(namedNode.ChildNode); } - void VisitRepeat (Repeat repeat, object data) + void VisitRepeat(Repeat repeat) { - 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(Roles.Comma); + WriteIdentifier(repeat.MaxCount.ToString()); + WriteToken(Roles.Comma); } - VisitNodeInPattern (repeat.ChildNode, data); - RPar (); + VisitNodeInPattern(repeat.ChildNode); + RPar(); } - void VisitOptionalNode (OptionalNode optionalNode, object data) + void VisitOptionalNode(OptionalNode optionalNode) { - WriteKeyword ("optional"); - LPar (); - VisitNodeInPattern (optionalNode.ChildNode, data); - RPar (); + WriteKeyword("optional"); + LPar(); + VisitNodeInPattern(optionalNode.ChildNode); + RPar(); } - void VisitNodeInPattern (INode childNode, object data) + void VisitNodeInPattern(INode childNode) { if (childNode is AstNode) { - ((AstNode)childNode).AcceptVisitor(this, data); + ((AstNode)childNode).AcceptVisitor(this); } else if (childNode is IdentifierExpressionBackreference) { - VisitIdentifierExpressionBackreference((IdentifierExpressionBackreference)childNode, data); + VisitIdentifierExpressionBackreference((IdentifierExpressionBackreference)childNode); } else if (childNode is Choice) { - VisitChoice((Choice)childNode, data); + VisitChoice((Choice)childNode); } else if (childNode is AnyNode) { - VisitAnyNode((AnyNode)childNode, data); + VisitAnyNode((AnyNode)childNode); } else if (childNode is Backreference) { - VisitBackreference((Backreference)childNode, data); + VisitBackreference((Backreference)childNode); } else if (childNode is NamedNode) { - VisitNamedNode((NamedNode)childNode, data); + VisitNamedNode((NamedNode)childNode); } else if (childNode is OptionalNode) { - VisitOptionalNode((OptionalNode)childNode, data); + VisitOptionalNode((OptionalNode)childNode); } else if (childNode is Repeat) { - VisitRepeat((Repeat)childNode, data); + VisitRepeat((Repeat)childNode); } else { WritePrimitiveValue(childNode); } } #endregion + + #region Documentation Reference + public void VisitDocumentationReference(DocumentationReference documentationReference) + { + StartNode(documentationReference); + if (!documentationReference.DeclaringType.IsNull) { + documentationReference.DeclaringType.AcceptVisitor(this); + if (documentationReference.EntityType != EntityType.TypeDefinition) { + WriteToken(Roles.Dot); + } + } + switch (documentationReference.EntityType) { + case EntityType.TypeDefinition: + // we already printed the DeclaringType + break; + case EntityType.Indexer: + WriteKeyword(IndexerDeclaration.ThisKeywordRole); + break; + case EntityType.Operator: + var opType = documentationReference.OperatorType; + if (opType == OperatorType.Explicit) { + WriteKeyword(OperatorDeclaration.ExplicitRole); + } else if (opType == OperatorType.Implicit) { + WriteKeyword(OperatorDeclaration.ImplicitRole); + } + WriteKeyword(OperatorDeclaration.OperatorKeywordRole); + Space(); + if (opType == OperatorType.Explicit || opType == OperatorType.Implicit) { + documentationReference.ConversionOperatorReturnType.AcceptVisitor(this); + } else { + WriteToken(OperatorDeclaration.GetToken(opType), OperatorDeclaration.GetRole(opType)); + } + break; + default: + WriteIdentifier(documentationReference.MemberName); + break; + } + WriteTypeArguments(documentationReference.TypeArguments); + if (documentationReference.HasParameterList) { + Space(policy.SpaceBeforeMethodDeclarationParentheses); + if (documentationReference.EntityType == EntityType.Indexer) { + WriteCommaSeparatedListInBrackets(documentationReference.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + } else { + WriteCommaSeparatedListInParenthesis(documentationReference.Parameters, policy.SpaceWithinMethodDeclarationParentheses); + } + } + EndNode(documentationReference); + } + #endregion } } diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs index 4775282ee..6b55c1490 100644 --- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs @@ -1,4 +1,4 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team +// 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 @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp /// /// The conversion is intended for use in the SharpDevelop forms designer. /// - public class CodeDomConvertVisitor : IAstVisitor + public class CodeDomConvertVisitor : IAstVisitor { //ICompilation compilation = MinimalResolveContext.Instance; CSharpAstResolver resolver; @@ -171,7 +171,7 @@ namespace ICSharpCode.NRefactory.CSharp string MakeSnippet(AstNode node) { StringWriter w = new StringWriter(); - CSharpOutputVisitor v = new CSharpOutputVisitor(w, new CSharpFormattingOptions()); + CSharpOutputVisitor v = new CSharpOutputVisitor(w, FormattingOptionsFactory.CreateMono ()); node.AcceptVisitor(v); return w.ToString(); } @@ -190,17 +190,17 @@ namespace ICSharpCode.NRefactory.CSharp return new CodeSnippetStatement(MakeSnippet(stmt)); } - CodeObject IAstVisitor.VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) + CodeObject IAstVisitor.VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression) { return MakeSnippetExpression(anonymousMethodExpression); } - CodeObject IAstVisitor.VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, object data) + CodeObject IAstVisitor.VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression) { return MakeSnippetExpression(undocumentedExpression); } - CodeObject IAstVisitor.VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) + CodeObject IAstVisitor.VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression) { CodeArrayCreateExpression ace = new CodeArrayCreateExpression(); int dimensions = arrayCreateExpression.Arguments.Count; @@ -223,29 +223,29 @@ namespace ICSharpCode.NRefactory.CSharp return ace; } - CodeObject IAstVisitor.VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, object data) + CodeObject IAstVisitor.VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression) { // Array initializers should be handled by the parent node return MakeSnippetExpression(arrayInitializerExpression); } - CodeObject IAstVisitor.VisitAsExpression(AsExpression asExpression, object data) + CodeObject IAstVisitor.VisitAsExpression(AsExpression asExpression) { return MakeSnippetExpression(asExpression); } - CodeObject IAstVisitor.VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) + CodeObject IAstVisitor.VisitAssignmentExpression(AssignmentExpression assignmentExpression) { // assignments are only supported as statements, not as expressions return MakeSnippetExpression(assignmentExpression); } - CodeObject IAstVisitor.VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) + CodeObject IAstVisitor.VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression) { return new CodeBaseReferenceExpression(); } - CodeObject IAstVisitor.VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) + CodeObject IAstVisitor.VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression) { CodeBinaryOperatorType op; switch (binaryOperatorExpression.Operator) { @@ -322,27 +322,27 @@ namespace ICSharpCode.NRefactory.CSharp return new CodeBinaryOperatorExpression(Convert(binaryOperatorExpression.Left), op, Convert(binaryOperatorExpression.Right)); } - CodeObject IAstVisitor.VisitCastExpression(CastExpression castExpression, object data) + CodeObject IAstVisitor.VisitCastExpression(CastExpression castExpression) { return new CodeCastExpression(Convert(castExpression.Type), Convert(castExpression.Expression)); } - CodeObject IAstVisitor.VisitCheckedExpression(CheckedExpression checkedExpression, object data) + CodeObject IAstVisitor.VisitCheckedExpression(CheckedExpression checkedExpression) { return MakeSnippetExpression(checkedExpression); } - CodeObject IAstVisitor.VisitConditionalExpression(ConditionalExpression conditionalExpression, object data) + CodeObject IAstVisitor.VisitConditionalExpression(ConditionalExpression conditionalExpression) { return MakeSnippetExpression(conditionalExpression); } - CodeObject IAstVisitor.VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) + CodeObject IAstVisitor.VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression) { return new CodeDefaultValueExpression(Convert(defaultValueExpression.Type)); } - CodeObject IAstVisitor.VisitDirectionExpression(DirectionExpression directionExpression, object data) + CodeObject IAstVisitor.VisitDirectionExpression(DirectionExpression directionExpression) { System.CodeDom.FieldDirection direction; if (directionExpression.FieldDirection == FieldDirection.Out) { @@ -353,7 +353,7 @@ namespace ICSharpCode.NRefactory.CSharp return new CodeDirectionExpression(direction, Convert(directionExpression.Expression)); } - CodeObject IAstVisitor.VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) + CodeObject IAstVisitor.VisitIdentifierExpression(IdentifierExpression identifierExpression) { ResolveResult rr = Resolve(identifierExpression); LocalResolveResult lrr = rr as LocalResolveResult; @@ -386,7 +386,7 @@ namespace ICSharpCode.NRefactory.CSharp return new CodeVariableReferenceExpression(identifierExpression.Identifier); } - CodeObject IAstVisitor.VisitIndexerExpression(IndexerExpression indexerExpression, object data) + CodeObject IAstVisitor.VisitIndexerExpression(IndexerExpression indexerExpression) { if (Resolve(indexerExpression) is ArrayAccessResolveResult) return new CodeArrayIndexerExpression(Convert(indexerExpression.Target), Convert(indexerExpression.Arguments)); @@ -394,7 +394,7 @@ namespace ICSharpCode.NRefactory.CSharp return new CodeIndexerExpression(Convert(indexerExpression.Target), Convert(indexerExpression.Arguments)); } - CodeObject IAstVisitor.VisitInvocationExpression(InvocationExpression invocationExpression, object data) + CodeObject IAstVisitor.VisitInvocationExpression(InvocationExpression invocationExpression) { MemberResolveResult rr = Resolve(invocationExpression) as MemberResolveResult; CSharpInvocationResolveResult csRR = rr as CSharpInvocationResolveResult; @@ -426,17 +426,17 @@ namespace ICSharpCode.NRefactory.CSharp return MakeSnippetExpression(invocationExpression); } - CodeObject IAstVisitor.VisitIsExpression(IsExpression isExpression, object data) + CodeObject IAstVisitor.VisitIsExpression(IsExpression isExpression) { return MakeSnippetExpression(isExpression); } - CodeObject IAstVisitor.VisitLambdaExpression(LambdaExpression lambdaExpression, object data) + CodeObject IAstVisitor.VisitLambdaExpression(LambdaExpression lambdaExpression) { return MakeSnippetExpression(lambdaExpression); } - CodeObject IAstVisitor.VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) + CodeObject IAstVisitor.VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression) { CodeExpression target = Convert(memberReferenceExpression.Target); ResolveResult rr = Resolve(memberReferenceExpression); @@ -471,75 +471,75 @@ namespace ICSharpCode.NRefactory.CSharp } } - CodeObject IAstVisitor.VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data) + CodeObject IAstVisitor.VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression) { return MakeSnippetExpression(namedArgumentExpression); } - CodeObject IAstVisitor.VisitNamedExpression(NamedExpression namedExpression, object data) + CodeObject IAstVisitor.VisitNamedExpression(NamedExpression namedExpression) { return MakeSnippetExpression(namedExpression); } - CodeObject IAstVisitor.VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, object data) + CodeObject IAstVisitor.VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression) { return new CodePrimitiveExpression(null); } - CodeObject IAstVisitor.VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data) + CodeObject IAstVisitor.VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression) { if (!objectCreateExpression.Initializer.IsNull) return MakeSnippetExpression(objectCreateExpression); return new CodeObjectCreateExpression(Convert(objectCreateExpression.Type), Convert(objectCreateExpression.Arguments)); } - CodeObject IAstVisitor.VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, object data) + CodeObject IAstVisitor.VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression) { return MakeSnippetExpression(anonymousTypeCreateExpression); } - CodeObject IAstVisitor.VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) + CodeObject IAstVisitor.VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression) { // CodeDom generators will insert parentheses where necessary return Convert(parenthesizedExpression.Expression); } - CodeObject IAstVisitor.VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data) + CodeObject IAstVisitor.VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression) { return MakeSnippetExpression(pointerReferenceExpression); } - CodeObject IAstVisitor.VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) + CodeObject IAstVisitor.VisitPrimitiveExpression(PrimitiveExpression primitiveExpression) { return new CodePrimitiveExpression(primitiveExpression.Value); } - CodeObject IAstVisitor.VisitSizeOfExpression(SizeOfExpression sizeOfExpression, object data) + CodeObject IAstVisitor.VisitSizeOfExpression(SizeOfExpression sizeOfExpression) { return MakeSnippetExpression(sizeOfExpression); } - CodeObject IAstVisitor.VisitStackAllocExpression(StackAllocExpression stackAllocExpression, object data) + CodeObject IAstVisitor.VisitStackAllocExpression(StackAllocExpression stackAllocExpression) { return MakeSnippetExpression(stackAllocExpression); } - CodeObject IAstVisitor.VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) + CodeObject IAstVisitor.VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression) { return new CodeThisReferenceExpression(); } - CodeObject IAstVisitor.VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) + CodeObject IAstVisitor.VisitTypeOfExpression(TypeOfExpression typeOfExpression) { return new CodeTypeOfExpression(Convert(typeOfExpression.Type)); } - CodeObject IAstVisitor.VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data) + CodeObject IAstVisitor.VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression) { return new CodeTypeReferenceExpression(Convert(typeReferenceExpression.Type)); } - CodeObject IAstVisitor.VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) + CodeObject IAstVisitor.VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression) { switch (unaryOperatorExpression.Operator) { case UnaryOperatorType.Not: @@ -559,72 +559,72 @@ namespace ICSharpCode.NRefactory.CSharp } } - CodeObject IAstVisitor.VisitUncheckedExpression(UncheckedExpression uncheckedExpression, object data) + CodeObject IAstVisitor.VisitUncheckedExpression(UncheckedExpression uncheckedExpression) { return MakeSnippetExpression(uncheckedExpression); } - CodeObject IAstVisitor.VisitEmptyExpression(EmptyExpression emptyExpression, object data) + CodeObject IAstVisitor.VisitEmptyExpression(EmptyExpression emptyExpression) { return null; } - CodeObject IAstVisitor.VisitQueryExpression(QueryExpression queryExpression, object data) + CodeObject IAstVisitor.VisitQueryExpression(QueryExpression queryExpression) { return MakeSnippetExpression(queryExpression); } - CodeObject IAstVisitor.VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause, object data) + CodeObject IAstVisitor.VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitQueryFromClause(QueryFromClause queryFromClause, object data) + CodeObject IAstVisitor.VisitQueryFromClause(QueryFromClause queryFromClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitQueryLetClause(QueryLetClause queryLetClause, object data) + CodeObject IAstVisitor.VisitQueryLetClause(QueryLetClause queryLetClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitQueryWhereClause(QueryWhereClause queryWhereClause, object data) + CodeObject IAstVisitor.VisitQueryWhereClause(QueryWhereClause queryWhereClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitQueryJoinClause(QueryJoinClause queryJoinClause, object data) + CodeObject IAstVisitor.VisitQueryJoinClause(QueryJoinClause queryJoinClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitQueryOrderClause(QueryOrderClause queryOrderClause, object data) + CodeObject IAstVisitor.VisitQueryOrderClause(QueryOrderClause queryOrderClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitQueryOrdering(QueryOrdering queryOrdering, object data) + CodeObject IAstVisitor.VisitQueryOrdering(QueryOrdering queryOrdering) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitQuerySelectClause(QuerySelectClause querySelectClause, object data) + CodeObject IAstVisitor.VisitQuerySelectClause(QuerySelectClause querySelectClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitQueryGroupClause(QueryGroupClause queryGroupClause, object data) + CodeObject IAstVisitor.VisitQueryGroupClause(QueryGroupClause queryGroupClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitAttribute(Attribute attribute, object data) + CodeObject IAstVisitor.VisitAttribute(Attribute attribute) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitAttributeSection(AttributeSection attributeSection, object data) + CodeObject IAstVisitor.VisitAttributeSection(AttributeSection attributeSection) { throw new NotSupportedException(); } @@ -655,7 +655,7 @@ namespace ICSharpCode.NRefactory.CSharp return result.ToArray(); } - CodeObject IAstVisitor.VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data) + CodeObject IAstVisitor.VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration) { CodeTypeDelegate d = new CodeTypeDelegate(delegateDeclaration.Name); d.Attributes = ConvertMemberAttributes(delegateDeclaration.Modifiers); @@ -696,7 +696,7 @@ namespace ICSharpCode.NRefactory.CSharp return a; } - CodeObject IAstVisitor.VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) + CodeObject IAstVisitor.VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration) { CodeNamespace ns = new CodeNamespace(namespaceDeclaration.Name); foreach (AstNode node in namespaceDeclaration.Members) { @@ -715,9 +715,9 @@ namespace ICSharpCode.NRefactory.CSharp Stack typeStack = new Stack(); - CodeObject IAstVisitor.VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) + CodeObject IAstVisitor.VisitTypeDeclaration(TypeDeclaration typeDeclaration) { - bool isNestedType = typeStack.Count > 0; + //bool isNestedType = typeStack.Count > 0; CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(typeDeclaration.Name); typeDecl.Attributes = ConvertMemberAttributes(typeDeclaration.Modifiers); typeDecl.CustomAttributes.AddRange(Convert(typeDeclaration.Attributes)); @@ -757,42 +757,42 @@ namespace ICSharpCode.NRefactory.CSharp typeStack.Peek().Members.Add(member); } - CodeObject IAstVisitor.VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration, object data) + CodeObject IAstVisitor.VisitUsingAliasDeclaration(UsingAliasDeclaration usingAliasDeclaration) { return new CodeSnippetTypeMember(MakeSnippet(usingAliasDeclaration)); } - CodeObject IAstVisitor.VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) + CodeObject IAstVisitor.VisitUsingDeclaration(UsingDeclaration usingDeclaration) { return new CodeNamespaceImport(usingDeclaration.Namespace); } - CodeObject IAstVisitor.VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration, object data) + CodeObject IAstVisitor.VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration) { return new CodeSnippetTypeMember(MakeSnippet(externAliasDeclaration)); } - CodeObject IAstVisitor.VisitBlockStatement(BlockStatement blockStatement, object data) + CodeObject IAstVisitor.VisitBlockStatement(BlockStatement blockStatement) { return new CodeConditionStatement(new CodePrimitiveExpression(true), ConvertBlock(blockStatement)); } - CodeObject IAstVisitor.VisitBreakStatement(BreakStatement breakStatement, object data) + CodeObject IAstVisitor.VisitBreakStatement(BreakStatement breakStatement) { return MakeSnippetStatement(breakStatement); } - CodeObject IAstVisitor.VisitCheckedStatement(CheckedStatement checkedStatement, object data) + CodeObject IAstVisitor.VisitCheckedStatement(CheckedStatement checkedStatement) { return MakeSnippetStatement(checkedStatement); } - CodeObject IAstVisitor.VisitContinueStatement(ContinueStatement continueStatement, object data) + CodeObject IAstVisitor.VisitContinueStatement(ContinueStatement continueStatement) { return MakeSnippetStatement(continueStatement); } - CodeObject IAstVisitor.VisitDoWhileStatement(DoWhileStatement doWhileStatement, object data) + CodeObject IAstVisitor.VisitDoWhileStatement(DoWhileStatement doWhileStatement) { // do { } while (expr); // @@ -807,12 +807,12 @@ namespace ICSharpCode.NRefactory.CSharp ); } - CodeObject IAstVisitor.VisitEmptyStatement(EmptyStatement emptyStatement, object data) + CodeObject IAstVisitor.VisitEmptyStatement(EmptyStatement emptyStatement) { return null; } - CodeObject IAstVisitor.VisitExpressionStatement(ExpressionStatement expressionStatement, object data) + CodeObject IAstVisitor.VisitExpressionStatement(ExpressionStatement expressionStatement) { AssignmentExpression assignment = expressionStatement.Expression as AssignmentExpression; if (assignment != null && assignment.Operator == AssignmentOperatorType.Assign) { @@ -821,17 +821,17 @@ namespace ICSharpCode.NRefactory.CSharp return new CodeExpressionStatement(Convert(expressionStatement.Expression)); } - CodeObject IAstVisitor.VisitFixedStatement(FixedStatement fixedStatement, object data) + CodeObject IAstVisitor.VisitFixedStatement(FixedStatement fixedStatement) { return MakeSnippetStatement(fixedStatement); } - CodeObject IAstVisitor.VisitForeachStatement(ForeachStatement foreachStatement, object data) + CodeObject IAstVisitor.VisitForeachStatement(ForeachStatement foreachStatement) { return MakeSnippetStatement(foreachStatement); } - CodeObject IAstVisitor.VisitForStatement(ForStatement forStatement, object data) + CodeObject IAstVisitor.VisitForStatement(ForStatement forStatement) { if (forStatement.Initializers.Count != 1 || forStatement.Iterators.Count != 1) return MakeSnippetStatement(forStatement); @@ -843,22 +843,22 @@ namespace ICSharpCode.NRefactory.CSharp ); } - CodeObject IAstVisitor.VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, object data) + CodeObject IAstVisitor.VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement) { return MakeSnippetStatement(gotoCaseStatement); } - CodeObject IAstVisitor.VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement, object data) + CodeObject IAstVisitor.VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement) { return MakeSnippetStatement(gotoDefaultStatement); } - CodeObject IAstVisitor.VisitGotoStatement(GotoStatement gotoStatement, object data) + CodeObject IAstVisitor.VisitGotoStatement(GotoStatement gotoStatement) { return new CodeGotoStatement(gotoStatement.Label); } - CodeObject IAstVisitor.VisitIfElseStatement(IfElseStatement ifElseStatement, object data) + CodeObject IAstVisitor.VisitIfElseStatement(IfElseStatement ifElseStatement) { return new CodeConditionStatement( Convert(ifElseStatement.Condition), @@ -866,42 +866,42 @@ namespace ICSharpCode.NRefactory.CSharp ConvertEmbeddedStatement(ifElseStatement.FalseStatement)); } - CodeObject IAstVisitor.VisitLabelStatement(LabelStatement labelStatement, object data) + CodeObject IAstVisitor.VisitLabelStatement(LabelStatement labelStatement) { return new CodeLabeledStatement(labelStatement.Label); } - CodeObject IAstVisitor.VisitLockStatement(LockStatement lockStatement, object data) + CodeObject IAstVisitor.VisitLockStatement(LockStatement lockStatement) { return MakeSnippetStatement(lockStatement); } - CodeObject IAstVisitor.VisitReturnStatement(ReturnStatement returnStatement, object data) + CodeObject IAstVisitor.VisitReturnStatement(ReturnStatement returnStatement) { return new CodeMethodReturnStatement(Convert(returnStatement.Expression)); } - CodeObject IAstVisitor.VisitSwitchStatement(SwitchStatement switchStatement, object data) + CodeObject IAstVisitor.VisitSwitchStatement(SwitchStatement switchStatement) { return MakeSnippetStatement(switchStatement); } - CodeObject IAstVisitor.VisitSwitchSection(SwitchSection switchSection, object data) + CodeObject IAstVisitor.VisitSwitchSection(SwitchSection switchSection) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitCaseLabel(CaseLabel caseLabel, object data) + CodeObject IAstVisitor.VisitCaseLabel(CaseLabel caseLabel) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitThrowStatement(ThrowStatement throwStatement, object data) + CodeObject IAstVisitor.VisitThrowStatement(ThrowStatement throwStatement) { return new CodeThrowExceptionStatement(Convert(throwStatement.Expression)); } - CodeObject IAstVisitor.VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) + CodeObject IAstVisitor.VisitTryCatchStatement(TryCatchStatement tryCatchStatement) { List catchClauses = new List(); foreach (var catchClause in tryCatchStatement.CatchClauses) { @@ -913,27 +913,27 @@ namespace ICSharpCode.NRefactory.CSharp ConvertBlock(tryCatchStatement.FinallyBlock)); } - CodeObject IAstVisitor.VisitCatchClause(CatchClause catchClause, object data) + CodeObject IAstVisitor.VisitCatchClause(CatchClause catchClause) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitUncheckedStatement(UncheckedStatement uncheckedStatement, object data) + CodeObject IAstVisitor.VisitUncheckedStatement(UncheckedStatement uncheckedStatement) { return MakeSnippetStatement(uncheckedStatement); } - CodeObject IAstVisitor.VisitUnsafeStatement(UnsafeStatement unsafeStatement, object data) + CodeObject IAstVisitor.VisitUnsafeStatement(UnsafeStatement unsafeStatement) { return MakeSnippetStatement(unsafeStatement); } - CodeObject IAstVisitor.VisitUsingStatement(UsingStatement usingStatement, object data) + CodeObject IAstVisitor.VisitUsingStatement(UsingStatement usingStatement) { return MakeSnippetStatement(usingStatement); } - CodeObject IAstVisitor.VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, object data) + CodeObject IAstVisitor.VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement) { if (variableDeclarationStatement.Variables.Count != 1) return MakeSnippetStatement(variableDeclarationStatement); @@ -954,27 +954,27 @@ namespace ICSharpCode.NRefactory.CSharp } } - CodeObject IAstVisitor.VisitWhileStatement(WhileStatement whileStatement, object data) + CodeObject IAstVisitor.VisitWhileStatement(WhileStatement whileStatement) { return new CodeIterationStatement(null, Convert(whileStatement.Condition), null, ConvertEmbeddedStatement(whileStatement.EmbeddedStatement)); } - CodeObject IAstVisitor.VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement, object data) + CodeObject IAstVisitor.VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement) { return MakeSnippetStatement(yieldBreakStatement); } - CodeObject IAstVisitor.VisitYieldReturnStatement(YieldReturnStatement yieldStatement, object data) + CodeObject IAstVisitor.VisitYieldReturnStatement(YieldReturnStatement yieldStatement) { return MakeSnippetStatement(yieldStatement); } - CodeObject IAstVisitor.VisitAccessor(Accessor accessor, object data) + CodeObject IAstVisitor.VisitAccessor(Accessor accessor) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) + CodeObject IAstVisitor.VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration) { CodeConstructor ctor = new CodeConstructor(); ctor.Attributes = ConvertMemberAttributes(constructorDeclaration.Modifiers); @@ -990,17 +990,17 @@ namespace ICSharpCode.NRefactory.CSharp return ctor; } - CodeObject IAstVisitor.VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) + CodeObject IAstVisitor.VisitConstructorInitializer(ConstructorInitializer constructorInitializer) { throw new NotSupportedException(); } - CodeObject IAstVisitor.VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) + CodeObject IAstVisitor.VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration) { return new CodeSnippetTypeMember(MakeSnippet(destructorDeclaration)); } - CodeObject IAstVisitor.VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, object data) + CodeObject IAstVisitor.VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration) { TypeDeclaration td = enumMemberDeclaration.Parent as TypeDeclaration; CodeMemberField f = new CodeMemberField(td != null ? td.Name : "Enum", enumMemberDeclaration.Name); @@ -1010,7 +1010,7 @@ namespace ICSharpCode.NRefactory.CSharp return f; } - CodeObject IAstVisitor.VisitEventDeclaration(EventDeclaration eventDeclaration, object data) + CodeObject IAstVisitor.VisitEventDeclaration(EventDeclaration eventDeclaration) { foreach (VariableInitializer vi in eventDeclaration.Variables) { if (!vi.Initializer.IsNull) { @@ -1028,12 +1028,12 @@ namespace ICSharpCode.NRefactory.CSharp return null; } - CodeObject IAstVisitor.VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration, object data) + CodeObject IAstVisitor.VisitCustomEventDeclaration(CustomEventDeclaration customEventDeclaration) { return new CodeSnippetTypeMember(MakeSnippet(customEventDeclaration)); } - CodeObject IAstVisitor.VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) + CodeObject IAstVisitor.VisitFieldDeclaration(FieldDeclaration fieldDeclaration) { foreach (VariableInitializer vi in fieldDeclaration.Variables) { CodeMemberField f = new CodeMemberField(Convert(fieldDeclaration.ReturnType), vi.Name); @@ -1045,7 +1045,7 @@ namespace ICSharpCode.NRefactory.CSharp return null; } - CodeObject IAstVisitor.VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, object data) + CodeObject IAstVisitor.VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration) { CodeMemberProperty p = new CodeMemberProperty(); p.Attributes = ConvertMemberAttributes(indexerDeclaration.Modifiers); @@ -1066,7 +1066,7 @@ namespace ICSharpCode.NRefactory.CSharp return p; } - CodeObject IAstVisitor.VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) + CodeObject IAstVisitor.VisitMethodDeclaration(MethodDeclaration methodDeclaration) { CodeMemberMethod m = new CodeMemberMethod(); m.Attributes = ConvertMemberAttributes(methodDeclaration.Modifiers); @@ -1084,7 +1084,7 @@ namespace ICSharpCode.NRefactory.CSharp return m; } - CodeObject IAstVisitor.VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data) + CodeObject IAstVisitor.VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) { CodeMemberMethod m = new CodeMemberMethod(); m.Attributes = ConvertMemberAttributes(operatorDeclaration.Modifiers); @@ -1100,7 +1100,7 @@ namespace ICSharpCode.NRefactory.CSharp return m; } - CodeObject IAstVisitor.VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, object data) + CodeObject IAstVisitor.VisitParameterDeclaration(ParameterDeclaration parameterDeclaration) { var p = new CodeParameterDeclarationExpression(Convert(parameterDeclaration.Type), parameterDeclaration.Name); p.CustomAttributes.AddRange(Convert(parameterDeclaration.Attributes)); @@ -1126,7 +1126,7 @@ namespace ICSharpCode.NRefactory.CSharp return result.ToArray(); } - CodeObject IAstVisitor.VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) + CodeObject IAstVisitor.VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { CodeMemberProperty p = new CodeMemberProperty(); p.Attributes = ConvertMemberAttributes(propertyDeclaration.Modifiers); @@ -1146,22 +1146,22 @@ namespace ICSharpCode.NRefactory.CSharp return p; } - CodeObject IAstVisitor.VisitVariableInitializer(VariableInitializer variableInitializer, object data) + CodeObject IAstVisitor.VisitVariableInitializer(VariableInitializer variableInitializer) { throw new NotSupportedException(); // should be handled by the parent node } - CodeObject IAstVisitor.VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, object data) + CodeObject IAstVisitor.VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration) { return new CodeSnippetTypeMember(MakeSnippet(fixedFieldDeclaration)); } - CodeObject IAstVisitor.VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, object data) + CodeObject IAstVisitor.VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer) { throw new NotSupportedException(); // should be handled by the parent node } - CodeObject IAstVisitor.VisitCompilationUnit(CompilationUnit compilationUnit, object data) + CodeObject IAstVisitor.VisitCompilationUnit(CompilationUnit compilationUnit) { CodeCompileUnit cu = new CodeCompileUnit(); foreach (AstNode node in compilationUnit.Children) { @@ -1179,7 +1179,7 @@ namespace ICSharpCode.NRefactory.CSharp return cu; } - CodeObject IAstVisitor.VisitSimpleType(SimpleType simpleType, object data) + CodeObject IAstVisitor.VisitSimpleType(SimpleType simpleType) { if (useFullyQualifiedTypeNames) { IType type = Resolve(simpleType).Type; @@ -1191,7 +1191,7 @@ namespace ICSharpCode.NRefactory.CSharp return tr; } - CodeObject IAstVisitor.VisitMemberType(MemberType memberType, object data) + CodeObject IAstVisitor.VisitMemberType(MemberType memberType) { if (memberType.IsDoubleColon && new SimpleType("global").IsMatch(memberType.Target)) { var tr = new CodeTypeReference(memberType.MemberName, CodeTypeReferenceOptions.GlobalReference); @@ -1211,7 +1211,7 @@ namespace ICSharpCode.NRefactory.CSharp return target; } - CodeObject IAstVisitor.VisitComposedType(ComposedType composedType, object data) + CodeObject IAstVisitor.VisitComposedType(ComposedType composedType) { CodeTypeReference typeRef = Convert(composedType.BaseType); if (typeRef == null) @@ -1225,12 +1225,12 @@ namespace ICSharpCode.NRefactory.CSharp return typeRef; } - CodeObject IAstVisitor.VisitArraySpecifier(ArraySpecifier arraySpecifier, object data) + CodeObject IAstVisitor.VisitArraySpecifier(ArraySpecifier arraySpecifier) { throw new NotSupportedException(); // handled by parent node } - CodeObject IAstVisitor.VisitPrimitiveType(PrimitiveType primitiveType, object data) + CodeObject IAstVisitor.VisitPrimitiveType(PrimitiveType primitiveType) { KnownTypeCode typeCode = primitiveType.KnownTypeCode; if (typeCode != KnownTypeCode.None) { @@ -1240,22 +1240,37 @@ namespace ICSharpCode.NRefactory.CSharp return new CodeTypeReference(primitiveType.Keyword); } - CodeObject IAstVisitor.VisitComment (Comment comment, object data) + CodeObject IAstVisitor.VisitComment (Comment comment) { return new CodeComment (comment.Content, comment.CommentType == CommentType.Documentation); } - - CodeObject IAstVisitor.VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective, object data) + + CodeObject IAstVisitor.VisitNewLine(NewLineNode newLineNode) + { + throw new NotSupportedException(); + } + + CodeObject IAstVisitor.VisitWhitespace(WhitespaceNode whitespaceNode) + { + throw new NotSupportedException(); + } + + CodeObject IAstVisitor.VisitText(TextNode textNode) + { + throw new NotSupportedException(); + } + + CodeObject IAstVisitor.VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective) { return new CodeComment ("#" + preProcessorDirective.Type.ToString ().ToLower ()); } - CodeObject IAstVisitor.VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, object data) + CodeObject IAstVisitor.VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration) { throw new NotSupportedException(); // type parameters and constraints are handled together } - CodeObject IAstVisitor.VisitConstraint(Constraint constraint, object data) + CodeObject IAstVisitor.VisitConstraint(Constraint constraint) { throw new NotSupportedException(); } @@ -1284,17 +1299,22 @@ namespace ICSharpCode.NRefactory.CSharp return result.ToArray(); } - CodeObject IAstVisitor.VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, object data) + CodeObject IAstVisitor.VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode) + { + return null; + } + + CodeObject IAstVisitor.VisitIdentifier(Identifier identifier) { return null; } - CodeObject IAstVisitor.VisitIdentifier(Identifier identifier, object data) + CodeObject IAstVisitor.VisitPatternPlaceholder(AstNode placeholder, ICSharpCode.NRefactory.PatternMatching.Pattern pattern) { return null; } - CodeObject IAstVisitor.VisitPatternPlaceholder(AstNode placeholder, ICSharpCode.NRefactory.PatternMatching.Pattern pattern, object data) + CodeObject IAstVisitor.VisitDocumentationReference(DocumentationReference documentationReference) { return null; } diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/InsertParenthesesVisitor.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/InsertParenthesesVisitor.cs index 340955c15..0b7e2424c 100644 --- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/InsertParenthesesVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/InsertParenthesesVisitor.cs @@ -27,7 +27,7 @@ namespace ICSharpCode.NRefactory.CSharp /// would incorrectly result in "2 * 1 + 1". By running InsertParenthesesVisitor, the necessary /// parentheses are inserted: "2 * (1 + 1)". /// - public class InsertParenthesesVisitor : DepthFirstAstVisitor + public class InsertParenthesesVisitor : DepthFirstAstVisitor { /// /// Gets/Sets whether the visitor should insert parentheses to make the code better looking. @@ -126,25 +126,25 @@ namespace ICSharpCode.NRefactory.CSharp } // Primary expressions - public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) + public override void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression) { ParenthesizeIfRequired(memberReferenceExpression.Target, Primary); - return base.VisitMemberReferenceExpression(memberReferenceExpression, data); + base.VisitMemberReferenceExpression(memberReferenceExpression); } - public override object VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data) + public override void VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression) { ParenthesizeIfRequired(pointerReferenceExpression.Target, Primary); - return base.VisitPointerReferenceExpression(pointerReferenceExpression, data); + base.VisitPointerReferenceExpression(pointerReferenceExpression); } - public override object VisitInvocationExpression(InvocationExpression invocationExpression, object data) + public override void VisitInvocationExpression(InvocationExpression invocationExpression) { ParenthesizeIfRequired(invocationExpression.Target, Primary); - return base.VisitInvocationExpression(invocationExpression, data); + base.VisitInvocationExpression(invocationExpression); } - public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data) + public override void VisitIndexerExpression(IndexerExpression indexerExpression) { ParenthesizeIfRequired(indexerExpression.Target, Primary); ArrayCreateExpression ace = indexerExpression.Target as ArrayCreateExpression; @@ -152,20 +152,20 @@ namespace ICSharpCode.NRefactory.CSharp // require parentheses for "(new int[1])[0]" Parenthesize(indexerExpression.Target); } - return base.VisitIndexerExpression(indexerExpression, data); + base.VisitIndexerExpression(indexerExpression); } // Unary expressions - public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) + public override void VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression) { ParenthesizeIfRequired(unaryOperatorExpression.Expression, GetPrecedence(unaryOperatorExpression)); UnaryOperatorExpression child = unaryOperatorExpression.Expression as UnaryOperatorExpression; if (child != null && InsertParenthesesForReadability) Parenthesize(child); - return base.VisitUnaryOperatorExpression(unaryOperatorExpression, data); + base.VisitUnaryOperatorExpression(unaryOperatorExpression); } - public override object VisitCastExpression(CastExpression castExpression, object data) + public override void VisitCastExpression(CastExpression castExpression) { ParenthesizeIfRequired(castExpression.Expression, InsertParenthesesForReadability ? Primary : Unary); // There's a nasty issue in the C# grammar: cast expressions including certain operators are ambiguous in some cases @@ -211,7 +211,7 @@ namespace ICSharpCode.NRefactory.CSharp break; } } - return base.VisitCastExpression(castExpression, data); + base.VisitCastExpression(castExpression); } static bool TypeCanBeMisinterpretedAsExpression(AstType type) @@ -227,7 +227,7 @@ namespace ICSharpCode.NRefactory.CSharp } // Binary Operators - public override object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) + public override void VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression) { int precedence = GetPrecedence(binaryOperatorExpression); if (binaryOperatorExpression.Operator == BinaryOperatorType.NullCoalescing) { @@ -255,7 +255,7 @@ namespace ICSharpCode.NRefactory.CSharp ParenthesizeIfRequired(binaryOperatorExpression.Right, precedence + 1); } } - return base.VisitBinaryOperatorExpression(binaryOperatorExpression, data); + base.VisitBinaryOperatorExpression(binaryOperatorExpression); } BinaryOperatorType? GetBinaryOperatorType(Expression expr) @@ -267,7 +267,7 @@ namespace ICSharpCode.NRefactory.CSharp return null; } - public override object VisitIsExpression(IsExpression isExpression, object data) + public override void VisitIsExpression(IsExpression isExpression) { if (InsertParenthesesForReadability) { // few people know the precedence of 'is', so always put parentheses in nice-looking mode. @@ -275,10 +275,10 @@ namespace ICSharpCode.NRefactory.CSharp } else { ParenthesizeIfRequired(isExpression.Expression, RelationalAndTypeTesting); } - return base.VisitIsExpression(isExpression, data); + base.VisitIsExpression(isExpression); } - public override object VisitAsExpression(AsExpression asExpression, object data) + public override void VisitAsExpression(AsExpression asExpression) { if (InsertParenthesesForReadability) { // few people know the precedence of 'as', so always put parentheses in nice-looking mode. @@ -286,11 +286,11 @@ namespace ICSharpCode.NRefactory.CSharp } else { ParenthesizeIfRequired(asExpression.Expression, RelationalAndTypeTesting); } - return base.VisitAsExpression(asExpression, data); + base.VisitAsExpression(asExpression); } // Conditional operator - public override object VisitConditionalExpression(ConditionalExpression conditionalExpression, object data) + public override void VisitConditionalExpression(ConditionalExpression conditionalExpression) { // Associativity here is a bit tricky: // (a ? b : c ? d : e) == (a ? b : (c ? d : e)) @@ -306,10 +306,10 @@ namespace ICSharpCode.NRefactory.CSharp ParenthesizeIfRequired(conditionalExpression.TrueExpression, Conditional); ParenthesizeIfRequired(conditionalExpression.FalseExpression, Conditional); } - return base.VisitConditionalExpression(conditionalExpression, data); + base.VisitConditionalExpression(conditionalExpression); } - public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) + public override void VisitAssignmentExpression(AssignmentExpression assignmentExpression) { // assignment is right-associative ParenthesizeIfRequired(assignmentExpression.Left, Assignment + 1); @@ -318,12 +318,12 @@ namespace ICSharpCode.NRefactory.CSharp } else { ParenthesizeIfRequired(assignmentExpression.Right, Assignment); } - return base.VisitAssignmentExpression(assignmentExpression, data); + base.VisitAssignmentExpression(assignmentExpression); } // don't need to handle lambdas, they have lowest precedence and unambiguous associativity - public override object VisitQueryExpression(QueryExpression queryExpression, object data) + public override void VisitQueryExpression(QueryExpression queryExpression) { // Query expressions are strange beasts: // "var a = -from b in c select d;" is valid, so queries bind stricter than unary expressions. @@ -339,7 +339,7 @@ namespace ICSharpCode.NRefactory.CSharp if (queryExpression.Parent is UnaryOperatorExpression || queryExpression.Parent is BinaryOperatorExpression) Parenthesize(queryExpression); } - return base.VisitQueryExpression(queryExpression, data); + base.VisitQueryExpression(queryExpression); } } } diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs index 4bd8c2da4..e8d481b21 100644 --- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs +++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/TextWriterOutputFormatter.cs @@ -82,6 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp switch (style) { case BraceStyle.DoNotChange: case BraceStyle.EndOfLine: + case BraceStyle.BannerStyle: WriteIndentation(); if (!isAtStartOfLine) textWriter.Write(' '); @@ -130,6 +131,7 @@ namespace ICSharpCode.NRefactory.CSharp textWriter.Write('}'); isAtStartOfLine = false; break; + case BraceStyle.BannerStyle: case BraceStyle.NextLineShifted: WriteIndentation(); textWriter.Write('}'); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs index 17591a506..3c6929bae 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.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.Linq; using System.Collections.Generic; @@ -51,7 +50,7 @@ namespace ICSharpCode.NRefactory.CSharp } } - public LocationsBag LocationsBag { + public LocationsBag LocationsBag { get; private set; } @@ -67,59 +66,60 @@ namespace ICSharpCode.NRefactory.CSharp return new TextLocation (loc.Row, loc.Column); } - public override void Visit (ModuleContainer mc) + public override void Visit(ModuleContainer mc) { bool first = true; foreach (var container in mc.Containers) { var nspace = container as NamespaceContainer; if (nspace == null) { - container.Accept (this); + container.Accept(this); continue; } NamespaceDeclaration nDecl = null; - var loc = LocationsBag.GetLocations (nspace); + var loc = LocationsBag.GetLocations(nspace); - if (nspace.NS != null && !string.IsNullOrEmpty (nspace.NS.Name)) { + if (nspace.NS != null && !string.IsNullOrEmpty(nspace.NS.Name)) { nDecl = new NamespaceDeclaration (); - if (loc != null) - nDecl.AddChild (new CSharpTokenNode (Convert (loc[0]), "namespace".Length), NamespaceDeclaration.Roles.Keyword); - ConvertNamespaceName (nspace.RealMemberName, nDecl); - if (loc != null && loc.Count > 1) - nDecl.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), NamespaceDeclaration.Roles.LBrace); - AddToNamespace (nDecl); - namespaceStack.Push (nDecl); + if (loc != null) { + nDecl.AddChild(new CSharpTokenNode (Convert(loc [0])), Roles.NamespaceKeyword); + } + ConvertNamespaceName(nspace.RealMemberName, nDecl); + if (loc != null && loc.Count > 1) { + nDecl.AddChild(new CSharpTokenNode (Convert(loc [1])), Roles.LBrace); + } + AddToNamespace(nDecl); + namespaceStack.Push(nDecl); } if (nspace.Usings != null) { foreach (var us in nspace.Usings) { - us.Accept (this); + us.Accept(this); } } if (first) { first = false; - AddAttributeSection (Unit, mc); + AddAttributeSection(Unit, mc); } if (nspace.Containers != null) { foreach (var subContainer in nspace.Containers) { - subContainer.Accept (this); + subContainer.Accept(this); } } - if (nDecl != null) { - AddAttributeSection (nDecl, nspace.UnattachedAttributes, AttributedNode.UnattachedAttributeRole); + AddAttributeSection (nDecl, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole); if (loc != null && loc.Count > 2) - nDecl.AddChild (new CSharpTokenNode (Convert (loc[2]), 1), NamespaceDeclaration.Roles.RBrace); + nDecl.AddChild (new CSharpTokenNode (Convert (loc [2])), Roles.RBrace); if (loc != null && loc.Count > 3) - nDecl.AddChild (new CSharpTokenNode (Convert (loc[3]), 1), NamespaceDeclaration.Roles.Semicolon); + nDecl.AddChild (new CSharpTokenNode (Convert (loc [3])), Roles.Semicolon); namespaceStack.Pop (); } else { - AddAttributeSection (unit, nspace.UnattachedAttributes, AttributedNode.UnattachedAttributeRole); + AddAttributeSection (unit, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole); } } - AddAttributeSection (unit, mc.UnattachedAttributes, AttributedNode.UnattachedAttributeRole); + AddAttributeSection (unit, mc.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole); } #region Global @@ -131,15 +131,15 @@ namespace ICSharpCode.NRefactory.CSharp 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); + result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 2])), Roles.LChevron); int i = 0; foreach (var arg in texpr.TypeArguments.Args) { - result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument); + result.AddChild (ConvertToType (arg), Roles.TypeArgument); if (loc != null && i < loc.Count - 2) - result.AddChild (new CSharpTokenNode (Convert (loc [i++]), 1), AstType.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (loc [i++])), Roles.Comma); } if (loc != null && loc.Count >= 2) - result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 1]), 1), AstType.Roles.RChevron); + result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 1])), Roles.RChevron); } AstType ConvertToType (TypeParameter spec) @@ -157,23 +157,23 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (ConvertToType (memberName.Left), MemberType.TargetRole); var loc = LocationsBag.GetLocations (memberName.Left); if (loc != null) - result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), MemberType.Roles.Dot); - result.AddChild (Identifier.Create (memberName.Name, Convert (memberName.Location)), MemberType.Roles.Identifier); + result.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.Dot); + result.AddChild (Identifier.Create (memberName.Name, Convert (memberName.Location)), Roles.Identifier); } else { result = new SimpleType () { IdentifierToken = Identifier.Create (memberName.Name, Convert (memberName.Location)) }; } if (memberName.TypeParameters != null) { var chevronLocs = LocationsBag.GetLocations (memberName.TypeParameters); if (chevronLocs != null) - result.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 2]), 1), InvocationExpression.Roles.LChevron); + result.AddChild (new CSharpTokenNode (Convert (chevronLocs [chevronLocs.Count - 2])), Roles.LChevron); for (int i = 0; i < memberName.TypeParameters.Count; i++) { - var param = memberName.TypeParameters[i]; - result.AddChild (new SimpleType (Identifier.Create (param.Name, Convert (param.Location))), AstType.Roles.TypeArgument); + var param = memberName.TypeParameters [i]; + result.AddChild (new SimpleType (Identifier.Create (param.Name, Convert (param.Location))), Roles.TypeArgument); if (chevronLocs != null && i < chevronLocs.Count - 2) - result.AddChild (new CSharpTokenNode (Convert (chevronLocs [i]), 1), InvocationExpression.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (chevronLocs [i])), Roles.Comma); } if (chevronLocs != null) - result.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron); + result.AddChild (new CSharpTokenNode (Convert (chevronLocs [chevronLocs.Count - 1])), Roles.RChevron); } return result; } @@ -202,7 +202,7 @@ namespace ICSharpCode.NRefactory.CSharp var memberType = new MemberType (); memberType.AddChild (ConvertToType (ma.LeftExpression), MemberType.TargetRole); - memberType.AddChild (new CSharpTokenNode (Convert (ma.DotLocation), 1), MemberType.Roles.Dot); + memberType.AddChild (new CSharpTokenNode (Convert (ma.DotLocation)), Roles.Dot); memberType.MemberNameToken = Identifier.Create (ma.Name, Convert (ma.Location)); @@ -224,15 +224,15 @@ namespace ICSharpCode.NRefactory.CSharp var ccSpec = cc.Spec; while (ccSpec != null) { if (ccSpec.IsNullable) { - result.AddChild (new CSharpTokenNode (Convert (ccSpec.Location), 1), ComposedType.NullableRole); + result.AddChild (new CSharpTokenNode (Convert (ccSpec.Location)), ComposedType.NullableRole); } else if (ccSpec.IsPointer) { - result.AddChild (new CSharpTokenNode (Convert (ccSpec.Location), 1), ComposedType.PointerRole); + result.AddChild (new CSharpTokenNode (Convert (ccSpec.Location)), ComposedType.PointerRole); } else { var location = LocationsBag.GetLocations (ccSpec); var spec = new ArraySpecifier () { Dimensions = ccSpec.Dimension }; - spec.AddChild (new CSharpTokenNode (Convert (ccSpec.Location), 1), FieldDeclaration.Roles.LBracket); + spec.AddChild (new CSharpTokenNode (Convert (ccSpec.Location)), Roles.LBracket); if (location != null) - spec.AddChild (new CSharpTokenNode (Convert (location [0]), 1), FieldDeclaration.Roles.RBracket); + spec.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.RBracket); result.ArraySpecifiers.Add (spec); } @@ -266,46 +266,46 @@ namespace ICSharpCode.NRefactory.CSharp result.HasArgumentList = loc != null; int pos = 0; if (loc != null) - result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.LPar); if (attr.PositionalArguments != null) { foreach (var arg in attr.PositionalArguments) { var na = arg as NamedArgument; if (na != null) { var newArg = new NamedArgumentExpression (); - newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier); + newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), Roles.Identifier); var argLoc = LocationsBag.GetLocations (na); if (argLoc != null) - newArg.AddChild (new CSharpTokenNode (Convert (argLoc [0]), 1), NamedArgumentExpression.Roles.Colon); + newArg.AddChild (new CSharpTokenNode (Convert (argLoc [0])), Roles.Colon); if (na.Expr != null) - newArg.AddChild ((Expression)na.Expr.Accept (this), NamedExpression.Roles.Expression); - result.AddChild (newArg, Attribute.Roles.Argument); + newArg.AddChild ((Expression)na.Expr.Accept (this), Roles.Expression); + result.AddChild (newArg, Roles.Argument); } else { if (arg.Expr != null) - result.AddChild ((Expression)arg.Expr.Accept (this), Attribute.Roles.Argument); + result.AddChild ((Expression)arg.Expr.Accept (this), Roles.Argument); } if (loc != null && pos + 1 < loc.Count) - result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.Comma); } } if (attr.NamedArguments != null) { foreach (NamedArgument na in attr.NamedArguments) { var newArg = new NamedExpression (); - newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), NamedExpression.Roles.Identifier); + newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), Roles.Identifier); var argLoc = LocationsBag.GetLocations (na); if (argLoc != null) - newArg.AddChild (new CSharpTokenNode (Convert (argLoc[0]), 1), NamedExpression.Roles.Assign); + newArg.AddChild (new CSharpTokenNode (Convert (argLoc [0])), Roles.Assign); if (na.Expr != null) - newArg.AddChild ((Expression)na.Expr.Accept (this), NamedExpression.Roles.Expression); - result.AddChild (newArg, Attribute.Roles.Argument); + newArg.AddChild ((Expression)na.Expr.Accept (this), Roles.Expression); + result.AddChild (newArg, Roles.Argument); if (loc != null && pos + 1 < loc.Count) - result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.Comma); } } if (loc != null && pos < loc.Count) - result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.RPar); yield return result; } @@ -319,67 +319,68 @@ namespace ICSharpCode.NRefactory.CSharp var loc = LocationsBag.GetLocations (optAttributes); int pos = 0; if (loc != null) - result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.LBracket); + result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.LBracket); var first = optAttributes.FirstOrDefault (); string target = first != null ? first.ExplicitTarget : null; if (!string.IsNullOrEmpty (target)) { if (loc != null && pos < loc.Count - 1) { - result.AddChild (Identifier.Create (target, Convert (loc [pos++])), AttributeSection.Roles.Identifier); + result.AddChild (Identifier.Create (target, Convert (loc [pos++])), Roles.Identifier); } else { - result.AddChild (Identifier.Create (target), AttributeSection.Roles.Identifier); + result.AddChild (Identifier.Create (target), Roles.Identifier); } if (loc != null && pos < loc.Count) - result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.Colon); + result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.Colon); } foreach (var attr in GetAttributes (optAttributes)) { - result.AddChild (attr, AttributeSection.AttributeRole); + result.AddChild (attr, Roles.Attribute); } // optional comma if (loc != null && pos < loc.Count - 1 && !loc [pos].Equals (loc [pos + 1])) - result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.Comma); if (loc != null && pos < loc.Count) - result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.RBracket); + result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.RBracket); return result; } - public override void Visit (NamespaceContainer nspace) + public override void Visit(NamespaceContainer nspace) { NamespaceDeclaration nDecl = null; - var loc = LocationsBag.GetLocations (nspace); + var loc = LocationsBag.GetLocations(nspace); - if (nspace.NS != null && !string.IsNullOrEmpty (nspace.NS.Name)) { + if (nspace.NS != null && !string.IsNullOrEmpty(nspace.NS.Name)) { nDecl = new NamespaceDeclaration (); - if (loc != null) - nDecl.AddChild (new CSharpTokenNode (Convert (loc[0]), "namespace".Length), NamespaceDeclaration.Roles.Keyword); - ConvertNamespaceName (nspace.RealMemberName, nDecl); - if (loc != null && loc.Count > 1) - nDecl.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), NamespaceDeclaration.Roles.LBrace); - AddToNamespace (nDecl); - namespaceStack.Push (nDecl); + if (loc != null) { + nDecl.AddChild(new CSharpTokenNode (Convert(loc [0])), Roles.NamespaceKeyword); + } + ConvertNamespaceName(nspace.RealMemberName, nDecl); + if (loc != null && loc.Count > 1) { + nDecl.AddChild(new CSharpTokenNode (Convert(loc [1])), Roles.LBrace); + } + AddToNamespace(nDecl); + namespaceStack.Push(nDecl); } if (nspace.Usings != null) { foreach (var us in nspace.Usings) { - us.Accept (this); + us.Accept(this); } } if (nspace.Containers != null) { foreach (var container in nspace.Containers) { - container.Accept (this); + container.Accept(this); } } - if (nDecl != null) { - AddAttributeSection (nDecl, nspace.UnattachedAttributes, AttributedNode.UnattachedAttributeRole); + AddAttributeSection(nDecl, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole); if (loc != null && loc.Count > 2) - nDecl.AddChild (new CSharpTokenNode (Convert (loc[2]), 1), NamespaceDeclaration.Roles.RBrace); + nDecl.AddChild (new CSharpTokenNode (Convert (loc [2])), Roles.RBrace); if (loc != null && loc.Count > 3) - nDecl.AddChild (new CSharpTokenNode (Convert (loc[3]), 1), NamespaceDeclaration.Roles.Semicolon); + nDecl.AddChild (new CSharpTokenNode (Convert (loc [3])), Roles.Semicolon); namespaceStack.Pop (); } @@ -398,12 +399,12 @@ namespace ICSharpCode.NRefactory.CSharp AstNode insertPos = null; while (memberName != null) { Identifier newIdent = Identifier.Create (memberName.Name, Convert (memberName.Location)); - namespaceDecl.InsertChildBefore (insertPos, newIdent, NamespaceDeclaration.Roles.Identifier); + namespaceDecl.InsertChildBefore (insertPos, newIdent, Roles.Identifier); insertPos = newIdent; if (!memberName.DotLocation.IsNull) { - var dotToken = new CSharpTokenNode (Convert (memberName.DotLocation), 1); - namespaceDecl.InsertChildBefore (insertPos, dotToken, NamespaceDeclaration.Roles.Dot); + var dotToken = new CSharpTokenNode (Convert (memberName.DotLocation)); + namespaceDecl.InsertChildBefore (insertPos, dotToken, Roles.Dot); insertPos = dotToken; } @@ -411,64 +412,64 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override void Visit (UsingNamespace un) - { - var ud = new UsingDeclaration (); - var loc = LocationsBag.GetLocations (un); - ud.AddChild (new CSharpTokenNode (Convert (un.Location), "using".Length), UsingDeclaration.Roles.Keyword); - if (un.NamespaceExpression != null) - ud.AddChild (ConvertToType (un.NamespaceExpression), UsingDeclaration.ImportRole); - if (loc != null) - ud.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), UsingDeclaration.Roles.Semicolon); - AddToNamespace (ud); - } + public override void Visit (UsingNamespace un) + { + var ud = new UsingDeclaration (); + var loc = LocationsBag.GetLocations (un); + ud.AddChild (new CSharpTokenNode (Convert (un.Location)), UsingDeclaration.UsingKeywordRole); + if (un.NamespaceExpression != null) + ud.AddChild (ConvertToType (un.NamespaceExpression), UsingDeclaration.ImportRole); + if (loc != null) + ud.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.Semicolon); + AddToNamespace (ud); + } - public override void Visit (UsingAliasNamespace uan) - { - var ud = new UsingAliasDeclaration (); - var loc = LocationsBag.GetLocations (uan); - - ud.AddChild (new CSharpTokenNode (Convert (uan.Location), "using".Length), UsingAliasDeclaration.Roles.Keyword); - ud.AddChild (Identifier.Create (uan.Alias.Value, Convert (uan.Alias.Location)), UsingAliasDeclaration.AliasRole); - if (loc != null) - ud.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), UsingAliasDeclaration.Roles.Assign); - if (uan.NamespaceExpression != null) - ud.AddChild (ConvertToType (uan.NamespaceExpression), UsingAliasDeclaration.ImportRole); - if (loc != null && loc.Count > 1) - ud.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), UsingAliasDeclaration.Roles.Semicolon); - AddToNamespace (ud); - } + public override void Visit (UsingAliasNamespace uan) + { + var ud = new UsingAliasDeclaration (); + var loc = LocationsBag.GetLocations (uan); + + ud.AddChild (new CSharpTokenNode (Convert (uan.Location)), UsingAliasDeclaration.UsingKeywordRole); + ud.AddChild (Identifier.Create (uan.Alias.Value, Convert (uan.Alias.Location)), UsingAliasDeclaration.AliasRole); + if (loc != null) + ud.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.Assign); + if (uan.NamespaceExpression != null) + ud.AddChild (ConvertToType (uan.NamespaceExpression), UsingAliasDeclaration.ImportRole); + if (loc != null && loc.Count > 1) + ud.AddChild (new CSharpTokenNode (Convert (loc [1])), Roles.Semicolon); + AddToNamespace (ud); + } - public override void Visit (UsingExternAlias uea) - { - var ud = new ExternAliasDeclaration (); - var loc = LocationsBag.GetLocations (uea); - ud.AddChild (new CSharpTokenNode (Convert (uea.Location), "extern".Length), ExternAliasDeclaration.Roles.Keyword); - if (loc != null) - ud.AddChild (new CSharpTokenNode (Convert (loc[0]), "alias".Length), ExternAliasDeclaration.AliasRole); - ud.AddChild (Identifier.Create (uea.Alias.Value, Convert (uea.Alias.Location)), ExternAliasDeclaration.Roles.Identifier); - if (loc != null && loc.Count > 1) - ud.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), UsingAliasDeclaration.Roles.Semicolon); - AddToNamespace (ud); - } + public override void Visit (UsingExternAlias uea) + { + var ud = new ExternAliasDeclaration (); + var loc = LocationsBag.GetLocations (uea); + ud.AddChild (new CSharpTokenNode (Convert (uea.Location)), Roles.ExternKeyword); + if (loc != null) + ud.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.AliasKeyword); + ud.AddChild (Identifier.Create (uea.Alias.Value, Convert (uea.Alias.Location)), Roles.Identifier); + if (loc != null && loc.Count > 1) + ud.AddChild (new CSharpTokenNode (Convert (loc [1])), Roles.Semicolon); + AddToNamespace (ud); + } AstType ConvertImport (MemberName memberName) { 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); if (!memberName.DotLocation.IsNull) - t.AddChild (new CSharpTokenNode (Convert (memberName.DotLocation), 1), MemberType.Roles.Dot); + t.AddChild (new CSharpTokenNode (Convert (memberName.DotLocation)), Roles.Dot); - t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier); + t.AddChild (Identifier.Create (memberName.Name, Convert (memberName.Location)), Roles.Identifier); AddTypeArguments (t, memberName); return t; } else { - SimpleType t = new SimpleType(); - t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier); + SimpleType t = new SimpleType (); + t.AddChild (Identifier.Create (memberName.Name, Convert (memberName.Location)), Roles.Identifier); AddTypeArguments (t, memberName); return t; } @@ -482,31 +483,31 @@ namespace ICSharpCode.NRefactory.CSharp Stack typeStack = new Stack (); - public override void Visit (Class c) + public override void Visit(Class c) { - TypeDeclaration newType = new TypeDeclaration (); + var newType = new TypeDeclaration (); newType.ClassType = ClassType.Class; - AddAttributeSection (newType, c); + AddAttributeSection(newType, c); - var location = LocationsBag.GetMemberLocation (c); - AddModifiers (newType, location); + var location = LocationsBag.GetMemberLocation(c); + AddModifiers(newType, location); int curLoc = 0; - if (location != null) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), "class".Length), TypeDeclaration.Roles.Keyword); + if (location != null && location.Count > 0) + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.ClassKeyword); - newType.AddChild (Identifier.Create (c.MemberName.Name, Convert (c.MemberName.Location)), AstNode.Roles.Identifier); + newType.AddChild (Identifier.Create (c.MemberName.Name, Convert (c.MemberName.Location)), Roles.Identifier); AddTypeParameters (newType, c.MemberName); if (c.TypeBaseExpressions != null) { if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Colon); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Colon); var commaLocations = LocationsBag.GetLocations (c.TypeBaseExpressions); int i = 0; foreach (var baseTypes in c.TypeBaseExpressions) { - newType.AddChild (ConvertToType (baseTypes), TypeDeclaration.BaseTypeRole); + newType.AddChild (ConvertToType (baseTypes), Roles.BaseType); if (commaLocations != null && i < commaLocations.Count) { - newType.AddChild (new CSharpTokenNode (Convert (commaLocations [i]), 1), TypeDeclaration.Roles.Comma); + newType.AddChild (new CSharpTokenNode (Convert (commaLocations [i])), Roles.Comma); i++; } } @@ -514,47 +515,47 @@ namespace ICSharpCode.NRefactory.CSharp AddConstraints (newType, c.CurrentTypeParameters); if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.LBrace); typeStack.Push (newType); base.Visit (c); - AddAttributeSection (newType, c.UnattachedAttributes, AttributedNode.UnattachedAttributeRole); + AddAttributeSection (newType, c.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole); if (location != null && curLoc < location.Count) { - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.RBrace); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.RBrace); if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Semicolon); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Semicolon); } else { // parser error, set end node to max value. - newType.AddChild (new ErrorNode (), AstNode.Roles.Error); + newType.AddChild (new ErrorNode (), Roles.Error); } typeStack.Pop (); AddType (newType); } - public override void Visit (Struct s) + public override void Visit(Struct s) { - TypeDeclaration newType = new TypeDeclaration (); + var newType = new TypeDeclaration(); newType.ClassType = ClassType.Struct; - AddAttributeSection (newType, s); - var location = LocationsBag.GetMemberLocation (s); - AddModifiers (newType, location); + AddAttributeSection(newType, s); + var location = LocationsBag.GetMemberLocation(s); + AddModifiers(newType, location); int curLoc = 0; - if (location != null) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), "struct".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (Identifier.Create (s.MemberName.Name, Convert (s.MemberName.Location)), AstNode.Roles.Identifier); + if (location != null && location.Count > 0) + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.StructKeyword); + newType.AddChild (Identifier.Create (s.MemberName.Name, Convert (s.MemberName.Location)), Roles.Identifier); AddTypeParameters (newType, s.MemberName); if (s.TypeBaseExpressions != null) { if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Colon); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Colon); var commaLocations = LocationsBag.GetLocations (s.TypeBaseExpressions); int i = 0; foreach (var baseTypes in s.TypeBaseExpressions) { - newType.AddChild (ConvertToType (baseTypes), TypeDeclaration.BaseTypeRole); + newType.AddChild (ConvertToType (baseTypes), Roles.BaseType); if (commaLocations != null && i < commaLocations.Count) { - newType.AddChild (new CSharpTokenNode (Convert (commaLocations [i]), 1), TypeDeclaration.Roles.Comma); + newType.AddChild (new CSharpTokenNode (Convert (commaLocations [i])), Roles.Comma); i++; } } @@ -562,44 +563,44 @@ namespace ICSharpCode.NRefactory.CSharp AddConstraints (newType, s.CurrentTypeParameters); if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.LBrace); typeStack.Push (newType); base.Visit (s); if (location != null && location.Count > 2) { if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.RBrace); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.RBrace); if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Semicolon); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Semicolon); } else { // parser error, set end node to max value. - newType.AddChild (new ErrorNode (), AstNode.Roles.Error); + newType.AddChild (new ErrorNode (), Roles.Error); } typeStack.Pop (); AddType (newType); } - public override void Visit (Interface i) + public override void Visit(Interface i) { - TypeDeclaration newType = new TypeDeclaration (); + var newType = new TypeDeclaration(); newType.ClassType = ClassType.Interface; - AddAttributeSection (newType, i); - var location = LocationsBag.GetMemberLocation (i); - AddModifiers (newType, location); + AddAttributeSection(newType, i); + var location = LocationsBag.GetMemberLocation(i); + AddModifiers(newType, location); int curLoc = 0; - if (location != null) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), "interface".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (Identifier.Create (i.MemberName.Name, Convert (i.MemberName.Location)), AstNode.Roles.Identifier); + if (location != null && location.Count > 0) + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.InterfaceKeyword); + newType.AddChild (Identifier.Create (i.MemberName.Name, Convert (i.MemberName.Location)), Roles.Identifier); AddTypeParameters (newType, i.MemberName); if (i.TypeBaseExpressions != null) { if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Colon); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Colon); var commaLocations = LocationsBag.GetLocations (i.TypeBaseExpressions); int j = 0; foreach (var baseTypes in i.TypeBaseExpressions) { - newType.AddChild (ConvertToType (baseTypes), TypeDeclaration.BaseTypeRole); + newType.AddChild (ConvertToType (baseTypes), Roles.BaseType); if (commaLocations != null && j < commaLocations.Count) { - newType.AddChild (new CSharpTokenNode (Convert (commaLocations [j]), 1), TypeDeclaration.Roles.Comma); + newType.AddChild (new CSharpTokenNode (Convert (commaLocations [j])), Roles.Comma); j++; } } @@ -607,52 +608,54 @@ namespace ICSharpCode.NRefactory.CSharp AddConstraints (newType, i.CurrentTypeParameters); if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.LBrace); typeStack.Push (newType); base.Visit (i); if (location != null && location.Count > 2) { if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.RBrace); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.RBrace); if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Semicolon); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Semicolon); } else { // parser error, set end node to max value. - newType.AddChild (new ErrorNode (), AstNode.Roles.Error); + newType.AddChild (new ErrorNode (), Roles.Error); } typeStack.Pop (); AddType (newType); } - public override void Visit (Mono.CSharp.Delegate d) + public override void Visit(Mono.CSharp.Delegate d) { DelegateDeclaration newDelegate = new DelegateDeclaration (); - var location = LocationsBag.GetMemberLocation (d); - AddAttributeSection (newDelegate, d); - AddModifiers (newDelegate, location); - if (location != null) - newDelegate.AddChild (new CSharpTokenNode (Convert (location[0]), "delegate".Length), TypeDeclaration.Roles.Keyword); - newDelegate.AddChild (ConvertToType (d.ReturnType), AstNode.Roles.Type); - newDelegate.AddChild (Identifier.Create (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier); + var location = LocationsBag.GetMemberLocation(d); + AddAttributeSection(newDelegate, d); + AddModifiers(newDelegate, location); + if (location != null && location.Count > 0) { + newDelegate.AddChild(new CSharpTokenNode (Convert(location [0])), Roles.DelegateKeyword); + } + if (d.ReturnType != null) + newDelegate.AddChild (ConvertToType (d.ReturnType), Roles.Type); + newDelegate.AddChild (Identifier.Create (d.MemberName.Name, Convert (d.MemberName.Location)), Roles.Identifier); AddTypeParameters (newDelegate, d.MemberName); - if (location != null) - newDelegate.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DelegateDeclaration.Roles.LPar); + if (location != null && location.Count > 1) + newDelegate.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.LPar); AddParameter (newDelegate, d.Parameters); - if (location != null) { - newDelegate.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DelegateDeclaration.Roles.RPar); + if (location != null && location.Count > 2) { + newDelegate.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.RPar); } AddConstraints (newDelegate, d.CurrentTypeParameters); - if (location != null) { - newDelegate.AddChild (new CSharpTokenNode (Convert (location[3]), 1), DelegateDeclaration.Roles.Semicolon); + if (location != null && location.Count > 3) { + newDelegate.AddChild (new CSharpTokenNode (Convert (location [3])), Roles.Semicolon); } AddType (newDelegate); } - void AddType (AttributedNode child) + void AddType (EntityDeclaration child) { if (typeStack.Count > 0) { - typeStack.Peek ().AddChild (child, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (child, Roles.TypeMemberRole); } else { AddToNamespace (child); } @@ -667,43 +670,43 @@ namespace ICSharpCode.NRefactory.CSharp } } - public override void Visit (Mono.CSharp.Enum e) + public override void Visit(Mono.CSharp.Enum e) { - TypeDeclaration newType = new TypeDeclaration (); - AddAttributeSection (newType, e); + var newType = new TypeDeclaration(); newType.ClassType = ClassType.Enum; - var location = LocationsBag.GetMemberLocation (e); + AddAttributeSection(newType, e); + var location = LocationsBag.GetMemberLocation(e); - AddModifiers (newType, location); + AddModifiers(newType, location); int curLoc = 0; - if (location != null) - newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++]), "enum".Length), TypeDeclaration.Roles.Keyword); - newType.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), AstNode.Roles.Identifier); + if (location != null && location.Count > 0) + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.EnumKeyword); + newType.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), Roles.Identifier); if (e.BaseTypeExpression != null) { if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Colon); - newType.AddChild (ConvertToType (e.BaseTypeExpression), TypeDeclaration.BaseTypeRole); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Colon); + newType.AddChild (ConvertToType (e.BaseTypeExpression), Roles.BaseType); } if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.LBrace); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.LBrace); typeStack.Push (newType); foreach (EnumMember member in e.Members) { Visit (member); if (location != null && curLoc < location.Count - 1) //last one is closing brace - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Comma); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Comma); } if (location != null && location.Count > 2) { if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.RBrace); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.RBrace); if (location != null && curLoc < location.Count) - newType.AddChild (new CSharpTokenNode (Convert (location[curLoc++]), 1), AstNode.Roles.Semicolon); + newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Semicolon); } else { // parser error, set end node to max value. - newType.AddChild (new ErrorNode (), AstNode.Roles.Error); + newType.AddChild (new ErrorNode (), Roles.Error); } typeStack.Pop (); AddType (newType); @@ -713,14 +716,14 @@ namespace ICSharpCode.NRefactory.CSharp { EnumMemberDeclaration newField = new EnumMemberDeclaration (); AddAttributeSection (newField, em); - newField.AddChild (Identifier.Create (em.Name, Convert (em.Location)), AstNode.Roles.Identifier); + newField.AddChild (Identifier.Create (em.Name, Convert (em.Location)), Roles.Identifier); if (em.Initializer != null) { - newField.AddChild (new CSharpTokenNode (Convert (em.Initializer.Location), 1), EnumMemberDeclaration.Roles.Assign); + newField.AddChild (new CSharpTokenNode (Convert (em.Initializer.Location)), Roles.Assign); newField.AddChild ((Expression)em.Initializer.Accept (this), EnumMemberDeclaration.InitializerRole); } //Console.WriteLine (newField.StartLocation +"-" + newField.EndLocation); - typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newField, Roles.TypeMemberRole); } #endregion @@ -734,20 +737,22 @@ namespace ICSharpCode.NRefactory.CSharp var newField = new FixedFieldDeclaration (); AddAttributeSection (newField, f); AddModifiers (newField, location); - if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location [0]), "fixed".Length), FixedFieldDeclaration.Roles.Keyword); - newField.AddChild (ConvertToType (f.TypeExpression), FixedFieldDeclaration.Roles.Type); + if (location != null && location.Count > 0) + newField.AddChild (new CSharpTokenNode (Convert (location [0])), FixedFieldDeclaration.FixedKeywordRole); + + if (f.TypeExpression != null) + newField.AddChild (ConvertToType (f.TypeExpression), Roles.Type); var variable = new FixedVariableInitializer (); - variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FixedFieldDeclaration.Roles.Identifier); - if (!f.Initializer.IsNull) { + variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), Roles.Identifier); + if (f.Initializer != null && !f.Initializer.IsNull) { var bracketLocations = LocationsBag.GetLocations (f.Initializer); if (bracketLocations != null && bracketLocations.Count > 1) - variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.LBracket); + variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0])), Roles.LBracket); - variable.AddChild ((Expression)f.Initializer.Accept (this), FieldDeclaration.Roles.Expression); + variable.AddChild ((Expression)f.Initializer.Accept (this), Roles.Expression); if (bracketLocations != null && bracketLocations.Count > 1) - variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.RBracket); + variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0])), Roles.RBracket); } newField.AddChild (variable, FixedFieldDeclaration.VariableRole); @@ -755,65 +760,65 @@ 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])), Roles.Comma); variable = new FixedVariableInitializer (); - variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), Roles.Identifier); if (!decl.Initializer.IsNull) { var bracketLocations = LocationsBag.GetLocations (f.Initializer); if (bracketLocations != null && bracketLocations.Count > 1) - variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.LBracket); - variable.AddChild ((Expression)decl.Initializer.Accept (this), FieldDeclaration.Roles.Expression); + variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0])), Roles.LBracket); + variable.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression); if (bracketLocations != null && bracketLocations.Count > 1) - variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0]), 1), FixedFieldDeclaration.Roles.RBracket); + variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0])), Roles.RBracket); } newField.AddChild (variable, FixedFieldDeclaration.VariableRole); } } if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FieldDeclaration.Roles.Semicolon); - typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); + newField.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); + typeStack.Peek ().AddChild (newField, Roles.TypeMemberRole); } - public override void Visit (Field f) + public override void Visit(Field f) { - var location = LocationsBag.GetMemberLocation (f); + var location = LocationsBag.GetMemberLocation(f); FieldDeclaration newField = new FieldDeclaration (); AddAttributeSection (newField, f); AddModifiers (newField, location); - newField.AddChild (ConvertToType (f.TypeExpression), FieldDeclaration.Roles.Type); + newField.AddChild (ConvertToType (f.TypeExpression), Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), Roles.Identifier); if (f.Initializer != null) { if (location != null) - variable.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.Assign); - variable.AddChild ((Expression)f.Initializer.Accept (this), VariableInitializer.Roles.Expression); + variable.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Assign); + variable.AddChild ((Expression)f.Initializer.Accept (this), Roles.Expression); } - newField.AddChild (variable, FieldDeclaration.Roles.Variable); + newField.AddChild (variable, Roles.Variable); if (f.Declarators != null) { foreach (var decl in f.Declarators) { var declLoc = LocationsBag.GetLocations (decl); if (declLoc != null) - newField.AddChild (new CSharpTokenNode (Convert (declLoc [0]), 1), FieldDeclaration.Roles.Comma); + newField.AddChild (new CSharpTokenNode (Convert (declLoc [0])), Roles.Comma); variable = new VariableInitializer (); - variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), Roles.Identifier); if (decl.Initializer != null) { if (declLoc != null) - variable.AddChild (new CSharpTokenNode (Convert (declLoc [1]), 1), FieldDeclaration.Roles.Assign); - variable.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); + variable.AddChild (new CSharpTokenNode (Convert (declLoc [1])), Roles.Assign); + variable.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression); } - newField.AddChild (variable, FieldDeclaration.Roles.Variable); + newField.AddChild (variable, Roles.Variable); } } 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])), Roles.Semicolon); - typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newField, Roles.TypeMemberRole); } public override void Visit (Const f) @@ -824,36 +829,36 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newField, f); AddModifiers (newField, location); if (location != null) - newField.AddChild (new CSharpModifierToken (Convert (location [0]), Modifiers.Const), AttributedNode.ModifierRole); - newField.AddChild (ConvertToType (f.TypeExpression), FieldDeclaration.Roles.Type); + newField.AddChild (new CSharpModifierToken (Convert (location [0]), Modifiers.Const), EntityDeclaration.ModifierRole); + newField.AddChild (ConvertToType (f.TypeExpression), Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), Roles.Identifier); if (f.Initializer != null) { - variable.AddChild (new CSharpTokenNode (Convert (f.Initializer.Location), 1), VariableInitializer.Roles.Assign); - variable.AddChild ((Expression)f.Initializer.Accept (this), VariableInitializer.Roles.Expression); + variable.AddChild (new CSharpTokenNode (Convert (f.Initializer.Location)), Roles.Assign); + variable.AddChild ((Expression)f.Initializer.Accept (this), Roles.Expression); } - newField.AddChild (variable, FieldDeclaration.Roles.Variable); + newField.AddChild (variable, Roles.Variable); if (f.Declarators != null) { foreach (var decl in f.Declarators) { var declLoc = LocationsBag.GetLocations (decl); if (declLoc != null) - newField.AddChild (new CSharpTokenNode (Convert (declLoc[0]), 1), FieldDeclaration.Roles.Comma); + newField.AddChild (new CSharpTokenNode (Convert (declLoc [0])), Roles.Comma); variable = new VariableInitializer (); - variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), 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); + variable.AddChild (new CSharpTokenNode (Convert (decl.Initializer.Location)), Roles.Assign); + variable.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression); } - newField.AddChild (variable, FieldDeclaration.Roles.Variable); + newField.AddChild (variable, Roles.Variable); } } if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FieldDeclaration.Roles.Semicolon); + newField.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); - typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newField, Roles.TypeMemberRole); } @@ -869,40 +874,41 @@ 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); + if (location != null && location.Count > 0) { + newOperator.AddChild (new CSharpTokenNode (Convert (location [0])), OperatorDeclaration.ImplicitRole); + if (location.Count > 1) + newOperator.AddChild (new CSharpTokenNode (Convert (location [1])), OperatorDeclaration.OperatorKeywordRole); } - newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type); + newOperator.AddChild (ConvertToType (o.TypeExpression), Roles.Type); } 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); + if (location != null && location.Count > 0) { + newOperator.AddChild (new CSharpTokenNode (Convert (location [0])), OperatorDeclaration.ExplicitRole); + if (location.Count > 1) + newOperator.AddChild (new CSharpTokenNode (Convert (location [1])), OperatorDeclaration.OperatorKeywordRole); } - newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type); + newOperator.AddChild (ConvertToType (o.TypeExpression), Roles.Type); } else { - newOperator.AddChild (ConvertToType (o.TypeExpression), AstNode.Roles.Type); - - if (location != null) - newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "operator".Length), OperatorDeclaration.OperatorKeywordRole); + newOperator.AddChild (ConvertToType (o.TypeExpression), Roles.Type); + + if (location != null && location.Count > 0) + newOperator.AddChild (new CSharpTokenNode (Convert (location [0])), OperatorDeclaration.OperatorKeywordRole); - int opLength = OperatorDeclaration.GetToken(newOperator.OperatorType).Length; - if (location != null) - newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), opLength), OperatorDeclaration.OperatorTypeRole); + if (location != null && location.Count > 1) + newOperator.AddChild (new CSharpTokenNode (Convert (location [1])), OperatorDeclaration.GetRole (newOperator.OperatorType)); } - if (location != null) - newOperator.AddChild (new CSharpTokenNode (Convert (location[2]), 1), OperatorDeclaration.Roles.LPar); + if (location != null && location.Count > 2) + newOperator.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.LPar); AddParameter (newOperator, o.ParameterInfo); - if (location != null) - newOperator.AddChild (new CSharpTokenNode (Convert (location[3]), 1), OperatorDeclaration.Roles.RPar); + if (location != null && location.Count > 3) + newOperator.AddChild (new CSharpTokenNode (Convert (location [3])), Roles.RPar); if (o.Block != null) { - newOperator.AddChild ((BlockStatement)o.Block.Accept (this), OperatorDeclaration.Roles.Body); + newOperator.AddChild ((BlockStatement)o.Block.Accept (this), Roles.Body); } else { if (location != null && location.Count >= 5) - newOperator.AddChild (new CSharpTokenNode (Convert (location[4]), 1), MethodDeclaration.Roles.Semicolon); + newOperator.AddChild (new CSharpTokenNode (Convert (location [4])), Roles.Semicolon); } - typeStack.Peek ().AddChild (newOperator, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newOperator, Roles.TypeMemberRole); } public void AddAttributeSection (AstNode parent, Attributable a) @@ -917,12 +923,13 @@ namespace ICSharpCode.NRefactory.CSharp if (attrs == null) return; foreach (var attr in attrs.Sections) { - parent.AddChild (ConvertAttributeSection (attr), AttributedNode.AttributeRole); + parent.AddChild (ConvertAttributeSection (attr), EntityDeclaration.AttributeRole); } } + public void AddAttributeSection (AstNode parent, Attributes attrs) { - AddAttributeSection (parent, attrs, AttributedNode.AttributeRole); + AddAttributeSection (parent, attrs, EntityDeclaration.AttributeRole); } public override void Visit (Indexer indexer) @@ -931,31 +938,31 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newIndexer, indexer); var location = LocationsBag.GetMemberLocation (indexer); AddModifiers (newIndexer, location); - newIndexer.AddChild (ConvertToType (indexer.TypeExpression), IndexerDeclaration.Roles.Type); + newIndexer.AddChild (ConvertToType (indexer.TypeExpression), Roles.Type); AddExplicitInterface (newIndexer, indexer.MemberName); var name = indexer.MemberName; - newIndexer.AddChild (Identifier.Create ("this", Convert (name.Location)), IndexerDeclaration.Roles.Identifier); + newIndexer.AddChild (Identifier.Create ("this", Convert (name.Location)), Roles.Identifier); - if (location != null) - newIndexer.AddChild (new CSharpTokenNode (Convert (location [0]), 1), IndexerDeclaration.Roles.LBracket); + if (location != null && location.Count > 0) + newIndexer.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LBracket); AddParameter (newIndexer, indexer.ParameterInfo); - if (location != null) - newIndexer.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IndexerDeclaration.Roles.RBracket); + if (location != null && location.Count > 1) + newIndexer.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RBracket); - if (location != null) - newIndexer.AddChild (new CSharpTokenNode (Convert (location[2]), 1), IndexerDeclaration.Roles.LBrace); + if (location != null && location.Count > 2) + newIndexer.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.LBrace); if (indexer.Get != null) { Accessor getAccessor = new Accessor (); var getLocation = LocationsBag.GetMemberLocation (indexer.Get); AddAttributeSection (getAccessor, indexer.Get); AddModifiers (getAccessor, getLocation); if (getLocation != null) - getAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Get.Location), "get".Length), PropertyDeclaration.Roles.Keyword); + getAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Get.Location)), PropertyDeclaration.GetKeywordRole); if (indexer.Get.Block != null) { - getAccessor.AddChild ((BlockStatement)indexer.Get.Block.Accept (this), MethodDeclaration.Roles.Body); + getAccessor.AddChild ((BlockStatement)indexer.Get.Block.Accept (this), 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])), Roles.Semicolon); } newIndexer.AddChild (getAccessor, PropertyDeclaration.GetterRole); } @@ -966,24 +973,25 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (setAccessor, indexer.Set); AddModifiers (setAccessor, setLocation); if (setLocation != null) - setAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Set.Location), "set".Length), PropertyDeclaration.Roles.Keyword); + setAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Set.Location)), PropertyDeclaration.SetKeywordRole); if (indexer.Set.Block != null) { - setAccessor.AddChild ((BlockStatement)indexer.Set.Block.Accept (this), MethodDeclaration.Roles.Body); + setAccessor.AddChild ((BlockStatement)indexer.Set.Block.Accept (this), 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])), Roles.Semicolon); } newIndexer.AddChild (setAccessor, PropertyDeclaration.SetterRole); } if (location != null) { - newIndexer.AddChild (new CSharpTokenNode (Convert (location[3]), 1), IndexerDeclaration.Roles.RBrace); + if (location.Count > 3) + newIndexer.AddChild (new CSharpTokenNode (Convert (location [3])), Roles.RBrace); } else { // parser error, set end node to max value. - newIndexer.AddChild (new ErrorNode (), AstNode.Roles.Error); + newIndexer.AddChild (new ErrorNode (), Roles.Error); } - typeStack.Peek ().AddChild (newIndexer, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newIndexer, Roles.TypeMemberRole); } public override void Visit (Method m) @@ -992,37 +1000,37 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newMethod, m); var location = LocationsBag.GetMemberLocation (m); AddModifiers (newMethod, location); - newMethod.AddChild (ConvertToType (m.TypeExpression), AstNode.Roles.Type); + newMethod.AddChild (ConvertToType (m.TypeExpression), Roles.Type); AddExplicitInterface (newMethod, m.MethodName); - newMethod.AddChild (Identifier.Create (m.MethodName.Name, Convert (m.Location)), AstNode.Roles.Identifier); + newMethod.AddChild (Identifier.Create (m.MethodName.Name, Convert (m.Location)), Roles.Identifier); AddTypeParameters (newMethod, m.MemberName); - if (location != null) - newMethod.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MethodDeclaration.Roles.LPar); + if (location != null && location.Count > 0) + newMethod.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); AddParameter (newMethod, m.ParameterInfo); - if (location != null) - newMethod.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RPar); + if (location != null && location.Count > 1) + newMethod.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); AddConstraints (newMethod, m.CurrentTypeParameters); if (m.Block != null) { var bodyBlock = (BlockStatement)m.Block.Accept (this); // if (m.Block is ToplevelBlock) { -// newMethod.AddChild (bodyBlock.FirstChild.NextSibling, MethodDeclaration.Roles.Body); +// newMethod.AddChild (bodyBlock.FirstChild.NextSibling, Roles.Body); // } else { - newMethod.AddChild (bodyBlock, MethodDeclaration.Roles.Body); + newMethod.AddChild (bodyBlock, Roles.Body); // } } else if (location != null) { if (location.Count < 3) { // parser error, set end node to max value. - newMethod.AddChild (new ErrorNode (), AstNode.Roles.Error); + newMethod.AddChild (new ErrorNode (), Roles.Error); } else { - newMethod.AddChild (new CSharpTokenNode (Convert (location[2]), 1), MethodDeclaration.Roles.Semicolon); + newMethod.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.Semicolon); } } - typeStack.Peek ().AddChild (newMethod, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newMethod, Roles.TypeMemberRole); } static Dictionary modifierTable = new Dictionary (); @@ -1069,17 +1077,17 @@ namespace ICSharpCode.NRefactory.CSharp keywordTable [(int)BuiltinTypeSpec.Type.Bool] = "bool"; } - void AddModifiers (AttributedNode parent, LocationsBag.MemberLocations location) + void AddModifiers (EntityDeclaration parent, LocationsBag.MemberLocations location) { if (location == null || location.Modifiers == null) return; foreach (var modifier in location.Modifiers) { ICSharpCode.NRefactory.CSharp.Modifiers mod; if (!modifierTable.TryGetValue (modifier.Item1, out mod)) { - Console.WriteLine ("modifier "+ modifier.Item1 + " can't be converted,"); + Console.WriteLine ("modifier " + modifier.Item1 + " can't be converted,"); } - parent.AddChild (new CSharpModifierToken (Convert (modifier.Item2), mod), AttributedNode.ModifierRole); + parent.AddChild (new CSharpModifierToken (Convert (modifier.Item2), mod), EntityDeclaration.ModifierRole); } } @@ -1089,12 +1097,12 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newProperty, p); var location = LocationsBag.GetMemberLocation (p); AddModifiers (newProperty, location); - newProperty.AddChild (ConvertToType (p.TypeExpression), AstNode.Roles.Type); + newProperty.AddChild (ConvertToType (p.TypeExpression), Roles.Type); AddExplicitInterface (newProperty, p.MemberName); - newProperty.AddChild (Identifier.Create (p.MemberName.Name, Convert (p.Location)), PropertyDeclaration.Roles.Identifier); + newProperty.AddChild (Identifier.Create (p.MemberName.Name, Convert (p.Location)), Roles.Identifier); - if (location != null) - newProperty.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MethodDeclaration.Roles.LBrace); + if (location != null && location.Count > 0) + newProperty.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LBrace); Accessor getAccessor = null; if (p.Get != null) { @@ -1102,13 +1110,13 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (getAccessor, p.Get); var getLocation = LocationsBag.GetMemberLocation (p.Get); AddModifiers (getAccessor, getLocation); - getAccessor.AddChild (new CSharpTokenNode (Convert (p.Get.Location), "get".Length), PropertyDeclaration.Roles.Keyword); + getAccessor.AddChild (new CSharpTokenNode (Convert (p.Get.Location)), PropertyDeclaration.GetKeywordRole); if (p.Get.Block != null) { - getAccessor.AddChild ((BlockStatement)p.Get.Block.Accept (this), MethodDeclaration.Roles.Body); + getAccessor.AddChild ((BlockStatement)p.Get.Block.Accept (this), Roles.Body); } else { if (getLocation != null && getLocation.Count > 0) - getAccessor.AddChild (new CSharpTokenNode (Convert (getLocation[0]), 1), MethodDeclaration.Roles.Semicolon); + getAccessor.AddChild (new CSharpTokenNode (Convert (getLocation [0])), Roles.Semicolon); } } @@ -1118,13 +1126,13 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (setAccessor, p.Set); var setLocation = LocationsBag.GetMemberLocation (p.Set); AddModifiers (setAccessor, setLocation); - setAccessor.AddChild (new CSharpTokenNode (Convert (p.Set.Location), "set".Length), PropertyDeclaration.Roles.Keyword); + setAccessor.AddChild (new CSharpTokenNode (Convert (p.Set.Location)), PropertyDeclaration.SetKeywordRole); if (p.Set.Block != null) { - setAccessor.AddChild ((BlockStatement)p.Set.Block.Accept (this), MethodDeclaration.Roles.Body); + setAccessor.AddChild ((BlockStatement)p.Set.Block.Accept (this), Roles.Body); } else { if (setLocation != null && setLocation.Count > 0) - setAccessor.AddChild (new CSharpTokenNode (Convert (setLocation[0]), 1), MethodDeclaration.Roles.Semicolon); + setAccessor.AddChild (new CSharpTokenNode (Convert (setLocation [0])), Roles.Semicolon); } } if (getAccessor != null && setAccessor != null) { @@ -1143,13 +1151,13 @@ namespace ICSharpCode.NRefactory.CSharp } if (location != null && location.Count > 1) { - newProperty.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RBrace); + newProperty.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RBrace); } else { // parser error, set end node to max value. - newProperty.AddChild (new ErrorNode (), AstNode.Roles.Error); + newProperty.AddChild (new ErrorNode (), Roles.Error); } - typeStack.Peek ().AddChild (newProperty, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newProperty, Roles.TypeMemberRole); } public override void Visit (Constructor c) @@ -1158,13 +1166,13 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newConstructor, c); var location = LocationsBag.GetMemberLocation (c); AddModifiers (newConstructor, location); - 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 (Identifier.Create (c.MemberName.Name, Convert (c.MemberName.Location)), Roles.Identifier); + if (location != null && location.Count > 0) + newConstructor.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); AddParameter (newConstructor, c.ParameterInfo); - if (location != null) - newConstructor.AddChild (new CSharpTokenNode (Convert (location[1]), 1), MethodDeclaration.Roles.RPar); + if (location != null && location.Count > 1) + newConstructor.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); if (c.Initializer != null) { var initializer = new ConstructorInitializer (); @@ -1172,22 +1180,21 @@ namespace ICSharpCode.NRefactory.CSharp var initializerLocation = LocationsBag.GetLocations (c.Initializer); if (initializerLocation != null) - newConstructor.AddChild (new CSharpTokenNode (Convert (initializerLocation[0]), 1), ConstructorDeclaration.Roles.Colon); + newConstructor.AddChild (new CSharpTokenNode (Convert (initializerLocation [0])), Roles.Colon); if (initializerLocation != null && initializerLocation.Count > 1) { // this and base has the same length - initializer.AddChild (new CSharpTokenNode (Convert (c.Initializer.Location), "this".Length), ConstructorDeclaration.Roles.Keyword); - initializer.AddChild (new CSharpTokenNode (Convert (initializerLocation[1]), 1), ConstructorDeclaration.Roles.LPar); + initializer.AddChild (new CSharpTokenNode (Convert (c.Initializer.Location)), initializer.ConstructorInitializerType == ConstructorInitializerType.This ? ConstructorInitializer.ThisKeywordRole : ConstructorInitializer.BaseKeywordRole); + initializer.AddChild (new CSharpTokenNode (Convert (initializerLocation [1])), Roles.LPar); AddArguments (initializer, LocationsBag.GetLocations (c.Initializer.Arguments), c.Initializer.Arguments); - initializer.AddChild (new CSharpTokenNode (Convert (initializerLocation[2]), 1), ConstructorDeclaration.Roles.RPar); + initializer.AddChild (new CSharpTokenNode (Convert (initializerLocation [2])), Roles.RPar); newConstructor.AddChild (initializer, ConstructorDeclaration.InitializerRole); } } if (c.Block != null) - newConstructor.AddChild ((BlockStatement)c.Block.Accept (this), ConstructorDeclaration.Roles.Body); - - typeStack.Peek ().AddChild (newConstructor, TypeDeclaration.MemberRole); + newConstructor.AddChild ((BlockStatement)c.Block.Accept (this), Roles.Body); + typeStack.Peek ().AddChild (newConstructor, Roles.TypeMemberRole); } public override void Visit (Destructor d) @@ -1196,19 +1203,21 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (newDestructor, d); var location = LocationsBag.GetMemberLocation (d); AddModifiers (newDestructor, location); - if (location != null) - 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 && location.Count > 0) + newDestructor.AddChild (new CSharpTokenNode (Convert (location [0])), DestructorDeclaration.TildeRole); + newDestructor.AddChild (Identifier.Create (d.Identifier, Convert (d.MemberName.Location)), 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); + if (location != null && location.Count > 1) { + newDestructor.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.LPar); + + if (location.Count > 2) + newDestructor.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.RPar); } if (d.Block != null) - newDestructor.AddChild ((BlockStatement)d.Block.Accept (this), DestructorDeclaration.Roles.Body); + newDestructor.AddChild ((BlockStatement)d.Block.Accept (this), Roles.Body); - typeStack.Peek ().AddChild (newDestructor, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newDestructor, Roles.TypeMemberRole); } public override void Visit (EventField e) @@ -1218,52 +1227,52 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetMemberLocation (e); AddModifiers (newEvent, location); - if (location != null) - newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), EventDeclaration.Roles.Keyword); - newEvent.AddChild (ConvertToType (e.TypeExpression), AstNode.Roles.Type); + if (location != null && location.Count > 0) + newEvent.AddChild (new CSharpTokenNode (Convert (location [0])), EventDeclaration.EventKeywordRole); + newEvent.AddChild (ConvertToType (e.TypeExpression), Roles.Type); VariableInitializer variable = new VariableInitializer (); - variable.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), FieldDeclaration.Roles.Identifier); + variable.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), Roles.Identifier); if (e.Initializer != null) { - if (location != null) - variable.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.Assign); - variable.AddChild ((Expression)e.Initializer.Accept (this), VariableInitializer.Roles.Expression); + if (location != null && location.Count > 0) + variable.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Assign); + variable.AddChild ((Expression)e.Initializer.Accept (this), Roles.Expression); } - newEvent.AddChild (variable, FieldDeclaration.Roles.Variable); + newEvent.AddChild (variable, Roles.Variable); if (e.Declarators != null) { 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])), Roles.Comma); variable = new VariableInitializer (); - variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), VariableInitializer.Roles.Identifier); + variable.AddChild (Identifier.Create (decl.Name.Value, Convert (decl.Name.Location)), Roles.Identifier); if (decl.Initializer != null) { if (declLoc != null) - variable.AddChild (new CSharpTokenNode (Convert (declLoc [1]), 1), FieldDeclaration.Roles.Assign); - variable.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); + variable.AddChild (new CSharpTokenNode (Convert (declLoc [1])), Roles.Assign); + variable.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression); } - newEvent.AddChild (variable, FieldDeclaration.Roles.Variable); + newEvent.AddChild (variable, Roles.Variable); } } - if (location != null) - newEvent.AddChild (new CSharpTokenNode (Convert (location[1]), ";".Length), EventDeclaration.Roles.Semicolon); + if (location != null && location.Count > 1) + newEvent.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); - typeStack.Peek ().AddChild (newEvent, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newEvent, Roles.TypeMemberRole); } - + void AddExplicitInterface (AstNode parent, MemberName memberName) { if (memberName == null || memberName.ExplicitInterface == null) return; - parent.AddChild (ConvertToType (memberName.ExplicitInterface), MemberDeclaration.PrivateImplementationTypeRole); + parent.AddChild (ConvertToType (memberName.ExplicitInterface), EntityDeclaration.PrivateImplementationTypeRole); var privateImplTypeLoc = LocationsBag.GetLocations (memberName.ExplicitInterface); if (privateImplTypeLoc != null) - parent.AddChild (new CSharpTokenNode (Convert (privateImplTypeLoc[0]), 1), MethodDeclaration.Roles.Dot); + parent.AddChild (new CSharpTokenNode (Convert (privateImplTypeLoc [0])), Roles.Dot); } public override void Visit (EventProperty ep) @@ -1273,25 +1282,25 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetMemberLocation (ep); AddModifiers (newEvent, location); - if (location != null) - newEvent.AddChild (new CSharpTokenNode (Convert (location[0]), "event".Length), CustomEventDeclaration.Roles.Keyword); - newEvent.AddChild (ConvertToType (ep.TypeExpression), CustomEventDeclaration.Roles.Type); + if (location != null && location.Count > 0) + newEvent.AddChild (new CSharpTokenNode (Convert (location [0])), CustomEventDeclaration.EventKeywordRole); + newEvent.AddChild (ConvertToType (ep.TypeExpression), Roles.Type); AddExplicitInterface (newEvent, ep.MemberName); - newEvent.AddChild (Identifier.Create (ep.MemberName.Name, Convert (ep.Location)), CustomEventDeclaration.Roles.Identifier); + newEvent.AddChild (Identifier.Create (ep.MemberName.Name, Convert (ep.Location)), 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])), Roles.LBrace); if (ep.Add != null) { Accessor addAccessor = new Accessor (); AddAttributeSection (addAccessor, ep.Add); var addLocation = LocationsBag.GetMemberLocation (ep.Add); AddModifiers (addAccessor, addLocation); - addAccessor.AddChild (new CSharpTokenNode (Convert (ep.Add.Location), "add".Length), CustomEventDeclaration.Roles.Keyword); + addAccessor.AddChild (new CSharpTokenNode (Convert (ep.Add.Location)), CustomEventDeclaration.AddKeywordRole); if (ep.Add.Block != null) - addAccessor.AddChild ((BlockStatement)ep.Add.Block.Accept (this), CustomEventDeclaration.Roles.Body); + addAccessor.AddChild ((BlockStatement)ep.Add.Block.Accept (this), Roles.Body); newEvent.AddChild (addAccessor, CustomEventDeclaration.AddAccessorRole); } @@ -1300,20 +1309,20 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (removeAccessor, ep.Remove); var removeLocation = LocationsBag.GetMemberLocation (ep.Remove); AddModifiers (removeAccessor, removeLocation); - removeAccessor.AddChild (new CSharpTokenNode (Convert (ep.Remove.Location), "remove".Length), CustomEventDeclaration.Roles.Keyword); + removeAccessor.AddChild (new CSharpTokenNode (Convert (ep.Remove.Location)), CustomEventDeclaration.RemoveKeywordRole); if (ep.Remove.Block != null) - removeAccessor.AddChild ((BlockStatement)ep.Remove.Block.Accept (this), CustomEventDeclaration.Roles.Body); + removeAccessor.AddChild ((BlockStatement)ep.Remove.Block.Accept (this), Roles.Body); newEvent.AddChild (removeAccessor, CustomEventDeclaration.RemoveAccessorRole); } if (location != null && location.Count >= 3) { - newEvent.AddChild (new CSharpTokenNode (Convert (location[2]), 1), CustomEventDeclaration.Roles.RBrace); + newEvent.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.RBrace); } else { // parser error, set end node to max value. - newEvent.AddChild (new ErrorNode (), AstNode.Roles.Error); + newEvent.AddChild (new ErrorNode (), Roles.Error); } - typeStack.Peek ().AddChild (newEvent, TypeDeclaration.MemberRole); + typeStack.Peek ().AddChild (newEvent, Roles.TypeMemberRole); } #endregion @@ -1328,37 +1337,37 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (BlockVariableDeclaration blockVariableDeclaration) { var result = new VariableDeclarationStatement (); - result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), VariableDeclarationStatement.Roles.Type); + result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), Roles.Type); var varInit = new VariableInitializer (); var location = LocationsBag.GetLocations (blockVariableDeclaration); - varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { - if (location != null) - varInit.AddChild (new CSharpTokenNode (Convert (location[0]), 1), VariableInitializer.Roles.Assign); - varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), VariableInitializer.Roles.Expression); + if (location != null && location.Count > 0) + varInit.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Assign); + varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), Roles.Expression); } - result.AddChild (varInit, VariableDeclarationStatement.Roles.Variable); + result.AddChild (varInit, Roles.Variable); if (blockVariableDeclaration.Declarators != null) { foreach (var decl in blockVariableDeclaration.Declarators) { var loc = LocationsBag.GetLocations (decl); var init = new VariableInitializer (); if (loc != null && loc.Count > 0) - result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), VariableInitializer.Roles.Comma); - init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); + result.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.Comma); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), Roles.Identifier); if (decl.Initializer != null) { if (loc != null && loc.Count > 1) - init.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), VariableInitializer.Roles.Assign); - init.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); + init.AddChild (new CSharpTokenNode (Convert (loc [1])), Roles.Assign); + init.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression); } else { } - result.AddChild (init, VariableDeclarationStatement.Roles.Variable); + result.AddChild (init, Roles.Variable); } } if (location != null && (blockVariableDeclaration.Initializer == null || location.Count > 1)) - result.AddChild (new CSharpTokenNode (Convert (location[location.Count - 1]), 1), VariableDeclarationStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1])), Roles.Semicolon); return result; } @@ -1367,44 +1376,44 @@ namespace ICSharpCode.NRefactory.CSharp var result = new VariableDeclarationStatement (); var location = LocationsBag.GetLocations (blockVariableDeclaration); - if (location != null) + if (location != null && location.Count > 0) result.AddChild (new CSharpModifierToken (Convert (location [0]), ICSharpCode.NRefactory.CSharp.Modifiers.Const), VariableDeclarationStatement.ModifierRole); - result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), VariableDeclarationStatement.Roles.Type); + result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), Roles.Type); var varInit = new VariableInitializer (); - varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { - if (location != null) - varInit.AddChild (new CSharpTokenNode (Convert (location[1]), 1), VariableInitializer.Roles.Assign); - varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), VariableInitializer.Roles.Expression); + if (location != null && location.Count > 1) + varInit.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Assign); + varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), Roles.Expression); } - result.AddChild (varInit, VariableDeclarationStatement.Roles.Variable); + result.AddChild (varInit, Roles.Variable); if (blockVariableDeclaration.Declarators != null) { foreach (var decl in blockVariableDeclaration.Declarators) { var loc = LocationsBag.GetLocations (decl); var init = new VariableInitializer (); - init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), Roles.Identifier); if (decl.Initializer != null) { if (loc != null) - init.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), VariableInitializer.Roles.Assign); - init.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); + init.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.Assign); + init.AddChild ((Expression)decl.Initializer.Accept (this), 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])), 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])), Roles.Comma); } - result.AddChild (init, VariableDeclarationStatement.Roles.Variable); + result.AddChild (init, Roles.Variable); } } if (location != null) { - result.AddChild (new CSharpTokenNode (Convert (location[location.Count - 1]), 1), VariableDeclarationStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1])), Roles.Semicolon); } else { // parser error, set end node to max value. - result.AddChild (new ErrorNode (), AstNode.Roles.Error); + result.AddChild (new ErrorNode (), Roles.Error); } return result; } @@ -1437,20 +1446,20 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (ifStatement); - result.AddChild (new CSharpTokenNode (Convert (ifStatement.loc), "if".Length), IfElseStatement.IfKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (ifStatement.loc)), IfElseStatement.IfKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), IfElseStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (ifStatement.Expr != null) - result.AddChild ((Expression)ifStatement.Expr.Accept (this), IfElseStatement.Roles.Condition); + result.AddChild ((Expression)ifStatement.Expr.Accept (this), Roles.Condition); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IfElseStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), 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); + if (location != null && location.Count > 2) + result.AddChild (new CSharpTokenNode (Convert (location [2])), IfElseStatement.ElseKeywordRole); result.AddChild ((Statement)ifStatement.FalseStatement.Accept (this), IfElseStatement.FalseRole); } @@ -1461,18 +1470,19 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new DoWhileStatement (); var location = LocationsBag.GetLocations (doStatement); - result.AddChild (new CSharpTokenNode (Convert (doStatement.loc), "do".Length), DoWhileStatement.DoKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (doStatement.loc)), DoWhileStatement.DoKeywordRole); if (doStatement.EmbeddedStatement != null) - result.AddChild ((Statement)doStatement.EmbeddedStatement.Accept (this), WhileStatement.Roles.EmbeddedStatement); + result.AddChild ((Statement)doStatement.EmbeddedStatement.Accept (this), Roles.EmbeddedStatement); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "while".Length), DoWhileStatement.WhileKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [0])), DoWhileStatement.WhileKeywordRole); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DoWhileStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.LPar); if (doStatement.expr != null) - result.AddChild ((Expression)doStatement.expr.Accept (this), DoWhileStatement.Roles.Condition); + result.AddChild ((Expression)doStatement.expr.Accept (this), Roles.Condition); if (location != null && location.Count > 2) { - 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])), Roles.RPar); + if (location.Count > 3) + result.AddChild (new CSharpTokenNode (Convert (location [3])), Roles.Semicolon); } return result; @@ -1482,16 +1492,16 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new WhileStatement (); var location = LocationsBag.GetLocations (whileStatement); - result.AddChild (new CSharpTokenNode (Convert (whileStatement.loc), "while".Length), WhileStatement.WhileKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (whileStatement.loc)), WhileStatement.WhileKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), WhileStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (whileStatement.expr != null) - result.AddChild ((Expression)whileStatement.expr.Accept (this), WhileStatement.Roles.Condition); + result.AddChild ((Expression)whileStatement.expr.Accept (this), Roles.Condition); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), WhileStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); if (whileStatement.Statement != null) - result.AddChild ((Statement)whileStatement.Statement.Accept (this), WhileStatement.Roles.EmbeddedStatement); + result.AddChild ((Statement)whileStatement.Statement.Accept (this), Roles.EmbeddedStatement); return result; } @@ -1516,26 +1526,26 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (forStatement); - result.AddChild (new CSharpTokenNode (Convert (forStatement.loc), "for".Length), ForStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (forStatement.loc)), ForStatement.ForKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ForStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); AddStatementOrList (result, forStatement.Initializer, ForStatement.InitializerRole); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), ForStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); if (forStatement.Condition != null) - result.AddChild ((Expression)forStatement.Condition.Accept (this), ForStatement.Roles.Condition); + result.AddChild ((Expression)forStatement.Condition.Accept (this), Roles.Condition); if (location != null && location.Count >= 3) - result.AddChild (new CSharpTokenNode (Convert (location [2]), 1), ForStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.Semicolon); AddStatementOrList (result, forStatement.Iterator, ForStatement.IteratorRole); if (location != null && location.Count >= 4) - result.AddChild (new CSharpTokenNode (Convert (location [3]), 1), ForStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [3])), Roles.RPar); if (forStatement.Statement != null) - result.AddChild ((Statement)forStatement.Statement.Accept (this), ForStatement.Roles.EmbeddedStatement); + result.AddChild ((Statement)forStatement.Statement.Accept (this), Roles.EmbeddedStatement); return result; } @@ -1545,10 +1555,10 @@ namespace ICSharpCode.NRefactory.CSharp var result = new ExpressionStatement (); var expr = statementExpression.Expr.Accept (this) as Expression; if (expr != null) - result.AddChild ((Expression)expr, ExpressionStatement.Roles.Expression); + result.AddChild ((Expression)expr, 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])), Roles.Semicolon); return result; } @@ -1557,7 +1567,7 @@ namespace ICSharpCode.NRefactory.CSharp var result = new ExpressionStatement (); var expr = statementErrorExpression.Expr.Accept (this) as Expression; if (expr != null) - result.AddChild ((Expression)expr, ExpressionStatement.Roles.Expression); + result.AddChild ((Expression)expr, Roles.Expression); return result; } @@ -1568,10 +1578,10 @@ namespace ICSharpCode.NRefactory.CSharp return result; var expr = statementExpression.Expression.Accept (this) as Expression; if (expr != null) - result.AddChild (expr, ExpressionStatement.Roles.Expression); + result.AddChild (expr, 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])), Roles.Semicolon); return result; } @@ -1579,13 +1589,13 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new ReturnStatement (); - result.AddChild (new CSharpTokenNode (Convert (returnStatement.loc), "return".Length), ReturnStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (returnStatement.loc)), ReturnStatement.ReturnKeywordRole); if (returnStatement.Expr != null) - result.AddChild ((Expression)returnStatement.Expr.Accept (this), ReturnStatement.Roles.Expression); + result.AddChild ((Expression)returnStatement.Expr.Accept (this), Roles.Expression); 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])), Roles.Semicolon); return result; } @@ -1594,11 +1604,11 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new GotoStatement (); var location = LocationsBag.GetLocations (gotoStatement); - result.AddChild (new CSharpTokenNode (Convert (gotoStatement.loc), "goto".Length), GotoStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (gotoStatement.loc)), GotoStatement.GotoKeywordRole); var loc = location != null ? Convert (location [0]) : TextLocation.Empty; - result.AddChild (Identifier.Create (gotoStatement.Target, loc), GotoStatement.Roles.Identifier); + result.AddChild (Identifier.Create (gotoStatement.Target, loc), Roles.Identifier); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), GotoStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); return result; } @@ -1606,21 +1616,22 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (LabeledStatement labeledStatement) { var result = new LabelStatement (); - result.AddChild (Identifier.Create (labeledStatement.Name, Convert (labeledStatement.loc)), LabelStatement.Roles.Identifier); + result.AddChild (Identifier.Create (labeledStatement.Name, Convert (labeledStatement.loc)), Roles.Identifier); var location = LocationsBag.GetLocations (labeledStatement); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), LabelStatement.Roles.Colon); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Colon); return result; } public override object Visit (GotoDefault gotoDefault) { var result = new GotoDefaultStatement (); - result.AddChild (new CSharpTokenNode (Convert (gotoDefault.loc), "goto".Length), GotoDefaultStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (gotoDefault.loc)), GotoDefaultStatement.GotoKeywordRole); var location = LocationsBag.GetLocations (gotoDefault); - if (location != null && location.Count > 1) { - result.AddChild (new CSharpTokenNode (Convert (location[0]), "default".Length), GotoDefaultStatement.DefaultKeywordRole); - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), GotoDefaultStatement.Roles.Semicolon); + if (location != null) { + result.AddChild (new CSharpTokenNode (Convert (location [0])), GotoDefaultStatement.DefaultKeywordRole); + if (location.Count > 1) + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); } return result; @@ -1629,15 +1640,15 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (GotoCase gotoCase) { var result = new GotoCaseStatement (); - result.AddChild (new CSharpTokenNode (Convert (gotoCase.loc), "goto".Length), GotoCaseStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (gotoCase.loc)), GotoCaseStatement.GotoKeywordRole); 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])), GotoCaseStatement.CaseKeywordRole); if (gotoCase.Expr != null) - result.AddChild ((Expression)gotoCase.Expr.Accept (this), GotoCaseStatement.Roles.Expression); + result.AddChild ((Expression)gotoCase.Expr.Accept (this), Roles.Expression); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), GotoCaseStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); return result; } @@ -1646,11 +1657,11 @@ namespace ICSharpCode.NRefactory.CSharp var result = new ThrowStatement (); var location = LocationsBag.GetLocations (throwStatement); - result.AddChild (new CSharpTokenNode (Convert (throwStatement.loc), "throw".Length), ThrowStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (throwStatement.loc)), ThrowStatement.ThrowKeywordRole); if (throwStatement.Expr != null) - result.AddChild ((Expression)throwStatement.Expr.Accept (this), ThrowStatement.Roles.Expression); + result.AddChild ((Expression)throwStatement.Expr.Accept (this), Roles.Expression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ThrowStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Semicolon); return result; } @@ -1659,9 +1670,9 @@ namespace ICSharpCode.NRefactory.CSharp var result = new BreakStatement (); var location = LocationsBag.GetLocations (breakStatement); - result.AddChild (new CSharpTokenNode (Convert (breakStatement.loc), "break".Length), BreakStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (breakStatement.loc)), BreakStatement.BreakKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), BreakStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Semicolon); return result; } @@ -1669,9 +1680,9 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new ContinueStatement (); var location = LocationsBag.GetLocations (continueStatement); - result.AddChild (new CSharpTokenNode (Convert (continueStatement.loc), "continue".Length), ContinueStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (continueStatement.loc)), ContinueStatement.ContinueKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ContinueStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Semicolon); return result; } @@ -1683,11 +1694,11 @@ namespace ICSharpCode.NRefactory.CSharp 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); + usingResult.AddChild (new CSharpTokenNode (Convert (u.loc)), UsingStatement.UsingKeywordRole); + usingResult.AddChild (new CSharpTokenNode (Convert (blockStatement.StartLocation)), Roles.LPar); if (u.Variables != null) { var initializer = new VariableInitializer () { NameToken = Identifier.Create (u.Variables.Variable.Name, Convert (u.Variables.Variable.Location)), @@ -1695,12 +1706,12 @@ namespace ICSharpCode.NRefactory.CSharp var loc = LocationsBag.GetLocations (u.Variables); if (loc != null) - initializer.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), VariableInitializer.Roles.Assign); + initializer.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.Assign); if (u.Variables.Initializer != null) initializer.Initializer = u.Variables.Initializer.Accept (this) as Expression; - var varDec = new VariableDeclarationStatement () { + var varDec = new VariableDeclarationStatement () { Type = ConvertToType (u.Variables.TypeExpression), Variables = { initializer } }; @@ -1710,22 +1721,22 @@ namespace ICSharpCode.NRefactory.CSharp var declLoc = LocationsBag.GetLocations (decl); var init = new VariableInitializer (); if (declLoc != null && declLoc.Count > 0) - varDec.AddChild (new CSharpTokenNode (Convert (declLoc [0]), 1), VariableInitializer.Roles.Comma); - init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); + varDec.AddChild (new CSharpTokenNode (Convert (declLoc [0])), Roles.Comma); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), Roles.Identifier); if (decl.Initializer != null) { if (declLoc != null && declLoc.Count > 1) - init.AddChild (new CSharpTokenNode (Convert (declLoc [1]), 1), VariableInitializer.Roles.Assign); - init.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); + init.AddChild (new CSharpTokenNode (Convert (declLoc [1])), Roles.Assign); + init.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression); } - varDec.AddChild (init, UsingStatement.Roles.Variable); + varDec.AddChild (init, Roles.Variable); } } usingResult.AddChild (varDec, UsingStatement.ResourceAcquisitionRole); } cur = u.Statement; - usingResult.AddChild (new CSharpTokenNode (Convert (blockStatement.EndLocation), 1), UsingStatement.Roles.RPar); + usingResult.AddChild (new CSharpTokenNode (Convert (blockStatement.EndLocation)), Roles.RPar); if (cur != null) - usingResult.AddChild ((Statement)cur.Accept (this), UsingStatement.Roles.EmbeddedStatement); + usingResult.AddChild ((Statement)cur.Accept (this), Roles.EmbeddedStatement); } return usingResult; } @@ -1739,7 +1750,7 @@ namespace ICSharpCode.NRefactory.CSharp if (stmt == null) continue; /* if (curLocal < localVariables.Count && IsLower (localVariables[curLocal].Location, stmt.loc)) { - result.AddChild (CreateVariableDeclaration (localVariables[curLocal]), AstNode.Roles.Statement); + result.AddChild (CreateVariableDeclaration (localVariables[curLocal]), Roles.Statement); curLocal++; }*/ if (stmt is Block && !(stmt is ToplevelBlock || stmt is ExplicitBlock)) { @@ -1758,11 +1769,11 @@ namespace ICSharpCode.NRefactory.CSharp return blockStatement.Statements.Last ().Accept (this); } var result = new BlockStatement (); - result.AddChild (new CSharpTokenNode (Convert (blockStatement.StartLocation), 1), AstNode.Roles.LBrace); + result.AddChild (new CSharpTokenNode (Convert (blockStatement.StartLocation)), Roles.LBrace); int curLocal = 0; AddBlockChildren (result, blockStatement, ref curLocal); - result.AddChild (new CSharpTokenNode (Convert (blockStatement.EndLocation), 1), AstNode.Roles.RBrace); + result.AddChild (new CSharpTokenNode (Convert (blockStatement.EndLocation)), Roles.RBrace); return result; } @@ -1771,15 +1782,15 @@ namespace ICSharpCode.NRefactory.CSharp var result = new SwitchStatement (); var location = LocationsBag.GetLocations (switchStatement); - result.AddChild (new CSharpTokenNode (Convert (switchStatement.loc), "switch".Length), SwitchStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (switchStatement.loc)), SwitchStatement.SwitchKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), SwitchStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (switchStatement.Expr != null) - result.AddChild ((Expression)switchStatement.Expr.Accept (this), SwitchStatement.Roles.Expression); + result.AddChild ((Expression)switchStatement.Expr.Accept (this), Roles.Expression); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), SwitchStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); if (location != null && location.Count > 2) - result.AddChild (new CSharpTokenNode (Convert (location [2]), 1), SwitchStatement.Roles.LBrace); + result.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.LBrace); if (switchStatement.Sections != null) { foreach (var section in switchStatement.Sections) { var newSection = new SwitchSection (); @@ -1787,15 +1798,15 @@ namespace ICSharpCode.NRefactory.CSharp foreach (var caseLabel in section.Labels) { var newLabel = new CaseLabel (); if (caseLabel.Label != null) { - newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location), "case".Length), SwitchStatement.Roles.Keyword); + newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location)), CaseLabel.CaseKeywordRole); if (caseLabel.Label != null) - newLabel.AddChild ((Expression)caseLabel.Label.Accept (this), SwitchStatement.Roles.Expression); + newLabel.AddChild ((Expression)caseLabel.Label.Accept (this), Roles.Expression); var colonLocation = LocationsBag.GetLocations (caseLabel); if (colonLocation != null) - newLabel.AddChild (new CSharpTokenNode (Convert (colonLocation [0]), 1), SwitchStatement.Roles.Colon); + newLabel.AddChild (new CSharpTokenNode (Convert (colonLocation [0])), Roles.Colon); } else { - newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location), "default".Length), SwitchStatement.Roles.Keyword); - newLabel.AddChild (new CSharpTokenNode (new TextLocation (caseLabel.Location.Row, caseLabel.Location.Column + "default".Length), 1), SwitchStatement.Roles.Colon); + newLabel.AddChild (new CSharpTokenNode (Convert (caseLabel.Location)), CaseLabel.DefaultKeywordRole); + newLabel.AddChild (new CSharpTokenNode (new TextLocation (caseLabel.Location.Row, caseLabel.Location.Column + "default".Length)), Roles.Colon); } newSection.AddChild (newLabel, SwitchSection.CaseLabelRole); } @@ -1807,7 +1818,7 @@ namespace ICSharpCode.NRefactory.CSharp AddBlockChildren (bodyBlock, blockStatement, ref curLocal); foreach (var statement in bodyBlock.Statements) { statement.Remove (); - newSection.AddChild (statement, SwitchSection.Roles.EmbeddedStatement); + newSection.AddChild (statement, Roles.EmbeddedStatement); } result.AddChild (newSection, SwitchStatement.SwitchSectionRole); @@ -1815,10 +1826,10 @@ namespace ICSharpCode.NRefactory.CSharp } if (location != null && location.Count > 3) { - result.AddChild (new CSharpTokenNode (Convert (location [3]), 1), SwitchStatement.Roles.RBrace); + result.AddChild (new CSharpTokenNode (Convert (location [3])), Roles.RBrace); } else { // parser error, set end node to max value. - result.AddChild (new ErrorNode (), AstNode.Roles.Error); + result.AddChild (new ErrorNode (), Roles.Error); } return result; @@ -1828,17 +1839,17 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new LockStatement (); var location = LocationsBag.GetLocations (lockStatement); - result.AddChild (new CSharpTokenNode (Convert (lockStatement.loc), "lock".Length), LockStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (lockStatement.loc)), LockStatement.LockKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), LockStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (lockStatement.Expr != null) - result.AddChild ((Expression)lockStatement.Expr.Accept (this), LockStatement.Roles.Expression); + result.AddChild ((Expression)lockStatement.Expr.Accept (this), Roles.Expression); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), LockStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); if (lockStatement.Statement != null) - result.AddChild ((Statement)lockStatement.Statement.Accept (this), LockStatement.Roles.EmbeddedStatement); + result.AddChild ((Statement)lockStatement.Statement.Accept (this), Roles.EmbeddedStatement); return result; } @@ -1846,28 +1857,27 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (Unchecked uncheckedStatement) { var result = new UncheckedStatement (); - result.AddChild (new CSharpTokenNode (Convert (uncheckedStatement.loc), "unchecked".Length), UncheckedStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (uncheckedStatement.loc)), UncheckedStatement.UncheckedKeywordRole); if (uncheckedStatement.Block != null) - result.AddChild ((BlockStatement)uncheckedStatement.Block.Accept (this), UncheckedStatement.Roles.Body); + result.AddChild ((BlockStatement)uncheckedStatement.Block.Accept (this), Roles.Body); return result; } - public override object Visit (Checked checkedStatement) { var result = new CheckedStatement (); - result.AddChild (new CSharpTokenNode (Convert (checkedStatement.loc), "checked".Length), CheckedStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (checkedStatement.loc)), CheckedStatement.CheckedKeywordRole); if (checkedStatement.Block != null) - result.AddChild ((BlockStatement)checkedStatement.Block.Accept (this), CheckedStatement.Roles.Body); + result.AddChild ((BlockStatement)checkedStatement.Block.Accept (this), Roles.Body); return result; } public override object Visit (Unsafe unsafeStatement) { var result = new UnsafeStatement (); - result.AddChild (new CSharpTokenNode (Convert (unsafeStatement.loc), "unsafe".Length), UnsafeStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (unsafeStatement.loc)), UnsafeStatement.UnsafeKeywordRole); if (unsafeStatement.Block != null) - result.AddChild ((BlockStatement)unsafeStatement.Block.Accept (this), UnsafeStatement.Roles.Body); + result.AddChild ((BlockStatement)unsafeStatement.Block.Accept (this), Roles.Body); return result; } @@ -1876,46 +1886,46 @@ namespace ICSharpCode.NRefactory.CSharp var result = new FixedStatement (); var location = LocationsBag.GetLocations (fixedStatement); - result.AddChild (new CSharpTokenNode (Convert (fixedStatement.loc), "fixed".Length), FixedStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (fixedStatement.loc)), FixedStatement.FixedKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FixedStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (fixedStatement.Variables != null) { var blockVariableDeclaration = fixedStatement.Variables; - result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), FixedStatement.Roles.Type); + result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), Roles.Type); var varInit = new VariableInitializer (); var initLocation = LocationsBag.GetLocations (blockVariableDeclaration); - varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), VariableInitializer.Roles.Identifier); + varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (initLocation != null) - varInit.AddChild (new CSharpTokenNode (Convert (location[0]), 1), VariableInitializer.Roles.Assign); - varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), VariableInitializer.Roles.Expression); + varInit.AddChild (new CSharpTokenNode (Convert (initLocation [0])), Roles.Assign); + varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), Roles.Expression); } - result.AddChild (varInit, FixedStatement.Roles.Variable); + result.AddChild (varInit, Roles.Variable); if (blockVariableDeclaration.Declarators != null) { foreach (var decl in blockVariableDeclaration.Declarators) { var loc = LocationsBag.GetLocations (decl); var init = new VariableInitializer (); if (loc != null && loc.Count > 0) - result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), VariableInitializer.Roles.Comma); - init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), VariableInitializer.Roles.Identifier); + result.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.Comma); + init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), Roles.Identifier); if (decl.Initializer != null) { if (loc != null && loc.Count > 1) - init.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), VariableInitializer.Roles.Assign); - init.AddChild ((Expression)decl.Initializer.Accept (this), VariableInitializer.Roles.Expression); + init.AddChild (new CSharpTokenNode (Convert (loc [1])), Roles.Assign); + init.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression); } else { } - result.AddChild (init, FixedStatement.Roles.Variable); + result.AddChild (init, Roles.Variable); } } } if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FixedStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); if (fixedStatement.Statement != null) - result.AddChild ((Statement)fixedStatement.Statement.Accept (this), FixedStatement.Roles.EmbeddedStatement); + result.AddChild ((Statement)fixedStatement.Statement.Accept (this), Roles.EmbeddedStatement); return result; } @@ -1928,12 +1938,12 @@ namespace ICSharpCode.NRefactory.CSharp result = (TryCatchStatement)tryFinallyStatement.Stmt.Accept (this); } else { result = new TryCatchStatement (); - result.AddChild (new CSharpTokenNode (Convert (tryFinallyStatement.loc), "try".Length), TryCatchStatement.TryKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (tryFinallyStatement.loc)), TryCatchStatement.TryKeywordRole); if (tryFinallyStatement.Stmt != null) 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])), TryCatchStatement.FinallyKeywordRole); if (tryFinallyStatement.Fini != null) result.AddChild ((BlockStatement)tryFinallyStatement.Fini.Accept (this), TryCatchStatement.FinallyBlockRole); @@ -1944,22 +1954,22 @@ namespace ICSharpCode.NRefactory.CSharp { CatchClause result = new CatchClause (); var location = LocationsBag.GetLocations (ctch); - result.AddChild (new CSharpTokenNode (Convert (ctch.loc), "catch".Length), CatchClause.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (ctch.loc)), CatchClause.CatchKeywordRole); 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])), Roles.LPar); if (ctch.TypeExpression != null) - result.AddChild (ConvertToType (ctch.TypeExpression), CatchClause.Roles.Type); + result.AddChild (ConvertToType (ctch.TypeExpression), Roles.Type); if (ctch.Variable != null && !string.IsNullOrEmpty (ctch.Variable.Name)) - result.AddChild (Identifier.Create (ctch.Variable.Name, Convert (ctch.Variable.Location)), CatchClause.Roles.Identifier); + result.AddChild (Identifier.Create (ctch.Variable.Name, Convert (ctch.Variable.Location)), Roles.Identifier); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CatchClause.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); } if (ctch.Block != null) - result.AddChild ((BlockStatement)ctch.Block.Accept (this), CatchClause.Roles.Body); + result.AddChild ((BlockStatement)ctch.Block.Accept (this), Roles.Body); return result; } @@ -1967,7 +1977,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (TryCatch tryCatchStatement) { var result = new TryCatchStatement (); - result.AddChild (new CSharpTokenNode (Convert (tryCatchStatement.loc), "try".Length), TryCatchStatement.TryKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (tryCatchStatement.loc)), TryCatchStatement.TryKeywordRole); if (tryCatchStatement.Block != null) result.AddChild ((BlockStatement)tryCatchStatement.Block.Accept (this), TryCatchStatement.TryBlockRole); if (tryCatchStatement.Clauses != null) { @@ -1986,17 +1996,17 @@ namespace ICSharpCode.NRefactory.CSharp var result = new UsingStatement (); var location = LocationsBag.GetLocations (usingStatement); - result.AddChild (new CSharpTokenNode (Convert (usingStatement.loc), "using".Length), UsingStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (usingStatement.loc)), UsingStatement.UsingKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), UsingStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (usingStatement.Expr != null) result.AddChild ((AstNode)usingStatement.Expr.Accept (this), UsingStatement.ResourceAcquisitionRole); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), 1), UsingStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); if (usingStatement.Statement != null) - result.AddChild ((Statement)usingStatement.Statement.Accept (this), UsingStatement.Roles.EmbeddedStatement); + result.AddChild ((Statement)usingStatement.Statement.Accept (this), Roles.EmbeddedStatement); return result; } @@ -2006,27 +2016,27 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (foreachStatement); - result.AddChild (new CSharpTokenNode (Convert (foreachStatement.loc), "foreach".Length), ForeachStatement.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (foreachStatement.loc)), ForeachStatement.ForeachKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [0]), 1), ForeachStatement.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (foreachStatement.TypeExpression != null) - result.AddChild (ConvertToType (foreachStatement.TypeExpression), ForeachStatement.Roles.Type); + result.AddChild (ConvertToType (foreachStatement.TypeExpression), Roles.Type); if (foreachStatement.Variable != null) - result.AddChild (Identifier.Create (foreachStatement.Variable.Name, Convert (foreachStatement.Variable.Location)), ForeachStatement.Roles.Identifier); + result.AddChild (Identifier.Create (foreachStatement.Variable.Name, Convert (foreachStatement.Variable.Location)), Roles.Identifier); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location [1]), "in".Length), ForeachStatement.Roles.InKeyword); + result.AddChild (new CSharpTokenNode (Convert (location [1])), ForeachStatement.InKeywordRole); if (foreachStatement.Expr != null) - result.AddChild ((Expression)foreachStatement.Expr.Accept (this), ForeachStatement.Roles.Expression); + result.AddChild ((Expression)foreachStatement.Expr.Accept (this), Roles.Expression); if (location != null && location.Count > 2) - result.AddChild (new CSharpTokenNode (Convert (location [2]), 1), ForeachStatement.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [2])), Roles.RPar); if (foreachStatement.Statement != null) - result.AddChild ((Statement)foreachStatement.Statement.Accept (this), ForeachStatement.Roles.EmbeddedStatement); + result.AddChild ((Statement)foreachStatement.Statement.Accept (this), Roles.EmbeddedStatement); return result; } @@ -2036,13 +2046,13 @@ namespace ICSharpCode.NRefactory.CSharp var result = new YieldReturnStatement (); var location = LocationsBag.GetLocations (yieldStatement); - result.AddChild (new CSharpTokenNode (Convert (yieldStatement.loc), "yield".Length), YieldReturnStatement.YieldKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (yieldStatement.loc)), YieldReturnStatement.YieldKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "return".Length), YieldReturnStatement.ReturnKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [0])), YieldReturnStatement.ReturnKeywordRole); if (yieldStatement.Expr != null) - result.AddChild ((Expression)yieldStatement.Expr.Accept (this), YieldReturnStatement.Roles.Expression); + result.AddChild ((Expression)yieldStatement.Expr.Accept (this), Roles.Expression); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), ";".Length), YieldReturnStatement.Roles.Semicolon); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); return result; } @@ -2051,10 +2061,11 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new YieldBreakStatement (); var location = LocationsBag.GetLocations (yieldBreakStatement); - result.AddChild (new CSharpTokenNode (Convert (yieldBreakStatement.loc), "yield".Length), YieldBreakStatement.YieldKeywordRole); - if (location != null && location.Count > 1) { - 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 (yieldBreakStatement.loc)), YieldBreakStatement.YieldKeywordRole); + if (location != null) { + result.AddChild (new CSharpTokenNode (Convert (location [0])), YieldBreakStatement.BreakKeywordRole); + if (location.Count > 1) + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); } return result; } @@ -2080,7 +2091,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (LocalVariableReference localVariableReference) { - return Identifier.Create (localVariableReference.Name, Convert (localVariableReference.Location));; + return Identifier.Create (localVariableReference.Name, Convert (localVariableReference.Location)); } public override object Visit (MemberAccess memberAccess) @@ -2089,20 +2100,20 @@ namespace ICSharpCode.NRefactory.CSharp if (memberAccess.LeftExpression is Indirection) { var ind = memberAccess.LeftExpression as Indirection; result = new PointerReferenceExpression (); - result.AddChild ((Expression)ind.Expr.Accept (this), PointerReferenceExpression.Roles.TargetExpression); - result.AddChild (new CSharpTokenNode (Convert (ind.Location), "->".Length), PointerReferenceExpression.ArrowRole); + result.AddChild ((Expression)ind.Expr.Accept (this), Roles.TargetExpression); + result.AddChild (new CSharpTokenNode (Convert (ind.Location)), PointerReferenceExpression.ArrowRole); } else { result = new MemberReferenceExpression (); if (memberAccess.LeftExpression != null) { var leftExpr = memberAccess.LeftExpression.Accept (this); - result.AddChild ((Expression)leftExpr, MemberReferenceExpression.Roles.TargetExpression); + result.AddChild ((Expression)leftExpr, Roles.TargetExpression); } if (!memberAccess.DotLocation.IsNull) { - result.AddChild (new CSharpTokenNode (Convert (memberAccess.DotLocation), 1), MemberReferenceExpression.Roles.Dot); + result.AddChild (new CSharpTokenNode (Convert (memberAccess.DotLocation)), Roles.Dot); } } - result.AddChild (Identifier.Create (memberAccess.Name, Convert (memberAccess.Location)), MemberReferenceExpression.Roles.Identifier); + result.AddChild (Identifier.Create (memberAccess.Name, Convert (memberAccess.Location)), Roles.Identifier); AddTypeArguments (result, memberAccess); return result; @@ -2114,7 +2125,7 @@ namespace ICSharpCode.NRefactory.CSharp result.Target = new SimpleType (qualifiedAliasMember.alias, Convert (qualifiedAliasMember.Location)); result.IsDoubleColon = true; var location = LocationsBag.GetLocations (qualifiedAliasMember); - result.AddChild (Identifier.Create (qualifiedAliasMember.Name, location != null ? Convert (location[0]) : TextLocation.Empty), MemberReferenceExpression.Roles.Identifier); + result.AddChild (Identifier.Create (qualifiedAliasMember.Name, location != null ? Convert (location [0]) : TextLocation.Empty), Roles.Identifier); return new TypeReferenceExpression () { Type = result }; } @@ -2138,7 +2149,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (SimpleName simpleName) { var result = new IdentifierExpression (); - result.AddChild (Identifier.Create (simpleName.Name, Convert (simpleName.Location)), IdentifierExpression.Roles.Identifier); + result.AddChild (Identifier.Create (simpleName.Name, Convert (simpleName.Location)), Roles.Identifier); AddTypeArguments (result, simpleName); return result; } @@ -2147,18 +2158,17 @@ namespace ICSharpCode.NRefactory.CSharp { 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])), Roles.LPar); if (parenthesizedExpression.Expr != null) - result.AddChild ((Expression)parenthesizedExpression.Expr.Accept (this), ParenthesizedExpression.Roles.Expression); + result.AddChild ((Expression)parenthesizedExpression.Expr.Accept (this), Roles.Expression); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ParenthesizedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } @@ -2166,25 +2176,25 @@ namespace ICSharpCode.NRefactory.CSharp { 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; - } - result.AddChild (new CSharpTokenNode (Convert (unaryExpression.Location), 1), UnaryOperatorExpression.OperatorRole); + 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)), UnaryOperatorExpression.GetOperatorRole (result.Operator)); if (unaryExpression.Expr != null) - result.AddChild ((Expression)unaryExpression.Expr.Accept (this), UnaryOperatorExpression.Roles.Expression); + result.AddChild ((Expression)unaryExpression.Expr.Accept (this), Roles.Expression); return result; } @@ -2195,27 +2205,27 @@ namespace ICSharpCode.NRefactory.CSharp return result; 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, Roles.Expression); + result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location)), UnaryOperatorExpression.DecrementRole); + break; + case UnaryMutator.Mode.PostIncrement: + result.Operator = UnaryOperatorType.PostIncrement; + result.AddChild (expression, Roles.Expression); + result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location)), UnaryOperatorExpression.IncrementRole); + 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)), UnaryOperatorExpression.IncrementRole); + result.AddChild (expression, Roles.Expression); + break; + case UnaryMutator.Mode.PreDecrement: + result.Operator = UnaryOperatorType.Decrement; + result.AddChild (new CSharpTokenNode (Convert (unaryMutatorExpression.Location)), UnaryOperatorExpression.DecrementRole); + result.AddChild (expression, Roles.Expression); + break; } return result; @@ -2225,11 +2235,9 @@ namespace ICSharpCode.NRefactory.CSharp { 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 (indirectionExpression.Location)), UnaryOperatorExpression.DereferenceRole); if (indirectionExpression.Expr != null) - result.AddChild ((Expression)indirectionExpression.Expr.Accept (this), UnaryOperatorExpression.Roles.Expression); + result.AddChild ((Expression)indirectionExpression.Expr.Accept (this), Roles.Expression); return result; } @@ -2237,11 +2245,11 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new IsExpression (); if (isExpression.Expr != null) - result.AddChild ((Expression)isExpression.Expr.Accept (this), IsExpression.Roles.Expression); - result.AddChild (new CSharpTokenNode (Convert (isExpression.Location), "is".Length), IsExpression.Roles.Keyword); + result.AddChild ((Expression)isExpression.Expr.Accept (this), Roles.Expression); + result.AddChild (new CSharpTokenNode (Convert (isExpression.Location)), IsExpression.IsKeywordRole); if (isExpression.ProbeType != null) - result.AddChild (ConvertToType (isExpression.ProbeType), IsExpression.Roles.Type); + result.AddChild (ConvertToType (isExpression.ProbeType), Roles.Type); return result; } @@ -2249,10 +2257,10 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new AsExpression (); if (asExpression.Expr != null) - result.AddChild ((Expression)asExpression.Expr.Accept (this), AsExpression.Roles.Expression); - result.AddChild (new CSharpTokenNode (Convert (asExpression.Location), "as".Length), AsExpression.Roles.Keyword); + result.AddChild ((Expression)asExpression.Expr.Accept (this), Roles.Expression); + result.AddChild (new CSharpTokenNode (Convert (asExpression.Location)), AsExpression.AsKeywordRole); if (asExpression.ProbeType != null) - result.AddChild (ConvertToType (asExpression.ProbeType), AsExpression.Roles.Type); + result.AddChild (ConvertToType (asExpression.ProbeType), Roles.Type); return result; } @@ -2261,33 +2269,33 @@ namespace ICSharpCode.NRefactory.CSharp var result = new CastExpression (); var location = LocationsBag.GetLocations (castExpression); - result.AddChild (new CSharpTokenNode (Convert (castExpression.Location), 1), CastExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (castExpression.Location)), Roles.LPar); if (castExpression.TargetType != null) - result.AddChild (ConvertToType (castExpression.TargetType), CastExpression.Roles.Type); + result.AddChild (ConvertToType (castExpression.TargetType), Roles.Type); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), CastExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.RPar); if (castExpression.Expr != null) - result.AddChild ((Expression)castExpression.Expr.Accept (this), CastExpression.Roles.Expression); + result.AddChild ((Expression)castExpression.Expr.Accept (this), Roles.Expression); return result; } public override object Visit (ComposedCast composedCast) { var result = new ComposedType (); - result.AddChild (ConvertToType (composedCast.Left), ComposedType.Roles.Type); + result.AddChild (ConvertToType (composedCast.Left), Roles.Type); var spec = composedCast.Spec; while (spec != null) { if (spec.IsNullable) { - result.AddChild (new CSharpTokenNode (Convert (spec.Location), 1), ComposedType.NullableRole); + result.AddChild (new CSharpTokenNode (Convert (spec.Location)), ComposedType.NullableRole); } else if (spec.IsPointer) { - result.AddChild (new CSharpTokenNode (Convert (spec.Location), 1), ComposedType.PointerRole); + result.AddChild (new CSharpTokenNode (Convert (spec.Location)), ComposedType.PointerRole); } else { var aSpec = new ArraySpecifier (); - aSpec.AddChild (new CSharpTokenNode (Convert (spec.Location), 1), ComposedType.Roles.LBracket); + aSpec.AddChild (new CSharpTokenNode (Convert (spec.Location)), Roles.LBracket); var location = LocationsBag.GetLocations (spec); if (location != null) - aSpec.AddChild (new CSharpTokenNode (Convert (spec.Location), 1), ComposedType.Roles.RBracket); + aSpec.AddChild (new CSharpTokenNode (Convert (spec.Location)), Roles.RBracket); result.AddChild (aSpec, ComposedType.ArraySpecifierRole); } spec = spec.Next; @@ -2299,88 +2307,79 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (Mono.CSharp.DefaultValueExpression defaultValueExpression) { var result = new DefaultValueExpression (); - result.AddChild (new CSharpTokenNode (Convert (defaultValueExpression.Location), "default".Length), CastExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (defaultValueExpression.Location)), DefaultValueExpression.DefaultKeywordRole); var location = LocationsBag.GetLocations (defaultValueExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), CastExpression.Roles.LPar); - result.AddChild (ConvertToType (defaultValueExpression.Expr), CastExpression.Roles.Type); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); + result.AddChild (ConvertToType (defaultValueExpression.Expr), Roles.Type); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CastExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), 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; + break; + case Binary.Operator.RightShift: + result.Operator = BinaryOperatorType.ShiftRight; + 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; + break; + case Binary.Operator.GreaterThanOrEqual: + result.Operator = BinaryOperatorType.GreaterThanOrEqual; + break; + case Binary.Operator.Equality: + result.Operator = BinaryOperatorType.Equality; + break; + case Binary.Operator.Inequality: + result.Operator = BinaryOperatorType.InEquality; + 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; + break; + case Binary.Operator.LogicalOr: + result.Operator = BinaryOperatorType.ConditionalOr; + break; } if (binaryExpression.Left != null) result.AddChild ((Expression)binaryExpression.Left.Accept (this), BinaryOperatorExpression.LeftRole); - result.AddChild (new CSharpTokenNode (Convert (binaryExpression.Location), opLength), BinaryOperatorExpression.OperatorRole); + result.AddChild (new CSharpTokenNode (Convert (binaryExpression.Location)), BinaryOperatorExpression.GetOperatorRole (result.Operator)); if (binaryExpression.Right != null) result.AddChild ((Expression)binaryExpression.Right.Accept (this), BinaryOperatorExpression.RightRole); return result; @@ -2392,7 +2391,7 @@ namespace ICSharpCode.NRefactory.CSharp result.Operator = BinaryOperatorType.NullCoalescing; if (nullCoalescingOperator.LeftExpression != null) result.AddChild ((Expression)nullCoalescingOperator.LeftExpression.Accept (this), BinaryOperatorExpression.LeftRole); - result.AddChild (new CSharpTokenNode (Convert (nullCoalescingOperator.Location), 2), BinaryOperatorExpression.OperatorRole); + result.AddChild (new CSharpTokenNode (Convert (nullCoalescingOperator.Location)), BinaryOperatorExpression.NullCoalescingRole); if (nullCoalescingOperator.RightExpression != null) result.AddChild ((Expression)nullCoalescingOperator.RightExpression.Accept (this), BinaryOperatorExpression.RightRole); return result; @@ -2403,14 +2402,14 @@ namespace ICSharpCode.NRefactory.CSharp var result = new ConditionalExpression (); if (conditionalExpression.Expr != null) - result.AddChild ((Expression)conditionalExpression.Expr.Accept (this), ConditionalExpression.Roles.Condition); + result.AddChild ((Expression)conditionalExpression.Expr.Accept (this), Roles.Condition); var location = LocationsBag.GetLocations (conditionalExpression); - result.AddChild (new CSharpTokenNode (Convert (conditionalExpression.Location), 1), ConditionalExpression.QuestionMarkRole); + result.AddChild (new CSharpTokenNode (Convert (conditionalExpression.Location)), ConditionalExpression.QuestionMarkRole); if (conditionalExpression.TrueExpr != null) 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])), ConditionalExpression.ColonRole); if (conditionalExpression.FalseExpr != null) result.AddChild ((Expression)conditionalExpression.FalseExpr.Accept (this), ConditionalExpression.FalseRole); return result; @@ -2433,39 +2432,39 @@ namespace ICSharpCode.NRefactory.CSharp case Parameter.Modifier.OUT: parameterDeclarationExpression.ParameterModifier = ParameterModifier.Out; if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "out".Length), ParameterDeclaration.Roles.Keyword); + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0])), ParameterDeclaration.OutModifierRole); break; case Parameter.Modifier.REF: parameterDeclarationExpression.ParameterModifier = ParameterModifier.Ref; if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "ref".Length), ParameterDeclaration.Roles.Keyword); + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0])), ParameterDeclaration.RefModifierRole); break; case Parameter.Modifier.PARAMS: parameterDeclarationExpression.ParameterModifier = ParameterModifier.Params; if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "params".Length), ParameterDeclaration.Roles.Keyword); + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0])), ParameterDeclaration.ParamsModifierRole); break; default: if (p.HasExtensionMethodModifier) { parameterDeclarationExpression.ParameterModifier = ParameterModifier.This; if (location != null) { - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "this".Length), ParameterDeclaration.Roles.Keyword); + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0])), ParameterDeclaration.ThisModifierRole); } } break; } if (p.TypeExpression != null) // lambdas may have no types (a, b) => ... - parameterDeclarationExpression.AddChild (ConvertToType (p.TypeExpression), ParameterDeclaration.Roles.Type); + parameterDeclarationExpression.AddChild (ConvertToType (p.TypeExpression), Roles.Type); if (p.Name != null) - parameterDeclarationExpression.AddChild (Identifier.Create (p.Name, Convert (p.Location)), ParameterDeclaration.Roles.Identifier); + parameterDeclarationExpression.AddChild (Identifier.Create (p.Name, Convert (p.Location)), Roles.Identifier); if (p.HasDefaultValue) { - if (location != null) - parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [1]), 1), ParameterDeclaration.Roles.Assign); - parameterDeclarationExpression.AddChild ((Expression)p.DefaultValue.Accept (this), ParameterDeclaration.Roles.Expression); + if (location != null && location.Count > 1) + parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Assign); + parameterDeclarationExpression.AddChild ((Expression)p.DefaultValue.Accept (this), Roles.Expression); } - parent.AddChild (parameterDeclarationExpression, InvocationExpression.Roles.Parameter); + parent.AddChild (parameterDeclarationExpression, Roles.Parameter); if (paramLocation != null && i < paramLocation.Count) { - parent.AddChild (new CSharpTokenNode (Convert (paramLocation [i]), 1), ParameterDeclaration.Roles.Comma); + parent.AddChild (new CSharpTokenNode (Convert (paramLocation [i])), Roles.Comma); } } } @@ -2476,14 +2475,14 @@ namespace ICSharpCode.NRefactory.CSharp return; var chevronLocs = LocationsBag.GetLocations (memberName.TypeParameters); if (chevronLocs != null) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 2]), 1), InvocationExpression.Roles.LChevron); + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [chevronLocs.Count - 2])), Roles.LChevron); for (int i = 0; i < memberName.TypeParameters.Count; i++) { if (chevronLocs != null && i > 0 && i - 1 < chevronLocs.Count) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[i - 1]), 1), InvocationExpression.Roles.Comma); - var arg = memberName.TypeParameters[i]; + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [i - 1])), Roles.Comma); + var arg = memberName.TypeParameters [i]; if (arg == null) continue; - TypeParameterDeclaration tp = new TypeParameterDeclaration(); + TypeParameterDeclaration tp = new TypeParameterDeclaration (); List varianceLocation; switch (arg.Variance) { @@ -2491,13 +2490,13 @@ namespace ICSharpCode.NRefactory.CSharp tp.Variance = VarianceModifier.Contravariant; varianceLocation = LocationsBag.GetLocations (arg); if (varianceLocation != null) - tp.AddChild (new CSharpTokenNode (Convert (varianceLocation[0]), "out".Length), TypeParameterDeclaration.VarianceRole); + tp.AddChild (new CSharpTokenNode (Convert (varianceLocation [0])), TypeParameterDeclaration.InVarianceKeywordRole); break; case Variance.Covariant: tp.Variance = VarianceModifier.Covariant; varianceLocation = LocationsBag.GetLocations (arg); if (varianceLocation != null) - tp.AddChild (new CSharpTokenNode (Convert (varianceLocation[0]), "out".Length), TypeParameterDeclaration.VarianceRole); + tp.AddChild (new CSharpTokenNode (Convert (varianceLocation [0])), TypeParameterDeclaration.OutVarianceKeywordRole); break; default: tp.Variance = VarianceModifier.Invariant; @@ -2508,18 +2507,18 @@ namespace ICSharpCode.NRefactory.CSharp AddAttributeSection (tp, arg.OptAttributes); switch (arg.Variance) { - case Variance.Covariant: - tp.Variance = VarianceModifier.Covariant; - break; - case Variance.Contravariant: - tp.Variance = VarianceModifier.Contravariant; - break; + case Variance.Covariant: + tp.Variance = VarianceModifier.Covariant; + break; + case Variance.Contravariant: + tp.Variance = VarianceModifier.Contravariant; + break; } - tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier); - parent.AddChild (tp, InvocationExpression.Roles.TypeParameter); + tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), Roles.Identifier); + parent.AddChild (tp, Roles.TypeParameter); } if (chevronLocs != null) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron); + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [chevronLocs.Count - 1])), Roles.RChevron); } void AddTypeArguments (AstNode parent, MemberName memberName) @@ -2528,19 +2527,19 @@ namespace ICSharpCode.NRefactory.CSharp return; var chevronLocs = LocationsBag.GetLocations (memberName.TypeParameters); if (chevronLocs != null) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 2]), 1), InvocationExpression.Roles.LChevron); + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [chevronLocs.Count - 2])), Roles.LChevron); for (int i = 0; i < memberName.TypeParameters.Count; i++) { - var arg = memberName.TypeParameters[i]; + var arg = memberName.TypeParameters [i]; if (arg == null) continue; - parent.AddChild (ConvertToType (arg), InvocationExpression.Roles.TypeArgument); + parent.AddChild (ConvertToType (arg), Roles.TypeArgument); if (chevronLocs != null && i < chevronLocs.Count - 2) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[i]), 1), InvocationExpression.Roles.Comma); + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [i])), Roles.Comma); } if (chevronLocs != null) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron); + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [chevronLocs.Count - 1])), Roles.RChevron); } void AddTypeArguments (AstNode parent, ATypeNameExpression memberName) @@ -2549,27 +2548,27 @@ namespace ICSharpCode.NRefactory.CSharp return; var chevronLocs = LocationsBag.GetLocations (memberName.TypeArguments); if (chevronLocs != null) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 2]), 1), InvocationExpression.Roles.LChevron); + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [chevronLocs.Count - 2])), Roles.LChevron); for (int i = 0; i < memberName.TypeArguments.Count; i++) { - var arg = memberName.TypeArguments.Args[i]; + var arg = memberName.TypeArguments.Args [i]; if (arg == null) continue; - parent.AddChild (ConvertToType (arg), InvocationExpression.Roles.TypeArgument); + parent.AddChild (ConvertToType (arg), Roles.TypeArgument); if (chevronLocs != null && i < chevronLocs.Count - 2) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[i]), 1), InvocationExpression.Roles.Comma); + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [i])), Roles.Comma); } if (chevronLocs != null) - parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron); + parent.AddChild (new CSharpTokenNode (Convert (chevronLocs [chevronLocs.Count - 1])), Roles.RChevron); } - void AddConstraints (AstNode parent, TypeParameters d) + void AddConstraints(AstNode parent, TypeParameters d) { if (d == null) return; for (int i = d.Count - 1; i >= 0; i--) { - var typeParameter = d[i]; + var typeParameter = d [i]; if (typeParameter == null) continue; var c = typeParameter.Constraints; @@ -2577,18 +2576,21 @@ namespace ICSharpCode.NRefactory.CSharp continue; var location = LocationsBag.GetLocations (c); var constraint = new Constraint (); - constraint.AddChild (new CSharpTokenNode (Convert (c.Location), "where".Length), InvocationExpression.Roles.Keyword); - constraint.AddChild (new SimpleType (Identifier.Create (c.TypeParameter.Value, Convert (c.TypeParameter.Location))), Constraint.TypeParameterRole); + constraint.AddChild (new CSharpTokenNode (Convert (c.Location)), Roles.WhereKeyword); + constraint.AddChild (new SimpleType (Identifier.Create (c.TypeParameter.Value, Convert (c.TypeParameter.Location))), Roles.ConstraintTypeParameter); if (location != null) - constraint.AddChild (new CSharpTokenNode (Convert (location [0]), 1), Constraint.ColonRole); + constraint.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Colon); var commaLocs = LocationsBag.GetLocations (c.ConstraintExpressions); int curComma = 0; - foreach (var expr in c.ConstraintExpressions) { - constraint.AddChild (ConvertToType (expr), Constraint.BaseTypeRole); - if (commaLocs != null && curComma < commaLocs.Count) - constraint.AddChild (new CSharpTokenNode (Convert (commaLocs[curComma++]), 1), InvocationExpression.Roles.Comma); + if (c.ConstraintExpressions != null) { + foreach (var expr in c.ConstraintExpressions) { + constraint.AddChild (ConvertToType (expr), Roles.BaseType); + if (commaLocs != null && curComma < commaLocs.Count) + constraint.AddChild (new CSharpTokenNode (Convert (commaLocs [curComma++])), Roles.Comma); + } } - parent.AddChild (constraint, AstNode.Roles.Constraint); + + parent.AddChild (constraint, Roles.Constraint); } } @@ -2596,23 +2598,23 @@ namespace ICSharpCode.NRefactory.CSharp { if (arg is NamedArgument) { var na = (NamedArgument)arg; - NamedArgumentExpression newArg = new NamedArgumentExpression(); - newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), NamedArgumentExpression.Roles.Identifier); + NamedArgumentExpression newArg = new NamedArgumentExpression (); + newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), Roles.Identifier); var loc = LocationsBag.GetLocations (na); if (loc != null) - newArg.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), NamedArgumentExpression.Roles.Colon); + newArg.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.Colon); 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 ((Expression)arg.Expr.Accept (this), InvocationExpression.Roles.Expression); - newArg.AddChild (direction, NamedArgumentExpression.Roles.Expression); + direction.AddChild (new CSharpTokenNode (Convert (argLocation [0])), arg.ArgType == Argument.AType.Out ? DirectionExpression.OutKeywordRole : DirectionExpression.RefKeywordRole); + direction.AddChild ((Expression)arg.Expr.Accept (this), Roles.Expression); + newArg.AddChild (direction, Roles.Expression); } else { - newArg.AddChild ((Expression)na.Expr.Accept (this), NamedArgumentExpression.Roles.Expression); + newArg.AddChild ((Expression)na.Expr.Accept (this), Roles.Expression); } return newArg; } @@ -2622,8 +2624,8 @@ 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 ((Expression)arg.Expr.Accept (this), InvocationExpression.Roles.Expression); + direction.AddChild (new CSharpTokenNode (Convert (argLocation [0])), arg.ArgType == Argument.AType.Out ? DirectionExpression.OutKeywordRole : DirectionExpression.RefKeywordRole); + direction.AddChild ((Expression)arg.Expr.Accept (this), Roles.Expression); return direction; } @@ -2637,13 +2639,13 @@ 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]), Roles.Argument); if (commaLocations != null && i < commaLocations.Count) { - parent.AddChild (new CSharpTokenNode (Convert (commaLocations[i]), 1), InvocationExpression.Roles.Comma); + parent.AddChild (new CSharpTokenNode (Convert (commaLocations [i])), Roles.Comma); } } if (commaLocations != null && commaLocations.Count > args.Count) - parent.AddChild (new CSharpTokenNode (Convert (commaLocations[args.Count]), 1), InvocationExpression.Roles.Comma); + parent.AddChild (new CSharpTokenNode (Convert (commaLocations [args.Count])), Roles.Comma); } public override object Visit (Invocation invocationExpression) @@ -2651,13 +2653,13 @@ namespace ICSharpCode.NRefactory.CSharp var result = new InvocationExpression (); var location = LocationsBag.GetLocations (invocationExpression); if (invocationExpression.Exp != null) - result.AddChild ((Expression)invocationExpression.Exp.Accept (this), InvocationExpression.Roles.TargetExpression); + result.AddChild ((Expression)invocationExpression.Exp.Accept (this), Roles.TargetExpression); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), InvocationExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); AddArguments (result, location, invocationExpression.Arguments); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), InvocationExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } @@ -2665,16 +2667,16 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new ObjectCreateExpression (); var location = LocationsBag.GetLocations (newExpression); - result.AddChild (new CSharpTokenNode (Convert (newExpression.Location), "new".Length), ObjectCreateExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (newExpression.Location)), ObjectCreateExpression.NewKeywordRole); if (newExpression.TypeRequested != null) - result.AddChild (ConvertToType (newExpression.TypeRequested), ObjectCreateExpression.Roles.Type); + result.AddChild (ConvertToType (newExpression.TypeRequested), Roles.Type); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ObjectCreateExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); AddArguments (result, location, newExpression.Arguments); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ObjectCreateExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } @@ -2691,14 +2693,14 @@ namespace ICSharpCode.NRefactory.CSharp if (location == null) { if (par.Expr != null) - result.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression); + result.AddChild ((Expression)par.Expr.Accept (this), Roles.Expression); } else { var namedExpression = new NamedExpression (); - namedExpression.AddChild (Identifier.Create (par.Name, Convert (par.Location)), AnonymousTypeCreateExpression.Roles.Identifier); - namedExpression.AddChild (new CSharpTokenNode (Convert (location[0]), 1), AnonymousTypeCreateExpression.Roles.Assign); + namedExpression.AddChild (Identifier.Create (par.Name, Convert (par.Location)), Roles.Identifier); + namedExpression.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Assign); if (par.Expr != null) - namedExpression.AddChild ((Expression)par.Expr.Accept (this), AnonymousTypeCreateExpression.Roles.Expression); - result.AddChild (namedExpression, AnonymousTypeCreateExpression.Roles.Expression); + namedExpression.AddChild ((Expression)par.Expr.Accept (this), Roles.Expression); + result.AddChild (namedExpression, Roles.Expression); } } return result; @@ -2719,74 +2721,72 @@ namespace ICSharpCode.NRefactory.CSharp var commaLoc = LocationsBag.GetLocations (minit.Initializers); int curComma = 0; if (initLoc != null) - init.AddChild (new CSharpTokenNode (Convert (initLoc [0]), 1), ArrayInitializerExpression.Roles.LBrace); + init.AddChild (new CSharpTokenNode (Convert (initLoc [0])), Roles.LBrace); foreach (var expr in minit.Initializers) { var collectionInit = expr as CollectionElementInitializer; if (collectionInit != null) { var parent = new ArrayInitializerExpression (); - var braceLocs = LocationsBag.GetLocations (expr); - if (braceLocs != null) - parent.AddChild (new CSharpTokenNode (Convert (braceLocs [0]), 1), ArrayInitializerExpression.Roles.LBrace); - + parent.AddChild (new CSharpTokenNode (Convert (expr.Location)), Roles.LBrace); + for (int i = 0; i < collectionInit.Arguments.Count; i++) { var arg = collectionInit.Arguments [i] as CollectionElementInitializer.ElementInitializerArgument; if (arg == null) continue; - parent.AddChild ((ICSharpCode.NRefactory.CSharp.Expression)arg.Expr.Accept (this), ArrayInitializerExpression.Roles.Expression); + parent.AddChild ((ICSharpCode.NRefactory.CSharp.Expression)arg.Expr.Accept (this), Roles.Expression); } + var braceLocs = LocationsBag.GetLocations (expr); if (braceLocs != null) - parent.AddChild (new CSharpTokenNode (Convert (braceLocs [1]), 1), ArrayInitializerExpression.Roles.RBrace); + parent.AddChild (new CSharpTokenNode (Convert (braceLocs [0])), Roles.RBrace); - init.AddChild (parent, ArrayInitializerExpression.Roles.Expression); + init.AddChild (parent, Roles.Expression); } else { var eleInit = expr as ElementInitializer; if (eleInit != null) { var nexpr = new NamedExpression (); - nexpr.AddChild (Identifier.Create (eleInit.Name, Convert (eleInit.Location)), NamedArgumentExpression.Roles.Identifier); + nexpr.AddChild (Identifier.Create (eleInit.Name, Convert (eleInit.Location)), Roles.Identifier); var assignLoc = LocationsBag.GetLocations (eleInit); if (assignLoc != null) - nexpr.AddChild (new CSharpTokenNode (Convert (assignLoc [0]), 1), NamedArgumentExpression.Roles.Assign); + nexpr.AddChild (new CSharpTokenNode (Convert (assignLoc [0])), Roles.Assign); if (eleInit.Source != null) { if (eleInit.Source is CollectionOrObjectInitializers) { var arrInit = new ArrayInitializerExpression (); AddConvertCollectionOrObjectInitializers (arrInit, eleInit.Source as CollectionOrObjectInitializers); - nexpr.AddChild (arrInit, NamedArgumentExpression.Roles.Expression); + nexpr.AddChild (arrInit, Roles.Expression); } else { - nexpr.AddChild ((Expression)eleInit.Source.Accept (this), NamedArgumentExpression.Roles.Expression); + nexpr.AddChild ((Expression)eleInit.Source.Accept (this), Roles.Expression); } } - init.AddChild (nexpr, ArrayInitializerExpression.Roles.Expression); + init.AddChild (nexpr, Roles.Expression); } } if (commaLoc != null && curComma < commaLoc.Count) - init.AddChild (new CSharpTokenNode (Convert (commaLoc [curComma++]), 1), ArrayInitializerExpression.Roles.Comma); + init.AddChild (new CSharpTokenNode (Convert (commaLoc [curComma++])), Roles.Comma); } if (initLoc != null) { if (initLoc.Count == 3) // optional comma - init.AddChild (new CSharpTokenNode (Convert (initLoc [1]), 1), ArrayInitializerExpression.Roles.Comma); - init.AddChild (new CSharpTokenNode (Convert (initLoc [initLoc.Count - 1]), 1), ArrayInitializerExpression.Roles.RBrace); + init.AddChild (new CSharpTokenNode (Convert (initLoc [1])), Roles.Comma); + init.AddChild (new CSharpTokenNode (Convert (initLoc [initLoc.Count - 1])), Roles.RBrace); } } - public override object Visit (NewInitialize newInitializeExpression) { var result = new ObjectCreateExpression (); - result.AddChild (new CSharpTokenNode (Convert (newInitializeExpression.Location), "new".Length), ObjectCreateExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (newInitializeExpression.Location)), ObjectCreateExpression.NewKeywordRole); if (newInitializeExpression.TypeRequested != null) - result.AddChild (ConvertToType (newInitializeExpression.TypeRequested), ObjectCreateExpression.Roles.Type); + result.AddChild (ConvertToType (newInitializeExpression.TypeRequested), Roles.Type); 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])), Roles.LPar); AddArguments (result, location, newInitializeExpression.Arguments); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ObjectCreateExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); var init = ConvertCollectionOrObjectInitializers (newInitializeExpression.Initializers); if (init != null) @@ -2795,15 +2795,14 @@ namespace ICSharpCode.NRefactory.CSharp return result; } - public override object Visit (ArrayCreation arrayCreationExpression) { var result = new ArrayCreateExpression (); var location = LocationsBag.GetLocations (arrayCreationExpression); - result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Location), "new".Length), ArrayCreateExpression.Roles.Keyword); - if (arrayCreationExpression.NewType != null) - result.AddChild (ConvertToType (arrayCreationExpression.NewType), ArrayCreateExpression.Roles.Type); + result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Location)), ArrayCreateExpression.NewKeywordRole); + if (arrayCreationExpression.TypeExpression != null) + result.AddChild (ConvertToType (arrayCreationExpression.TypeExpression), Roles.Type); var next = arrayCreationExpression.Rank; if (arrayCreationExpression.Arguments != null) { @@ -2811,47 +2810,47 @@ namespace ICSharpCode.NRefactory.CSharp next = next.Next; if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ArrayCreateExpression.Roles.LBracket); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LBracket); 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), Roles.Argument); if (commaLocations != null && i < commaLocations.Count) - result.AddChild (new CSharpTokenNode (Convert (commaLocations [i]), 1), ArrayCreateExpression.Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (commaLocations [i])), Roles.Comma); } if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ArrayCreateExpression.Roles.RBracket); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RBracket); } while (next != null) { ArraySpecifier spec = new ArraySpecifier (next.Dimension); var loc = LocationsBag.GetLocations (next); - spec.AddChild (new CSharpTokenNode (Convert (next.Location), 1), ArraySpecifier.Roles.LBracket); + spec.AddChild (new CSharpTokenNode (Convert (next.Location)), Roles.LBracket); result.AddChild (spec, ArrayCreateExpression.AdditionalArraySpecifierRole); if (loc != null) - result.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), ArraySpecifier.Roles.RBracket); + result.AddChild (new CSharpTokenNode (Convert (loc [0])), Roles.RBracket); next = next.Next; } 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); + initializer.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Initializers.Location)), Roles.LBrace); var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Initializers.Elements); for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) { - var init = arrayCreationExpression.Initializers[i]; + var init = arrayCreationExpression.Initializers [i]; if (init == null) continue; - initializer.AddChild ((Expression)init.Accept (this), ArrayInitializerExpression.Roles.Expression); + initializer.AddChild ((Expression)init.Accept (this), Roles.Expression); if (commaLocations != null && i < commaLocations.Count) { - initializer.AddChild (new CSharpTokenNode (Convert (commaLocations [i]), 1), IndexerExpression.Roles.Comma); + initializer.AddChild (new CSharpTokenNode (Convert (commaLocations [i])), 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])), Roles.RBrace); result.AddChild (initializer, ArrayCreateExpression.InitializerRole); } @@ -2870,7 +2869,7 @@ namespace ICSharpCode.NRefactory.CSharp var result = new UndocumentedExpression () { UndocumentedExpressionType = UndocumentedExpressionType.ArgListAccess }; - result.AddChild (new CSharpTokenNode (Convert (argListAccessExpression.Location), "__arglist".Length), UndocumentedExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (argListAccessExpression.Location)), UndocumentedExpression.ArglistKeywordRole); return result; } @@ -2878,65 +2877,65 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (Arglist argListExpression) { var result = new UndocumentedExpression () { UndocumentedExpressionType = UndocumentedExpressionType.ArgList }; - result.AddChild (new CSharpTokenNode (Convert (argListExpression.Location), "__arglist".Length), UndocumentedExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (argListExpression.Location)), UndocumentedExpression.ArglistKeywordRole); 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])), Roles.LPar); AddArguments (result, location, argListExpression.Arguments); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UndocumentedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } public override object Visit (MakeRefExpr makeRefExpr) { var result = new UndocumentedExpression () { UndocumentedExpressionType = UndocumentedExpressionType.MakeRef }; - result.AddChild (new CSharpTokenNode (Convert (makeRefExpr.Location), "__makeref".Length), UndocumentedExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (makeRefExpr.Location)), UndocumentedExpression.MakerefKeywordRole); 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])), Roles.LPar); if (makeRefExpr.Expr != null) - result.AddChild ((Expression)makeRefExpr.Expr.Accept (this), UndocumentedExpression.Roles.Argument); + result.AddChild ((Expression)makeRefExpr.Expr.Accept (this), Roles.Argument); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UndocumentedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } public override object Visit (RefTypeExpr refTypeExpr) { var result = new UndocumentedExpression () { UndocumentedExpressionType = UndocumentedExpressionType.RefType }; - result.AddChild (new CSharpTokenNode (Convert (refTypeExpr.Location), "__reftype".Length), UndocumentedExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (refTypeExpr.Location)), UndocumentedExpression.ReftypeKeywordRole); 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])), Roles.LPar); if (refTypeExpr.Expr != null) - result.AddChild ((Expression)refTypeExpr.Expr.Accept (this), UndocumentedExpression.Roles.Argument); + result.AddChild ((Expression)refTypeExpr.Expr.Accept (this), Roles.Argument); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UndocumentedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), 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); + result.AddChild (new CSharpTokenNode (Convert (refValueExpr.Location)), UndocumentedExpression.RefvalueKeywordRole); 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])), Roles.LPar); if (refValueExpr.Expr != null) - result.AddChild ((Expression)refValueExpr.Expr.Accept (this), UndocumentedExpression.Roles.Argument); + result.AddChild ((Expression)refValueExpr.Expr.Accept (this), Roles.Argument); if (refValueExpr.FullNamedExpression != null) - result.AddChild ((Expression)refValueExpr.FullNamedExpression.Accept (this), UndocumentedExpression.Roles.Argument); + result.AddChild ((Expression)refValueExpr.FullNamedExpression.Accept (this), Roles.Argument); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UndocumentedExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } #endregion @@ -2945,13 +2944,13 @@ 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 (typeOfExpression.Location)), TypeOfExpression.TypeofKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (typeOfExpression.TypeExpression != null) - result.AddChild (ConvertToType (typeOfExpression.TypeExpression), TypeOfExpression.Roles.Type); + result.AddChild (ConvertToType (typeOfExpression.TypeExpression), Roles.Type); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } @@ -2959,13 +2958,13 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new SizeOfExpression (); var location = LocationsBag.GetLocations (sizeOfExpression); - result.AddChild (new CSharpTokenNode (Convert (sizeOfExpression.Location), "sizeof".Length), TypeOfExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (sizeOfExpression.Location)), SizeOfExpression.SizeofKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (sizeOfExpression.TypeExpression != null) - result.AddChild (ConvertToType (sizeOfExpression.TypeExpression), TypeOfExpression.Roles.Type); + result.AddChild (ConvertToType (sizeOfExpression.TypeExpression), Roles.Type); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } @@ -2973,13 +2972,13 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new CheckedExpression (); var location = LocationsBag.GetLocations (checkedExpression); - result.AddChild (new CSharpTokenNode (Convert (checkedExpression.Location), "checked".Length), TypeOfExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (checkedExpression.Location)), CheckedExpression.CheckedKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (checkedExpression.Expr != null) - result.AddChild ((Expression)checkedExpression.Expr.Accept (this), TypeOfExpression.Roles.Expression); + result.AddChild ((Expression)checkedExpression.Expr.Accept (this), Roles.Expression); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } @@ -2987,13 +2986,13 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new UncheckedExpression (); var location = LocationsBag.GetLocations (uncheckedExpression); - result.AddChild (new CSharpTokenNode (Convert (uncheckedExpression.Location), "unchecked".Length), TypeOfExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (uncheckedExpression.Location)), UncheckedExpression.UncheckedKeywordRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LPar); if (uncheckedExpression.Expr != null) - 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 ((Expression)uncheckedExpression.Expr.Accept (this), Roles.Expression); + if (location != null && location.Count > 1) + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RPar); return result; } @@ -3003,11 +3002,11 @@ namespace ICSharpCode.NRefactory.CSharp var location = LocationsBag.GetLocations (elementAccessExpression); if (elementAccessExpression.Expr != null) - result.AddChild ((Expression)elementAccessExpression.Expr.Accept (this), IndexerExpression.Roles.TargetExpression); - result.AddChild (new CSharpTokenNode (Convert (elementAccessExpression.Location), 1), TypeOfExpression.Roles.LBracket); + result.AddChild ((Expression)elementAccessExpression.Expr.Accept (this), Roles.TargetExpression); + result.AddChild (new CSharpTokenNode (Convert (elementAccessExpression.Location)), 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])), Roles.RBracket); return result; } @@ -3024,15 +3023,15 @@ namespace ICSharpCode.NRefactory.CSharp 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])), StackAllocExpression.StackallocKeywordRole); if (stackAllocExpression.TypeExpression != null) - result.AddChild (ConvertToType (stackAllocExpression.TypeExpression), StackAllocExpression.Roles.Type); + result.AddChild (ConvertToType (stackAllocExpression.TypeExpression), 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])), Roles.LBracket); if (stackAllocExpression.CountExpression != null) - result.AddChild ((Expression)stackAllocExpression.CountExpression.Accept (this), StackAllocExpression.Roles.Expression); + result.AddChild ((Expression)stackAllocExpression.CountExpression.Accept (this), 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])), Roles.RBracket); return result; } @@ -3043,7 +3042,7 @@ namespace ICSharpCode.NRefactory.CSharp result.Operator = AssignmentOperatorType.Assign; if (simpleAssign.Target != null) result.AddChild ((Expression)simpleAssign.Target.Accept (this), AssignmentExpression.LeftRole); - result.AddChild (new CSharpTokenNode (Convert (simpleAssign.Location), 1), AssignmentExpression.OperatorRole); + result.AddChild (new CSharpTokenNode (Convert (simpleAssign.Location)), AssignmentExpression.AssignRole); if (simpleAssign.Source != null) { result.AddChild ((Expression)simpleAssign.Source.Accept (this), AssignmentExpression.RightRole); } @@ -3053,45 +3052,42 @@ namespace ICSharpCode.NRefactory.CSharp 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; + break; + case Binary.Operator.RightShift: + result.Operator = AssignmentOperatorType.ShiftRight; + 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; } if (compoundAssign.Target != null) result.AddChild ((Expression)compoundAssign.Target.Accept (this), AssignmentExpression.LeftRole); - result.AddChild (new CSharpTokenNode (Convert (compoundAssign.Location), opLength), AssignmentExpression.OperatorRole); + result.AddChild (new CSharpTokenNode (Convert (compoundAssign.Location)), AssignmentExpression.GetOperatorRole (result.Operator)); if (compoundAssign.Source != null) result.AddChild ((Expression)compoundAssign.Source.Accept (this), AssignmentExpression.RightRole); return result; @@ -3104,20 +3100,20 @@ namespace ICSharpCode.NRefactory.CSharp int l = 0; if (anonymousMethodExpression.IsAsync) { result.IsAsync = true; - result.AddChild (new CSharpTokenNode (Convert (location[l++]), "async".Length), AnonymousMethodExpression.AsyncModifierRole); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), AnonymousMethodExpression.AsyncModifierRole); } if (location != null) { - result.AddChild (new CSharpTokenNode (Convert (location[l++]), "delegate".Length), AnonymousMethodExpression.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), AnonymousMethodExpression.DelegateKeywordRole); if (location.Count > l) { result.HasParameterList = true; - result.AddChild (new CSharpTokenNode (Convert (location[l++]), 1), AnonymousMethodExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), Roles.LPar); AddParameter (result, anonymousMethodExpression.Parameters); - result.AddChild (new CSharpTokenNode (Convert (location[l++]), 1), AnonymousMethodExpression.Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), Roles.RPar); } } if (anonymousMethodExpression.Block != null) - result.AddChild ((BlockStatement)anonymousMethodExpression.Block.Accept (this), AnonymousMethodExpression.Roles.Body); + result.AddChild ((BlockStatement)anonymousMethodExpression.Block.Accept (this), Roles.Body); return result; } @@ -3128,19 +3124,19 @@ namespace ICSharpCode.NRefactory.CSharp int l = 0; if (lambdaExpression.IsAsync) { result.IsAsync = true; - result.AddChild (new CSharpTokenNode (Convert (location [l++]), "async".Length), LambdaExpression.AsyncModifierRole); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), LambdaExpression.AsyncModifierRole); } if (location == null || location.Count == l + 1) { AddParameter (result, lambdaExpression.Parameters); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location [l++]), "=>".Length), LambdaExpression.ArrowRole); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), LambdaExpression.ArrowRole); } else { - result.AddChild (new CSharpTokenNode (Convert (location [l++]), 1), LambdaExpression.Roles.LPar); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), Roles.LPar); AddParameter (result, lambdaExpression.Parameters); if (location != null) { - result.AddChild (new CSharpTokenNode (Convert (location [l++]), 1), LambdaExpression.Roles.RPar); - result.AddChild (new CSharpTokenNode (Convert (location [l++]), "=>".Length), LambdaExpression.ArrowRole); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), Roles.RPar); + result.AddChild (new CSharpTokenNode (Convert (location [l++])), LambdaExpression.ArrowRole); } } if (lambdaExpression.Block != null) { @@ -3164,21 +3160,21 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new ArrayInitializerExpression (); var location = LocationsBag.GetLocations (arrayInitializer); - result.AddChild (new CSharpTokenNode (Convert (arrayInitializer.Location), "{".Length), ArrayInitializerExpression.Roles.LBrace); + result.AddChild (new CSharpTokenNode (Convert (arrayInitializer.Location)), Roles.LBrace); var commaLocations = LocationsBag.GetLocations (arrayInitializer.Elements); for (int i = 0; i < arrayInitializer.Count; i++) { - var init = arrayInitializer[i]; + var init = arrayInitializer [i]; if (init == null) continue; - result.AddChild ((Expression)init.Accept (this), ArrayInitializerExpression.Roles.Expression); + result.AddChild ((Expression)init.Accept (this), 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])), 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])), Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1])), Roles.RBrace); } return result; } @@ -3196,9 +3192,9 @@ namespace ICSharpCode.NRefactory.CSharp 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; @@ -3211,54 +3207,55 @@ namespace ICSharpCode.NRefactory.CSharp { if (queryStart.Expr == null) { var intoClause = new QueryContinuationClause (); - intoClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "into".Length), QueryContinuationClause.IntoKeywordRole); - intoClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryContinuationClause.Roles.Identifier); + intoClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location)), QueryContinuationClause.IntoKeywordRole); + intoClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert (queryStart.IntoVariable.Location)), Roles.Identifier); return intoClause; } var fromClause = new QueryFromClause (); - var location = LocationsBag.GetLocations (queryStart); - - fromClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "from".Length), QueryFromClause.FromKeywordRole); + + fromClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location)), QueryFromClause.FromKeywordRole); if (queryStart.IdentifierType != null) - fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type); + fromClause.AddChild (ConvertToType (queryStart.IdentifierType), Roles.Type); - fromClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); + fromClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert (queryStart.IntoVariable.Location)), Roles.Identifier); + var location = LocationsBag.GetLocations (queryStart); if (location != null) - fromClause.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryFromClause.InKeywordRole); + fromClause.AddChild (new CSharpTokenNode (Convert (location [0])), QueryFromClause.InKeywordRole); + if (queryStart.Expr != null) - fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), QueryFromClause.Roles.Expression); + fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), Roles.Expression); return fromClause; } public override object Visit (Mono.CSharp.Linq.SelectMany queryStart) { var fromClause = new QueryFromClause (); - var location = LocationsBag.GetLocations (queryStart); - - fromClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "from".Length), QueryFromClause.FromKeywordRole); + + fromClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location)), QueryFromClause.FromKeywordRole); if (queryStart.IdentifierType != null) - fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type); + fromClause.AddChild (ConvertToType (queryStart.IdentifierType), Roles.Type); - fromClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert(queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier); + fromClause.AddChild (Identifier.Create (queryStart.IntoVariable.Name, Convert (queryStart.IntoVariable.Location)), Roles.Identifier); + var location = LocationsBag.GetLocations (queryStart); if (location != null) - fromClause.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryFromClause.InKeywordRole); - + fromClause.AddChild (new CSharpTokenNode (Convert (location [0])), QueryFromClause.InKeywordRole); + if (queryStart.Expr != null) - fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), QueryFromClause.Roles.Expression); + fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), Roles.Expression); return fromClause; } public override object Visit (Mono.CSharp.Linq.Select sel) { var result = new QuerySelectClause (); - result.AddChild (new CSharpTokenNode (Convert (sel.Location), "select".Length), QueryWhereClause.Roles.Keyword); + result.AddChild (new CSharpTokenNode (Convert (sel.Location)), QuerySelectClause.SelectKeywordRole); if (sel.Expr != null) - result.AddChild ((Expression)sel.Expr.Accept (this), QueryWhereClause.Roles.Expression); + result.AddChild ((Expression)sel.Expr.Accept (this), Roles.Expression); return result; } @@ -3266,10 +3263,11 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new QueryGroupClause (); var location = LocationsBag.GetLocations (groupBy); - result.AddChild (new CSharpTokenNode (Convert (groupBy.Location), "group".Length), QueryGroupClause.GroupKeywordRole); - result.AddChild ((Expression)groupBy.ElementSelector.Accept (this), QueryGroupClause.ProjectionRole); + result.AddChild (new CSharpTokenNode (Convert (groupBy.Location)), QueryGroupClause.GroupKeywordRole); + if (groupBy.ElementSelector != null) + result.AddChild ((Expression)groupBy.ElementSelector.Accept (this), QueryGroupClause.ProjectionRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "by".Length), QueryGroupClause.ByKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [0])), QueryGroupClause.ByKeywordRole); if (groupBy.Expr != null) result.AddChild ((Expression)groupBy.Expr.Accept (this), QueryGroupClause.KeyRole); return result; @@ -3280,12 +3278,12 @@ namespace ICSharpCode.NRefactory.CSharp var result = new QueryLetClause (); var location = LocationsBag.GetLocations (l); - result.AddChild (new CSharpTokenNode (Convert (l.Location), "let".Length), QueryLetClause.Roles.Keyword); - result.AddChild (Identifier.Create (l.IntoVariable.Name, Convert (l.IntoVariable.Location)), Identifier.Roles.Identifier); + result.AddChild (new CSharpTokenNode (Convert (l.Location)), QueryLetClause.LetKeywordRole); + result.AddChild (Identifier.Create (l.IntoVariable.Name, Convert (l.IntoVariable.Location)), Roles.Identifier); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), QueryLetClause.Roles.Assign); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Assign); if (l.Expr != null) - result.AddChild ((Expression)l.Expr.Accept (this), QueryLetClause.Roles.Expression); + result.AddChild ((Expression)l.Expr.Accept (this), Roles.Expression); return result; } @@ -3294,9 +3292,9 @@ namespace ICSharpCode.NRefactory.CSharp 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])), QueryWhereClause.WhereKeywordRole); if (w.Expr != null) - result.AddChild ((Expression)w.Expr.Accept (this), QueryWhereClause.Roles.Condition); + result.AddChild ((Expression)w.Expr.Accept (this), Roles.Condition); return result; } @@ -3304,23 +3302,24 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new QueryJoinClause (); var location = LocationsBag.GetLocations (join); - result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (join.Location)), QueryJoinClause.JoinKeywordRole); result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), QueryJoinClause.JoinIdentifierRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [0])), QueryJoinClause.InKeywordRole); + if (join.Expr != null) result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.InExpressionRole); if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [1])), QueryJoinClause.OnKeywordRole); var outer = join.OuterSelector.Statements.FirstOrDefault () as ContextualReturn; if (outer != null) result.AddChild ((Expression)outer.Expr.Accept (this), QueryJoinClause.OnExpressionRole); if (location != null && location.Count > 2) - result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [2])), QueryJoinClause.EqualsKeywordRole); var inner = join.InnerSelector.Statements.FirstOrDefault () as ContextualReturn; if (inner != null) @@ -3333,31 +3332,33 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new QueryJoinClause (); var location = LocationsBag.GetLocations (join); - result.AddChild (new CSharpTokenNode (Convert (join.Location), "join".Length), QueryJoinClause.JoinKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (join.Location)), QueryJoinClause.JoinKeywordRole); // mcs seems to have swapped IntoVariable with JoinVariable, so we'll swap it back here result.AddChild (Identifier.Create (join.IntoVariable.Name, Convert (join.IntoVariable.Location)), QueryJoinClause.JoinIdentifierRole); if (location != null) - result.AddChild (new CSharpTokenNode (Convert (location[0]), "in".Length), QueryJoinClause.InKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [0])), QueryJoinClause.InKeywordRole); + if (join.Expr != null) + result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.InExpressionRole); + + if (location != null && location.Count > 1) + result.AddChild (new CSharpTokenNode (Convert (location [1])), QueryJoinClause.OnKeywordRole); + var outer = join.OuterSelector.Statements.FirstOrDefault () as ContextualReturn; if (outer != null) result.AddChild ((Expression)outer.Expr.Accept (this), QueryJoinClause.OnExpressionRole); - if (location != null && location.Count > 1) - result.AddChild (new CSharpTokenNode (Convert (location[1]), "on".Length), QueryJoinClause.OnKeywordRole); - if (join.Expr != null) - result.AddChild ((Expression)join.Expr.Accept (this), QueryJoinClause.InExpressionRole); - + if (location != null && location.Count > 2) - result.AddChild (new CSharpTokenNode (Convert (location[2]), "equals".Length), QueryJoinClause.EqualsKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [2])), QueryJoinClause.EqualsKeywordRole); var inner = join.InnerSelector.Statements.FirstOrDefault () as ContextualReturn; if (inner != null) result.AddChild ((Expression)inner.Expr.Accept (this), QueryJoinClause.EqualsExpressionRole); if (location != null && location.Count > 3) - result.AddChild (new CSharpTokenNode (Convert (location[3]), "into".Length), QueryJoinClause.IntoKeywordRole); + result.AddChild (new CSharpTokenNode (Convert (location [3])), QueryJoinClause.IntoKeywordRole); result.AddChild (Identifier.Create (join.JoinVariable.Name, Convert (join.JoinVariable.Location)), QueryJoinClause.IntoIdentifierRole); return result; @@ -3369,11 +3370,11 @@ namespace ICSharpCode.NRefactory.CSharp var ordering = new QueryOrdering (); if (orderByAscending.Expr != null) - ordering.AddChild ((Expression)orderByAscending.Expr.Accept (this), QueryWhereClause.Roles.Expression); + ordering.AddChild ((Expression)orderByAscending.Expr.Accept (this), Roles.Expression); 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])), QueryOrdering.AscendingKeywordRole); } result.AddChild (ordering, QueryOrderClause.OrderingRole); return result; @@ -3385,15 +3386,15 @@ namespace ICSharpCode.NRefactory.CSharp var ordering = new QueryOrdering (); if (orderByDescending.Expr != null) - ordering.AddChild ((Expression)orderByDescending.Expr.Accept (this), QueryWhereClause.Roles.Expression); + ordering.AddChild ((Expression)orderByDescending.Expr.Accept (this), Roles.Expression); 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])), QueryOrdering.DescendingKeywordRole); } result.AddChild (ordering, QueryOrderClause.OrderingRole); return result; - } + } public override object Visit (Mono.CSharp.Linq.ThenByAscending thenByAscending) { @@ -3401,11 +3402,11 @@ namespace ICSharpCode.NRefactory.CSharp var ordering = new QueryOrdering (); if (thenByAscending.Expr != null) - ordering.AddChild ((Expression)thenByAscending.Expr.Accept (this), QueryWhereClause.Roles.Expression); + ordering.AddChild ((Expression)thenByAscending.Expr.Accept (this), Roles.Expression); 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])), QueryOrdering.AscendingKeywordRole); } result.AddChild (ordering, QueryOrderClause.OrderingRole); return result; @@ -3417,11 +3418,11 @@ namespace ICSharpCode.NRefactory.CSharp var ordering = new QueryOrdering (); if (thenByDescending.Expr != null) - ordering.AddChild ((Expression)thenByDescending.Expr.Accept (this), QueryWhereClause.Roles.Expression); + ordering.AddChild ((Expression)thenByDescending.Expr.Accept (this), Roles.Expression); 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])), QueryOrdering.DescendingKeywordRole); } result.AddChild (ordering, QueryOrderClause.OrderingRole); return result; @@ -3431,9 +3432,9 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new UnaryOperatorExpression (); result.Operator = UnaryOperatorType.Await; - result.AddChild (new CSharpTokenNode (Convert (awaitExpr.Location), 1), UnaryOperatorExpression.OperatorRole); + result.AddChild (new CSharpTokenNode (Convert (awaitExpr.Location)), UnaryOperatorExpression.AwaitRole); if (awaitExpr.Expression != null) - result.AddChild ((Expression)awaitExpr.Expression.Accept (this), UnaryOperatorExpression.Roles.Expression); + result.AddChild ((Expression)awaitExpr.Expression.Accept (this), Roles.Expression); return result; } #endregion @@ -3465,7 +3466,7 @@ namespace ICSharpCode.NRefactory.CSharp var next = node.NextSibling; if (next == null) return node.Parent; - return GetOuterLeft(next); + return GetOuterLeft (next); } static void InsertComments (CompilerCompilationUnit top, ConversionVisitor conversionVisitor) @@ -3476,14 +3477,20 @@ namespace ICSharpCode.NRefactory.CSharp AstNode newLeaf = null; var comment = special as SpecialsBag.Comment; if (comment != null) { - if (conversionVisitor.convertTypeSystemMode && (comment.CommentType != SpecialsBag.CommentType.Documentation)) + // HACK: multiline documentation comment detection; better move this logic into the mcs tokenizer + bool isMultilineDocumentationComment = ( + comment.CommentType == SpecialsBag.CommentType.Multi + && comment.Content.StartsWith("*", StringComparison.Ordinal) + && !comment.Content.StartsWith("**", StringComparison.Ordinal) + ); + if (conversionVisitor.convertTypeSystemMode && !(comment.CommentType == SpecialsBag.CommentType.Documentation || isMultilineDocumentationComment)) continue; - var type = (CommentType)comment.CommentType; + var type = isMultilineDocumentationComment ? CommentType.MultiLineDocumentation : (CommentType)comment.CommentType; var start = new TextLocation (comment.Line, comment.Col); var end = new TextLocation (comment.EndLine, comment.EndCol); newLeaf = new Comment (type, start, end) { StartsLine = comment.StartsLine, - Content = comment.Content + Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content }; } else { var directive = special as SpecialsBag.PreProcessorDirective; @@ -3507,9 +3514,9 @@ namespace ICSharpCode.NRefactory.CSharp node = node.Parent; } if (newLeaf is Comment) { - node.InsertChildBefore (leaf, (Comment)newLeaf, AstNode.Roles.Comment); + node.InsertChildBefore (leaf, (Comment)newLeaf, Roles.Comment); } else { - node.InsertChildBefore (leaf, (PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective); + node.InsertChildBefore (leaf, (PreProcessorDirective)newLeaf, Roles.PreProcessorDirective); } leaf = newLeaf; break; @@ -3519,9 +3526,9 @@ namespace ICSharpCode.NRefactory.CSharp if (nextLeaf == null) { var node = leaf.Parent ?? conversionVisitor.Unit; if (newLeaf is Comment) { - node.AddChild ((Comment)newLeaf, AstNode.Roles.Comment); + node.AddChild ((Comment)newLeaf, Roles.Comment); } else { - node.AddChild ((PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective); + node.AddChild ((PreProcessorDirective)newLeaf, Roles.PreProcessorDirective); } leaf = newLeaf; break; @@ -3531,9 +3538,9 @@ namespace ICSharpCode.NRefactory.CSharp if (leaf.EndLocation <= newLeaf.StartLocation && newLeaf.StartLocation <= nextLeaf.StartLocation) { var node = leaf.Parent ?? conversionVisitor.Unit; if (newLeaf is Comment) { - node.InsertChildAfter (leaf, (Comment)newLeaf, AstNode.Roles.Comment); + node.InsertChildAfter (leaf, (Comment)newLeaf, Roles.Comment); } else { - node.InsertChildAfter (leaf, (PreProcessorDirective)newLeaf, AstNode.Roles.PreProcessorDirective); + node.InsertChildAfter (leaf, (PreProcessorDirective)newLeaf, Roles.PreProcessorDirective); } leaf = newLeaf; break; @@ -3553,9 +3560,9 @@ namespace ICSharpCode.NRefactory.CSharp this.fileName = fileName; } - public override void Print (AbstractMessage msg) + public override void Print (AbstractMessage msg, bool showFullPath) { - base.Print (msg); + base.Print (msg, showFullPath); var newError = new Error (msg.IsWarning ? ErrorType.Warning : ErrorType.Error, msg.Text, new DomRegion (fileName, msg.Location.Row, msg.Location.Column)); Errors.Add (newError); } @@ -3570,7 +3577,7 @@ namespace ICSharpCode.NRefactory.CSharp public bool HasErrors { get { - return errorReportPrinter.ErrorsCount + errorReportPrinter.FatalCounter > 0; + return errorReportPrinter.ErrorsCount > 0; } } @@ -3582,7 +3589,7 @@ namespace ICSharpCode.NRefactory.CSharp public CompilationUnit Parse (ITextSource textSource, string fileName, int lineModifier = 0) { - return Parse (textSource.CreateReader(), fileName, lineModifier); + return Parse (textSource.CreateReader (), fileName, lineModifier); } public CompilationUnit Parse (TextReader reader, string fileName, int lineModifier = 0) @@ -3601,36 +3608,27 @@ namespace ICSharpCode.NRefactory.CSharp } } - public static void AdjustLineLocations (AstNode node, int lineModifier) + public CompilationUnit Parse(CompilerCompilationUnit top, string fileName, int lineModifier = 0) { - if (node is IRelocatable) { - ((IRelocatable)node).SetStartLocation (new TextLocation (node.StartLocation.Line + lineModifier, node.StartLocation.Column)); - } - foreach (var child in node.Children) { - AdjustLineLocations (child, lineModifier); - } - } - - public CompilationUnit Parse (CompilerCompilationUnit top, string fileName, int lineModifier = 0) - { - if (top == null) + if (top == null) { return null; + } CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (GenerateTypeSystemMode, top.LocationsBag); - top.ModuleCompiled.Accept (conversionVisitor); - InsertComments (top, conversionVisitor); - if (CompilationUnitCallback != null) - CompilationUnitCallback (top); - if (lineModifier != 0) - AdjustLineLocations (conversionVisitor.Unit, lineModifier); - if (top.LastYYValue is Mono.CSharp.Expression) - conversionVisitor.Unit.TopExpression = ((Mono.CSharp.Expression)top.LastYYValue).Accept (conversionVisitor) as AstNode; + top.ModuleCompiled.Accept(conversionVisitor); + InsertComments(top, conversionVisitor); + if (CompilationUnitCallback != null) { + CompilationUnitCallback(top); + } + if (top.LastYYValue is Mono.CSharp.Expression) { + conversionVisitor.Unit.TopExpression = ((Mono.CSharp.Expression)top.LastYYValue).Accept(conversionVisitor) as AstNode; + } conversionVisitor.Unit.FileName = fileName; return conversionVisitor.Unit; } public CompilerSettings CompilerSettings { get; - private set; + internal set; } public Action CompilationUnitCallback { @@ -3650,7 +3648,7 @@ namespace ICSharpCode.NRefactory.CSharp internal static object parseLock = new object (); - public CompilationUnit Parse (Stream stream, string fileName, int lineModifier = 0) + public CompilationUnit Parse(Stream stream, string fileName, int lineModifier = 0) { lock (parseLock) { errorReportPrinter = new ErrorReportPrinter (""); @@ -3660,8 +3658,7 @@ namespace ICSharpCode.NRefactory.CSharp var file = new SourceFile (fileName, fileName, 0); Location.Initialize (new List (new [] { file })); var module = new ModuleContainer (ctx); - var driver = new Driver (ctx); - var parser = driver.Parse (reader, file, module); + var parser = Driver.Parse (reader, file, module, lineModifier); var top = new CompilerCompilationUnit () { ModuleCompiled = module, @@ -3675,41 +3672,41 @@ namespace ICSharpCode.NRefactory.CSharp } } - public IEnumerable ParseTypeMembers (TextReader reader, int lineModifier = 0) + public IEnumerable ParseTypeMembers (TextReader reader, int lineModifier = 0) { string code = "unsafe partial class MyClass { " + Environment.NewLine + reader.ReadToEnd () + "}"; var cu = Parse (new StringReader (code), "parsed.cs", lineModifier - 1); if (cu == null) - return Enumerable.Empty (); + return Enumerable.Empty (); var td = cu.Children.FirstOrDefault () as TypeDeclaration; if (td != null) return td.Members; - return Enumerable.Empty (); + return Enumerable.Empty (); } - public IEnumerable ParseStatements(TextReader reader, int lineModifier = 0) + public IEnumerable ParseStatements (TextReader reader, int lineModifier = 0) { - string code = "void M() { " + Environment.NewLine + reader.ReadToEnd() + "}"; - var members = ParseTypeMembers(new StringReader(code), lineModifier - 1); - 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; + 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 = " + Environment.NewLine + reader.ReadToEnd() + ";"), -1).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) @@ -3721,10 +3718,20 @@ 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 (); + } + + public DocumentationReference ParseDocumentationReference (string cref) + { + if (cref == null) + throw new ArgumentNullException ("cref"); + cref = cref.Replace ('{', '<').Replace ('}', '>'); + // TODO: add support for parsing cref attributes + // (documentation_parsing production, see DocumentationBuilder.HandleXrefCommon) + throw new NotImplementedException (); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs index 583289595..664cdf0cf 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs @@ -1,12 +1,13 @@ // -// Mono.CSharp.Debugger/MonoSymbolFile.cs +// MonoSymbolFile.cs // -// Author: +// Authors: // Martin Baulig (martin@ximian.com) +// Marek Safar (marek.safar@gmail.com) // // (C) 2003 Ximian, Inc. http://www.ximian.com +// Copyright (C) 2012 Xamarin Inc (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 @@ -30,10 +31,7 @@ using System; using System.Reflection; -using SRE = System.Reflection.Emit; using System.Collections.Generic; -using System.Text; -using System.Threading; using System.IO; namespace Mono.CompilerServices.SymbolWriter @@ -46,7 +44,13 @@ namespace Mono.CompilerServices.SymbolWriter public MonoSymbolFileException (string message, params object[] args) : base (String.Format (message, args)) - { } + { + } + + public MonoSymbolFileException (string message, Exception innerException) + : base (message, innerException) + { + } } internal class MyBinaryWriter : BinaryWriter @@ -109,48 +113,6 @@ namespace Mono.CompilerServices.SymbolWriter } } -#if !CECIL - // TODO: Obsolete under .net 4 - internal class MonoDebuggerSupport - { - static GetMethodTokenFunc get_method_token; - static GetGuidFunc get_guid; - - delegate int GetMethodTokenFunc (MethodBase method); - delegate Guid GetGuidFunc (Module module); - - static Delegate create_delegate (Type type, Type delegate_type, string name) - { - MethodInfo mi = type.GetMethod (name, BindingFlags.Static | - BindingFlags.NonPublic); - if (mi == null) - throw new Exception ("Can't find " + name); - - return Delegate.CreateDelegate (delegate_type, mi); - } - - static MonoDebuggerSupport () - { - get_method_token = (GetMethodTokenFunc) create_delegate ( - typeof (Assembly), typeof (GetMethodTokenFunc), - "MonoDebugger_GetMethodToken"); - - get_guid = (GetGuidFunc) create_delegate ( - typeof (Module), typeof (GetGuidFunc), "Mono_GetGuid"); - } - - public static int GetMethodToken (MethodBase method) - { - return get_method_token (method); - } - - public static Guid GetGuid (Module module) - { - return get_guid (module); - } - } -#endif - public class MonoSymbolFile : IDisposable { List methods = new List (); @@ -163,7 +125,6 @@ namespace Mono.CompilerServices.SymbolWriter int last_method_index; int last_namespace_index; - public readonly string FileName = ""; public readonly int MajorVersion = OffsetTable.MajorVersion; public readonly int MinorVersion = OffsetTable.MinorVersion; @@ -369,10 +330,8 @@ namespace Mono.CompilerServices.SymbolWriter Guid guid; - MonoSymbolFile (string filename) + MonoSymbolFile (Stream stream) { - this.FileName = filename; - FileStream stream = new FileStream (filename, FileMode.Open, FileAccess.Read); reader = new MyBinaryReader (stream); try { @@ -381,89 +340,56 @@ namespace Mono.CompilerServices.SymbolWriter int minor_version = reader.ReadInt32 (); if (magic != OffsetTable.Magic) - throw new MonoSymbolFileException ( - "Symbol file `{0}' is not a valid " + - "Mono symbol file", filename); + throw new MonoSymbolFileException ("Symbol file is not a valid"); if (major_version != OffsetTable.MajorVersion) throw new MonoSymbolFileException ( - "Symbol file `{0}' has version {1}, " + - "but expected {2}", filename, major_version, - OffsetTable.MajorVersion); + "Symbol file has version {0} but expected {1}", major_version, OffsetTable.MajorVersion); if (minor_version != OffsetTable.MinorVersion) - throw new MonoSymbolFileException ( - "Symbol file `{0}' has version {1}.{2}, " + - "but expected {3}.{4}", filename, major_version, - minor_version, OffsetTable.MajorVersion, - OffsetTable.MinorVersion); + throw new MonoSymbolFileException ("Symbol file has version {0}.{1} but expected {2}.{3}", + major_version, minor_version, + OffsetTable.MajorVersion, OffsetTable.MinorVersion); MajorVersion = major_version; MinorVersion = minor_version; guid = new Guid (reader.ReadBytes (16)); ot = new OffsetTable (reader, major_version, minor_version); - } catch { - throw new MonoSymbolFileException ( - "Cannot read symbol file `{0}'", filename); + } catch (Exception e) { + throw new MonoSymbolFileException ("Cannot read symbol file", e); } source_file_hash = new Dictionary (); compile_unit_hash = new Dictionary (); } - void CheckGuidMatch (Guid other, string filename, string assembly) + public static MonoSymbolFile ReadSymbolFile (Assembly assembly) { - if (other == guid) - return; - - throw new MonoSymbolFileException ( - "Symbol file `{0}' does not match assembly `{1}'", - filename, assembly); - } + string filename = assembly.Location; + string name = filename + ".mdb"; -#if CECIL - protected MonoSymbolFile (string filename, Mono.Cecil.ModuleDefinition module) - : this (filename) - { - CheckGuidMatch (module.Mvid, filename, module.FullyQualifiedName); - } + Module[] modules = assembly.GetModules (); + Guid assembly_guid = modules[0].ModuleVersionId; - public static MonoSymbolFile ReadSymbolFile (Mono.Cecil.ModuleDefinition module) - { - return ReadSymbolFile (module, module.FullyQualifiedName); + return ReadSymbolFile (name, assembly_guid); } - public static MonoSymbolFile ReadSymbolFile (Mono.Cecil.ModuleDefinition module, string filename) - { - string name = filename + ".mdb"; - - return new MonoSymbolFile (name, module); - } -#else - protected MonoSymbolFile (string filename, Assembly assembly) : this (filename) + public static MonoSymbolFile ReadSymbolFile (string mdbFilename) { - // Check that the MDB file matches the assembly, if we have been - // passed an assembly. - if (assembly == null) - return; - - Module[] modules = assembly.GetModules (); - Guid assembly_guid = MonoDebuggerSupport.GetGuid (modules [0]); - - CheckGuidMatch (assembly_guid, filename, assembly.Location); + return ReadSymbolFile (new FileStream (mdbFilename, FileMode.Open, FileAccess.Read)); } - public static MonoSymbolFile ReadSymbolFile (Assembly assembly) + public static MonoSymbolFile ReadSymbolFile (string mdbFilename, Guid assemblyGuid) { - string filename = assembly.Location; - string name = filename + ".mdb"; + var sf = ReadSymbolFile (mdbFilename); + if (assemblyGuid != sf.guid) + throw new MonoSymbolFileException ("Symbol file `{0}' does not match assembly", mdbFilename); - return new MonoSymbolFile (name, assembly); + return sf; } -#endif - public static MonoSymbolFile ReadSymbolFile (string mdbFilename) + public static MonoSymbolFile ReadSymbolFile (Stream stream) { - return new MonoSymbolFile (mdbFilename, null); + return new MonoSymbolFile (stream); } public int CompileUnitCount { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs index ef40dfbfe..c9beaa0d4 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs @@ -551,7 +551,6 @@ namespace Mono.CompilerServices.SymbolWriter } } - [Obsolete] public int DefineNamespace (string name, string[] using_clauses, int parent) { if (!creating) @@ -921,9 +920,7 @@ namespace Mono.CompilerServices.SymbolWriter (opcode <= DW_LNE_MONO__extensions_end)) { ; // reserved for future extensions } else { - throw new MonoSymbolFileException ( - "Unknown extended opcode {0:x} in LNT ({1})", - opcode, file.FileName); + throw new MonoSymbolFileException ("Unknown extended opcode {0:x}", opcode); } br.BaseStream.Position = end_pos; @@ -1113,7 +1110,7 @@ namespace Mono.CompilerServices.SymbolWriter } } - void CheckLineNumberTable (LineNumberEntry[] line_numbers) + static void CheckLineNumberTable (LineNumberEntry[] line_numbers) { int last_offset = -1; int last_row = -1; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolWriter.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolWriter.cs index d1783bbf7..199ef41d5 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolWriter.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolWriter.cs @@ -153,7 +153,6 @@ namespace Mono.CompilerServices.SymbolWriter return entry; } - [Obsolete] public int DefineNamespace (string name, CompileUnitEntry unit, string[] using_clauses, int parent) { @@ -240,174 +239,4 @@ namespace Mono.CompilerServices.SymbolWriter } } } - - public class SourceMethodBuilder - { - List _locals; - List _blocks; - List _scope_vars; -#if NET_2_1 - System.Collections.Stack _block_stack; -#else - Stack _block_stack; -#endif - List method_lines; - - string _real_name; - IMethodDef _method; - ICompileUnit _comp_unit; -// MethodEntry.Flags _method_flags; - int _ns_id; - - public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method) - { - this._comp_unit = comp_unit; - this._method = method; - this._ns_id = ns_id; - method_lines = new List (); - } - - public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden) - { - int file_idx = file != null ? file.Index : 0; - var lne = new LineNumberEntry (file_idx, line, offset, is_hidden); - - if (method_lines.Count > 0) { - var prev = method_lines[method_lines.Count - 1]; - - // - // Same offset cannot be used for multiple lines - // - if (prev.Offset == offset) { - // - // Use the new location because debugger will adjust - // the breakpoint to next line with sequence point - // - if (LineNumberEntry.LocationComparer.Default.Compare (lne, prev) > 0) - method_lines[method_lines.Count - 1] = lne; - - return; - } - } - - method_lines.Add (lne); - } - - public void StartBlock (CodeBlockEntry.Type type, int start_offset) - { - if (_block_stack == null) { -#if NET_2_1 - _block_stack = new System.Collections.Stack (); -#else - _block_stack = new Stack (); -#endif - } - - if (_blocks == null) - _blocks = new List (); - - int parent = CurrentBlock != null ? CurrentBlock.Index : -1; - - CodeBlockEntry block = new CodeBlockEntry ( - _blocks.Count + 1, parent, type, start_offset); - - _block_stack.Push (block); - _blocks.Add (block); - } - - public void EndBlock (int end_offset) - { - CodeBlockEntry block = (CodeBlockEntry) _block_stack.Pop (); - block.Close (end_offset); - } - - public CodeBlockEntry[] Blocks { - get { - if (_blocks == null) - return new CodeBlockEntry [0]; - - CodeBlockEntry[] retval = new CodeBlockEntry [_blocks.Count]; - _blocks.CopyTo (retval, 0); - return retval; - } - } - - public CodeBlockEntry CurrentBlock { - get { - if ((_block_stack != null) && (_block_stack.Count > 0)) - return (CodeBlockEntry) _block_stack.Peek (); - else - return null; - } - } - - public LocalVariableEntry[] Locals { - get { - if (_locals == null) - return new LocalVariableEntry [0]; - else { - LocalVariableEntry[] retval = - new LocalVariableEntry [_locals.Count]; - _locals.CopyTo (retval, 0); - return retval; - } - } - } - - public void AddLocal (int index, string name) - { - if (_locals == null) - _locals = new List (); - int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0; - _locals.Add (new LocalVariableEntry (index, name, block_idx)); - } - - public ScopeVariable[] ScopeVariables { - get { - if (_scope_vars == null) - return new ScopeVariable [0]; - - ScopeVariable[] retval = new ScopeVariable [_scope_vars.Count]; - _scope_vars.CopyTo (retval); - return retval; - } - } - - public void AddScopeVariable (int scope, int index) - { - if (_scope_vars == null) - _scope_vars = new List (); - _scope_vars.Add ( - new ScopeVariable (scope, index)); - } - - [Obsolete] - public string RealMethodName { - get { return _real_name; } - } - - [Obsolete ("It has no meaning")] - public void SetRealMethodName (string name) - { - _real_name = name; - } - - public ICompileUnit SourceFile { - get { return _comp_unit; } - } - - public IMethodDef Method { - get { return _method; } - } - - public void DefineMethod (MonoSymbolFile file) - { - MethodEntry entry = new MethodEntry ( - file, _comp_unit.Entry, _method.Token, ScopeVariables, - Locals, method_lines.ToArray (), Blocks, _real_name, 0, //_method_flags, - _ns_id); - - file.AddMethod (entry); - } - } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/SourceMethodBuilder.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/SourceMethodBuilder.cs new file mode 100644 index 000000000..1ff399cdc --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/SourceMethodBuilder.cs @@ -0,0 +1,193 @@ +// +// SourceMethodBuilder.cs +// +// Authors: +// Martin Baulig (martin@ximian.com) +// Marek Safar (marek.safar@gmail.com) +// +// (C) 2002 Ximian, Inc. http://www.ximian.com +// Copyright (C) 2012 Xamarin Inc (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.Collections.Generic; + +namespace Mono.CompilerServices.SymbolWriter +{ + public class SourceMethodBuilder + { + List _locals; + List _blocks; + List _scope_vars; +#if NET_2_1 + System.Collections.Stack _block_stack; +#else + Stack _block_stack; +#endif + readonly List method_lines; + + readonly ICompileUnit _comp_unit; + readonly int ns_id; + readonly IMethodDef method; + + public SourceMethodBuilder (ICompileUnit comp_unit) + { + this._comp_unit = comp_unit; + method_lines = new List (); + } + + public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method) + : this (comp_unit) + { + this.ns_id = ns_id; + this.method = method; + } + + public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden) + { + int file_idx = file != null ? file.Index : 0; + var lne = new LineNumberEntry (file_idx, line, offset, is_hidden); + + if (method_lines.Count > 0) { + var prev = method_lines[method_lines.Count - 1]; + + // + // Same offset cannot be used for multiple lines + // + if (prev.Offset == offset) { + // + // Use the new location because debugger will adjust + // the breakpoint to next line with sequence point + // + if (LineNumberEntry.LocationComparer.Default.Compare (lne, prev) > 0) + method_lines[method_lines.Count - 1] = lne; + + return; + } + } + + method_lines.Add (lne); + } + + public void StartBlock (CodeBlockEntry.Type type, int start_offset) + { + if (_block_stack == null) { +#if NET_2_1 + _block_stack = new System.Collections.Stack (); +#else + _block_stack = new Stack (); +#endif + } + + if (_blocks == null) + _blocks = new List (); + + int parent = CurrentBlock != null ? CurrentBlock.Index : -1; + + CodeBlockEntry block = new CodeBlockEntry ( + _blocks.Count + 1, parent, type, start_offset); + + _block_stack.Push (block); + _blocks.Add (block); + } + + public void EndBlock (int end_offset) + { + CodeBlockEntry block = (CodeBlockEntry) _block_stack.Pop (); + block.Close (end_offset); + } + + public CodeBlockEntry[] Blocks { + get { + if (_blocks == null) + return new CodeBlockEntry [0]; + + CodeBlockEntry[] retval = new CodeBlockEntry [_blocks.Count]; + _blocks.CopyTo (retval, 0); + return retval; + } + } + + public CodeBlockEntry CurrentBlock { + get { + if ((_block_stack != null) && (_block_stack.Count > 0)) + return (CodeBlockEntry) _block_stack.Peek (); + else + return null; + } + } + + public LocalVariableEntry[] Locals { + get { + if (_locals == null) + return new LocalVariableEntry [0]; + else { + return _locals.ToArray (); + } + } + } + + public ICompileUnit SourceFile { + get { + return _comp_unit; + } + } + + public void AddLocal (int index, string name) + { + if (_locals == null) + _locals = new List (); + int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0; + _locals.Add (new LocalVariableEntry (index, name, block_idx)); + } + + public ScopeVariable[] ScopeVariables { + get { + if (_scope_vars == null) + return new ScopeVariable [0]; + + return _scope_vars.ToArray (); + } + } + + public void AddScopeVariable (int scope, int index) + { + if (_scope_vars == null) + _scope_vars = new List (); + _scope_vars.Add ( + new ScopeVariable (scope, index)); + } + + public void DefineMethod (MonoSymbolFile file) + { + DefineMethod (file, method.Token); + } + + public void DefineMethod (MonoSymbolFile file, int token) + { + MethodEntry entry = new MethodEntry ( + file, _comp_unit.Entry, token, ScopeVariables, + Locals, method_lines.ToArray (), Blocks, null, 0, ns_id); + + file.AddMethod (entry); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs index 6d59cc6cc..7ef97558f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs @@ -12,6 +12,8 @@ using System; using System.Collections.Generic; +using Mono.CompilerServices.SymbolWriter; +using System.Diagnostics; #if STATIC using IKVM.Reflection; @@ -24,11 +26,20 @@ using System.Reflection.Emit; namespace Mono.CSharp { - public abstract class CompilerGeneratedClass : Class + public abstract class CompilerGeneratedContainer : ClassOrStruct { - protected CompilerGeneratedClass (TypeContainer parent, MemberName name, Modifiers mod) - : base (parent, name, mod | Modifiers.COMPILER_GENERATED, null) + protected CompilerGeneratedContainer (TypeContainer parent, MemberName name, Modifiers mod) + : this (parent, name, mod, MemberKind.Class) + { + } + + protected CompilerGeneratedContainer (TypeContainer parent, MemberName name, Modifiers mod, MemberKind kind) + : base (parent, name, null, kind) { + Debug.Assert ((mod & Modifiers.AccessibilityMask) != 0); + + ModFlags = mod | Modifiers.COMPILER_GENERATED | Modifiers.SEALED; + spec = new TypeSpec (Kind, null, this, null, ModFlags); } protected void CheckMembersDefined () @@ -37,6 +48,15 @@ namespace Mono.CSharp { throw new InternalErrorException ("Helper class already defined!"); } + protected override bool DoDefineMembers () + { + if (Kind == MemberKind.Class && !IsStatic && !PartialContainer.HasInstanceConstructor) { + DefineDefaultConstructor (false); + } + + return base.DoDefineMembers (); + } + protected static MemberName MakeMemberName (MemberBase host, string name, int unique_id, TypeParameters tparams, Location loc) { string host_name = host == null ? null : host is InterfaceMemberBase ? ((InterfaceMemberBase)host).GetFullName (host.MemberName) : host.MemberName.Name; @@ -58,9 +78,17 @@ namespace Mono.CSharp { { return "<" + host + ">" + typePrefix + "__" + name + id.ToString ("X"); } + + protected override TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class) + { + base_type = Compiler.BuiltinTypes.Object; + + base_class = null; + return null; + } } - public class HoistedStoreyClass : CompilerGeneratedClass + public class HoistedStoreyClass : CompilerGeneratedContainer { public sealed class HoistedField : Field { @@ -85,8 +113,8 @@ namespace Mono.CSharp { protected TypeParameterMutator mutator; - public HoistedStoreyClass (TypeDefinition parent, MemberName name, TypeParameters tparams, Modifiers mod) - : base (parent, name, mod | Modifiers.PRIVATE) + public HoistedStoreyClass (TypeDefinition parent, MemberName name, TypeParameters tparams, Modifiers mods, MemberKind kind) + : base (parent, name, mods | Modifiers.PRIVATE, kind) { if (tparams != null) { @@ -172,7 +200,7 @@ namespace Mono.CSharp { protected override void DoEmit (EmitContext ec) { - hoisted_this.EmitHoistingAssignment (ec); + hoisted_this.EmitAssign (ec, new CompilerGeneratedThis (ec.CurrentType, loc), false, false); } protected override void CloneTo (CloneContext clonectx, Statement target) @@ -184,7 +212,7 @@ namespace Mono.CSharp { // Unique storey ID public readonly int ID; - public readonly Block OriginalSourceBlock; + public readonly ExplicitBlock OriginalSourceBlock; // A list of StoreyFieldPair with local field keeping parent storey instance List used_parent_storeys; @@ -192,6 +220,7 @@ namespace Mono.CSharp { // A list of hoisted parameters protected List hoisted_params; + List hoisted_local_params; protected List hoisted_locals; // Hoisted this @@ -200,9 +229,11 @@ namespace Mono.CSharp { // Local variable which holds this storey instance public Expression Instance; - public AnonymousMethodStorey (Block block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name) + bool initialize_hoisted_this; + + public AnonymousMethodStorey (ExplicitBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind) : base (parent, MakeMemberName (host, name, parent.Module.CounterAnonymousContainers, tparams, block.StartLocation), - tparams, Modifiers.SEALED) + tparams, 0, kind) { OriginalSourceBlock = block; ID = parent.Module.CounterAnonymousContainers++; @@ -211,18 +242,10 @@ namespace Mono.CSharp { public void AddCapturedThisField (EmitContext ec) { TypeExpr type_expr = new TypeExpression (ec.CurrentType, Location); - Field f = AddCompilerGeneratedField ("<>f__this", type_expr); - f.Define (); + Field f = AddCompilerGeneratedField ("$this", type_expr); hoisted_this = new HoistedThis (this, f); - // Inflated type instance has to be updated manually - if (Instance.Type is InflatedTypeSpec) { - var inflator = new TypeParameterInflator (this, Instance.Type, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); - Instance.Type.MemberCache.AddMember (f.Spec.InflateMember (inflator)); - - inflator = new TypeParameterInflator (this, f.Parent.CurrentType, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); - f.Parent.CurrentType.MemberCache.AddMember (f.Spec.InflateMember (inflator)); - } + initialize_hoisted_this = true; } public Field AddCapturedVariable (string name, TypeSpec type) @@ -282,38 +305,93 @@ namespace Mono.CSharp { used_parent_storeys.Add (new StoreyFieldPair (storey, f)); } - public void CaptureLocalVariable (ResolveContext ec, LocalVariable local_info) + public void CaptureLocalVariable (ResolveContext ec, LocalVariable localVariable) { - ec.CurrentBlock.Explicit.HasCapturedVariable = true; - if (ec.CurrentBlock.Explicit != local_info.Block.Explicit) - AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit); + if (this is StateMachine) { + if (ec.CurrentBlock.ParametersBlock != localVariable.Block.ParametersBlock) + ec.CurrentBlock.Explicit.HasCapturedVariable = true; + } else { + ec.CurrentBlock.Explicit.HasCapturedVariable = true; + } - if (local_info.HoistedVariant != null) - return; + var hoisted = localVariable.HoistedVariant; + if (hoisted != null && hoisted.Storey != this && hoisted.Storey.Kind == MemberKind.Struct) { + // TODO: It's too late the field is defined in HoistedLocalVariable ctor + hoisted.Storey.hoisted_locals.Remove (hoisted); + hoisted = null; + } + + if (hoisted == null) { + hoisted = new HoistedLocalVariable (this, localVariable, GetVariableMangledName (localVariable)); + localVariable.HoistedVariant = hoisted; - HoistedVariable var = new HoistedLocalVariable (this, local_info, GetVariableMangledName (local_info)); - local_info.HoistedVariant = var; + if (hoisted_locals == null) + hoisted_locals = new List (); - if (hoisted_locals == null) - hoisted_locals = new List (); + hoisted_locals.Add (hoisted); + } - hoisted_locals.Add (var); + if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit) + hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit); } - public void CaptureParameter (ResolveContext ec, ParameterReference param_ref) + public void CaptureParameter (ResolveContext ec, ParametersBlock.ParameterInfo parameterInfo, ParameterReference parameterReference) { - ec.CurrentBlock.Explicit.HasCapturedVariable = true; - AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit); + if (!(this is StateMachine)) { + ec.CurrentBlock.Explicit.HasCapturedVariable = true; + } - if (param_ref.GetHoistedVariable (ec) != null) - return; + var hoisted = parameterInfo.Parameter.HoistedVariant; + + if (parameterInfo.Block.StateMachine is AsyncTaskStorey) { + // + // Another storey in same block exists but state machine does not + // have parameter captured. We need to add it there as well to + // proxy parameter value correctly. + // + if (hoisted == null && parameterInfo.Block.StateMachine != this) { + var storey = parameterInfo.Block.StateMachine; + + hoisted = new HoistedParameter (storey, parameterReference); + parameterInfo.Parameter.HoistedVariant = hoisted; + + if (storey.hoisted_params == null) + storey.hoisted_params = new List (); + + storey.hoisted_params.Add (hoisted); + } + + // + // Lift captured parameter from value type storey to reference type one. Otherwise + // any side effects would be done on a copy + // + if (hoisted != null && hoisted.Storey != this && hoisted.Storey.Kind == MemberKind.Struct) { + if (hoisted_local_params == null) + hoisted_local_params = new List (); - if (hoisted_params == null) - hoisted_params = new List (2); + hoisted_local_params.Add (hoisted); + hoisted = null; + } + } - var expr = new HoistedParameter (this, param_ref); - param_ref.Parameter.HoistedVariant = expr; - hoisted_params.Add (expr); + if (hoisted == null) { + hoisted = new HoistedParameter (this, parameterReference); + parameterInfo.Parameter.HoistedVariant = hoisted; + + if (hoisted_params == null) + hoisted_params = new List (); + + hoisted_params.Add (hoisted); + } + + // + // Register link between current block and parameter storey. It will + // be used when setting up storey definition to deploy storey reference + // when parameters are used from multiple blocks + // + if (ec.CurrentBlock.Explicit != parameterInfo.Block) { + hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit); + } } TypeExpr CreateStoreyTypeExpression (EmitContext ec) @@ -397,8 +475,6 @@ namespace Mono.CSharp { if (Instance != null) throw new InternalErrorException (); - SymbolWriter.OpenCompilerGeneratedBlock (ec); - // // Create an instance of this storey // @@ -427,11 +503,14 @@ namespace Mono.CSharp { var fexpr = new FieldExpr (field, Location); fexpr.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, Location); fexpr.EmitAssign (ec, source, false, false); - Instance = fexpr; } else { var local = TemporaryVariableReference.Create (source.Type, block, Location); - local.EmitAssign (ec, source); + if (source.Type.IsStruct) { + local.LocalInfo.CreateBuilder (ec); + } else { + local.EmitAssign (ec, source); + } Instance = local; } @@ -440,8 +519,6 @@ namespace Mono.CSharp { // TODO: Implement properly //SymbolWriter.DefineScopeVariable (ID, Instance.Builder); - - SymbolWriter.CloseCompilerGeneratedBlock (ec); } void EmitHoistedFieldsInitialization (ResolveContext rc, EmitContext ec) @@ -462,6 +539,7 @@ namespace Mono.CSharp { FieldExpr f_set_expr = new FieldExpr (fs, Location); f_set_expr.InstanceExpression = instace_expr; + // TODO: CompilerAssign expression SimpleAssign a = new SimpleAssign (f_set_expr, sf.Storey.GetStoreyInstanceExpression (ec)); if (a.Resolve (rc) != null) a.EmitStatement (ec); @@ -469,10 +547,10 @@ namespace Mono.CSharp { } // - // Define hoisted `this' in top-level storey only + // Initialize hoisted `this' only once, everywhere else will be + // referenced indirectly // - if (OriginalSourceBlock.Explicit.HasCapturedThis && !(Parent is AnonymousMethodStorey)) { - AddCapturedThisField (ec); + if (initialize_hoisted_this) { rc.CurrentBlock.AddScopeStatement (new ThisInitializer (hoisted_this)); } @@ -489,36 +567,21 @@ namespace Mono.CSharp { ec.CurrentAnonymousMethod = ae; } - protected virtual void EmitHoistedParameters (EmitContext ec, IList hoisted) + protected virtual void EmitHoistedParameters (EmitContext ec, List hoisted) { foreach (HoistedParameter hp in hoisted) { - hp.EmitHoistingAssignment (ec); - } - } - - public override void Emit () - { - base.Emit (); - - SymbolWriter.DefineAnonymousScope (ID); - - if (hoisted_this != null) - hoisted_this.EmitSymbolInfo (); - - if (hoisted_locals != null) { - foreach (HoistedVariable local in hoisted_locals) - local.EmitSymbolInfo (); - } - - if (hoisted_params != null) { - foreach (HoistedParameter param in hoisted_params) - param.EmitSymbolInfo (); - } - - if (used_parent_storeys != null) { - foreach (StoreyFieldPair sf in used_parent_storeys) { - SymbolWriter.DefineCapturedScope (ID, sf.Storey.ID, sf.Field.Name); + // + // Parameters could be proxied via local fields for value type storey + // + if (hoisted_local_params != null) { + var local_param = hoisted_local_params.Find (l => l.Parameter.Parameter == hp.Parameter.Parameter); + var source = new FieldExpr (local_param.Field, Location); + source.InstanceExpression = new CompilerGeneratedThis (CurrentType, Location); + hp.EmitAssign (ec, source, false, false); + continue; } + + hp.EmitHoistingAssignment (ec); } } @@ -590,7 +653,12 @@ namespace Mono.CSharp { } public HoistedThis HoistedThis { - get { return hoisted_this; } + get { + return hoisted_this; + } + set { + hoisted_this = value; + } } public IList ReferencesFromChildrenBlock { @@ -658,6 +726,12 @@ namespace Mono.CSharp { this.field = field; } + public AnonymousMethodStorey Storey { + get { + return storey; + } + } + public void AddressOf (EmitContext ec, AddressOp mode) { GetFieldExpression (ec).AddressOf (ec, mode); @@ -726,8 +800,6 @@ namespace Mono.CSharp { return inner_access; } - public abstract void EmitSymbolInfo (); - public void Emit (EmitContext ec, bool leave_copy) { GetFieldExpression (ec).Emit (ec, leave_copy); @@ -741,7 +813,7 @@ namespace Mono.CSharp { public class HoistedParameter : HoistedVariable { - sealed class HoistedFieldAssign : Assign + sealed class HoistedFieldAssign : CompilerAssign { public HoistedFieldAssign (Expression target, Expression source) : base (target, source, source.Location) @@ -772,52 +844,42 @@ namespace Mono.CSharp { this.parameter = hp.parameter; } + #region Properties + + public Field Field { + get { + return field; + } + } + + public ParameterReference Parameter { + get { + return parameter; + } + } + + #endregion + public void EmitHoistingAssignment (EmitContext ec) { // // Remove hoisted redirection to emit assignment from original parameter // - HoistedVariable temp = parameter.Parameter.HoistedVariant; + var temp = parameter.Parameter.HoistedVariant; parameter.Parameter.HoistedVariant = null; - Assign a = new HoistedFieldAssign (GetFieldExpression (ec), parameter); - if (a.Resolve (new ResolveContext (ec.MemberContext)) != null) - a.EmitStatement (ec); + var a = new HoistedFieldAssign (GetFieldExpression (ec), parameter); + a.EmitStatement (ec); parameter.Parameter.HoistedVariant = temp; } - - public override void EmitSymbolInfo () - { - SymbolWriter.DefineCapturedParameter (storey.ID, field.Name, field.Name); - } - - public Field Field { - get { return field; } - } } class HoistedLocalVariable : HoistedVariable { - readonly string name; - public HoistedLocalVariable (AnonymousMethodStorey storey, LocalVariable local, string name) : base (storey, name, local.Type) { - this.name = local.Name; - } - - // - // For compiler generated local variables - // - public HoistedLocalVariable (AnonymousMethodStorey storey, Field field) - : base (storey, field) - { - } - - public override void EmitSymbolInfo () - { - SymbolWriter.DefineCapturedLocal (storey.ID, name, field.Name); } } @@ -828,20 +890,10 @@ namespace Mono.CSharp { { } - public void EmitHoistingAssignment (EmitContext ec) - { - SimpleAssign a = new SimpleAssign (GetFieldExpression (ec), new CompilerGeneratedThis (ec.CurrentType, field.Location)); - if (a.Resolve (new ResolveContext (ec.MemberContext)) != null) - a.EmitStatement (ec); - } - - public override void EmitSymbolInfo () - { - SymbolWriter.DefineCapturedThis (storey.ID, field.Name); - } - public Field Field { - get { return field; } + get { + return field; + } } } @@ -1057,12 +1109,8 @@ namespace Mono.CSharp { } using (ec.Set (ResolveContext.Options.ProbingMode | ResolveContext.Options.InferReturnType)) { - var body = CompatibleMethodBody (ec, tic, InternalType.Arglist, delegate_type); + var body = CompatibleMethodBody (ec, tic, null, delegate_type); if (body != null) { - if (Block.IsAsync) { - AsyncInitializer.Create (ec, body.Block, body.Parameters, ec.CurrentMemberDefinition.Parent.PartialContainer, null, loc); - } - am = body.Compatible (ec, body); } else { am = null; @@ -1134,6 +1182,10 @@ namespace Mono.CSharp { } else { int errors = ec.Report.Errors; + if (Block.IsAsync) { + ec.Report.Error (1989, loc, "Async lambda expressions cannot be converted to expression trees"); + } + using (ec.Set (ResolveContext.Options.ExpressionTreeConversion)) { am = body.Compatible (ec); } @@ -1145,22 +1197,12 @@ namespace Mono.CSharp { am = CreateExpressionTree (ec, delegate_type); } } else { - if (Block.IsAsync) { - var rt = body.ReturnType; - if (rt.Kind != MemberKind.Void && - rt != ec.Module.PredefinedTypes.Task.TypeSpec && - !rt.IsGenericTask) { - ec.Report.Error (4010, loc, "Cannot convert async {0} to delegate type `{1}'", - GetSignatureForError (), type.GetSignatureForError ()); - } - - AsyncInitializer.Create (ec, body.Block, body.Parameters, ec.CurrentMemberDefinition.Parent.PartialContainer, rt, loc); - } - am = body.Compatible (ec); } } catch (CompletionResult) { throw; + } catch (FatalException) { + throw; } catch (Exception e) { throw new InternalErrorException (e, loc); } @@ -1195,7 +1237,7 @@ namespace Mono.CSharp { for (int i = 0; i < delegate_parameters.Count; i++) { Parameter.Modifier i_mod = delegate_parameters.FixedParameters [i].ModFlags; - if (i_mod == Parameter.Modifier.OUT) { + if ((i_mod & Parameter.Modifier.OUT) != 0) { if (!ec.IsInProbingMode) { ec.Report.Error (1688, loc, "Cannot convert anonymous method block without a parameter list to delegate type `{0}' because it has one or more `out' parameters", @@ -1282,7 +1324,19 @@ namespace Mono.CSharp { ParametersBlock b = ec.IsInProbingMode ? (ParametersBlock) Block.PerformClone () : Block; - return CompatibleMethodFactory (return_type, delegate_type, p, b); + if (b.IsAsync) { + var rt = return_type; + if (rt != null && rt.Kind != MemberKind.Void && rt != ec.Module.PredefinedTypes.Task.TypeSpec && !rt.IsGenericTask) { + ec.Report.Error (4010, loc, "Cannot convert async {0} to delegate type `{1}'", + GetSignatureForError (), delegate_type.GetSignatureForError ()); + + return null; + } + + b = b.ConvertToAsyncTask (ec, ec.CurrentMemberDefinition.Parent.PartialContainer, p, return_type, loc); + } + + return CompatibleMethodFactory (return_type ?? InternalType.Arglist, delegate_type, p, b); } protected virtual AnonymousMethodBody CompatibleMethodFactory (TypeSpec return_type, TypeSpec delegate_type, ParametersCompiled p, ParametersBlock b) @@ -1327,9 +1381,9 @@ namespace Mono.CSharp { Block = new ToplevelBlock (am.block, parameters); } - public override EmitContext CreateEmitContext (ILGenerator ig) + public override EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod) { - EmitContext ec = new EmitContext (this, ig, ReturnType); + EmitContext ec = new EmitContext (this, ig, ReturnType, sourceMethod); ec.CurrentAnonymousMethod = AnonymousMethod; return ec; } @@ -1382,6 +1436,15 @@ namespace Mono.CSharp { public abstract bool IsIterator { get; } public abstract AnonymousMethodStorey Storey { get; } + // + // The block that makes up the body for the anonymous method + // + public ParametersBlock Block { + get { + return block; + } + } + public AnonymousExpression Compatible (ResolveContext ec) { return Compatible (ec, this); @@ -1455,16 +1518,6 @@ namespace Mono.CSharp { b = b.Parent == null ? null : b.Parent.Explicit; } while (b != null); } - - // - // The block that makes up the body for the anonymous method - // - public ParametersBlock Block { - get { - return block; - } - } - } public class AnonymousMethodBody : AnonymousExpression @@ -1552,19 +1605,49 @@ namespace Mono.CSharp { // Modifiers modifiers; - if (Block.HasCapturedVariable || Block.HasCapturedThis) { - storey = FindBestMethodStorey (); + TypeDefinition parent = null; + + var src_block = Block.Original.Explicit; + if (src_block.HasCapturedVariable || src_block.HasCapturedThis) { + parent = storey = FindBestMethodStorey (); + + if (storey == null) { + var sm = src_block.ParametersBlock.TopBlock.StateMachine; + + // + // Remove hoisted this demand when simple instance method is enough + // + if (src_block.HasCapturedThis) { + src_block.ParametersBlock.TopBlock.RemoveThisReferenceFromChildrenBlock (src_block); + + // + // Special case where parent class is used to emit instance method + // because currect storey is of value type (async host) and we don't + // want to create another childer storey to host this reference only + // + if (sm != null && sm.Kind == MemberKind.Struct) + parent = sm.Parent.PartialContainer; + } + + // + // For iterators we can host everything in one class + // + if (sm is IteratorStorey) + parent = storey = sm; + } + modifiers = storey != null ? Modifiers.INTERNAL : Modifiers.PRIVATE; } else { if (ec.CurrentAnonymousMethod != null) - storey = ec.CurrentAnonymousMethod.Storey; + parent = storey = ec.CurrentAnonymousMethod.Storey; modifiers = Modifiers.STATIC | Modifiers.PRIVATE; } - var parent = storey != null ? storey : ec.CurrentTypeDefinition.Parent.PartialContainer; + if (parent == null) + parent = ec.CurrentTypeDefinition.Parent.PartialContainer; - string name = CompilerGeneratedClass.MakeName (parent != storey ? block_name : null, + string name = CompilerGeneratedContainer.MakeName (parent != storey ? block_name : null, "m", null, ec.Module.CounterAnonymousMethods++); MemberName member_name; @@ -1622,7 +1705,7 @@ namespace Mono.CSharp { am_cache = new Field (parent, new TypeExpression (cache_type, loc), Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, - new MemberName (CompilerGeneratedClass.MakeName (null, "f", "am$cache", id), loc), null); + new MemberName (CompilerGeneratedContainer.MakeName (null, "f", "am$cache", id), loc), null); am_cache.Define (); parent.AddField (am_cache); } else { @@ -1662,10 +1745,22 @@ namespace Mono.CSharp { ec.EmitNull (); } else if (storey != null) { Expression e = storey.GetStoreyInstanceExpression (ec).Resolve (new ResolveContext (ec.MemberContext)); - if (e != null) + if (e != null) { e.Emit (ec); + } } else { ec.EmitThis (); + + // + // Special case for value type storey where this is not lifted but + // droped off to parent class + // + for (var b = Block.Parent; b != null; b = b.Parent) { + if (b.ParametersBlock.StateMachine != null) { + ec.Emit (OpCodes.Ldfld, b.ParametersBlock.StateMachine.HoistedThis.Field.Spec); + break; + } + } } var delegate_method = method.Spec; @@ -1676,9 +1771,7 @@ namespace Mono.CSharp { // Mutate anonymous method instance type if we are in nested // hoisted generic anonymous method storey // - if (ec.CurrentAnonymousMethod != null && - ec.CurrentAnonymousMethod.Storey != null && - ec.CurrentAnonymousMethod.Storey.Mutator != null) { + if (ec.IsAnonymousStoreyMutateRequired) { t = storey.Mutator.Mutate (t); } @@ -1731,7 +1824,7 @@ namespace Mono.CSharp { // // Anonymous type container // - public class AnonymousTypeClass : CompilerGeneratedClass + public class AnonymousTypeClass : CompilerGeneratedContainer { public const string ClassNamePrefix = "<>__AnonType"; public const string SignatureForError = "anonymous type"; @@ -1739,7 +1832,7 @@ namespace Mono.CSharp { readonly IList parameters; private AnonymousTypeClass (ModuleContainer parent, MemberName name, IList parameters, Location loc) - : base (parent, name, (parent.Evaluator != null ? Modifiers.PUBLIC : 0) | Modifiers.SEALED) + : base (parent, name, parent.Evaluator != null ? Modifiers.PUBLIC : Modifiers.INTERNAL) { this.parameters = parameters; } @@ -1792,13 +1885,13 @@ namespace Mono.CSharp { c.Block = new ToplevelBlock (parent.Module.Compiler, c.ParameterInfo, loc); // - // Create fields and contructor body with field initialization + // Create fields and constructor body with field initialization // bool error = false; for (int i = 0; i < parameters.Count; ++i) { AnonymousTypeParameter p = parameters [i]; - Field f = new Field (a_type, t_args [i], Modifiers.PRIVATE | Modifiers.READONLY, + Field f = new Field (a_type, t_args [i], Modifiers.PRIVATE | Modifiers.READONLY | Modifiers.DEBUGGER_HIDDEN, new MemberName ("<" + p.Name + ">", p.Location), null); if (!a_type.AddField (f)) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs index a6fa8bd84..9da98b8a8 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs @@ -120,10 +120,14 @@ namespace Mono.CSharp ml.AddressOf (ec, mode); } - public Argument EmitToField (EmitContext ec) + public Argument EmitToField (EmitContext ec, bool cloneResult) { var res = Expr.EmitToField (ec); - return res == Expr ? this : new Argument (res, ArgType); + if (cloneResult && res != Expr) + return new Argument (res, ArgType); + + Expr = res; + return this; } public string GetSignatureForError () @@ -258,7 +262,7 @@ namespace Mono.CSharp { foreach (var a in ordered) { if (prepareAwait) - a.EmitToField (ec); + a.EmitToField (ec, false); else a.EmitToVariable (ec); } @@ -440,7 +444,7 @@ namespace Mono.CSharp LocalTemporary lt; foreach (Argument a in args) { if (prepareAwait) { - dups.Add (a.EmitToField (ec)); + dups.Add (a.EmitToField (ec, true)); continue; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs index 0dad8ff0f..1cdbf4518 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs @@ -50,7 +50,7 @@ namespace Mono.CSharp // TODO: make it private and move all builder based methods here public AssemblyBuilder Builder; protected AssemblyBuilderExtension builder_extra; - MonoSymbolWriter symbol_writer; + MonoSymbolFile symbol_writer; bool is_cls_compliant; bool wrap_non_exception_throws; @@ -179,6 +179,12 @@ namespace Mono.CSharp } } + public MonoSymbolFile SymbolWriter { + get { + return symbol_writer; + } + } + #endregion public void AddModule (ImportedModuleDefinition module) @@ -446,10 +452,7 @@ namespace Mono.CSharp } if (Compiler.Settings.GenerateDebugInfo) { - symbol_writer = new MonoSymbolWriter (file_name); - - // TODO: global variables - SymbolWriter.symwriter = symbol_writer; + symbol_writer = new MonoSymbolFile (); } module.EmitContainer (); @@ -781,25 +784,38 @@ namespace Mono.CSharp public void Save () { - PortableExecutableKinds pekind; + PortableExecutableKinds pekind = PortableExecutableKinds.ILOnly; ImageFileMachine machine; switch (Compiler.Settings.Platform) { case Platform.X86: - pekind = PortableExecutableKinds.Required32Bit | PortableExecutableKinds.ILOnly; + pekind |= PortableExecutableKinds.Required32Bit; machine = ImageFileMachine.I386; break; case Platform.X64: - pekind = PortableExecutableKinds.ILOnly; + pekind |= PortableExecutableKinds.PE32Plus; machine = ImageFileMachine.AMD64; break; case Platform.IA64: - pekind = PortableExecutableKinds.ILOnly; machine = ImageFileMachine.IA64; break; + case Platform.AnyCPU32Preferred: +#if STATIC + pekind |= PortableExecutableKinds.Preferred32Bit; + machine = ImageFileMachine.I386; + break; +#else + throw new NotSupportedException (); +#endif + case Platform.Arm: +#if STATIC + machine = ImageFileMachine.ARM; + break; +#else + throw new NotSupportedException (); +#endif case Platform.AnyCPU: default: - pekind = PortableExecutableKinds.ILOnly; machine = ImageFileMachine.I386; break; } @@ -820,7 +836,21 @@ namespace Mono.CSharp if (symbol_writer != null && Compiler.Report.Errors == 0) { // TODO: it should run in parallel Compiler.TimeReporter.Start (TimeReporter.TimerType.DebugSave); - symbol_writer.WriteSymbolFile (SymbolWriter.GetGuid (module.Builder)); + + var filename = file_name + ".mdb"; + try { + // We mmap the file, so unlink the previous version since it may be in use + File.Delete (filename); + } catch { + // We can safely ignore + } + + module.WriteDebugSymbol (symbol_writer); + + using (FileStream fs = new FileStream (filename, FileMode.Create, FileAccess.Write)) { + symbol_writer.CreateSymbolFile (module.Builder.ModuleVersionId, fs); + } + Compiler.TimeReporter.Stop (TimeReporter.TimerType.DebugSave); } } @@ -980,7 +1010,7 @@ namespace Mono.CSharp // // A placeholder class for assembly attributes when emitting module // - class AssemblyAttributesPlaceholder : CompilerGeneratedClass + class AssemblyAttributesPlaceholder : CompilerGeneratedContainer { static readonly string TypeNamePrefix = "<$AssemblyAttributes${0}>"; public static readonly string AssemblyFieldName = "attributes"; @@ -988,7 +1018,7 @@ namespace Mono.CSharp Field assembly; public AssemblyAttributesPlaceholder (ModuleContainer parent, string outputName) - : base (parent, new MemberName (GetGeneratedName (outputName)), Modifiers.STATIC) + : base (parent, new MemberName (GetGeneratedName (outputName)), Modifiers.STATIC | Modifiers.INTERNAL) { assembly = new Field (this, new TypeExpression (parent.Compiler.BuiltinTypes.Object, Location), Modifiers.PUBLIC | Modifiers.STATIC, new MemberName (AssemblyFieldName), null); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs index c5feb0085..673d586d1 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs @@ -343,7 +343,7 @@ namespace Mono.CSharp { type = target_type; if (!(target is IAssignMethod)) { - Error_ValueAssignment (ec, source); + target.Error_ValueAssignment (ec, source); return null; } @@ -488,6 +488,10 @@ namespace Mono.CSharp { public CompilerAssign (Expression target, Expression source, Location loc) : base (target, source, loc) { + if (target.Type != null) { + type = target.Type; + eclass = ExprClass.Value; + } } protected override Expression DoResolve (ResolveContext ec) @@ -568,10 +572,10 @@ namespace Mono.CSharp { // // Emit sequence symbol info even if we are in compiler generated - // block to allow debugging filed initializers when constructor is + // block to allow debugging field initializers when constructor is // compiler generated // - if (ec.HasSet (BuilderContext.Options.OmitDebugInfo)) { + if (ec.HasSet (BuilderContext.Options.OmitDebugInfo) && ec.HasMethodSymbolBuilder) { using (ec.With (BuilderContext.Options.OmitDebugInfo, false)) { ec.Mark (loc); } @@ -822,7 +826,7 @@ namespace Mono.CSharp { return new SimpleAssign (target, new DynamicConversion (target_type, CSharpBinderFlags.ConvertExplicit, arg, loc), loc).Resolve (ec); } - right.Error_ValueCannotBeConverted (ec, loc, target_type, false); + right.Error_ValueCannotBeConverted (ec, target_type, false); return null; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs index dd75b1bbf..4c0cce612 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs @@ -46,6 +46,12 @@ namespace Mono.CSharp } } + public AwaitStatement Statement { + get { + return stmt; + } + } + protected override void CloneTo (CloneContext clonectx, Expression target) { var t = (Await) target; @@ -70,11 +76,6 @@ namespace Mono.CSharp "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) { rc.Report.Error (4004, loc, "The `await' operator cannot be used in an unsafe context"); @@ -94,7 +95,10 @@ namespace Mono.CSharp public override void Emit (EmitContext ec) { stmt.EmitPrologue (ec); - stmt.Emit (ec); + + using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) { + stmt.Emit (ec); + } } public override Expression EmitToField (EmitContext ec) @@ -121,7 +125,7 @@ namespace Mono.CSharp } } - class AwaitStatement : YieldStatement + public class AwaitStatement : YieldStatement { sealed class AwaitableMemberAccess : MemberAccess { @@ -137,7 +141,13 @@ namespace Mono.CSharp protected override void Error_OperatorCannotBeApplied (ResolveContext rc, TypeSpec type) { - rc.Report.Error (4001, loc, "Cannot await `{0}' expression", type.GetSignatureForError ()); + var invocation = LeftExpression as Invocation; + if (invocation != null && invocation.MethodGroup != null && (invocation.MethodGroup.BestCandidate.Modifiers & Modifiers.ASYNC) != 0) { + rc.Report.Error (4008, loc, "Cannot await void method `{0}'. Consider changing method return type to `Task'", + invocation.GetSignatureForError ()); + } else { + rc.Report.Error (4001, loc, "Cannot await `{0}' expression", type.GetSignatureForError ()); + } } } @@ -158,7 +168,6 @@ namespace Mono.CSharp Field awaiter; PropertySpec is_completed; - MethodSpec on_completed; MethodSpec get_result; TypeSpec type; TypeSpec result_type; @@ -176,12 +185,6 @@ namespace Mono.CSharp } } - public TypeSpec Type { - get { - return type; - } - } - public TypeSpec ResultType { get { return result_type; @@ -216,6 +219,8 @@ namespace Mono.CSharp public void EmitPrologue (EmitContext ec) { + awaiter = ((AsyncTaskStorey) machine_initializer.Storey).AddAwaiter (expr.Type, loc); + var fe_awaiter = new FieldExpr (awaiter, loc); fe_awaiter.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); @@ -233,6 +238,10 @@ namespace Mono.CSharp Arguments dargs = new Arguments (1); dargs.Add (new Argument (fe_awaiter)); completed_expr = new DynamicMemberBinder ("IsCompleted", dargs, loc).Resolve (rc); + + dargs = new Arguments (1); + dargs.Add (new Argument (completed_expr)); + completed_expr = new DynamicConversion (ec.Module.Compiler.BuiltinTypes.Bool, 0, dargs, loc).Resolve (rc); } else { var pe = PropertyExpr.CreatePredefined (is_completed, loc); pe.InstanceExpression = fe_awaiter; @@ -255,25 +264,10 @@ namespace Mono.CSharp ec.AssertEmptyStack (); var storey = (AsyncTaskStorey) machine_initializer.Storey; - var cont_field = storey.EmitContinuationInitialization (ec); - - var args = new Arguments (1); - args.Add (new Argument (cont_field)); - if (IsDynamic) { - var rc = new ResolveContext (ec.MemberContext); - var mg_expr = new Invocation (new MemberAccess (fe_awaiter, "OnCompleted"), args).Resolve (rc); - - ExpressionStatement es = (ExpressionStatement) mg_expr; - es.EmitStatement (ec); + storey.EmitAwaitOnCompletedDynamic (ec, fe_awaiter); } else { - var mg_completed = MethodGroupExpr.CreatePredefined (on_completed, fe_awaiter.Type, loc); - mg_completed.InstanceExpression = fe_awaiter; - - // - // awaiter.OnCompleted (continuation); - // - mg_completed.EmitCall (ec, args); + storey.EmitAwaitOnCompleted (ec, fe_awaiter); } // Return ok @@ -286,7 +280,9 @@ namespace Mono.CSharp public void EmitStatement (EmitContext ec) { EmitPrologue (ec); - Emit (ec); + DoEmit (ec); + + awaiter.IsAvailableForReuse = true; if (ResultType.Kind != MemberKind.Void) { var storey = (AsyncTaskStorey) machine_initializer.Storey; @@ -300,12 +296,18 @@ namespace Mono.CSharp void Error_WrongAwaiterPattern (ResolveContext rc, TypeSpec awaiter) { - rc.Report.Error (4011, loc, "The awaiter type `{0}' must have suitable IsCompleted, OnCompleted, and GetResult members", + rc.Report.Error (4011, loc, "The awaiter type `{0}' must have suitable IsCompleted and GetResult members", awaiter.GetSignatureForError ()); } public override bool Resolve (BlockContext bc) { + if (bc.CurrentBlock is Linq.QueryBlock) { + bc.Report.Error (1995, loc, + "The `await' operator may only be used in a query expression within the first collection expression of the initial `from' clause or within the collection expression of a `join' clause"); + return false; + } + if (!base.Resolve (bc)) return false; @@ -318,9 +320,6 @@ namespace Mono.CSharp // if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { result_type = type; - - awaiter = ((AsyncTaskStorey) machine_initializer.Storey).AddAwaiter (type, loc); - expr = new Invocation (new MemberAccess (expr, "GetAwaiter"), args).Resolve (bc); return true; } @@ -346,8 +345,6 @@ namespace Mono.CSharp } var awaiter_type = ama.Type; - awaiter = ((AsyncTaskStorey) machine_initializer.Storey).AddAwaiter (awaiter_type, loc); - expr = ama; // @@ -361,20 +358,6 @@ namespace Mono.CSharp 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 () // @@ -389,6 +372,16 @@ namespace Mono.CSharp return false; } + // + // Predefined: INotifyCompletion.OnCompleted (System.Action) + // + var nc = bc.Module.PredefinedTypes.INotifyCompletion; + if (nc.Define () && !awaiter_type.ImplementsInterface (nc.TypeSpec, false)) { + bc.Report.Error (4027, loc, "The awaiter type `{0}' must implement interface `{1}'", + awaiter_type.GetSignatureForError (), nc.GetSignatureForError ()); + return false; + } + result_type = get_result.ReturnType; return true; @@ -418,12 +411,6 @@ namespace Mono.CSharp } } - public Block OriginalBlock { - get { - return block.Parent; - } - } - public TypeInferenceContext ReturnTypeInference { get { return return_inference; @@ -432,38 +419,6 @@ namespace Mono.CSharp #endregion - public static void Create (IMemberContext context, ParametersBlock block, ParametersCompiled parameters, TypeDefinition host, TypeSpec returnType, Location loc) - { - 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; - } - - if (p is ArglistParameter) { - host.Compiler.Report.Error (4006, p.Location, - "__arglist is not allowed in parameter list of async methods"); - return; - } - - if (parameters.Types[i].IsPointer) { - host.Compiler.Report.Error (4005, p.Location, - "Async methods cannot have unsafe parameters"); - return; - } - } - - if (!block.HasAwait) { - host.Compiler.Report.Warning (1998, 1, loc, - "Async block lacks `await' operator and will run synchronously"); - } - - block.WrapIntoAsyncTask (context, host, returnType); - } - protected override BlockContext CreateBlockContext (ResolveContext rc) { var ctx = base.CreateBlockContext (rc); @@ -494,37 +449,7 @@ namespace Mono.CSharp public override void EmitStatement (EmitContext ec) { var storey = (AsyncTaskStorey) Storey; - storey.Instance.Emit (ec); - - var move_next_entry = storey.StateMachineMethod.Spec; - if (storey.MemberName.Arity > 0) { - move_next_entry = MemberCache.GetMember (storey.Instance.Type, move_next_entry); - } - - ec.Emit (OpCodes.Call, move_next_entry); - - // - // Emits return .$builder.Task; - // - if (storey.Task != null) { - var builder_field = storey.Builder.Spec; - var task_get = storey.Task.Get; - - if (storey.MemberName.Arity > 0) { - builder_field = MemberCache.GetMember (storey.Instance.Type, builder_field); - task_get = MemberCache.GetMember (builder_field.MemberType, task_get); - } - - var pe_task = new PropertyExpr (storey.Task, loc) { - InstanceExpression = new FieldExpr (builder_field, loc) { - InstanceExpression = storey.Instance - }, - Getter = task_get - }; - - pe_task.Emit (ec); - } - + storey.EmitInitializer (ec); ec.Emit (OpCodes.Ret); } } @@ -532,30 +457,27 @@ namespace Mono.CSharp class AsyncTaskStorey : StateMachine { int awaiters; - Field builder, continuation; + Field builder; readonly TypeSpec return_type; MethodSpec set_result; MethodSpec set_exception; + MethodSpec builder_factory; + MethodSpec builder_start; PropertySpec task; LocalVariable hoisted_return; int locals_captured; - Dictionary> stack_fields; - TypeSpec action; + Dictionary> stack_fields; + Dictionary> awaiter_fields; - public AsyncTaskStorey (IMemberContext context, AsyncInitializer initializer, TypeSpec type) - : base (initializer.OriginalBlock, initializer.Host, context.CurrentMemberDefinition as MemberBase, context.CurrentTypeParameters, "async") + public AsyncTaskStorey (ParametersBlock block, IMemberContext context, AsyncInitializer initializer, TypeSpec type) + : base (block, initializer.Host, context.CurrentMemberDefinition as MemberBase, context.CurrentTypeParameters, "async", MemberKind.Struct) { return_type = type; + awaiter_fields = new Dictionary> (); } #region Properties - public Field Builder { - get { - return builder; - } - } - public LocalVariable HoistedReturn { get { return hoisted_return; @@ -578,34 +500,53 @@ namespace Mono.CSharp public Field AddAwaiter (TypeSpec type, Location loc) { - return AddCapturedVariable ("$awaiter" + awaiters++.ToString ("X"), type); + if (mutator != null) + type = mutator.Mutate (type); + + List existing_fields = null; + if (awaiter_fields.TryGetValue (type, out existing_fields)) { + foreach (var f in existing_fields) { + if (f.IsAvailableForReuse) { + f.IsAvailableForReuse = false; + return f; + } + } + } + + var field = AddCompilerGeneratedField ("$awaiter" + awaiters++.ToString ("X"), new TypeExpression (type, Location), true); + field.Define (); + + if (existing_fields == null) { + existing_fields = new List (); + awaiter_fields.Add (type, existing_fields); + } + + existing_fields.Add (field); + return field; } - public StackField AddCapturedLocalVariable (TypeSpec type) + public Field AddCapturedLocalVariable (TypeSpec type) { if (mutator != null) type = mutator.Mutate (type); - List existing_fields = null; + List existing_fields = null; if (stack_fields == null) { - stack_fields = new Dictionary> (); + stack_fields = new Dictionary> (); } else if (stack_fields.TryGetValue (type, out existing_fields)) { foreach (var f in existing_fields) { - if (f.CanBeReused) { - f.CanBeReused = false; + if (f.IsAvailableForReuse) { + f.IsAvailableForReuse = false; return f; } } } - const Modifiers mod = Modifiers.COMPILER_GENERATED | Modifiers.PRIVATE; - var field = new StackField (this, new TypeExpression (type, Location), mod, new MemberName ("$" + locals_captured++.ToString ("X"), Location)); - AddField (field); - + var field = AddCompilerGeneratedField ("$stack" + locals_captured++.ToString ("X"), new TypeExpression (type, Location), true); field.Define (); if (existing_fields == null) { - existing_fields = new List (); + existing_fields = new List (); stack_fields.Add (type, existing_fields); } @@ -616,39 +557,52 @@ namespace Mono.CSharp protected override bool DoDefineMembers () { - action = Module.PredefinedTypes.Action.Resolve (); - PredefinedType builder_type; PredefinedMember bf; + PredefinedMember bs; PredefinedMember sr; PredefinedMember se; + PredefinedMember sm; 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; + bs = pred_members.AsyncVoidMethodBuilderStart; sr = pred_members.AsyncVoidMethodBuilderSetResult; se = pred_members.AsyncVoidMethodBuilderSetException; + sm = pred_members.AsyncVoidMethodBuilderSetStateMachine; } else if (return_type == Module.PredefinedTypes.Task.TypeSpec) { builder_type = Module.PredefinedTypes.AsyncTaskMethodBuilder; bf = pred_members.AsyncTaskMethodBuilderCreate; + bs = pred_members.AsyncTaskMethodBuilderStart; sr = pred_members.AsyncTaskMethodBuilderSetResult; se = pred_members.AsyncTaskMethodBuilderSetException; + sm = pred_members.AsyncTaskMethodBuilderSetStateMachine; task = pred_members.AsyncTaskMethodBuilderTask.Get (); } else { builder_type = Module.PredefinedTypes.AsyncTaskMethodBuilderGeneric; bf = pred_members.AsyncTaskMethodBuilderGenericCreate; + bs = pred_members.AsyncTaskMethodBuilderGenericStart; sr = pred_members.AsyncTaskMethodBuilderGenericSetResult; se = pred_members.AsyncTaskMethodBuilderGenericSetException; + sm = pred_members.AsyncTaskMethodBuilderGenericSetStateMachine; task = pred_members.AsyncTaskMethodBuilderGenericTask.Get (); has_task_return_type = true; } set_result = sr.Get (); set_exception = se.Get (); - var builder_factory = bf.Get (); - if (!builder_type.Define () || set_result == null || builder_factory == null || set_exception == null) { + builder_factory = bf.Get (); + builder_start = bs.Get (); + + var istate_machine = Module.PredefinedTypes.IAsyncStateMachine; + var set_statemachine = sm.Get (); + + if (!builder_type.Define () || !istate_machine.Define () || set_result == null || builder_factory == null || + set_exception == null || set_statemachine == null || builder_start == null || + !Module.PredefinedTypes.INotifyCompletion.Define ()) { Report.Error (1993, Location, "Cannot find compiler required types for asynchronous functions support. Are you targeting the wrong framework version?"); return base.DoDefineMembers (); @@ -665,83 +619,206 @@ namespace Mono.CSharp task_return_type = mutator.Mutate (task_return_type); bt = bt.MakeGenericType (Module, task_return_type); - builder_factory = MemberCache.GetMember (bt, builder_factory); - set_result = MemberCache.GetMember (bt, set_result); - set_exception = MemberCache.GetMember (bt, set_exception); + set_result = MemberCache.GetMember (bt, set_result); + set_exception = MemberCache.GetMember (bt, set_exception); + set_statemachine = MemberCache.GetMember (bt, set_statemachine); if (task != null) - task = MemberCache.GetMember (bt, task); + task = MemberCache.GetMember (bt, task); } builder = AddCompilerGeneratedField ("$builder", new TypeExpression (bt, Location)); - var ctor = DefineDefaultConstructor (false); + var set_state_machine = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Void, Location), + Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN | Modifiers.PUBLIC, + new MemberName ("SetStateMachine"), + ParametersCompiled.CreateFullyResolved ( + new Parameter (new TypeExpression (istate_machine.TypeSpec, Location), "stateMachine", Parameter.Modifier.NONE, null, Location), + istate_machine.TypeSpec), + null); + + ToplevelBlock block = new ToplevelBlock (Compiler, set_state_machine.ParameterInfo, Location); + block.IsCompilerGenerated = true; + set_state_machine.Block = block; + + Members.Add (set_state_machine); if (!base.DoDefineMembers ()) return false; - Block block = ctor.Block; + // + // Fabricates SetStateMachine method + // + // public void SetStateMachine (IAsyncStateMachine stateMachine) + // { + // $builder.SetStateMachine (stateMachine); + // } + // + var mg = MethodGroupExpr.CreatePredefined (set_statemachine, bt, Location); + mg.InstanceExpression = new FieldExpr (builder, Location); - var mg = MethodGroupExpr.CreatePredefined (builder_factory, bt, Location); - block.AddStatement ( - new StatementExpression (new SimpleAssign ( - new FieldExpr (builder, Location), - new Invocation (mg, new Arguments (0)), - Location))); + var param_reference = block.GetParameterReference (0, Location); + param_reference.Type = istate_machine.TypeSpec; + param_reference.eclass = ExprClass.Variable; + + var args = new Arguments (1); + args.Add (new Argument (param_reference)); + set_state_machine.Block.AddStatement (new StatementExpression (new Invocation (mg, args))); if (has_task_return_type) { - hoisted_return = LocalVariable.CreateCompilerGenerated (bt.TypeArguments[0], block, Location); + hoisted_return = LocalVariable.CreateCompilerGenerated (bt.TypeArguments[0], StateMachineMethod.Block, Location); } return true; } - public Expression EmitContinuationInitialization (EmitContext ec) + public void EmitAwaitOnCompletedDynamic (EmitContext ec, FieldExpr awaiter) { + var critical = Module.PredefinedTypes.ICriticalNotifyCompletion; + if (!critical.Define ()) { + throw new NotImplementedException (); + } + + var temp_critical = new LocalTemporary (critical.TypeSpec); + var label_critical = ec.DefineLabel (); + var label_end = ec.DefineLabel (); + // - // When more than 1 awaiter has been used in the block we - // introduce class scope field to cache continuation delegate + // Special path for dynamic awaiters // - if (awaiters > 1) { - if (continuation == null) { - continuation = AddCompilerGeneratedField ("$continuation", new TypeExpression (action, Location), true); - continuation.Define (); - } + // var awaiter = this.$awaiter as ICriticalNotifyCompletion; + // if (awaiter == null) { + // var completion = (INotifyCompletion) this.$awaiter; + // this.$builder.AwaitOnCompleted (ref completion, ref this); + // } else { + // this.$builder.AwaitUnsafeOnCompleted (ref awaiter, ref this); + // } + // + awaiter.Emit (ec); + ec.Emit (OpCodes.Isinst, critical.TypeSpec); + temp_critical.Store (ec); + temp_critical.Emit (ec); + ec.Emit (OpCodes.Brtrue_S, label_critical); + + var temp = new LocalTemporary (Module.PredefinedTypes.INotifyCompletion.TypeSpec); + awaiter.Emit (ec); + ec.Emit (OpCodes.Castclass, temp.Type); + temp.Store (ec); + EmitOnCompleted (ec, temp, false); + temp.Release (ec); + ec.Emit (OpCodes.Br_S, label_end); - var fexpr = new FieldExpr (continuation, Location); - fexpr.InstanceExpression = new CompilerGeneratedThis (CurrentType, Location); + ec.MarkLabel (label_critical); - // - // if ($continuation == null) - // $continuation = new Action (MoveNext); - // - fexpr.Emit (ec); + EmitOnCompleted (ec, temp_critical, true); - var skip_cont_init = ec.DefineLabel (); - ec.Emit (OpCodes.Brtrue_S, skip_cont_init); + ec.MarkLabel (label_end); - ec.EmitThis (); - EmitActionLoad (ec); - ec.Emit (OpCodes.Stfld, continuation.Spec); - ec.MarkLabel (skip_cont_init); + temp_critical.Release (ec); + } - return fexpr; + public void EmitAwaitOnCompleted (EmitContext ec, FieldExpr awaiter) + { + bool unsafe_version = false; + if (Module.PredefinedTypes.ICriticalNotifyCompletion.Define ()) { + unsafe_version = awaiter.Type.ImplementsInterface (Module.PredefinedTypes.ICriticalNotifyCompletion.TypeSpec, false); } - // - // Otherwise simply use temporary local variable - // - var field = LocalVariable.CreateCompilerGenerated (action, OriginalSourceBlock, Location); - EmitActionLoad (ec); - field.EmitAssign (ec); - return new LocalVariableReference (field, Location); + EmitOnCompleted (ec, awaiter, unsafe_version); + } + + void EmitOnCompleted (EmitContext ec, Expression awaiter, bool unsafeVersion) + { + var pm = Module.PredefinedMembers; + PredefinedMember predefined; + bool has_task_return_type = false; + if (return_type.Kind == MemberKind.Void) { + predefined = unsafeVersion ? pm.AsyncVoidMethodBuilderOnCompletedUnsafe : pm.AsyncVoidMethodBuilderOnCompleted; + } else if (return_type == Module.PredefinedTypes.Task.TypeSpec) { + predefined = unsafeVersion ? pm.AsyncTaskMethodBuilderOnCompletedUnsafe : pm.AsyncTaskMethodBuilderOnCompleted; + } else { + predefined = unsafeVersion ? pm.AsyncTaskMethodBuilderGenericOnCompletedUnsafe : pm.AsyncTaskMethodBuilderGenericOnCompleted; + has_task_return_type = true; + } + + var on_completed = predefined.Resolve (Location); + if (on_completed == null) + return; + + if (has_task_return_type) + on_completed = MemberCache.GetMember (set_result.DeclaringType, on_completed); + + on_completed = on_completed.MakeGenericMethod (this, awaiter.Type, ec.CurrentType); + + var mg = MethodGroupExpr.CreatePredefined (on_completed, on_completed.DeclaringType, Location); + mg.InstanceExpression = new FieldExpr (builder, Location) { + InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, Location) + }; + + var args = new Arguments (2); + args.Add (new Argument (awaiter, Argument.AType.Ref)); + args.Add (new Argument (new CompilerGeneratedThis (CurrentType, Location), Argument.AType.Ref)); + mg.EmitCall (ec, args); } - void EmitActionLoad (EmitContext ec) + public void EmitInitializer (EmitContext ec) { - ec.EmitThis (); - ec.Emit (OpCodes.Ldftn, StateMachineMethod.Spec); - ec.Emit (OpCodes.Newobj, (MethodSpec) MemberCache.FindMember (action, MemberFilter.Constructor (null), BindingRestriction.DeclaredOnly)); + // + // Some predefined types are missing + // + if (builder == null) + return; + + var instance = (TemporaryVariableReference) Instance; + var builder_field = builder.Spec; + if (MemberName.Arity > 0) { + builder_field = MemberCache.GetMember (instance.Type, builder_field); + } + + // + // Inflated factory method when task is of generic type + // + if (builder_factory.DeclaringType.IsGeneric) { + var task_return_type = return_type.TypeArguments; + var bt = builder_factory.DeclaringType.MakeGenericType (Module, task_return_type); + builder_factory = MemberCache.GetMember (bt, builder_factory); + builder_start = MemberCache.GetMember (bt, builder_start); + } + + // + // stateMachine.$builder = AsyncTaskMethodBuilder<{task-type}>.Create(); + // + instance.AddressOf (ec, AddressOp.Store); + ec.Emit (OpCodes.Call, builder_factory); + ec.Emit (OpCodes.Stfld, builder_field); + + // + // stateMachine.$builder.Start<{storey-type}>(ref stateMachine); + // + instance.AddressOf (ec, AddressOp.Store); + ec.Emit (OpCodes.Ldflda, builder_field); + if (Task != null) + ec.Emit (OpCodes.Dup); + instance.AddressOf (ec, AddressOp.Store); + ec.Emit (OpCodes.Call, builder_start.MakeGenericMethod (Module, instance.Type)); + + // + // Emits return stateMachine.$builder.Task; + // + if (Task != null) { + var task_get = Task.Get; + + if (MemberName.Arity > 0) { + task_get = MemberCache.GetMember (builder_field.MemberType, task_get); + } + + var pe_task = new PropertyExpr (Task, Location) { + InstanceExpression = EmptyExpression.Null, // Comes from the dup above + Getter = task_get + }; + + pe_task.Emit (ec); + } } public void EmitSetException (EmitContext ec, LocalVariableReference exceptionVariable) @@ -750,7 +827,7 @@ namespace Mono.CSharp // $builder.SetException (Exception) // var mg = MethodGroupExpr.CreatePredefined (set_exception, set_exception.DeclaringType, Location); - mg.InstanceExpression = new FieldExpr (Builder, Location) { + mg.InstanceExpression = new FieldExpr (builder, Location) { InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, Location) }; @@ -767,7 +844,7 @@ namespace Mono.CSharp // $builder.SetResult (value); // var mg = MethodGroupExpr.CreatePredefined (set_result, set_result.DeclaringType, Location); - mg.InstanceExpression = new FieldExpr (Builder, Location) { + mg.InstanceExpression = new FieldExpr (builder, Location) { InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, Location) }; @@ -781,31 +858,57 @@ namespace Mono.CSharp mg.EmitCall (ec, args); } - } - class StackField : Field - { - public StackField (TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name) - : base (parent, type, mod, name, null) + protected override TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class) { - } + base_type = Compiler.BuiltinTypes.ValueType; + base_class = null; + + var istate_machine = Module.PredefinedTypes.IAsyncStateMachine; + if (istate_machine.Define ()) { + return new[] { istate_machine.TypeSpec }; + } - public bool CanBeReused { get; set; } + return null; + } } - class StackFieldExpr : FieldExpr + class StackFieldExpr : FieldExpr, IExpressionCleanup { public StackFieldExpr (Field field) : base (field, Location.Null) { } + public override void AddressOf (EmitContext ec, AddressOp mode) + { + base.AddressOf (ec, mode); + + if (mode == AddressOp.Load) { + var field = (Field) spec.MemberDefinition; + field.IsAvailableForReuse = true; + } + } + public override void Emit (EmitContext ec) { base.Emit (ec); - var field = (StackField) spec.MemberDefinition; - field.CanBeReused = true; + var field = (Field) spec.MemberDefinition; + field.IsAvailableForReuse = true; + + // + // Release any captured reference type stack variables + // to imitate real stack behavour and help GC stuff early + // + if (TypeSpec.IsReferenceType (type)) { + ec.AddStatementEpilog (this); + } + } + + void IExpressionCleanup.EmitCleanup (EmitContext ec) + { + EmitAssign (ec, new NullConstant (type, loc), false, false); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs index a9decc3ba..47eaad62e 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs @@ -278,7 +278,7 @@ namespace Mono.CSharp { void ResolveAttributeType () { SessionReportPrinter resolve_printer = new SessionReportPrinter (); - ReportPrinter prev_recorder = context.Module.Compiler.Report.SetPrinter (resolve_printer); + ReportPrinter prev_recorder = Report.SetPrinter (resolve_printer); bool t1_is_attr = false; bool t2_is_attr = false; @@ -902,6 +902,11 @@ namespace Mono.CSharp { // Returns true for MethodImplAttribute with MethodImplOptions.InternalCall value // public bool IsInternalCall () + { + return (GetMethodImplOptions () & MethodImplOptions.InternalCall) != 0; + } + + public MethodImplOptions GetMethodImplOptions () { MethodImplOptions options = 0; if (pos_args.Count == 1) { @@ -911,7 +916,7 @@ namespace Mono.CSharp { options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), named.GetValue ().ToString ()); } - return (options & MethodImplOptions.InternalCall) != 0; + return options; } // @@ -1557,56 +1562,6 @@ namespace Mono.CSharp { /// static class AttributeTester { - public enum Result { - Ok, - RefOutArrayError, - ArrayArrayError - } - - /// - /// Returns true if parameters of two compared methods are CLS-Compliant. - /// It tests differing only in ref or out, or in array rank. - /// - public static Result AreOverloadedMethodParamsClsCompliant (AParametersCollection pa, AParametersCollection pb) - { - TypeSpec [] types_a = pa.Types; - TypeSpec [] types_b = pb.Types; - if (types_a == null || types_b == null) - return Result.Ok; - - if (types_a.Length != types_b.Length) - return Result.Ok; - - Result result = Result.Ok; - for (int i = 0; i < types_b.Length; ++i) { - TypeSpec aType = types_a [i]; - TypeSpec bType = types_b [i]; - - var ac_a = aType as ArrayContainer; - var ac_b = aType as ArrayContainer; - - if (ac_a != null && ac_b != null) { - if (ac_a.Rank != ac_b.Rank && ac_a.Element == ac_b.Element) { - result = Result.RefOutArrayError; - continue; - } - - if (ac_a.Element.IsArray || ac_b.Element.IsArray) { - result = Result.ArrayArrayError; - continue; - } - } - - if (aType != bType) - return Result.Ok; - - const Parameter.Modifier out_ref_mod = (Parameter.Modifier.OUTMASK | Parameter.Modifier.REFMASK); - if ((pa.FixedParameters[i].ModFlags & out_ref_mod) != (pb.FixedParameters[i].ModFlags & out_ref_mod)) - result = Result.RefOutArrayError; - } - return result; - } - /// /// Common method for Obsolete error/warning reporting. /// @@ -1666,6 +1621,7 @@ namespace Mono.CSharp { public readonly PredefinedAttribute DebuggerHidden; public readonly PredefinedAttribute UnsafeValueType; public readonly PredefinedAttribute UnmanagedFunctionPointer; + public readonly PredefinedDebuggerBrowsableAttribute DebuggerBrowsable; // New in .NET 3.5 public readonly PredefinedAttribute Extension; @@ -1680,6 +1636,9 @@ namespace Mono.CSharp { public readonly PredefinedDecimalAttribute DecimalConstant; public readonly PredefinedAttribute StructLayout; public readonly PredefinedAttribute FieldOffset; + public readonly PredefinedAttribute CallerMemberNameAttribute; + public readonly PredefinedAttribute CallerLineNumberAttribute; + public readonly PredefinedAttribute CallerFilePathAttribute; public PredefinedAttributes (ModuleContainer module) { @@ -1720,6 +1679,7 @@ namespace Mono.CSharp { DebuggerHidden = new PredefinedAttribute (module, "System.Diagnostics", "DebuggerHiddenAttribute"); UnsafeValueType = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "UnsafeValueTypeAttribute"); UnmanagedFunctionPointer = new PredefinedAttribute (module, "System.Runtime.InteropServices", "UnmanagedFunctionPointerAttribute"); + DebuggerBrowsable = new PredefinedDebuggerBrowsableAttribute (module, "System.Diagnostics", "DebuggerBrowsableAttribute"); Extension = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "ExtensionAttribute"); @@ -1730,6 +1690,10 @@ namespace Mono.CSharp { StructLayout = new PredefinedAttribute (module, "System.Runtime.InteropServices", "StructLayoutAttribute"); FieldOffset = new PredefinedAttribute (module, "System.Runtime.InteropServices", "FieldOffsetAttribute"); + CallerMemberNameAttribute = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "CallerMemberNameAttribute"); + CallerLineNumberAttribute = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "CallerLineNumberAttribute"); + CallerFilePathAttribute = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "CallerFilePathAttribute"); + // TODO: Should define only attributes which are used for comparison const System.Reflection.BindingFlags all_fields = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly; @@ -1803,22 +1767,12 @@ namespace Mono.CSharp { builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty); } - public void EmitAttribute (FieldBuilder builder, AttributeEncoder argsEncoded) - { - builder.SetCustomAttribute (GetCtorMetaInfo (), argsEncoded.ToArray ()); - } - public void EmitAttribute (TypeBuilder builder) { if (ResolveBuilder ()) builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty); } - public void EmitAttribute (TypeBuilder builder, AttributeEncoder argsEncoded) - { - builder.SetCustomAttribute (GetCtorMetaInfo (), argsEncoded.ToArray ()); - } - public void EmitAttribute (AssemblyBuilder builder) { if (ResolveBuilder ()) @@ -1837,11 +1791,6 @@ namespace Mono.CSharp { builder.SetCustomAttribute (GetCtorMetaInfo (), AttributeEncoder.Empty); } - public void EmitAttribute (ParameterBuilder builder, AttributeEncoder argsEncoded) - { - builder.SetCustomAttribute (GetCtorMetaInfo (), argsEncoded.ToArray ()); - } - ConstructorInfo GetCtorMetaInfo () { return (ConstructorInfo) ctor.GetMetaInfo (); @@ -1863,6 +1812,27 @@ namespace Mono.CSharp { } } + public class PredefinedDebuggerBrowsableAttribute : PredefinedAttribute + { + public PredefinedDebuggerBrowsableAttribute (ModuleContainer module, string ns, string name) + : base (module, ns, name) + { + } + + public void EmitAttribute (FieldBuilder builder, System.Diagnostics.DebuggerBrowsableState state) + { + var ctor = module.PredefinedMembers.DebuggerBrowsableAttributeCtor.Get (); + if (ctor == null) + return; + + AttributeEncoder encoder = new AttributeEncoder (); + encoder.Encode ((int) state); + encoder.EncodeEmptyNamedArguments (); + + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + } + } + public class PredefinedDecimalAttribute : PredefinedAttribute { public PredefinedDecimalAttribute (ModuleContainer module, string ns, string name) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs index 7580124ce..9e2cfc8b9 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs @@ -149,7 +149,7 @@ namespace Mono.CSharp { case Binary.Operator.ExclusiveOr: result = BinaryFold (ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc); if (result != null) - result = result.TryReduce (ec, lt, loc); + result = result.TryReduce (ec, lt); return result; /// @@ -158,7 +158,7 @@ namespace Mono.CSharp { case Binary.Operator.Subtraction: result = BinaryFold (ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc); if (result != null) - result = result.TryReduce (ec, EnumSpec.GetUnderlyingType (lt), loc); + result = result.TryReduce (ec, EnumSpec.GetUnderlyingType (lt)); return result; /// @@ -340,7 +340,7 @@ namespace Mono.CSharp { if (result == null) return null; - result = result.TryReduce (ec, lt, loc); + result = result.TryReduce (ec, lt); if (result == null) return null; @@ -459,7 +459,7 @@ namespace Mono.CSharp { if (result == null) return null; - result = result.TryReduce (ec, lt, loc); + result = result.TryReduce (ec, lt); if (result == null) return null; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs index 2769d8aba..de601e145 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs @@ -20,6 +20,7 @@ using System.Security.Permissions; using System.Linq; using System.Text; using System.Diagnostics; +using Mono.CompilerServices.SymbolWriter; #if NET_2_1 using XmlElement = System.Object; @@ -84,16 +85,15 @@ namespace Mono.CSharp } } -#if FULL_AST // - // Any unattached attributes during parsing get added here. + // Any unattached attributes during parsing get added here. User + // by FULL_AST mode // public Attributes UnattachedAttributes { get; set; } -#endif - public virtual void AddCompilerGeneratedClass (CompilerGeneratedClass c) + public virtual void AddCompilerGeneratedClass (CompilerGeneratedContainer c) { containers.Add (c); } @@ -255,7 +255,14 @@ namespace Mono.CSharp { if (containers != null) { foreach (var t in containers) { - t.PrepareEmit (); + try { + t.PrepareEmit (); + } catch (Exception e) { + if (MemberName == MemberName.Null) + throw; + + throw new InternalErrorException (t, e); + } } } } @@ -348,6 +355,15 @@ namespace Mono.CSharp tc.VerifyMembers (); } } + + public override void WriteDebugSymbol (MonoSymbolFile file) + { + if (containers != null) { + foreach (TypeContainer tc in containers) { + tc.WriteDebugSymbol (file); + } + } + } } public abstract class TypeDefinition : TypeContainer, ITypeDefinition @@ -632,6 +648,12 @@ namespace Mono.CSharp } } + public bool IsPartial { + get { + return (ModFlags & Modifiers.PARTIAL) != 0; + } + } + // // Returns true for secondary partial containers // @@ -724,7 +746,7 @@ namespace Mono.CSharp base.AddTypeContainer (tc); } - public override void AddCompilerGeneratedClass (CompilerGeneratedClass c) + public override void AddCompilerGeneratedClass (CompilerGeneratedContainer c) { members.Add (c); @@ -1273,6 +1295,18 @@ namespace Mono.CSharp } + public SourceMethodBuilder CreateMethodSymbolEntry () + { + if (Module.DeclaringAssembly.SymbolWriter == null) + return null; + + var source_file = GetCompilationSourceFile (); + if (source_file == null) + return null; + + return new SourceMethodBuilder (source_file.SymbolUnitEntry); + } + // // Creates a proxy base method call inside this container for hoisted base member calls // @@ -1291,7 +1325,7 @@ namespace Mono.CSharp } if (proxy_method == null) { - string name = CompilerGeneratedClass.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count); + string name = CompilerGeneratedContainer.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count); var base_parameters = new Parameter[method.Parameters.Count]; for (int i = 0; i < base_parameters.Length; ++i) { var base_param = method.Parameters.FixedParameters[i]; @@ -1487,6 +1521,9 @@ namespace Mono.CSharp public override void PrepareEmit () { + if ((caching_flags & Flags.CloseTypeCreated) != 0) + return; + foreach (var member in members) { var pm = member as IParametersMember; if (pm != null) { @@ -1920,28 +1957,28 @@ namespace Mono.CSharp if (OptAttributes != null) OptAttributes.Emit (); - if (!IsTopLevel) { - MemberSpec candidate; - bool overrides = false; - var conflict_symbol = MemberCache.FindBaseMember (this, out candidate, ref overrides); - if (conflict_symbol == null && candidate == null) { - if ((ModFlags & Modifiers.NEW) != 0) - Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", - GetSignatureForError ()); - } else { - if ((ModFlags & Modifiers.NEW) == 0) { - if (candidate == null) - candidate = conflict_symbol; + if (!IsCompilerGenerated) { + if (!IsTopLevel) { + MemberSpec candidate; + bool overrides = false; + var conflict_symbol = MemberCache.FindBaseMember (this, out candidate, ref overrides); + if (conflict_symbol == null && candidate == null) { + if ((ModFlags & Modifiers.NEW) != 0) + Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", + GetSignatureForError ()); + } else { + if ((ModFlags & Modifiers.NEW) == 0) { + if (candidate == null) + candidate = conflict_symbol; - Report.SymbolRelatedToPreviousError (candidate); - Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended", - GetSignatureForError (), candidate.GetSignatureForError ()); + Report.SymbolRelatedToPreviousError (candidate); + Report.Warning (108, 2, Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended", + GetSignatureForError (), candidate.GetSignatureForError ()); + } } } - } - // Run constraints check on all possible generic types - if ((ModFlags & Modifiers.COMPILER_GENERATED) == 0) { + // Run constraints check on all possible generic types if (base_type != null && base_type_expr != null) { ConstraintChecker.Check (this, base_type, base_type_expr.Location); } @@ -2270,6 +2307,16 @@ namespace Mono.CSharp cached_method |= CachedMethods.GetHashCode; } + public override void WriteDebugSymbol (MonoSymbolFile file) + { + if (IsPartialPart) + return; + + foreach (var m in members) { + m.WriteDebugSymbol (file); + } + } + /// /// Method container contains Equals method /// @@ -2307,6 +2354,8 @@ namespace Mono.CSharp public abstract class ClassOrStruct : TypeDefinition { + public const TypeAttributes StaticClassAttribute = TypeAttributes.Abstract | TypeAttributes.Sealed; + SecurityType declarative_security; public ClassOrStruct (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) @@ -2316,7 +2365,19 @@ namespace Mono.CSharp protected override TypeAttributes TypeAttr { get { - return has_static_constructor ? base.TypeAttr : base.TypeAttr | TypeAttributes.BeforeFieldInit; + TypeAttributes ta = base.TypeAttr; + if (!has_static_constructor) + ta |= TypeAttributes.BeforeFieldInit; + + if (Kind == MemberKind.Class) { + ta |= TypeAttributes.AutoLayout | TypeAttributes.Class; + if (IsStatic) + ta |= StaticClassAttribute; + } else { + ta |= TypeAttributes.SequentialLayout; + } + + return ta; } } @@ -2431,8 +2492,8 @@ namespace Mono.CSharp } - // TODO: should be sealed - public class Class : ClassOrStruct { + public sealed class Class : ClassOrStruct + { const Modifiers AllowedModifiers = Modifiers.NEW | Modifiers.PUBLIC | @@ -2444,8 +2505,6 @@ namespace Mono.CSharp Modifiers.STATIC | Modifiers.UNSAFE; - public const TypeAttributes StaticClassAttribute = TypeAttributes.Abstract | TypeAttributes.Sealed; - public Class (TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base (parent, name, attrs, MemberKind.Class) { @@ -2639,23 +2698,10 @@ namespace Mono.CSharp caching_flags |= Flags.Excluded; return conditions; } - - // - // FIXME: How do we deal with the user specifying a different - // layout? - // - protected override TypeAttributes TypeAttr { - get { - TypeAttributes ta = base.TypeAttr | TypeAttributes.AutoLayout | TypeAttributes.Class; - if (IsStatic) - ta |= StaticClassAttribute; - return ta; - } - } } - public sealed class Struct : ClassOrStruct { - + public sealed class Struct : ClassOrStruct + { bool is_unmanaged, has_unmanaged_check_done; bool InTransit; @@ -2827,17 +2873,6 @@ namespace Mono.CSharp return ifaces; } - protected override TypeAttributes TypeAttr { - get { - const - TypeAttributes DefaultTypeAttributes = - TypeAttributes.SequentialLayout | - TypeAttributes.Sealed ; - - return base.TypeAttr | DefaultTypeAttributes; - } - } - public override void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression) { if ((field.ModFlags & Modifiers.STATIC) == 0) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs index bb79678ba..026d41069 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; +using Mono.CompilerServices.SymbolWriter; #if STATIC using MetaType = IKVM.Reflection.Type; @@ -76,11 +77,15 @@ namespace Mono.CSharp readonly IMemberContext member_context; + readonly SourceMethodBuilder methodSymbols; + DynamicSiteClass dynamic_site_container; Label? return_label; - public EmitContext (IMemberContext rc, ILGenerator ig, TypeSpec return_type) + List epilogue_expressions; + + public EmitContext (IMemberContext rc, ILGenerator ig, TypeSpec return_type, SourceMethodBuilder methodSymbols) { this.member_context = rc; this.ig = ig; @@ -89,7 +94,8 @@ namespace Mono.CSharp if (rc.Module.Compiler.Settings.Checked) flags |= Options.CheckedScope; - if (SymbolWriter.HasSymbolWriter) { + if (methodSymbols != null) { + this.methodSymbols = methodSymbols; if (!rc.Module.Compiler.Settings.Optimize) flags |= Options.AccurateDebugInfo; } else { @@ -133,6 +139,12 @@ namespace Mono.CSharp } } + public bool HasMethodSymbolBuilder { + get { + return methodSymbols != null; + } + } + public bool HasReturnLabel { get { return return_label.HasValue; @@ -186,8 +198,25 @@ namespace Mono.CSharp } } + public List StatementEpilogue { + get { + return epilogue_expressions; + } + } + #endregion + public void AddStatementEpilog (IExpressionCleanup cleanupExpression) + { + if (epilogue_expressions == null) { + epilogue_expressions = new List (); + } else if (epilogue_expressions.Contains (cleanupExpression)) { + return; + } + + epilogue_expressions.Add (cleanupExpression); + } + public void AssertEmptyStack () { #if STATIC @@ -206,19 +235,25 @@ namespace Mono.CSharp if ((flags & Options.OmitDebugInfo) != 0) return false; - if (loc.IsNull) + if (loc.IsNull || methodSymbols == null) return false; - if (loc.SourceFile.IsHiddenLocation (loc)) + var sf = loc.SourceFile; + if (sf.IsHiddenLocation (loc)) return false; - SymbolWriter.MarkSequencePoint (ig, loc); +#if NET_4_0 + methodSymbols.MarkSequencePoint (ig.ILOffset, sf.SourceFileEntry, loc.Row, loc.Column, false); +#endif return true; } public void DefineLocalVariable (string name, LocalBuilder builder) { - SymbolWriter.DefineLocalVariable (name, builder); + if ((flags & Options.OmitDebugInfo) != 0) + return; + + methodSymbols.AddLocal (builder.LocalIndex, name); } public void BeginCatchBlock (TypeSpec type) @@ -238,7 +273,12 @@ namespace Mono.CSharp public void BeginScope () { - SymbolWriter.OpenScope(ig); + if ((flags & Options.OmitDebugInfo) != 0) + return; + +#if NET_4_0 + methodSymbols.StartBlock (CodeBlockEntry.Type.Lexical, ig.ILOffset); +#endif } public void EndExceptionBlock () @@ -248,7 +288,12 @@ namespace Mono.CSharp public void EndScope () { - SymbolWriter.CloseScope(ig); + if ((flags & Options.OmitDebugInfo) != 0) + return; + +#if NET_4_0 + methodSymbols.EndBlock (ig.ILOffset); +#endif } // @@ -790,6 +835,17 @@ namespace Mono.CSharp ig.Emit (OpCodes.Ldarg_0); } + public void EmitEpilogue () + { + if (epilogue_expressions == null) + return; + + foreach (var e in epilogue_expressions) + e.EmitCleanup (this); + + epilogue_expressions = null; + } + /// /// Returns a temporary storage for a variable of type t as /// a local variable in the current body. @@ -1040,9 +1096,11 @@ namespace Mono.CSharp return false; // - // It's non-virtual and will never be null + // It's non-virtual and will never be null and it can be determined + // whether it's known value or reference type by verifier // - if (!method.IsVirtual && (instance is This || instance is New || instance is ArrayCreation || instance is DelegateCreation)) + if (!method.IsVirtual && (instance is This || instance is New || instance is ArrayCreation || instance is DelegateCreation) && + !instance.Type.IsGenericParameter) return false; return true; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs index 7f91ce5ea..5eb93d129 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs @@ -205,7 +205,7 @@ namespace Mono.CSharp { else if (!(expr is Constant)) Error_ExpressionMustBeConstant (rc, expr.Location, GetSignatureForError ()); else - expr.Error_ValueCannotBeConverted (rc, expr.Location, field.MemberType, false); + expr.Error_ValueCannotBeConverted (rc, field.MemberType, false); } expr = c; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/constant.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/constant.cs index 3869f1e80..4297c521d 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/constant.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/constant.cs @@ -58,7 +58,7 @@ namespace Mono.CSharp { } #endif - public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) + public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl) { if (!expl && IsLiteral && BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) && @@ -66,7 +66,7 @@ namespace Mono.CSharp { ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'", GetValueAsLiteral (), TypeManager.CSharpName (target)); } else { - base.Error_ValueCannotBeConverted (ec, loc, target, expl); + base.Error_ValueCannotBeConverted (ec, target, expl); } } @@ -74,7 +74,7 @@ namespace Mono.CSharp { { Constant c = ConvertImplicitly (type); if (c == null) - Error_ValueCannotBeConverted (ec, loc, type, false); + Error_ValueCannotBeConverted (ec, type, false); return c; } @@ -160,8 +160,11 @@ namespace Mono.CSharp { return new NullConstant (t, loc); } - throw new InternalErrorException ("Constant value `{0}' has unexpected underlying type `{1}'", - v, TypeManager.CSharpName (t)); +#if STATIC + throw new InternalErrorException ("Constant value `{0}' has unexpected underlying type `{1}'", v, t.GetSignatureForError ()); +#else + return null; +#endif } public override Expression CreateExpressionTree (ResolveContext ec) @@ -251,32 +254,38 @@ namespace Mono.CSharp { /// /// Attempts to do a compile-time folding of a constant cast. /// - public Constant TryReduce (ResolveContext ec, TypeSpec target_type, Location loc) + public Constant TryReduce (ResolveContext ec, TypeSpec target_type) { try { - return TryReduce (ec, target_type); - } - catch (OverflowException) { + return TryReduceConstant (ec, target_type); + } catch (OverflowException) { if (ec.ConstantCheckState && Type.BuiltinType != BuiltinTypeSpec.Type.Decimal) { ec.Report.Error (221, loc, "Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax to override)", GetValueAsLiteral (), target_type.GetSignatureForError ()); } else { - Error_ValueCannotBeConverted (ec, loc, target_type, false); + Error_ValueCannotBeConverted (ec, target_type, false); } return New.Constantify (target_type, loc); } } - Constant TryReduce (ResolveContext ec, TypeSpec target_type) + Constant TryReduceConstant (ResolveContext ec, TypeSpec target_type) { - if (Type == target_type) + if (Type == target_type) { + // + // Reducing literal value produces a new constant. Syntactically 10 is not same as (int)10 + // + if (IsLiteral) + return CreateConstantFromValue (target_type, GetValue (), loc); + return this; + } Constant c; if (target_type.IsEnum) { - c = TryReduce (ec, EnumSpec.GetUnderlyingType (target_type)); + c = TryReduceConstant (ec, EnumSpec.GetUnderlyingType (target_type)); if (c == null) return null; @@ -378,11 +387,11 @@ namespace Mono.CSharp { eclass = ExprClass.Value; } - public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) + public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl) { try { ConvertExplicitly (true, target); - base.Error_ValueCannotBeConverted (ec, loc, target, expl); + base.Error_ValueCannotBeConverted (ec, target, expl); } catch { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs index 4a2318c2b..5f309854b 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs @@ -481,7 +481,7 @@ namespace Mono.CSharp // or it's a parameter // if (CurrentAnonymousMethod is AsyncInitializer) - return CurrentBlock.Explicit.HasAwait; + return local.IsParameter || CurrentBlock.Explicit.HasAwait; return local.Block.ParametersBlock != CurrentBlock.ParametersBlock.Original; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs index 0daf116e9..a9a304dfc 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs @@ -495,6 +495,11 @@ namespace Mono.CSharp { return ImplicitNumericConversion (expr, expr.Type, target_type); } + public static bool ImplicitNumericConversionExists (TypeSpec expr_type, TypeSpec target_type) + { + return ImplicitNumericConversion (null, expr_type, target_type) != null; + } + static Expression ImplicitNumericConversion (Expression expr, TypeSpec expr_type, TypeSpec target_type) { switch (expr_type.BuiltinType) { @@ -1190,7 +1195,7 @@ namespace Mono.CSharp { if (s_x != source_type) { var c = source as Constant; if (c != null) { - source = c.TryReduce (ec, s_x, loc); + source = c.TryReduce (ec, s_x); } else { source = implicitOnly ? ImplicitConversionStandard (ec, source_type_expr, s_x, loc) : @@ -1418,7 +1423,7 @@ namespace Mono.CSharp { if (e != null) return e; - source.Error_ValueCannotBeConverted (ec, loc, target_type, false); + source.Error_ValueCannotBeConverted (ec, target_type, false); return null; } @@ -2098,7 +2103,7 @@ namespace Mono.CSharp { if (ec.IsUnsafe && expr.Type.IsPointer && target_type.IsPointer && ((PointerContainer)expr.Type).Element.Kind == MemberKind.Void) return EmptyCast.Create (expr, target_type); - expr.Error_ValueCannotBeConverted (ec, l, target_type, true); + expr.Error_ValueCannotBeConverted (ec, target_type, true); return null; } @@ -2161,7 +2166,7 @@ namespace Mono.CSharp { if (e != null) return e; - expr.Error_ValueCannotBeConverted (ec, loc, target_type, true); + expr.Error_ValueCannotBeConverted (ec, target_type, true); return null; } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs index da1c2e602..77893426d 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs @@ -149,6 +149,9 @@ namespace Mono.CSharp Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation; Location savedAttrParenOpenLocation, savedAttrParenCloseLocation, savedOperatorLocation; Stack> locationListStack = new Stack> (); // used for type parameters + Stack opt_intoStack = new Stack (); + + bool HadAttributeParens; List attributeCommas = new List (); List attributeArgumentCommas = new List (); List parameterListCommas = new List (); @@ -345,6 +348,7 @@ namespace Mono.CSharp //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_header : opt_attributes opt_modifiers member_type method_declaration_name error", //t "method_body : block", //t "method_body : SEMICOLON", //t "opt_formal_parameter_list :", @@ -363,6 +367,7 @@ namespace Mono.CSharp //t "fixed_parameters : fixed_parameters COMMA fixed_parameter", //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 : attribute_sections error", //t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type error", //t "$$26 :", //t "fixed_parameter : opt_attributes opt_parameter_modifier parameter_type IDENTIFIER ASSIGN $$26 constant_expression", @@ -567,7 +572,6 @@ namespace Mono.CSharp //t "type_list : base_type_name", //t "type_list : type_list COMMA base_type_name", //t "base_type_name : type", -//t "base_type_name : error", //t "builtin_types : OBJECT", //t "builtin_types : STRING", //t "builtin_types : BOOL", @@ -648,7 +652,7 @@ namespace Mono.CSharp //t "argument_list : argument_or_named_argument", //t "argument_list : argument_list COMMA argument", //t "argument_list : argument_list COMMA named_argument", -//t "argument_list : argument_list COMMA", +//t "argument_list : argument_list COMMA error", //t "argument_list : COMMA error", //t "argument : expression", //t "argument : non_simple_argument", @@ -779,7 +783,8 @@ namespace Mono.CSharp //t "null_coalescing_expression : conditional_or_expression", //t "null_coalescing_expression : conditional_or_expression OP_COALESCING null_coalescing_expression", //t "conditional_expression : null_coalescing_expression", -//t "conditional_expression : null_coalescing_expression INTERR expression COLON expression", +//t "conditional_expression : null_coalescing_expression INTERR expression COLON expression_or_error", +//t "conditional_expression : null_coalescing_expression INTERR expression error", //t "assignment_expression : prefixed_unary_expression ASSIGN expression", //t "assignment_expression : prefixed_unary_expression OP_MULT_ASSIGN expression", //t "assignment_expression : prefixed_unary_expression OP_DIV_ASSIGN expression", @@ -853,12 +858,13 @@ namespace Mono.CSharp //t "modifier : ASYNC", //t "opt_class_base :", //t "opt_class_base : COLON type_list", +//t "opt_class_base : COLON type_list error", //t "opt_type_parameter_constraints_clauses :", //t "opt_type_parameter_constraints_clauses : type_parameter_constraints_clauses", -//t "opt_type_parameter_constraints_clauses : error", //t "type_parameter_constraints_clauses : type_parameter_constraints_clause", //t "type_parameter_constraints_clauses : type_parameter_constraints_clauses type_parameter_constraints_clause", //t "type_parameter_constraints_clause : WHERE IDENTIFIER COLON type_parameter_constraints", +//t "type_parameter_constraints_clause : WHERE IDENTIFIER error", //t "type_parameter_constraints : type_parameter_constraint", //t "type_parameter_constraints : type_parameter_constraints COMMA type_parameter_constraint", //t "type_parameter_constraint : type", @@ -875,6 +881,7 @@ namespace Mono.CSharp //t "block_end : COMPLETE_COMPLETION", //t "$$81 :", //t "block_prepared : OPEN_BRACE $$81 opt_statement_list CLOSE_BRACE", +//t "block_prepared : CLOSE_BRACE", //t "opt_statement_list :", //t "opt_statement_list : statement_list", //t "statement_list : statement", @@ -936,9 +943,11 @@ namespace Mono.CSharp //t "identifier_inside_body : IDENTIFIER", //t "identifier_inside_body : AWAIT", //t "$$83 :", -//t "block_variable_declaration : variable_type identifier_inside_body $$83 opt_local_variable_initializer opt_variable_declarators SEMICOLON", +//t "block_variable_declaration : variable_type identifier_inside_body $$83 opt_local_variable_initializer opt_variable_declarators semicolon_or_handle_error_close_brace", //t "$$84 :", //t "block_variable_declaration : CONST variable_type identifier_inside_body $$84 const_variable_initializer opt_const_declarators SEMICOLON", +//t "semicolon_or_handle_error_close_brace : SEMICOLON", +//t "semicolon_or_handle_error_close_brace : CLOSE_BRACE", //t "opt_local_variable_initializer :", //t "opt_local_variable_initializer : ASSIGN block_variable_initializer", //t "opt_local_variable_initializer : ASSIGN error", @@ -987,6 +996,7 @@ namespace Mono.CSharp //t "switch_labels : switch_label", //t "switch_labels : switch_labels switch_label", //t "switch_label : CASE constant_expression COLON", +//t "switch_label : CASE constant_expression error", //t "switch_label : DEFAULT_COLON", //t "iteration_statement : while_statement", //t "iteration_statement : do_statement", @@ -1000,14 +1010,17 @@ namespace Mono.CSharp //t "$$87 :", //t "for_statement : FOR open_parens_any $$87 for_statement_cont", //t "$$88 :", +//t "for_statement_cont : opt_for_initializer SEMICOLON $$88 for_statement_condition", +//t "for_statement_cont : opt_for_initializer CLOSE_PARENS", //t "$$89 :", -//t "$$90 :", -//t "for_statement_cont : opt_for_initializer SEMICOLON $$88 opt_for_condition SEMICOLON $$89 opt_for_iterator CLOSE_PARENS $$90 embedded_statement", -//t "for_statement_cont : error", +//t "for_statement_condition : opt_for_condition SEMICOLON $$89 for_statement_end", +//t "for_statement_condition : boolean_expression CLOSE_PARENS", +//t "for_statement_end : opt_for_iterator CLOSE_PARENS embedded_statement", +//t "for_statement_end : error", //t "opt_for_initializer :", //t "opt_for_initializer : for_initializer", -//t "$$91 :", -//t "for_initializer : variable_type identifier_inside_body $$91 opt_local_variable_initializer opt_variable_declarators", +//t "$$90 :", +//t "for_initializer : variable_type identifier_inside_body $$90 opt_local_variable_initializer opt_variable_declarators", //t "for_initializer : statement_expression_list", //t "opt_for_condition :", //t "opt_for_condition : boolean_expression", @@ -1018,8 +1031,8 @@ namespace Mono.CSharp //t "statement_expression_list : statement_expression_list COMMA statement_expression", //t "foreach_statement : FOREACH open_parens_any type error", //t "foreach_statement : FOREACH open_parens_any type identifier_inside_body error", -//t "$$92 :", -//t "foreach_statement : FOREACH open_parens_any type identifier_inside_body IN expression CLOSE_PARENS $$92 embedded_statement", +//t "$$91 :", +//t "foreach_statement : FOREACH open_parens_any type identifier_inside_body IN expression CLOSE_PARENS $$91 embedded_statement", //t "foreach_statement : FOREACH open_parens_any type identifier_inside_body error", //t "foreach_statement : FOREACH open_parens_any type error", //t "jump_statement : break_statement", @@ -1030,11 +1043,14 @@ namespace Mono.CSharp //t "jump_statement : yield_statement", //t "break_statement : BREAK SEMICOLON", //t "continue_statement : CONTINUE SEMICOLON", +//t "continue_statement : CONTINUE error", //t "goto_statement : GOTO identifier_inside_body SEMICOLON", //t "goto_statement : GOTO CASE constant_expression SEMICOLON", //t "goto_statement : GOTO DEFAULT SEMICOLON", //t "return_statement : RETURN opt_expression SEMICOLON", +//t "return_statement : RETURN error", //t "throw_statement : THROW opt_expression SEMICOLON", +//t "throw_statement : THROW error", //t "yield_statement : identifier_inside_body RETURN opt_expression SEMICOLON", //t "yield_statement : identifier_inside_body BREAK SEMICOLON", //t "opt_expression :", @@ -1048,21 +1064,21 @@ namespace Mono.CSharp //t "opt_identifier :", //t "opt_identifier : identifier_inside_body", //t "catch_clause : CATCH block", -//t "$$93 :", -//t "catch_clause : CATCH open_parens_any type opt_identifier CLOSE_PARENS $$93 block_prepared", +//t "$$92 :", +//t "catch_clause : CATCH open_parens_any type opt_identifier CLOSE_PARENS $$92 block_prepared", //t "catch_clause : CATCH open_parens_any error", //t "checked_statement : CHECKED block", //t "unchecked_statement : UNCHECKED block", -//t "$$94 :", -//t "unsafe_statement : UNSAFE $$94 block", +//t "$$93 :", +//t "unsafe_statement : UNSAFE $$93 block", //t "lock_statement : LOCK open_parens_any expression CLOSE_PARENS embedded_statement", //t "lock_statement : LOCK open_parens_any expression error", +//t "$$94 :", //t "$$95 :", +//t "fixed_statement : FIXED open_parens_any variable_type identifier_inside_body $$94 using_or_fixed_variable_initializer opt_using_or_fixed_variable_declarators CLOSE_PARENS $$95 embedded_statement", //t "$$96 :", -//t "fixed_statement : FIXED open_parens_any variable_type identifier_inside_body $$95 using_or_fixed_variable_initializer opt_using_or_fixed_variable_declarators CLOSE_PARENS $$96 embedded_statement", //t "$$97 :", -//t "$$98 :", -//t "using_statement : USING open_parens_any variable_type identifier_inside_body $$97 using_initialization CLOSE_PARENS $$98 embedded_statement", +//t "using_statement : USING open_parens_any variable_type identifier_inside_body $$96 using_initialization CLOSE_PARENS $$97 embedded_statement", //t "using_statement : USING open_parens_any expression CLOSE_PARENS embedded_statement", //t "using_statement : USING open_parens_any expression error", //t "using_initialization : using_or_fixed_variable_initializer opt_using_or_fixed_variable_declarators", @@ -1077,20 +1093,20 @@ namespace Mono.CSharp //t "first_from_clause : FROM_FIRST type identifier_inside_body IN expression", //t "nested_from_clause : FROM identifier_inside_body IN expression", //t "nested_from_clause : FROM type identifier_inside_body IN expression", +//t "$$98 :", +//t "from_clause : FROM identifier_inside_body IN $$98 expression_or_error", //t "$$99 :", -//t "from_clause : FROM identifier_inside_body IN $$99 expression_or_error", -//t "$$100 :", -//t "from_clause : FROM type identifier_inside_body IN $$100 expression_or_error", -//t "query_body : opt_query_body_clauses select_or_group_clause opt_query_continuation", -//t "query_body : opt_query_body_clauses COMPLETE_COMPLETION", +//t "from_clause : FROM type identifier_inside_body IN $$99 expression_or_error", +//t "query_body : query_body_clauses select_or_group_clause opt_query_continuation", +//t "query_body : select_or_group_clause opt_query_continuation", +//t "query_body : query_body_clauses COMPLETE_COMPLETION", +//t "query_body : query_body_clauses error", //t "query_body : error", +//t "$$100 :", +//t "select_or_group_clause : SELECT $$100 expression_or_error", //t "$$101 :", -//t "select_or_group_clause : SELECT $$101 expression_or_error", //t "$$102 :", -//t "$$103 :", -//t "select_or_group_clause : GROUP $$102 expression_or_error $$103 BY expression_or_error", -//t "opt_query_body_clauses :", -//t "opt_query_body_clauses : query_body_clauses", +//t "select_or_group_clause : GROUP $$101 expression_or_error $$102 BY expression_or_error", //t "query_body_clauses : query_body_clause", //t "query_body_clauses : query_body_clauses query_body_clause", //t "query_body_clause : from_clause", @@ -1098,28 +1114,28 @@ namespace Mono.CSharp //t "query_body_clause : where_clause", //t "query_body_clause : join_clause", //t "query_body_clause : orderby_clause", +//t "$$103 :", +//t "let_clause : LET identifier_inside_body ASSIGN $$103 expression_or_error", //t "$$104 :", -//t "let_clause : LET identifier_inside_body ASSIGN $$104 expression_or_error", +//t "where_clause : WHERE $$104 expression_or_error", //t "$$105 :", -//t "where_clause : WHERE $$105 expression_or_error", //t "$$106 :", //t "$$107 :", +//t "join_clause : JOIN identifier_inside_body IN $$105 expression_or_error ON $$106 expression_or_error EQUALS $$107 expression_or_error opt_join_into", //t "$$108 :", -//t "join_clause : JOIN identifier_inside_body IN $$106 expression_or_error ON $$107 expression_or_error EQUALS $$108 expression_or_error opt_join_into", //t "$$109 :", //t "$$110 :", -//t "$$111 :", -//t "join_clause : JOIN type identifier_inside_body IN $$109 expression_or_error ON $$110 expression_or_error EQUALS $$111 expression_or_error opt_join_into", +//t "join_clause : JOIN type identifier_inside_body IN $$108 expression_or_error ON $$109 expression_or_error EQUALS $$110 expression_or_error opt_join_into", //t "opt_join_into :", //t "opt_join_into : INTO identifier_inside_body", -//t "$$112 :", -//t "orderby_clause : ORDERBY $$112 orderings", +//t "$$111 :", +//t "orderby_clause : ORDERBY $$111 orderings", //t "orderings : order_by", -//t "$$113 :", -//t "orderings : order_by COMMA $$113 orderings_then_by", +//t "$$112 :", +//t "orderings : order_by COMMA $$112 orderings_then_by", //t "orderings_then_by : then_by", -//t "$$114 :", -//t "orderings_then_by : orderings_then_by COMMA $$114 then_by", +//t "$$113 :", +//t "orderings_then_by : orderings_then_by COMMA $$113 then_by", //t "order_by : expression", //t "order_by : expression ASCENDING", //t "order_by : expression DESCENDING", @@ -1127,12 +1143,12 @@ namespace Mono.CSharp //t "then_by : expression ASCENDING", //t "then_by : expression DESCENDING", //t "opt_query_continuation :", -//t "$$115 :", -//t "opt_query_continuation : INTO identifier_inside_body $$115 query_body", +//t "$$114 :", +//t "opt_query_continuation : INTO identifier_inside_body $$114 query_body", //t "interactive_parsing : EVAL_STATEMENT_PARSER EOF", //t "interactive_parsing : EVAL_USING_DECLARATIONS_UNIT_PARSER using_directives opt_COMPLETE_COMPLETION", -//t "$$116 :", -//t "interactive_parsing : EVAL_STATEMENT_PARSER $$116 interactive_statement_list opt_COMPLETE_COMPLETION", +//t "$$115 :", +//t "interactive_parsing : EVAL_STATEMENT_PARSER $$115 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", @@ -1145,16 +1161,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 "$$117 :", -//t "doc_cref : doc_type_declaration_name DOT THIS OPEN_BRACKET $$117 opt_doc_parameters CLOSE_BRACKET", +//t "$$116 :", +//t "doc_cref : doc_type_declaration_name DOT THIS OPEN_BRACKET $$116 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 "$$118 :", -//t "opt_doc_method_sig : OPEN_PARENS $$118 opt_doc_parameters CLOSE_PARENS", +//t "$$117 :", +//t "opt_doc_method_sig : OPEN_PARENS $$117 opt_doc_parameters CLOSE_PARENS", //t "opt_doc_parameters :", //t "opt_doc_parameters : doc_parameters", //t "doc_parameters : doc_parameter", @@ -1399,20 +1415,20 @@ namespace Mono.CSharp yyVal = yyV > yyTop ? null : yyVals[yyV]; // yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); switch (yyN) { case 1: -#line 387 "cs-parser.jay" +#line 390 "cs-parser.jay" { Lexer.check_incorrect_doc_comment (); } break; case 2: -#line 388 "cs-parser.jay" +#line 391 "cs-parser.jay" { Lexer.CompleteOnEOF = false; } break; case 6: case_6(); break; case 7: -#line 405 "cs-parser.jay" +#line 410 "cs-parser.jay" { module.AddAttributes ((Attributes) yyVals[0+yyTop], current_namespace); } @@ -1424,7 +1440,7 @@ case 13: case_13(); break; case 14: -#line 450 "cs-parser.jay" +#line 455 "cs-parser.jay" { Error_SyntaxError (yyToken); } @@ -1463,7 +1479,7 @@ case 39: case_39(); break; case 40: -#line 616 "cs-parser.jay" +#line 621 "cs-parser.jay" { current_namespace.DeclarationFound = true; } @@ -1496,18 +1512,18 @@ case 56: case_56(); break; case 57: -#line 732 "cs-parser.jay" +#line 735 "cs-parser.jay" { yyVal = "event"; savedCloseLocation = GetLocation (yyVals[0+yyTop]); } break; case 58: -#line 733 "cs-parser.jay" +#line 736 "cs-parser.jay" { yyVal = "return"; savedCloseLocation = GetLocation (yyVals[0+yyTop]); } break; case 59: case_59(); break; case 60: -#line 750 "cs-parser.jay" +#line 753 "cs-parser.jay" { yyVal = new List (4) { (Attribute) yyVals[0+yyTop] }; } @@ -1516,7 +1532,7 @@ case 61: case_61(); break; case 62: -#line 765 "cs-parser.jay" +#line 768 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1525,14 +1541,14 @@ case 63: case_63(); break; case 65: -#line 791 "cs-parser.jay" - { yyVal = null; } +#line 796 "cs-parser.jay" + { yyVal = null; HadAttributeParens = false; } break; case 66: case_66(); break; case 67: -#line 802 "cs-parser.jay" +#line 808 "cs-parser.jay" { yyVal = null; } break; case 68: @@ -1548,13 +1564,13 @@ case 71: case_71(); break; case 72: -#line 846 "cs-parser.jay" +#line 852 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; case 74: -#line 854 "cs-parser.jay" +#line 860 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1566,29 +1582,29 @@ case 76: case_76(); break; case 77: -#line 880 "cs-parser.jay" +#line 886 "cs-parser.jay" { yyVal = null; } break; case 78: -#line 884 "cs-parser.jay" +#line 890 "cs-parser.jay" { yyVal = Argument.AType.Ref; } break; case 79: -#line 888 "cs-parser.jay" +#line 894 "cs-parser.jay" { yyVal = Argument.AType.Out; } break; case 82: -#line 900 "cs-parser.jay" +#line 906 "cs-parser.jay" { lexer.parsing_modifiers = true; } break; case 83: -#line 904 "cs-parser.jay" +#line 910 "cs-parser.jay" { lexer.parsing_modifiers = true; } @@ -1597,7 +1613,7 @@ case 95: case_95(); break; case 96: -#line 935 "cs-parser.jay" +#line 941 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1618,7 +1634,7 @@ case 101: case_101(); break; case 102: -#line 978 "cs-parser.jay" +#line 984 "cs-parser.jay" { Error_SyntaxError (yyToken); } @@ -1630,13 +1646,13 @@ case 104: case_104(); break; case 107: -#line 1019 "cs-parser.jay" +#line 1025 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 108: -#line 1023 "cs-parser.jay" +#line 1029 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1645,7 +1661,7 @@ case 109: case_109(); break; case 110: -#line 1039 "cs-parser.jay" +#line 1045 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1669,7 +1685,7 @@ case 118: case_118(); break; case 119: -#line 1118 "cs-parser.jay" +#line 1124 "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"); } @@ -1681,13 +1697,13 @@ case 122: case_122(); break; case 125: -#line 1148 "cs-parser.jay" +#line 1154 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 126: -#line 1152 "cs-parser.jay" +#line 1158 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1696,7 +1712,7 @@ case 127: case_127(); break; case 128: -#line 1165 "cs-parser.jay" +#line 1171 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1705,13 +1721,13 @@ case 129: case_129(); break; case 132: -#line 1184 "cs-parser.jay" +#line 1190 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 133: -#line 1188 "cs-parser.jay" +#line 1194 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1720,7 +1736,7 @@ case 134: case_134(); break; case 135: -#line 1204 "cs-parser.jay" +#line 1210 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1741,13 +1757,13 @@ case 142: case_142(); break; case 143: -#line 1275 "cs-parser.jay" +#line 1281 "cs-parser.jay" { valid_param_mod = ParameterModifierType.All; } break; case 144: -#line 1279 "cs-parser.jay" +#line 1285 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1756,7 +1772,7 @@ case 145: case_145(); break; case 146: -#line 1305 "cs-parser.jay" +#line 1311 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } @@ -1765,7 +1781,7 @@ case 147: case_147(); break; case 148: -#line 1315 "cs-parser.jay" +#line 1321 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1776,16 +1792,16 @@ case 149: case 150: case_150(); break; -case 152: -#line 1363 "cs-parser.jay" - { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } +case 151: + case_151(); break; case 153: -#line 1367 "cs-parser.jay" - { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } +#line 1386 "cs-parser.jay" + { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } break; -case 155: - case_155(); +case 154: +#line 1390 "cs-parser.jay" + { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 156: case_156(); @@ -1806,20 +1822,20 @@ case 161: case_161(); break; case 162: -#line 1439 "cs-parser.jay" + case_162(); + break; +case 163: +#line 1462 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[0+yyTop] } ); } break; -case 163: -#line 1443 "cs-parser.jay" +case 164: +#line 1466 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true); } break; -case 164: - case_164(); - break; case 165: case_165(); break; @@ -1836,29 +1852,29 @@ case 169: case_169(); break; case 170: -#line 1518 "cs-parser.jay" - { - ++lexer.parsing_block; - } + case_170(); break; case 171: case_171(); break; case 172: -#line 1559 "cs-parser.jay" - { yyVal = Parameter.Modifier.NONE; } - break; -case 174: -#line 1567 "cs-parser.jay" +#line 1547 "cs-parser.jay" { - yyVal = yyVals[0+yyTop]; + ++lexer.parsing_block; } break; -case 175: - case_175(); +case 173: + case_173(); + break; +case 174: +#line 1588 "cs-parser.jay" + { yyVal = Parameter.Modifier.NONE; } break; case 176: - case_176(); +#line 1596 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 177: case_177(); @@ -1882,16 +1898,16 @@ case 183: case_183(); break; case 184: -#line 1660 "cs-parser.jay" - { - Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS); - } + case_184(); break; case 185: case_185(); break; case 186: - case_186(); +#line 1689 "cs-parser.jay" + { + Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS); + } break; case 187: case_187(); @@ -1903,10 +1919,7 @@ case 189: case_189(); break; case 190: -#line 1714 "cs-parser.jay" - { - valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue; - } + case_190(); break; case 191: case_191(); @@ -1914,17 +1927,20 @@ case 191: case 192: #line 1743 "cs-parser.jay" { - lexer.PropertyParsing = false; + valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue; } break; case 193: case_193(); break; -case 198: - case_198(); +case 194: +#line 1772 "cs-parser.jay" + { + lexer.PropertyParsing = false; + } break; -case 199: - case_199(); +case 195: + case_195(); break; case 200: case_200(); @@ -1935,23 +1951,23 @@ case 201: case 202: case_202(); break; +case 203: + case_203(); + break; case 204: case_204(); break; -case 205: - case_205(); - break; case 206: -#line 1892 "cs-parser.jay" - { - lexer.ConstraintsParsing = true; - } + case_206(); break; case 207: case_207(); break; case 208: - case_208(); +#line 1921 "cs-parser.jay" + { + lexer.ConstraintsParsing = true; + } break; case 209: case_209(); @@ -1960,176 +1976,173 @@ case 210: case_210(); break; case 211: -#line 1931 "cs-parser.jay" + case_211(); + break; +case 212: + case_212(); + break; +case 213: +#line 1960 "cs-parser.jay" { Error_SyntaxError (yyToken); } break; -case 214: -#line 1943 "cs-parser.jay" +case 216: +#line 1972 "cs-parser.jay" { lexer.parsing_modifiers = true; } break; -case 215: -#line 1947 "cs-parser.jay" +case 217: +#line 1976 "cs-parser.jay" { lexer.parsing_modifiers = true; } break; -case 216: -#line 1954 "cs-parser.jay" +case 218: +#line 1983 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; -case 217: -#line 1958 "cs-parser.jay" +case 219: +#line 1987 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; -case 222: -#line 1966 "cs-parser.jay" +case 224: +#line 1995 "cs-parser.jay" { report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators"); } break; -case 223: -#line 1970 "cs-parser.jay" +case 225: +#line 1999 "cs-parser.jay" { report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors"); } break; -case 224: -#line 1974 "cs-parser.jay" +case 226: +#line 2003 "cs-parser.jay" { report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations"); } break; -case 225: -#line 1980 "cs-parser.jay" +case 227: +#line 2009 "cs-parser.jay" { } break; -case 226: - case_226(); - break; case 228: -#line 2013 "cs-parser.jay" - { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } + case_228(); break; case 230: - case_230(); +#line 2042 "cs-parser.jay" + { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } + break; +case 232: + case_232(); break; -case 231: -#line 2029 "cs-parser.jay" +case 233: +#line 2058 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } break; -case 232: - case_232(); - break; case 234: -#line 2075 "cs-parser.jay" - { yyVal = Operator.OpType.LogicalNot; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } - break; -case 235: -#line 2076 "cs-parser.jay" - { yyVal = Operator.OpType.OnesComplement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } + case_234(); break; case 236: -#line 2077 "cs-parser.jay" - { yyVal = Operator.OpType.Increment; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2104 "cs-parser.jay" + { yyVal = Operator.OpType.LogicalNot; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 237: -#line 2078 "cs-parser.jay" - { yyVal = Operator.OpType.Decrement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2105 "cs-parser.jay" + { yyVal = Operator.OpType.OnesComplement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 238: -#line 2079 "cs-parser.jay" - { yyVal = Operator.OpType.True; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2106 "cs-parser.jay" + { yyVal = Operator.OpType.Increment; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 239: -#line 2080 "cs-parser.jay" - { yyVal = Operator.OpType.False; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2107 "cs-parser.jay" + { yyVal = Operator.OpType.Decrement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 240: -#line 2082 "cs-parser.jay" - { yyVal = Operator.OpType.Addition; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2108 "cs-parser.jay" + { yyVal = Operator.OpType.True; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 241: -#line 2083 "cs-parser.jay" - { yyVal = Operator.OpType.Subtraction; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2109 "cs-parser.jay" + { yyVal = Operator.OpType.False; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 242: -#line 2085 "cs-parser.jay" - { yyVal = Operator.OpType.Multiply; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2111 "cs-parser.jay" + { yyVal = Operator.OpType.Addition; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 243: -#line 2086 "cs-parser.jay" - { yyVal = Operator.OpType.Division; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2112 "cs-parser.jay" + { yyVal = Operator.OpType.Subtraction; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 244: -#line 2087 "cs-parser.jay" - { yyVal = Operator.OpType.Modulus; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2114 "cs-parser.jay" + { yyVal = Operator.OpType.Multiply; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 245: -#line 2088 "cs-parser.jay" - { yyVal = Operator.OpType.BitwiseAnd; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2115 "cs-parser.jay" + { yyVal = Operator.OpType.Division; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 246: -#line 2089 "cs-parser.jay" - { yyVal = Operator.OpType.BitwiseOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2116 "cs-parser.jay" + { yyVal = Operator.OpType.Modulus; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 247: -#line 2090 "cs-parser.jay" - { yyVal = Operator.OpType.ExclusiveOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2117 "cs-parser.jay" + { yyVal = Operator.OpType.BitwiseAnd; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 248: -#line 2091 "cs-parser.jay" - { yyVal = Operator.OpType.LeftShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2118 "cs-parser.jay" + { yyVal = Operator.OpType.BitwiseOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 249: -#line 2092 "cs-parser.jay" - { yyVal = Operator.OpType.RightShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2119 "cs-parser.jay" + { yyVal = Operator.OpType.ExclusiveOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 250: -#line 2093 "cs-parser.jay" - { yyVal = Operator.OpType.Equality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2120 "cs-parser.jay" + { yyVal = Operator.OpType.LeftShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 251: -#line 2094 "cs-parser.jay" - { yyVal = Operator.OpType.Inequality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2121 "cs-parser.jay" + { yyVal = Operator.OpType.RightShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 252: -#line 2095 "cs-parser.jay" - { yyVal = Operator.OpType.GreaterThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2122 "cs-parser.jay" + { yyVal = Operator.OpType.Equality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 253: -#line 2096 "cs-parser.jay" - { yyVal = Operator.OpType.LessThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2123 "cs-parser.jay" + { yyVal = Operator.OpType.Inequality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 254: -#line 2097 "cs-parser.jay" - { yyVal = Operator.OpType.GreaterThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2124 "cs-parser.jay" + { yyVal = Operator.OpType.GreaterThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 255: -#line 2098 "cs-parser.jay" - { yyVal = Operator.OpType.LessThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } +#line 2125 "cs-parser.jay" + { yyVal = Operator.OpType.LessThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 256: -#line 2105 "cs-parser.jay" - { - valid_param_mod = ParameterModifierType.DefaultValue; - } +#line 2126 "cs-parser.jay" + { yyVal = Operator.OpType.GreaterThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 257: - case_257(); +#line 2127 "cs-parser.jay" + { yyVal = Operator.OpType.LessThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 258: -#line 2124 "cs-parser.jay" +#line 2134 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2138,7 +2151,10 @@ case 259: case_259(); break; case 260: - case_260(); +#line 2153 "cs-parser.jay" + { + valid_param_mod = ParameterModifierType.DefaultValue; + } break; case 261: case_261(); @@ -2155,21 +2171,18 @@ case 264: case 265: case_265(); break; -case 267: -#line 2230 "cs-parser.jay" - { current_block = null; yyVal = null; } +case 266: + case_266(); break; -case 270: -#line 2242 "cs-parser.jay" - { - ++lexer.parsing_block; - } +case 267: + case_267(); break; -case 271: - case_271(); +case 269: +#line 2259 "cs-parser.jay" + { current_block = null; yyVal = null; } break; case 272: -#line 2252 "cs-parser.jay" +#line 2271 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2178,7 +2191,10 @@ case 273: case_273(); break; case 274: - case_274(); +#line 2281 "cs-parser.jay" + { + ++lexer.parsing_block; + } break; case 275: case_275(); @@ -2204,54 +2220,54 @@ case 281: case 282: case_282(); break; +case 283: + case_283(); + break; case 284: -#line 2367 "cs-parser.jay" + case_284(); + break; +case 286: +#line 2397 "cs-parser.jay" { ++lexer.parsing_block; } break; -case 285: - case_285(); +case 287: + case_287(); break; -case 288: -#line 2384 "cs-parser.jay" +case 290: +#line 2414 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; -case 289: -#line 2388 "cs-parser.jay" +case 291: +#line 2418 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; -case 290: - case_290(); +case 292: + case_292(); break; -case 291: -#line 2401 "cs-parser.jay" +case 293: +#line 2431 "cs-parser.jay" { ++lexer.parsing_block; } break; -case 292: - case_292(); +case 294: + case_294(); break; -case 293: - case_293(); +case 295: + case_295(); break; -case 294: -#line 2426 "cs-parser.jay" +case 296: +#line 2456 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 297: - case_297(); - break; -case 298: - case_298(); - break; case 299: case_299(); break; @@ -2270,12 +2286,12 @@ case 303: case 304: case_304(); break; +case 305: + case_305(); + break; case 306: case_306(); break; -case 307: - case_307(); - break; case 308: case_308(); break; @@ -2285,24 +2301,24 @@ case 309: case 310: case_310(); break; +case 311: + case_311(); + break; case 312: case_312(); break; -case 313: - case_313(); +case 314: + case_314(); + break; +case 315: + case_315(); break; -case 316: -#line 2601 "cs-parser.jay" +case 318: +#line 2624 "cs-parser.jay" { lbag.AppendToMember (current_container, GetLocation (yyVals[0+yyTop])); } break; -case 318: - case_318(); - break; -case 319: - case_319(); - break; case 320: case_320(); break; @@ -2310,23 +2326,26 @@ case 321: case_321(); break; case 322: -#line 2659 "cs-parser.jay" - { - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue; - } + case_322(); break; case 323: case_323(); break; case 324: -#line 2678 "cs-parser.jay" +#line 2682 "cs-parser.jay" { - lexer.ConstraintsParsing = false; + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue; } break; case 325: case_325(); break; +case 326: +#line 2701 "cs-parser.jay" + { + lexer.ConstraintsParsing = false; + } + break; case 327: case_327(); break; @@ -2336,15 +2355,12 @@ case 329: case 331: case_331(); break; -case 332: - case_332(); +case 333: + case_333(); break; case 334: case_334(); break; -case 335: - case_335(); - break; case 336: case_336(); break; @@ -2352,23 +2368,23 @@ case 337: case_337(); break; case 338: -#line 2784 "cs-parser.jay" - { - lexer.parsing_generic_declaration = true; - } + case_338(); break; case 339: case_339(); break; case 340: - case_340(); +#line 2807 "cs-parser.jay" + { + lexer.parsing_generic_declaration = true; + } + break; +case 341: + case_341(); break; case 342: case_342(); break; -case 343: - case_343(); - break; case 344: case_344(); break; @@ -2381,12 +2397,12 @@ case 346: case 347: case_347(); break; +case 348: + case_348(); + break; case 349: case_349(); break; -case 350: - case_350(); - break; case 351: case_351(); break; @@ -2396,21 +2412,24 @@ case 352: case 353: case_353(); break; +case 354: + case_354(); + break; case 355: -#line 2902 "cs-parser.jay" + case_355(); + break; +case 357: +#line 2929 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } break; -case 356: -#line 2909 "cs-parser.jay" +case 358: +#line 2936 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } break; -case 358: - case_358(); - break; case 360: case_360(); break; @@ -2418,40 +2437,37 @@ case 362: case_362(); break; case 364: -#line 2947 "cs-parser.jay" - { - yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); - } - break; -case 365: - case_365(); + case_364(); break; case 366: -#line 2966 "cs-parser.jay" +#line 2974 "cs-parser.jay" { - yyVal = new ComposedCast ((ATypeNameExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); + yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; case 367: case_367(); break; case 368: -#line 2975 "cs-parser.jay" +#line 2993 "cs-parser.jay" { - yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); + yyVal = new ComposedCast ((ATypeNameExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; case 369: -#line 2979 "cs-parser.jay" - { - yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); - } + case_369(); break; case 370: - case_370(); +#line 3002 "cs-parser.jay" + { + yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); + } break; case 371: - case_371(); +#line 3006 "cs-parser.jay" + { + yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); + } break; case 372: case_372(); @@ -2460,95 +2476,95 @@ case 373: case_373(); break; case 374: -#line 3018 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } + case_374(); break; case 375: -#line 3019 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } +#line 3040 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } break; case 376: -#line 3020 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } +#line 3041 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } break; case 377: -#line 3021 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } +#line 3042 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } break; case 378: -#line 3022 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } +#line 3043 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } break; case 379: -#line 3023 "cs-parser.jay" +#line 3044 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } + break; +case 380: +#line 3045 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation (yyVals[0+yyTop])); } break; -case 381: -#line 3028 "cs-parser.jay" +case 382: +#line 3050 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.SByte, GetLocation (yyVals[0+yyTop])); } break; -case 382: -#line 3029 "cs-parser.jay" +case 383: +#line 3051 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Byte, GetLocation (yyVals[0+yyTop])); } break; -case 383: -#line 3030 "cs-parser.jay" +case 384: +#line 3052 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Short, GetLocation (yyVals[0+yyTop])); } break; -case 384: -#line 3031 "cs-parser.jay" +case 385: +#line 3053 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UShort, GetLocation (yyVals[0+yyTop])); } break; -case 385: -#line 3032 "cs-parser.jay" +case 386: +#line 3054 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Int, GetLocation (yyVals[0+yyTop])); } break; -case 386: -#line 3033 "cs-parser.jay" +case 387: +#line 3055 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UInt, GetLocation (yyVals[0+yyTop])); } break; -case 387: -#line 3034 "cs-parser.jay" +case 388: +#line 3056 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Long, GetLocation (yyVals[0+yyTop])); } break; -case 388: -#line 3035 "cs-parser.jay" +case 389: +#line 3057 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.ULong, GetLocation (yyVals[0+yyTop])); } break; -case 389: -#line 3036 "cs-parser.jay" +case 390: +#line 3058 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Char, GetLocation (yyVals[0+yyTop])); } break; -case 410: - case_410(); - break; case 411: case_411(); break; -case 415: -#line 3083 "cs-parser.jay" - { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } +case 412: + case_412(); break; case 416: -#line 3087 "cs-parser.jay" - { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); } +#line 3105 "cs-parser.jay" + { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } break; case 417: -#line 3088 "cs-parser.jay" - { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); } +#line 3109 "cs-parser.jay" + { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); } break; -case 422: - case_422(); +case 418: +#line 3110 "cs-parser.jay" + { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); } break; case 423: -#line 3121 "cs-parser.jay" + case_423(); + break; +case 424: +#line 3143 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); } break; -case 424: - case_424(); - break; case 425: case_425(); break; @@ -2559,49 +2575,49 @@ case 427: case_427(); break; case 428: -#line 3156 "cs-parser.jay" + case_428(); + break; +case 429: +#line 3178 "cs-parser.jay" { yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop])); } break; -case 429: - case_429(); - break; case 430: -#line 3164 "cs-parser.jay" + case_430(); + break; +case 431: +#line 3186 "cs-parser.jay" { yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location); } break; -case 431: - case_431(); - break; case 432: case_432(); break; case 433: -#line 3180 "cs-parser.jay" - { yyVal = null; } + case_433(); break; -case 435: - case_435(); +case 434: +#line 3202 "cs-parser.jay" + { yyVal = null; } break; case 436: case_436(); break; case 437: -#line 3203 "cs-parser.jay" - { yyVal = null; } + case_437(); break; case 438: -#line 3207 "cs-parser.jay" +#line 3225 "cs-parser.jay" + { yyVal = null; } + break; +case 439: +#line 3229 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 439: - case_439(); - break; case 440: case_440(); break; @@ -2612,26 +2628,26 @@ case 442: case_442(); break; case 443: -#line 3240 "cs-parser.jay" + case_443(); + break; +case 444: +#line 3262 "cs-parser.jay" { yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop])); } break; -case 444: - case_444(); - break; case 445: case_445(); break; case 446: case_446(); break; -case 449: -#line 3268 "cs-parser.jay" - { yyVal = null; } +case 447: + case_447(); break; -case 451: - case_451(); +case 450: +#line 3292 "cs-parser.jay" + { yyVal = null; } break; case 452: case_452(); @@ -2646,14 +2662,14 @@ case 455: case_455(); break; case 456: -#line 3320 "cs-parser.jay" + case_456(); + break; +case 457: +#line 3344 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; -case 460: - case_460(); - break; case 461: case_461(); break; @@ -2663,20 +2679,14 @@ case 462: case 463: case_463(); break; -case 465: - case_465(); +case 464: + case_464(); break; case 466: -#line 3365 "cs-parser.jay" - { - yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); - } + case_466(); break; case 467: -#line 3369 "cs-parser.jay" - { - yyVal = new ElementAccess ((Expression) yyVals[-2+yyTop], null, GetLocation (yyVals[-1+yyTop])); - } + case_467(); break; case 468: case_468(); @@ -2694,38 +2704,38 @@ case 472: case_472(); break; case 473: -#line 3415 "cs-parser.jay" + case_473(); + break; +case 474: +#line 3441 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; -case 475: -#line 3423 "cs-parser.jay" +case 476: +#line 3449 "cs-parser.jay" { yyVal = new This (GetLocation (yyVals[0+yyTop])); } break; -case 476: - case_476(); - break; case 477: case_477(); break; case 478: -#line 3443 "cs-parser.jay" + case_478(); + break; +case 479: +#line 3469 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; -case 479: -#line 3450 "cs-parser.jay" +case 480: +#line 3476 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } break; -case 480: - case_480(); - break; case 481: case_481(); break; @@ -2745,23 +2755,23 @@ case 486: case_486(); break; case 487: -#line 3516 "cs-parser.jay" + case_487(); + break; +case 488: +#line 3543 "cs-parser.jay" { ++lexer.parsing_type; } break; -case 488: - case_488(); - break; case 489: case_489(); break; -case 492: -#line 3543 "cs-parser.jay" - { yyVal = null; } +case 490: + case_490(); break; -case 494: - case_494(); +case 493: +#line 3570 "cs-parser.jay" + { yyVal = null; } break; case 495: case_495(); @@ -2778,8 +2788,8 @@ case 498: case 499: case_499(); break; -case 503: - case_503(); +case 500: + case_500(); break; case 504: case_504(); @@ -2788,32 +2798,32 @@ case 505: case_505(); break; case 506: -#line 3621 "cs-parser.jay" + case_506(); + break; +case 507: +#line 3648 "cs-parser.jay" { yyVal = 2; } break; -case 507: -#line 3625 "cs-parser.jay" +case 508: +#line 3652 "cs-parser.jay" { yyVal = ((int) yyVals[-1+yyTop]) + 1; } break; -case 508: -#line 3632 "cs-parser.jay" +case 509: +#line 3659 "cs-parser.jay" { yyVal = null; } break; -case 509: -#line 3636 "cs-parser.jay" +case 510: +#line 3663 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 510: - case_510(); - break; case 511: case_511(); break; @@ -2824,16 +2834,16 @@ case 513: case_513(); break; case 514: -#line 3680 "cs-parser.jay" + case_514(); + break; +case 515: +#line 3707 "cs-parser.jay" { lexer.TypeOfParsing = true; } break; -case 515: - case_515(); - break; -case 518: - case_518(); +case 516: + case_516(); break; case 519: case_519(); @@ -2869,136 +2879,136 @@ case 529: case_529(); break; case 530: -#line 3800 "cs-parser.jay" + case_530(); + break; +case 531: +#line 3827 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], false, GetLocation (yyVals[-1+yyTop])); } break; -case 531: - case_531(); - break; case 532: -#line 3813 "cs-parser.jay" + case_532(); + break; +case 533: +#line 3840 "cs-parser.jay" { start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], true, GetLocation (yyVals[-2+yyTop])); } break; -case 533: - case_533(); - break; case 534: -#line 3830 "cs-parser.jay" + case_534(); + break; +case 535: +#line 3857 "cs-parser.jay" { yyVal = ParametersCompiled.Undefined; } break; -case 536: -#line 3838 "cs-parser.jay" +case 537: +#line 3865 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 537: - case_537(); - break; case 538: case_538(); break; -case 540: -#line 3864 "cs-parser.jay" +case 539: + case_539(); + break; +case 541: +#line 3891 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 541: -#line 3868 "cs-parser.jay" +case 542: +#line 3895 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 542: - case_542(); - break; case 543: case_543(); break; -case 545: -#line 3896 "cs-parser.jay" +case 544: + case_544(); + break; +case 546: +#line 3931 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 546: -#line 3900 "cs-parser.jay" +case 547: +#line 3935 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 547: -#line 3904 "cs-parser.jay" +case 548: +#line 3939 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 548: -#line 3908 "cs-parser.jay" +case 549: +#line 3943 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 549: -#line 3912 "cs-parser.jay" +case 550: +#line 3947 "cs-parser.jay" { yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 550: -#line 3916 "cs-parser.jay" +case 551: +#line 3951 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 552: - case_552(); - break; case 553: case_553(); break; case 554: case_554(); break; -case 556: - case_556(); +case 555: + case_555(); break; case 557: -#line 3948 "cs-parser.jay" + case_557(); + break; +case 558: +#line 3983 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 558: - case_558(); - break; case 559: -#line 3957 "cs-parser.jay" + case_559(); + break; +case 560: +#line 3992 "cs-parser.jay" { yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 560: -#line 3961 "cs-parser.jay" +case 561: +#line 3996 "cs-parser.jay" { yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 562: - case_562(); - break; case 563: case_563(); break; -case 565: - case_565(); +case 564: + case_564(); break; case 566: case_566(); @@ -3009,44 +3019,44 @@ case 567: case 568: case_568(); break; -case 570: - case_570(); +case 569: + case_569(); break; case 571: case_571(); break; -case 573: - case_573(); +case 572: + case_572(); break; -case 575: - case_575(); +case 574: + case_574(); break; -case 577: - case_577(); +case 576: + case_576(); break; -case 579: - case_579(); +case 578: + case_578(); break; -case 581: - case_581(); +case 580: + case_580(); break; -case 583: - case_583(); +case 582: + case_582(); break; -case 585: - case_585(); +case 584: + case_584(); break; case 586: -#line 4085 "cs-parser.jay" - { - yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_586(); break; case 587: case_587(); break; case 588: - case_588(); +#line 4125 "cs-parser.jay" + { + yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 589: case_589(); @@ -3088,27 +3098,27 @@ case 601: case_601(); break; case 602: -#line 4182 "cs-parser.jay" - { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } + case_602(); break; case 603: case_603(); break; -case 606: -#line 4198 "cs-parser.jay" +case 604: +#line 4222 "cs-parser.jay" + { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } + break; +case 605: + case_605(); + break; +case 608: +#line 4238 "cs-parser.jay" { start_block (Location.Null); } break; -case 607: - case_607(); - break; case 609: case_609(); break; -case 610: - case_610(); - break; case 611: case_611(); break; @@ -3119,62 +3129,62 @@ case 613: case_613(); break; case 614: -#line 4243 "cs-parser.jay" - { - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; - } + case_614(); break; case 615: case_615(); break; case 616: - case_616(); - break; -case 617: -#line 4257 "cs-parser.jay" +#line 4283 "cs-parser.jay" { - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; +case 617: + case_617(); + break; case 618: case_618(); break; case 619: - case_619(); - break; -case 625: -#line 4282 "cs-parser.jay" +#line 4297 "cs-parser.jay" { - yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 626: - case_626(); +case 620: + case_620(); + break; +case 621: + case_621(); break; case 627: - case_627(); +#line 4322 "cs-parser.jay" + { + yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); + } break; case 628: case_628(); break; +case 629: + case_629(); + break; case 630: -#line 4311 "cs-parser.jay" + case_630(); + break; +case 632: +#line 4351 "cs-parser.jay" { yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); } break; -case 631: -#line 4324 "cs-parser.jay" +case 633: +#line 4364 "cs-parser.jay" { lexer.ConstraintsParsing = true; } break; -case 632: - case_632(); - break; -case 633: - case_633(); - break; case 634: case_634(); break; @@ -3182,28 +3192,28 @@ case 635: case_635(); break; case 636: -#line 4369 "cs-parser.jay" - { yyVal = null; } + case_636(); break; case 637: -#line 4371 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } + case_637(); break; case 638: - case_638(); +#line 4409 "cs-parser.jay" + { yyVal = null; } break; case 639: -#line 4384 "cs-parser.jay" +#line 4411 "cs-parser.jay" + { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } + break; +case 640: + case_640(); + break; +case 641: +#line 4424 "cs-parser.jay" { lexer.parsing_modifiers = false; } break; -case 641: - case_641(); - break; -case 642: - case_642(); - break; case 643: case_643(); break; @@ -3246,23 +3256,23 @@ case 655: case 656: case_656(); break; +case 657: + case_657(); + break; case 658: case_658(); break; case 660: -#line 4504 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_660(); break; case 661: case_661(); break; -case 662: - case_662(); - break; case 663: - case_663(); +#line 4550 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 664: case_664(); @@ -3280,40 +3290,37 @@ case 668: case_668(); break; case 669: -#line 4595 "cs-parser.jay" + case_669(); + break; +case 670: + case_670(); + break; +case 671: + case_671(); + break; +case 672: +#line 4643 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop])); } break; -case 670: -#line 4599 "cs-parser.jay" +case 673: +#line 4647 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop])); } break; -case 671: -#line 4606 "cs-parser.jay" +case 674: +#line 4654 "cs-parser.jay" { yyVal = Variance.None; } break; -case 672: - case_672(); - break; -case 673: - case_673(); - break; -case 674: - case_674(); - break; case 675: case_675(); break; case 676: -#line 4651 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_676(); break; case 677: case_677(); @@ -3322,107 +3329,113 @@ case 678: case_678(); break; case 679: - case_679(); +#line 4699 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 680: case_680(); break; -case 685: -#line 4695 "cs-parser.jay" +case 681: + case_681(); + break; +case 682: + case_682(); + break; +case 683: + case_683(); + break; +case 684: + case_684(); + break; +case 689: +#line 4748 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 686: -#line 4699 "cs-parser.jay" +case 690: +#line 4752 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 688: - case_688(); +case 692: + case_692(); break; -case 689: - case_689(); +case 693: + case_693(); break; -case 692: -#line 4733 "cs-parser.jay" +case 696: +#line 4786 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 693: -#line 4737 "cs-parser.jay" +case 697: +#line 4790 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 722: - case_722(); - break; -case 723: - case_723(); - break; -case 724: - case_724(); - break; -case 725: - case_725(); - 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 731: - case_731(); - break; -case 732: - case_732(); - break; case 733: -#line 4881 "cs-parser.jay" - { - yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); - } + case_733(); break; case 734: -#line 4885 "cs-parser.jay" - { - yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); - } + case_734(); break; case 735: case_735(); break; +case 736: + case_736(); + break; case 737: - case_737(); +#line 4934 "cs-parser.jay" + { + yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); + } break; case 738: -#line 4906 "cs-parser.jay" +#line 4938 "cs-parser.jay" { - yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop])); + yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 740: - case_740(); +case 739: + case_739(); break; case 741: case_741(); break; case 742: - case_742(); - break; -case 743: - case_743(); +#line 4959 "cs-parser.jay" + { + yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop])); + } break; case 744: case_744(); break; +case 745: + case_745(); + break; case 746: case_746(); break; @@ -3432,50 +3445,41 @@ case 747: case 748: case_748(); break; +case 750: + case_750(); + break; case 752: case_752(); break; -case 755: - case_755(); +case 753: + case_753(); break; -case 756: - case_756(); - break; -case 757: -#line 5031 "cs-parser.jay" - { - report.Error (145, lexer.Location, "A const field requires a value to be provided"); - } +case 754: + case_754(); break; case 758: case_758(); break; -case 763: - case_763(); - break; -case 765: - case_765(); +case 761: + case_761(); break; -case 766: - case_766(); +case 762: + case_762(); break; -case 767: - case_767(); +case 763: +#line 5094 "cs-parser.jay" + { + report.Error (145, lexer.Location, "A const field requires a value to be provided"); + } break; -case 768: -#line 5081 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } +case 764: + case_764(); break; case 769: case_769(); break; -case 770: -#line 5091 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } - break; case 771: -#line 5092 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } + case_771(); break; case 772: case_772(); @@ -3484,10 +3488,19 @@ case 773: case_773(); break; case 774: - case_774(); +#line 5144 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } + break; +case 775: + case_775(); + break; +case 776: +#line 5154 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } break; case 777: - case_777(); +#line 5155 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } break; case 778: case_778(); @@ -3496,43 +3509,31 @@ case 779: case_779(); break; case 780: -#line 5167 "cs-parser.jay" - { - start_block (GetLocation (yyVals[0+yyTop])); - } - break; -case 781: - case_781(); - break; -case 782: - case_782(); + case_780(); break; case 783: case_783(); break; +case 784: + case_784(); + break; case 785: case_785(); break; case 786: - case_786(); +#line 5230 "cs-parser.jay" + { + start_block (GetLocation (yyVals[0+yyTop])); + } break; case 787: case_787(); break; case 788: -#line 5218 "cs-parser.jay" - { - current_block = current_block.CreateSwitchBlock (lexer.Location); - } + case_788(); break; case 789: -#line 5222 "cs-parser.jay" - { - yyVal = new SwitchSection ((List) yyVals[-2+yyTop], current_block); - } - break; -case 790: - case_790(); + case_789(); break; case 791: case_791(); @@ -3541,11 +3542,26 @@ case 792: case_792(); break; case 793: -#line 5251 "cs-parser.jay" + case_793(); + break; +case 794: +#line 5281 "cs-parser.jay" { - yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); + current_block = current_block.CreateSwitchBlock (lexer.Location); + } + break; +case 795: +#line 5285 "cs-parser.jay" + { + yyVal = new SwitchSection ((List) yyVals[-2+yyTop], current_block); } break; +case 796: + case_796(); + break; +case 797: + case_797(); + break; case 798: case_798(); break; @@ -3553,40 +3569,19 @@ case 799: case_799(); break; case 800: - case_800(); - break; -case 801: - case_801(); - break; -case 802: - case_802(); - break; -case 803: - case_803(); - break; -case 804: -#line 5311 "cs-parser.jay" +#line 5319 "cs-parser.jay" { - yyVal = yyVals[0+yyTop]; + yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); } break; case 805: -#line 5319 "cs-parser.jay" - { - ((For) yyVals[-2+yyTop]).Initializer = (Statement) yyVals[-1+yyTop]; - } + case_805(); break; case 806: -#line 5323 "cs-parser.jay" - { - ((For) yyVals[-5+yyTop]).Condition = (BooleanExpression) yyVals[-1+yyTop]; - } + case_806(); break; case 807: -#line 5327 "cs-parser.jay" - { - ((For) yyVals[-8+yyTop]).Iterator = (Statement) yyVals[-1+yyTop]; - } + case_807(); break; case 808: case_808(); @@ -3595,25 +3590,47 @@ case 809: case_809(); break; case 810: -#line 5347 "cs-parser.jay" - { yyVal = new EmptyStatement (lexer.Location); } + case_810(); + break; +case 811: +#line 5380 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 812: case_812(); break; case 813: - case_813(); +#line 5395 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } + break; +case 814: + case_814(); break; case 815: -#line 5368 "cs-parser.jay" - { yyVal = null; } + case_815(); + break; +case 816: +#line 5416 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 817: -#line 5373 "cs-parser.jay" - { yyVal = new EmptyStatement (lexer.Location); } + case_817(); + break; +case 818: + case_818(); + break; +case 819: + case_819(); break; -case 821: - case_821(); +case 820: +#line 5449 "cs-parser.jay" + { yyVal = new EmptyStatement (lexer.Location); } break; case 822: case_822(); @@ -3621,17 +3638,22 @@ case 822: case 823: case_823(); break; -case 824: - case_824(); - break; case 825: - case_825(); - break; -case 826: - case_826(); +#line 5470 "cs-parser.jay" + { yyVal = null; } break; case 827: - case_827(); +#line 5475 "cs-parser.jay" + { yyVal = new EmptyStatement (lexer.Location); } + break; +case 831: + case_831(); + break; +case 832: + case_832(); + break; +case 833: + case_833(); break; case 834: case_834(); @@ -3645,26 +3667,11 @@ case 836: case 837: case_837(); break; -case 838: - case_838(); - break; -case 839: - case_839(); - break; -case 840: - case_840(); - break; -case 841: - case_841(); - break; -case 842: - case_842(); +case 844: + case_844(); break; case 845: -#line 5574 "cs-parser.jay" - { - yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); - } + case_845(); break; case 846: case_846(); @@ -3681,44 +3688,32 @@ case 849: case 850: case_850(); break; +case 851: + case_851(); + break; +case 852: + case_852(); + break; case 853: -#line 5623 "cs-parser.jay" - { - yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_853(); break; case 854: case_854(); break; case 855: -#line 5642 "cs-parser.jay" - { - yyVal = yyVals[-1+yyTop]; - } - break; -case 856: - case_856(); - break; -case 857: -#line 5660 "cs-parser.jay" - { - yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_855(); break; case 858: -#line 5667 "cs-parser.jay" +#line 5692 "cs-parser.jay" { - yyVal = new Unchecked ((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 859: case_859(); break; case 860: -#line 5677 "cs-parser.jay" - { - yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); - } + case_860(); break; case 861: case_861(); @@ -3729,34 +3724,43 @@ case 862: case 863: case_863(); break; -case 864: - case_864(); - break; -case 865: - case_865(); - break; case 866: - case_866(); +#line 5742 "cs-parser.jay" + { + yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 867: case_867(); break; case 868: - case_868(); +#line 5761 "cs-parser.jay" + { + yyVal = yyVals[-1+yyTop]; + } break; case 869: case_869(); break; case 870: - case_870(); +#line 5779 "cs-parser.jay" + { + yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } + break; +case 871: +#line 5786 "cs-parser.jay" + { + yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 872: case_872(); break; case 873: -#line 5782 "cs-parser.jay" +#line 5796 "cs-parser.jay" { - Error_MissingInitializer (lexer.Location); + yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } break; case 874: @@ -3787,34 +3791,28 @@ case 882: case_882(); break; case 883: -#line 5883 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } - break; -case 884: - case_884(); + case_883(); break; case 885: -#line 5898 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_885(); break; case 886: - case_886(); +#line 5901 "cs-parser.jay" + { + Error_MissingInitializer (lexer.Location); + } break; case 887: case_887(); break; +case 888: + case_888(); + break; case 889: case_889(); break; case 890: -#line 5943 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_890(); break; case 891: case_891(); @@ -3828,24 +3826,48 @@ case 893: case 894: case_894(); break; -case 898: - case_898(); +case 895: + case_895(); break; -case 904: -#line 6002 "cs-parser.jay" +case 896: +#line 6006 "cs-parser.jay" { - current_block = new Linq.QueryBlock (current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; -case 905: - case_905(); +case 897: + case_897(); break; -case 906: -#line 6021 "cs-parser.jay" +case 898: +#line 6022 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } + break; +case 899: + case_899(); + break; +case 900: + case_900(); + break; +case 901: + case_901(); + break; +case 903: + case_903(); + break; +case 904: + case_904(); + break; +case 905: +#line 6086 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; +case 906: + case_906(); + break; case 907: case_907(); break; @@ -3855,38 +3877,26 @@ case 908: case 909: case_909(); break; -case 910: - case_910(); - break; case 911: case_911(); break; -case 912: - case_912(); - break; -case 913: - case_913(); - break; -case 914: - case_914(); - break; -case 915: - case_915(); - break; case 917: -#line 6165 "cs-parser.jay" +#line 6140 "cs-parser.jay" { - yyVal = yyVals[0+yyTop]; + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; case 918: -#line 6172 "cs-parser.jay" + case_918(); + break; +case 919: +#line 6159 "cs-parser.jay" { - current_block = new Linq.QueryBlock (current_block, lexer.Location); + current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; -case 919: - case_919(); +case 920: + case_920(); break; case 921: case_921(); @@ -3894,6 +3904,9 @@ case 921: case 922: case_922(); break; +case 923: + case_923(); + break; case 924: case_924(); break; @@ -3901,10 +3914,7 @@ case 925: case_925(); break; case 926: -#line 6218 "cs-parser.jay" - { - yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); - } + case_926(); break; case 927: case_927(); @@ -3912,104 +3922,140 @@ case 927: case 928: case_928(); break; -case 929: -#line 6235 "cs-parser.jay" - { - yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); - } - break; case 930: case_930(); break; case 931: - case_931(); +#line 6313 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } break; -case 933: - case_933(); +case 932: + case_932(); break; case 934: case_934(); break; +case 935: + case_935(); + break; case 937: case_937(); break; case 938: case_938(); break; +case 939: +#line 6359 "cs-parser.jay" + { + yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); + } + break; +case 940: + case_940(); + break; +case 941: + case_941(); + break; +case 942: +#line 6376 "cs-parser.jay" + { + yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); + } + break; +case 943: + case_943(); + break; +case 944: + case_944(); + break; case 946: -#line 6357 "cs-parser.jay" + case_946(); + break; +case 947: + case_947(); + break; +case 950: + case_950(); + break; +case 951: + case_951(); + break; +case 959: +#line 6498 "cs-parser.jay" { module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop]; } break; -case 947: -#line 6364 "cs-parser.jay" +case 960: +#line 6505 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; } break; -case 948: - case_948(); +case 961: + case_961(); break; -case 949: - case_949(); +case 962: + case_962(); break; -case 950: -#line 6381 "cs-parser.jay" +case 963: +#line 6522 "cs-parser.jay" { yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], MemberCache.IndexerNameAlias, Location.Null); } break; -case 951: -#line 6385 "cs-parser.jay" +case 964: +#line 6526 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 952: - case_952(); +case 965: + case_965(); break; -case 953: - case_953(); +case 966: + case_966(); break; -case 954: - case_954(); +case 967: + case_967(); break; -case 955: - case_955(); +case 968: + case_968(); break; -case 957: -#line 6421 "cs-parser.jay" +case 970: +#line 6562 "cs-parser.jay" { yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]); } break; -case 959: -#line 6429 "cs-parser.jay" +case 972: +#line 6570 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 960: -#line 6433 "cs-parser.jay" +case 973: +#line 6574 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; -case 961: -#line 6440 "cs-parser.jay" +case 974: +#line 6581 "cs-parser.jay" { yyVal = new List (0); } break; -case 963: - case_963(); +case 976: + case_976(); break; -case 964: - case_964(); +case 977: + case_977(); break; -case 965: - case_965(); +case 978: + case_978(); break; #line default } @@ -4047,17 +4093,19 @@ case 965: All more than 3 lines long rules are wrapped into a method */ void case_6() -#line 395 "cs-parser.jay" +#line 398 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { Attributes attrs = (Attributes) yyVals[0+yyTop]; report.Error (1730, attrs.Attrs [0].Location, "Assembly and module attributes must precede all other elements except using clauses and extern alias declarations"); + + current_namespace.UnattachedAttributes = attrs; } } void case_8() -#line 407 "cs-parser.jay" +#line 412 "cs-parser.jay" { if (yyToken == Token.EXTERN_ALIAS) report.Error (439, lexer.Location, "An extern alias declaration must precede all other elements"); @@ -4066,7 +4114,7 @@ void case_8() } void case_13() -#line 427 "cs-parser.jay" +#line 432 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -4089,14 +4137,14 @@ void case_13() } void case_17() -#line 460 "cs-parser.jay" +#line 465 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_18() -#line 468 "cs-parser.jay" +#line 473 "cs-parser.jay" { var un = new UsingNamespace ((ATypeNameExpression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); current_namespace.AddUsing (un); @@ -4105,7 +4153,7 @@ void case_18() } void case_19() -#line 475 "cs-parser.jay" +#line 480 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") { @@ -4119,14 +4167,14 @@ void case_19() } void case_20() -#line 487 "cs-parser.jay" +#line 492 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_21() -#line 500 "cs-parser.jay" +#line 505 "cs-parser.jay" { Attributes attrs = (Attributes) yyVals[-2+yyTop]; var name = (MemberName) yyVals[0+yyTop]; @@ -4156,14 +4204,14 @@ void case_21() } void case_22() -#line 528 "cs-parser.jay" +#line 533 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_23() -#line 533 "cs-parser.jay" +#line 538 "cs-parser.jay" { if (yyVals[0+yyTop] != null) lbag.AddLocation (current_container, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); @@ -4174,14 +4222,14 @@ void case_23() } void case_24() -#line 545 "cs-parser.jay" +#line 550 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName (lt.Value, lt.Location); } void case_25() -#line 550 "cs-parser.jay" +#line 555 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], lt.Value, lt.Location) { @@ -4190,14 +4238,14 @@ void case_25() } void case_26() -#line 557 "cs-parser.jay" +#line 562 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new MemberName ("", lexer.Location); } void case_39() -#line 595 "cs-parser.jay" +#line 600 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { TypeContainer ds = (TypeContainer)yyVals[0+yyTop]; @@ -4218,17 +4266,15 @@ void case_39() } void case_41() -#line 617 "cs-parser.jay" +#line 622 "cs-parser.jay" { -#if FULL_AST current_namespace.UnattachedAttributes = (Attributes) yyVals[-1+yyTop]; -#endif report.Error (1518, lexer.Location, "Attributes must be attached to class, delegate, enum, interface or struct"); lexer.putback ('}'); } void case_49() -#line 652 "cs-parser.jay" +#line 655 "cs-parser.jay" { var sect = (List) yyVals[0+yyTop]; yyVal = new Attributes (sect); @@ -4241,7 +4287,7 @@ void case_49() } void case_50() -#line 663 "cs-parser.jay" +#line 666 "cs-parser.jay" { Attributes attrs = yyVals[-1+yyTop] as Attributes; var sect = (List) yyVals[0+yyTop]; @@ -4256,21 +4302,21 @@ void case_50() } void case_51() -#line 679 "cs-parser.jay" +#line 682 "cs-parser.jay" { lexer.parsing_attribute_section = true; savedOpenLocation = GetLocation (yyVals[0+yyTop]); } void case_52() -#line 684 "cs-parser.jay" +#line 687 "cs-parser.jay" { lexer.parsing_attribute_section = false; yyVal = yyVals[0+yyTop]; } void case_53() -#line 692 "cs-parser.jay" +#line 695 "cs-parser.jay" { current_attr_target = (string) yyVals[-1+yyTop]; if (current_attr_target == "assembly" || current_attr_target == "module") { @@ -4279,7 +4325,7 @@ void case_53() } void case_54() -#line 699 "cs-parser.jay" +#line 702 "cs-parser.jay" { /* when attribute target is invalid*/ if (current_attr_target == string.Empty) @@ -4297,7 +4343,7 @@ void case_54() } void case_55() -#line 715 "cs-parser.jay" +#line 718 "cs-parser.jay" { yyVal = yyVals[-2+yyTop]; if (yyVals[-1+yyTop] != null) { @@ -4308,7 +4354,7 @@ void case_55() } void case_56() -#line 727 "cs-parser.jay" +#line 730 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = CheckAttributeTarget (lt.Value, lt.Location); @@ -4316,7 +4362,7 @@ void case_56() } void case_59() -#line 735 "cs-parser.jay" +#line 738 "cs-parser.jay" { if (yyToken == Token.IDENTIFIER) { Error_SyntaxError (yyToken); @@ -4328,7 +4374,7 @@ void case_59() } void case_61() -#line 752 "cs-parser.jay" +#line 755 "cs-parser.jay" { var attrs = (List) yyVals[-2+yyTop]; attrs.Add ((Attribute) yyVals[0+yyTop]); @@ -4338,7 +4384,7 @@ void case_61() } void case_63() -#line 767 "cs-parser.jay" +#line 770 "cs-parser.jay" { --lexer.parsing_block; @@ -4354,19 +4400,22 @@ void case_63() attributeArgumentCommas.Add (savedAttrParenCloseLocation); lbag.AddLocation (yyVal, attributeArgumentCommas); attributeArgumentCommas.Clear (); + } else if (HadAttributeParens) { + lbag.AddLocation (yyVal, savedAttrParenOpenLocation, savedAttrParenCloseLocation); } } void case_66() -#line 793 "cs-parser.jay" +#line 798 "cs-parser.jay" { savedAttrParenOpenLocation = GetLocation (yyVals[-2+yyTop]); savedAttrParenCloseLocation = GetLocation (yyVals[0+yyTop]); yyVal = yyVals[-1+yyTop]; + HadAttributeParens = true; } void case_68() -#line 804 "cs-parser.jay" +#line 810 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); @@ -4374,7 +4423,7 @@ void case_68() } void case_69() -#line 810 "cs-parser.jay" +#line 816 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); @@ -4382,7 +4431,7 @@ void case_69() } void case_70() -#line 816 "cs-parser.jay" +#line 822 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] != null) { @@ -4399,7 +4448,7 @@ void case_70() } void case_71() -#line 831 "cs-parser.jay" +#line 837 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] == null) { @@ -4411,7 +4460,7 @@ void case_71() } void case_75() -#line 856 "cs-parser.jay" +#line 862 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4420,7 +4469,7 @@ void case_75() } void case_76() -#line 866 "cs-parser.jay" +#line 872 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "named argument"); @@ -4434,7 +4483,7 @@ void case_76() } void case_95() -#line 920 "cs-parser.jay" +#line 926 "cs-parser.jay" { report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration", GetSymbolName (yyToken)); @@ -4443,14 +4492,14 @@ void case_95() } void case_97() -#line 937 "cs-parser.jay" +#line 943 "cs-parser.jay" { push_current_container (new Struct (current_container, (MemberName) yyVals[0+yyTop], (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]); lbag.AddMember (current_container, GetModifierLocations (), GetLocation (yyVals[-2+yyTop])); } void case_98() -#line 943 "cs-parser.jay" +#line 949 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -4465,14 +4514,14 @@ void case_98() } void case_99() -#line 956 "cs-parser.jay" +#line 962 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_100() -#line 961 "cs-parser.jay" +#line 967 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -4480,7 +4529,7 @@ void case_100() } void case_101() -#line 967 "cs-parser.jay" +#line 973 "cs-parser.jay" { if (yyVals[0+yyTop] == null) { lbag.AppendToMember (current_container, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop])); @@ -4491,7 +4540,7 @@ void case_101() } void case_103() -#line 985 "cs-parser.jay" +#line 991 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var mod = (Modifiers) yyVals[-3+yyTop]; @@ -4506,7 +4555,7 @@ void case_103() } void case_104() -#line 998 "cs-parser.jay" +#line 1004 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4519,7 +4568,7 @@ void case_104() } void case_109() -#line 1028 "cs-parser.jay" +#line 1034 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4527,7 +4576,7 @@ void case_109() } void case_111() -#line 1041 "cs-parser.jay" +#line 1047 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -4535,14 +4584,14 @@ void case_111() } void case_112() -#line 1047 "cs-parser.jay" +#line 1053 "cs-parser.jay" { report.Error (145, lexer.Location, "A const field requires a value to be provided"); yyVal = null; } void case_115() -#line 1062 "cs-parser.jay" +#line 1068 "cs-parser.jay" { lexer.parsing_generic_declaration = false; @@ -4557,7 +4606,7 @@ void case_115() } void case_116() -#line 1077 "cs-parser.jay" +#line 1083 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4570,7 +4619,7 @@ void case_116() } void case_117() -#line 1090 "cs-parser.jay" +#line 1096 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "fixed size buffers"); @@ -4583,7 +4632,7 @@ void case_117() } void case_118() -#line 1101 "cs-parser.jay" +#line 1107 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4597,7 +4646,7 @@ void case_118() } void case_121() -#line 1124 "cs-parser.jay" +#line 1130 "cs-parser.jay" { ++lexer.parsing_block; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -4605,7 +4654,7 @@ void case_121() } void case_122() -#line 1130 "cs-parser.jay" +#line 1136 "cs-parser.jay" { --lexer.parsing_block; current_field.Initializer = (Expression) yyVals[0+yyTop]; @@ -4615,7 +4664,7 @@ void case_122() } void case_127() -#line 1157 "cs-parser.jay" +#line 1163 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); @@ -4623,7 +4672,7 @@ void case_127() } void case_129() -#line 1167 "cs-parser.jay" +#line 1173 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4632,7 +4681,7 @@ void case_129() } void case_134() -#line 1193 "cs-parser.jay" +#line 1199 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4640,7 +4689,7 @@ void case_134() } void case_136() -#line 1206 "cs-parser.jay" +#line 1212 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); @@ -4648,14 +4697,14 @@ void case_136() } void case_137() -#line 1212 "cs-parser.jay" +#line 1218 "cs-parser.jay" { report.Error (443, lexer.Location, "Value or constant expected"); yyVal = null; } void case_140() -#line 1222 "cs-parser.jay" +#line 1228 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); @@ -4663,7 +4712,7 @@ void case_140() } void case_141() -#line 1231 "cs-parser.jay" +#line 1237 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.NotAllowed; @@ -4675,7 +4724,7 @@ void case_141() } void case_142() -#line 1241 "cs-parser.jay" +#line 1247 "cs-parser.jay" { Method method = (Method) yyVals[-2+yyTop]; method.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -4703,7 +4752,7 @@ void case_142() } void case_145() -#line 1281 "cs-parser.jay" +#line 1287 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4724,14 +4773,14 @@ void case_145() } void case_147() -#line 1308 "cs-parser.jay" +#line 1314 "cs-parser.jay" { lexer.parsing_generic_declaration = false; valid_param_mod = ParameterModifierType.All; } void case_149() -#line 1317 "cs-parser.jay" +#line 1323 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4757,7 +4806,7 @@ void case_149() } void case_150() -#line 1344 "cs-parser.jay" +#line 1350 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-3+yyTop]; report.Error (1585, name.Location, @@ -4774,16 +4823,32 @@ void case_150() yyVal = method; } -void case_155() -#line 1373 "cs-parser.jay" +void case_151() +#line 1369 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + current_local_parameters = ParametersCompiled.Undefined; + + MemberName name = (MemberName) yyVals[-1+yyTop]; + var method = Method.Create (current_type, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-3+yyTop], + name, current_local_parameters, (Attributes) yyVals[-4+yyTop], false); + + if (doc_support) + method.DocComment = Lexer.consume_doc_comment (); + + yyVal = method; + } + +void case_156() +#line 1396 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); lbag.AddLocation (yyVal, parameterListCommas); } -void case_156() -#line 1379 "cs-parser.jay" +void case_157() +#line 1402 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add ((Parameter) yyVals[0+yyTop]); @@ -4793,8 +4858,8 @@ void case_156() lbag.AddLocation (yyVal, parameterListCommas); } -void case_157() -#line 1388 "cs-parser.jay" +void case_158() +#line 1411 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add (new ArglistParameter (GetLocation (yyVals[0+yyTop]))); @@ -4804,8 +4869,8 @@ void case_157() lbag.AddLocation (yyVal, parameterListCommas); } -void case_158() -#line 1397 "cs-parser.jay" +void case_159() +#line 1420 "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"); @@ -4814,8 +4879,8 @@ void case_158() lbag.AddLocation (yyVal, parameterListCommas); } -void case_159() -#line 1405 "cs-parser.jay" +void case_160() +#line 1428 "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"); @@ -4829,8 +4894,8 @@ void case_159() lbag.AddLocation (yyVal, parameterListCommas); } -void case_160() -#line 1418 "cs-parser.jay" +void case_161() +#line 1441 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4838,8 +4903,8 @@ void case_160() lbag.AddLocation (yyVal, parameterListCommas); } -void case_161() -#line 1425 "cs-parser.jay" +void case_162() +#line 1448 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4852,15 +4917,15 @@ void case_161() lbag.AddLocation (yyVal, parameterListCommas); } -void case_164() -#line 1445 "cs-parser.jay" +void case_165() +#line 1468 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = ParametersCompiled.EmptyReadOnlyParameters; } -void case_165() -#line 1453 "cs-parser.jay" +void case_166() +#line 1476 "cs-parser.jay" { parameters_bucket.Clear (); Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4870,8 +4935,8 @@ void case_165() yyVal = parameters_bucket; } -void case_166() -#line 1462 "cs-parser.jay" +void case_167() +#line 1485 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4890,16 +4955,16 @@ void case_166() yyVal = yyVals[-2+yyTop]; } -void case_167() -#line 1486 "cs-parser.jay" +void case_168() +#line 1509 "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_168() -#line 1495 "cs-parser.jay" +void case_169() +#line 1518 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name"); @@ -4907,17 +4972,25 @@ void case_168() lbag.AddLocation (yyVal, parameterModifierLocation); } -void case_169() -#line 1505 "cs-parser.jay" +void case_170() +#line 1525 "cs-parser.jay" { - Error_SyntaxError (yyToken); + Error_SyntaxError (yyToken); + Location l = GetLocation (yyVals[0+yyTop]); + yyVal = new Parameter (null, null, Parameter.Modifier.NONE, (Attributes) yyVals[-1+yyTop], l); + } + +void case_171() +#line 1534 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); Location l = GetLocation (yyVals[0+yyTop]); yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], null, (Parameter.Modifier) yyVals[-2+yyTop], (Attributes) yyVals[-3+yyTop], l); lbag.AddLocation (yyVal, parameterModifierLocation); } -void case_171() -#line 1520 "cs-parser.jay" +void case_173() +#line 1549 "cs-parser.jay" { --lexer.parsing_block; if (lang_version <= LanguageVersion.V_3) { @@ -4955,8 +5028,8 @@ void case_171() ((Parameter) yyVal).DefaultValue = new DefaultParameterValueExpression ((Expression) yyVals[0+yyTop]); } -void case_175() -#line 1569 "cs-parser.jay" +void case_177() +#line 1598 "cs-parser.jay" { Parameter.Modifier p2 = (Parameter.Modifier)yyVals[0+yyTop]; Parameter.Modifier mod = (Parameter.Modifier)yyVals[-1+yyTop] | p2; @@ -4978,8 +5051,8 @@ void case_175() yyVal = mod; } -void case_176() -#line 1593 "cs-parser.jay" +void case_178() +#line 1622 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Ref) == 0) Error_ParameterModifierNotValid ("ref", GetLocation (yyVals[0+yyTop])); @@ -4987,8 +5060,8 @@ void case_176() yyVal = Parameter.Modifier.REF; } -void case_177() -#line 1600 "cs-parser.jay" +void case_179() +#line 1629 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Out) == 0) Error_ParameterModifierNotValid ("out", GetLocation (yyVals[0+yyTop])); @@ -4996,8 +5069,8 @@ void case_177() yyVal = Parameter.Modifier.OUT; } -void case_178() -#line 1607 "cs-parser.jay" +void case_180() +#line 1636 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.This) == 0) Error_ParameterModifierNotValid ("this", GetLocation (yyVals[0+yyTop])); @@ -5008,16 +5081,16 @@ void case_178() yyVal = Parameter.Modifier.This; } -void case_179() -#line 1620 "cs-parser.jay" +void case_181() +#line 1649 "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); lbag.AddLocation (yyVal, savedLocation); } -void case_180() -#line 1626 "cs-parser.jay" +void case_182() +#line 1655 "cs-parser.jay" { report.Error (1751, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for a parameter array"); @@ -5026,23 +5099,23 @@ void case_180() lbag.AddLocation (yyVal, savedLocation); } -void case_181() -#line 1634 "cs-parser.jay" +void case_183() +#line 1663 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_182() -#line 1642 "cs-parser.jay" +void case_184() +#line 1671 "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"); savedLocation = GetLocation (yyVals[0+yyTop]); } -void case_183() -#line 1648 "cs-parser.jay" +void case_185() +#line 1677 "cs-parser.jay" { Parameter.Modifier mod = (Parameter.Modifier)yyVals[0+yyTop]; if ((mod & Parameter.Modifier.This) != 0) { @@ -5053,22 +5126,22 @@ void case_183() savedLocation = GetLocation (yyVals[-1+yyTop]); } -void case_185() -#line 1665 "cs-parser.jay" +void case_187() +#line 1694 "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_186() -#line 1676 "cs-parser.jay" +void case_188() +#line 1705 "cs-parser.jay" { if (doc_support) tmpComment = Lexer.consume_doc_comment (); } -void case_187() -#line 1681 "cs-parser.jay" +void case_189() +#line 1710 "cs-parser.jay" { var type = (FullNamedExpression) yyVals[-3+yyTop]; current_property = new Property (current_type, type, (Modifiers) yyVals[-4+yyTop], @@ -5083,8 +5156,8 @@ void case_187() lexer.PropertyParsing = true; } -void case_188() -#line 1695 "cs-parser.jay" +void case_190() +#line 1724 "cs-parser.jay" { lexer.PropertyParsing = false; @@ -5092,15 +5165,15 @@ void case_188() current_property.DocComment = ConsumeStoredComment (); } -void case_189() -#line 1702 "cs-parser.jay" +void case_191() +#line 1731 "cs-parser.jay" { lbag.AppendToMember (current_property, GetLocation (yyVals[0+yyTop])); current_property = null; } -void case_191() -#line 1716 "cs-parser.jay" +void case_193() +#line 1745 "cs-parser.jay" { valid_param_mod = 0; var type = (FullNamedExpression) yyVals[-6+yyTop]; @@ -5126,8 +5199,8 @@ void case_191() lexer.PropertyParsing = true; } -void case_193() -#line 1745 "cs-parser.jay" +void case_195() +#line 1774 "cs-parser.jay" { if (current_property.AccessorFirst != null && current_property.AccessorFirst.Block == null) ((Indexer) current_property).ParameterInfo.CheckParameters (current_property); @@ -5139,8 +5212,8 @@ void case_193() current_property = null; } -void case_198() -#line 1764 "cs-parser.jay" +void case_200() +#line 1793 "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 ()); @@ -5152,8 +5225,8 @@ void case_198() } } -void case_199() -#line 1778 "cs-parser.jay" +void case_201() +#line 1807 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5175,8 +5248,8 @@ void case_199() lexer.PropertyParsing = false; } -void case_200() -#line 1799 "cs-parser.jay" +void case_202() +#line 1828 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Get.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5198,8 +5271,8 @@ void case_200() Lexer.doc_state = XmlCommentState.NotAllowed; } -void case_201() -#line 1823 "cs-parser.jay" +void case_203() +#line 1852 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5226,8 +5299,8 @@ void case_201() lexer.PropertyParsing = false; } -void case_202() -#line 1849 "cs-parser.jay" +void case_204() +#line 1878 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Set.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5249,29 +5322,29 @@ void case_202() Lexer.doc_state = XmlCommentState.NotAllowed; } -void case_204() -#line 1874 "cs-parser.jay" +void case_206() +#line 1903 "cs-parser.jay" { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } -void case_205() -#line 1879 "cs-parser.jay" +void case_207() +#line 1908 "cs-parser.jay" { Error_SyntaxError (1043, yyToken, "Invalid accessor body"); yyVal = null; } -void case_207() -#line 1894 "cs-parser.jay" +void case_209() +#line 1923 "cs-parser.jay" { push_current_container (new Interface (current_container, (MemberName) yyVals[0+yyTop], (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]), yyVals[-3+yyTop]); lbag.AddMember (current_container, GetModifierLocations (), GetLocation (yyVals[-2+yyTop])); } -void case_208() -#line 1900 "cs-parser.jay" +void case_210() +#line 1929 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -5286,16 +5359,16 @@ void case_208() lexer.parsing_modifiers = true; } -void case_209() -#line 1914 "cs-parser.jay" +void case_211() +#line 1943 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_210() -#line 1920 "cs-parser.jay" +void case_212() +#line 1949 "cs-parser.jay" { if (yyVals[0+yyTop] == null) { lbag.AppendToMember (current_container, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); @@ -5305,8 +5378,8 @@ void case_210() yyVal = pop_current_class (); } -void case_226() -#line 1982 "cs-parser.jay" +void case_228() +#line 2011 "cs-parser.jay" { OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop]; if (decl != null) { @@ -5335,15 +5408,15 @@ void case_226() current_local_parameters = null; } -void case_230() -#line 2019 "cs-parser.jay" +void case_232() +#line 2048 "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_232() -#line 2031 "cs-parser.jay" +void case_234() +#line 2060 "cs-parser.jay" { valid_param_mod = 0; @@ -5384,8 +5457,8 @@ void case_232() lbag.AddLocation (yyVal, GetLocation (yyVals[-5+yyTop]), savedOperatorLocation, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_257() -#line 2107 "cs-parser.jay" +void case_259() +#line 2136 "cs-parser.jay" { valid_param_mod = 0; @@ -5401,8 +5474,8 @@ void case_257() lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_259() -#line 2126 "cs-parser.jay" +void case_261() +#line 2155 "cs-parser.jay" { valid_param_mod = 0; @@ -5418,24 +5491,24 @@ void case_259() lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_260() -#line 2141 "cs-parser.jay" +void case_262() +#line 2170 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; yyVal = new OperatorDeclaration (Operator.OpType.Implicit, null, GetLocation (yyVals[-1+yyTop])); } -void case_261() -#line 2147 "cs-parser.jay" +void case_263() +#line 2176 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; yyVal = new OperatorDeclaration (Operator.OpType.Explicit, null, GetLocation (yyVals[-1+yyTop])); } -void case_262() -#line 2157 "cs-parser.jay" +void case_264() +#line 2186 "cs-parser.jay" { Constructor c = (Constructor) yyVals[-1+yyTop]; c.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5448,8 +5521,8 @@ void case_262() Lexer.doc_state = XmlCommentState.Allowed; } -void case_263() -#line 2174 "cs-parser.jay" +void case_265() +#line 2203 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5459,8 +5532,8 @@ void case_263() valid_param_mod = ParameterModifierType.All; } -void case_264() -#line 2183 "cs-parser.jay" +void case_266() +#line 2212 "cs-parser.jay" { valid_param_mod = 0; current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; @@ -5490,8 +5563,8 @@ void case_264() start_block (lexer.Location); } -void case_265() -#line 2212 "cs-parser.jay" +void case_267() +#line 2241 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { var c = (Constructor) yyVals[-1+yyTop]; @@ -5507,39 +5580,39 @@ void case_265() yyVal = yyVals[-1+yyTop]; } -void case_271() -#line 2244 "cs-parser.jay" +void case_273() +#line 2273 "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_273() -#line 2254 "cs-parser.jay" +void case_275() +#line 2283 "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_274() -#line 2260 "cs-parser.jay" +void case_276() +#line 2289 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ConstructorThisInitializer (null, GetLocation (yyVals[0+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_275() -#line 2266 "cs-parser.jay" +void case_277() +#line 2295 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_276() -#line 2274 "cs-parser.jay" +void case_278() +#line 2303 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5549,8 +5622,8 @@ void case_276() current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; } -void case_277() -#line 2283 "cs-parser.jay" +void case_279() +#line 2312 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lt.Value != current_container.MemberName.Name){ @@ -5561,6 +5634,7 @@ void case_277() Destructor d = new Destructor (current_type, (Modifiers) yyVals[-6+yyTop], ParametersCompiled.EmptyReadOnlyParameters, (Attributes) yyVals[-7+yyTop], lt.Location); + d.Identifier = lt.Value; if (doc_support) d.DocComment = ConsumeStoredComment (); @@ -5571,8 +5645,8 @@ void case_277() current_local_parameters = null; } -void case_278() -#line 2308 "cs-parser.jay" +void case_280() +#line 2338 "cs-parser.jay" { current_event_field = new EventField (current_type, (FullNamedExpression) yyVals[-1+yyTop], (Modifiers) yyVals[-3+yyTop], (MemberName) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop]); current_type.AddMember (current_event_field); @@ -5585,8 +5659,8 @@ void case_278() yyVal = current_event_field; } -void case_279() -#line 2322 "cs-parser.jay" +void case_281() +#line 2352 "cs-parser.jay" { if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment (); @@ -5597,8 +5671,8 @@ void case_279() current_event_field = null; } -void case_280() -#line 2335 "cs-parser.jay" +void case_282() +#line 2365 "cs-parser.jay" { current_event = new EventProperty (current_type, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-4+yyTop], (MemberName) yyVals[-1+yyTop], (Attributes) yyVals[-5+yyTop]); current_type.AddMember (current_event); @@ -5607,8 +5681,8 @@ void case_280() lexer.EventParsing = true; } -void case_281() -#line 2343 "cs-parser.jay" +void case_283() +#line 2373 "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"); @@ -5616,8 +5690,8 @@ void case_281() lexer.EventParsing = false; } -void case_282() -#line 2350 "cs-parser.jay" +void case_284() +#line 2380 "cs-parser.jay" { if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment (); @@ -5629,23 +5703,23 @@ void case_282() current_local_parameters = null; } -void case_285() -#line 2369 "cs-parser.jay" +void case_287() +#line 2399 "cs-parser.jay" { --lexer.parsing_block; current_event_field.Initializer = (Expression) yyVals[0+yyTop]; } -void case_290() -#line 2393 "cs-parser.jay" +void case_292() +#line 2423 "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_292() -#line 2403 "cs-parser.jay" +void case_294() +#line 2433 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -5653,8 +5727,8 @@ void case_292() lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_293() -#line 2412 "cs-parser.jay" +void case_295() +#line 2442 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) { report.Error (68, lexer.Location, "`{0}': event in interface cannot have an initializer", @@ -5667,29 +5741,29 @@ void case_293() } } -void case_297() -#line 2433 "cs-parser.jay" +void case_299() +#line 2463 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } -void case_298() -#line 2438 "cs-parser.jay" +void case_300() +#line 2468 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } -void case_299() -#line 2443 "cs-parser.jay" +void case_301() +#line 2473 "cs-parser.jay" { report.Error (1055, GetLocation (yyVals[0+yyTop]), "An add or remove accessor expected"); yyVal = null; } -void case_300() -#line 2451 "cs-parser.jay" +void case_302() +#line 2481 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5702,8 +5776,8 @@ void case_300() lexer.EventParsing = false; } -void case_301() -#line 2463 "cs-parser.jay" +void case_303() +#line 2493 "cs-parser.jay" { lexer.EventParsing = true; @@ -5717,8 +5791,8 @@ void case_301() current_local_parameters = null; } -void case_302() -#line 2479 "cs-parser.jay" +void case_304() +#line 2509 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5731,8 +5805,8 @@ void case_302() lexer.EventParsing = false; } -void case_303() -#line 2491 "cs-parser.jay" +void case_305() +#line 2521 "cs-parser.jay" { lexer.EventParsing = true; @@ -5746,32 +5820,30 @@ void case_303() current_local_parameters = null; } -void case_304() -#line 2507 "cs-parser.jay" +void case_306() +#line 2537 "cs-parser.jay" { report.Error (73, lexer.Location, "An add or remove accessor must have a body"); yyVal = null; } -void case_306() -#line 2515 "cs-parser.jay" +void case_308() +#line 2546 "cs-parser.jay" { -#if FULL_AST current_type.UnattachedAttributes = (Attributes) yyVals[-1+yyTop]; -#endif report.Error (1519, GetLocation (yyVals[-1+yyTop]), "An attribute is missing member declaration"); lexer.putback ('}'); } -void case_307() -#line 2530 "cs-parser.jay" +void case_309() +#line 2559 "cs-parser.jay" { if (doc_support) enumTypeComment = Lexer.consume_doc_comment (); } -void case_308() -#line 2535 "cs-parser.jay" +void case_310() +#line 2564 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; @@ -5781,7 +5853,7 @@ void case_308() report.Error (1675, name.Location, "Enums cannot have type parameters"); } - push_current_container (new Enum (current_container, (TypeExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-5+yyTop], name, (Attributes) yyVals[-6+yyTop]), null); + push_current_container (new Enum (current_container, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-5+yyTop], name, (Attributes) yyVals[-6+yyTop]), null); if (yyVals[-2+yyTop] != null) { lbag.AddMember (current_container, GetModifierLocations (), GetLocation (yyVals[-4+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); } else { @@ -5789,16 +5861,16 @@ void case_308() } } -void case_309() -#line 2552 "cs-parser.jay" +void case_311() +#line 2581 "cs-parser.jay" { /* here will be evaluated after CLOSE_BLACE is consumed.*/ if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_310() -#line 2558 "cs-parser.jay" +void case_312() +#line 2587 "cs-parser.jay" { lbag.AppendToMember (current_container, GetLocation (yyVals[-1+yyTop])); if (yyVals[0+yyTop] != null) { @@ -5815,35 +5887,29 @@ void case_310() yyVal = pop_current_class (); } -void case_312() -#line 2578 "cs-parser.jay" +void case_314() +#line 2607 "cs-parser.jay" { - var te = yyVals[0+yyTop] as TypeExpression; - if (te == null || !EnumSpec.IsValidUnderlyingType (te.Type)) { - Enum.Error_1008 (GetLocation (yyVals[0+yyTop]), report); - yyVal = null; - } else { - savedLocation = GetLocation (yyVals[-1+yyTop]); - yyVal = yyVals[0+yyTop]; - } + savedLocation = GetLocation (yyVals[-1+yyTop]); + yyVal = yyVals[0+yyTop]; } -void case_313() -#line 2589 "cs-parser.jay" +void case_315() +#line 2612 "cs-parser.jay" { Error_TypeExpected (GetLocation (yyVals[-1+yyTop])); yyVal = null; } -void case_318() -#line 2607 "cs-parser.jay" +void case_320() +#line 2630 "cs-parser.jay" { lbag.AppendToMember (current_container, GetLocation (yyVals[-1+yyTop])); yyVal = yyVals[0+yyTop]; } -void case_319() -#line 2615 "cs-parser.jay" +void case_321() +#line 2638 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) yyVals[-1+yyTop]); @@ -5857,8 +5923,8 @@ void case_319() yyVal = em; } -void case_320() -#line 2628 "cs-parser.jay" +void case_322() +#line 2651 "cs-parser.jay" { ++lexer.parsing_block; if (doc_support) { @@ -5867,8 +5933,8 @@ void case_320() } } -void case_321() -#line 2636 "cs-parser.jay" +void case_323() +#line 2659 "cs-parser.jay" { --lexer.parsing_block; @@ -5883,8 +5949,8 @@ void case_321() yyVal = em; } -void case_323() -#line 2661 "cs-parser.jay" +void case_325() +#line 2684 "cs-parser.jay" { valid_param_mod = 0; @@ -5900,8 +5966,8 @@ void case_323() lexer.ConstraintsParsing = true; } -void case_325() -#line 2680 "cs-parser.jay" +void case_327() +#line 2703 "cs-parser.jay" { if (doc_support) { current_delegate.DocComment = Lexer.consume_doc_comment (); @@ -5917,8 +5983,8 @@ void case_325() current_delegate = null; } -void case_327() -#line 2699 "cs-parser.jay" +void case_329() +#line 2722 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "nullable types"); @@ -5926,8 +5992,8 @@ void case_327() yyVal = ComposedTypeSpecifier.CreateNullable (GetLocation (yyVals[0+yyTop])); } -void case_329() -#line 2710 "cs-parser.jay" +void case_331() +#line 2733 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -5936,23 +6002,23 @@ void case_329() lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_331() -#line 2722 "cs-parser.jay" +void case_333() +#line 2745 "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_332() -#line 2731 "cs-parser.jay" +void case_334() +#line 2754 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_334() -#line 2743 "cs-parser.jay" +void case_336() +#line 2766 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); @@ -5964,15 +6030,15 @@ void case_334() yyVal = yyVals[-1+yyTop];; } -void case_335() -#line 2754 "cs-parser.jay" +void case_337() +#line 2777 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = new TypeArguments (); } -void case_336() -#line 2762 "cs-parser.jay" +void case_338() +#line 2785 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -5980,8 +6046,8 @@ void case_336() locationListStack.Push (new List ()); } -void case_337() -#line 2769 "cs-parser.jay" +void case_339() +#line 2792 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -5989,16 +6055,16 @@ void case_337() locationListStack.Peek ().Add (GetLocation (yyVals[-1+yyTop])); } -void case_339() -#line 2786 "cs-parser.jay" +void case_341() +#line 2809 "cs-parser.jay" { lexer.parsing_generic_declaration = false; var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new MemberName (lt.Value, (TypeParameters)yyVals[0+yyTop], lt.Location); } -void case_340() -#line 2795 "cs-parser.jay" +void case_342() +#line 2818 "cs-parser.jay" { MemberName mn = (MemberName)yyVals[0+yyTop]; if (mn.TypeParameters != null) @@ -6006,38 +6072,38 @@ void case_340() mn.GetSignatureForError ())); } -void case_342() -#line 2806 "cs-parser.jay" +void case_344() +#line 2829 "cs-parser.jay" { lexer.parsing_generic_declaration = false; var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new MemberName (lt.Value, (TypeParameters) yyVals[0+yyTop], (ATypeNameExpression) yyVals[-2+yyTop], lt.Location); } -void case_343() -#line 2815 "cs-parser.jay" +void case_345() +#line 2838 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeDefinition.DefaultIndexerName, GetLocation (yyVals[0+yyTop])); } -void case_344() -#line 2820 "cs-parser.jay" +void case_346() +#line 2843 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeDefinition.DefaultIndexerName, null, (ATypeNameExpression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } -void case_345() -#line 2828 "cs-parser.jay" +void case_347() +#line 2851 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_346() -#line 2834 "cs-parser.jay" +void case_348() +#line 2857 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -6046,50 +6112,54 @@ void case_346() lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_347() -#line 2842 "cs-parser.jay" +void case_349() +#line 2865 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; yyVal = new MemberAccess ((ATypeNameExpression) yyVals[-3+yyTop], lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_349() -#line 2852 "cs-parser.jay" +void case_351() +#line 2875 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); yyVal = yyVals[-1+yyTop]; - lbag.AppendTo (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); + var list = locationListStack.Pop (); + list.Add (GetLocation (yyVals[-2+yyTop])); + list.Add (GetLocation (yyVals[-1+yyTop])); + lbag.AddLocation (yyVals[-1+yyTop], list); } -void case_350() -#line 2863 "cs-parser.jay" +void case_352() +#line 2889 "cs-parser.jay" { var tparams = new TypeParameters (); tparams.Add ((TypeParameter)yyVals[0+yyTop]); yyVal = tparams; + locationListStack.Push (new List ()); } -void case_351() -#line 2869 "cs-parser.jay" +void case_353() +#line 2896 "cs-parser.jay" { var tparams = (TypeParameters) yyVals[-2+yyTop]; tparams.Add ((TypeParameter)yyVals[0+yyTop]); yyVal = tparams; - lbag.AddLocation (yyVals[0+yyTop], GetLocation (yyVals[0+yyTop])); + locationListStack.Peek ().Add (GetLocation (yyVals[-1+yyTop])); } -void case_352() -#line 2879 "cs-parser.jay" +void case_354() +#line 2906 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop]; yyVal = new TypeParameter (new MemberName (lt.Value, lt.Location), (Attributes)yyVals[-2+yyTop], (Variance) yyVals[-1+yyTop]); } -void case_353() -#line 2884 "cs-parser.jay" +void case_355() +#line 2911 "cs-parser.jay" { if (GetTokenName (yyToken) == "type") report.Error (81, GetLocation (yyVals[0+yyTop]), "Type parameter declaration must be an identifier not a type"); @@ -6099,29 +6169,29 @@ void case_353() yyVal = new TypeParameter (MemberName.Null, null, Variance.None); } -void case_358() -#line 2918 "cs-parser.jay" +void case_360() +#line 2945 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_360() -#line 2927 "cs-parser.jay" +void case_362() +#line 2954 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_362() -#line 2936 "cs-parser.jay" +void case_364() +#line 2963 "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_365() -#line 2952 "cs-parser.jay" +void case_367() +#line 2979 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { yyVal = new ComposedCast ((ATypeNameExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); @@ -6134,23 +6204,23 @@ void case_365() } } -void case_367() -#line 2968 "cs-parser.jay" +void case_369() +#line 2995 "cs-parser.jay" { if (yyVals[0+yyTop] != null) yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_370() -#line 2984 "cs-parser.jay" +void case_372() +#line 3011 "cs-parser.jay" { var types = new List (2); types.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = types; } -void case_371() -#line 2990 "cs-parser.jay" +void case_373() +#line 3017 "cs-parser.jay" { var types = (List) yyVals[-2+yyTop]; types.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -6158,8 +6228,8 @@ void case_371() yyVal = types; } -void case_372() -#line 3000 "cs-parser.jay" +void case_374() +#line 3027 "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 ()); @@ -6167,36 +6237,29 @@ void case_372() yyVal = yyVals[0+yyTop]; } -void case_373() -#line 3007 "cs-parser.jay" -{ - Error_TypeExpected (lexer.Location); - yyVal = null; - } - -void case_410() -#line 3069 "cs-parser.jay" +void case_411() +#line 3091 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_411() -#line 3073 "cs-parser.jay" +void case_412() +#line 3095 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location); } -void case_422() -#line 3114 "cs-parser.jay" +void case_423() +#line 3136 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_424() -#line 3126 "cs-parser.jay" +void case_425() +#line 3148 "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) { @@ -6204,8 +6267,8 @@ void case_424() }; } -void case_425() -#line 3133 "cs-parser.jay" +void case_426() +#line 3155 "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) { @@ -6213,8 +6276,8 @@ void case_425() }; } -void case_426() -#line 3140 "cs-parser.jay" +void case_427() +#line 3162 "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) { @@ -6222,8 +6285,8 @@ void case_426() }; } -void case_427() -#line 3147 "cs-parser.jay" +void case_428() +#line 3169 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6232,29 +6295,29 @@ void case_427() lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_429() -#line 3157 "cs-parser.jay" +void case_430() +#line 3179 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } -void case_431() -#line 3165 "cs-parser.jay" +void case_432() +#line 3187 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } -void case_432() -#line 3173 "cs-parser.jay" +void case_433() +#line 3195 "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_435() -#line 3186 "cs-parser.jay" +void case_436() +#line 3208 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) { yyVal = CollectionOrObjectInitializers.Empty; @@ -6265,23 +6328,23 @@ void case_435() } } -void case_436() -#line 3196 "cs-parser.jay" +void case_437() +#line 3218 "cs-parser.jay" { yyVal = new CollectionOrObjectInitializers ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_439() -#line 3212 "cs-parser.jay" +void case_440() +#line 3234 "cs-parser.jay" { var a = new List (); a.Add ((Expression) yyVals[0+yyTop]); yyVal = a; } -void case_440() -#line 3218 "cs-parser.jay" +void case_441() +#line 3240 "cs-parser.jay" { var a = (List)yyVals[-2+yyTop]; a.Add ((Expression) yyVals[0+yyTop]); @@ -6289,23 +6352,23 @@ void case_440() yyVal = a; } -void case_441() -#line 3224 "cs-parser.jay" +void case_442() +#line 3246 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } -void case_442() -#line 3232 "cs-parser.jay" +void case_443() +#line 3254 "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_444() -#line 3241 "cs-parser.jay" +void case_445() +#line 3263 "cs-parser.jay" { CompletionSimpleName csn = yyVals[-1+yyTop] as CompletionSimpleName; if (csn == null) @@ -6314,32 +6377,34 @@ void case_444() yyVal = new CompletionElementInitializer (csn.Prefix, csn.Location); } -void case_445() -#line 3249 "cs-parser.jay" +void case_446() +#line 3271 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) yyVal = null; - else + else { yyVal = new CollectionElementInitializer ((List)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); + } } -void case_446() -#line 3256 "cs-parser.jay" +void case_447() +#line 3280 "cs-parser.jay" { report.Error (1920, GetLocation (yyVals[-1+yyTop]), "An element initializer cannot be empty"); yyVal = null; } -void case_451() -#line 3274 "cs-parser.jay" +void case_452() +#line 3298 "cs-parser.jay" { Arguments list = new Arguments (4); list.Add ((Argument) yyVals[0+yyTop]); yyVal = list; } -void case_452() -#line 3280 "cs-parser.jay" +void case_453() +#line 3304 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; if (list [list.Count - 1] is NamedArgument) @@ -6350,8 +6415,8 @@ void case_452() yyVal = list; } -void case_453() -#line 3290 "cs-parser.jay" +void case_454() +#line 3314 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; NamedArgument a = (NamedArgument) yyVals[0+yyTop]; @@ -6367,65 +6432,79 @@ void case_453() yyVal = list; } -void case_454() -#line 3305 "cs-parser.jay" +void case_455() +#line 3329 "cs-parser.jay" { - report.Error (839, GetLocation (yyVals[0+yyTop]), "An argument is missing"); - yyVal = yyVals[-1+yyTop]; + Error_SyntaxError (yyToken); + yyVal = yyVals[-2+yyTop]; } -void case_455() -#line 3310 "cs-parser.jay" +void case_456() +#line 3334 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[-1+yyTop]), "An argument is missing"); yyVal = null; } -void case_460() -#line 3331 "cs-parser.jay" +void case_461() +#line 3355 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_461() -#line 3336 "cs-parser.jay" +void case_462() +#line 3360 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_462() -#line 3341 "cs-parser.jay" +void case_463() +#line 3365 "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_463() -#line 3346 "cs-parser.jay" +void case_464() +#line 3370 "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_465() -#line 3358 "cs-parser.jay" +void case_466() +#line 3382 "cs-parser.jay" { yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } +void case_467() +#line 3387 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + yyVal = new ElementAccess ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); + } + void case_468() -#line 3374 "cs-parser.jay" +#line 3392 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + yyVal = new ElementAccess ((Expression) yyVals[-2+yyTop], null, GetLocation (yyVals[-1+yyTop])); + } + +void case_469() +#line 3400 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); yyVal = list; } -void case_469() -#line 3380 "cs-parser.jay" +void case_470() +#line 3406 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6433,23 +6512,23 @@ void case_469() yyVal = list; } -void case_470() -#line 3386 "cs-parser.jay" +void case_471() +#line 3412 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } -void case_471() -#line 3394 "cs-parser.jay" +void case_472() +#line 3420 "cs-parser.jay" { Arguments args = new Arguments (4); args.Add ((Argument) yyVals[0+yyTop]); yyVal = args; } -void case_472() -#line 3400 "cs-parser.jay" +void case_473() +#line 3426 "cs-parser.jay" { Arguments args = (Arguments) yyVals[-2+yyTop]; if (args [args.Count - 1] is NamedArgument && !(yyVals[0+yyTop] is NamedArgument)) @@ -6460,22 +6539,22 @@ void case_472() yyVal = args; } -void case_476() -#line 3428 "cs-parser.jay" +void case_477() +#line 3454 "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_477() -#line 3433 "cs-parser.jay" +void case_478() +#line 3459 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess (null, null, GetLocation (yyVals[-1+yyTop])); } -void case_480() -#line 3455 "cs-parser.jay" +void case_481() +#line 3481 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { if (lang_version <= LanguageVersion.ISO_2) @@ -6489,8 +6568,8 @@ void case_480() lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_481() -#line 3468 "cs-parser.jay" +void case_482() +#line 3494 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers"); @@ -6498,8 +6577,8 @@ void case_481() yyVal = new NewInitialize ((FullNamedExpression) yyVals[-1+yyTop], null, (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_482() -#line 3480 "cs-parser.jay" +void case_483() +#line 3506 "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])) { @@ -6508,8 +6587,8 @@ void case_482() lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_483() -#line 3488 "cs-parser.jay" +void case_484() +#line 3514 "cs-parser.jay" { if (yyVals[0+yyTop] == null) report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer"); @@ -6517,8 +6596,8 @@ void case_483() yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); } -void case_484() -#line 3495 "cs-parser.jay" +void case_485() +#line 3521 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays"); @@ -6526,29 +6605,30 @@ void case_484() yyVal = new ImplicitlyTypedArrayCreation ((ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_485() -#line 3502 "cs-parser.jay" +void case_486() +#line 3528 "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_486() -#line 3507 "cs-parser.jay" +void case_487() +#line 3533 "cs-parser.jay" { - Error_SyntaxError (1526, yyToken, "Unexpected symbol"); - yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); + Error_SyntaxError (yyToken); + /* It can be any of new expression, create the most common one*/ + yyVal = new New ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } -void case_488() -#line 3518 "cs-parser.jay" +void case_489() +#line 3545 "cs-parser.jay" { --lexer.parsing_type; yyVal = yyVals[0+yyTop]; } -void case_489() -#line 3526 "cs-parser.jay" +void case_490() +#line 3553 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types"); @@ -6559,16 +6639,16 @@ void case_489() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_494() -#line 3549 "cs-parser.jay" +void case_495() +#line 3576 "cs-parser.jay" { var a = new List (4); a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); yyVal = a; } -void case_495() -#line 3555 "cs-parser.jay" +void case_496() +#line 3582 "cs-parser.jay" { var a = (List) yyVals[-2+yyTop]; a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); @@ -6577,60 +6657,60 @@ void case_495() yyVal = a; } -void case_496() -#line 3566 "cs-parser.jay" +void case_497() +#line 3593 "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_497() -#line 3572 "cs-parser.jay" +void case_498() +#line 3599 "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_498() -#line 3578 "cs-parser.jay" +void case_499() +#line 3605 "cs-parser.jay" { MemberAccess ma = (MemberAccess) yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location); } -void case_499() -#line 3583 "cs-parser.jay" +void case_500() +#line 3610 "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_503() -#line 3598 "cs-parser.jay" +void case_504() +#line 3625 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_504() -#line 3606 "cs-parser.jay" +void case_505() +#line 3633 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension (1, GetLocation (yyVals[-1+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_505() -#line 3611 "cs-parser.jay" +void case_506() +#line 3638 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension ((int)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_510() -#line 3641 "cs-parser.jay" +void case_511() +#line 3668 "cs-parser.jay" { var ai = new ArrayInitializer (0, GetLocation (yyVals[-1+yyTop])); ai.VariableDeclaration = current_variable; @@ -6638,8 +6718,8 @@ void case_510() yyVal = ai; } -void case_511() -#line 3648 "cs-parser.jay" +void case_512() +#line 3675 "cs-parser.jay" { var ai = new ArrayInitializer ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); ai.VariableDeclaration = current_variable; @@ -6651,16 +6731,16 @@ void case_511() yyVal = ai; } -void case_512() -#line 3662 "cs-parser.jay" +void case_513() +#line 3689 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); yyVal = list; } -void case_513() -#line 3668 "cs-parser.jay" +void case_514() +#line 3695 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6668,31 +6748,31 @@ void case_513() yyVal = list; } -void case_515() -#line 3682 "cs-parser.jay" +void case_516() +#line 3709 "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_518() -#line 3693 "cs-parser.jay" +void case_519() +#line 3720 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } -void case_519() -#line 3701 "cs-parser.jay" +void case_520() +#line 3728 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (int) yyVals[0+yyTop], lt.Location); } -void case_520() -#line 3707 "cs-parser.jay" +void case_521() +#line 3734 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6701,8 +6781,8 @@ void case_520() lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_521() -#line 3715 "cs-parser.jay" +void case_522() +#line 3742 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -6711,8 +6791,8 @@ void case_521() }; } -void case_522() -#line 3723 "cs-parser.jay" +void case_523() +#line 3750 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6721,8 +6801,8 @@ void case_522() }; } -void case_523() -#line 3731 "cs-parser.jay" +void case_524() +#line 3758 "cs-parser.jay" { var tne = (ATypeNameExpression) yyVals[-3+yyTop]; if (tne.HasTypeArguments) @@ -6734,8 +6814,8 @@ void case_523() }; } -void case_524() -#line 3745 "cs-parser.jay" +void case_525() +#line 3772 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics"); @@ -6743,8 +6823,8 @@ void case_524() yyVal = yyVals[0+yyTop]; } -void case_525() -#line 3755 "cs-parser.jay" +void case_526() +#line 3782 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; if (lang_version == LanguageVersion.ISO_1) @@ -6753,36 +6833,36 @@ void case_525() yyVal = lt; } -void case_526() -#line 3766 "cs-parser.jay" +void case_527() +#line 3793 "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_527() -#line 3774 "cs-parser.jay" +void case_528() +#line 3801 "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_528() -#line 3782 "cs-parser.jay" +void case_529() +#line 3809 "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_529() -#line 3790 "cs-parser.jay" +void case_530() +#line 3817 "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_531() -#line 3802 "cs-parser.jay" +void case_532() +#line 3829 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); if ((ParametersCompiled) yyVals[-2+yyTop] != ParametersCompiled.Undefined) { @@ -6792,8 +6872,8 @@ void case_531() } } -void case_533() -#line 3815 "cs-parser.jay" +void case_534() +#line 3842 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); @@ -6804,8 +6884,8 @@ void case_533() } } -void case_537() -#line 3840 "cs-parser.jay" +void case_538() +#line 3867 "cs-parser.jay" { valid_param_mod = 0; yyVal = yyVals[-1+yyTop]; @@ -6813,8 +6893,8 @@ void case_537() savedCloseLocation = GetLocation (yyVals[-2+yyTop]); } -void case_538() -#line 3850 "cs-parser.jay" +void case_539() +#line 3877 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression"); @@ -6823,19 +6903,27 @@ void case_538() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_542() -#line 3870 "cs-parser.jay" +void case_543() +#line 3897 "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_543() -#line 3875 "cs-parser.jay" +void case_544() +#line 3902 "cs-parser.jay" { if (!async_block) { - report.Error (1992, GetLocation (yyVals[-1+yyTop]), - "The `await' operator can only be used when its containing method or lambda expression is marked with the `async' modifier"); + if (current_anonymous_method is LambdaExpression) { + report.Error (4034, GetLocation (yyVals[-1+yyTop]), + "The `await' operator can only be used when its containing lambda expression is marked with the `async' modifier"); + } else if (current_anonymous_method is AnonymousMethodExpression) { + report.Error (4035, GetLocation (yyVals[-1+yyTop]), + "The `await' operator can only be used when its containing anonymous method is marked with the `async' modifier"); + } else { + report.Error (4033, GetLocation (yyVals[-1+yyTop]), + "The `await' operator can only be used when its containing method is marked with the `async' modifier"); + } } else { current_block.Explicit.RegisterAsyncAwait (); } @@ -6843,134 +6931,134 @@ void case_543() yyVal = new Await ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_552() -#line 3922 "cs-parser.jay" +void case_553() +#line 3957 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_553() -#line 3927 "cs-parser.jay" +void case_554() +#line 3962 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_554() -#line 3932 "cs-parser.jay" +void case_555() +#line 3967 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_556() -#line 3941 "cs-parser.jay" +void case_557() +#line 3976 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_558() -#line 3950 "cs-parser.jay" +void case_559() +#line 3985 "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_562() -#line 3967 "cs-parser.jay" +void case_563() +#line 4002 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_563() -#line 3972 "cs-parser.jay" +void case_564() +#line 4007 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_565() -#line 3981 "cs-parser.jay" +void case_566() +#line 4016 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_566() -#line 3986 "cs-parser.jay" +void case_567() +#line 4021 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_567() -#line 3991 "cs-parser.jay" +void case_568() +#line 4026 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LessThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_568() -#line 3996 "cs-parser.jay" +void case_569() +#line 4031 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_570() -#line 4005 "cs-parser.jay" +void case_571() +#line 4040 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Equality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_571() -#line 4010 "cs-parser.jay" +void case_572() +#line 4045 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.Inequality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_573() -#line 4019 "cs-parser.jay" +void case_574() +#line 4054 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_575() -#line 4028 "cs-parser.jay" +void case_576() +#line 4063 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_577() -#line 4037 "cs-parser.jay" +void case_578() +#line 4072 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_579() -#line 4046 "cs-parser.jay" +void case_580() +#line 4081 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_581() -#line 4055 "cs-parser.jay" +void case_582() +#line 4090 "cs-parser.jay" { yyVal = new Binary (Binary.Operator.LogicalOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_583() -#line 4064 "cs-parser.jay" +void case_584() +#line 4099 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator"); @@ -6978,85 +7066,92 @@ void case_583() yyVal = new Nullable.NullCoalescingOperator ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_585() -#line 4075 "cs-parser.jay" +void case_586() +#line 4110 "cs-parser.jay" { yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-4+yyTop]), (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_587() -#line 4087 "cs-parser.jay" +#line 4115 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + yyVal = new Conditional (new BooleanExpression ((Expression) yyVals[-3+yyTop]), (Expression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); + } + +void case_589() +#line 4127 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_588() -#line 4092 "cs-parser.jay" +void case_590() +#line 4132 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_589() -#line 4097 "cs-parser.jay" +void case_591() +#line 4137 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_590() -#line 4102 "cs-parser.jay" +void case_592() +#line 4142 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_591() -#line 4107 "cs-parser.jay" +void case_593() +#line 4147 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_592() -#line 4112 "cs-parser.jay" +void case_594() +#line 4152 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_593() -#line 4117 "cs-parser.jay" +void case_595() +#line 4157 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_594() -#line 4122 "cs-parser.jay" +void case_596() +#line 4162 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_595() -#line 4127 "cs-parser.jay" +void case_597() +#line 4167 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_596() -#line 4132 "cs-parser.jay" +void case_598() +#line 4172 "cs-parser.jay" { yyVal = new CompoundAssign ( Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_597() -#line 4140 "cs-parser.jay" +void case_599() +#line 4180 "cs-parser.jay" { var pars = new List (4); pars.Add ((Parameter) yyVals[0+yyTop]); @@ -7064,8 +7159,8 @@ void case_597() yyVal = pars; } -void case_598() -#line 4147 "cs-parser.jay" +void case_600() +#line 4187 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter)yyVals[0+yyTop]; @@ -7079,39 +7174,39 @@ void case_598() yyVal = pars; } -void case_599() -#line 4163 "cs-parser.jay" +void case_601() +#line 4203 "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_600() -#line 4169 "cs-parser.jay" +void case_602() +#line 4209 "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_601() -#line 4175 "cs-parser.jay" +void case_603() +#line 4215 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location); } -void case_603() -#line 4183 "cs-parser.jay" +void case_605() +#line 4223 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); lbag.AddLocation (yyVal, parameterListCommas); } -void case_607() -#line 4200 "cs-parser.jay" +void case_609() +#line 4240 "cs-parser.jay" { Block b = end_block (Location.Null); b.IsCompilerGenerated = true; @@ -7119,94 +7214,94 @@ void case_607() yyVal = b; } -void case_609() -#line 4211 "cs-parser.jay" +void case_611() +#line 4251 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = EmptyExpression.Null; } -void case_610() -#line 4219 "cs-parser.jay" +void case_612() +#line 4259 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location); start_anonymous (true, new ParametersCompiled (p), false, lt.Location); } -void case_611() -#line 4225 "cs-parser.jay" +void case_613() +#line 4265 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_612() -#line 4230 "cs-parser.jay" +void case_614() +#line 4270 "cs-parser.jay" { 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_613() -#line 4236 "cs-parser.jay" +void case_615() +#line 4276 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_615() -#line 4245 "cs-parser.jay" +void case_617() +#line 4285 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], false, GetLocation (yyVals[-4+yyTop])); } -void case_616() -#line 4250 "cs-parser.jay" +void case_618() +#line 4290 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_618() -#line 4259 "cs-parser.jay" +void case_620() +#line 4299 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], true, GetLocation (yyVals[-5+yyTop])); } -void case_619() -#line 4264 "cs-parser.jay" +void case_621() +#line 4304 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_626() -#line 4287 "cs-parser.jay" +void case_628() +#line 4327 "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_627() -#line 4292 "cs-parser.jay" +void case_629() +#line 4332 "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_628() -#line 4297 "cs-parser.jay" +void case_630() +#line 4337 "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_632() -#line 4326 "cs-parser.jay" +void case_634() +#line 4366 "cs-parser.jay" { Class c = new Class (current_container, (MemberName) yyVals[0+yyTop], (Modifiers) yyVals[-4+yyTop], (Attributes) yyVals[-5+yyTop]); if (((c.ModFlags & Modifiers.STATIC) != 0) && lang_version == LanguageVersion.ISO_1) { @@ -7217,8 +7312,8 @@ void case_632() lbag.AddMember (current_container, GetModifierLocations (), GetLocation (yyVals[-2+yyTop])); } -void case_633() -#line 4337 "cs-parser.jay" +void case_635() +#line 4377 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -7233,16 +7328,16 @@ void case_633() lexer.parsing_modifiers = true; } -void case_634() -#line 4351 "cs-parser.jay" +void case_636() +#line 4391 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_635() -#line 4357 "cs-parser.jay" +void case_637() +#line 4397 "cs-parser.jay" { if (yyVals[0+yyTop] == null) { lbag.AppendToMember (current_container, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); @@ -7252,16 +7347,16 @@ void case_635() yyVal = pop_current_class (); } -void case_638() -#line 4376 "cs-parser.jay" +void case_640() +#line 4416 "cs-parser.jay" { mod_locations = null; yyVal = ModifierNone; lexer.parsing_modifiers = false; } -void case_641() -#line 4390 "cs-parser.jay" +void case_643() +#line 4430 "cs-parser.jay" { var m1 = (Modifiers) yyVals[-1+yyTop]; var m2 = (Modifiers) yyVals[0+yyTop]; @@ -7278,8 +7373,8 @@ void case_641() yyVal = m1 | m2; } -void case_642() -#line 4409 "cs-parser.jay" +void case_644() +#line 4449 "cs-parser.jay" { yyVal = Modifiers.NEW; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7288,92 +7383,92 @@ void case_642() report.Error (1530, GetLocation (yyVals[0+yyTop]), "Keyword `new' is not allowed on namespace elements"); } -void case_643() -#line 4417 "cs-parser.jay" +void case_645() +#line 4457 "cs-parser.jay" { yyVal = Modifiers.PUBLIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_644() -#line 4422 "cs-parser.jay" +void case_646() +#line 4462 "cs-parser.jay" { yyVal = Modifiers.PROTECTED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_645() -#line 4427 "cs-parser.jay" +void case_647() +#line 4467 "cs-parser.jay" { yyVal = Modifiers.INTERNAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_646() -#line 4432 "cs-parser.jay" +void case_648() +#line 4472 "cs-parser.jay" { yyVal = Modifiers.PRIVATE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_647() -#line 4437 "cs-parser.jay" +void case_649() +#line 4477 "cs-parser.jay" { yyVal = Modifiers.ABSTRACT; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_648() -#line 4442 "cs-parser.jay" +void case_650() +#line 4482 "cs-parser.jay" { yyVal = Modifiers.SEALED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_649() -#line 4447 "cs-parser.jay" +void case_651() +#line 4487 "cs-parser.jay" { yyVal = Modifiers.STATIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_650() -#line 4452 "cs-parser.jay" +void case_652() +#line 4492 "cs-parser.jay" { yyVal = Modifiers.READONLY; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_651() -#line 4457 "cs-parser.jay" +void case_653() +#line 4497 "cs-parser.jay" { yyVal = Modifiers.VIRTUAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_652() -#line 4462 "cs-parser.jay" +void case_654() +#line 4502 "cs-parser.jay" { yyVal = Modifiers.OVERRIDE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_653() -#line 4467 "cs-parser.jay" +void case_655() +#line 4507 "cs-parser.jay" { yyVal = Modifiers.EXTERN; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_654() -#line 4472 "cs-parser.jay" +void case_656() +#line 4512 "cs-parser.jay" { yyVal = Modifiers.VOLATILE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_655() -#line 4477 "cs-parser.jay" +void case_657() +#line 4517 "cs-parser.jay" { yyVal = Modifiers.UNSAFE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7381,37 +7476,38 @@ void case_655() Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } -void case_656() -#line 4484 "cs-parser.jay" +void case_658() +#line 4524 "cs-parser.jay" { yyVal = Modifiers.ASYNC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_658() -#line 4493 "cs-parser.jay" +void case_660() +#line 4533 "cs-parser.jay" { current_type.AddBasesForPart ((List) yyVals[0+yyTop]); lbag.AppendToMember (current_type, GetLocation (yyVals[-1+yyTop])); } void case_661() -#line 4506 "cs-parser.jay" +#line 4538 "cs-parser.jay" { Error_SyntaxError (yyToken); - yyVal = null; - } -void case_662() -#line 4514 "cs-parser.jay" + current_type.AddBasesForPart ((List) yyVals[-1+yyTop]); + } + +void case_664() +#line 4555 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((Constraints) yyVals[0+yyTop]); yyVal = constraints; } -void case_663() -#line 4520 "cs-parser.jay" +void case_665() +#line 4561 "cs-parser.jay" { var constraints = (List) yyVals[-1+yyTop]; Constraints new_constraint = (Constraints)yyVals[0+yyTop]; @@ -7428,24 +7524,33 @@ void case_663() yyVal = constraints; } -void case_664() -#line 4539 "cs-parser.jay" +void case_666() +#line 4580 "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])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_665() -#line 4548 "cs-parser.jay" +void case_667() +#line 4586 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + + var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; + yyVal = new Constraints (new SimpleMemberName (lt.Value, lt.Location), null, GetLocation (yyVals[-2+yyTop])); + } + +void case_668() +#line 4596 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = constraints; } -void case_666() -#line 4554 "cs-parser.jay" +void case_669() +#line 4602 "cs-parser.jay" { var constraints = (List) yyVals[-2+yyTop]; var prev = constraints [constraints.Count - 1] as SpecialContraintExpr; @@ -7470,8 +7575,8 @@ void case_666() yyVal = constraints; } -void case_667() -#line 4581 "cs-parser.jay" +void case_670() +#line 4629 "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 ()); @@ -7479,15 +7584,15 @@ void case_667() yyVal = yyVals[0+yyTop]; } -void case_668() -#line 4588 "cs-parser.jay" +void case_671() +#line 4636 "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_672() -#line 4608 "cs-parser.jay" +void case_675() +#line 4656 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (lexer.Location, "generic type variance"); @@ -7495,57 +7600,65 @@ void case_672() yyVal = yyVals[0+yyTop]; } -void case_673() -#line 4618 "cs-parser.jay" +void case_676() +#line 4666 "cs-parser.jay" { yyVal = Variance.Covariant; savedLocation = GetLocation (yyVals[0+yyTop]); } -void case_674() -#line 4623 "cs-parser.jay" +void case_677() +#line 4671 "cs-parser.jay" { yyVal = Variance.Contravariant; savedLocation = GetLocation (yyVals[0+yyTop]); } -void case_675() -#line 4644 "cs-parser.jay" +void case_678() +#line 4692 "cs-parser.jay" { ++lexer.parsing_block; start_block (GetLocation (yyVals[0+yyTop])); } -void case_677() -#line 4656 "cs-parser.jay" +void case_680() +#line 4704 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_678() -#line 4661 "cs-parser.jay" +void case_681() +#line 4709 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (lexer.Location); } -void case_679() -#line 4670 "cs-parser.jay" +void case_682() +#line 4718 "cs-parser.jay" { ++lexer.parsing_block; current_block.StartLocation = GetLocation (yyVals[0+yyTop]); } -void case_680() -#line 4675 "cs-parser.jay" +void case_683() +#line 4723 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_688() -#line 4703 "cs-parser.jay" +void case_684() +#line 4727 "cs-parser.jay" +{ + report.Error (1525, GetLocation (yyVals[0+yyTop]), "Unexpected symbol '}', expected '{'"); + lexer.putback ('}'); + yyVal = end_block (GetLocation (yyVals[0+yyTop])); + } + +void case_692() +#line 4756 "cs-parser.jay" { Error_SyntaxError (yyToken); var lt =(Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -7554,43 +7667,43 @@ void case_688() yyVal = null; } -void case_689() -#line 4712 "cs-parser.jay" +void case_693() +#line 4765 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_722() -#line 4776 "cs-parser.jay" +void case_726() +#line 4829 "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_723() -#line 4781 "cs-parser.jay" +void case_727() +#line 4834 "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_724() -#line 4786 "cs-parser.jay" +void case_728() +#line 4839 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_725() -#line 4794 "cs-parser.jay" +void case_729() +#line 4847 "cs-parser.jay" { /* Uses lexer.Location because semicolon location is not kept in quick mode*/ yyVal = new EmptyStatement (lexer.Location); } -void case_726() -#line 4802 "cs-parser.jay" +void case_730() +#line 4855 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location); @@ -7599,8 +7712,8 @@ void case_726() current_block.AddStatement (labeled); } -void case_729() -#line 4815 "cs-parser.jay" +void case_733() +#line 4868 "cs-parser.jay" { if (yyVals[-1+yyTop] is VarExpr) yyVals[-1+yyTop] = new SimpleName ("var", ((VarExpr) yyVals[-1+yyTop]).Location); @@ -7608,8 +7721,8 @@ void case_729() yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_730() -#line 4831 "cs-parser.jay" +void case_734() +#line 4884 "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*/ @@ -7640,8 +7753,8 @@ void case_730() } } -void case_731() -#line 4861 "cs-parser.jay" +void case_735() +#line 4914 "cs-parser.jay" { ATypeNameExpression expr = yyVals[-1+yyTop] as ATypeNameExpression; @@ -7653,8 +7766,8 @@ void case_731() } } -void case_732() -#line 4872 "cs-parser.jay" +void case_736() +#line 4925 "cs-parser.jay" { if (yyVals[0+yyTop] == null) yyVal = yyVals[-1+yyTop]; @@ -7662,22 +7775,22 @@ void case_732() yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_735() -#line 4887 "cs-parser.jay" +void case_739() +#line 4940 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_737() -#line 4896 "cs-parser.jay" +void case_741() +#line 4949 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_740() -#line 4912 "cs-parser.jay" +void case_744() +#line 4965 "cs-parser.jay" { if (async_block) { report.Error (4003, GetLocation (yyVals[0+yyTop]), "`await' cannot be used as an identifier within an async method or lambda expression"); @@ -7685,8 +7798,8 @@ void case_740() } } -void case_741() -#line 4922 "cs-parser.jay" +void case_745() +#line 4975 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7694,16 +7807,16 @@ void case_741() current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_742() -#line 4929 "cs-parser.jay" +void case_746() +#line 4982 "cs-parser.jay" { yyVal = current_variable; current_variable = null; lbag.AppendTo (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_743() -#line 4935 "cs-parser.jay" +void case_747() +#line 4988 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7711,8 +7824,8 @@ void case_743() current_variable = new BlockConstantDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_744() -#line 4942 "cs-parser.jay" +void case_748() +#line 4995 "cs-parser.jay" { if (current_variable.Initializer != null) { lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); @@ -7723,15 +7836,24 @@ void case_744() current_variable = null; } -void case_746() -#line 4956 "cs-parser.jay" +void case_750() +#line 5008 "cs-parser.jay" +{ + /* Redundant, but wont regress*/ + report.Error (1525, lexer.Location, "Unexpected symbol }"); + lexer.putback ('}'); + yyVal = yyVals[0+yyTop]; + } + +void case_752() +#line 5019 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } -void case_747() -#line 4961 "cs-parser.jay" +void case_753() +#line 5024 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7746,8 +7868,8 @@ void case_747() lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } -void case_748() -#line 4975 "cs-parser.jay" +void case_754() +#line 5038 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7757,8 +7879,8 @@ void case_748() } } -void case_752() -#line 4993 "cs-parser.jay" +void case_758() +#line 5056 "cs-parser.jay" { foreach (var d in current_variable.Declarators) { if (d.Initializer == null) @@ -7766,8 +7888,8 @@ void case_752() } } -void case_755() -#line 5008 "cs-parser.jay" +void case_761() +#line 5071 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7777,8 +7899,8 @@ void case_755() lbag.AddLocation (d, GetLocation (yyVals[-1+yyTop])); } -void case_756() -#line 5017 "cs-parser.jay" +void case_762() +#line 5080 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7788,15 +7910,15 @@ void case_756() lbag.AddLocation (d, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_758() -#line 5033 "cs-parser.jay" +void case_764() +#line 5096 "cs-parser.jay" { savedLocation = GetLocation (yyVals[-1+yyTop]); current_variable.Initializer = (Expression) yyVals[0+yyTop]; } -void case_763() -#line 5051 "cs-parser.jay" +void case_769() +#line 5114 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7806,38 +7928,37 @@ void case_763() lbag.AddLocation (d, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_765() -#line 5064 "cs-parser.jay" +void case_771() +#line 5127 "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_766() -#line 5069 "cs-parser.jay" +void case_772() +#line 5132 "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_767() -#line 5077 "cs-parser.jay" +void case_773() +#line 5140 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_769() -#line 5082 "cs-parser.jay" +void case_775() +#line 5146 "cs-parser.jay" { - yyVal = yyVals[-1+yyTop]; - lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); - report.Error (1525, "Unexpected symbol '}' after statement, expecting ';'"); + yyVal = yyVals[-1+yyTop]; + report.Error (1002, GetLocation (yyVals[0+yyTop]), "; expected"); lexer.putback ('}'); } -void case_772() -#line 5101 "cs-parser.jay" +void case_778() +#line 5164 "cs-parser.jay" { ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement; if (s == null) { @@ -7848,8 +7969,8 @@ void case_772() } } -void case_773() -#line 5114 "cs-parser.jay" +void case_779() +#line 5177 "cs-parser.jay" { Expression expr = (Expression) yyVals[0+yyTop]; ExpressionStatement s; @@ -7858,15 +7979,15 @@ void case_773() yyVal = new StatementExpression (s); } -void case_774() -#line 5122 "cs-parser.jay" +void case_780() +#line 5185 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_777() -#line 5136 "cs-parser.jay" +void case_783() +#line 5199 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7875,8 +7996,8 @@ void case_777() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_778() -#line 5145 "cs-parser.jay" +void case_784() +#line 5208 "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])); @@ -7887,8 +8008,8 @@ void case_778() Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_779() -#line 5155 "cs-parser.jay" +void case_785() +#line 5218 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7896,16 +8017,16 @@ void case_779() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_781() -#line 5169 "cs-parser.jay" +void case_787() +#line 5232 "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_782() -#line 5175 "cs-parser.jay" +void case_788() +#line 5238 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7913,15 +8034,15 @@ void case_782() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_783() -#line 5185 "cs-parser.jay" +void case_789() +#line 5248 "cs-parser.jay" { report.Warning (1522, 1, current_block.StartLocation, "Empty switch block"); yyVal = new List (); } -void case_785() -#line 5194 "cs-parser.jay" +void case_791() +#line 5257 "cs-parser.jay" { var sections = new List (4); @@ -7929,8 +8050,8 @@ void case_785() yyVal = sections; } -void case_786() -#line 5201 "cs-parser.jay" +void case_792() +#line 5264 "cs-parser.jay" { var sections = (List) yyVals[-1+yyTop]; @@ -7938,15 +8059,15 @@ void case_786() yyVal = sections; } -void case_787() -#line 5208 "cs-parser.jay" +void case_793() +#line 5271 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new List (); } -void case_790() -#line 5227 "cs-parser.jay" +void case_796() +#line 5290 "cs-parser.jay" { var labels = new List (2); @@ -7954,8 +8075,8 @@ void case_790() yyVal = labels; } -void case_791() -#line 5234 "cs-parser.jay" +void case_797() +#line 5297 "cs-parser.jay" { var labels = (List) (yyVals[-1+yyTop]); labels.Add ((SwitchLabel) yyVals[0+yyTop]); @@ -7963,15 +8084,22 @@ void case_791() yyVal = labels; } -void case_792() -#line 5244 "cs-parser.jay" +void case_798() +#line 5307 "cs-parser.jay" { yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_798() -#line 5263 "cs-parser.jay" +void case_799() +#line 5312 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); + } + +void case_805() +#line 5331 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7980,8 +8108,8 @@ void case_798() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_799() -#line 5271 "cs-parser.jay" +void case_806() +#line 5339 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7989,22 +8117,22 @@ void case_799() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_800() -#line 5281 "cs-parser.jay" +void case_807() +#line 5349 "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_801() -#line 5286 "cs-parser.jay" +void case_808() +#line 5354 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Do ((Statement) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); } -void case_802() -#line 5291 "cs-parser.jay" +void case_809() +#line 5359 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8012,38 +8140,79 @@ void case_802() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_803() -#line 5301 "cs-parser.jay" +void case_810() +#line 5369 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); current_block.IsCompilerGenerated = true; For f = new For (GetLocation (yyVals[-1+yyTop])); current_block.AddStatement (f); + lbag.AddStatement (f, current_block.StartLocation); yyVal = f; } -void case_808() -#line 5329 "cs-parser.jay" +void case_812() +#line 5386 "cs-parser.jay" +{ + For f = (For) yyVals[-2+yyTop]; + f.Initializer = (Statement) yyVals[-1+yyTop]; + lbag.AppendTo (f, GetLocation (yyVals[0+yyTop])); + yyVal = f; + } + +void case_814() +#line 5396 "cs-parser.jay" { + report.Error (1525, GetLocation (yyVals[0+yyTop]), "Unexpected symbol ')', expected ';'"); + For f = (For) yyVals[-2+yyTop]; + f.Initializer = (Statement) yyVals[-1+yyTop]; + lbag.AppendTo (f, GetLocation (yyVals[0+yyTop])); + yyVal = end_block (GetLocation (yyVals[0+yyTop])); + } + +void case_815() +#line 5407 "cs-parser.jay" +{ + For f = (For) yyVals[-2+yyTop]; + f.Condition = (BooleanExpression) yyVals[-1+yyTop]; + lbag.AppendTo (f, GetLocation (yyVals[0+yyTop])); + yyVal = f; + } + +void case_817() +#line 5417 "cs-parser.jay" +{ + report.Error (1525, GetLocation (yyVals[0+yyTop]), "Unexpected symbol ')', expected ';'"); + For f = (For) yyVals[-2+yyTop]; + f.Condition = (BooleanExpression) yyVals[-1+yyTop]; + lbag.AppendTo (f, GetLocation (yyVals[0+yyTop])); + yyVal = end_block (GetLocation (yyVals[0+yyTop])); + } + +void case_818() +#line 5429 "cs-parser.jay" +{ + For f = (For) yyVals[-3+yyTop]; + f.Iterator = (Statement) yyVals[-2+yyTop]; + if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); - For f = ((For) yyVals[-10+yyTop]); f.Statement = (Statement) yyVals[0+yyTop]; - lbag.AddStatement (f, current_block.StartLocation, GetLocation (yyVals[-8+yyTop]), GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop])); + lbag.AppendTo (f, GetLocation (yyVals[-1+yyTop])); - yyVal = end_block (GetLocation (yyVals[-8+yyTop])); + yyVal = end_block (GetLocation (yyVals[-1+yyTop])); } -void case_809() -#line 5340 "cs-parser.jay" +void case_819() +#line 5442 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = end_block (current_block.StartLocation); } -void case_812() -#line 5353 "cs-parser.jay" +void case_822() +#line 5455 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -8051,15 +8220,15 @@ void case_812() current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_813() -#line 5360 "cs-parser.jay" +void case_823() +#line 5462 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_821() -#line 5384 "cs-parser.jay" +void case_831() +#line 5486 "cs-parser.jay" { var sl = yyVals[-2+yyTop] as StatementList; if (sl == null) { @@ -8068,31 +8237,32 @@ void case_821() } else { sl.Add ((Statement) yyVals[0+yyTop]); lbag.AppendTo (sl, GetLocation (yyVals[-1+yyTop])); + } yyVal = sl; } -void case_822() -#line 5400 "cs-parser.jay" +void case_832() +#line 5503 "cs-parser.jay" { report.Error (230, GetLocation (yyVals[-3+yyTop]), "Type and identifier are both required in a foreach statement"); start_block (GetLocation (yyVals[-2+yyTop])); current_block.IsCompilerGenerated = true; - Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, GetLocation (yyVals[-3+yyTop])); + Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, null, GetLocation (yyVals[-3+yyTop])); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation (yyVals[-2+yyTop])); yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_823() -#line 5413 "cs-parser.jay" +void case_833() +#line 5516 "cs-parser.jay" { Error_SyntaxError (yyToken); - + start_block (GetLocation (yyVals[-3+yyTop])); current_block.IsCompilerGenerated = true; @@ -8100,15 +8270,15 @@ void case_823() var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location); current_block.AddLocalName (li); - Foreach f = new Foreach ((Expression) yyVals[-2+yyTop], li, null, null, GetLocation (yyVals[-4+yyTop])); + Foreach f = new Foreach ((Expression) yyVals[-2+yyTop], li, null, null, null, GetLocation (yyVals[-4+yyTop])); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation (yyVals[-3+yyTop])); yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_824() -#line 5430 "cs-parser.jay" +void case_834() +#line 5533 "cs-parser.jay" { start_block (GetLocation (yyVals[-5+yyTop])); current_block.IsCompilerGenerated = true; @@ -8118,96 +8288,117 @@ void case_824() yyVal = li; } -void case_825() -#line 5439 "cs-parser.jay" +void case_835() +#line 5542 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); - - Foreach f = new Foreach ((Expression) yyVals[-6+yyTop], (LocalVariable) yyVals[-1+yyTop], (Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-8+yyTop])); - current_block.AddStatement (f); + Foreach f = new Foreach ((Expression) yyVals[-6+yyTop], (LocalVariable) yyVals[-1+yyTop], (Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], current_block, GetLocation (yyVals[-8+yyTop])); lbag.AddStatement (f, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); - yyVal = end_block (GetLocation (yyVals[-2+yyTop])); + end_block (GetLocation (yyVals[-2+yyTop])); + + yyVal = f; } -void case_826() -#line 5450 "cs-parser.jay" +void case_836() +#line 5553 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); current_block.IsCompilerGenerated = true; var lt = yyVals[-1+yyTop] as Tokenizer.LocatedToken; var li = lt != null ? new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location) : null; - Foreach f = new Foreach ((Expression) yyVals[-2+yyTop], li, null, null, GetLocation (yyVals[-4+yyTop])); + Foreach f = new Foreach ((Expression) yyVals[-2+yyTop], li, null, null, null, GetLocation (yyVals[-4+yyTop])); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation (yyVals[-3+yyTop])); yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_827() -#line 5463 "cs-parser.jay" +void case_837() +#line 5566 "cs-parser.jay" { - Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, GetLocation (yyVals[-3+yyTop])); + Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, null, GetLocation (yyVals[-3+yyTop])); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation (yyVals[-2+yyTop])); yyVal = f; } -void case_834() -#line 5483 "cs-parser.jay" +void case_844() +#line 5586 "cs-parser.jay" { yyVal = new Break (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_835() -#line 5491 "cs-parser.jay" +void case_845() +#line 5594 "cs-parser.jay" { yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_836() -#line 5499 "cs-parser.jay" +void case_846() +#line 5599 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); + } + +void case_847() +#line 5607 "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_837() -#line 5505 "cs-parser.jay" +void case_848() +#line 5613 "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_838() -#line 5510 "cs-parser.jay" +void case_849() +#line 5618 "cs-parser.jay" { yyVal = new GotoDefault (GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_839() -#line 5518 "cs-parser.jay" +void case_850() +#line 5626 "cs-parser.jay" { yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_840() -#line 5526 "cs-parser.jay" +void case_851() +#line 5631 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + yyVal = new Return (null, GetLocation (yyVals[-1+yyTop])); + } + +void case_852() +#line 5639 "cs-parser.jay" { yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_841() -#line 5534 "cs-parser.jay" +void case_853() +#line 5644 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + yyVal = new Throw (null, GetLocation (yyVals[-1+yyTop])); + } + +void case_854() +#line 5652 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; string s = lt.Value; @@ -8224,8 +8415,8 @@ void case_841() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_842() -#line 5550 "cs-parser.jay" +void case_855() +#line 5668 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -8240,29 +8431,30 @@ void case_842() lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_846() -#line 5576 "cs-parser.jay" +void case_859() +#line 5694 "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_847() -#line 5581 "cs-parser.jay" +void case_860() +#line 5699 "cs-parser.jay" { - yyVal = new TryFinally (new TryCatch ((Block) yyVals[-3+yyTop], (List) yyVals[-2+yyTop], Location.Null, true), (Block) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop])); + var loc = GetLocation (yyVals[-4+yyTop]); + yyVal = new TryFinally (new TryCatch ((Block) yyVals[-3+yyTop], (List) yyVals[-2+yyTop], loc, true), (Block) yyVals[0+yyTop], loc); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_848() -#line 5586 "cs-parser.jay" +void case_861() +#line 5705 "cs-parser.jay" { Error_SyntaxError (1524, yyToken); yyVal = new TryCatch ((Block) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]), false); } -void case_849() -#line 5594 "cs-parser.jay" +void case_862() +#line 5713 "cs-parser.jay" { var l = new List (2); @@ -8270,8 +8462,8 @@ void case_849() yyVal = l; } -void case_850() -#line 5601 "cs-parser.jay" +void case_863() +#line 5720 "cs-parser.jay" { var l = (List) yyVals[-1+yyTop]; @@ -8284,8 +8476,8 @@ void case_850() yyVal = l; } -void case_854() -#line 5625 "cs-parser.jay" +void case_867() +#line 5744 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop])); @@ -8301,8 +8493,8 @@ void case_854() yyVal = c; } -void case_856() -#line 5644 "cs-parser.jay" +void case_869() +#line 5763 "cs-parser.jay" { if (yyToken == Token.CLOSE_PARENS) { report.Error (1015, lexer.Location, @@ -8314,15 +8506,15 @@ void case_856() yyVal = new Catch (null, GetLocation (yyVals[-2+yyTop])); } -void case_859() -#line 5672 "cs-parser.jay" +void case_872() +#line 5791 "cs-parser.jay" { if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } -void case_861() -#line 5682 "cs-parser.jay" +void case_874() +#line 5801 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8331,8 +8523,8 @@ void case_861() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_862() -#line 5690 "cs-parser.jay" +void case_875() +#line 5809 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8340,8 +8532,8 @@ void case_862() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_863() -#line 5700 "cs-parser.jay" +void case_876() +#line 5819 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8352,15 +8544,15 @@ void case_863() current_variable = new Fixed.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_864() -#line 5710 "cs-parser.jay" +void case_877() +#line 5829 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_865() -#line 5715 "cs-parser.jay" +void case_878() +#line 5834 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8371,8 +8563,8 @@ void case_865() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_866() -#line 5728 "cs-parser.jay" +void case_879() +#line 5847 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8383,15 +8575,15 @@ void case_866() current_variable = new Using.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_867() -#line 5738 "cs-parser.jay" +void case_880() +#line 5857 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_868() -#line 5743 "cs-parser.jay" +void case_881() +#line 5862 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8402,8 +8594,8 @@ void case_868() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_869() -#line 5753 "cs-parser.jay" +void case_882() +#line 5872 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8412,8 +8604,8 @@ void case_869() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_870() -#line 5761 "cs-parser.jay" +void case_883() +#line 5880 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8421,23 +8613,23 @@ void case_870() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_872() -#line 5772 "cs-parser.jay" +void case_885() +#line 5891 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); } -void case_874() -#line 5784 "cs-parser.jay" +void case_887() +#line 5903 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); yyVal = current_variable; } -void case_875() -#line 5796 "cs-parser.jay" +void case_888() +#line 5915 "cs-parser.jay" { lexer.query_parsing = false; @@ -8450,8 +8642,8 @@ void case_875() current_block = current_block.Parent; } -void case_876() -#line 5808 "cs-parser.jay" +void case_889() +#line 5927 "cs-parser.jay" { Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause; @@ -8462,8 +8654,8 @@ void case_876() current_block = current_block.Parent; } -void case_877() -#line 5819 "cs-parser.jay" +void case_890() +#line 5938 "cs-parser.jay" { lexer.query_parsing = false; yyVal = yyVals[-1+yyTop]; @@ -8472,64 +8664,68 @@ void case_877() current_block = current_block.Parent; } -void case_878() -#line 5826 "cs-parser.jay" +void case_891() +#line 5945 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; } -void case_879() -#line 5835 "cs-parser.jay" +void case_892() +#line 5954 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var rv = new Linq.RangeVariable (lt.Value, lt.Location); - yyVal = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-3+yyTop]))); + var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-3+yyTop])); + lbag.AddLocation (start, GetLocation (yyVals[-1+yyTop])); + yyVal = new Linq.QueryExpression (start); } -void case_880() -#line 5843 "cs-parser.jay" +void case_893() +#line 5964 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var rv = new Linq.RangeVariable (lt.Value, lt.Location); - yyVal = new Linq.QueryExpression ( - new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-4+yyTop])) { - IdentifierType = (FullNamedExpression)yyVals[-3+yyTop] - } - ); + var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-4+yyTop])) { + IdentifierType = (FullNamedExpression)yyVals[-3+yyTop] + }; + lbag.AddLocation (start, GetLocation (yyVals[-1+yyTop])); + yyVal = new Linq.QueryExpression (start); } -void case_881() -#line 5858 "cs-parser.jay" +void case_894() +#line 5979 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var rv = new Linq.RangeVariable (lt.Value, lt.Location); - yyVal = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-3+yyTop]))); + var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-3+yyTop])); + lbag.AddLocation (start, GetLocation (yyVals[-1+yyTop])); + yyVal = new Linq.QueryExpression (start); } -void case_882() -#line 5866 "cs-parser.jay" +void case_895() +#line 5989 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var rv = new Linq.RangeVariable (lt.Value, lt.Location); - yyVal = new Linq.QueryExpression ( - new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-4+yyTop])) { - IdentifierType = (FullNamedExpression)yyVals[-3+yyTop] - } - ); + var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], rv, GetLocation (yyVals[-4+yyTop])) { + IdentifierType = (FullNamedExpression)yyVals[-3+yyTop] + }; + lbag.AddLocation (start, GetLocation (yyVals[-1+yyTop])); + yyVal = new Linq.QueryExpression (start); } -void case_884() -#line 5885 "cs-parser.jay" +void case_897() +#line 6008 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8537,12 +8733,13 @@ void case_884() current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - ((Linq.QueryBlock)current_block).AddRangeVariable (sn); + + lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_886() -#line 5900 "cs-parser.jay" +void case_899() +#line 6024 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8555,10 +8752,12 @@ void case_886() current_block = current_block.Parent; ((Linq.QueryBlock)current_block).AddRangeVariable (sn); + + lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_887() -#line 5917 "cs-parser.jay" +void case_900() +#line 6043 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[-1+yyTop]; @@ -8574,15 +8773,36 @@ void case_887() yyVal = head; } -void case_889() -#line 5933 "cs-parser.jay" +void case_901() +#line 6058 "cs-parser.jay" +{ + Linq.AQueryClause head = (Linq.AQueryClause)yyVals[0+yyTop]; + + if (yyVals[-1+yyTop] != null) { + Linq.AQueryClause clause = (Linq.AQueryClause)yyVals[-1+yyTop]; + clause.Tail.Next = head; + head = clause; + } + + yyVal = head; + } + +void case_903() +#line 6071 "cs-parser.jay" +{ + report.Error (742, GetLocation (yyVals[0+yyTop]), "Unexpected symbol `{0}'. A query body must end with select or group clause", GetSymbolName (yyToken)); + yyVal = yyVals[-1+yyTop]; + } + +void case_904() +#line 6076 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_891() -#line 5945 "cs-parser.jay" +void case_906() +#line 6088 "cs-parser.jay" { yyVal = new Linq.Select ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8590,8 +8810,8 @@ void case_891() current_block = current_block.Parent; } -void case_892() -#line 5952 "cs-parser.jay" +void case_907() +#line 6095 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8600,8 +8820,8 @@ void case_892() linq_clause_blocks.Push ((Linq.QueryBlock)current_block); } -void case_893() -#line 5960 "cs-parser.jay" +void case_908() +#line 6103 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8609,8 +8829,8 @@ void case_893() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_894() -#line 5967 "cs-parser.jay" +void case_909() +#line 6110 "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])); @@ -8619,15 +8839,15 @@ void case_894() current_block = current_block.Parent; } -void case_898() -#line 5984 "cs-parser.jay" +void case_911() +#line 6122 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_905() -#line 6004 "cs-parser.jay" +void case_918() +#line 6142 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8640,8 +8860,8 @@ void case_905() ((Linq.QueryBlock)current_block).AddRangeVariable (sn); } -void case_907() -#line 6023 "cs-parser.jay" +void case_920() +#line 6161 "cs-parser.jay" { yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8649,8 +8869,8 @@ void case_907() current_block = current_block.Parent; } -void case_908() -#line 6033 "cs-parser.jay" +void case_921() +#line 6171 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8659,8 +8879,8 @@ void case_908() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_909() -#line 6041 "cs-parser.jay" +void case_922() +#line 6179 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8669,8 +8889,8 @@ void case_909() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_910() -#line 6049 "cs-parser.jay" +void case_923() +#line 6187 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8679,8 +8899,8 @@ void case_910() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_911() -#line 6057 "cs-parser.jay" +void case_924() +#line 6195 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8712,15 +8932,15 @@ void case_911() into = new Linq.RangeVariable (lt.Value, lt.Location); yyVal = new Linq.GroupJoin (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, into, GetLocation (yyVals[-11+yyTop])); - lbag.AddLocation (yyVal, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop])); + lbag.AddLocation (yyVal, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), opt_intoStack.Pop ()); } current_block = block.Parent; ((Linq.QueryBlock)current_block).AddRangeVariable (into); } -void case_912() -#line 6095 "cs-parser.jay" +void case_925() +#line 6233 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8729,8 +8949,8 @@ void case_912() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_913() -#line 6103 "cs-parser.jay" +void case_926() +#line 6241 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8739,8 +8959,8 @@ void case_913() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_914() -#line 6111 "cs-parser.jay" +void case_927() +#line 6249 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8749,8 +8969,8 @@ void case_914() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_915() -#line 6119 "cs-parser.jay" +void case_928() +#line 6257 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8767,6 +8987,7 @@ void case_915() yyVal = new Linq.Join (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, GetLocation (yyVals[-12+yyTop])) { IdentifierType = (FullNamedExpression)yyVals[-11+yyTop] }; + lbag.AddLocation (yyVal, GetLocation (yyVals[-10+yyTop]), GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop])); } else { /**/ /* Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions*/ @@ -8785,14 +9006,22 @@ void case_915() yyVal = new Linq.GroupJoin (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, into, GetLocation (yyVals[-12+yyTop])) { IdentifierType = (FullNamedExpression)yyVals[-11+yyTop] }; + lbag.AddLocation (yyVal, GetLocation (yyVals[-10+yyTop]), GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop]), opt_intoStack.Pop ()); } current_block = block.Parent; ((Linq.QueryBlock)current_block).AddRangeVariable (into); } -void case_919() -#line 6174 "cs-parser.jay" +void case_930() +#line 6303 "cs-parser.jay" +{ + opt_intoStack.Push (GetLocation (yyVals[-1+yyTop])); + yyVal = yyVals[0+yyTop]; + } + +void case_932() +#line 6315 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8800,8 +9029,8 @@ void case_919() yyVal = yyVals[0+yyTop]; } -void case_921() -#line 6185 "cs-parser.jay" +void case_934() +#line 6326 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8809,15 +9038,15 @@ void case_921() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_922() -#line 6192 "cs-parser.jay" +void case_935() +#line 6333 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } -void case_924() -#line 6201 "cs-parser.jay" +void case_937() +#line 6342 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8825,43 +9054,43 @@ void case_924() current_block = new Linq.QueryBlock ((Linq.QueryBlock) current_block, lexer.Location); } -void case_925() -#line 6208 "cs-parser.jay" +void case_938() +#line 6349 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } -void case_927() -#line 6220 "cs-parser.jay" +void case_940() +#line 6361 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_928() -#line 6225 "cs-parser.jay" +void case_941() +#line 6366 "cs-parser.jay" { yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_930() -#line 6237 "cs-parser.jay" +void case_943() +#line 6378 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_931() -#line 6242 "cs-parser.jay" +void case_944() +#line 6383 "cs-parser.jay" { yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_933() -#line 6252 "cs-parser.jay" +void case_946() +#line 6393 "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*/ @@ -8878,8 +9107,8 @@ void case_933() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_934() -#line 6268 "cs-parser.jay" +void case_947() +#line 6409 "cs-parser.jay" { var current_block = linq_clause_blocks.Pop (); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -8889,8 +9118,8 @@ void case_934() }; } -void case_937() -#line 6295 "cs-parser.jay" +void case_950() +#line 6436 "cs-parser.jay" { current_container = current_type = new Class (current_container, new MemberName (""), Modifiers.PUBLIC, null); @@ -8919,8 +9148,8 @@ void case_937() start_block (lexer.Location); } -void case_938() -#line 6323 "cs-parser.jay" +void case_951() +#line 6464 "cs-parser.jay" { --lexer.parsing_block; Method method = (Method) oob_stack.Pop (); @@ -8931,16 +9160,16 @@ void case_938() current_local_parameters = null; } -void case_948() -#line 6366 "cs-parser.jay" +void case_961() +#line 6507 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; yyVal = null; } -void case_949() -#line 6372 "cs-parser.jay" +void case_962() +#line 6513 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -8948,15 +9177,15 @@ void case_949() yyVal = new MemberName (lt.Value); } -void case_952() -#line 6387 "cs-parser.jay" +void case_965() +#line 6528 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[-1+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-6+yyTop], MemberCache.IndexerNameAlias, Location.Null); } -void case_953() -#line 6392 "cs-parser.jay" +void case_966() +#line 6533 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -8965,8 +9194,8 @@ void case_953() yyVal = null; } -void case_954() -#line 6400 "cs-parser.jay" +void case_967() +#line 6541 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -8975,8 +9204,8 @@ void case_954() yyVal = null; } -void case_955() -#line 6408 "cs-parser.jay" +void case_968() +#line 6549 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); module.DocumentationBuilder.ParsedParameters = p; @@ -8984,24 +9213,24 @@ void case_955() yyVal = null; } -void case_963() -#line 6446 "cs-parser.jay" +void case_976() +#line 6587 "cs-parser.jay" { var parameters = new List (); parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); yyVal = parameters; } -void case_964() -#line 6452 "cs-parser.jay" +void case_977() +#line 6593 "cs-parser.jay" { var parameters = yyVals[-2+yyTop] as List; parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); yyVal = parameters; } -void case_965() -#line 6461 "cs-parser.jay" +void case_978() +#line 6602 "cs-parser.jay" { if (yyVals[-1+yyTop] != null) yyVal = new DocumentationParameter ((Parameter.Modifier) yyVals[-1+yyTop], (FullNamedExpression) yyVals[0+yyTop]); @@ -9026,88 +9255,89 @@ void case_965() 91, 83, 85, 85, 92, 92, 93, 94, 93, 89, 89, 95, 95, 96, 97, 87, 87, 90, 90, 90, 100, 54, 103, 104, 98, 105, 106, 107, 98, 98, - 99, 99, 102, 102, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 111, 111, 114, 114, 114, 117, - 114, 115, 115, 118, 118, 119, 119, 119, 112, 112, - 112, 120, 120, 120, 113, 122, 124, 125, 55, 127, - 128, 129, 57, 123, 123, 123, 123, 123, 133, 130, - 134, 131, 132, 132, 132, 135, 136, 137, 139, 28, - 28, 138, 138, 140, 140, 141, 141, 141, 141, 141, - 141, 141, 141, 141, 144, 58, 143, 143, 145, 145, - 148, 142, 142, 147, 147, 147, 147, 147, 147, 147, + 98, 99, 99, 102, 102, 110, 110, 110, 110, 110, + 110, 110, 110, 110, 110, 111, 111, 114, 114, 114, + 114, 117, 114, 115, 115, 118, 118, 119, 119, 119, + 112, 112, 112, 120, 120, 120, 113, 122, 124, 125, + 55, 127, 128, 129, 57, 123, 123, 123, 123, 123, + 133, 130, 134, 131, 132, 132, 132, 135, 136, 137, + 139, 28, 28, 138, 138, 140, 140, 141, 141, 141, + 141, 141, 141, 141, 141, 141, 144, 58, 143, 143, + 145, 145, 148, 142, 142, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 150, 149, 151, 149, 149, - 149, 59, 154, 156, 152, 153, 153, 155, 155, 160, - 158, 161, 158, 158, 158, 162, 60, 164, 56, 167, - 168, 56, 163, 170, 163, 165, 165, 171, 171, 172, - 173, 172, 174, 169, 166, 166, 166, 166, 166, 178, - 175, 179, 176, 177, 177, 61, 181, 183, 184, 29, - 180, 180, 180, 182, 182, 182, 185, 185, 186, 187, - 186, 188, 189, 190, 30, 191, 191, 16, 16, 192, - 192, 195, 194, 194, 194, 196, 196, 198, 64, 121, - 101, 101, 126, 126, 199, 199, 199, 197, 197, 200, - 200, 201, 201, 203, 203, 82, 72, 72, 86, 86, - 116, 116, 146, 146, 204, 204, 204, 204, 204, 208, - 208, 209, 209, 207, 207, 207, 207, 207, 207, 207, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 211, + 147, 147, 147, 147, 147, 147, 147, 150, 149, 151, + 149, 149, 149, 59, 154, 156, 152, 153, 153, 155, + 155, 160, 158, 161, 158, 158, 158, 162, 60, 164, + 56, 167, 168, 56, 163, 170, 163, 165, 165, 171, + 171, 172, 173, 172, 174, 169, 166, 166, 166, 166, + 166, 178, 175, 179, 176, 177, 177, 61, 181, 183, + 184, 29, 180, 180, 180, 182, 182, 182, 185, 185, + 186, 187, 186, 188, 189, 190, 30, 191, 191, 16, + 16, 192, 192, 195, 194, 194, 194, 196, 196, 198, + 64, 121, 101, 101, 126, 126, 199, 199, 199, 197, + 197, 200, 200, 201, 201, 203, 203, 82, 72, 72, + 86, 86, 116, 116, 146, 146, 204, 204, 204, 204, + 204, 208, 208, 209, 207, 207, 207, 207, 207, 207, + 207, 210, 210, 210, 210, 210, 210, 210, 210, 210, + 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, - 211, 211, 211, 211, 211, 211, 211, 211, 211, 212, - 212, 212, 213, 213, 213, 233, 233, 234, 234, 235, - 235, 215, 215, 232, 232, 232, 232, 232, 232, 232, - 232, 217, 236, 236, 237, 237, 238, 238, 240, 240, - 240, 241, 241, 241, 241, 241, 242, 242, 159, 159, - 246, 246, 246, 246, 246, 248, 248, 247, 247, 249, - 249, 249, 249, 250, 218, 218, 218, 245, 245, 245, - 251, 251, 252, 252, 219, 220, 220, 221, 222, 223, - 223, 214, 214, 214, 214, 214, 257, 253, 224, 258, - 258, 259, 259, 260, 260, 261, 261, 261, 261, 254, - 254, 205, 205, 256, 256, 262, 262, 255, 255, 81, - 81, 263, 263, 264, 225, 265, 265, 265, 266, 266, - 266, 266, 266, 267, 193, 226, 227, 228, 229, 269, - 230, 270, 230, 268, 268, 272, 271, 216, 273, 273, - 273, 273, 273, 274, 274, 274, 274, 274, 274, 274, - 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, - 277, 277, 277, 278, 278, 278, 278, 278, 279, 279, - 279, 280, 280, 281, 281, 282, 282, 283, 283, 284, - 284, 285, 285, 286, 286, 287, 287, 287, 287, 287, - 287, 287, 287, 287, 287, 287, 288, 288, 289, 289, - 289, 290, 290, 291, 291, 294, 292, 293, 293, 296, - 295, 297, 295, 298, 299, 295, 300, 301, 295, 44, - 44, 243, 243, 243, 243, 231, 231, 231, 80, 303, - 304, 305, 306, 307, 26, 63, 63, 62, 62, 108, - 108, 308, 308, 308, 308, 308, 308, 308, 308, 308, - 308, 308, 308, 308, 308, 308, 66, 66, 68, 68, - 68, 309, 309, 310, 311, 311, 312, 312, 312, 312, - 202, 202, 313, 313, 315, 109, 316, 316, 317, 157, - 314, 314, 318, 318, 319, 319, 319, 319, 319, 323, - 323, 324, 324, 324, 321, 321, 321, 321, 321, 321, - 321, 321, 321, 321, 321, 321, 321, 325, 325, 325, - 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, - 339, 339, 339, 339, 326, 340, 322, 341, 341, 342, - 342, 342, 342, 342, 342, 206, 206, 343, 47, 47, - 345, 320, 348, 320, 344, 344, 344, 344, 346, 346, - 352, 352, 351, 351, 353, 353, 347, 347, 349, 349, - 354, 354, 355, 350, 350, 350, 327, 327, 327, 338, - 338, 356, 357, 357, 328, 328, 358, 358, 358, 361, - 359, 359, 360, 360, 362, 362, 362, 365, 363, 364, - 364, 366, 366, 329, 329, 329, 329, 367, 367, 368, - 368, 368, 372, 369, 375, 377, 378, 371, 371, 373, - 373, 380, 379, 379, 374, 374, 376, 376, 382, 381, - 381, 370, 370, 383, 370, 370, 370, 330, 330, 330, - 330, 330, 330, 384, 385, 386, 386, 386, 387, 388, - 389, 389, 390, 390, 331, 331, 331, 331, 391, 391, - 393, 393, 392, 394, 392, 392, 332, 333, 395, 336, - 334, 334, 397, 398, 337, 400, 401, 335, 335, 335, - 399, 399, 396, 396, 302, 302, 302, 302, 402, 402, - 404, 404, 406, 405, 407, 405, 403, 403, 403, 411, - 409, 412, 413, 409, 408, 408, 414, 414, 415, 415, - 415, 415, 415, 420, 416, 421, 417, 422, 423, 424, - 418, 426, 427, 428, 418, 425, 425, 430, 419, 429, - 433, 429, 432, 435, 432, 431, 431, 431, 434, 434, - 434, 410, 436, 410, 3, 3, 437, 3, 3, 438, - 438, 244, 244, 239, 239, 5, 439, 439, 439, 439, - 443, 439, 439, 439, 439, 440, 440, 441, 444, 441, - 442, 442, 445, 445, 446, + 212, 212, 212, 213, 213, 213, 233, 233, 234, 234, + 235, 235, 215, 215, 232, 232, 232, 232, 232, 232, + 232, 232, 217, 236, 236, 237, 237, 238, 238, 240, + 240, 240, 241, 241, 241, 241, 241, 242, 242, 159, + 159, 246, 246, 246, 246, 246, 248, 248, 247, 247, + 249, 249, 249, 249, 250, 218, 218, 218, 245, 245, + 245, 251, 251, 252, 252, 219, 220, 220, 221, 222, + 223, 223, 214, 214, 214, 214, 214, 257, 253, 224, + 258, 258, 259, 259, 260, 260, 261, 261, 261, 261, + 254, 254, 205, 205, 256, 256, 262, 262, 255, 255, + 81, 81, 263, 263, 264, 225, 265, 265, 265, 266, + 266, 266, 266, 266, 267, 193, 226, 227, 228, 229, + 269, 230, 270, 230, 268, 268, 272, 271, 216, 273, + 273, 273, 273, 273, 274, 274, 274, 274, 274, 274, + 274, 275, 275, 275, 275, 276, 276, 276, 276, 276, + 276, 277, 277, 277, 278, 278, 278, 278, 278, 279, + 279, 279, 280, 280, 281, 281, 282, 282, 283, 283, + 284, 284, 285, 285, 286, 286, 286, 288, 288, 288, + 288, 288, 288, 288, 288, 288, 288, 288, 289, 289, + 290, 290, 290, 291, 291, 292, 292, 294, 293, 287, + 287, 296, 295, 297, 295, 298, 299, 295, 300, 301, + 295, 44, 44, 243, 243, 243, 243, 231, 231, 231, + 80, 303, 304, 305, 306, 307, 26, 63, 63, 62, + 62, 108, 108, 308, 308, 308, 308, 308, 308, 308, + 308, 308, 308, 308, 308, 308, 308, 308, 66, 66, + 66, 68, 68, 309, 309, 310, 310, 311, 311, 312, + 312, 312, 312, 202, 202, 313, 313, 315, 109, 316, + 316, 317, 157, 157, 314, 314, 318, 318, 319, 319, + 319, 319, 319, 323, 323, 324, 324, 324, 321, 321, + 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, + 321, 325, 325, 325, 325, 325, 325, 325, 325, 325, + 325, 325, 325, 325, 339, 339, 339, 339, 326, 340, + 322, 341, 341, 342, 342, 342, 342, 342, 342, 206, + 206, 343, 47, 47, 345, 320, 349, 320, 347, 347, + 344, 344, 344, 344, 346, 346, 353, 353, 352, 352, + 354, 354, 348, 348, 350, 350, 355, 355, 356, 351, + 351, 351, 327, 327, 327, 338, 338, 357, 358, 358, + 328, 328, 359, 359, 359, 362, 360, 360, 361, 361, + 363, 363, 363, 366, 364, 365, 365, 367, 367, 367, + 329, 329, 329, 329, 368, 368, 369, 369, 369, 373, + 370, 376, 372, 372, 379, 375, 375, 378, 378, 374, + 374, 382, 381, 381, 377, 377, 380, 380, 384, 383, + 383, 371, 371, 385, 371, 371, 371, 330, 330, 330, + 330, 330, 330, 386, 387, 387, 388, 388, 388, 389, + 389, 390, 390, 391, 391, 392, 392, 331, 331, 331, + 331, 393, 393, 395, 395, 394, 396, 394, 394, 332, + 333, 397, 336, 334, 334, 399, 400, 337, 402, 403, + 335, 335, 335, 401, 401, 398, 398, 302, 302, 302, + 302, 404, 404, 406, 406, 408, 407, 409, 407, 405, + 405, 405, 405, 405, 413, 411, 414, 415, 411, 410, + 410, 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, 412, 437, 412, 3, 3, 438, + 3, 3, 439, 439, 244, 244, 239, 239, 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, @@ -9125,1371 +9355,1366 @@ void case_965() 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, 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, 5, 1, 1, 1, 1, - 0, 7, 1, 1, 1, 1, 1, 1, 1, 1, + 5, 1, 1, 0, 1, 1, 3, 3, 3, 5, + 3, 5, 1, 1, 1, 1, 3, 4, 6, 2, + 4, 0, 7, 0, 1, 1, 2, 1, 1, 1, + 4, 6, 4, 1, 2, 2, 1, 0, 0, 0, + 10, 0, 0, 0, 13, 1, 2, 1, 2, 1, + 0, 5, 0, 5, 1, 1, 1, 0, 0, 0, + 0, 15, 5, 0, 1, 1, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 5, 1, 1, + 1, 1, 0, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 7, 0, 7, 2, - 2, 2, 0, 0, 9, 1, 1, 0, 1, 0, - 6, 0, 6, 2, 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, 2, 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, 0, 7, 0, + 7, 2, 2, 2, 0, 0, 9, 1, 1, 0, + 1, 0, 6, 0, 6, 2, 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, 2, 0, 0, + 0, 12, 0, 2, 2, 0, 1, 2, 1, 3, + 2, 0, 5, 0, 0, 0, 13, 0, 1, 1, + 3, 1, 4, 2, 0, 3, 2, 1, 3, 0, + 3, 1, 1, 3, 1, 2, 3, 4, 4, 0, + 3, 1, 3, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, + 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 4, 3, 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, 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, 2, 0, 1, - 1, 1, 2, 4, 1, 3, 1, 3, 1, 1, - 0, 1, 1, 1, 0, 4, 1, 1, 0, 4, - 0, 1, 1, 2, 1, 1, 1, 2, 1, 1, - 2, 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, 3, 2, 1, 1, 1, 1, + 2, 2, 4, 3, 1, 4, 4, 3, 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, 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, 4, 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, 2, + 3, 0, 1, 1, 2, 4, 3, 1, 3, 1, + 3, 1, 1, 0, 1, 1, 1, 0, 4, 1, + 1, 0, 4, 1, 0, 1, 1, 2, 1, 1, + 1, 2, 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, 0, 4, 1, 2, 2, - 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, - 0, 6, 0, 7, 0, 2, 2, 1, 0, 1, - 0, 1, 1, 2, 2, 4, 0, 2, 0, 1, - 1, 2, 4, 1, 5, 2, 2, 2, 2, 2, - 2, 1, 1, 1, 1, 1, 5, 7, 4, 0, - 8, 4, 0, 1, 1, 2, 1, 0, 3, 1, - 2, 3, 1, 1, 1, 1, 1, 5, 4, 7, - 3, 6, 0, 4, 0, 0, 0, 10, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 4, 1, 2, 2, 2, 2, 2, 2, 1, 1, + 2, 1, 1, 1, 0, 6, 0, 7, 1, 1, + 0, 2, 2, 1, 0, 1, 0, 1, 1, 2, + 2, 4, 0, 2, 0, 1, 1, 2, 4, 1, + 5, 2, 2, 2, 2, 2, 2, 1, 1, 1, + 1, 1, 5, 7, 4, 0, 8, 4, 0, 1, + 1, 2, 1, 0, 3, 1, 2, 3, 3, 1, + 1, 1, 1, 1, 5, 4, 7, 3, 6, 0, + 4, 0, 4, 2, 0, 4, 2, 3, 1, 0, 1, 0, 5, 1, 0, 1, 0, 1, 1, 1, 3, 4, 5, 0, 9, 5, 4, 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, 4, 0, 0, 10, 0, 0, 9, 5, 4, - 2, 1, 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, + 1, 1, 1, 2, 2, 2, 3, 4, 3, 3, + 2, 3, 2, 4, 3, 0, 1, 3, 4, 5, + 3, 1, 2, 0, 1, 2, 0, 7, 3, 2, + 2, 0, 3, 5, 4, 0, 0, 10, 0, 0, + 9, 5, 4, 2, 1, 0, 2, 2, 2, 2, + 2, 4, 5, 4, 5, 0, 5, 0, 6, 3, + 2, 2, 2, 1, 0, 3, 0, 0, 6, 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, 935, 0, 0, 939, 0, - 0, 15, 17, 376, 382, 389, 377, 379, 0, 378, - 0, 385, 387, 374, 0, 381, 383, 375, 386, 388, - 384, 338, 956, 0, 380, 946, 0, 10, 1, 0, - 0, 0, 12, 0, 774, 0, 0, 0, 0, 0, - 0, 0, 0, 417, 0, 0, 0, 0, 0, 0, - 0, 415, 0, 0, 0, 475, 0, 416, 0, 514, - 0, 859, 0, 0, 0, 625, 0, 0, 0, 0, - 0, 0, 0, 675, 0, 725, 0, 0, 0, 0, - 0, 0, 0, 0, 414, 0, 614, 0, 773, 0, - 708, 0, 0, 0, 0, 391, 392, 0, 394, 395, - 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, - 406, 407, 408, 409, 412, 413, 621, 544, 0, 0, + 0, 0, 11, 14, 0, 948, 0, 0, 952, 0, + 0, 15, 17, 377, 383, 390, 378, 380, 0, 379, + 0, 386, 388, 375, 0, 382, 384, 376, 387, 389, + 385, 340, 969, 0, 381, 959, 0, 10, 1, 0, + 0, 0, 12, 0, 780, 0, 0, 0, 0, 0, + 0, 0, 0, 418, 0, 0, 0, 0, 0, 0, + 0, 416, 0, 0, 0, 476, 0, 417, 0, 515, + 0, 872, 0, 0, 0, 627, 0, 0, 0, 0, + 0, 0, 0, 678, 0, 729, 0, 0, 0, 0, + 0, 0, 0, 0, 415, 0, 616, 0, 779, 0, + 712, 0, 0, 0, 0, 392, 393, 0, 395, 396, + 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, + 407, 408, 409, 410, 413, 414, 623, 545, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 622, 620, 623, 624, 692, 694, 0, 690, 693, 709, - 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, - 710, 0, 0, 0, 775, 776, 794, 795, 796, 797, - 828, 829, 830, 831, 832, 833, 0, 0, 0, 20, - 0, 0, 328, 0, 330, 943, 16, 936, 0, 0, - 239, 238, 235, 240, 241, 234, 253, 252, 245, 246, - 242, 244, 243, 247, 236, 237, 248, 249, 255, 254, - 250, 251, 0, 0, 959, 0, 948, 0, 947, 3, + 624, 622, 625, 626, 696, 698, 0, 694, 697, 713, + 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, + 714, 0, 0, 0, 781, 782, 801, 802, 803, 804, + 838, 839, 840, 841, 842, 843, 0, 0, 0, 20, + 0, 0, 330, 0, 332, 956, 16, 949, 0, 0, + 241, 240, 237, 242, 243, 236, 255, 254, 247, 248, + 244, 246, 245, 249, 238, 239, 250, 251, 257, 256, + 252, 253, 0, 0, 972, 0, 961, 0, 960, 3, 51, 0, 0, 0, 40, 37, 39, 42, 43, 44, - 45, 46, 49, 13, 0, 0, 0, 834, 418, 419, - 857, 0, 0, 0, 0, 0, 0, 393, 0, 835, - 0, 536, 530, 535, 724, 772, 695, 722, 721, 723, - 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, - 706, 707, 0, 0, 0, 803, 0, 0, 0, 740, - 739, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 844, 0, 390, 0, 0, 0, 0, 0, 0, - 858, 0, 0, 0, 738, 734, 0, 0, 0, 0, - 0, 0, 0, 357, 0, 0, 0, 0, 0, 0, - 0, 0, 617, 0, 543, 0, 0, 541, 545, 546, - 540, 550, 549, 547, 548, 610, 525, 0, 411, 410, - 0, 0, 0, 0, 0, 726, 0, 327, 0, 732, - 733, 0, 478, 479, 0, 0, 0, 730, 731, 0, + 45, 46, 49, 13, 0, 0, 0, 844, 419, 420, + 870, 0, 0, 0, 0, 0, 0, 394, 0, 846, + 845, 0, 537, 531, 536, 728, 778, 699, 726, 725, + 727, 700, 701, 702, 703, 704, 705, 706, 707, 708, + 709, 710, 711, 0, 0, 0, 810, 0, 0, 0, + 744, 743, 0, 0, 0, 0, 0, 0, 0, 0, + 851, 0, 0, 857, 0, 391, 0, 0, 0, 853, + 0, 0, 0, 871, 0, 0, 0, 742, 738, 0, + 0, 0, 0, 0, 0, 0, 359, 0, 0, 0, + 0, 0, 0, 0, 0, 619, 0, 544, 0, 0, + 542, 546, 547, 541, 551, 550, 548, 549, 612, 526, + 0, 412, 411, 0, 0, 0, 0, 0, 730, 0, + 329, 0, 736, 737, 0, 479, 480, 0, 0, 0, + 734, 735, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 951, 695, 745, 733, + 0, 776, 777, 904, 919, 0, 0, 905, 907, 0, + 931, 890, 888, 912, 0, 0, 910, 913, 914, 915, + 916, 891, 889, 0, 0, 0, 334, 0, 18, 0, + 0, 0, 968, 0, 341, 0, 0, 0, 970, 0, + 0, 38, 649, 655, 647, 0, 644, 654, 648, 646, + 645, 652, 650, 651, 657, 653, 656, 658, 0, 0, + 642, 41, 50, 478, 0, 474, 475, 0, 0, 472, + 0, 747, 0, 0, 0, 808, 0, 775, 773, 774, + 0, 0, 0, 631, 0, 849, 847, 632, 0, 0, + 500, 0, 0, 0, 491, 0, 495, 505, 507, 0, + 487, 0, 0, 0, 0, 0, 482, 0, 485, 0, + 489, 361, 850, 0, 0, 852, 861, 0, 0, 0, + 862, 0, 0, 873, 0, 0, 741, 0, 371, 367, + 368, 0, 0, 366, 369, 370, 0, 0, 0, 552, + 0, 0, 533, 0, 614, 693, 0, 0, 0, 687, + 689, 690, 691, 423, 424, 0, 337, 338, 0, 179, + 178, 180, 0, 0, 0, 0, 363, 0, 599, 0, + 0, 855, 0, 0, 428, 0, 431, 0, 429, 0, + 468, 0, 0, 0, 0, 0, 457, 460, 0, 0, + 452, 459, 458, 0, 588, 589, 590, 591, 592, 593, + 594, 595, 596, 598, 597, 553, 555, 554, 560, 561, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 938, 691, 741, 729, 0, 770, 771, - 889, 906, 0, 0, 0, 918, 877, 875, 899, 0, - 0, 897, 900, 901, 902, 903, 878, 876, 0, 0, - 0, 332, 0, 18, 0, 0, 0, 955, 0, 339, - 0, 0, 0, 957, 0, 0, 38, 647, 653, 645, - 0, 642, 652, 646, 644, 643, 650, 648, 649, 655, - 651, 654, 656, 0, 0, 640, 41, 50, 477, 0, - 473, 474, 0, 0, 471, 0, 743, 0, 0, 0, - 801, 0, 769, 767, 768, 0, 0, 0, 629, 0, - 838, 836, 630, 0, 0, 499, 0, 0, 0, 490, - 0, 494, 504, 506, 0, 486, 0, 0, 0, 0, - 0, 481, 0, 484, 0, 488, 359, 839, 0, 0, - 840, 848, 0, 0, 0, 849, 0, 0, 860, 0, - 0, 737, 0, 369, 365, 366, 0, 0, 364, 367, - 368, 0, 0, 0, 551, 0, 0, 532, 0, 612, - 689, 0, 0, 0, 683, 685, 686, 687, 422, 423, - 0, 335, 336, 0, 177, 176, 178, 0, 0, 0, - 0, 361, 0, 597, 0, 0, 842, 0, 0, 427, - 0, 430, 0, 428, 0, 467, 0, 0, 0, 0, - 0, 456, 459, 0, 0, 451, 458, 457, 0, 586, - 587, 588, 589, 590, 591, 592, 593, 594, 596, 595, - 552, 554, 553, 559, 560, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 583, 0, 0, 503, 0, 0, 0, 0, 0, 0, - 0, 890, 892, 888, 0, 898, 0, 0, 329, 953, - 954, 353, 0, 0, 0, 350, 0, 0, 174, 0, - 0, 963, 949, 951, 59, 57, 58, 0, 0, 52, - 0, 0, 60, 62, 26, 24, 0, 0, 0, 637, - 0, 641, 426, 0, 476, 0, 527, 0, 538, 164, - 185, 0, 0, 154, 0, 0, 0, 165, 531, 0, - 863, 809, 0, 820, 804, 0, 811, 0, 822, 0, - 837, 779, 0, 862, 0, 0, 489, 0, 505, 507, - 0, 0, 443, 0, 0, 439, 0, 0, 468, 0, - 509, 483, 0, 140, 510, 138, 139, 512, 0, 526, - 782, 0, 853, 0, 846, 0, 850, 518, 0, 0, - 0, 354, 0, 516, 0, 0, 528, 870, 0, 866, - 799, 0, 881, 0, 879, 0, 0, 627, 628, 0, - 0, 0, 688, 677, 678, 676, 684, 605, 611, 604, - 0, 0, 334, 600, 0, 0, 0, 542, 841, 727, - 431, 425, 429, 424, 529, 466, 465, 464, 461, 460, - 0, 455, 420, 421, 432, 0, 0, 748, 0, 0, - 609, 608, 907, 883, 0, 908, 0, 904, 0, 919, - 0, 0, 0, 0, 887, 19, 331, 674, 673, 0, - 672, 0, 349, 965, 175, 960, 0, 0, 53, 0, - 0, 0, 0, 0, 0, 356, 0, 631, 0, 0, - 79, 78, 0, 472, 0, 0, 0, 0, 0, 537, - 0, 0, 0, 0, 0, 812, 805, 0, 823, 0, - 0, 861, 496, 495, 446, 0, 0, 944, 945, 435, - 441, 0, 444, 0, 470, 0, 0, 0, 0, 0, - 780, 856, 0, 847, 0, 524, 519, 0, 0, 515, - 0, 869, 0, 798, 882, 880, 0, 533, 0, 613, - 607, 337, 599, 598, 615, 463, 0, 453, 452, 585, - 140, 0, 764, 746, 0, 0, 0, 753, 0, 885, - 0, 912, 0, 927, 928, 921, 891, 893, 933, 352, - 351, 964, 0, 0, 61, 55, 0, 63, 25, 22, - 0, 0, 307, 0, 211, 0, 102, 0, 76, 758, - 113, 114, 0, 0, 0, 761, 183, 184, 0, 0, - 0, 0, 157, 166, 158, 160, 802, 0, 0, 0, - 0, 0, 821, 0, 0, 445, 447, 448, 442, 436, - 440, 0, 501, 0, 469, 480, 434, 513, 511, 0, - 852, 0, 0, 0, 520, 0, 872, 0, 0, 626, - 618, 0, 462, 0, 0, 742, 754, 884, 0, 0, - 0, 905, 0, 0, 0, 952, 0, 0, 0, 68, - 69, 72, 73, 0, 322, 313, 312, 0, 632, 207, - 97, 0, 744, 762, 169, 0, 181, 0, 0, 0, - 800, 874, 0, 0, 0, 816, 0, 824, 778, 485, - 482, 787, 0, 793, 0, 0, 785, 0, 790, 854, - 523, 522, 871, 867, 0, 616, 0, 0, 886, 909, - 0, 0, 0, 923, 0, 934, 0, 74, 66, 0, - 0, 0, 308, 0, 0, 0, 0, 0, 170, 0, - 161, 159, 864, 813, 806, 0, 0, 781, 786, 0, - 791, 0, 0, 619, 0, 756, 0, 913, 930, 931, - 924, 894, 54, 0, 70, 71, 0, 0, 0, 0, - 0, 0, 0, 763, 168, 0, 180, 0, 0, 825, - 792, 0, 679, 855, 868, 765, 0, 0, 0, 75, - 0, 0, 323, 0, 309, 0, 317, 373, 372, 0, - 370, 661, 0, 633, 0, 662, 208, 98, 171, 865, - 0, 0, 818, 0, 910, 0, 925, 0, 0, 0, - 0, 0, 0, 0, 0, 663, 0, 0, 807, 0, - 0, 914, 28, 23, 324, 0, 0, 318, 371, 0, - 0, 0, 99, 0, 680, 0, 0, 0, 0, 310, - 669, 0, 670, 667, 0, 665, 95, 0, 0, 93, - 0, 0, 82, 84, 85, 86, 87, 88, 89, 90, - 91, 92, 94, 141, 0, 0, 224, 216, 217, 218, - 219, 220, 221, 222, 223, 0, 0, 214, 0, 808, - 0, 911, 0, 325, 321, 0, 0, 0, 306, 634, - 83, 0, 267, 262, 266, 0, 209, 215, 0, 917, - 915, 668, 666, 0, 0, 0, 0, 0, 0, 0, - 276, 0, 0, 225, 0, 0, 233, 0, 152, 142, - 151, 0, 100, 0, 0, 261, 0, 0, 260, 0, - 146, 0, 0, 343, 0, 341, 0, 0, 186, 0, - 0, 0, 0, 0, 635, 210, 0, 103, 0, 340, - 0, 0, 0, 0, 117, 0, 0, 0, 0, 0, - 0, 143, 0, 0, 190, 0, 344, 0, 228, 227, - 226, 0, 101, 0, 280, 0, 258, 119, 0, 256, - 0, 0, 0, 121, 0, 345, 0, 0, 187, 0, - 0, 0, 342, 231, 112, 110, 0, 0, 284, 0, - 0, 0, 0, 0, 147, 0, 264, 0, 0, 0, - 0, 125, 0, 0, 0, 0, 346, 347, 0, 0, - 0, 0, 0, 107, 299, 0, 281, 0, 0, 293, - 0, 0, 0, 288, 0, 137, 0, 0, 0, 0, - 132, 0, 0, 277, 0, 122, 0, 116, 126, 144, - 150, 198, 0, 188, 0, 0, 0, 0, 111, 0, - 104, 108, 0, 0, 0, 295, 0, 296, 285, 0, - 0, 279, 289, 259, 0, 0, 118, 133, 257, 0, - 275, 0, 265, 269, 128, 0, 0, 0, 195, 197, - 191, 232, 109, 300, 302, 282, 0, 0, 294, 291, - 136, 134, 148, 274, 0, 0, 0, 145, 199, 201, - 189, 0, 0, 0, 293, 0, 270, 272, 129, 0, - 0, 192, 304, 305, 301, 303, 292, 149, 0, 0, - 205, 204, 203, 200, 202, 0, 0, 0, 193, 271, - 273, + 0, 0, 0, 0, 0, 584, 0, 0, 504, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 903, 902, + 0, 911, 0, 901, 0, 0, 331, 966, 967, 355, + 0, 0, 0, 352, 0, 0, 176, 0, 0, 976, + 962, 964, 59, 57, 58, 0, 0, 52, 0, 0, + 60, 62, 26, 24, 0, 0, 0, 639, 0, 643, + 427, 0, 477, 0, 528, 0, 539, 165, 187, 0, + 0, 0, 155, 0, 0, 0, 166, 532, 0, 876, + 0, 830, 811, 0, 821, 0, 832, 0, 848, 785, + 0, 875, 0, 0, 490, 0, 506, 508, 0, 0, + 444, 0, 0, 440, 0, 0, 469, 0, 510, 484, + 0, 140, 511, 138, 139, 513, 0, 527, 788, 0, + 866, 0, 859, 0, 863, 519, 0, 0, 0, 356, + 0, 517, 0, 0, 529, 883, 0, 879, 806, 0, + 894, 0, 892, 0, 0, 629, 630, 0, 0, 0, + 692, 680, 681, 679, 688, 607, 613, 606, 0, 0, + 336, 602, 0, 0, 0, 543, 854, 731, 432, 426, + 430, 425, 530, 467, 466, 465, 462, 461, 0, 456, + 421, 422, 433, 0, 587, 0, 754, 0, 0, 611, + 610, 920, 896, 0, 921, 0, 906, 908, 917, 0, + 932, 0, 900, 946, 19, 333, 677, 676, 0, 675, + 0, 351, 978, 177, 973, 0, 0, 53, 0, 0, + 0, 0, 0, 0, 358, 0, 633, 0, 0, 79, + 78, 0, 473, 0, 0, 0, 0, 0, 170, 538, + 0, 0, 0, 0, 0, 822, 814, 812, 0, 833, + 0, 0, 874, 497, 496, 447, 0, 0, 957, 958, + 436, 442, 0, 445, 0, 471, 0, 0, 0, 0, + 0, 786, 869, 0, 860, 0, 525, 520, 0, 0, + 516, 0, 882, 0, 805, 895, 893, 0, 534, 0, + 615, 609, 339, 601, 600, 617, 464, 0, 455, 454, + 453, 586, 140, 0, 770, 752, 0, 0, 0, 759, + 0, 898, 0, 925, 0, 0, 940, 941, 934, 0, + 354, 353, 977, 0, 0, 61, 55, 0, 63, 25, + 22, 0, 0, 309, 0, 213, 0, 102, 0, 76, + 764, 113, 114, 0, 0, 0, 767, 185, 186, 0, + 0, 0, 0, 158, 167, 159, 161, 809, 0, 0, + 0, 0, 0, 831, 0, 0, 446, 448, 449, 443, + 437, 441, 0, 502, 0, 470, 481, 435, 514, 512, + 0, 865, 0, 0, 0, 521, 0, 885, 0, 0, + 628, 620, 0, 463, 0, 0, 750, 749, 746, 760, + 897, 0, 0, 0, 0, 918, 0, 947, 965, 0, + 0, 0, 68, 69, 72, 73, 0, 324, 315, 314, + 0, 634, 209, 97, 0, 748, 768, 171, 0, 183, + 0, 0, 0, 807, 887, 0, 0, 0, 0, 813, + 0, 834, 784, 486, 483, 793, 0, 800, 0, 0, + 791, 0, 796, 867, 524, 523, 884, 880, 0, 618, + 0, 0, 899, 922, 0, 909, 0, 0, 936, 0, + 74, 66, 0, 0, 0, 310, 0, 0, 0, 0, + 0, 172, 0, 162, 160, 877, 823, 817, 815, 0, + 0, 787, 792, 0, 797, 0, 0, 621, 0, 762, + 0, 926, 943, 944, 937, 54, 0, 70, 71, 0, + 0, 0, 0, 0, 0, 0, 769, 169, 0, 182, + 0, 0, 835, 799, 798, 0, 682, 684, 868, 881, + 771, 0, 0, 0, 75, 0, 0, 325, 0, 311, + 0, 319, 374, 0, 372, 0, 635, 0, 664, 210, + 98, 173, 878, 819, 816, 0, 0, 828, 0, 923, + 0, 938, 0, 0, 0, 0, 0, 661, 0, 0, + 0, 665, 0, 0, 0, 0, 0, 927, 28, 23, + 326, 0, 0, 320, 373, 667, 0, 0, 0, 99, + 818, 683, 0, 0, 0, 0, 312, 672, 0, 673, + 670, 0, 668, 95, 0, 0, 93, 0, 0, 82, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 94, + 141, 0, 0, 226, 218, 219, 220, 221, 222, 223, + 224, 225, 0, 0, 216, 0, 0, 924, 0, 327, + 323, 0, 0, 0, 308, 636, 83, 0, 269, 264, + 268, 0, 211, 217, 0, 930, 928, 671, 669, 0, + 0, 0, 0, 0, 0, 0, 278, 0, 0, 227, + 0, 0, 235, 0, 153, 142, 152, 0, 100, 0, + 0, 263, 0, 0, 262, 0, 146, 0, 0, 345, + 0, 343, 0, 0, 188, 0, 0, 0, 0, 0, + 637, 212, 0, 103, 0, 342, 0, 0, 0, 0, + 117, 0, 0, 0, 0, 0, 0, 151, 143, 0, + 0, 192, 0, 346, 0, 230, 229, 228, 0, 101, + 0, 282, 0, 260, 119, 0, 258, 0, 0, 0, + 121, 0, 347, 0, 0, 189, 0, 0, 0, 344, + 233, 112, 110, 0, 0, 286, 0, 0, 0, 0, + 0, 147, 0, 266, 0, 0, 0, 0, 125, 0, + 0, 0, 0, 348, 349, 0, 0, 0, 0, 0, + 107, 301, 0, 283, 0, 0, 295, 0, 0, 0, + 290, 0, 137, 0, 0, 0, 0, 132, 0, 0, + 279, 0, 122, 0, 116, 126, 144, 150, 200, 0, + 190, 0, 0, 0, 0, 111, 0, 104, 108, 0, + 0, 0, 297, 0, 298, 287, 0, 0, 281, 291, + 261, 0, 0, 118, 133, 259, 0, 277, 0, 267, + 271, 128, 0, 0, 0, 197, 199, 193, 234, 109, + 302, 304, 284, 0, 0, 296, 293, 136, 134, 148, + 276, 0, 0, 0, 145, 201, 203, 191, 0, 0, + 0, 295, 0, 272, 274, 129, 0, 0, 194, 306, + 307, 303, 305, 294, 149, 0, 0, 207, 206, 205, + 202, 204, 0, 0, 0, 195, 273, 275, }; protected static readonly short [] yyDgoto = { 7, - 8, 49, 9, 50, 10, 11, 51, 232, 692, 654, - 12, 13, 52, 22, 23, 321, 235, 677, 844, 1034, - 1152, 1493, 841, 236, 237, 238, 239, 240, 241, 242, - 243, 670, 445, 671, 672, 944, 673, 674, 948, 842, - 1029, 1030, 1031, 266, 593, 1124, 110, 853, 1221, 1222, - 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, - 1233, 464, 681, 1306, 958, 1131, 1096, 1164, 1188, 1249, - 1317, 1159, 1367, 1344, 1392, 1393, 1394, 960, 1390, 961, - 737, 1283, 1355, 1330, 1380, 516, 1373, 1349, 1409, 923, - 1378, 1381, 1382, 1477, 1410, 1411, 1407, 1234, 1290, 1262, - 1307, 693, 1357, 1456, 1327, 1413, 1486, 465, 267, 694, - 695, 696, 697, 698, 657, 570, 1136, 658, 659, 859, - 1309, 1334, 1424, 1385, 1458, 1310, 1360, 1482, 1506, 1425, - 1426, 1504, 1490, 1491, 956, 1095, 1187, 1246, 1292, 1247, - 1248, 1284, 1341, 1313, 1285, 324, 223, 1389, 1287, 1374, - 1371, 1235, 1264, 1303, 1453, 1415, 1144, 1454, 594, 1499, - 1500, 1302, 1370, 1346, 1402, 1397, 1368, 1434, 1439, 1400, - 1403, 1404, 1485, 1440, 1398, 1399, 1495, 1483, 1484, 953, - 1038, 1155, 1129, 1181, 1156, 1157, 1196, 1092, 1179, 1208, - 535, 193, 112, 350, 195, 564, 440, 224, 1322, 655, - 656, 830, 846, 325, 407, 534, 303, 1160, 1161, 45, - 114, 304, 116, 117, 118, 119, 120, 121, 122, 123, + 8, 49, 9, 50, 10, 11, 51, 232, 700, 662, + 12, 13, 52, 22, 23, 324, 235, 685, 853, 1047, + 1167, 1510, 850, 236, 237, 238, 239, 240, 241, 242, + 243, 678, 450, 679, 680, 955, 681, 682, 959, 851, + 1042, 1043, 1044, 267, 598, 1137, 110, 862, 1238, 1239, + 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, + 1250, 469, 689, 1322, 969, 1144, 1109, 1177, 1204, 1266, + 1333, 1173, 1384, 1361, 1409, 1410, 1411, 971, 1407, 972, + 745, 1299, 1372, 1346, 1397, 521, 1390, 1366, 1426, 935, + 1395, 1398, 1399, 1494, 1427, 1428, 1424, 1251, 1306, 1278, + 1323, 702, 1374, 1473, 1343, 1430, 1503, 470, 268, 703, + 704, 705, 706, 707, 665, 575, 1149, 666, 667, 868, + 1325, 1351, 1441, 1402, 1475, 1326, 1377, 1499, 1523, 1442, + 1443, 1521, 1507, 1508, 967, 1108, 1203, 1263, 1308, 1264, + 1265, 1300, 1358, 1329, 1301, 327, 223, 1406, 1303, 1391, + 1388, 1252, 1280, 1319, 1470, 1432, 1159, 1471, 599, 1516, + 1517, 1318, 1387, 1363, 1419, 1414, 1385, 1451, 1456, 1417, + 1420, 1421, 1502, 1457, 1415, 1416, 1512, 1500, 1501, 964, + 1051, 1170, 1142, 1196, 1171, 1172, 1212, 1105, 1194, 1225, + 540, 193, 112, 353, 195, 569, 445, 224, 1338, 663, + 664, 839, 855, 328, 410, 539, 305, 1174, 1175, 45, + 114, 306, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 135, 136, 252, 805, 996, 512, 724, 880, 725, - 726, 989, 137, 198, 730, 595, 596, 597, 598, 799, - 474, 475, 297, 994, 732, 408, 299, 499, 500, 501, - 502, 505, 739, 310, 755, 756, 897, 263, 480, 770, - 264, 479, 138, 139, 140, 141, 142, 143, 144, 145, - 146, 147, 148, 149, 150, 151, 152, 573, 574, 575, - 779, 780, 813, 781, 153, 561, 772, 351, 1012, 549, - 1075, 154, 494, 954, 1094, 1185, 1288, 466, 1165, 1166, - 1215, 1216, 831, 553, 336, 776, 1174, 554, 555, 268, - 269, 270, 157, 158, 159, 271, 272, 273, 274, 275, - 276, 277, 278, 279, 280, 281, 282, 171, 283, 579, - 172, 173, 317, 810, 633, 926, 856, 688, 964, 924, - 927, 1054, 928, 965, 966, 284, 174, 175, 176, 1065, - 1000, 1066, 1067, 1068, 1110, 1069, 177, 178, 179, 180, - 705, 487, 706, 1057, 982, 1171, 1139, 1204, 707, 981, - 708, 1173, 1106, 181, 182, 183, 184, 185, 186, 305, - 525, 526, 1002, 1112, 313, 980, 865, 1138, 1009, 903, - 1113, 187, 418, 188, 419, 929, 1019, 420, 645, 825, - 822, 823, 1024, 421, 422, 423, 424, 425, 426, 933, - 635, 931, 1117, 1191, 1252, 1021, 1148, 1207, 820, 641, - 821, 1083, 1023, 1084, 1149, 1025, 17, 19, 46, 47, - 227, 660, 838, 441, 661, 662, + 134, 135, 136, 252, 813, 1007, 517, 732, 891, 733, + 734, 1000, 137, 198, 738, 600, 601, 602, 603, 807, + 479, 480, 298, 1005, 740, 411, 300, 504, 505, 506, + 507, 510, 747, 313, 763, 764, 908, 264, 485, 778, + 265, 484, 138, 139, 140, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 822, 152, 578, 579, + 580, 787, 788, 789, 153, 566, 780, 354, 1023, 554, + 1089, 154, 499, 965, 1107, 1201, 1304, 471, 1178, 1179, + 1232, 1233, 840, 558, 339, 784, 1189, 559, 560, 269, + 270, 271, 157, 158, 159, 272, 273, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 171, 284, 584, + 172, 173, 320, 819, 638, 938, 1029, 865, 696, 975, + 936, 939, 1067, 940, 976, 977, 285, 174, 175, 176, + 1079, 1011, 1080, 1081, 1082, 1124, 1083, 177, 178, 179, + 180, 713, 492, 714, 1070, 993, 1071, 1185, 1152, 1186, + 715, 992, 716, 1188, 1120, 181, 182, 183, 184, 185, + 186, 307, 530, 531, 1013, 1126, 316, 991, 875, 1151, + 1020, 914, 1127, 187, 423, 188, 424, 941, 1032, 425, + 426, 654, 645, 646, 945, 427, 428, 429, 430, 431, + 946, 640, 943, 1131, 1207, 1268, 1034, 1163, 1224, 831, + 648, 832, 1098, 1037, 1099, 1164, 950, 17, 19, 46, + 47, 227, 668, 847, 446, 669, 670, }; - protected static readonly short [] yySindex = { -50, - 0, -198, -148, -227, -77,12060, 0, 70, 0, 0, - -77, -227, 0, 0, -75, 0, 6660, -77, 0, -195, - -230, 0, 0, 0, 0, 0, 0, 0, 240, 0, - 301, 0, 0, 0, 3623, 0, 0, 0, 0, 0, - 0, 0, 0, 56, 0, 0, 663, 0, 0, 70, - 41, -77, 0, 375, 0, 250, 421, 261,11560, 469, - 93, 141, 6817, 0, 93, 93, 93, -179, 93, 93, - 712, 0,10663, 93, 93, 0,10663, 0, 310, 0, - 261, 0, 93, 384, 93, 0,12079,12079, 480, 93, - 93, 2,11343, 0,10663, 0,11343,11343,11343,11343, -11343,11343,11343,11343, 0, 62, 0, 8523, 0, 202, - 0, 443, 430, 692, 369, 0, 0, 509, 0, 0, + protected static readonly short [] yySindex = { -175, + 0, -180, -100, -38, 249,12550, 0, 124, 0, 0, + 249, -38, 0, 0, 200, 0, 6884, 249, 0, -171, + -242, 0, 0, 0, 0, 0, 0, 0, 319, 0, + 397, 0, 0, 0, 3907, 0, 0, 0, 0, 0, + 0, 0, 0, 289, 0, 0, 712, 0, 0, 124, + 367, 249, 0, 374, 0, 214, 401, 244,12032, -83, + -255, 420, 7041, 0, -255, -255, -255, -90, -255, -255, + 720, 0, 8730, -255, -255, 0, 8887, 0, 429, 0, + 244, 0, -255, 458, -255, 0,12594,12594, 491, -255, + -255, -191,11815, 0,11135, 0,11815,11815,11815,11815, +11815,11815,11815,11815, 0, 258, 0, 8590, 0, 218, + 0, 468, 11, 522, 387, 0, 0, 527, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1299, 685, + 89, -273, -265, 413, 529, 561, 553, 557, 123, 588, + 0, 0, 0, 0, 0, 0, 3608, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1141, 704, - 186, -73, 604, 599, 493, 544, 555, 551, 366, 577, - 0, 0, 0, 0, 0, 0, 3324, 0, 0, 0, + 0, -8, 617, -261, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 306, 330, 367, 0, + 403, 344, 0, 577, 0, 0, 0, 0, 8590, 8590, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 63, 606, 16, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -197, -182, 41, 0, - 433, 220, 0, 566, 0, 0, 0, 0, 8523, 8523, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 651, 612, 0, 616, 0, -248, 0, 0, + 0, 367,13162, 470, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 788, 661,11271, 0, 0, 0, + 0,11135, -255, -255, 781, 412, 522, 0, -8, 0, + 0, 8590, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 620, 590, 0, 595, 0, -226, 0, 0, - 0, 41,12772, 819, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 752, 598,10799, 0, 0, 0, - 0,10663, 93, 93, 756, 385, 692, 0, 63, 0, - 8523, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -146, 138,12032, 0, 8590,11135, 740, + 0, 0, 750,11135,11135, 4875, 157, -165, 764, 8747, + 0,11815, 258, 0, 762, 0, 789, 8590,11135, 0, + 826, 442, -255, 0,11135, 429,10591, 0, 0, 458, +11135, 458, 228, 443, 848, -8, 0, 617, 387, 851, + -8,11135,11135,11135, 420, 0, 818, 0, 7198, -50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 159, 127,11560, 0, 8523,10663, 653, 0, - 0, 672,10663,10663, 4591, 357, 138, 684, 8680,11343, - 62, 0, 682, 0, 690, 8523,10663, 694, 588, 93, - 0,10663, 310,10119, 0, 0, 384,10663, 384, 394, - 498, 784, 63, 0, 606, 369, 788, 63,10663,10663, -10663, 141, 0, 744, 0, 6974, -257, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 4207, 0, 0, -11989, 394, 723, 726,10663, 0, 700, 0, -100, 0, - 0, 318, 0, 0, 715, 8506, 9847, 0, 0,11343, -10663,10663,10663,10663,10663,10663,10663,10663,10663,10663, -10663,11343,11343,11343, 8523, 8523,11343,11343,11343,11343, -11343,11343,11343,11343,11343,11343,11343,11343,11343,11343, -11343,11343,10663, 0, 0, 0, 0, 606, 0, 0, - 0, 0,12079,12079, 63, 0, 0, 0, 0, 122, - 790, 0, 0, 0, 0, 0, 0, 0, 41, 819, - 721, 0, 758, 0, 700, 620, 620, 0, -71, 0, - 593, 620, 776, 0, -180,12772, 0, 0, 0, 0, - -192, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 42,12802, 0, 0, 0, 0, 700, - 0, 0, 804, 508, 0, 822, 0, 827, 30, 310, - 0, 93, 0, 0, 0, 63, 8054, -202, 0, 786, - 0, 0, 0, -97, -90, 0, 324, 0, 823, 0, - 830, 0, 0, 0, 607, 0, 8190, 622,10663, 684, - 9847, 0, 7445, 0, 384, 0, 0, 0, 841, -60, - 0, 0, 261, 310, -150, 0, 444, 847, 0, 17, - 63, 0, 83, 0, 0, 0,10663, 929, 0, 0, - 0,10663, 933, 871, 0, 879, 883, 0,11989, 0, - 0, -210, 114, 6974, 0, 0, 0, 0, 0, 0, - 310, 0, 0, -237, 0, 0, 0, 384, 394, 63, -12133, 0, 885, 0, 893,11343, 0, 872, 6974, 0, - 302, 0, 401, 0, 700, 0, 11,10663,10663, 911, - 1016, 0, 0, 168, 915, 0, 0, 0, 704, 0, + 4491, 0, 0,12505, 228, 804, 827,11135, 0, 791, + 0, -298, 0, 0, 441, 0, 0, 786, 9044,10455, + 0, 0,11815,11135,11135,11135,11135,11135,11135,11135, +11135,11135,11135,11135,11815,11815,11815, 8590, 8590,11815, +11815,11815,11815,11815,11815,11815,11815,11815,11815,11815, +11815,11815,11815,11815,11815,11135, 0, 0, 0, 0, + 617, 0, 0, 0, 0,12594,12594, 0, 0, -8, + 0, 0, 0, 0, 469, 850, 0, 0, 0, 0, + 0, 0, 0, 367, 470, 792, 0, 795, 0, 791, + 651, 651, 0, 71, 0, 559, 651, 839, 0, -195, +13162, 0, 0, 0, 0, -164, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 202,13194, + 0, 0, 0, 0, 791, 0, 0, 837, 586, 0, + 842, 0, 847, 59, 429, 0, -255, 0, 0, 0, + -8,10591, -184, 0, 844, 0, 0, 0, -174, 58, + 0, 423, 0, 858, 0, 853, 0, 0, 0, 607, + 0, 8414, 618,11135, 764,10455, 0, 7669, 0, 458, + 0, 0, 0, 856, 63, 0, 0, 244, 429, 516, + 0, 4332, 859, 0, 65, -8, 0, 94, 0, 0, + 0,11135, 936, 0, 0, 0,11135, 939, 860, 0, + 863, 865, 0,12505, 0, 0, -182, -28, 7198, 0, + 0, 0, 0, 0, 0, 429, 0, 0, 6, 0, + 0, 0, 458, 228, -8, 8904, 0, 864, 0, 870, +11815, 0, 867, 7198, 0, -289, 0, 304, 0, 791, + 0, -65,11135,11135, 873, 992, 0, 0, -47, 883, + 0, 0, 0, 685, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 704, 704, 186, 186, -73, - -73, -73, -73, 604, 604, 599, 493, 544, 555, 551, - 0, 926, -145, 0, 8663, 1005, 63, 1009, 63, 923, -10663, 0, 0, 0, 949, 0, 319, 700, 0, 0, - 0, 0, 524, 41, 338, 0,12133, 593, 0, 937, - 936, 0, 0, 0, 0, 0, 0, 394, 955, 0, - 954, 956, 0, 0, 0, 0, 958,12150, 916, 0, - 398, 0, 0, 594, 0,10799, 0, 951, 0, 0, - 0, 619, 961, 0, 964, 965, 966, 0, 0,10663, - 0, 0, 63, 0, 0, 959, 0, 967, 0, 403, - 0, 0, 6817, 0, 6817, 8349, 0, 4591, 0, 0, -10255, 189, 0, 134, -59, 0, 917, 927, 0, 32, - 0, 0, 977, 0, 0, 0, 0, 0, 978, 0, - 0, 984, 0, 7462, 0, 310, 0, 0, 384, 507, - 934, 0, 190, 0, 982, 983, 0, 0, 6817, 0, - 0, 6817, 0,10663, 0,10663, 8523, 0, 0, 310, - 987, 310, 0, 0, 0, 0, 0, 0, 0, 0, - 8663, 8523, 0, 0, 63,11989, 1017, 0, 0, 0, + 685, 685, 89, 89, -273, -273, -273, -273, -265, -265, + 413, 529, 561, 553, 557, 0, -149, -181, 0, 9201, + 964, -8, 965, -8, 9201, 9201, 879,11135, 0, 0, + 850, 0, -8, 0, 512, 791, 0, 0, 0, 0, + 240, 367, 16, 0, 8904, 559, 0, 889, 888, 0, + 0, 0, 0, 0, 0, 228, 891, 0, 892, 897, + 0, 0, 0, 0, 893, 9061, 855, 0, 398, 0, + 0, 220, 0,11271, 0, 896, 0, 0, 0, 555, + 90, 908, 0, 907, 911, 912, 0, 0,11135, 0, + -8, 0, 0, 624, 0, 914, 0, 266, 0, 0, + 7041, 0, 7041, 8573, 0, 4875, 0, 0,10727, 161, + 0, -12, -66, 0, 862, 866, 0, -64, 0, 0, + 910, 0, 0, 0, 0, 0, 919, 0, 0, 928, + 0, 7686, 0, 429, 0, 0, 458, 463, 875, 0, + 39, 0, 925, 930, 0, 0, 7041, 0, 0, 7041, + 0,11135, 0,11135, 8590, 0, 0, 429, 926, 429, + 0, 0, 0, 0, 0, 0, 0, 0, 9201, 8590, + 0, 0, -8,12505, 961, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,10319, 0, + 0, 0, 0, 7826, 0, 9201, 0, 7983, 931, 0, + 0, 0, 0, 1012, 0, 1014, 0, 0, 0, 652, + 0, 935, 0, 0, 0, 0, 0, 0, 894, 0, + 71, 0, 0, 0, 0, 559, 559, 0, 792, 940, + 943, 900, 948, 855, 0, 944, 0, 1064, 1065, 0, + 0,11135, 0,10863, 950, 555, 8904, 8590, 0, 0, + 180, 1066, 1070, 122, 946, 0, 0, 0,11135, 0, +11135, 1049, 0, 0, 0, 0, 40,10999, 0, 0, + 0, 0, 8119, 0, 1074, 0, 617,11135, 968, 8573, + 970, 0, 0, -8, 0, 195, 0, 0, 791, 875, + 0, -8, 0, -161, 0, 0, 0, 967, 0, 997, + 0, 0, 0, 0, 0, 0, 0, 730, 0, 0, + 0, 0, 0, 8747, 0, 0, -8, 549, 931, 0, + 9201, 0, 9201, 0, 998, 9201, 0, 0, 0, 680, + 0, 0, 0, 980, 792, 0, 0,11407, 0, 0, + 0, 972, 7843, 0, 855, 0, 855, 0, 855, 0, + 0, 0, 0, -8, 975, 950, 0, 0, 0, -162, + -156, 978, 979, 0, 0, 0, 0, 0, 981, 8573, + 931, -181,11135, 0, 983, 7041, 0, 0, 0, 0, + 0, 0, 986, 0, 764, 0, 0, 0, 0, 0, + -189, 0, 987, 791, 875, 0, 875, 0, 931, 988, + 0, 0, 429, 0, 938, 977, 0, 0, 0, 0, + 0, 9201, 1015, 9201, 9201, 0,11135, 0, 0, 897, + 239, 731, 0, 0, 0, 0, -38, 0, 0, 0, + 1002, 0, 0, 0, 989, 0, 0, 0, 523, 0, + 990, 1116, 1117, 0, 0, 931, 1003, 931, 1005, 0, + 1006, 0, 0, 0, 0, 0,11135, 0, 1013, -154, + 0, -154, 0, 0, 0, 0, 0, 0, 429, 0, +11135, 8278, 0, 0, 1027, 0, 736, 1009, 0, 1016, + 0, 0,11407, 249, 59, 0, 1017, 1017, 1017,10863, + 1018, 0,11135, 0, 0, 0, 0, 0, 0, 7041, + -80, 0, 0, 7198, 0, 743, 7041, 0, 1019, 0, + 9201, 0, 0, 0, 0, 0,11135, 0, 0, 367, + 1026, 367, 8590, 1045, 1045, 1045, 0, 0,11135, 0, + 7041, 9358, 0, 0, 0, 7198, 0, 0, 0, 0, + 0, 1043, 9201,11135, 0, 367, 1029, 0, 982, 0, + 1028, 0, 0, 38, 0, 985, 0, 1045, 0, 0, + 0, 0, 0, 0, 0, 1032, 914, 0, 7198, 0, + 1051, 0, 1030, 1045, 0, 1033, 367, 0, 8590, -76, + 1038, 0, 1041, 1044, 7041, 1042, 9201, 0, 0, 0, + 0, 1031, 1030, 0, 0, 0,12111, 120, 367, 0, + 0, 0, 1059, 9201, 1040,11135, 0, 0, 1046, 0, + 0, 1047, 0, 0,13194, 800, 0, 1050, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9711, 0, 0, 0, 0, 9983,10663, 0, 7602, 988, - 0, 0, 0, 0, 1070, 0, 1071, 0, 855, 0, - 994, 8663, 8663, 63, 0, 0, 0, 0, 0, 952, - 0, -71, 0, 0, 0, 0, 593, 593, 0, 721, - 999, 1000, 957, 1007, 916, 0, 997, 0, 1120, 1122, - 0, 0,10663, 0,10391, 1006, 619,12133, 8523, 0, - 321, 1123, 1125, 85, 1001, 0, 0,10663, 0,10663, - 1103, 0, 0, 0, 0, 68,10527, 0, 0, 0, - 0, 7738, 0, 1131, 0, 606,10663, 1021, 8349, 1023, - 0, 0, 63, 0, 194, 0, 0, 700, 934, 0, - 63, 0, -82, 0, 0, 0, 1020, 0, 1046, 0, - 0, 0, 0, 0, 0, 0, 724, 0, 0, 0, - 0, 8680, 0, 0, 63, 1019, 988, 0, 8663, 0, - 8663, 0, 8663, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1028, 721, 0, 0,10935, 0, 0, 0, - 1022, 7619, 0, 916, 0, 916, 0, 916, 0, 0, - 0, 0, 63, 1024, 1006, 0, 0, 0, -187, -175, - 1027, 1029, 0, 0, 0, 0, 0, 1026, 8349, 988, - -145,10663, 0, 1033, 6817, 0, 0, 0, 0, 0, - 0, 1036, 0, 684, 0, 0, 0, 0, 0, -193, - 0, 1035, 700, 934, 0, 934, 0, 988, 1037, 0, - 0, 310, 0, 985, 1031, 0, 0, 0, 8663, 1066, - 8663, 0,10663, 1063, 299, 0, 956, 201, 727, 0, - 0, 0, 0, -227, 0, 0, 0, 1048, 0, 0, - 0, 1039, 0, 0, 0, 471, 0, 1041, 1160, 1161, - 0, 0, 988, 1052, 988, 0, 1042, 0, 0, 0, - 0, 0,10663, 0, 1057, -189, 0, -189, 0, 0, - 0, 0, 0, 0, 310, 0,10663, 7897, 0, 0, - 1079, 877, 1058, 0, 8663, 0, 1064, 0, 0,10935, - -77, 30, 0, 1060, 1060, 1060,10391, 1067, 0,10663, - 0, 0, 0, 0, 0, 6817, 1065, 0, 0, 6974, - 0, 1072, 6817, 0, 1068, 0, 8663, 0, 0, 0, - 0, 0, 0,10663, 0, 0, 41, 1061, 41, 7914, - -149, -149, -149, 0, 0,10663, 0, 6817,10663, 0, - 0, 6974, 0, 0, 0, 0, 1094, 8663,10663, 0, - 41, 1075, 0, 1034, 0, 1073, 0, 0, 0, 1077, - 0, 0, 1038, 0, 1105, 0, 0, 0, 0, 0, - 1074, 967, 0, 6974, 0, 1097, 0, 1078, -149, 0, - 1081, 41, 7914, 1080, 1090, 0, 1091, 1092, 0, 1096, - 8663, 0, 0, 0, 0, 1084, 1078, 0, 0,11639, - -67, 41, 0, 6817, 0, 1106, 8663, 1093,10663, 0, - 0, 1095, 0, 0, 1098, 0, 0,12802, 901, 0, - 1099, -67, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 139,12802, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1100, 41, 0, -67, 0, - 63, 0, 1106, 0, 0, 1101,11639,11805, 0, 0, - 0, 516, 0, 0, 0,11837, 0, 0, 1107, 0, - 0, 0, 0, 8523, 8523, 348, 8680, 391, 384, 1137, - 0, 394, 9617, 0, 1171, 0, 0, 1078, 0, 0, - 0, 1078, 0, 1083, 1086, 0, 8523, -173, 0, 8523, - 0, 1087, 1110, 0, 394, 0, 1114, 9647, 0, 1128, - 1088, -137, 541, 3623, 0, 0, 1078, 0, 394, 0, - 1132, 1102, 1127, 1133, 0, 1142, 1086, 1146, 30, 1130, - 1145, 0, 1148, 1154, 0, 700, 0, 862, 0, 0, - 0, 1152, 0, -70, 0, 1151, 0, 0, 1157, 0, - 1156, 1162, 1163, 0, 1159, 0, 30, 30, 0, 30, - 1169, 1182, 0, 0, 0, 0, 1183, 9, 0, 1184, - 30, 1300, 1186, 30, 0, 516, 0, 8349, 1143, 1188, - 1159, 0, 1190, 1194, 148, 1197, 0, 0, 30,10391, - 1150, 1195, 1183, 0, 0,12802, 0, 41, 41, 0, - 1158, 1198, 1184, 0, 1203, 0,10663, 1165, 1202, 1186, - 0, 1207, 30, 0, -88, 0, 1189, 0, 0, 0, - 0, 0,12802, 0, 148, 148, 1214, 1216, 0, -70, - 0, 0, 183, 1221,12802, 0,12802, 0, 0, 8349, - 1209, 0, 0, 0, 1223, 1157, 0, 0, 0, 1219, - 0, 312, 0, 0, 0, -149, 914, 1227, 0, 0, - 0, 0, 0, 0, 0, 0, 1282, 1335, 0, 0, - 0, 0, 0, 0, 1228, 1230, 8349, 0, 0, 0, - 0, 148, 569, 569, 0, -149, 0, 0, 0, 61, - 61, 0, 0, 0, 0, 0, 0, 0, 9847, 9847, - 0, 0, 0, 0, 0, 1234, 1231, 1232, 0, 0, - 0, + 0, 540,13194, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1054, 367, 0, 120, -8, 0, 1059, 0, + 0, 1061,12111,12277, 0, 0, 0, 27, 0, 0, + 0,12309, 0, 0, 1055, 0, 0, 0, 0, 8590, + 8590, 309, 8747, 312, 458, 1082, 0, 228, 4646, 0, + 1129, 0, 0, 1030, 0, 0, 0, 1030, 0, 1021, + 1034, 0, 8590, -147, 0, 8590, 0, 1056, 1072, 0, + 228, 0, 62, 5003, 0, 1067, 1057, 24, 511, 3907, + 0, 0, 1030, 0, 228, 0, 1068, 1058, 1073, 1071, + 0, 1075, 1034, 1078, 59, 1080, 1083, 0, 0, 1091, + 1097, 0, 791, 0, 766, 0, 0, 0, 1096, 0, + -97, 0, 1087, 0, 0, 1103, 0, 1107, 1108, 1110, + 0, 1063, 0, 59, 59, 0, 59, 1106, 1112, 0, + 0, 0, 0, 1109, 127, 0, 1115, 59, 1234, 1118, + 59, 0, 27, 0, 8573, 1079, 1120, 1063, 0, 1119, + 1121, 129, 1128, 0, 0, 59,10863, 1084, 1125, 1109, + 0, 0,13194, 0, 367, 367, 0, 1085, 1130, 1115, + 0, 1132, 0,11135, 1090, 1133, 1118, 0, 1139, 59, + 0, -74, 0, 1124, 0, 0, 0, 0, 0,13194, + 0, 129, 129, 1145, 1141, 0, -97, 0, 0, 106, + 1146,13194, 0,13194, 0, 0, 8573, 1134, 0, 0, + 0, 1149, 1103, 0, 0, 0, 1151, 0, 445, 0, + 0, 0, 1045, 794, 1150, 0, 0, 0, 0, 0, + 0, 0, 0, 1206, 1261, 0, 0, 0, 0, 0, + 0, 1155, 1157, 8573, 0, 0, 0, 0, 129, 542, + 542, 0, 1045, 0, 0, 0, -79, -79, 0, 0, + 0, 0, 0, 0, 0,10455,10455, 0, 0, 0, + 0, 0, 1161, 1158, 1159, 0, 0, 0, }; - protected static readonly short [] yyRindex = { 2755, - 0, 0, 7131, 2755, 0, 0, 0, 1605, 0, 0, - 2908, 1725, 0, 0, 0, 0, 0, 2908, 0, 0, - 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, + protected static readonly short [] yyRindex = { 1916, + 0, 0, 7355, 1916, 0, 0, 0, 1532, 0, 0, + 3243, 1827, 0, 0, 0, 0, 0, 3243, 0, 0, + 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1606, 0, 0, 1606, 0, 0, 1605, - 2982, 2802, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1240, 0, 0, 0, 0, 0, 0, 0, 0, -12204, 0, 1239, 0, 0, 0, 1239, 0, 0, 0, - 0, 0, 0, 106, 0, 0, 0, 0, 0, 0, - 0, 0, 204, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 4430, 0, 0, 0, 0, - 0, 0, 236, 4589, 3800, 0, 0, 4365, 0, 0, + 0, 0, 0, 1533, 0, 0, 1533, 0, 0, 1532, + 3286, 3157, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1167, 0, 0, 0, 0, 0, 0, 0, 0, + 9218, 0, 1160, 0, 0, 0, 1160, 0, 0, 0, + 0, 0, 0, -280, 0, 0, 0, 0, 0, 0, + 0, 0, 234, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 4714, 0, 0, 0, 0, + 0, 0, 182, 4873, 4084, 0, 0, 4649, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 4745, 4813, - 5157, 5361, 1140, 5837, 5973, 6109, 6245, 6381, 1729, 3691, - 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 5029, 5097, + 5441, 5645, 5985, 6189, 6325, 6461, 6597, 1264, 1413, 2967, + 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 231, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 931, 931, 3025, 0, - 550, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 207, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 3329, 0, + 599, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1606, 112, 0, 0, 0, 0, 0, 0, - 0, 3068, 395, 3131, 0, 0, 0, 0, 0, 0, + 0, 0, 1533, 136, 0, 0, 0, 0, 0, 0, + 0, 3372, 355, 3415, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 3411, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3695, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1242, 0, 0, 0, 0, 0, - 3411, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 2136, 0, 2500, 253, - 2266, 0, 0, 0, 2396, 2266, 0, 0, 0, 0, - 0, 1240, 0, 0, 0, 140, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1172, 0, 0, 0, 0, + 0, 0, 3695, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2517, + 0, 3027, 119, 2647, 0, 0, 0, 2777, 2647, 0, + 0, 0, 0, 0, 1167, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1244, 1554, 0, 0, 1239, 0, 3411, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 206, 0, 0, 0, + 0, 0, 0, 1163, 2881, 0, 0, 1160, 0, 3695, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1275, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 178, 0, 0, 0, 0, 0, 0, 0, 3178, 3245, - 0, 0, 0, 0, 1990, 1606, 1606, 0, -208, 0, - 8071, 1606, 1618, 0, 0, 177, 0, 0, 0, 0, + 1656, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3975, 0, 0, 0, 0, + 0, 0, 0, 3482, 3529, 0, 0, 0, 0, 2371, + 1533, 1533, 0, -132, 0, 8000, 1533, 1541, 0, 0, + 197, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 417,11964, + 0, 0, 0, 0, 3695, 0, 0, 0, 0, 0, + 0, 0, 0,12353, 0, 0, 0, 0, 0, 0, + 0, 637, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 591, 973, 0, 0, 1176, 0, 0, 0, 0, + 0, 140, 0, 0, 4172, 1173, 0, 0, 0, 407, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2078, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 412,11492, 0, 0, 0, 0, 3411, - 0, 0, 0, 0, 0, 0, 0, 0,11881, 0, - 0, 0, 0, 0, 0, 0, 1257, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 735, 974, 0, 0, - 1252, 0, 0, 0, 0, 0, 182, 0, 0, 3888, - 1262, 0, 0, 0, -169, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1463, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1244, 0, - 0, 6500, 0, 207, 0, 0, 0, 0, 0, 0, - 8820, 0, 0, 0, 0, 0, 0, -194, 646, 0, - 0, 0, 1263, 0, 0, 0, 0, 0, 0, 0, - 3411, 0, 3411, 0, 4047, 0, 0, 0, 0, -271, - 0, 0, 0, 0, 219, 0, 0, 0, 4917, 0, + 0, 0, 0, 1163, 0, 0, 6724, 0, 145, 0, + 0, 0, 0, 0, 0, 9515, 0, 0, 0, 0, + 0, 0, -158, 380, 0, 0, 0, 1174, 0, 0, + 0, 0, 0, 0, 0, 3695, 0, 3695, 0, 4331, + 0, 0, 0, 0, -284, 0, 0, 0, 0, 130, + 0, 0, 0, 5201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 4985, 5089, 5225, 5293, 5429, - 5497, 5565, 5633, 5701, 5769, 5905, 6041, 6177, 6313, 6437, - 0, 0, 749, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4009, 0, 0, 1990, 0, 0, - 0, 0, 1222, 9024, 0, 0, 0,12228, 0, 0, - 768, 0, 0, 0, 0, 0, 0, 683, 668, 0, - 0, 1269, 0, 0, 0, 0, 1274, 0, 0, 0, - 0, 0, 0,11071, 0, 0, 0, 770, 0, 0, - 0,12278, 0, 0, 787, 801, 805, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1268, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1284, 0, 0, - 0, 3477, 0, 0, 215, 0, 92, 3570, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1287, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 105, 587, - 0, 0, 0, 0, 0, 1294, 0, 0, 0, 0, + 5269, 5373, 5509, 5577, 5713, 5781, 5849, 5917, 6053, 6121, + 6257, 6393, 6529, 6665, 1918, 0, 0, 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 8820, 0, 0, 0, 0, 0, 0, 0, 0, + 3975, 0, 0, 0, 0, 2371, 0, 0, 0, 0, + 1131, 9719, 0, 0, 0, 9375, 0, 0, 737, 0, + 0, 0, 0, 0, 0, 693, -247, 0, 0, 1177, + 0, 0, 0, 0, 1181, 0, 0, 0, 0, 0, + 0,11543, 0, 0, 0, 741, 0, 0, 0,12618, +12429, 0, 0, 752, 757, 768, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 640, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1183, 0, 0, 0, 3761, + 0, 0, 151, 0, 57, 3854, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1184, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 236, 709, 0, 0, + 0, 0, 0, 1182, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9515, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 180, 0, 0, 0, 1313, - 0, 0, 0, 0, 0, 0, 0, 0, 311, 0, - 473, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -208, 0, 0, 0, 0,12278, 8366, 0, 1320, - 0, 640, 0, 0, 0, 0, 1325, 0, 1276, 1278, - 0, 0, 0, 0, 0, 1321,12302, 0, 0, 0, -11957, 0, 0, 0, 811, 0, 0, 0, 0, 0, - 1864, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 3729, 0, 4206, 1331, 0, - 0, 0, 1328, 0, 0, 0, 0, 356, 0, 0, - 0, 0, 811, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1326, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 606, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -186, + 0, 504, 0, 0, 0, 0, 0, 0, 0, 0, + -132, 0, 0, 0, 0,12618, 8295, 0, 1185, 0, + 666, 0, 0, 0, 0, 1189, 0, 1140, 1142, 0, + 0, 0, 0, 0, 1186,12672, 0, 0, 0, 0, +12461, 0, 0, 0, 769, 0, 0, 0, 0, 0, + 0, 2245, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4013, 0, 4490, 1191, + 0, 0, 0, 1192, 0, 0, 0, 0, 318, 0, + 0, 0, 0, 769, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 831, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 579, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 778, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1193, 0, 0, 0, 0, + 0, 784, 785, 0, 0, 0, 0, 0, 0, 0, + 1195, 649, 1194, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4172, 0, 0, 0, 0, 0, + 1197, 0, 0, 318, 0, 0, 816, 0, 1195, 0, + 0, 0, 9515, 0, 572, 595, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1177, + 9565, 0, 0, 0, 0, 0,12714, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 665, 0, + 678, 0, 0, 0, 0, 1199, 0, 671, 1198, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1212, + 0, 7512, 0, 0, 0, 0, 0, 0, 9515, 0, + 0, 0, 0, 0, 0, 0, 294, 550, 0, 0, + 0, 0, 0,12790,12353, 0, 371, 371, 371, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1327, 0, 0, 0, 0, 0, - 858, 874, 0, 0, 0, 0, 0, 0, 0, 1329, - 749, 1330, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 3888, 0, 0, 0, 0, 0, 1337, - 0, 0, 356, 0, 0, 912, 0, 1329, 0, 0, - 0, 8820, 0, 695, 750, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 192, 0, 1269, 8870, 0, 0, - 0, 0, 0,12353, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 795, 0, 798, 0, 0, - 0, 0, 1338, 0, 1313, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1339, 0, 7288, 0, 0, - 0, 0, 0, 0, 8820, 0, 0, 0, 0, 0, - 0, 419, 630, 0, 0, 0, 0, 0, 0, 0, -12396,11881, 0, 80, 80, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0,12895, + 0, -271, 0, 1214, 1214, 1214, 0, 0, 0, 0, + 0, 1210, 0, 0, 0, -157, 0, 0, 0, 0, + 0, 0, 0, 0, 0,12938, 0, 0, 0, 0, + 1217, 0, 0, 375, 0, 0, 0, 544, 0, 0, + 0, 0, 0, 0, 0, 0, 1216, 0, 1218, 0, + 0, 0, 3200, 1213, 414, 0, -14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0,12465, 0, -258, 0, - 1344, 1344, 1344, 0, 0, 0, 0, 0, 1340, 0, - 0, -201, 0, 0, 0, 0, 0, 0, 0, 0, -12508, 0, 0, 0, 0, 1345, 0, 0, 0, 111, - 0, 0, 0, 0, 581, 0, 0, 0, 0, 0, - 0, 1342, 0, 1347, 0, 0, 0, 2865, 1341, 579, - 0, -72, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 2669, 0, 0, 0, - 9129, 9327, 0, 0, 0, 691, 0, 0, 0, 0, - 0, 0, 0, 0, 406, 0, 0,11663, 9421, 0, - 0, 9228, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0,11731, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9507, 0, 9129, 0, - 0, 0, 691, 0, 0, 0, 0, 412, 0, 0, - 0, 0, 0, 0, 0, 412, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 4362, 438, - 0, 9549, 0, 0, 0, 4719, 0, 2669, 0, 0, - 0, 2669, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 461, 0, 1349, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 2669, 0, 548, 0, - 671, 0, 0, 0, 0, 0, 0, 0,11881, 876, - 0, 0, 0, 0, 0, 1348, 0, 866, 0, 0, - 0, 0, 0, 0, 0, 882, 0, 0, 0, 0, - 0, 0, 0, 0, 1346, 0,11881,11881, 0,11913, - 0, 0, 0, 0, 0, 0, 1350,12732, 0, 1356, -11881,11207, 1359,11881, 0, 0, 0, 0, 0, 0, - 1368, 0, 0, 0,12702, 0, 0, 0,11881, 0, - 0, 0, 1369, 0, 0, 234, 0,12626,12664, 0, - 0, 0, 1370, 0, 0, 0, 0, 0, 0, 1371, - 0, 0,11881, 0, 585, 0, 886, 0, 0, 0, - 0, 0, 922, 0,12550,12588, 0, 0, 0, 0, - 0, 0, 0, 0, 1403, 0, 1460, 0, 0, 0, - 892, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 597, 0, 0, 0, 0, + 0, 0, 1553, 0, 0, 0, 0, 9824,10022, 0, + 0, 0, 641, 0, 0, 0, 0, 0, 0, 0, + 0, 534, 0, 0,12135,10116, 0, 0, 9923, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0,12203, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,10202, 0, 9824, 0, 0, 641, 0, + 0, 0, 0, 417, 0, 0, 0, 0, 0, 0, + 0, 417, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 744, 433, 0,10244, 0, 0, + 0, 1148, 0, 1553, 0, 0, 0, 1553, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 190, 0, 1224, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1553, 0, 763, 0, 623, 0, 0, 0, + 0, 0, 0, 0,12353, 790, 0, 0, 0, 0, + 0, 0, 1188, 0, 221, 0, 0, 0, 0, 0, + 0, 0, 798, 0, 0, 0, 0, 0, 0, 0, + 0, 1219, 0,12353,12353, 0,12385, 0, 0, 0, + 0, 0, 0, 1220,13132, 0, 1221,12353,11679, 1222, +12353, 0, 0, 0, 0, 0, 0, 1229, 0, 0, + 0, 1266, 0, 0, 0,12353, 0, 0, 0, 1230, + 0, 0, 232, 0,13056,13094, 0, 0, 0, 1231, + 0, 0, 0, 0, 0, 0, 1245, 0, 0,12353, + 0, 554, 0, 803, 0, 0, 0, 0, 0, 828, + 0,12980,13018, 0, 0, 0, 0, 0, 0, 0, + 0, 1277, 0, 1330, 0, 0, 0, 811, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0,12702, 905,11379, 0, 597, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1262, 1262, + 0, 0, 556, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1266,11851, +12832, 0, 556, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1173, 1173, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, }; protected static readonly short [] yyGindex = { 0, - 0, 1674, 0, 0, 0, -3, -15, -178, -41, -38, - 0, 1737, 1751, 635, 0, -1, 0, 0, 0, 0, - 0,-1105, -697, -220, -381, 0, 0, 0, 0, 0, - -229, 0, 0, 0, 813, 0, 919, 0, 0, 0, - 0, 670, 674, -17, -225, 0, 3, 0, 512, 0, - 546,-1109, -616, -569, -568, -527, -461, -452, -449, 0, - 0,-1171, 0, 14, 0, 197, 0,-1083, 0, 0, - 0, -79, 339, 0, 0, 0, 377,-1061, 0, -267, - -296, 1108, 0, 0, 0, -894, 325, 0, 0, -499, - 0, 0, 392, 0, 0, 364, 0, 0, 399, 0, --1195, -978, 0, 0, 0, 0, 0, 495, -13, 0, - 0, 938, 940, 944, 1117, -518, 0, 0, -321, 960, - 481, 0, -836, 0, 0, 0, 0, 0, 0, 0, - 0, 289, 0, 0, 0, 0, 0, 0, 0, 0, - 536, 0, 0, 0, 0, -312, 470, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 576, 0, -505, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 327, 0, - 0, 410, 0, 0, 415, 417, 334, 0, 0, 0, - 0, 0, 0, 0, 0, 637, 0, 0, 0, 0, - -58, 0, 153, -48, 0, 0, 482, 0, 538, 0, - 995, 0, 1301, -292, -273, -43, 850, 0, 649, 0, - -32, 87, 0, 0, 25, 0, 0, 0, 0, 0, + 0, 1544, 0, 0, 0, -2, -9, -179, -48, -43, + 0, 1588, 1617, 589, 0, 3, 0, 0, 0, 0, + 0,-1109, -711, -213, -432, 0, 0, 0, 0, 0, + -228, 0, 0, 0, 668, 0, 775, 0, 0, 0, + 0, 524, 530, -17, -236, 0, -46, 0, 359, 0, + 396,-1114, -607, -598, -534, -519, -516, -513, -500, 0, + 0,-1173, 0, 1, 0, 86, 0,-1098, 0, 0, + 0, -44, 179, 0, 0, 0, 227,-1059, 0, -272, + -279, 955, 0, 0, 0, -894, 181, 0, 0, -505, + 0, 0, 245, 0, 0, 215, 0, 0, 252, 0, + -721, -968, 0, 0, 0, 0, 0, 349, -13, 0, + 0, 779, 780, 782, 949, -537, 0, 0, -323, 796, + 341, 0,-1330, 0, 0, 0, 0, 0, 0, 0, + 0, 149, 0, 0, 0, 0, 0, 0, 0, 0, + 394, 0, 0, 0, 0, -339, 331, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 408, 0, -515, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, + 0, 248, 0, 0, 254, 256, 172, 0, 0, 0, + 0, 0, 0, 0, 0, 477, 0, 0, 0, 0, + -42, 0, 373, -138, 0, 0, 320, 0, 377, 0, + 838, 0, 1153, -295, -263, -63, 1025, 0, 479, 0, + -33, 112, 0, 0, 1152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -255, 0, 820, 0, 0, -94, 0, 0, 0, - 947, 0, -294, -125, 1112, 1043, 0, 1030, 0, 1248, - 1472, 1164, 0, 0, 851, 1775, 0, 0, 0, 0, - 1135, 0, 0, 0, 0, 0, -811, 1516, 0, 0, - 0, 0, 0, 924, 601, 906, 760, 902, 1454, 1456, - 1458, 1459, 1457, 0, 1461, 0, 0, 0, 1076, 1311, - -728, 0, -490, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -300, 0, 0, 0, 0, -450, 0, 696, - 0, 608, 0, 693, 0, 0, 0, 759, -528, 6, - -299, 8, 0, 1709, 0, 65, 0, 77, 89, 91, - 99, 100, 113, 128, 135, 136, 137, 0, -682, 0, - -25, 0, 0, 887, 0, 815, 0, 0, 0, 793, - -117, 864, -842, 0, 908, -471, 0, 0, 0, 0, - 0, 0, 808, 0, 0, 807, 0, 0, 0, 0, + 0, -262, 0, 1209, 0, 0, -130, 0, 0, 0, + 799, 0, -302, -129, 952, 874, 0, 868, 0, 1093, + 1319, 1000, 0, 0, 686, 1624, 0, 0, 0, 0, + 1008, 0, 0, 0, 0, 0, -599, 1363, 0, 0, + 0, 0, 0, 1327, 343, 806, 704, 802, 1315, 1298, + 1333, 1335, 1332, 0, 1334, 0, -608, 0, 0, 947, + 1190, -747, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -294, 0, 0, 0, 0, -454, 0, 562, + 0, 472, 0, 558, 0, 0, 0, 619, -530, -5, + -314, -3, 0, 1585, 0, 46, 0, 82, 84, 85, + 91, 117, 118, 125, 126, 132, 134, 0, -664, 0, + -27, 0, 0, 758, 0, 681, 0, 0, 0, 0, + 659, -145, 734, -870, 0, 797, -468, 0, 0, 0, + 0, 0, 0, 674, 0, 0, 673, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 737, 0, 0, 0, 0, 0, 0, 0, 0, -39, - 0, 1352, 0, 0, 0, 975, 0, 0, 0, 0, - 0, 0, -171, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1465, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 626, 0, 0, 0, 0, 0, - 0, 0, 0, 738, 0, 0, 0, 0, 0, 0, - -4, 1050, 0, 0, 0, 1047, + 0, 0, 604, 0, 0, 0, 0, 0, 0, 0, + 0, -19, 0, 1228, 0, 0, 0, 857, 0, 0, + 0, 0, 0, 0, -170, 0, 0, 0, 0, 0, + 1345, 1123, 0, 0, 0, 1347, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 506, 0, 0, 0, 0, + 0, 0, 0, 0, 614, 0, 0, 0, 0, 0, + 0, 2, 929, 0, 0, 0, 933, }; protected static readonly short [] yyTable = { 109, - 18, 514, 189, 111, 468, 733, 517, 323, 328, 233, - 429, 447, 234, 738, 682, 704, 428, 533, 192, 43, - 490, 472, 155, 510, 156, 777, 257, 1014, 353, 571, - 871, 404, 872, 259, 544, 1134, 557, 308, 572, 498, - 316, 890, 229, 910, 251, 773, 1258, 942, 1167, 1168, - 790, 539, 785, 709, 360, 302, 368, 14, 411, 302, - 190, 362, 1062, 675, 1266, 309, 789, 311, 1045, 361, - 292, 369, 1194, 411, 1063, 665, 902, 337, 1063, 904, - 1047, 160, 1324, 258, 1017, 47, 360, 1005, 288, 322, - 327, 1210, 1238, 161, 334, 1195, 289, 47, 443, 1320, - 625, 666, 625, 115, 20, 162, 1162, 163, 16, 314, - 808, 348, 1333, 1128, 559, 164, 165, 258, 523, 436, - 437, 258, 258, 258, 258, 258, 258, 258, 258, 166, - 2, 1351, 346, 667, 634, 746, 782, 1238, 834, 109, - 472, 412, 432, 111, 167, 115, 413, 233, 414, 115, - 430, 168, 169, 170, 415, 416, 412, 625, 712, 47, - 290, 413, 155, 414, 156, 714, 789, 1451, 362, 415, - 416, 560, 194, 1007, 406, 362, 6, 362, 783, 362, - 347, 478, 1315, 290, 652, 1365, 1316, 1337, 1217, 1163, - 446, 42, 1071, 430, 1072, 741, 881, 360, 196, 360, - 468, 360, 360, 348, 360, 1, 360, 488, 447, 47, - 1017, 1343, 727, 731, 752, 291, 873, 349, 438, 15, - 789, 160, 191, 362, 1433, 676, 519, 571, 1064, 471, - 1046, 417, 1064, 161, 476, 809, 572, 668, 291, 194, - 194, 444, 1048, 115, 1325, 162, 427, 163, 360, 473, - 360, 1457, 257, 360, 557, 164, 165, 20, 572, 486, - 194, 477, 257, 1467, 1395, 1468, 796, 540, 563, 166, - 489, 432, 758, 532, 713, 493, 495, 536, 332, 557, - 1338, 715, 541, 1076, 167, 690, 1452, 885, 531, 520, - 911, 168, 169, 170, 528, 316, 530, 231, 979, 529, - 493, 231, 1059, 432, 942, 614, 615, 2, 580, 258, - 1366, 742, 546, 547, 882, 578, 1501, 581, 678, 258, - 389, 390, 679, 885, 258, 538, 48, 582, 1429, 1087, - 543, 937, 938, 637, 639, 657, 835, 302, 761, 969, - 977, 556, 54, 558, 572, 47, 1114, 942, 471, 592, - 1353, 194, 194, 600, 601, 602, 603, 604, 605, 606, - 607, 608, 609, 610, 290, 752, 658, 348, 473, 473, - 691, 115, 1478, 3, 4, 5, 6, 231, 1383, 1384, - 797, 1386, 1298, 680, 686, 632, 649, 233, 759, 998, - 430, 409, 1405, 506, 258, 1412, 983, 653, 231, 864, - 115, 886, 1498, 1422, 346, 887, 258, 258, 258, 231, - 1428, 258, 258, 194, 481, 636, 638, 640, 657, 291, - 333, 683, 115, 1140, 468, 290, 225, 94, 226, 647, - 1145, 650, 651, 6, 1450, 986, 1502, 663, 1018, 194, - 1020, 887, 1022, 669, 410, 1464, 657, 385, 638, 658, - 348, 194, 347, 638, 762, 1170, 978, 638, 194, 942, - 472, 703, 498, 249, 571, 942, 699, 354, 735, 740, - 642, 643, 638, 572, 735, 348, 355, 658, 348, 1052, - 291, 774, 348, 386, 348, 348, 348, 348, 701, 349, - 710, 729, 348, 592, 483, 736, 638, 1465, 482, 638, - 194, 878, 484, 194, 507, 1143, 508, 681, 249, 743, - 745, 262, 250, 473, 1263, 355, 231, 740, 638, 763, - 432, 1250, 355, 735, 765, 750, 896, 896, 1079, 751, - 1081, 346, 792, 760, 794, 967, 795, 194, 194, 803, - 895, 895, 775, 346, 199, 572, 739, 778, 638, 437, - 644, 454, 290, 454, 411, 485, 290, 250, 962, 556, - 509, 558, 879, 387, 388, 194, 194, 1474, 681, 877, - 798, 798, 784, 115, 682, 1475, 356, 449, 740, 347, - 918, 1088, 438, 194, 556, 1239, 558, 727, 1459, 1460, - 450, 347, 433, 728, 1122, 434, 804, 194, 326, 827, - 258, 883, 348, 1296, 326, 200, 896, 898, 454, 333, - 437, 1003, 993, 777, 348, 333, 349, 812, 245, 432, - 895, 333, 246, 819, 333, 333, 1147, 94, 349, 517, - 1239, 249, 1240, 1241, 449, 682, 1476, 412, 333, 815, - 115, 817, 413, 438, 414, 1492, 1299, 450, 728, 926, - 415, 416, 1297, 326, 926, 197, 926, 1176, 869, 926, - 926, 971, 926, 926, 893, 115, 638, 704, 471, 848, - 333, 638, 247, 739, 1242, 638, 94, 1240, 1241, 753, - 250, 1056, 493, 636, 926, 257, 197, 907, 473, 231, - 638, 433, 847, 849, 826, 1300, 870, 731, 736, 748, - 1206, 194, 912, 729, 716, 866, 536, 636, 24, 637, - 25, 832, 333, 26, 347, 348, 1253, 638, 27, 1242, - 850, 1033, 28, 194, 333, 358, 503, 333, 333, 791, - 504, 30, 894, 637, 636, 583, 638, 348, 32, 926, - 1243, 333, 258, 33, 664, 584, 905, 34, 906, 1244, - 244, 349, 1245, 833, 315, 899, 908, 929, 778, 36, - 637, 37, 929, 812, 929, 38, 401, 929, 929, 315, - 929, 929, 664, 39, 40, 347, 739, 41, 402, 970, - 749, 664, 988, 592, 347, 1243, 358, 913, 592, 920, - 653, 736, 929, 997, 1244, 1107, 248, 1245, 348, 115, - 962, 115, 359, 473, 812, 812, 290, 348, 473, 194, - 557, 920, 349, 431, 348, 315, 920, 828, 920, 1220, - 1237, 920, 920, 347, 920, 920, 939, 338, 793, 829, - 194, 338, 1137, 333, 115, 959, 115, 489, 669, 1098, - 1220, 115, 557, 522, 260, 115, 348, 929, 115, 649, - 329, 1099, 984, 1086, 358, 44, 523, 682, 951, 987, - 357, 320, 1053, 358, 1033, 1237, 113, 1220, 1169, 995, - 433, 736, 1037, 524, 557, 338, 397, 685, 1416, 895, - 261, 686, 94, 315, 285, 286, 287, 370, 293, 294, - 1053, 1289, 315, 306, 307, 1001, 194, 1004, 565, 851, - 312, 920, 314, 1006, 318, 566, 852, 94, 113, 330, - 331, 812, 113, 812, 338, 812, 1339, 567, 338, 194, - 333, 338, 333, 338, 565, 333, 857, 1015, 338, 1032, - 447, 566, 398, 367, 194, 94, 326, 326, 194, 399, - 1469, 1255, 669, 567, 1193, 1286, 319, 660, 1151, 473, - 400, 268, 319, 1286, 827, 326, 660, 326, 326, 320, - 268, 736, 338, 659, 493, 1042, 403, 1039, 922, 1040, - 599, 1041, 659, 922, 296, 922, 719, 1489, 922, 922, - 720, 922, 922, 435, 517, 391, 392, 616, 617, 468, - 225, 728, 194, 1507, 1508, 504, 395, 396, 778, 393, - 394, 812, 333, 812, 439, 1082, 113, 469, 333, 65, - 194, 194, 442, 65, 333, 470, 335, 601, 333, 601, - 338, 339, 340, 341, 342, 343, 344, 345, 491, 916, - 1091, 333, 332, 225, 916, 228, 916, 64, 64, 916, - 916, 64, 916, 916, 278, 489, 278, 492, 326, 326, - 513, 278, 333, 333, 359, 333, 333, 56, 922, 1115, - 736, 778, 249, 333, 362, 518, 766, 812, 766, 521, - 766, 115, 1032, 312, 194, 1127, 367, 537, 295, 489, - 296, 542, 489, 363, 364, 233, 550, 1154, 430, 382, - 383, 384, 473, 962, 576, 1013, 194, 806, 1089, 812, - 1090, 577, 497, 365, 194, 333, 1150, 333, 497, 233, - 326, 250, 430, 348, 366, 556, 511, 558, 489, 916, - 1214, 755, 745, 755, 745, 755, 333, 333, 412, 527, - 812, 1082, 585, 413, 113, 414, 326, 962, 352, 962, - 1154, 415, 416, 757, 664, 757, 333, 556, 326, 558, - 620, 621, 622, 623, 333, 326, 155, 333, 155, 1218, - 1236, 711, 1219, 113, 167, 27, 167, 179, 167, 179, - 162, 179, 162, 812, 163, 648, 163, 1214, 684, 556, - 1218, 558, 873, 1219, 873, 113, 467, 231, 27, 812, - 717, 489, 115, 687, 1294, 1295, 115, 326, 689, 115, - 326, 27, 67, 718, 67, 1236, 27, 1218, 934, 935, - 1219, 27, 740, 27, 27, 27, 27, 1323, 757, 27, - 1326, 27, 764, 335, 115, 27, 766, 185, 115, 185, - 1119, 1120, 348, 432, 326, 326, 348, 27, 333, 348, - 27, 348, 27, 156, 767, 156, 348, 789, 1291, 120, - 768, 120, 545, 1270, 769, 283, 1331, 283, 786, 127, - 115, 127, 326, 326, 787, 290, 27, 290, 1259, 231, - 1331, 802, 27, 27, 502, 348, 439, 1479, 1480, 895, - 895, 801, 194, 521, 521, 638, 638, 1361, 806, 1362, - 115, 1132, 1133, 545, 618, 619, 624, 625, 814, 1340, - 807, 700, 816, 818, 824, 611, 612, 613, 836, 837, - 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - 545, 545, 545, 545, 545, 545, 1396, 433, 839, 840, - 843, 855, 860, 42, 867, 194, 113, 861, 862, 863, - 868, 498, 744, 1423, 412, 196, 412, 498, 888, 884, - 891, 889, 194, 900, 896, 901, 1435, 1437, 909, 915, - 736, 925, 1291, 930, 932, 412, 412, 936, 946, 940, - 947, 952, 489, 950, 949, 955, 326, 957, 975, 963, - 976, 979, 985, 1423, 1423, 412, 992, 507, 1011, 1445, - 999, 1010, 1035, 412, 1016, 569, 412, 1026, 326, 1043, - 1049, 1051, 1050, 113, 1058, 1060, 1070, 1077, 1074, 194, - 194, 1078, 1080, 1085, 1093, 1101, 1102, 1105, 194, 1097, - 326, 1100, 736, 1103, 1108, 1118, 194, 194, 113, 194, - 545, 1121, 1153, 1123, 1130, 1311, 1135, 1146, 1143, 1141, - 1423, 1175, 1178, 1163, 1192, 1189, 1182, 1311, 1197, 194, - 1183, 1180, 194, 1193, 1200, 1184, 1201, 1202, 1203, 736, - 1311, 1251, 845, 1205, 1209, 1256, 1260, 1267, 1254, 1494, - 1494, 1257, 1272, 1301, 1293, 1314, 1503, 1503, 569, 1311, - 1329, 592, 592, 569, 1332, 569, 569, 569, 569, 569, - 569, 569, 569, 569, 569, 569, 1335, 1347, 1345, 788, - 1318, 473, 473, 1319, 1328, 1336, 326, 569, 1348, 569, - 1354, 569, 1350, 569, 569, 569, 1352, 1356, 1358, 1338, - 1359, 371, 1364, 569, 569, 1372, 1375, 326, 569, 569, - 502, 1369, 1379, 1376, 1377, 502, 502, 569, 569, 569, - 569, 1387, 372, 373, 374, 375, 376, 377, 378, 379, - 380, 381, 569, 333, 1388, 1406, 1391, 1401, 502, 1408, - 1417, 1420, 113, 1418, 113, 1421, 1427, 1430, 569, 1455, - 1431, 502, 502, 1442, 1444, 1441, 502, 1447, 1449, 502, - 1461, 502, 1446, 502, 502, 502, 502, 1462, 1466, 1470, - 1473, 502, 1471, 326, 1481, 502, 1465, 1464, 1487, 502, - 1488, 1509, 1510, 1511, 9, 958, 534, 502, 113, 492, - 502, 113, 502, 502, 843, 602, 326, 950, 502, 493, - 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, - 502, 326, 810, 449, 603, 326, 502, 502, 29, 671, - 21, 502, 502, 814, 502, 502, 502, 502, 502, 502, - 502, 491, 502, 502, 29, 502, 502, 502, 502, 502, - 502, 502, 502, 502, 502, 517, 502, 502, 502, 502, - 502, 502, 502, 502, 502, 502, 502, 502, 502, 502, - 502, 502, 502, 502, 502, 502, 502, 502, 749, 30, - 502, 311, 502, 206, 502, 96, 759, 502, 30, 851, - 751, 750, 760, 502, 783, 815, 784, 326, 326, 752, - 659, 817, 315, 819, 681, 340, 659, 638, 845, 845, - 333, 123, 638, 230, 34, 105, 845, 845, 845, 845, - 845, 286, 845, 845, 130, 845, 845, 845, 845, 845, - 845, 845, 845, 124, 106, 287, 131, 845, 53, 845, - 845, 845, 845, 845, 845, 21, 1027, 845, 945, 1125, - 1269, 845, 845, 1126, 845, 845, 845, 1261, 1463, 1432, - 1472, 326, 1419, 1448, 1414, 1321, 845, 1308, 845, 1505, - 845, 845, 1268, 1342, 845, 845, 845, 845, 845, 845, - 845, 845, 845, 845, 845, 845, 845, 845, 972, 845, - 973, 326, 845, 845, 974, 545, 845, 845, 858, 333, - 1265, 1497, 1443, 1438, 1436, 333, 968, 1496, 1198, 1363, - 1312, 845, 845, 845, 845, 845, 941, 754, 991, 845, - 845, 1199, 876, 845, 113, 919, 800, 587, 845, 845, - 845, 845, 845, 917, 1061, 298, 845, 548, 845, 854, - 626, 333, 874, 627, 845, 845, 628, 630, 629, 771, - 1186, 914, 631, 777, 1273, 405, 1190, 1055, 1142, 1104, - 1116, 1073, 1044, 1109, 1111, 1172, 747, 1008, 1271, 845, - 845, 845, 845, 942, 845, 646, 1177, 943, 0, 0, - 0, 845, 333, 0, 0, 0, 0, 333, 0, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 0, 0, 0, 0, 0, 333, 0, 0, 0, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 0, 333, 333, 0, 0, 333, 333, 333, 333, 333, - 0, 0, 333, 333, 0, 0, 0, 333, 333, 333, - 333, 333, 333, 333, 333, 113, 0, 0, 0, 113, - 0, 0, 113, 0, 0, 0, 333, 0, 0, 333, - 0, 333, 0, 333, 0, 0, 333, 0, 0, 326, - 0, 34, 333, 0, 582, 34, 0, 113, 0, 333, - 0, 113, 0, 0, 0, 0, 34, 0, 0, 0, - 0, 34, 0, 0, 0, 34, 0, 0, 34, 0, + 741, 18, 233, 111, 522, 473, 43, 234, 189, 434, + 477, 155, 746, 156, 577, 690, 495, 433, 452, 519, + 319, 293, 192, 712, 562, 257, 538, 407, 785, 549, + 576, 259, 921, 503, 515, 901, 827, 828, 793, 1025, + 325, 330, 326, 331, 251, 337, 1180, 1181, 229, 364, + 1147, 372, 437, 798, 955, 304, 882, 311, 883, 304, + 673, 1274, 160, 356, 544, 312, 1076, 314, 1030, 939, + 363, 717, 371, 781, 817, 14, 448, 340, 1077, 1282, + 1, 720, 739, 1210, 190, 335, 674, 627, 739, 627, + 511, 683, 20, 1058, 1018, 1211, 316, 364, 161, 1060, + 162, 163, 913, 1227, 1255, 915, 815, 164, 1340, 486, + 795, 1476, 1477, 1077, 412, 249, 394, 395, 675, 586, + 392, 393, 64, 64, 351, 409, 64, 843, 115, 587, + 396, 397, 477, 165, 166, 350, 1141, 739, 799, 109, + 233, 167, 168, 111, 627, 435, 47, 639, 169, 1255, + 170, 155, 939, 156, 441, 442, 16, 939, 1382, 939, + 349, 47, 939, 939, 250, 939, 939, 413, 1509, 42, + 115, 291, 260, 47, 115, 1154, 1518, 289, 291, 1216, + 922, 1468, 2, 451, 437, 290, 196, 939, 435, 892, + 804, 896, 760, 487, 1331, 1030, 6, 721, 1332, 818, + 478, 512, 160, 513, 364, 249, 473, 932, 350, 735, + 795, 364, 482, 364, 577, 364, 437, 483, 884, 990, + 452, 585, 676, 1360, 443, 816, 292, 336, 449, 476, + 576, 351, 1078, 292, 481, 739, 577, 15, 161, 1450, + 162, 163, 939, 493, 562, 352, 191, 164, 3, 4, + 5, 6, 257, 684, 250, 1059, 537, 514, 491, 364, + 541, 1061, 257, 524, 795, 546, 1474, 1078, 115, 562, + 1341, 494, 291, 165, 166, 1090, 498, 500, 1484, 543, + 1485, 167, 168, 1383, 548, 47, 545, 94, 169, 536, + 170, 525, 261, 1198, 1155, 896, 1519, 533, 1217, 535, + 1469, 657, 534, 498, 805, 897, 568, 893, 694, 898, + 1016, 955, 955, 722, 698, 551, 552, 1348, 749, 2, + 766, 564, 478, 478, 811, 577, 660, 292, 1100, 980, + 450, 1073, 1031, 561, 1033, 563, 691, 1036, 583, 782, + 304, 1128, 844, 619, 620, 869, 760, 1446, 1354, 769, + 388, 476, 597, 318, 291, 889, 605, 606, 607, 608, + 609, 610, 611, 612, 613, 614, 615, 361, 1481, 641, + 643, 642, 644, 647, 1495, 1234, 1370, 988, 565, 790, + 48, 812, 1412, 362, 1439, 233, 389, 450, 637, 841, + 435, 350, 194, 94, 1009, 661, 318, 115, 1314, 699, + 783, 291, 1305, 47, 1515, 1400, 1401, 997, 1403, 292, + 994, 1199, 743, 898, 874, 1085, 890, 1086, 685, 1422, + 1482, 791, 1429, 1093, 955, 1095, 1096, 231, 115, 723, + 955, 842, 1349, 473, 750, 437, 767, 1445, 655, 231, + 701, 1355, 658, 659, 710, 340, 718, 800, 671, 802, + 115, 803, 677, 6, 577, 1153, 909, 477, 231, 194, + 194, 1467, 1160, 503, 711, 770, 390, 391, 640, 478, + 576, 708, 473, 640, 350, 335, 350, 640, 686, 685, + 194, 335, 687, 357, 1065, 759, 1183, 335, 231, 768, + 335, 335, 640, 989, 640, 231, 737, 231, 597, 744, + 744, 451, 350, 349, 335, 488, 350, 438, 350, 350, + 350, 350, 686, 489, 751, 753, 350, 836, 439, 640, + 982, 880, 1162, 404, 771, 860, 508, 577, 792, 773, + 509, 358, 861, 837, 758, 405, 335, 437, 640, 743, + 1221, 888, 978, 688, 328, 838, 640, 744, 231, 942, + 328, 350, 786, 561, 1191, 563, 340, 291, 451, 881, + 340, 414, 335, 115, 1312, 115, 490, 1315, 438, 732, + 115, 194, 194, 686, 351, 806, 806, 930, 561, 439, + 563, 349, 245, 20, 973, 414, 246, 350, 352, 1336, + 735, 350, 359, 335, 350, 824, 350, 826, 1223, 328, + 349, 350, 1350, 115, 340, 894, 834, 357, 744, 197, + 94, 1256, 1014, 1313, 249, 1269, 1316, 54, 350, 1101, + 1257, 1368, 821, 199, 732, 785, 640, 821, 821, 350, + 830, 640, 942, 1004, 194, 640, 247, 942, 522, 942, + 197, 351, 942, 942, 415, 942, 942, 478, 350, 416, + 640, 417, 351, 357, 418, 419, 1256, 420, 421, 225, + 194, 226, 362, 250, 876, 1257, 352, 942, 415, 857, + 115, 351, 194, 416, 335, 417, 476, 640, 418, 419, + 194, 420, 421, 712, 1258, 352, 335, 856, 638, 335, + 335, 498, 257, 858, 541, 115, 640, 527, 1069, 1259, + 1491, 200, 1260, 335, 639, 1261, 744, 904, 1492, 659, + 528, 737, 638, 660, 910, 604, 438, 351, 1262, 439, + 859, 1046, 942, 194, 649, 739, 194, 529, 639, 1258, + 918, 801, 621, 622, 422, 231, 335, 659, 743, 638, + 905, 660, 335, 361, 1259, 923, 924, 1260, 335, 244, + 1261, 603, 335, 603, 916, 639, 917, 999, 432, 933, + 194, 194, 478, 1262, 919, 335, 786, 478, 1008, 1493, + 657, 821, 318, 362, 362, 362, 248, 362, 362, 1038, + 362, 321, 362, 436, 528, 1237, 1254, 321, 194, 194, + 263, 597, 661, 350, 322, 94, 597, 335, 821, 361, + 744, 754, 350, 724, 1121, 935, 1237, 415, 194, 562, + 398, 399, 416, 350, 417, 438, 351, 418, 419, 361, + 420, 421, 194, 981, 362, 351, 362, 701, 318, 362, + 973, 1254, 115, 1237, 115, 906, 351, 472, 231, 352, + 1150, 562, 933, 318, 970, 1066, 494, 933, 318, 933, + 352, 677, 933, 933, 962, 933, 933, 1012, 588, 1015, + 570, 332, 866, 995, 570, 1017, 1046, 571, 589, 690, + 998, 571, 666, 1066, 562, 836, 1182, 94, 115, 572, + 1006, 115, 744, 572, 438, 360, 1356, 835, 935, 1433, + 1026, 1111, 249, 935, 365, 935, 929, 650, 935, 935, + 666, 935, 935, 1112, 761, 373, 1157, 1158, 94, 666, + 663, 478, 400, 366, 367, 1279, 1027, 1209, 1050, 663, + 270, 270, 662, 821, 1028, 821, 194, 1055, 821, 270, + 751, 662, 933, 368, 1302, 414, 751, 402, 751, 772, + 1045, 250, 1302, 772, 369, 772, 756, 772, 194, 401, + 756, 1486, 452, 1271, 756, 693, 403, 677, 498, 694, + 1166, 335, 761, 335, 498, 1052, 761, 1053, 761, 1054, + 761, 335, 744, 755, 335, 498, 727, 406, 935, 929, + 728, 755, 335, 335, 929, 297, 929, 736, 1506, 929, + 929, 509, 929, 929, 440, 877, 280, 522, 280, 878, + 1524, 1525, 335, 280, 357, 947, 948, 473, 820, 786, + 335, 824, 820, 335, 821, 824, 821, 821, 415, 1097, + 751, 225, 751, 416, 751, 417, 444, 357, 418, 419, + 44, 420, 421, 447, 168, 65, 168, 194, 168, 65, + 357, 113, 755, 474, 1104, 357, 755, 181, 232, 181, + 357, 181, 357, 357, 357, 357, 478, 335, 194, 494, + 357, 701, 335, 335, 357, 335, 335, 56, 357, 929, + 385, 386, 387, 1129, 744, 786, 357, 328, 475, 357, + 328, 357, 225, 113, 228, 1045, 296, 113, 297, 1133, + 1134, 233, 494, 1169, 1140, 494, 435, 625, 626, 627, + 628, 1024, 1102, 814, 1103, 357, 975, 115, 975, 1157, + 1158, 329, 329, 821, 763, 496, 763, 233, 561, 1165, + 563, 156, 435, 156, 194, 497, 163, 973, 163, 340, + 518, 494, 329, 340, 362, 335, 340, 164, 340, 164, + 886, 542, 886, 340, 547, 821, 1097, 194, 1169, 67, + 561, 67, 563, 187, 157, 187, 157, 1496, 1497, 437, + 555, 357, 194, 120, 523, 120, 194, 1275, 231, 1235, + 1253, 285, 1231, 285, 1236, 581, 127, 340, 127, 351, + 444, 113, 1347, 561, 292, 563, 292, 522, 522, 821, + 1235, 640, 640, 1145, 1146, 1236, 1347, 623, 624, 629, + 630, 526, 582, 590, 351, 653, 821, 672, 494, 355, + 258, 692, 656, 695, 1378, 1253, 1379, 1235, 697, 719, + 1286, 194, 1236, 329, 329, 725, 726, 748, 1231, 772, + 765, 115, 774, 775, 776, 115, 777, 794, 115, 194, + 194, 795, 797, 809, 258, 1310, 1311, 810, 258, 258, + 258, 258, 258, 258, 258, 258, 814, 823, 825, 829, + 845, 846, 115, 438, 1307, 852, 848, 115, 1339, 262, + 849, 1342, 42, 286, 287, 288, 864, 294, 295, 870, + 871, 899, 308, 309, 872, 873, 329, 879, 895, 315, + 196, 317, 900, 321, 902, 907, 911, 920, 333, 334, + 115, 701, 912, 926, 937, 942, 194, 944, 949, 957, + 113, 951, 329, 958, 961, 1357, 115, 960, 963, 966, + 968, 986, 370, 974, 329, 987, 990, 194, 996, 1003, + 701, 701, 329, 701, 512, 194, 1413, 1010, 1021, 1022, + 499, 113, 1048, 413, 701, 413, 499, 701, 1035, 1039, + 1056, 1062, 1063, 1440, 1072, 1074, 1064, 1092, 1084, 1088, + 1091, 1094, 701, 113, 413, 413, 1452, 1454, 1106, 1110, + 1113, 1114, 1115, 1132, 1116, 329, 1118, 744, 329, 1307, + 1122, 1119, 1135, 1176, 413, 1136, 701, 1148, 1161, 494, + 1190, 1143, 413, 1440, 1440, 413, 1193, 1168, 1208, 1195, + 1213, 1197, 1200, 1205, 1218, 1209, 1462, 1219, 356, 1222, + 1220, 1226, 329, 329, 1267, 1270, 1272, 1276, 1317, 338, + 1273, 1283, 1309, 341, 342, 343, 344, 345, 346, 347, + 348, 356, 1288, 1330, 1362, 1352, 1396, 258, 1334, 744, + 329, 329, 1345, 1364, 356, 1367, 1365, 258, 1369, 356, + 1440, 1335, 231, 258, 356, 1373, 356, 356, 356, 356, + 1371, 1375, 315, 1376, 356, 370, 1381, 1386, 356, 478, + 478, 1389, 356, 1344, 1353, 1355, 744, 1392, 1404, 1393, + 356, 1394, 1408, 356, 1405, 356, 1511, 1511, 1418, 1423, + 1437, 1425, 1438, 1520, 1520, 1435, 1434, 1444, 597, 597, + 1448, 1447, 1458, 1461, 1472, 1459, 516, 1463, 1464, 356, + 1466, 1478, 1479, 1483, 1487, 194, 113, 1498, 1488, 581, + 1482, 532, 1490, 1481, 258, 1504, 47, 1505, 1526, 1527, + 1528, 9, 971, 535, 604, 856, 258, 258, 258, 493, + 963, 258, 258, 494, 450, 605, 29, 21, 674, 47, + 492, 29, 27, 518, 30, 313, 329, 208, 30, 96, + 335, 765, 47, 864, 789, 356, 757, 47, 766, 825, + 758, 194, 47, 826, 47, 47, 47, 47, 329, 790, + 662, 827, 47, 113, 317, 685, 47, 829, 662, 194, + 342, 640, 640, 230, 123, 105, 288, 130, 47, 53, + 329, 47, 581, 47, 124, 106, 289, 581, 113, 581, + 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, + 131, 21, 1040, 956, 1285, 1480, 1138, 47, 338, 47, + 47, 581, 1139, 581, 1277, 581, 1449, 581, 581, 581, + 854, 1465, 1436, 1489, 1431, 194, 194, 1324, 867, 983, + 984, 1337, 985, 581, 194, 503, 1522, 1284, 550, 1281, + 1359, 979, 194, 194, 581, 194, 1514, 1460, 583, 1455, + 1453, 1327, 1513, 1214, 1380, 1328, 581, 1215, 952, 374, + 887, 931, 928, 1327, 762, 194, 808, 592, 194, 329, + 1075, 1002, 581, 863, 299, 709, 1327, 553, 632, 550, + 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 329, 616, 617, 618, 631, 1327, 550, 550, 550, 550, + 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, + 550, 550, 258, 885, 633, 635, 752, 634, 636, 1202, + 925, 408, 1156, 779, 1289, 113, 1206, 113, 1117, 1068, + 1130, 583, 1087, 1123, 1125, 1187, 583, 755, 583, 583, + 583, 583, 583, 583, 583, 583, 583, 583, 583, 651, + 1019, 652, 1057, 833, 1287, 954, 329, 1192, 953, 0, + 583, 0, 583, 0, 583, 0, 583, 583, 583, 0, + 0, 113, 0, 0, 113, 0, 0, 0, 0, 329, + 0, 0, 583, 0, 0, 0, 0, 0, 27, 27, + 0, 0, 0, 27, 329, 0, 0, 27, 329, 27, + 0, 0, 27, 0, 27, 27, 34, 27, 0, 27, + 0, 27, 0, 27, 27, 27, 27, 0, 550, 27, + 27, 583, 0, 0, 0, 27, 0, 27, 27, 27, + 0, 0, 27, 27, 27, 0, 27, 0, 0, 27, + 0, 27, 27, 27, 27, 0, 0, 0, 27, 27, + 27, 0, 0, 27, 27, 27, 0, 258, 0, 0, + 0, 0, 27, 27, 0, 27, 27, 0, 27, 27, + 27, 329, 329, 0, 27, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 796, 0, 0, + 0, 503, 0, 0, 27, 33, 503, 503, 0, 0, + 27, 27, 0, 0, 0, 0, 0, 0, 0, 27, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 503, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 503, 503, 0, 0, 0, 503, 329, 0, + 503, 0, 503, 0, 503, 503, 503, 503, 0, 0, + 27, 0, 503, 0, 0, 0, 503, 0, 0, 0, + 503, 0, 0, 0, 0, 0, 0, 329, 503, 0, + 0, 503, 0, 503, 503, 0, 0, 0, 0, 503, + 0, 503, 503, 503, 503, 503, 503, 503, 503, 503, + 503, 503, 0, 0, 0, 0, 0, 503, 503, 0, + 113, 0, 503, 503, 0, 503, 503, 503, 503, 503, + 503, 503, 0, 503, 503, 0, 503, 503, 503, 503, + 503, 503, 503, 503, 503, 503, 0, 503, 503, 503, + 503, 503, 503, 503, 503, 503, 503, 503, 503, 503, + 503, 503, 503, 503, 503, 503, 503, 503, 503, 0, + 0, 503, 0, 503, 0, 503, 0, 858, 503, 0, + 0, 0, 0, 34, 503, 0, 0, 34, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, + 0, 0, 0, 34, 0, 0, 0, 34, 0, 0, + 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 34, 34, 0, 0, 0, 34, 34, 0, + 0, 0, 0, 34, 0, 34, 34, 34, 34, 0, + 0, 0, 0, 34, 113, 0, 0, 34, 113, 34, + 0, 113, 0, 0, 0, 0, 0, 0, 0, 34, + 0, 34, 34, 0, 34, 0, 0, 329, 34, 0, + 0, 0, 33, 582, 0, 113, 33, 0, 0, 0, + 113, 0, 0, 0, 0, 0, 0, 33, 34, 0, + 0, 0, 33, 0, 34, 34, 33, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 34, 34, 0, 113, 0, 34, 34, 0, 0, 0, - 0, 34, 326, 34, 34, 34, 34, 0, 0, 0, - 0, 34, 0, 0, 0, 34, 0, 34, 0, 326, - 0, 0, 0, 113, 0, 0, 0, 34, 0, 34, - 34, 0, 34, 0, 0, 0, 34, 582, 0, 0, - 0, 0, 582, 0, 582, 582, 582, 582, 582, 582, - 582, 582, 582, 582, 582, 0, 34, 0, 0, 0, - 0, 0, 34, 34, 0, 0, 582, 0, 582, 0, - 582, 0, 582, 582, 582, 0, 326, 326, 0, 0, - 0, 0, 0, 0, 0, 326, 0, 0, 582, 777, - 777, 0, 0, 326, 326, 0, 326, 777, 777, 777, - 777, 777, 0, 777, 777, 736, 777, 777, 777, 777, - 777, 777, 777, 0, 0, 0, 326, 0, 777, 326, - 777, 777, 777, 777, 777, 777, 0, 582, 777, 0, - 0, 0, 777, 777, 0, 777, 777, 777, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 777, 0, 777, - 0, 777, 777, 0, 0, 777, 0, 777, 777, 777, - 777, 777, 777, 777, 777, 777, 777, 777, 777, 0, - 777, 0, 0, 777, 777, 0, 0, 777, 777, 0, + 0, 33, 33, 113, 0, 0, 33, 33, 0, 550, + 0, 0, 33, 329, 33, 33, 33, 33, 0, 113, + 0, 0, 33, 0, 0, 0, 33, 0, 33, 0, + 0, 329, 0, 0, 783, 0, 0, 0, 33, 0, + 33, 33, 0, 33, 0, 0, 582, 33, 0, 0, + 0, 582, 0, 582, 582, 582, 582, 582, 582, 582, + 582, 582, 582, 582, 0, 0, 0, 33, 0, 0, + 0, 0, 0, 0, 33, 582, 0, 582, 0, 582, + 0, 582, 582, 582, 0, 0, 0, 329, 329, 0, + 0, 0, 0, 0, 0, 0, 329, 582, 0, 0, + 0, 0, 0, 0, 329, 329, 0, 329, 582, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 777, 777, 777, 777, 777, 0, 0, 0, - 777, 777, 0, 0, 777, 0, 0, 0, 0, 777, - 777, 777, 777, 777, 0, 333, 0, 777, 0, 777, - 333, 333, 0, 0, 0, 777, 777, 0, 0, 0, - 0, 0, 0, 0, 0, 326, 0, 0, 0, 0, - 0, 0, 0, 333, 0, 0, 0, 0, 0, 0, - 777, 777, 777, 777, 0, 777, 333, 333, 0, 0, - 0, 333, 777, 0, 333, 0, 333, 0, 333, 333, - 333, 333, 0, 0, 0, 0, 333, 0, 0, 0, - 333, 0, 0, 0, 333, 0, 0, 0, 0, 0, - 0, 0, 333, 0, 0, 333, 0, 333, 333, 0, - 0, 0, 0, 333, 0, 333, 333, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 0, 0, 0, - 0, 333, 333, 0, 0, 0, 333, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 0, 333, 333, 0, - 0, 333, 333, 333, 333, 333, 0, 0, 333, 333, - 0, 0, 0, 333, 333, 333, 333, 333, 333, 333, - 333, 736, 0, 0, 0, 363, 736, 736, 0, 0, - 0, 0, 333, 0, 0, 333, 0, 333, 0, 333, - 0, 0, 333, 0, 0, 0, 0, 0, 333, 736, + 582, 0, 0, 858, 858, 0, 0, 329, 0, 0, + 329, 858, 858, 858, 858, 858, 582, 858, 858, 0, + 858, 858, 858, 858, 858, 858, 858, 858, 0, 0, + 0, 0, 858, 0, 858, 858, 858, 858, 858, 858, + 335, 0, 858, 0, 0, 0, 858, 858, 0, 858, + 858, 858, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 858, 0, 858, 0, 858, 858, 0, 0, 858, + 0, 858, 858, 858, 858, 858, 858, 858, 858, 858, + 858, 858, 858, 0, 858, 0, 0, 858, 858, 0, + 0, 858, 858, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 858, 858, 858, 858, + 858, 0, 0, 0, 858, 858, 0, 0, 858, 0, + 0, 0, 0, 858, 858, 858, 858, 858, 0, 0, + 0, 858, 0, 858, 0, 0, 0, 0, 0, 858, + 858, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 736, 736, 0, 0, 0, 736, 0, 0, - 736, 0, 736, 0, 736, 736, 736, 736, 0, 0, - 0, 0, 736, 0, 0, 0, 736, 0, 0, 0, - 736, 0, 0, 0, 0, 0, 0, 0, 736, 0, - 0, 736, 0, 736, 736, 0, 0, 0, 0, 736, - 0, 736, 736, 736, 736, 736, 736, 736, 736, 736, - 736, 736, 0, 0, 0, 0, 0, 736, 736, 358, - 0, 0, 736, 736, 736, 736, 736, 736, 0, 736, - 736, 736, 0, 736, 736, 0, 0, 736, 736, 736, - 736, 326, 0, 0, 736, 736, 326, 326, 0, 736, - 736, 736, 736, 736, 736, 736, 736, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 736, 326, - 0, 736, 0, 736, 0, 736, 0, 0, 736, 0, - 0, 0, 326, 326, 736, 0, 0, 326, 0, 0, - 326, 0, 326, 0, 326, 326, 326, 326, 0, 0, - 0, 0, 326, 0, 0, 0, 326, 0, 0, 0, - 326, 0, 0, 0, 0, 0, 0, 0, 326, 0, - 0, 326, 0, 326, 326, 0, 0, 0, 0, 326, - 0, 326, 326, 326, 326, 326, 326, 326, 326, 326, - 326, 326, 0, 0, 0, 0, 0, 326, 326, 0, - 0, 0, 326, 326, 326, 326, 326, 326, 0, 326, - 326, 326, 0, 326, 326, 0, 0, 326, 326, 326, - 326, 363, 0, 0, 326, 326, 363, 363, 0, 326, - 326, 326, 326, 326, 326, 326, 326, 0, 27, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 326, 363, - 0, 326, 0, 326, 0, 326, 0, 0, 326, 0, - 0, 0, 363, 363, 326, 0, 0, 363, 0, 0, - 363, 0, 363, 0, 363, 363, 363, 363, 0, 0, - 0, 0, 363, 0, 0, 0, 363, 0, 0, 0, - 363, 0, 0, 0, 0, 0, 0, 0, 363, 0, - 0, 363, 0, 363, 363, 0, 0, 0, 0, 363, - 0, 363, 363, 363, 363, 363, 363, 363, 363, 363, - 363, 363, 0, 0, 33, 358, 0, 363, 363, 0, - 0, 358, 363, 363, 0, 363, 363, 363, 0, 363, - 363, 363, 0, 363, 363, 0, 0, 363, 363, 363, - 363, 0, 0, 0, 363, 363, 0, 0, 0, 363, - 363, 363, 363, 363, 363, 363, 363, 358, 0, 0, - 0, 32, 0, 0, 0, 0, 0, 0, 363, 0, - 0, 363, 0, 363, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 363, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 358, 0, - 0, 0, 0, 358, 0, 358, 358, 358, 358, 358, - 358, 358, 358, 358, 358, 358, 0, 0, 0, 0, - 0, 0, 358, 0, 27, 0, 358, 358, 0, 358, - 358, 358, 0, 358, 358, 358, 0, 358, 358, 0, - 0, 358, 358, 358, 358, 0, 0, 0, 358, 358, - 0, 0, 0, 358, 358, 358, 358, 358, 358, 358, - 358, 0, 0, 0, 0, 0, 0, 31, 0, 0, - 0, 0, 358, 0, 0, 358, 0, 358, 0, 0, - 0, 0, 0, 0, 27, 27, 0, 0, 358, 27, - 0, 0, 0, 27, 0, 27, 0, 0, 27, 0, - 27, 27, 0, 27, 0, 27, 0, 27, 0, 27, - 27, 27, 27, 0, 0, 27, 27, 0, 0, 0, - 0, 27, 0, 27, 27, 27, 0, 0, 27, 27, - 27, 0, 27, 0, 0, 27, 0, 27, 27, 27, - 27, 5, 0, 0, 27, 27, 27, 0, 0, 27, - 27, 27, 0, 0, 0, 0, 0, 0, 27, 27, - 0, 27, 27, 0, 27, 27, 27, 0, 0, 0, - 27, 33, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 0, 0, 940, 0, 33, 0, 0, 0, - 27, 33, 0, 0, 0, 33, 27, 27, 33, 0, - 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, - 33, 33, 0, 0, 0, 33, 33, 0, 32, 0, - 0, 33, 32, 33, 33, 33, 33, 47, 0, 0, - 0, 33, 0, 32, 0, 33, 0, 33, 32, 0, - 0, 0, 32, 0, 0, 32, 27, 33, 0, 33, - 33, 0, 33, 0, 0, 0, 33, 32, 32, 0, - 0, 0, 32, 32, 0, 0, 0, 0, 32, 0, - 32, 32, 32, 32, 0, 0, 33, 0, 32, 0, - 0, 27, 32, 33, 32, 27, 0, 0, 0, 0, - 7, 0, 0, 0, 32, 0, 27, 32, 0, 32, - 0, 27, 0, 32, 0, 27, 0, 0, 27, 0, + 0, 0, 0, 0, 858, 858, 858, 858, 0, 858, + 783, 783, 0, 0, 0, 0, 858, 0, 783, 783, + 783, 783, 783, 0, 783, 783, 740, 783, 783, 783, + 783, 783, 783, 783, 0, 0, 0, 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, - 27, 27, 0, 32, 31, 27, 27, 0, 31, 32, - 32, 27, 0, 27, 27, 27, 27, 941, 0, 31, - 0, 27, 0, 0, 31, 27, 0, 27, 31, 0, - 0, 31, 0, 0, 0, 0, 0, 27, 0, 0, - 27, 0, 27, 31, 31, 0, 27, 0, 31, 31, - 0, 0, 0, 0, 31, 0, 31, 31, 31, 31, - 0, 0, 0, 0, 31, 0, 27, 0, 31, 0, - 31, 0, 27, 27, 0, 0, 0, 0, 5, 0, - 31, 0, 47, 31, 48, 31, 0, 0, 0, 31, - 0, 0, 0, 47, 0, 0, 0, 0, 47, 0, - 0, 0, 47, 0, 0, 47, 0, 0, 0, 31, - 0, 0, 0, 0, 0, 0, 31, 47, 47, 0, - 0, 940, 47, 47, 0, 47, 0, 0, 47, 0, - 47, 47, 47, 47, 0, 0, 47, 0, 47, 0, - 0, 47, 47, 0, 47, 47, 0, 0, 47, 0, + 0, 0, 0, 783, 783, 783, 783, 783, 0, 0, + 0, 783, 783, 0, 0, 783, 0, 0, 0, 0, + 783, 783, 783, 783, 783, 0, 335, 0, 783, 0, + 783, 335, 335, 0, 0, 0, 783, 783, 0, 0, + 0, 0, 0, 0, 0, 0, 328, 0, 0, 0, + 0, 0, 0, 0, 335, 0, 0, 0, 0, 0, + 0, 783, 783, 783, 783, 0, 783, 335, 335, 0, + 0, 0, 335, 783, 0, 335, 0, 335, 0, 335, + 335, 335, 335, 0, 0, 0, 0, 335, 0, 0, + 0, 335, 0, 0, 0, 335, 0, 0, 0, 0, + 0, 0, 0, 335, 0, 0, 335, 0, 335, 335, + 0, 0, 0, 0, 335, 0, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 0, 0, + 0, 0, 335, 335, 0, 0, 0, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 0, 335, 335, + 0, 0, 335, 335, 335, 335, 335, 0, 0, 335, + 335, 0, 0, 0, 335, 335, 335, 335, 335, 335, + 335, 335, 740, 0, 0, 0, 365, 740, 740, 0, + 0, 0, 0, 335, 0, 0, 335, 0, 335, 0, + 335, 0, 0, 335, 0, 0, 0, 0, 0, 335, + 740, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 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, 740, + 335, 0, 0, 740, 740, 740, 740, 740, 740, 0, + 740, 740, 740, 0, 740, 740, 0, 0, 740, 740, + 740, 740, 328, 0, 0, 740, 740, 328, 328, 0, + 740, 740, 740, 740, 740, 740, 740, 740, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 740, + 328, 0, 740, 0, 740, 0, 740, 0, 0, 740, + 0, 0, 0, 328, 328, 740, 0, 0, 328, 0, + 0, 328, 0, 328, 0, 328, 328, 328, 328, 0, + 0, 0, 0, 328, 0, 0, 0, 328, 0, 0, + 0, 328, 0, 0, 0, 0, 0, 0, 0, 328, + 0, 0, 328, 0, 328, 328, 0, 0, 0, 0, + 328, 0, 328, 328, 328, 328, 328, 328, 328, 328, + 328, 328, 328, 0, 0, 0, 0, 0, 328, 328, + 0, 0, 0, 328, 328, 328, 328, 328, 328, 0, + 328, 328, 328, 0, 328, 328, 360, 0, 328, 328, + 328, 328, 365, 0, 0, 328, 328, 365, 365, 0, + 328, 328, 328, 328, 328, 328, 328, 328, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 328, + 365, 0, 328, 0, 328, 0, 328, 0, 0, 328, + 0, 0, 0, 365, 365, 328, 0, 0, 365, 0, + 0, 365, 0, 365, 0, 365, 365, 365, 365, 0, + 0, 0, 0, 365, 0, 0, 0, 365, 0, 0, + 0, 365, 0, 0, 0, 0, 0, 0, 0, 365, + 0, 0, 365, 0, 365, 365, 0, 0, 0, 0, + 365, 0, 365, 365, 365, 365, 365, 365, 365, 365, + 365, 365, 365, 0, 0, 0, 335, 0, 365, 365, + 0, 0, 335, 365, 365, 0, 365, 365, 365, 0, + 365, 365, 365, 0, 365, 365, 32, 0, 365, 365, + 365, 365, 0, 0, 0, 365, 365, 0, 0, 0, + 365, 365, 365, 365, 365, 365, 365, 365, 335, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 365, + 0, 0, 365, 0, 365, 0, 0, 0, 0, 27, + 0, 0, 0, 0, 0, 365, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 335, + 0, 0, 585, 0, 335, 0, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 0, 0, + 0, 0, 31, 335, 0, 0, 0, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 0, 335, 335, + 0, 0, 335, 335, 335, 335, 335, 0, 0, 335, + 335, 0, 0, 0, 335, 335, 335, 335, 335, 335, + 335, 335, 360, 0, 0, 5, 0, 0, 360, 0, + 0, 0, 0, 335, 0, 0, 335, 0, 335, 0, + 335, 0, 0, 335, 0, 585, 0, 0, 0, 335, + 585, 0, 585, 585, 585, 585, 585, 585, 585, 585, + 585, 585, 585, 0, 360, 0, 0, 0, 953, 0, + 0, 0, 0, 0, 585, 0, 585, 0, 585, 0, + 585, 585, 585, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 360, 0, 0, 0, 0, + 360, 47, 360, 360, 360, 360, 360, 360, 360, 360, + 360, 360, 360, 0, 0, 0, 0, 0, 0, 360, + 0, 0, 0, 360, 360, 585, 360, 360, 360, 0, + 360, 360, 360, 0, 360, 360, 0, 0, 360, 360, + 360, 360, 0, 32, 7, 360, 360, 32, 0, 0, + 360, 360, 360, 360, 360, 360, 360, 360, 32, 0, + 0, 0, 0, 32, 0, 0, 0, 32, 0, 360, + 32, 0, 360, 0, 360, 0, 0, 0, 0, 0, + 0, 0, 32, 32, 0, 360, 27, 32, 32, 0, + 27, 0, 0, 32, 0, 32, 32, 32, 32, 0, + 0, 27, 0, 32, 0, 0, 27, 32, 0, 32, + 27, 954, 0, 27, 0, 0, 0, 0, 0, 32, + 0, 0, 32, 0, 32, 27, 27, 0, 32, 31, + 27, 27, 0, 31, 0, 0, 27, 0, 27, 27, + 27, 27, 0, 0, 31, 0, 27, 0, 32, 31, + 27, 0, 27, 31, 32, 32, 31, 0, 48, 0, + 0, 0, 27, 0, 0, 27, 0, 27, 31, 31, + 0, 27, 5, 31, 31, 0, 47, 0, 0, 31, + 0, 31, 31, 31, 31, 0, 0, 47, 0, 31, + 0, 27, 47, 31, 0, 31, 47, 27, 27, 47, + 0, 0, 0, 0, 0, 31, 0, 0, 31, 0, + 31, 47, 47, 0, 31, 953, 47, 47, 0, 47, + 0, 0, 47, 0, 47, 47, 47, 47, 0, 0, + 47, 0, 47, 0, 31, 47, 47, 0, 47, 47, + 0, 31, 47, 0, 0, 0, 0, 0, 47, 0, + 0, 47, 0, 47, 47, 47, 0, 47, 47, 47, + 47, 0, 47, 0, 0, 47, 0, 47, 47, 47, + 47, 0, 0, 47, 0, 47, 0, 47, 47, 47, + 0, 47, 47, 0, 0, 47, 0, 0, 0, 0, + 0, 47, 0, 0, 47, 0, 47, 47, 47, 0, + 47, 7, 47, 47, 0, 48, 0, 0, 47, 0, + 47, 47, 47, 47, 0, 0, 48, 0, 47, 0, + 47, 48, 47, 0, 47, 48, 0, 0, 48, 0, 0, 0, 0, 0, 47, 0, 0, 47, 0, 47, - 47, 47, 0, 47, 47, 47, 47, 0, 47, 0, - 0, 47, 0, 47, 47, 47, 47, 0, 0, 47, - 0, 47, 0, 47, 47, 47, 0, 47, 47, 0, - 0, 47, 0, 0, 0, 0, 0, 47, 0, 0, - 47, 0, 47, 47, 47, 0, 47, 0, 47, 47, - 0, 0, 0, 0, 47, 0, 47, 47, 47, 47, - 0, 0, 0, 0, 47, 0, 47, 7, 47, 0, - 47, 48, 0, 0, 0, 0, 0, 0, 0, 0, - 47, 0, 48, 47, 0, 47, 0, 48, 0, 47, - 0, 48, 0, 0, 48, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 48, 48, 0, 47, - 0, 48, 48, 0, 941, 0, 0, 48, 47, 48, - 48, 48, 48, 0, 0, 0, 0, 48, 0, 47, - 0, 48, 0, 48, 47, 0, 0, 0, 47, 0, - 0, 47, 0, 48, 0, 0, 48, 0, 48, 0, - 0, 0, 48, 47, 47, 0, 0, 0, 47, 47, - 0, 0, 0, 0, 47, 0, 47, 47, 47, 47, - 0, 0, 48, 0, 47, 0, 0, 0, 47, 0, - 47, 48, 0, 0, 0, 48, 0, 0, 0, 0, - 47, 0, 0, 47, 0, 47, 48, 0, 0, 47, - 0, 48, 0, 0, 0, 48, 0, 0, 48, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, - 48, 48, 0, 0, 0, 48, 48, 0, 0, 0, + 48, 48, 0, 47, 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, 55, - 48, 0, 48, 0, 0, 0, 48, 56, 24, 57, - 25, 0, 0, 26, 58, 0, 59, 60, 27, 61, - 62, 63, 28, 0, 0, 0, 48, 0, 64, 0, - 65, 30, 66, 67, 68, 69, 0, 0, 32, 0, - 0, 0, 70, 33, 0, 71, 72, 34, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 73, 0, 36, - 0, 37, 74, 0, 0, 38, 0, 75, 76, 77, - 78, 79, 80, 39, 40, 81, 82, 41, 83, 0, - 84, 0, 0, 85, 86, 0, 333, 87, 88, 0, - 0, 0, 333, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 89, 90, 91, 92, 93, 0, 0, 0, - 94, 0, 0, 0, 95, 0, 0, 0, 0, 96, - 97, 98, 99, 100, 0, 0, 0, 101, 333, 102, - 0, 0, 0, 0, 0, 103, 104, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 333, 0, 0, 0, 0, 0, 333, 0, - 105, 106, 107, 108, 0, 0, 0, 0, 0, 333, - 0, 0, 196, 0, 333, 0, 333, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 0, 0, - 0, 0, 0, 333, 333, 0, 0, 0, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 0, 333, 333, - 0, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 0, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 333, 0, 504, 0, 0, 333, 0, - 333, 504, 0, 333, 0, 0, 0, 0, 0, 333, - 0, 0, 0, 0, 333, 0, 0, 333, 0, 333, - 333, 0, 0, 0, 333, 333, 0, 0, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 504, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 333, 333, - 0, 0, 0, 0, 0, 0, 333, 0, 0, 333, - 0, 0, 0, 0, 0, 333, 0, 201, 504, 0, - 0, 0, 0, 504, 0, 504, 504, 504, 504, 504, - 504, 504, 504, 504, 504, 504, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 504, 504, 504, 504, - 504, 504, 504, 504, 504, 504, 584, 504, 504, 202, - 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - 0, 504, 504, 504, 504, 504, 504, 504, 504, 504, - 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, - 504, 504, 504, 0, 500, 0, 0, 0, 0, 504, - 500, 0, 0, 0, 0, 0, 0, 0, 504, 203, - 204, 205, 206, 0, 207, 208, 209, 210, 211, 212, - 213, 214, 0, 0, 215, 216, 217, 218, 219, 220, - 221, 222, 0, 0, 0, 0, 500, 0, 0, 584, - 0, 0, 0, 0, 584, 0, 584, 584, 584, 584, - 584, 584, 584, 584, 584, 584, 584, 0, 0, 0, - 0, 0, 0, 0, 0, 390, 0, 0, 584, 0, - 584, 390, 584, 0, 584, 584, 584, 500, 0, 0, - 0, 0, 500, 0, 500, 500, 500, 500, 500, 500, - 500, 500, 500, 500, 500, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 500, 500, 390, 500, 500, - 500, 500, 500, 500, 500, 0, 500, 500, 0, 500, - 500, 500, 500, 500, 500, 500, 500, 500, 500, 584, - 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, - 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, - 500, 500, 0, 508, 0, 0, 0, 0, 500, 508, - 0, 500, 0, 0, 0, 0, 0, 500, 0, 0, - 0, 0, 326, 0, 0, 0, 0, 390, 326, 0, - 390, 390, 390, 390, 0, 390, 0, 390, 390, 0, - 390, 390, 390, 390, 390, 508, 390, 390, 390, 390, - 0, 390, 390, 390, 390, 390, 390, 390, 390, 390, - 390, 390, 390, 390, 390, 390, 390, 390, 390, 390, - 390, 390, 390, 0, 0, 0, 0, 326, 0, 390, - 0, 0, 390, 0, 0, 0, 508, 0, 390, 0, - 0, 508, 0, 508, 508, 508, 508, 508, 508, 508, - 508, 508, 508, 508, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 508, 0, 508, 508, 508, - 508, 508, 508, 508, 932, 508, 508, 0, 508, 508, - 508, 508, 508, 508, 508, 508, 508, 508, 0, 508, - 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, - 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, - 508, 0, 333, 0, 0, 0, 0, 508, 333, 0, - 508, 0, 0, 0, 0, 0, 508, 0, 0, 0, + 0, 48, 0, 47, 0, 48, 0, 48, 954, 0, + 0, 0, 47, 0, 0, 0, 0, 48, 0, 0, + 48, 0, 48, 47, 0, 0, 48, 0, 47, 0, + 0, 0, 47, 0, 0, 47, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 48, 47, 47, 0, + 0, 0, 47, 47, 0, 48, 0, 0, 47, 48, + 47, 47, 47, 47, 0, 0, 0, 0, 47, 0, + 48, 0, 47, 0, 47, 48, 0, 0, 0, 48, + 0, 0, 48, 0, 47, 0, 0, 47, 0, 47, + 0, 0, 0, 47, 48, 48, 0, 0, 0, 48, + 48, 0, 0, 0, 0, 48, 0, 48, 48, 48, + 48, 0, 0, 47, 0, 48, 0, 0, 0, 48, + 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 48, 0, 55, 48, 0, 48, 0, 0, 0, + 48, 56, 24, 57, 25, 0, 0, 26, 58, 0, + 59, 60, 27, 61, 62, 63, 28, 0, 0, 0, + 48, 0, 64, 0, 65, 30, 66, 67, 68, 69, + 0, 0, 32, 0, 0, 0, 70, 33, 0, 71, + 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 73, 0, 36, 0, 37, 74, 0, 0, 38, + 0, 75, 76, 77, 78, 79, 80, 39, 40, 81, + 82, 41, 83, 0, 84, 0, 0, 85, 86, 0, + 335, 87, 88, 0, 0, 0, 335, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 89, 90, 91, 92, + 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, + 0, 0, 0, 96, 97, 98, 99, 100, 0, 0, + 0, 101, 335, 102, 0, 0, 0, 0, 0, 103, + 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 335, 0, 0, 0, + 0, 0, 335, 0, 105, 106, 107, 108, 0, 0, + 0, 0, 0, 335, 0, 0, 196, 0, 335, 0, + 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 335, 0, 0, 0, 0, 0, 335, 335, 0, + 0, 0, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 0, 335, 335, 0, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 0, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 0, 505, + 0, 0, 335, 0, 335, 505, 0, 335, 0, 0, + 0, 0, 0, 335, 0, 0, 0, 0, 335, 0, + 0, 335, 0, 335, 335, 0, 0, 0, 335, 335, + 0, 0, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 505, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 335, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 335, 335, 0, 0, 0, 0, 0, 0, + 335, 0, 0, 335, 0, 0, 0, 0, 0, 335, + 0, 201, 505, 0, 0, 0, 0, 505, 0, 505, + 505, 505, 505, 505, 505, 505, 505, 505, 505, 505, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 505, 505, 505, 505, 505, 505, 505, 505, 505, 505, + 945, 505, 505, 202, 505, 505, 505, 505, 505, 505, + 505, 505, 505, 505, 0, 505, 505, 505, 505, 505, + 505, 505, 505, 505, 505, 505, 505, 505, 505, 505, + 505, 505, 505, 505, 505, 505, 505, 0, 501, 0, + 0, 0, 0, 505, 501, 0, 0, 0, 0, 0, + 0, 0, 505, 203, 204, 205, 206, 0, 207, 208, + 209, 210, 211, 212, 213, 214, 0, 0, 215, 216, + 217, 218, 219, 220, 221, 222, 0, 0, 0, 0, + 501, 0, 0, 945, 0, 0, 0, 0, 945, 0, + 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 391, + 0, 0, 945, 0, 945, 391, 945, 0, 945, 945, + 945, 501, 0, 0, 0, 0, 501, 0, 501, 501, + 501, 501, 501, 501, 501, 501, 501, 501, 501, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 501, + 501, 391, 501, 501, 501, 501, 501, 501, 501, 0, + 501, 501, 0, 501, 501, 501, 501, 501, 501, 501, + 501, 501, 501, 945, 501, 501, 501, 501, 501, 501, + 501, 501, 501, 501, 501, 501, 501, 501, 501, 501, + 501, 501, 501, 501, 501, 501, 0, 509, 0, 0, + 0, 0, 501, 509, 0, 501, 0, 0, 0, 0, + 0, 501, 0, 0, 0, 0, 328, 0, 0, 0, + 0, 391, 328, 0, 391, 391, 391, 391, 0, 391, + 0, 391, 391, 0, 391, 391, 391, 391, 391, 509, + 391, 391, 391, 391, 0, 391, 391, 391, 391, 391, + 391, 391, 391, 391, 391, 391, 391, 391, 391, 391, + 391, 391, 391, 391, 391, 391, 391, 0, 0, 0, + 0, 328, 0, 391, 0, 0, 391, 0, 0, 0, + 509, 0, 391, 0, 0, 509, 0, 509, 509, 509, + 509, 509, 509, 509, 509, 509, 509, 509, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 509, + 0, 509, 509, 509, 509, 509, 509, 509, 0, 509, + 509, 0, 509, 509, 509, 509, 509, 509, 509, 509, + 509, 509, 0, 509, 509, 509, 509, 509, 509, 509, + 509, 509, 509, 509, 509, 509, 509, 509, 509, 509, + 509, 509, 509, 509, 509, 0, 335, 756, 0, 0, + 0, 509, 335, 0, 509, 0, 24, 0, 25, 0, + 509, 26, 0, 0, 0, 0, 27, 0, 0, 0, + 28, 0, 0, 0, 0, 0, 0, 0, 0, 30, + 0, 0, 0, 0, 0, 0, 32, 0, 335, 0, + 0, 33, 0, 0, 0, 34, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, + 0, 0, 0, 38, 0, 0, 0, 0, 0, 0, + 0, 39, 40, 0, 0, 41, 0, 0, 757, 335, + 0, 0, 0, 0, 335, 0, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 0, 0, 0, + 0, 0, 0, 0, 291, 0, 0, 0, 335, 0, + 335, 335, 335, 335, 335, 335, 335, 0, 335, 335, + 0, 335, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 0, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 0, 434, 567, 0, 0, 323, + 335, 434, 0, 335, 0, 24, 0, 25, 0, 335, + 26, 0, 0, 0, 0, 27, 0, 0, 0, 28, + 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, + 0, 0, 0, 0, 0, 32, 0, 434, 0, 0, + 33, 0, 0, 0, 34, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 36, 0, 37, 0, + 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, + 39, 40, 0, 0, 41, 0, 0, 322, 434, 0, + 0, 0, 0, 434, 0, 434, 434, 434, 434, 434, + 434, 434, 434, 434, 434, 434, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 434, 0, 434, + 434, 434, 434, 434, 434, 434, 0, 434, 434, 0, + 434, 434, 434, 434, 434, 434, 434, 434, 434, 434, + 0, 434, 434, 434, 434, 434, 434, 434, 434, 434, + 434, 434, 434, 434, 434, 434, 434, 434, 434, 434, + 434, 434, 434, 0, 394, 0, 453, 0, 355, 434, + 394, 0, 434, 0, 0, 0, 0, 0, 434, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 333, 0, 0, 932, 0, 0, - 0, 0, 932, 0, 932, 932, 932, 932, 932, 932, - 932, 932, 932, 932, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 932, 0, 932, 0, - 932, 0, 932, 932, 932, 333, 0, 0, 0, 0, - 333, 0, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 333, 0, 333, 333, 333, 333, - 333, 333, 333, 0, 333, 333, 0, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 932, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 0, 433, 562, 0, 0, 0, 333, 433, 0, 333, - 0, 24, 0, 25, 0, 333, 26, 0, 0, 0, - 0, 27, 0, 0, 0, 28, 0, 0, 0, 0, - 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, - 0, 32, 0, 433, 0, 0, 33, 0, 0, 0, - 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 36, 0, 37, 0, 0, 0, 38, 0, - 0, 0, 0, 0, 0, 0, 39, 40, 0, 0, - 41, 0, 0, 319, 433, 0, 0, 0, 0, 433, - 0, 433, 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 433, 0, 433, 433, 433, 433, 433, - 433, 433, 0, 433, 433, 0, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 0, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, 433, 433, - 433, 433, 433, 433, 433, 433, 433, 433, 433, 0, - 393, 0, 355, 0, 352, 433, 393, 0, 433, 0, - 0, 0, 0, 0, 433, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 355, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 355, 0, - 0, 0, 393, 355, 0, 0, 230, 0, 355, 0, - 355, 355, 355, 355, 0, 0, 0, 0, 355, 0, - 0, 0, 355, 0, 0, 333, 355, 0, 0, 0, - 0, 333, 0, 0, 355, 739, 0, 355, 0, 355, - 0, 0, 0, 393, 0, 0, 0, 0, 393, 0, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 0, 0, 355, 0, 0, 0, 333, 0, 0, - 0, 0, 393, 0, 393, 393, 393, 393, 393, 393, - 393, 0, 393, 739, 0, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 0, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 0, 355, - 0, 0, 0, 0, 393, 0, 333, 393, 0, 0, - 0, 0, 333, 393, 0, 0, 0, 333, 333, 333, - 333, 333, 333, 333, 739, 333, 0, 333, 333, 0, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 0, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 0, 539, 0, 496, 333, 0, 333, - 539, 0, 333, 0, 56, 24, 0, 25, 333, 0, - 26, 253, 0, 0, 0, 27, 61, 62, 0, 28, - 0, 0, 0, 0, 0, 64, 0, 0, 30, 0, - 0, 0, 0, 0, 0, 32, 539, 0, 0, 0, - 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 36, 0, 37, 74, - 0, 0, 38, 0, 0, 76, 0, 78, 0, 80, - 39, 40, 254, 0, 41, 0, 0, 539, 0, 0, - 0, 0, 539, 0, 539, 539, 539, 539, 539, 539, - 539, 539, 539, 539, 539, 0, 0, 0, 0, 89, - 90, 91, 255, 0, 0, 0, 539, 0, 539, 0, - 539, 95, 539, 539, 539, 0, 539, 539, 0, 539, - 539, 539, 539, 539, 539, 539, 539, 539, 539, 354, - 0, 0, 539, 539, 539, 539, 539, 539, 539, 539, - 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, - 551, 539, 354, 0, 0, 0, 551, 105, 497, 0, - 0, 0, 0, 0, 0, 354, 0, 539, 0, 0, - 354, 0, 0, 229, 0, 354, 0, 354, 354, 354, - 354, 0, 0, 0, 0, 354, 0, 0, 0, 354, - 0, 0, 551, 354, 0, 0, 0, 0, 0, 0, - 0, 354, 0, 0, 354, 0, 354, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 555, 0, - 0, 0, 0, 0, 555, 0, 0, 0, 0, 0, - 354, 0, 0, 551, 0, 0, 0, 0, 551, 0, - 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, - 551, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 555, 0, 551, 0, 551, 0, 551, 0, 551, 551, - 551, 0, 551, 551, 0, 0, 551, 551, 551, 551, - 551, 551, 551, 551, 551, 0, 354, 0, 551, 551, - 551, 551, 551, 551, 551, 551, 0, 0, 0, 0, - 0, 555, 0, 0, 0, 0, 555, 551, 555, 555, - 555, 555, 555, 555, 555, 555, 555, 555, 555, 0, - 0, 0, 558, 551, 0, 0, 0, 0, 558, 0, - 555, 0, 555, 0, 555, 0, 555, 555, 555, 0, - 555, 555, 0, 0, 555, 555, 555, 555, 0, 0, - 0, 555, 555, 0, 0, 0, 555, 555, 555, 555, - 555, 555, 555, 555, 558, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 555, 0, 0, 0, 0, + 0, 0, 455, 0, 0, 0, 394, 457, 0, 0, + 0, 0, 458, 0, 459, 460, 461, 462, 0, 0, + 0, 0, 463, 0, 0, 0, 464, 0, 0, 335, + 1320, 0, 0, 0, 0, 335, 0, 0, 465, 743, + 0, 466, 0, 467, 0, 0, 0, 394, 0, 0, + 0, 0, 394, 0, 394, 394, 394, 394, 394, 394, + 394, 394, 394, 394, 394, 0, 0, 468, 0, 0, + 0, 335, 0, 0, 0, 0, 394, 0, 394, 394, + 394, 394, 394, 394, 394, 0, 394, 743, 0, 394, + 394, 394, 394, 394, 394, 394, 394, 394, 394, 0, + 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, + 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, + 394, 394, 0, 1321, 0, 0, 0, 0, 394, 0, + 335, 394, 0, 0, 0, 0, 335, 394, 0, 0, + 0, 335, 335, 335, 335, 335, 335, 335, 743, 335, + 0, 335, 335, 0, 335, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 0, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 0, 540, 0, + 501, 335, 0, 335, 540, 0, 335, 0, 56, 24, + 0, 25, 335, 0, 26, 253, 0, 0, 0, 27, + 61, 62, 0, 28, 0, 0, 0, 0, 0, 64, + 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, + 540, 0, 0, 0, 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 556, 555, 0, 0, 0, 0, 556, 0, 0, 0, - 0, 0, 0, 0, 0, 558, 0, 0, 0, 0, - 558, 0, 558, 558, 558, 558, 558, 558, 558, 558, - 558, 558, 558, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 556, 0, 558, 0, 558, 0, 558, 0, - 558, 558, 558, 0, 558, 558, 0, 0, 558, 558, - 558, 558, 0, 0, 0, 558, 558, 0, 0, 0, - 558, 558, 558, 558, 558, 558, 558, 558, 0, 0, - 0, 0, 0, 556, 0, 0, 0, 0, 556, 558, - 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, - 556, 0, 0, 0, 557, 558, 0, 0, 0, 0, - 557, 0, 556, 0, 556, 0, 556, 0, 556, 556, - 556, 0, 556, 556, 0, 0, 556, 556, 556, 556, - 0, 0, 0, 556, 556, 0, 0, 0, 556, 556, - 556, 556, 556, 556, 556, 556, 557, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 556, 0, 0, + 36, 0, 37, 74, 0, 0, 38, 0, 0, 76, + 0, 78, 0, 80, 39, 40, 254, 0, 41, 0, + 0, 540, 0, 0, 0, 0, 540, 0, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 0, + 0, 0, 0, 89, 90, 91, 255, 0, 0, 0, + 540, 0, 540, 0, 540, 95, 540, 540, 540, 0, + 540, 540, 0, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 453, 0, 0, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 552, 540, 454, 0, 0, 0, + 552, 105, 502, 0, 0, 0, 0, 0, 0, 455, + 0, 540, 0, 0, 457, 0, 0, 0, 0, 458, + 0, 459, 460, 461, 462, 0, 0, 0, 0, 463, + 0, 0, 0, 464, 0, 0, 552, 0, 0, 0, + 0, 0, 0, 0, 0, 465, 0, 0, 466, 0, + 467, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 556, 0, 0, 0, 0, 0, 556, 0, + 0, 0, 0, 0, 468, 0, 0, 552, 0, 0, + 0, 0, 552, 0, 552, 552, 552, 552, 552, 552, + 552, 552, 552, 552, 552, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 556, 0, 552, 0, 552, 0, + 552, 0, 552, 552, 552, 0, 552, 552, 0, 0, + 552, 552, 552, 552, 552, 552, 552, 552, 552, 0, + 1335, 0, 552, 552, 552, 552, 552, 552, 552, 552, + 0, 0, 0, 0, 0, 556, 0, 0, 0, 0, + 556, 552, 556, 556, 556, 556, 556, 556, 556, 556, + 556, 556, 556, 0, 0, 0, 559, 552, 0, 0, + 0, 0, 559, 0, 556, 0, 556, 0, 556, 0, + 556, 556, 556, 0, 556, 556, 0, 0, 556, 556, + 556, 556, 0, 0, 0, 556, 556, 0, 0, 0, + 556, 556, 556, 556, 556, 556, 556, 556, 559, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 556, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 561, 556, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 557, 0, 557, 557, 557, 557, 557, 557, - 557, 557, 557, 557, 557, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 557, 0, 557, 0, + 0, 0, 0, 0, 557, 556, 0, 0, 0, 0, + 557, 0, 0, 0, 0, 0, 0, 0, 0, 559, + 0, 0, 0, 0, 559, 0, 559, 559, 559, 559, + 559, 559, 559, 559, 559, 559, 559, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 557, 0, 559, 0, + 559, 0, 559, 0, 559, 559, 559, 0, 559, 559, + 0, 0, 559, 559, 559, 559, 0, 0, 0, 559, + 559, 0, 0, 0, 559, 559, 559, 559, 559, 559, + 559, 559, 0, 0, 0, 0, 0, 557, 0, 0, + 0, 0, 557, 559, 557, 557, 557, 557, 557, 557, + 557, 557, 557, 557, 557, 0, 0, 0, 558, 559, + 0, 0, 0, 0, 558, 0, 557, 0, 557, 0, 557, 0, 557, 557, 557, 0, 557, 557, 0, 0, 557, 557, 557, 557, 0, 0, 0, 557, 557, 0, - 562, 0, 557, 557, 557, 557, 557, 557, 557, 557, - 0, 0, 0, 0, 0, 561, 0, 0, 0, 0, - 561, 557, 561, 561, 561, 561, 561, 561, 561, 561, - 561, 561, 561, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 0, 0, 561, 0, 561, 0, 561, 0, - 561, 561, 561, 0, 0, 0, 0, 0, 561, 561, - 561, 561, 0, 0, 0, 561, 561, 0, 563, 0, - 561, 561, 561, 561, 561, 561, 561, 561, 0, 0, - 0, 0, 0, 562, 0, 0, 0, 0, 562, 561, - 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, - 562, 0, 0, 0, 0, 561, 0, 0, 0, 0, - 0, 0, 562, 0, 562, 0, 562, 0, 562, 562, - 562, 0, 0, 0, 0, 0, 562, 562, 562, 562, - 0, 0, 0, 562, 562, 0, 564, 0, 562, 562, - 562, 562, 562, 562, 562, 562, 0, 0, 0, 0, - 0, 563, 0, 0, 0, 0, 563, 562, 563, 563, - 563, 563, 563, 563, 563, 563, 563, 563, 563, 0, - 0, 0, 0, 562, 0, 0, 0, 0, 0, 0, - 563, 0, 563, 0, 563, 0, 563, 563, 563, 0, - 0, 0, 0, 0, 563, 563, 563, 563, 0, 0, - 0, 563, 563, 0, 565, 0, 563, 563, 563, 563, - 563, 563, 563, 563, 0, 0, 0, 0, 0, 564, - 0, 0, 0, 0, 564, 563, 564, 564, 564, 564, - 564, 564, 564, 564, 564, 564, 564, 0, 0, 0, - 0, 563, 0, 0, 0, 0, 0, 0, 564, 0, - 564, 0, 564, 0, 564, 564, 564, 0, 0, 0, - 0, 0, 564, 564, 564, 564, 0, 0, 0, 564, - 564, 0, 566, 0, 0, 0, 564, 564, 564, 564, - 564, 564, 0, 0, 0, 0, 0, 565, 0, 0, - 0, 0, 565, 564, 565, 565, 565, 565, 565, 565, - 565, 565, 565, 565, 565, 0, 0, 0, 0, 564, - 0, 0, 0, 0, 0, 0, 565, 0, 565, 0, - 565, 0, 565, 565, 565, 0, 0, 0, 0, 0, - 565, 565, 565, 565, 0, 0, 0, 565, 565, 0, - 567, 0, 0, 0, 565, 565, 565, 565, 565, 565, - 0, 0, 0, 0, 0, 566, 0, 0, 0, 0, - 566, 565, 566, 566, 566, 566, 566, 566, 566, 566, - 566, 566, 566, 0, 0, 0, 0, 565, 0, 0, - 0, 0, 0, 0, 566, 0, 566, 0, 566, 0, - 566, 566, 566, 0, 0, 0, 0, 0, 566, 566, - 566, 566, 0, 0, 0, 566, 566, 0, 568, 0, - 0, 0, 566, 566, 566, 566, 566, 566, 0, 0, - 0, 0, 0, 567, 0, 0, 0, 0, 567, 566, - 567, 567, 567, 567, 567, 567, 567, 567, 567, 567, - 567, 0, 0, 0, 0, 566, 0, 0, 0, 0, - 0, 0, 567, 0, 567, 0, 567, 0, 567, 567, - 567, 0, 0, 0, 0, 0, 567, 567, 567, 567, - 0, 0, 0, 567, 567, 0, 570, 0, 0, 0, - 567, 567, 567, 567, 567, 567, 0, 0, 0, 0, - 0, 568, 0, 0, 0, 0, 568, 567, 568, 568, - 568, 568, 568, 568, 568, 568, 568, 568, 568, 0, - 0, 0, 0, 567, 0, 0, 0, 0, 0, 0, - 568, 0, 568, 0, 568, 0, 568, 568, 568, 0, - 0, 0, 0, 0, 568, 568, 568, 568, 0, 0, - 0, 568, 568, 0, 571, 0, 0, 0, 568, 568, - 568, 568, 568, 568, 0, 0, 0, 0, 0, 570, - 0, 0, 0, 0, 570, 568, 570, 570, 570, 570, - 570, 570, 570, 570, 570, 570, 570, 0, 0, 0, - 0, 568, 0, 0, 0, 0, 0, 0, 570, 0, - 570, 0, 570, 0, 570, 570, 570, 0, 0, 0, - 0, 0, 0, 0, 570, 570, 0, 0, 0, 570, - 570, 0, 572, 0, 0, 0, 0, 0, 570, 570, - 570, 570, 0, 0, 0, 0, 0, 571, 0, 0, - 0, 0, 571, 570, 571, 571, 571, 571, 571, 571, - 571, 571, 571, 571, 571, 0, 0, 0, 0, 570, - 0, 0, 0, 0, 0, 0, 571, 0, 571, 0, - 571, 0, 571, 571, 571, 0, 0, 0, 0, 0, - 0, 0, 571, 571, 0, 0, 0, 571, 571, 0, - 573, 0, 0, 0, 0, 0, 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, 0, 0, - 572, 572, 0, 0, 0, 572, 572, 0, 574, 0, - 0, 0, 0, 0, 0, 0, 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, 0, 0, 573, 573, - 0, 0, 0, 573, 573, 0, 575, 0, 0, 0, - 0, 0, 0, 0, 573, 573, 0, 0, 0, 0, - 0, 574, 0, 0, 0, 0, 574, 573, 574, 574, - 574, 574, 574, 574, 574, 574, 574, 574, 574, 0, - 0, 0, 0, 573, 0, 0, 0, 0, 0, 0, - 574, 0, 574, 0, 574, 0, 574, 574, 574, 0, - 0, 0, 0, 0, 0, 0, 0, 574, 0, 0, - 0, 574, 574, 0, 576, 0, 0, 0, 0, 0, - 0, 0, 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, 0, 0, 0, 575, 0, 0, 0, 575, - 575, 0, 577, 0, 0, 0, 0, 0, 0, 0, - 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, - 0, 0, 0, 576, 0, 0, 0, 0, 576, 0, - 578, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, - 0, 577, 0, 0, 0, 0, 577, 0, 579, 0, - 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, - 0, 0, 0, 0, 578, 0, 580, 0, 0, 0, - 0, 0, 0, 0, 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, 581, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 579, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 579, 579, 0, 0, 0, 0, 0, 580, - 0, 0, 0, 0, 580, 579, 580, 580, 580, 580, - 580, 580, 580, 580, 580, 580, 580, 0, 0, 0, - 0, 579, 0, 0, 0, 0, 0, 0, 580, 0, - 580, 0, 580, 0, 580, 580, 580, 0, 0, 0, - 0, 333, 0, 0, 0, 739, 0, 0, 0, 0, - 580, 0, 0, 0, 0, 581, 0, 0, 0, 0, - 581, 580, 581, 581, 581, 581, 581, 581, 581, 581, - 581, 581, 581, 580, 0, 0, 0, 333, 0, 0, - 0, 0, 0, 0, 581, 0, 581, 0, 581, 580, - 581, 581, 581, 739, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 581, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 581, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 581, - 0, 0, 0, 0, 0, 0, 333, 0, 0, 0, - 0, 0, 333, 0, 0, 581, 0, 333, 333, 0, - 333, 0, 333, 0, 739, 333, 0, 333, 333, 0, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 0, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 0, 0, 55, 0, 333, 0, 333, - 0, 0, 333, 56, 24, 57, 25, 0, 333, 26, - 58, 0, 59, 60, 27, 61, 62, 63, 28, 0, - 0, 0, 0, 0, 64, 0, 65, 30, 66, 67, - 68, 69, 0, 0, 32, 0, 0, 0, 70, 33, - 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 73, 0, 36, 0, 37, 74, 0, - 0, 38, 0, 75, 76, 77, 78, 79, 80, 39, - 40, 81, 82, 41, 83, 0, 84, 0, 0, 85, - 86, 0, 0, 87, 88, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, - 91, 92, 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, 557, 557, 557, 557, 557, 557, 557, 557, + 558, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 557, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 562, 557, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 265, 0, 0, 0, 105, 106, 107, 108, - 56, 24, 57, 25, 0, 0, 26, 58, 0, 59, - 60, 27, 61, 62, 63, 28, 0, 0, 0, 0, - 0, 64, 0, 65, 30, 66, 67, 68, 69, 0, - 0, 32, 0, 0, 0, 70, 33, 0, 71, 72, - 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 73, 0, 36, 0, 37, 74, 0, 0, 38, 0, - 75, 76, 77, 78, 79, 80, 39, 40, 81, 82, - 41, 83, 0, 84, 0, 0, 85, 86, 0, 0, - 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 89, 90, 91, 92, 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, 558, 0, 0, 0, 0, 558, 0, 558, 558, + 558, 558, 558, 558, 558, 558, 558, 558, 558, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 551, - 0, 0, 0, 105, 106, 107, 108, 56, 24, 57, - 25, 0, 0, 26, 58, 0, 59, 60, 27, 61, + 558, 0, 558, 0, 558, 0, 558, 558, 558, 0, + 558, 558, 0, 0, 558, 558, 558, 558, 0, 0, + 0, 558, 558, 0, 563, 0, 558, 558, 558, 558, + 558, 558, 558, 558, 0, 0, 0, 0, 0, 562, + 0, 0, 0, 0, 562, 558, 562, 562, 562, 562, + 562, 562, 562, 562, 562, 562, 562, 0, 0, 0, + 0, 558, 0, 0, 0, 0, 0, 0, 562, 0, + 562, 0, 562, 0, 562, 562, 562, 0, 0, 0, + 0, 0, 562, 562, 562, 562, 0, 0, 0, 562, + 562, 0, 564, 0, 562, 562, 562, 562, 562, 562, + 562, 562, 0, 0, 0, 0, 0, 563, 0, 0, + 0, 0, 563, 562, 563, 563, 563, 563, 563, 563, + 563, 563, 563, 563, 563, 0, 0, 0, 0, 562, + 0, 0, 0, 0, 0, 0, 563, 0, 563, 0, + 563, 0, 563, 563, 563, 0, 0, 0, 0, 0, + 563, 563, 563, 563, 0, 0, 0, 563, 563, 0, + 565, 0, 563, 563, 563, 563, 563, 563, 563, 563, + 0, 0, 0, 0, 0, 564, 0, 0, 0, 0, + 564, 563, 564, 564, 564, 564, 564, 564, 564, 564, + 564, 564, 564, 0, 0, 0, 0, 563, 0, 0, + 0, 0, 0, 0, 564, 0, 564, 0, 564, 0, + 564, 564, 564, 0, 0, 0, 0, 0, 564, 564, + 564, 564, 0, 0, 0, 564, 564, 0, 566, 0, + 564, 564, 564, 564, 564, 564, 564, 564, 0, 0, + 0, 0, 0, 565, 0, 0, 0, 0, 565, 564, + 565, 565, 565, 565, 565, 565, 565, 565, 565, 565, + 565, 0, 0, 0, 0, 564, 0, 0, 0, 0, + 0, 0, 565, 0, 565, 0, 565, 0, 565, 565, + 565, 0, 0, 0, 0, 0, 565, 565, 565, 565, + 0, 0, 0, 565, 565, 0, 567, 0, 0, 0, + 565, 565, 565, 565, 565, 565, 0, 0, 0, 0, + 0, 566, 0, 0, 0, 0, 566, 565, 566, 566, + 566, 566, 566, 566, 566, 566, 566, 566, 566, 0, + 0, 0, 0, 565, 0, 0, 0, 0, 0, 0, + 566, 0, 566, 0, 566, 0, 566, 566, 566, 0, + 0, 0, 0, 0, 566, 566, 566, 566, 0, 0, + 0, 566, 566, 0, 568, 0, 0, 0, 566, 566, + 566, 566, 566, 566, 0, 0, 0, 0, 0, 567, + 0, 0, 0, 0, 567, 566, 567, 567, 567, 567, + 567, 567, 567, 567, 567, 567, 567, 0, 0, 0, + 0, 566, 0, 0, 0, 0, 0, 0, 567, 0, + 567, 0, 567, 0, 567, 567, 567, 0, 0, 0, + 0, 0, 567, 567, 567, 567, 0, 0, 0, 567, + 567, 0, 569, 0, 0, 0, 567, 567, 567, 567, + 567, 567, 0, 0, 0, 0, 0, 568, 0, 0, + 0, 0, 568, 567, 568, 568, 568, 568, 568, 568, + 568, 568, 568, 568, 568, 0, 0, 0, 0, 567, + 0, 0, 0, 0, 0, 0, 568, 0, 568, 0, + 568, 0, 568, 568, 568, 0, 0, 0, 0, 0, + 568, 568, 568, 568, 0, 0, 0, 568, 568, 0, + 570, 0, 0, 0, 568, 568, 568, 568, 568, 568, + 0, 0, 0, 0, 0, 569, 0, 0, 0, 0, + 569, 568, 569, 569, 569, 569, 569, 569, 569, 569, + 569, 569, 569, 0, 0, 0, 0, 568, 0, 0, + 0, 0, 0, 0, 569, 0, 569, 0, 569, 0, + 569, 569, 569, 0, 0, 0, 0, 0, 569, 569, + 569, 569, 0, 0, 0, 569, 569, 0, 571, 0, + 0, 0, 569, 569, 569, 569, 569, 569, 0, 0, + 0, 0, 0, 570, 0, 0, 0, 0, 570, 569, + 570, 570, 570, 570, 570, 570, 570, 570, 570, 570, + 570, 0, 0, 0, 0, 569, 0, 0, 0, 0, + 0, 0, 570, 0, 570, 0, 570, 0, 570, 570, + 570, 0, 0, 0, 0, 0, 0, 0, 570, 570, + 0, 0, 0, 570, 570, 0, 572, 0, 0, 0, + 0, 0, 570, 570, 570, 570, 0, 0, 0, 0, + 0, 571, 0, 0, 0, 0, 571, 570, 571, 571, + 571, 571, 571, 571, 571, 571, 571, 571, 571, 0, + 0, 0, 0, 570, 0, 0, 0, 0, 0, 0, + 571, 0, 571, 0, 571, 0, 571, 571, 571, 0, + 0, 0, 0, 0, 0, 0, 571, 571, 0, 0, + 0, 571, 571, 0, 573, 0, 0, 0, 0, 0, + 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, 0, 0, 572, 572, 0, 0, 0, 572, + 572, 0, 574, 0, 0, 0, 0, 0, 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, + 0, 0, 573, 573, 0, 0, 0, 573, 573, 0, + 575, 0, 0, 0, 0, 0, 0, 0, 573, 573, + 0, 0, 0, 0, 0, 574, 0, 0, 0, 0, + 574, 573, 574, 574, 574, 574, 574, 574, 574, 574, + 574, 574, 574, 0, 0, 0, 0, 573, 0, 0, + 0, 0, 0, 0, 574, 0, 574, 0, 574, 0, + 574, 574, 574, 0, 0, 0, 0, 0, 0, 0, + 574, 574, 0, 0, 0, 574, 574, 0, 576, 0, + 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 575, + 0, 0, 0, 575, 575, 0, 577, 0, 0, 0, + 0, 0, 0, 0, 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, 0, 0, 0, 576, 0, 0, + 0, 576, 576, 0, 578, 0, 0, 0, 0, 0, + 0, 0, 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, 0, 0, 0, 577, 0, 0, 0, 0, + 577, 0, 579, 0, 0, 0, 0, 0, 0, 0, + 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, + 0, 0, 0, 578, 0, 0, 0, 0, 578, 0, + 580, 0, 0, 0, 0, 0, 0, 0, 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, + 0, 0, 0, 0, 0, 335, 579, 0, 0, 743, + 0, 0, 0, 0, 0, 0, 579, 579, 0, 0, + 0, 0, 0, 580, 0, 0, 0, 0, 580, 579, + 580, 580, 580, 580, 580, 580, 580, 580, 580, 580, + 580, 335, 0, 0, 0, 579, 0, 0, 0, 0, + 0, 0, 580, 0, 580, 0, 580, 743, 580, 580, + 580, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 580, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 580, 580, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 580, 0, 0, + 335, 0, 0, 0, 0, 0, 335, 0, 0, 0, + 0, 335, 335, 580, 335, 0, 335, 0, 743, 335, + 0, 335, 335, 0, 335, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 0, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 0, 0, 55, + 0, 335, 0, 335, 0, 0, 335, 56, 24, 57, + 25, 0, 335, 26, 58, 0, 59, 60, 27, 61, 62, 63, 28, 0, 0, 0, 0, 0, 64, 0, 65, 30, 66, 67, 68, 69, 0, 0, 32, 0, 0, 0, 70, 33, 0, 71, 72, 34, 0, 0, @@ -10503,349 +10728,378 @@ void case_965() 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, 937, 0, 0, 0, - 105, 552, 107, 108, 937, 937, 937, 937, 0, 0, - 937, 937, 0, 937, 937, 937, 937, 937, 937, 937, - 0, 0, 0, 0, 0, 937, 0, 937, 937, 937, - 937, 937, 937, 0, 0, 937, 0, 0, 0, 937, - 937, 0, 937, 937, 937, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 937, 0, 937, 0, 937, 937, - 0, 0, 937, 0, 937, 937, 937, 937, 937, 937, - 937, 937, 937, 937, 937, 937, 0, 937, 0, 0, - 937, 937, 0, 0, 937, 937, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 937, - 937, 937, 937, 937, 0, 0, 0, 937, 0, 0, - 0, 937, 0, 0, 0, 0, 937, 937, 937, 937, - 937, 0, 0, 0, 937, 0, 937, 0, 0, 0, - 0, 0, 937, 937, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 788, 0, 0, 0, 937, 937, 937, - 937, 788, 788, 788, 788, 0, 0, 788, 788, 0, - 788, 788, 788, 788, 788, 788, 788, 0, 0, 0, - 0, 0, 788, 0, 788, 788, 788, 788, 788, 788, - 0, 0, 788, 0, 0, 0, 788, 788, 0, 788, - 788, 788, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 788, 0, 788, 0, 788, 788, 0, 0, 788, - 0, 788, 788, 788, 788, 788, 788, 788, 788, 788, - 788, 788, 788, 0, 788, 0, 0, 788, 788, 0, - 0, 788, 788, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 788, 788, 788, 788, - 788, 0, 0, 0, 788, 0, 0, 0, 788, 0, - 0, 0, 0, 788, 788, 788, 788, 788, 0, 0, - 0, 788, 0, 788, 0, 0, 0, 0, 0, 788, - 788, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 734, 0, 0, 0, 788, 788, 788, 788, 56, 24, - 0, 25, 0, 0, 26, 253, 0, 892, 0, 27, - 61, 62, 0, 28, 0, 0, 24, 0, 25, 64, - 0, 26, 30, 0, 0, 0, 27, 0, 0, 32, - 28, 0, 0, 0, 33, 0, 71, 72, 34, 30, - 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, - 36, 33, 37, 74, 0, 34, 38, 0, 0, 76, - 0, 78, 0, 80, 39, 40, 254, 36, 41, 37, - 0, 0, 0, 38, 0, 86, 0, 0, 87, 88, - 0, 39, 40, 0, 0, 41, 0, 0, 319, 0, - 0, 0, 0, 89, 90, 91, 92, 300, 0, 0, - 0, 513, 735, 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, 266, 0, 0, 0, + 105, 106, 107, 108, 56, 24, 57, 25, 0, 0, + 26, 58, 0, 59, 60, 27, 61, 62, 63, 28, + 0, 0, 0, 0, 0, 64, 0, 65, 30, 66, + 67, 68, 69, 0, 0, 32, 0, 0, 0, 70, + 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 73, 0, 36, 0, 37, 74, + 0, 0, 38, 0, 75, 76, 77, 78, 79, 80, + 39, 40, 81, 82, 41, 83, 0, 84, 0, 0, + 85, 86, 0, 0, 87, 88, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, + 90, 91, 92, 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, 0, 0, 0, 0, 921, 0, 0, - 0, 105, 301, 107, 108, 56, 24, 0, 25, 0, - 0, 26, 253, 0, 1036, 0, 27, 61, 62, 352, - 28, 0, 0, 24, 0, 25, 64, 0, 26, 30, - 0, 0, 0, 27, 0, 0, 32, 28, 0, 0, - 0, 33, 0, 71, 72, 34, 30, 0, 0, 0, - 0, 0, 0, 32, 0, 0, 0, 36, 33, 37, - 74, 922, 34, 38, 0, 0, 76, 0, 78, 0, - 80, 39, 40, 254, 36, 41, 37, 0, 0, 0, - 38, 0, 86, 0, 0, 87, 88, 0, 39, 40, - 0, 0, 41, 0, 0, 319, 0, 0, 0, 0, - 89, 90, 91, 92, 300, 0, 0, 0, 513, 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, 56, 24, 0, 25, 0, 0, 26, 253, 0, - 0, 0, 27, 61, 62, 0, 28, 0, 105, 301, - 107, 108, 64, 0, 0, 30, 0, 0, 0, 0, - 0, 0, 32, 0, 0, 0, 352, 33, 0, 71, + 0, 0, 0, 556, 0, 0, 0, 105, 106, 107, + 108, 56, 24, 57, 25, 0, 0, 26, 58, 0, + 59, 60, 27, 61, 62, 63, 28, 0, 0, 0, + 0, 0, 64, 0, 65, 30, 66, 67, 68, 69, + 0, 0, 32, 0, 0, 0, 70, 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 36, 0, 37, 74, 0, 0, 38, - 0, 0, 76, 0, 78, 0, 80, 39, 40, 254, - 0, 41, 0, 0, 0, 0, 0, 0, 86, 0, + 0, 73, 0, 36, 0, 37, 74, 0, 0, 38, + 0, 75, 76, 77, 78, 79, 80, 39, 40, 81, + 82, 41, 83, 0, 84, 0, 0, 85, 86, 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, 91, 92, - 300, 0, 0, 0, 721, 990, 0, 0, 95, 0, - 0, 0, 0, 0, 97, 98, 99, 100, 0, 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, - 0, 0, 734, 0, 105, 722, 107, 108, 0, 0, - 56, 24, 0, 25, 0, 723, 26, 253, 0, 1158, - 0, 27, 61, 62, 0, 28, 0, 0, 24, 0, - 25, 64, 0, 26, 30, 0, 0, 0, 27, 0, - 0, 32, 28, 0, 0, 0, 33, 0, 71, 72, - 34, 30, 0, 0, 0, 0, 0, 0, 32, 0, - 0, 0, 36, 33, 37, 74, 922, 34, 38, 0, - 0, 76, 0, 78, 0, 80, 39, 40, 254, 36, - 41, 37, 0, 0, 0, 38, 0, 86, 0, 0, - 87, 88, 0, 39, 40, 0, 0, 41, 0, 0, - 319, 0, 0, 0, 0, 89, 90, 91, 92, 300, - 0, 0, 0, 513, 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, + 950, 0, 0, 0, 105, 557, 107, 108, 950, 950, + 950, 950, 0, 0, 950, 950, 0, 950, 950, 950, + 950, 950, 950, 950, 0, 0, 0, 0, 0, 950, + 0, 950, 950, 950, 950, 950, 950, 0, 0, 950, + 0, 0, 0, 950, 950, 0, 950, 950, 950, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 950, 0, + 950, 0, 950, 950, 0, 0, 950, 0, 950, 950, + 950, 950, 950, 950, 950, 950, 950, 950, 950, 950, + 0, 950, 0, 0, 950, 950, 0, 0, 950, 950, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 702, - 0, 0, 0, 105, 301, 107, 108, 56, 24, 0, - 25, 0, 0, 26, 253, 0, 0, 0, 27, 61, - 62, 352, 28, 0, 0, 172, 0, 172, 64, 0, - 172, 30, 0, 0, 0, 172, 0, 0, 32, 172, - 0, 0, 0, 33, 0, 71, 72, 34, 172, 0, - 0, 0, 0, 0, 0, 172, 0, 0, 0, 36, - 172, 37, 74, 0, 172, 38, 0, 0, 76, 0, - 78, 0, 80, 39, 40, 254, 172, 41, 172, 0, - 84, 0, 172, 0, 86, 0, 0, 87, 88, 0, - 172, 172, 0, 0, 172, 0, 0, 172, 0, 0, - 0, 0, 89, 90, 91, 92, 300, 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, 961, 0, 0, 103, 104, 0, 0, 0, - 0, 0, 0, 56, 24, 0, 25, 0, 0, 26, - 253, 0, 0, 0, 27, 61, 62, 0, 28, 0, - 105, 301, 107, 108, 64, 0, 0, 30, 0, 0, - 0, 0, 0, 0, 32, 0, 0, 0, 172, 33, - 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 36, 0, 37, 74, 0, - 0, 38, 0, 0, 76, 0, 78, 0, 80, 39, - 40, 254, 0, 41, 0, 0, 0, 0, 0, 0, - 86, 0, 0, 87, 88, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, - 91, 92, 300, 0, 0, 0, 721, 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, + 0, 0, 0, 950, 950, 950, 950, 950, 0, 0, + 0, 950, 0, 0, 0, 950, 0, 0, 0, 0, + 950, 950, 950, 950, 950, 0, 0, 0, 950, 0, + 950, 0, 0, 0, 0, 0, 950, 950, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 734, 0, 105, 722, 107, 108, - 0, 0, 56, 24, 0, 25, 0, 723, 26, 253, - 0, 0, 0, 27, 61, 62, 0, 28, 0, 0, - 172, 0, 172, 64, 0, 172, 30, 0, 0, 0, - 172, 0, 0, 32, 172, 0, 0, 0, 33, 0, - 71, 72, 34, 172, 0, 0, 0, 0, 0, 0, - 172, 0, 0, 0, 36, 172, 37, 74, 0, 172, + 0, 0, 0, 0, 0, 0, 0, 794, 0, 0, + 0, 950, 950, 950, 950, 794, 794, 794, 794, 0, + 0, 794, 794, 0, 794, 794, 794, 794, 794, 794, + 794, 0, 0, 0, 0, 0, 794, 0, 794, 794, + 794, 794, 794, 794, 0, 0, 794, 0, 0, 0, + 794, 794, 0, 794, 794, 794, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 794, 0, 794, 0, 794, + 794, 0, 0, 794, 0, 794, 794, 794, 794, 794, + 794, 794, 794, 794, 794, 794, 794, 0, 794, 0, + 0, 794, 794, 0, 0, 794, 794, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 794, 794, 794, 794, 794, 0, 0, 0, 794, 0, + 0, 0, 794, 0, 0, 0, 0, 794, 794, 794, + 794, 794, 0, 0, 0, 794, 0, 794, 0, 0, + 0, 0, 0, 794, 794, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 742, 0, 0, 0, 794, 794, + 794, 794, 56, 24, 0, 25, 0, 0, 26, 253, + 0, 903, 0, 27, 61, 62, 0, 28, 0, 0, + 24, 0, 25, 64, 0, 26, 30, 0, 0, 0, + 27, 0, 0, 32, 28, 0, 0, 0, 33, 0, + 71, 72, 34, 30, 0, 0, 0, 0, 0, 0, + 32, 0, 0, 0, 36, 33, 37, 74, 0, 34, 38, 0, 0, 76, 0, 78, 0, 80, 39, 40, - 254, 172, 41, 172, 0, 0, 0, 172, 0, 86, - 0, 0, 87, 88, 0, 172, 172, 0, 0, 172, - 0, 0, 172, 0, 0, 0, 0, 89, 90, 91, - 92, 300, 0, 0, 0, 513, 0, 0, 0, 95, + 254, 36, 41, 37, 0, 0, 0, 38, 0, 86, + 0, 0, 87, 88, 0, 39, 40, 0, 0, 41, + 0, 0, 322, 0, 0, 0, 0, 89, 90, 91, + 92, 302, 0, 0, 0, 518, 743, 0, 0, 95, 0, 0, 0, 0, 0, 97, 98, 99, 100, 0, - 0, 0, 101, 0, 102, 961, 0, 0, 0, 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, 586, 0, 0, 0, 105, 301, 107, 108, 56, - 24, 0, 25, 0, 0, 26, 253, 0, 0, 0, - 27, 61, 62, 172, 28, 0, 0, 24, 0, 25, + 0, 929, 0, 0, 0, 105, 303, 107, 108, 56, + 24, 0, 25, 0, 0, 26, 253, 0, 1049, 0, + 27, 61, 62, 355, 28, 0, 0, 24, 0, 25, 64, 0, 26, 30, 0, 0, 0, 27, 0, 0, 32, 28, 0, 0, 0, 33, 0, 71, 72, 34, - 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, + 30, 593, 0, 0, 0, 0, 0, 32, 594, 0, 0, 36, 33, 37, 74, 0, 34, 38, 0, 0, 76, 0, 78, 0, 80, 39, 40, 254, 36, 41, - 37, 0, 0, 0, 38, 0, 86, 0, 0, 87, - 88, 0, 39, 40, 0, 0, 41, 0, 0, 319, + 37, 0, 0, 0, 38, 0, 595, 0, 0, 87, + 88, 0, 39, 40, 0, 0, 41, 0, 0, 322, 0, 0, 0, 0, 89, 90, 91, 92, 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, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 811, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 933, 0, 0, 0, 105, 106, 107, 108, 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, 0, 27, 61, 62, - 352, 28, 0, 0, 24, 0, 25, 64, 0, 26, + 355, 28, 0, 0, 174, 0, 174, 64, 0, 174, + 30, 0, 0, 0, 174, 0, 0, 32, 174, 0, + 0, 0, 33, 0, 71, 72, 34, 174, 0, 0, + 0, 0, 0, 0, 174, 0, 0, 0, 36, 174, + 37, 74, 934, 174, 38, 0, 0, 76, 0, 78, + 0, 80, 39, 40, 254, 174, 41, 174, 0, 0, + 0, 174, 0, 86, 0, 0, 87, 88, 0, 174, + 174, 0, 0, 174, 0, 0, 174, 0, 0, 0, + 0, 89, 90, 91, 92, 302, 0, 0, 0, 518, + 0, 0, 0, 95, 0, 0, 0, 0, 0, 97, + 98, 99, 100, 0, 0, 0, 101, 0, 102, 0, + 0, 974, 0, 0, 103, 104, 0, 0, 0, 0, + 0, 0, 56, 24, 0, 25, 0, 0, 26, 253, + 0, 0, 0, 27, 61, 62, 0, 28, 0, 105, + 303, 107, 108, 64, 0, 0, 30, 0, 0, 0, + 0, 0, 0, 32, 0, 0, 0, 174, 33, 0, + 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 36, 0, 37, 74, 0, 0, + 38, 0, 0, 76, 0, 78, 0, 80, 39, 40, + 254, 0, 41, 0, 0, 0, 0, 0, 0, 86, + 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 89, 90, 91, + 92, 302, 0, 0, 0, 729, 1001, 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, 742, 0, 105, 730, 107, 108, 0, + 0, 56, 24, 0, 25, 0, 731, 26, 253, 0, + 0, 0, 27, 61, 62, 0, 28, 0, 0, 174, + 0, 174, 64, 0, 174, 30, 0, 0, 0, 174, + 0, 0, 32, 174, 0, 0, 0, 33, 0, 71, + 72, 34, 174, 0, 0, 0, 0, 0, 0, 174, + 0, 0, 0, 36, 174, 37, 74, 934, 174, 38, + 0, 0, 76, 0, 78, 0, 80, 39, 40, 254, + 174, 41, 174, 0, 0, 0, 174, 0, 86, 0, + 0, 87, 88, 0, 174, 174, 0, 0, 174, 0, + 0, 174, 0, 0, 0, 0, 89, 90, 91, 92, + 302, 0, 0, 0, 518, 0, 0, 0, 95, 0, + 0, 0, 0, 0, 97, 98, 99, 100, 0, 0, + 0, 101, 0, 102, 974, 0, 0, 0, 0, 103, + 104, 0, 0, 0, 0, 0, 0, 56, 24, 0, + 25, 0, 0, 26, 253, 0, 0, 0, 27, 61, + 62, 0, 28, 0, 105, 303, 107, 108, 64, 0, + 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, + 0, 0, 174, 33, 0, 71, 72, 34, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, + 0, 37, 74, 0, 0, 38, 0, 0, 76, 0, + 78, 0, 80, 39, 40, 254, 0, 41, 0, 0, + 0, 0, 0, 0, 86, 0, 0, 87, 88, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 89, 90, 91, 92, 302, 0, 0, 0, + 729, 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, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 742, 0, + 105, 730, 107, 108, 0, 0, 56, 24, 0, 25, + 0, 731, 26, 253, 0, 0, 0, 27, 61, 62, + 0, 28, 0, 0, 24, 0, 25, 64, 0, 26, 30, 0, 0, 0, 27, 0, 0, 32, 28, 0, 0, 0, 33, 0, 71, 72, 34, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 36, 33, 37, 74, 0, 34, 38, 0, 0, 76, 0, 78, 0, 80, 39, 40, 254, 36, 41, 37, 0, 0, 0, 38, 0, 86, 0, 0, 87, 88, 0, 39, - 40, 0, 0, 41, 0, 0, 515, 0, 0, 0, - 0, 89, 90, 91, 92, 300, 0, 0, 0, 0, + 40, 0, 0, 41, 0, 0, 322, 0, 0, 0, + 0, 89, 90, 91, 92, 302, 0, 0, 0, 518, 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, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 606, 0, 0, 0, 105, - 301, 107, 108, 606, 606, 0, 606, 0, 0, 606, - 606, 0, 0, 0, 606, 606, 606, 352, 606, 0, - 0, 0, 0, 0, 606, 0, 0, 606, 0, 0, - 0, 0, 0, 0, 606, 0, 0, 0, 0, 606, - 0, 606, 606, 606, 0, 0, 0, 0, 0, 0, - 0, 333, 0, 0, 0, 606, 0, 606, 606, 0, - 0, 606, 0, 0, 606, 0, 606, 0, 606, 606, - 606, 606, 0, 606, 0, 0, 0, 0, 0, 0, - 606, 0, 0, 606, 606, 0, 0, 333, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 606, 606, - 606, 606, 606, 0, 0, 0, 0, 0, 0, 0, - 606, 0, 0, 0, 0, 0, 606, 606, 606, 606, - 0, 0, 0, 606, 0, 606, 0, 0, 0, 0, - 0, 606, 606, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 606, 606, 606, 606, - 333, 333, 333, 333, 739, 0, 0, 333, 333, 0, - 0, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 0, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 0, 48, 0, 48, 0, 48, 333, - 48, 0, 333, 48, 0, 48, 48, 0, 48, 0, - 48, 0, 48, 0, 48, 48, 48, 48, 0, 0, - 48, 48, 0, 0, 0, 0, 48, 48, 48, 48, - 48, 0, 0, 48, 0, 48, 0, 48, 0, 48, - 48, 48, 48, 48, 48, 48, 48, 0, 48, 48, - 48, 48, 0, 0, 48, 48, 48, 0, 48, 0, - 0, 0, 0, 48, 48, 0, 48, 48, 0, 48, - 48, 48, 0, 0, 0, 48, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 48, 0, 48, 48, 47, - 0, 0, 0, 47, 0, 47, 0, 0, 47, 0, - 47, 47, 0, 47, 0, 47, 0, 47, 0, 47, - 47, 47, 47, 0, 0, 47, 47, 0, 0, 0, - 0, 47, 0, 47, 47, 47, 0, 0, 47, 0, - 47, 0, 47, 0, 0, 47, 0, 47, 47, 47, - 47, 48, 0, 0, 47, 47, 47, 0, 0, 47, - 47, 47, 0, 0, 0, 0, 0, 0, 47, 47, - 0, 47, 47, 0, 47, 47, 47, 0, 0, 0, - 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 47, 0, - 47, 0, 47, 0, 47, 0, 80, 47, 0, 47, - 47, 0, 47, 0, 47, 47, 47, 0, 47, 47, - 47, 47, 0, 0, 47, 47, 0, 0, 0, 0, - 47, 0, 47, 47, 47, 0, 0, 47, 0, 47, - 0, 47, 0, 0, 47, 0, 47, 47, 47, 47, - 0, 0, 0, 47, 47, 47, 47, 0, 47, 47, - 47, 0, 0, 0, 0, 0, 0, 47, 47, 0, - 47, 47, 0, 47, 47, 47, 0, 0, 0, 47, + 0, 0, 0, 0, 0, 301, 0, 0, 0, 105, + 303, 107, 108, 56, 24, 0, 25, 0, 0, 26, + 253, 0, 0, 0, 27, 61, 62, 355, 28, 0, + 0, 24, 0, 25, 64, 0, 26, 30, 0, 0, + 0, 27, 0, 0, 32, 28, 0, 0, 0, 33, + 0, 71, 72, 34, 30, 0, 0, 0, 0, 0, + 0, 32, 0, 0, 0, 36, 33, 37, 74, 0, + 34, 38, 0, 0, 76, 0, 78, 0, 80, 39, + 40, 254, 36, 41, 37, 0, 0, 0, 38, 0, + 86, 0, 0, 87, 88, 0, 39, 40, 0, 0, + 41, 0, 0, 520, 0, 0, 0, 0, 89, 90, + 91, 92, 302, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 47, 0, 47, - 0, 47, 0, 47, 0, 81, 47, 0, 47, 47, - 0, 47, 0, 47, 47, 47, 0, 47, 47, 47, - 47, 0, 0, 47, 47, 0, 0, 0, 0, 47, - 0, 47, 47, 47, 0, 0, 47, 0, 47, 0, - 47, 0, 0, 47, 0, 47, 47, 47, 47, 0, - 0, 0, 47, 47, 47, 47, 0, 47, 47, 47, - 0, 0, 0, 0, 0, 0, 47, 47, 0, 47, - 47, 0, 47, 47, 47, 0, 0, 0, 47, 0, + 0, 0, 310, 0, 0, 0, 105, 303, 107, 108, + 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, + 0, 27, 61, 62, 355, 28, 0, 0, 24, 0, + 25, 64, 0, 26, 30, 0, 0, 0, 27, 0, + 0, 32, 28, 0, 0, 0, 33, 0, 71, 72, + 34, 30, 0, 0, 0, 0, 0, 0, 32, 0, + 0, 0, 36, 33, 37, 74, 0, 34, 38, 0, + 0, 76, 0, 78, 0, 80, 39, 40, 254, 36, + 41, 37, 0, 0, 0, 38, 0, 86, 0, 0, + 87, 88, 0, 39, 40, 0, 0, 41, 0, 0, + 573, 0, 0, 0, 0, 89, 90, 91, 92, 302, + 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, 0, 0, 0, - 0, 48, 0, 0, 0, 48, 0, 48, 47, 0, - 48, 0, 48, 48, 212, 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, 47, 0, 0, 0, 0, 0, - 48, 48, 0, 48, 48, 0, 48, 48, 48, 0, - 0, 0, 48, 0, 0, 0, 0, 47, 0, 0, - 0, 47, 0, 47, 0, 0, 47, 0, 47, 47, - 0, 47, 48, 47, 0, 47, 0, 47, 47, 47, - 47, 0, 0, 47, 47, 0, 0, 48, 0, 47, - 0, 47, 47, 47, 0, 0, 47, 0, 47, 333, - 47, 0, 0, 47, 0, 47, 47, 47, 47, 0, - 0, 0, 47, 47, 47, 0, 0, 47, 47, 47, - 0, 0, 333, 0, 0, 0, 47, 47, 48, 47, - 47, 0, 47, 47, 47, 333, 0, 0, 47, 0, - 333, 0, 0, 333, 0, 333, 0, 333, 333, 333, - 333, 0, 0, 0, 0, 333, 0, 0, 47, 333, - 0, 0, 0, 333, 213, 0, 0, 448, 0, 0, - 0, 333, 0, 0, 333, 0, 333, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 591, + 0, 0, 0, 105, 303, 107, 108, 56, 24, 0, + 25, 0, 0, 26, 253, 0, 0, 0, 27, 61, + 62, 355, 28, 0, 0, 24, 0, 25, 64, 0, + 26, 30, 0, 0, 0, 27, 0, 0, 32, 28, + 0, 0, 0, 33, 0, 71, 72, 34, 30, 0, + 0, 0, 0, 0, 0, 32, 0, 0, 0, 36, + 33, 37, 74, 0, 34, 38, 0, 0, 76, 0, + 78, 0, 80, 39, 40, 254, 36, 41, 37, 0, + 0, 0, 38, 0, 86, 0, 0, 87, 88, 0, + 39, 40, 0, 0, 41, 0, 0, 757, 0, 0, + 0, 0, 89, 90, 91, 92, 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, 0, 0, 0, 0, 0, 0, - 449, 0, 0, 0, 0, 333, 0, 448, 0, 0, - 333, 0, 0, 450, 0, 0, 0, 333, 452, 263, - 0, 333, 0, 453, 47, 454, 455, 456, 457, 0, - 449, 0, 0, 458, 333, 0, 0, 459, 0, 0, - 0, 1304, 0, 450, 0, 0, 0, 0, 452, 460, - 0, 0, 461, 453, 462, 454, 455, 456, 457, 0, - 0, 0, 0, 458, 0, 0, 333, 459, 0, 0, - 0, 0, 0, 0, 56, 24, 0, 25, 463, 460, - 26, 253, 461, 0, 462, 27, 61, 62, 0, 28, - 0, 0, 0, 0, 0, 64, 0, 0, 30, 0, - 0, 0, 0, 0, 0, 32, 0, 0, 463, 0, - 33, 0, 71, 72, 34, 0, 588, 0, 0, 0, - 0, 0, 0, 589, 0, 0, 36, 0, 37, 74, - 0, 0, 38, 0, 1305, 76, 0, 78, 0, 80, - 39, 40, 254, 0, 41, 0, 0, 0, 0, 0, - 0, 590, 0, 0, 87, 88, 0, 0, 0, 0, - 0, 0, 0, 0, 1319, 0, 0, 0, 0, 89, - 90, 91, 92, 93, 0, 0, 0, 0, 0, 0, - 0, 95, 916, 0, 591, 0, 0, 97, 98, 99, + 0, 0, 0, 0, 0, 0, 820, 0, 0, 0, + 105, 106, 107, 108, 56, 24, 0, 25, 0, 0, + 26, 253, 0, 0, 0, 27, 61, 62, 355, 28, + 0, 0, 488, 0, 488, 64, 0, 488, 30, 0, + 0, 0, 488, 0, 0, 32, 488, 0, 0, 0, + 33, 0, 71, 72, 34, 488, 0, 0, 0, 0, + 0, 0, 488, 0, 0, 0, 36, 488, 37, 74, + 0, 488, 38, 0, 0, 76, 0, 78, 0, 80, + 39, 40, 254, 488, 41, 488, 0, 0, 0, 488, + 0, 86, 0, 0, 87, 88, 0, 488, 488, 0, + 0, 488, 0, 0, 488, 0, 0, 0, 0, 89, + 90, 91, 92, 302, 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, - 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, - 0, 27, 61, 62, 0, 28, 0, 105, 106, 107, - 108, 64, 0, 0, 30, 0, 0, 0, 0, 0, - 0, 32, 0, 0, 0, 0, 33, 0, 71, 72, - 34, 0, 588, 0, 0, 0, 0, 0, 0, 589, - 0, 0, 36, 0, 37, 74, 0, 0, 38, 0, - 0, 76, 0, 78, 0, 80, 39, 40, 254, 0, - 41, 0, 0, 0, 0, 0, 0, 590, 0, 0, - 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 89, 90, 91, 92, 93, - 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, - 591, 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, 56, 24, 0, 25, - 0, 0, 26, 253, 0, 0, 0, 27, 61, 62, - 0, 28, 0, 105, 106, 107, 108, 64, 0, 0, - 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, - 0, 0, 33, 0, 71, 72, 34, 0, 588, 0, - 0, 0, 0, 0, 0, 589, 0, 0, 36, 0, - 37, 74, 0, 0, 38, 0, 0, 76, 0, 78, - 0, 80, 39, 40, 254, 0, 41, 0, 0, 0, - 0, 0, 0, 590, 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 89, 90, 91, 92, 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, 56, 24, 0, 25, 0, 0, 26, 253, - 0, 0, 0, 27, 61, 62, 0, 28, 0, 105, - 106, 107, 108, 64, 0, 0, 30, 0, 0, 0, - 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, - 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 36, 0, 37, 74, 0, 0, + 0, 0, 0, 1184, 0, 0, 0, 105, 303, 107, + 108, 56, 24, 0, 25, 0, 0, 26, 253, 0, + 0, 0, 27, 61, 62, 488, 28, 0, 0, 175, + 0, 175, 64, 0, 175, 30, 0, 0, 0, 175, + 0, 0, 32, 175, 0, 0, 0, 33, 0, 71, + 72, 34, 175, 0, 0, 0, 0, 0, 0, 175, + 0, 0, 0, 36, 175, 37, 74, 0, 175, 38, + 0, 0, 76, 0, 78, 0, 80, 39, 40, 254, + 175, 41, 175, 0, 0, 0, 175, 0, 86, 0, + 0, 87, 88, 0, 175, 175, 0, 0, 175, 0, + 0, 175, 0, 0, 0, 0, 89, 90, 91, 92, + 302, 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, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 608, 0, 0, 0, 105, 303, 107, 108, 608, 608, + 0, 608, 0, 0, 608, 608, 0, 0, 0, 608, + 608, 608, 175, 608, 0, 0, 0, 0, 0, 608, + 0, 0, 608, 0, 0, 0, 0, 0, 0, 608, + 0, 0, 0, 0, 608, 0, 608, 608, 608, 0, + 0, 0, 0, 0, 0, 0, 335, 0, 0, 0, + 608, 0, 608, 608, 0, 0, 608, 0, 0, 608, + 0, 608, 0, 608, 608, 608, 608, 0, 608, 0, + 0, 0, 0, 0, 0, 608, 0, 0, 608, 608, + 0, 0, 335, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 608, 608, 608, 608, 608, 0, 0, + 0, 0, 0, 0, 0, 608, 0, 0, 0, 0, + 0, 608, 608, 608, 608, 0, 0, 0, 608, 0, + 608, 0, 0, 0, 0, 0, 608, 608, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 608, 608, 608, 608, 335, 335, 335, 335, 743, + 0, 0, 335, 335, 0, 0, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 0, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, + 335, 335, 335, 335, 335, 335, 335, 335, 0, 48, + 0, 48, 0, 48, 335, 48, 0, 335, 48, 0, + 48, 48, 0, 48, 0, 48, 0, 48, 0, 48, + 48, 48, 48, 0, 0, 48, 48, 0, 0, 0, + 0, 48, 48, 48, 48, 48, 0, 0, 48, 0, + 48, 0, 48, 0, 48, 48, 0, 48, 48, 48, + 48, 0, 0, 48, 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, 0, 0, + 48, 0, 48, 48, 47, 0, 0, 0, 47, 0, + 47, 0, 0, 47, 0, 47, 47, 0, 47, 0, + 47, 0, 47, 0, 47, 47, 47, 47, 0, 0, + 47, 47, 0, 0, 0, 0, 47, 0, 47, 47, + 47, 0, 0, 47, 0, 47, 0, 47, 0, 0, + 47, 0, 47, 47, 47, 47, 48, 0, 0, 47, + 47, 47, 0, 0, 47, 47, 47, 0, 0, 0, + 0, 0, 0, 47, 47, 0, 47, 47, 0, 47, + 47, 47, 0, 0, 0, 47, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 47, 0, 47, 0, 47, 0, 47, + 0, 80, 47, 0, 47, 47, 0, 47, 0, 47, + 47, 47, 0, 47, 47, 47, 47, 0, 0, 47, + 47, 0, 0, 0, 0, 47, 0, 47, 47, 47, + 0, 0, 47, 0, 47, 0, 47, 0, 0, 47, + 0, 47, 47, 47, 47, 0, 0, 0, 47, 47, + 47, 47, 0, 47, 47, 47, 0, 0, 0, 0, + 0, 0, 47, 47, 0, 47, 47, 0, 47, 47, + 47, 0, 0, 0, 47, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 47, 0, 47, 0, 47, 0, 47, 0, + 81, 47, 0, 47, 47, 0, 47, 0, 47, 47, + 47, 0, 47, 47, 47, 47, 0, 0, 47, 47, + 0, 0, 0, 0, 47, 0, 47, 47, 47, 0, + 0, 47, 0, 47, 0, 47, 0, 0, 47, 0, + 47, 47, 47, 47, 0, 0, 0, 47, 47, 47, + 47, 0, 47, 47, 47, 0, 0, 0, 0, 0, + 0, 47, 47, 0, 47, 47, 0, 47, 47, 47, + 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, + 48, 0, 48, 47, 0, 48, 0, 48, 48, 214, + 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, 47, + 0, 0, 0, 0, 0, 48, 48, 0, 48, 48, + 0, 48, 48, 48, 0, 0, 0, 48, 0, 0, + 0, 0, 47, 0, 0, 0, 47, 0, 47, 0, + 0, 47, 0, 47, 47, 0, 47, 48, 47, 0, + 47, 0, 47, 47, 47, 47, 0, 0, 47, 47, + 0, 0, 48, 0, 47, 0, 47, 47, 47, 0, + 0, 47, 0, 47, 335, 47, 0, 0, 47, 0, + 47, 47, 47, 47, 0, 0, 0, 47, 47, 47, + 0, 0, 47, 47, 47, 0, 0, 335, 0, 0, + 0, 47, 47, 48, 47, 47, 0, 47, 47, 47, + 335, 0, 0, 47, 0, 335, 0, 0, 335, 0, + 335, 0, 335, 335, 335, 335, 0, 0, 0, 0, + 335, 0, 0, 47, 335, 0, 0, 0, 335, 215, + 0, 0, 0, 0, 0, 0, 335, 0, 0, 335, + 0, 335, 56, 24, 0, 25, 0, 0, 26, 253, + 0, 0, 0, 27, 61, 62, 0, 28, 0, 0, + 335, 0, 0, 64, 0, 335, 30, 0, 0, 0, + 0, 0, 335, 32, 265, 0, 335, 0, 33, 47, + 71, 72, 34, 0, 593, 0, 0, 0, 0, 335, + 0, 594, 0, 0, 36, 0, 37, 74, 0, 0, 38, 0, 0, 76, 0, 78, 0, 80, 39, 40, - 254, 0, 41, 0, 0, 84, 0, 0, 0, 86, - 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, + 254, 0, 41, 0, 0, 0, 0, 0, 0, 595, + 0, 335, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, 91, - 92, 300, 0, 0, 0, 0, 0, 0, 0, 95, - 0, 0, 0, 0, 0, 97, 98, 99, 100, 0, + 92, 93, 0, 0, 0, 0, 0, 0, 0, 95, + 927, 0, 596, 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, 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, 0, 27, - 61, 62, 0, 28, 0, 105, 301, 107, 108, 64, + 61, 62, 0, 28, 0, 105, 106, 107, 108, 64, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 71, 72, 34, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 593, 0, 0, 0, 0, 0, 0, 594, 0, 0, 36, 0, 37, 74, 0, 0, 38, 0, 0, 76, 0, 78, 0, 80, 39, 40, 254, 0, 41, 0, - 0, 0, 0, 0, 0, 86, 0, 0, 87, 88, + 0, 0, 0, 0, 0, 595, 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 89, 90, 91, 92, 300, 0, 0, - 0, 0, 875, 0, 0, 95, 0, 0, 0, 0, + 0, 0, 0, 89, 90, 91, 92, 93, 0, 0, + 0, 0, 0, 0, 0, 95, 0, 0, 596, 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, 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, 0, 27, 61, 62, 0, 28, - 0, 105, 301, 107, 108, 64, 0, 0, 30, 0, + 0, 105, 106, 107, 108, 64, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 74, 0, 0, 38, 0, 0, 76, 0, 78, 0, 80, - 39, 40, 254, 0, 41, 0, 0, 0, 0, 0, + 39, 40, 254, 0, 41, 0, 0, 84, 0, 0, 0, 86, 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, - 90, 91, 92, 300, 0, 0, 0, 513, 0, 0, + 90, 91, 92, 302, 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, 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, - 0, 27, 61, 62, 0, 28, 0, 105, 301, 107, + 0, 27, 61, 62, 0, 28, 0, 105, 303, 107, 108, 64, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -10853,13 +11107,13 @@ void case_965() 0, 76, 0, 78, 0, 80, 39, 40, 254, 0, 41, 0, 0, 0, 0, 0, 0, 86, 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 89, 90, 91, 92, 300, - 0, 0, 0, 507, 0, 0, 0, 95, 0, 0, + 0, 0, 0, 0, 0, 89, 90, 91, 92, 302, + 0, 0, 0, 0, 886, 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, 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, 0, 27, 61, 62, - 0, 28, 0, 105, 301, 107, 108, 64, 0, 0, + 0, 28, 0, 105, 303, 107, 108, 64, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, @@ -10867,13 +11121,13 @@ void case_965() 0, 80, 39, 40, 254, 0, 41, 0, 0, 0, 0, 0, 0, 86, 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 89, 90, 91, 92, 300, 0, 0, 0, 0, + 0, 89, 90, 91, 92, 302, 0, 0, 0, 518, 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, 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, 0, 27, 61, 62, 0, 28, 0, 105, - 301, 107, 108, 64, 0, 0, 30, 0, 0, 0, + 303, 107, 108, 64, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 74, 0, 0, @@ -10881,12 +11135,12 @@ void case_965() 254, 0, 41, 0, 0, 0, 0, 0, 0, 86, 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, 91, - 92, 93, 0, 0, 0, 0, 0, 0, 0, 95, + 92, 302, 0, 0, 0, 512, 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, 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, 0, 27, - 61, 62, 0, 28, 0, 105, 106, 107, 108, 64, + 61, 62, 0, 28, 0, 105, 303, 107, 108, 64, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -10894,155 +11148,178 @@ void case_965() 0, 78, 0, 80, 39, 40, 254, 0, 41, 0, 0, 0, 0, 0, 0, 86, 0, 0, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 89, 90, 91, 92, 93, 0, 0, + 0, 0, 0, 89, 90, 91, 92, 302, 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, 77, 77, 0, 77, 0, 0, - 77, 77, 0, 0, 0, 77, 77, 77, 0, 77, - 0, 105, 1028, 107, 108, 77, 0, 0, 77, 0, - 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, - 77, 0, 77, 77, 77, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 77, 0, 77, 77, - 0, 0, 77, 0, 0, 77, 0, 77, 0, 77, - 77, 77, 77, 0, 77, 0, 0, 0, 0, 0, - 0, 77, 0, 0, 77, 77, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, - 77, 77, 77, 77, 0, 0, 0, 0, 0, 0, - 0, 77, 0, 0, 0, 0, 0, 77, 77, 77, - 77, 0, 0, 0, 77, 0, 77, 0, 0, 0, - 0, 0, 77, 77, 0, 0, 0, 0, 0, 0, - 135, 135, 0, 135, 0, 0, 135, 135, 0, 0, - 0, 135, 135, 135, 0, 135, 0, 77, 77, 77, - 77, 135, 0, 0, 135, 0, 0, 0, 0, 0, - 0, 135, 0, 0, 0, 0, 135, 0, 135, 135, - 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 135, 0, 135, 135, 0, 0, 135, 0, - 0, 135, 0, 135, 0, 135, 135, 135, 135, 0, - 135, 0, 0, 0, 0, 0, 0, 135, 0, 0, - 135, 135, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 135, 135, 135, 135, 135, - 0, 0, 0, 0, 0, 0, 0, 135, 0, 0, - 0, 0, 0, 135, 135, 135, 135, 0, 0, 0, - 135, 0, 135, 0, 0, 0, 0, 0, 135, 135, - 0, 0, 0, 0, 0, 0, 56, 24, 0, 25, - 0, 0, 26, 253, 0, 0, 0, 27, 61, 62, - 0, 28, 0, 135, 135, 135, 135, 64, 0, 0, - 30, 0, 0, 0, 0, 0, 0, 32, 0, 27, - 0, 27, 33, 0, 71, 72, 34, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, - 37, 74, 27, 0, 38, 0, 0, 76, 0, 78, - 0, 80, 39, 40, 254, 27, 41, 0, 0, 0, - 27, 0, 0, 0, 0, 27, 0, 27, 27, 27, - 27, 0, 0, 0, 0, 27, 0, 0, 0, 27, - 0, 89, 90, 91, 255, 300, 0, 0, 0, 0, - 0, 27, 0, 95, 27, 0, 27, 0, 0, 97, - 98, 99, 100, 0, 0, 0, 101, 0, 102, 0, - 0, 0, 0, 0, 103, 104, 0, 0, 0, 0, - 27, 0, 0, 0, 0, 0, 27, 27, 0, 0, - 0, 0, 0, 0, 639, 0, 639, 0, 639, 105, - 256, 639, 108, 639, 639, 0, 639, 0, 639, 0, - 639, 0, 639, 639, 639, 0, 0, 0, 639, 639, - 0, 0, 0, 0, 639, 0, 639, 639, 0, 0, - 0, 639, 0, 0, 0, 639, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 639, 639, 0, 639, - 0, 0, 0, 639, 639, 0, 0, 0, 0, 0, - 0, 639, 639, 56, 24, 639, 25, 0, 639, 26, - 253, 0, 0, 639, 27, 61, 62, 0, 28, 0, - 0, 0, 0, 0, 64, 0, 0, 30, 0, 0, - 0, 0, 0, 0, 32, 639, 639, 0, 0, 33, - 0, 71, 72, 34, 0, 0, 0, 0, 639, 0, - 0, 0, 0, 0, 0, 36, 0, 37, 74, 0, - 0, 38, 0, 0, 76, 0, 78, 0, 80, 39, - 40, 254, 0, 41, 0, 0, 84, 0, 0, 0, - 0, 0, 0, 24, 0, 25, 0, 0, 26, 639, - 1211, 0, 0, 27, 0, 0, 0, 28, 89, 90, - 91, 255, 0, 0, 0, 0, 30, 638, 0, 638, - 95, 0, 638, 32, 638, 638, 0, 638, 33, 638, - 1212, 638, 34, 638, 638, 638, 0, 0, 0, 638, - 638, 0, 0, 0, 36, 638, 37, 638, 638, 0, - 38, 1213, 638, 0, 0, 0, 638, 0, 39, 40, - 0, 0, 41, 0, 0, 319, 105, 256, 638, 0, - 638, 0, 0, 0, 638, 638, 0, 0, 0, 0, - 0, 0, 638, 638, 0, 638, 638, 638, 0, 638, - 638, 0, 638, 638, 638, 638, 0, 638, 0, 638, - 0, 638, 638, 638, 0, 0, 0, 638, 638, 0, - 0, 0, 0, 638, 0, 638, 638, 0, 0, 0, - 638, 0, 0, 0, 638, 0, 0, 0, 0, 638, - 0, 0, 0, 0, 0, 0, 638, 0, 638, 0, - 0, 0, 638, 638, 0, 0, 352, 0, 0, 0, - 638, 638, 0, 0, 638, 0, 0, 638, 0, 24, - 0, 25, 638, 0, 26, 0, 0, 1274, 0, 27, - 638, 678, 0, 28, 0, 679, 1275, 1276, 0, 0, - 0, 1277, 30, 0, 0, 0, 0, 1278, 0, 32, - 0, 24, 0, 25, 33, 0, 26, 0, 34, 1274, - 0, 27, 0, 678, 0, 28, 0, 679, 1275, 1276, - 36, 0, 37, 1277, 30, 0, 38, 0, 0, 1278, - 0, 32, 0, 0, 39, 40, 33, 0, 41, 0, - 34, 1279, 0, 0, 0, 47, 1280, 47, 638, 0, - 47, 0, 36, 0, 37, 47, 0, 0, 38, 47, - 0, 0, 0, 0, 0, 0, 39, 40, 47, 0, - 41, 0, 0, 1279, 0, 47, 0, 47, 1280, 47, - 47, 1281, 47, 0, 47, 0, 47, 47, 47, 0, - 0, 47, 0, 47, 0, 0, 47, 0, 47, 0, - 47, 0, 47, 0, 0, 47, 0, 47, 0, 0, - 47, 47, 47, 0, 47, 0, 47, 47, 47, 0, - 47, 47, 1282, 47, 0, 47, 47, 0, 47, 0, - 47, 47, 0, 0, 47, 47, 0, 47, 0, 0, - 0, 0, 47, 47, 47, 0, 47, 0, 0, 47, - 0, 47, 153, 24, 1282, 25, 47, 0, 26, 0, - 47, 0, 47, 27, 47, 0, 0, 28, 0, 47, - 0, 0, 47, 0, 47, 0, 30, 0, 47, 0, - 0, 47, 153, 32, 0, 0, 47, 47, 33, 0, - 47, 0, 34, 47, 565, 0, 0, 0, 47, 0, - 0, 566, 0, 0, 36, 0, 37, 0, 0, 0, - 38, 0, 0, 567, 0, 0, 0, 0, 39, 40, - 0, 0, 41, 0, 24, 568, 25, 0, 0, 26, - 47, 0, 0, 0, 27, 0, 0, 0, 28, 0, - 0, 0, 29, 24, 0, 25, 0, 30, 26, 0, - 0, 0, 31, 27, 32, 0, 0, 28, 0, 33, - 0, 0, 0, 34, 35, 0, 30, 0, 0, 0, - 0, 0, 0, 32, 47, 36, 0, 37, 33, 0, - 0, 38, 34, 0, 0, 0, 0, 0, 0, 39, - 40, 0, 0, 41, 36, 0, 37, 24, 0, 25, - 38, 0, 26, 0, 0, 0, 569, 27, 39, 40, - 0, 28, 41, 0, 24, 319, 25, 0, 0, 26, - 30, 0, 0, 0, 27, 0, 0, 32, 28, 0, - 0, 0, 33, 0, 0, 0, 34, 30, 0, 0, - 0, 290, 0, 0, 32, 0, 0, 0, 36, 33, - 37, 0, 0, 34, 38, 0, 0, 0, 0, 0, - 0, 0, 39, 40, 0, 36, 41, 37, 487, 568, - 487, 38, 0, 487, 0, 0, 0, 42, 487, 39, - 40, 0, 487, 41, 0, 0, 749, 0, 0, 0, - 0, 487, 173, 0, 173, 0, 320, 173, 487, 0, - 0, 0, 173, 487, 0, 0, 173, 487, 0, 0, - 0, 0, 0, 0, 0, 173, 0, 0, 0, 487, - 0, 487, 173, 0, 0, 487, 0, 173, 0, 0, - 0, 173, 0, 487, 487, 0, 0, 487, 0, 0, - 487, 0, 172, 173, 172, 173, 0, 172, 0, 173, - 352, 0, 172, 0, 0, 0, 172, 173, 173, 0, - 0, 173, 0, 0, 173, 172, 182, 352, 182, 0, - 0, 182, 172, 0, 0, 0, 182, 172, 0, 0, - 182, 172, 0, 0, 0, 0, 0, 0, 0, 182, - 0, 0, 0, 172, 0, 172, 182, 0, 0, 172, - 0, 182, 0, 0, 0, 182, 0, 172, 172, 0, - 0, 172, 0, 33, 172, 0, 0, 182, 0, 182, - 0, 487, 0, 182, 33, 0, 0, 0, 0, 33, - 0, 182, 182, 33, 0, 182, 33, 0, 182, 0, - 0, 0, 0, 0, 0, 173, 0, 0, 33, 33, - 0, 0, 0, 33, 33, 0, 31, 0, 0, 33, - 0, 33, 33, 33, 33, 0, 0, 31, 0, 33, - 0, 0, 31, 33, 0, 33, 31, 0, 0, 31, - 0, 0, 0, 0, 0, 33, 0, 33, 33, 0, - 33, 31, 31, 0, 33, 172, 31, 31, 0, 0, - 0, 0, 31, 0, 31, 31, 31, 31, 0, 0, - 0, 0, 31, 0, 33, 0, 31, 0, 31, 182, - 33, 33, 0, 0, 0, 47, 0, 0, 31, 0, - 0, 31, 0, 31, 0, 0, 47, 31, 0, 0, + 0, 0, 0, 0, 56, 24, 0, 25, 0, 0, + 26, 253, 0, 0, 0, 27, 61, 62, 0, 28, + 0, 105, 303, 107, 108, 64, 0, 0, 30, 0, + 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, + 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 36, 0, 37, 74, + 0, 0, 38, 0, 0, 76, 0, 78, 0, 80, + 39, 40, 254, 0, 41, 0, 0, 0, 0, 0, + 0, 86, 0, 0, 87, 88, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, + 90, 91, 92, 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, + 56, 24, 0, 25, 0, 0, 26, 253, 0, 0, + 0, 27, 61, 62, 0, 28, 0, 105, 106, 107, + 108, 64, 0, 0, 30, 0, 0, 0, 0, 0, + 0, 32, 0, 0, 0, 0, 33, 0, 71, 72, + 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 36, 0, 37, 74, 0, 0, 38, 0, + 0, 76, 0, 78, 0, 80, 39, 40, 254, 0, + 41, 0, 0, 0, 0, 0, 0, 86, 0, 0, + 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 89, 90, 91, 92, 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, 77, 77, 0, 77, + 0, 0, 77, 77, 0, 0, 0, 77, 77, 77, + 0, 77, 0, 105, 1041, 107, 108, 77, 0, 0, + 77, 0, 0, 0, 0, 0, 0, 77, 0, 0, + 0, 0, 77, 0, 77, 77, 77, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, + 77, 77, 0, 0, 77, 0, 0, 77, 0, 77, + 0, 77, 77, 77, 77, 0, 77, 0, 0, 0, + 0, 0, 0, 77, 0, 0, 77, 77, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 77, 77, 77, 77, 77, 0, 0, 0, 0, + 0, 0, 0, 77, 0, 0, 0, 0, 0, 77, + 77, 77, 77, 0, 0, 0, 77, 0, 77, 0, + 0, 0, 0, 0, 77, 77, 0, 0, 0, 0, + 0, 0, 135, 135, 0, 135, 0, 0, 135, 135, + 0, 0, 0, 135, 135, 135, 0, 135, 0, 77, + 77, 77, 77, 135, 0, 0, 135, 0, 0, 0, + 0, 0, 0, 135, 0, 0, 0, 0, 135, 0, + 135, 135, 135, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 135, 0, 135, 135, 0, 0, + 135, 0, 0, 135, 0, 135, 0, 135, 135, 135, + 135, 0, 135, 0, 0, 0, 0, 0, 0, 135, + 0, 0, 135, 135, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 135, 135, 135, + 135, 135, 0, 0, 0, 0, 0, 0, 0, 135, + 0, 0, 0, 0, 0, 135, 135, 135, 135, 0, + 0, 0, 135, 0, 135, 0, 0, 0, 0, 0, + 135, 135, 0, 0, 0, 0, 0, 0, 56, 24, + 0, 25, 0, 0, 26, 253, 0, 0, 0, 27, + 61, 62, 0, 28, 0, 135, 135, 135, 135, 64, + 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, + 0, 27, 0, 0, 33, 0, 71, 72, 34, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 36, 0, 37, 74, 27, 0, 38, 0, 0, 76, + 0, 78, 0, 80, 39, 40, 254, 27, 41, 0, + 0, 0, 27, 0, 0, 0, 0, 27, 0, 27, + 27, 27, 27, 0, 0, 27, 0, 27, 0, 0, + 0, 27, 0, 89, 90, 91, 255, 302, 0, 0, + 0, 0, 0, 27, 0, 95, 27, 0, 27, 0, + 0, 97, 98, 99, 100, 0, 0, 0, 101, 0, + 102, 0, 0, 0, 0, 0, 103, 104, 0, 0, + 0, 0, 27, 0, 0, 0, 0, 0, 27, 27, + 0, 0, 0, 0, 0, 0, 641, 0, 641, 0, + 641, 105, 256, 641, 108, 641, 641, 0, 641, 0, + 641, 0, 641, 0, 641, 641, 641, 0, 0, 0, + 641, 641, 0, 0, 0, 0, 641, 0, 641, 641, + 0, 0, 0, 641, 0, 0, 0, 641, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 641, 641, + 0, 641, 0, 0, 0, 641, 641, 0, 0, 0, + 0, 0, 0, 641, 641, 56, 24, 641, 25, 0, + 641, 26, 253, 0, 0, 641, 27, 61, 62, 0, + 28, 0, 0, 0, 0, 0, 64, 0, 0, 30, + 0, 0, 0, 0, 0, 0, 32, 641, 641, 0, + 0, 33, 0, 71, 72, 34, 0, 0, 0, 0, + 641, 0, 0, 0, 0, 0, 0, 36, 0, 37, + 74, 0, 0, 38, 0, 0, 76, 0, 78, 0, + 80, 39, 40, 254, 0, 41, 0, 0, 84, 0, + 0, 0, 0, 0, 0, 24, 0, 25, 0, 0, + 26, 641, 1228, 0, 0, 27, 0, 0, 0, 28, + 89, 90, 91, 255, 0, 0, 0, 0, 30, 640, + 0, 640, 95, 0, 640, 32, 640, 640, 0, 640, + 33, 640, 1229, 640, 34, 640, 640, 640, 0, 0, + 0, 640, 640, 0, 0, 0, 36, 640, 37, 640, + 640, 0, 38, 1230, 640, 0, 0, 0, 640, 0, + 39, 40, 0, 0, 41, 0, 0, 322, 105, 256, + 640, 0, 640, 0, 0, 0, 640, 640, 0, 0, + 0, 0, 0, 0, 640, 640, 0, 640, 640, 640, + 0, 640, 640, 0, 640, 640, 640, 640, 0, 640, + 0, 640, 0, 640, 640, 640, 0, 0, 0, 640, + 640, 0, 0, 0, 0, 640, 0, 640, 640, 0, + 0, 0, 640, 0, 0, 0, 640, 0, 0, 0, + 0, 640, 0, 0, 0, 0, 0, 0, 640, 0, + 640, 0, 0, 0, 640, 640, 0, 0, 355, 0, + 0, 0, 640, 640, 0, 0, 640, 0, 0, 640, + 0, 24, 0, 25, 640, 0, 26, 0, 0, 1290, + 0, 27, 640, 686, 0, 28, 0, 687, 1291, 1292, + 0, 0, 0, 1293, 30, 0, 0, 0, 0, 1294, + 0, 32, 0, 24, 0, 25, 33, 0, 26, 0, + 34, 1290, 0, 27, 0, 686, 0, 28, 0, 687, + 1291, 1292, 36, 0, 37, 1293, 30, 0, 38, 0, + 0, 1294, 0, 32, 0, 0, 39, 40, 33, 0, + 41, 0, 34, 1295, 0, 0, 0, 47, 1296, 47, + 640, 0, 47, 0, 36, 0, 37, 47, 0, 0, + 38, 47, 0, 0, 0, 0, 0, 0, 39, 40, + 47, 0, 41, 0, 0, 1295, 0, 47, 0, 47, + 1296, 47, 47, 1297, 47, 0, 47, 0, 47, 47, + 47, 0, 0, 47, 0, 47, 0, 0, 47, 0, + 47, 0, 47, 0, 47, 0, 0, 47, 0, 47, + 0, 0, 47, 47, 47, 0, 47, 0, 47, 47, + 47, 0, 47, 48, 1298, 48, 0, 47, 48, 0, + 47, 0, 47, 48, 0, 0, 47, 48, 0, 47, + 0, 0, 0, 0, 47, 47, 48, 0, 47, 0, + 0, 47, 0, 48, 154, 47, 1298, 47, 48, 0, + 47, 0, 48, 0, 48, 47, 48, 0, 0, 47, + 0, 48, 0, 0, 48, 0, 48, 0, 47, 0, + 48, 0, 0, 48, 154, 47, 0, 0, 48, 48, + 47, 0, 48, 0, 47, 48, 47, 0, 47, 24, + 47, 25, 0, 47, 26, 0, 47, 0, 47, 27, + 0, 0, 47, 28, 0, 47, 0, 0, 0, 0, + 47, 47, 30, 0, 47, 0, 0, 47, 0, 32, + 0, 0, 47, 0, 33, 0, 0, 0, 34, 0, + 570, 0, 0, 0, 24, 0, 25, 571, 0, 26, + 36, 0, 37, 0, 27, 0, 38, 0, 28, 572, + 0, 0, 29, 0, 39, 40, 0, 30, 41, 0, + 0, 573, 31, 0, 32, 0, 48, 0, 0, 33, + 0, 0, 0, 34, 35, 0, 0, 0, 24, 0, + 25, 0, 0, 26, 0, 36, 0, 37, 27, 0, + 0, 38, 28, 0, 0, 0, 0, 0, 47, 39, + 40, 30, 174, 41, 174, 0, 0, 174, 32, 0, + 0, 0, 174, 33, 0, 0, 174, 34, 0, 0, + 0, 0, 0, 0, 0, 174, 0, 0, 0, 36, + 0, 37, 174, 0, 0, 38, 0, 174, 0, 0, + 0, 174, 574, 39, 40, 0, 0, 41, 0, 0, + 322, 0, 0, 174, 0, 174, 184, 0, 184, 174, + 0, 184, 0, 0, 0, 0, 184, 174, 174, 0, + 184, 174, 0, 0, 174, 0, 291, 0, 0, 184, + 0, 0, 0, 0, 0, 0, 184, 42, 0, 0, + 0, 184, 0, 0, 33, 184, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 0, 184, 0, 184, + 33, 0, 0, 184, 33, 0, 0, 33, 0, 0, + 0, 184, 184, 0, 0, 184, 0, 0, 184, 33, + 33, 323, 0, 0, 33, 33, 0, 0, 0, 0, + 33, 0, 33, 33, 33, 33, 0, 0, 0, 0, + 33, 0, 0, 0, 33, 174, 33, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 0, 33, 33, + 31, 33, 0, 0, 0, 33, 0, 0, 0, 0, + 0, 31, 0, 0, 0, 0, 31, 0, 0, 0, + 31, 0, 0, 31, 0, 33, 0, 0, 0, 0, + 0, 33, 33, 0, 0, 31, 31, 0, 0, 184, + 31, 31, 27, 0, 27, 0, 31, 0, 31, 31, + 31, 31, 0, 0, 0, 0, 31, 0, 0, 0, + 31, 0, 31, 0, 0, 27, 0, 0, 0, 0, + 0, 0, 31, 0, 0, 31, 0, 31, 27, 0, + 0, 31, 0, 27, 0, 0, 0, 0, 27, 0, + 27, 27, 27, 27, 0, 0, 0, 0, 27, 0, + 0, 31, 27, 0, 0, 47, 0, 31, 31, 0, + 0, 0, 0, 0, 27, 0, 47, 27, 0, 27, 0, 47, 0, 0, 0, 47, 0, 0, 47, 0, - 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, - 47, 47, 0, 31, 31, 47, 47, 0, 47, 0, - 0, 47, 0, 47, 47, 47, 47, 0, 0, 47, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 47, 47, 0, 27, 0, 47, 47, 0, 47, 27, + 27, 47, 0, 47, 47, 47, 47, 0, 0, 47, 0, 47, 0, 0, 47, 47, 0, 47, 47, 0, 0, 47, 0, 0, 0, 0, 0, 47, 0, 0, 47, 0, 47, 47, 47, 0, 47, 0, 47, 47, @@ -11056,581 +11333,619 @@ void case_965() 0, 0, 47, 0, 47, 47, 47, 47, 0, 47, 0, 0, 0, 0, 47, 0, 47, 47, 47, 47, 0, 0, 0, 0, 47, 0, 0, 0, 47, 47, - 0, 47, 0, 47, 47, 0, 0, 194, 0, 0, + 0, 47, 0, 47, 47, 0, 0, 196, 0, 0, 47, 0, 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 47, 0, 47, 47, 47, 47, 0, 0, 47, 0, 47, 0, 0, 0, 47, 47, 0, 47, - 0, 47, 47, 0, 0, 196, 0, 0, 47, 0, - 47, 47, 47, 47, 0, 47, 0, 0, 0, 0, + 0, 47, 47, 0, 0, 198, 0, 0, 47, 0, + 47, 47, 47, 47, 47, 47, 0, 0, 0, 0, 47, 0, 47, 47, 47, 47, 0, 0, 0, 0, 47, 0, 0, 0, 47, 47, 0, 47, 0, 0, - 0, 0, 47, 297, 47, 0, 47, 0, 47, 47, + 0, 0, 453, 299, 0, 0, 47, 0, 47, 47, 0, 47, 0, 47, 0, 0, 0, 0, 47, 0, - 47, 47, 47, 47, 0, 47, 0, 0, 47, 0, - 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, - 0, 298, 448, 47, 47, 0, 0, 47, 47, 47, - 47, 47, 47, 47, 0, 0, 47, 0, 47, 0, - 0, 0, 47, 0, 0, 449, 0, 0, 0, 0, - 0, 0, 448, 47, 47, 47, 47, 47, 450, 47, - 0, 0, 451, 452, 0, 0, 0, 0, 453, 0, - 454, 455, 456, 457, 0, 449, 0, 0, 458, 0, - 0, 0, 459, 47, 0, 0, 0, 0, 450, 0, - 0, 0, 0, 452, 460, 0, 0, 461, 453, 462, - 454, 455, 456, 457, 0, 0, 0, 0, 458, 0, - 0, 0, 459, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 463, 460, 0, 0, 461, 0, 462, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 47, 47, 47, 47, 0, 454, 47, 0, 47, 0, + 0, 0, 47, 0, 453, 47, 0, 0, 455, 0, + 0, 300, 456, 457, 47, 0, 0, 47, 458, 47, + 459, 460, 461, 462, 0, 0, 0, 454, 463, 0, + 0, 0, 464, 0, 0, 0, 0, 0, 0, 0, + 455, 0, 0, 47, 465, 457, 0, 466, 0, 467, + 458, 0, 459, 460, 461, 462, 0, 0, 0, 0, + 463, 0, 0, 0, 464, 0, 0, 0, 0, 0, + 0, 0, 0, 468, 0, 0, 465, 0, 0, 466, + 0, 467, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 463, + 0, 0, 0, 0, 0, 468, }; protected static readonly short [] yyCheck = { 17, - 4, 298, 18, 17, 234, 511, 299, 87, 88, 51, - 189, 232, 51, 513, 465, 487, 188, 318, 20, 6, - 288, 247, 17, 297, 17, 554, 59, 922, 108, 351, - 713, 157, 715, 59, 329, 1097, 336, 77, 351, 295, - 84, 739, 47, 772, 58, 256, 1218, 0, 1132, 1133, - 579, 325, 571, 256, 113, 73, 115, 256, 256, 77, - 256, 256, 256, 256, 1236, 79, 268, 81, 256, 113, - 68, 115, 1178, 256, 268, 256, 759, 95, 268, 762, - 256, 17, 256, 59, 927, 294, 256, 899, 268, 87, - 88, 1197, 1202, 17, 92, 1179, 276, 306, 325, 1295, - 372, 282, 374, 17, 335, 17, 256, 17, 257, 368, - 256, 0, 1308, 1092, 372, 17, 17, 93, 269, 199, - 200, 97, 98, 99, 100, 101, 102, 103, 104, 17, - 358, 1327, 343, 314, 408, 286, 374, 1247, 657, 157, - 366, 339, 191, 157, 17, 59, 344, 189, 346, 63, - 189, 17, 17, 17, 352, 353, 339, 429, 256, 418, - 363, 344, 157, 346, 157, 256, 368, 256, 363, 352, - 353, 429, 20, 256, 172, 370, 0, 372, 416, 374, - 391, 261, 1288, 363, 256, 256, 1292, 325, 256, 339, - 232, 418, 1004, 232, 1006, 256, 256, 367, 429, 369, - 430, 371, 372, 414, 374, 256, 376, 287, 429, 418, - 1053, 1317, 507, 510, 527, 418, 716, 428, 223, 418, - 422, 157, 418, 418, 1396, 418, 306, 549, 422, 247, - 418, 429, 422, 157, 252, 381, 549, 418, 418, 87, - 88, 228, 418, 157, 418, 157, 429, 157, 418, 247, - 420, 1423, 285, 423, 554, 157, 157, 335, 571, 285, - 108, 259, 295, 1435, 256, 1437, 256, 326, 348, 157, - 288, 320, 256, 317, 372, 293, 294, 321, 277, 579, - 418, 372, 326, 1012, 157, 256, 375, 256, 314, 307, - 781, 157, 157, 157, 312, 368, 314, 369, 381, 313, - 318, 369, 985, 352, 257, 385, 386, 358, 357, 285, - 381, 372, 330, 331, 374, 355, 256, 418, 277, 295, - 394, 395, 281, 256, 300, 323, 257, 428, 1390, 1027, - 328, 822, 823, 413, 414, 256, 658, 355, 256, 858, - 256, 336, 418, 336, 657, 418, 1075, 256, 366, 367, - 1329, 199, 200, 371, 372, 373, 374, 375, 376, 377, - 378, 379, 380, 381, 363, 678, 256, 256, 366, 367, - 341, 285, 1456, 424, 425, 426, 427, 369, 1357, 1358, - 370, 1360, 1277, 342, 374, 403, 435, 429, 372, 889, - 429, 376, 1371, 256, 370, 1374, 868, 439, 369, 700, - 314, 370, 1486, 256, 343, 374, 382, 383, 384, 369, - 1389, 387, 388, 261, 256, 413, 414, 415, 339, 418, - 419, 470, 336, 1106, 654, 363, 371, 367, 373, 431, - 1113, 436, 437, 257, 1413, 368, 376, 442, 929, 287, - 931, 374, 933, 445, 429, 263, 367, 262, 272, 339, - 339, 299, 391, 277, 372, 1138, 372, 281, 306, 368, - 686, 487, 718, 371, 786, 374, 480, 266, 363, 266, - 349, 350, 296, 786, 369, 414, 372, 367, 367, 979, - 418, 368, 371, 298, 373, 374, 375, 376, 486, 428, - 488, 509, 381, 511, 368, 513, 263, 315, 340, 323, - 348, 368, 376, 351, 367, 367, 369, 368, 371, 523, - 524, 371, 420, 511, 376, 314, 369, 314, 342, 537, - 569, 1204, 418, 418, 542, 527, 349, 350, 1019, 527, - 1021, 343, 581, 531, 583, 857, 585, 385, 386, 372, - 349, 350, 429, 343, 305, 858, 294, 561, 315, 368, - 429, 372, 363, 374, 256, 429, 363, 420, 855, 554, - 423, 554, 429, 378, 379, 413, 414, 256, 429, 381, - 588, 589, 570, 487, 368, 264, 375, 372, 375, 391, - 806, 381, 368, 431, 579, 1202, 579, 882, 1425, 1426, - 372, 391, 373, 363, 1085, 376, 429, 445, 363, 648, - 576, 727, 414, 256, 369, 305, 429, 418, 429, 357, - 429, 418, 886, 1142, 414, 363, 428, 635, 369, 668, - 429, 369, 373, 641, 372, 373, 1117, 367, 428, 922, - 1247, 371, 1202, 1202, 429, 429, 325, 339, 386, 637, - 554, 639, 344, 429, 346, 1482, 256, 429, 418, 339, - 352, 353, 305, 418, 344, 21, 346, 1148, 256, 349, - 350, 341, 352, 353, 744, 579, 272, 1139, 686, 272, - 418, 277, 423, 421, 1202, 281, 367, 1247, 1247, 527, - 420, 982, 700, 272, 374, 718, 52, 767, 686, 369, - 296, 373, 679, 296, 376, 305, 294, 994, 716, 256, - 1191, 549, 782, 721, 381, 703, 750, 296, 265, 272, - 267, 374, 357, 270, 391, 414, 1207, 323, 275, 1247, - 323, 947, 279, 571, 369, 357, 370, 372, 373, 428, - 374, 288, 746, 296, 323, 418, 342, 414, 295, 429, - 1202, 386, 718, 300, 339, 428, 764, 304, 766, 1202, - 376, 428, 1202, 416, 386, 753, 770, 339, 772, 316, - 323, 318, 344, 781, 346, 322, 401, 349, 350, 386, - 352, 353, 367, 330, 331, 391, 421, 334, 413, 859, - 337, 376, 877, 801, 391, 1247, 357, 785, 806, 807, - 832, 809, 374, 888, 1247, 1063, 376, 1247, 414, 713, - 1097, 715, 373, 801, 822, 823, 363, 414, 806, 657, - 1110, 339, 428, 381, 414, 386, 344, 294, 346, 1201, - 1202, 349, 350, 391, 352, 353, 824, 367, 428, 306, - 678, 371, 1100, 373, 374, 853, 376, 855, 840, 369, - 1222, 381, 1142, 256, 376, 759, 414, 429, 762, 898, - 371, 381, 870, 1025, 357, 6, 269, 1308, 845, 877, - 418, 418, 980, 357, 1090, 1247, 17, 1249, 1136, 887, - 373, 889, 952, 286, 1174, 415, 384, 370, 1378, 373, - 61, 374, 367, 386, 65, 66, 67, 379, 69, 70, - 1008, 376, 386, 74, 75, 893, 744, 895, 306, 306, - 81, 429, 83, 901, 85, 313, 313, 367, 59, 90, - 91, 929, 63, 931, 367, 933, 376, 325, 371, 767, - 373, 374, 373, 376, 306, 376, 308, 925, 381, 947, - 1151, 313, 389, 114, 782, 367, 87, 88, 786, 385, - 1440, 1209, 944, 325, 376, 1258, 368, 367, 1127, 947, - 400, 367, 374, 1266, 1003, 369, 376, 108, 372, 381, - 376, 979, 415, 367, 982, 963, 390, 954, 339, 956, - 370, 958, 376, 344, 369, 346, 370, 1477, 349, 350, - 374, 352, 353, 418, 1277, 382, 383, 387, 388, 1219, - 371, 370, 840, 1499, 1500, 374, 398, 399, 1012, 396, - 397, 1019, 357, 1021, 415, 1023, 157, 256, 363, 370, - 858, 859, 418, 374, 369, 418, 93, 372, 373, 374, - 97, 98, 99, 100, 101, 102, 103, 104, 376, 339, - 1034, 386, 277, 371, 344, 373, 346, 370, 371, 349, - 350, 374, 352, 353, 374, 1063, 376, 376, 199, 200, - 367, 381, 370, 371, 373, 373, 374, 375, 429, 1077, - 1078, 1075, 371, 418, 373, 376, 372, 1085, 374, 376, - 376, 985, 1090, 254, 922, 1091, 257, 294, 367, 1097, - 369, 294, 1100, 392, 393, 1127, 343, 1129, 1127, 386, - 387, 388, 1090, 1390, 372, 372, 944, 374, 372, 1117, - 374, 376, 368, 412, 952, 371, 1124, 373, 374, 1151, - 261, 420, 1151, 414, 423, 1110, 297, 1110, 1136, 429, - 1200, 372, 374, 374, 376, 376, 392, 393, 339, 310, - 1148, 1149, 418, 344, 285, 346, 287, 370, 418, 372, - 1182, 352, 353, 374, 369, 376, 412, 1142, 299, 1142, - 391, 392, 393, 394, 420, 306, 370, 423, 372, 1201, - 1202, 376, 1201, 314, 370, 261, 372, 370, 374, 372, - 370, 374, 372, 1191, 370, 418, 372, 1257, 375, 1174, - 1222, 1174, 372, 1222, 374, 336, 368, 369, 284, 1207, - 368, 1209, 1106, 372, 1274, 1275, 1110, 348, 372, 1113, - 351, 297, 372, 374, 374, 1247, 302, 1249, 354, 355, - 1249, 307, 372, 309, 310, 311, 312, 1297, 372, 315, - 1300, 317, 294, 300, 1138, 321, 294, 370, 1142, 372, - 354, 355, 367, 1282, 385, 386, 371, 333, 373, 374, - 336, 376, 338, 370, 374, 372, 381, 376, 1262, 374, - 372, 376, 329, 1251, 372, 374, 1305, 376, 374, 374, - 1174, 376, 413, 414, 372, 374, 362, 376, 368, 369, - 1319, 256, 368, 369, 0, 414, 415, 364, 365, 349, - 350, 371, 1130, 372, 373, 364, 365, 1336, 374, 1338, - 1204, 1095, 1096, 370, 389, 390, 395, 396, 294, 1313, - 375, 482, 294, 381, 356, 382, 383, 384, 372, 374, - 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, - 397, 398, 399, 400, 401, 402, 1368, 373, 375, 374, - 373, 381, 372, 418, 376, 1183, 487, 374, 374, 374, - 374, 368, 523, 1385, 371, 429, 373, 374, 372, 423, - 367, 374, 1200, 372, 421, 373, 1398, 1399, 372, 343, - 1378, 374, 1376, 294, 294, 392, 393, 374, 370, 418, - 371, 375, 1390, 367, 418, 256, 527, 256, 256, 374, - 256, 381, 280, 1425, 1426, 412, 256, 367, 343, 1407, - 368, 372, 371, 420, 376, 256, 423, 370, 549, 376, - 374, 376, 374, 554, 372, 370, 372, 423, 372, 1257, - 1258, 381, 347, 351, 367, 256, 256, 376, 1266, 381, - 571, 381, 1440, 372, 368, 347, 1274, 1275, 579, 1277, - 507, 374, 372, 370, 375, 1283, 370, 370, 367, 375, - 1482, 348, 368, 339, 348, 372, 374, 1295, 368, 1297, - 374, 418, 1300, 376, 375, 418, 367, 367, 367, 1477, - 1308, 356, 0, 368, 381, 371, 368, 368, 376, 1483, - 1484, 374, 372, 337, 368, 305, 1490, 1491, 339, 1327, - 371, 1499, 1500, 344, 371, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, 369, 371, 367, 576, - 418, 1499, 1500, 418, 418, 418, 657, 368, 376, 370, - 381, 372, 371, 374, 375, 376, 371, 373, 371, 418, - 367, 381, 371, 384, 385, 369, 371, 678, 389, 390, - 256, 381, 374, 372, 372, 261, 262, 398, 399, 400, - 401, 373, 402, 403, 404, 405, 406, 407, 408, 409, - 410, 411, 413, 0, 373, 256, 374, 374, 284, 374, - 418, 372, 713, 376, 715, 372, 370, 418, 429, 381, - 376, 297, 298, 376, 372, 418, 302, 376, 372, 305, - 367, 307, 418, 309, 310, 311, 312, 372, 368, 381, - 372, 317, 370, 744, 368, 321, 315, 263, 371, 325, - 371, 368, 372, 372, 0, 0, 367, 333, 759, 368, - 336, 762, 338, 339, 376, 372, 767, 0, 344, 368, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 782, 376, 372, 372, 786, 362, 363, 370, 418, - 367, 367, 368, 376, 370, 371, 372, 373, 374, 375, - 376, 368, 378, 379, 368, 381, 382, 383, 384, 385, - 386, 387, 388, 389, 390, 372, 392, 393, 394, 395, - 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, - 406, 407, 408, 409, 410, 411, 412, 413, 376, 370, - 416, 367, 418, 418, 420, 418, 376, 423, 368, 372, - 372, 376, 376, 429, 368, 376, 368, 858, 859, 372, - 367, 372, 368, 372, 368, 367, 376, 315, 256, 257, - 373, 376, 263, 50, 0, 376, 264, 265, 266, 267, - 268, 376, 270, 271, 376, 273, 274, 275, 276, 277, - 278, 279, 280, 376, 376, 376, 376, 285, 12, 287, - 288, 289, 290, 291, 292, 5, 944, 295, 840, 1090, - 1249, 299, 300, 1090, 302, 303, 304, 1222, 1430, 1393, - 1446, 922, 1381, 1410, 1376, 1295, 314, 1283, 316, 1491, - 318, 319, 1247, 1314, 322, 678, 324, 325, 326, 327, - 328, 329, 330, 331, 332, 333, 334, 335, 861, 337, - 861, 952, 340, 341, 861, 882, 344, 345, 692, 256, - 1235, 1485, 1403, 1399, 1398, 262, 857, 1484, 1182, 1338, - 1283, 359, 360, 361, 362, 363, 832, 527, 882, 367, - 368, 1183, 721, 371, 985, 806, 589, 366, 376, 377, - 378, 379, 380, 801, 994, 71, 384, 332, 386, 686, - 397, 298, 718, 398, 392, 393, 399, 401, 400, 549, - 1165, 786, 402, 0, 1257, 157, 1174, 981, 1110, 1055, - 1078, 1008, 965, 1066, 1068, 1139, 525, 903, 1253, 417, - 418, 419, 420, 837, 422, 421, 1149, 838, -1, -1, - -1, 429, 339, -1, -1, -1, -1, 344, -1, 346, + 516, 4, 51, 17, 300, 234, 6, 51, 18, 189, + 247, 17, 518, 17, 354, 470, 289, 188, 232, 299, + 84, 68, 20, 492, 339, 59, 321, 157, 559, 332, + 354, 59, 780, 296, 298, 747, 645, 646, 576, 934, + 87, 88, 87, 88, 58, 92, 1145, 1146, 47, 113, + 1110, 115, 191, 584, 0, 73, 721, 77, 723, 77, + 256, 1235, 17, 108, 328, 79, 256, 81, 939, 256, + 113, 256, 115, 256, 256, 256, 325, 95, 268, 1253, + 256, 256, 363, 1193, 256, 277, 282, 372, 369, 374, + 256, 256, 335, 256, 256, 1194, 368, 256, 17, 256, + 17, 17, 767, 1213, 1219, 770, 256, 17, 256, 256, + 268, 1442, 1443, 268, 376, 371, 382, 383, 314, 418, + 394, 395, 370, 371, 414, 172, 374, 665, 17, 428, + 396, 397, 369, 17, 17, 0, 1105, 418, 428, 157, + 189, 17, 17, 157, 429, 189, 418, 411, 17, 1264, + 17, 157, 339, 157, 199, 200, 257, 344, 256, 346, + 343, 294, 349, 350, 420, 352, 353, 429, 1499, 418, + 59, 363, 256, 306, 63, 256, 256, 268, 363, 256, + 789, 256, 358, 232, 323, 276, 429, 374, 232, 256, + 256, 256, 532, 340, 1304, 1066, 0, 372, 1308, 381, + 247, 367, 157, 369, 363, 371, 435, 816, 391, 512, + 368, 370, 259, 372, 554, 374, 355, 262, 724, 381, + 434, 360, 418, 1333, 223, 375, 418, 419, 228, 247, + 554, 414, 422, 418, 252, 515, 576, 418, 157, 1413, + 157, 157, 429, 288, 559, 428, 418, 157, 424, 425, + 426, 427, 286, 418, 420, 418, 320, 423, 286, 418, + 324, 418, 296, 308, 422, 329, 1440, 422, 157, 584, + 418, 289, 363, 157, 157, 1023, 294, 295, 1452, 326, + 1454, 157, 157, 381, 331, 418, 329, 367, 157, 317, + 157, 309, 376, 256, 375, 256, 376, 315, 375, 317, + 375, 440, 316, 321, 370, 370, 351, 374, 374, 374, + 910, 257, 256, 256, 256, 333, 334, 256, 256, 358, + 256, 372, 369, 370, 372, 665, 256, 418, 1040, 867, + 372, 996, 941, 339, 943, 339, 475, 946, 358, 368, + 358, 1089, 666, 388, 389, 256, 686, 1407, 325, 256, + 262, 369, 370, 368, 363, 368, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 384, 357, 263, 416, + 417, 416, 417, 420, 1473, 256, 1345, 256, 429, 374, + 257, 429, 256, 373, 256, 434, 298, 429, 406, 374, + 434, 256, 20, 367, 900, 444, 386, 286, 1293, 341, + 429, 363, 376, 418, 1503, 1374, 1375, 368, 1377, 418, + 879, 374, 294, 374, 709, 1015, 429, 1017, 368, 1388, + 315, 416, 1391, 1032, 368, 1034, 1035, 369, 317, 372, + 374, 416, 371, 662, 372, 574, 372, 1406, 436, 369, + 484, 418, 441, 442, 491, 256, 493, 586, 447, 588, + 339, 590, 450, 257, 794, 1120, 418, 694, 369, 87, + 88, 1430, 1127, 726, 492, 372, 378, 379, 272, 516, + 794, 485, 701, 277, 339, 357, 256, 281, 277, 429, + 108, 363, 281, 266, 990, 532, 1151, 369, 369, 536, + 372, 373, 296, 372, 263, 369, 514, 369, 516, 266, + 518, 372, 367, 343, 386, 368, 371, 368, 373, 374, + 375, 376, 368, 376, 528, 529, 381, 656, 368, 323, + 341, 256, 1131, 401, 542, 306, 370, 867, 575, 547, + 374, 314, 313, 294, 532, 413, 418, 676, 342, 421, + 1205, 381, 866, 342, 363, 306, 315, 314, 369, 256, + 369, 391, 566, 559, 1163, 559, 367, 363, 429, 294, + 371, 256, 373, 374, 256, 376, 429, 256, 429, 363, + 381, 199, 200, 429, 414, 593, 594, 814, 584, 429, + 584, 343, 369, 335, 864, 256, 373, 367, 428, 1311, + 893, 371, 375, 373, 374, 642, 376, 644, 1207, 418, + 343, 381, 1324, 492, 415, 735, 653, 372, 375, 21, + 367, 1219, 418, 305, 371, 1224, 305, 418, 391, 381, + 1219, 1343, 640, 305, 418, 1156, 272, 645, 646, 391, + 648, 277, 339, 897, 262, 281, 423, 344, 934, 346, + 52, 414, 349, 350, 339, 352, 353, 694, 391, 344, + 296, 346, 414, 418, 349, 350, 1264, 352, 353, 371, + 288, 373, 256, 420, 711, 1264, 428, 374, 339, 272, + 559, 414, 300, 344, 357, 346, 694, 323, 349, 350, + 308, 352, 353, 1152, 1219, 428, 369, 687, 272, 372, + 373, 709, 726, 296, 758, 584, 342, 256, 993, 1219, + 256, 305, 1219, 386, 272, 1219, 724, 752, 264, 339, + 269, 729, 296, 339, 761, 373, 373, 414, 1219, 376, + 323, 958, 429, 351, 256, 1005, 354, 286, 296, 1264, + 775, 428, 390, 391, 429, 369, 357, 367, 421, 323, + 754, 367, 363, 357, 1264, 790, 793, 1264, 369, 376, + 1264, 372, 373, 374, 772, 323, 774, 888, 429, 256, + 388, 389, 809, 1264, 778, 386, 780, 814, 899, 325, + 909, 789, 386, 367, 368, 369, 376, 371, 372, 950, + 374, 368, 376, 381, 269, 1218, 1219, 374, 416, 417, + 371, 809, 841, 391, 381, 367, 814, 418, 816, 357, + 818, 286, 391, 381, 1077, 256, 1239, 339, 436, 1124, + 398, 399, 344, 391, 346, 373, 414, 349, 350, 357, + 352, 353, 450, 868, 418, 414, 420, 871, 386, 423, + 1110, 1264, 721, 1266, 723, 373, 414, 368, 369, 428, + 1113, 1156, 339, 386, 862, 991, 864, 344, 386, 346, + 428, 849, 349, 350, 854, 352, 353, 904, 418, 906, + 306, 371, 308, 881, 306, 912, 1103, 313, 428, 1324, + 888, 313, 339, 1019, 1189, 1014, 1149, 367, 767, 325, + 898, 770, 900, 325, 373, 418, 376, 376, 339, 1395, + 937, 369, 371, 344, 373, 346, 256, 429, 349, 350, + 367, 352, 353, 381, 532, 379, 367, 368, 367, 376, + 367, 958, 384, 392, 393, 376, 368, 376, 963, 376, + 367, 368, 367, 941, 376, 943, 554, 974, 946, 376, + 368, 376, 429, 412, 1274, 256, 374, 385, 376, 368, + 958, 420, 1282, 372, 423, 374, 368, 376, 576, 389, + 372, 1457, 1166, 1226, 376, 370, 400, 955, 368, 374, + 1140, 371, 368, 373, 374, 965, 372, 967, 374, 969, + 376, 373, 990, 368, 376, 993, 370, 390, 429, 339, + 374, 376, 392, 393, 344, 369, 346, 370, 1494, 349, + 350, 374, 352, 353, 418, 372, 374, 1293, 376, 376, + 1516, 1517, 412, 381, 261, 354, 355, 1236, 372, 1023, + 420, 372, 376, 423, 1032, 376, 1034, 1035, 339, 1037, + 372, 371, 374, 344, 376, 346, 415, 284, 349, 350, + 6, 352, 353, 418, 370, 370, 372, 665, 374, 374, + 297, 17, 372, 256, 1047, 302, 376, 370, 305, 372, + 307, 374, 309, 310, 311, 312, 1103, 277, 686, 1077, + 317, 1105, 370, 371, 321, 373, 374, 375, 325, 429, + 386, 387, 388, 1091, 1092, 1089, 333, 369, 418, 336, + 372, 338, 371, 59, 373, 1103, 367, 63, 369, 354, + 355, 1140, 1110, 1142, 1104, 1113, 1140, 394, 395, 396, + 397, 372, 372, 374, 374, 362, 370, 996, 372, 367, + 368, 87, 88, 1131, 374, 376, 376, 1166, 1124, 1137, + 1124, 370, 1166, 372, 752, 376, 370, 1407, 372, 367, + 367, 1149, 108, 371, 373, 373, 374, 370, 376, 372, + 372, 294, 374, 381, 294, 1163, 1164, 775, 1197, 372, + 1156, 374, 1156, 370, 370, 372, 372, 364, 365, 1298, + 343, 418, 790, 374, 376, 376, 794, 368, 369, 1218, + 1219, 374, 1217, 376, 1218, 372, 374, 415, 376, 414, + 415, 157, 1321, 1189, 374, 1189, 376, 372, 373, 1207, + 1239, 364, 365, 1108, 1109, 1239, 1335, 392, 393, 398, + 399, 376, 376, 418, 414, 356, 1224, 369, 1226, 418, + 59, 375, 418, 372, 1353, 1264, 1355, 1266, 372, 376, + 1267, 849, 1266, 199, 200, 368, 374, 372, 1273, 294, + 372, 1120, 294, 374, 372, 1124, 372, 374, 1127, 867, + 868, 372, 376, 371, 93, 1290, 1291, 256, 97, 98, + 99, 100, 101, 102, 103, 104, 374, 294, 294, 381, + 372, 374, 1151, 373, 1278, 373, 375, 1156, 1313, 61, + 374, 1316, 418, 65, 66, 67, 381, 69, 70, 372, + 374, 372, 74, 75, 374, 374, 262, 374, 423, 81, + 429, 83, 374, 85, 367, 421, 372, 372, 90, 91, + 1189, 1345, 373, 343, 374, 294, 934, 294, 374, 370, + 286, 418, 288, 371, 367, 1329, 1205, 418, 375, 256, + 256, 256, 114, 374, 300, 256, 381, 955, 280, 256, + 1374, 1375, 308, 1377, 367, 963, 1385, 368, 372, 343, + 368, 317, 371, 371, 1388, 373, 374, 1391, 351, 370, + 376, 374, 374, 1402, 372, 370, 376, 381, 372, 372, + 423, 347, 1406, 339, 392, 393, 1415, 1416, 367, 381, + 381, 256, 256, 347, 372, 351, 372, 1395, 354, 1393, + 368, 376, 374, 339, 412, 370, 1430, 370, 370, 1407, + 348, 375, 420, 1442, 1443, 423, 368, 372, 348, 418, + 368, 374, 418, 372, 367, 376, 1424, 367, 261, 368, + 367, 381, 388, 389, 356, 376, 371, 368, 337, 93, + 374, 368, 368, 97, 98, 99, 100, 101, 102, 103, + 104, 284, 372, 305, 367, 369, 374, 286, 418, 1457, + 416, 417, 371, 371, 297, 371, 376, 296, 371, 302, + 1499, 418, 305, 302, 307, 373, 309, 310, 311, 312, + 381, 371, 254, 367, 317, 257, 371, 381, 321, 1516, + 1517, 369, 325, 418, 418, 418, 1494, 371, 373, 372, + 333, 372, 374, 336, 373, 338, 1500, 1501, 374, 256, + 372, 374, 372, 1507, 1508, 376, 418, 370, 1516, 1517, + 376, 418, 418, 372, 381, 376, 298, 418, 376, 362, + 372, 367, 372, 368, 381, 1143, 492, 368, 370, 256, + 315, 313, 372, 263, 373, 371, 261, 371, 368, 372, + 372, 0, 0, 367, 372, 376, 385, 386, 387, 368, + 0, 390, 391, 368, 372, 372, 370, 367, 418, 284, + 368, 368, 0, 372, 370, 367, 532, 418, 368, 418, + 373, 376, 297, 372, 368, 418, 372, 302, 376, 376, + 372, 1199, 307, 376, 309, 310, 311, 312, 554, 368, + 367, 372, 317, 559, 368, 368, 321, 372, 376, 1217, + 367, 315, 263, 50, 376, 376, 376, 376, 333, 12, + 576, 336, 339, 338, 376, 376, 376, 344, 584, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, - 357, -1, -1, -1, -1, -1, 363, -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, 1106, -1, -1, -1, 1110, - -1, -1, 1113, -1, -1, -1, 413, -1, -1, 416, - -1, 418, -1, 420, -1, -1, 423, -1, -1, 1130, - -1, 257, 429, -1, 256, 261, -1, 1138, -1, 0, - -1, 1142, -1, -1, -1, -1, 272, -1, -1, -1, - -1, 277, -1, -1, -1, 281, -1, -1, 284, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 296, 297, -1, 1174, -1, 301, 302, -1, -1, -1, - -1, 307, 1183, 309, 310, 311, 312, -1, -1, -1, - -1, 317, -1, -1, -1, 321, -1, 323, -1, 1200, - -1, -1, -1, 1204, -1, -1, -1, 333, -1, 335, - 336, -1, 338, -1, -1, -1, 342, 339, -1, -1, - -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, 362, -1, -1, -1, - -1, -1, 368, 369, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, 1257, 1258, -1, -1, - -1, -1, -1, -1, -1, 1266, -1, -1, 390, 256, - 257, -1, -1, 1274, 1275, -1, 1277, 264, 265, 266, - 267, 268, -1, 270, 271, 0, 273, 274, 275, 276, - 277, 278, 279, -1, -1, -1, 1297, -1, 285, 1300, - 287, 288, 289, 290, 291, 292, -1, 429, 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, 256, -1, 384, -1, 386, - 261, 262, -1, -1, -1, 392, 393, -1, -1, -1, - -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, - -1, -1, -1, 284, -1, -1, -1, -1, -1, -1, - 417, 418, 419, 420, -1, 422, 297, 298, -1, -1, - -1, 302, 429, -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, 363, -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, 256, -1, -1, -1, 0, 261, 262, -1, -1, - -1, -1, 413, -1, -1, 416, -1, 418, -1, 420, - -1, -1, 423, -1, -1, -1, -1, -1, 429, 284, + 376, 5, 955, 849, 1266, 1447, 1103, 362, 302, 364, + 365, 368, 1103, 370, 1239, 372, 1410, 374, 375, 376, + 686, 1427, 1398, 1463, 1393, 1273, 1274, 1299, 700, 871, + 871, 1311, 871, 390, 1282, 0, 1508, 1264, 332, 1252, + 1330, 866, 1290, 1291, 401, 1293, 1502, 1420, 256, 1416, + 1415, 1299, 1501, 1197, 1355, 1299, 413, 1199, 841, 381, + 729, 814, 809, 1311, 532, 1313, 594, 369, 1316, 665, + 1005, 893, 429, 694, 71, 487, 1324, 335, 401, 373, + 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, + 686, 385, 386, 387, 400, 1343, 390, 391, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, + 404, 405, 581, 726, 402, 404, 528, 403, 405, 1178, + 794, 157, 1124, 554, 1273, 721, 1189, 723, 1068, 992, + 1092, 339, 1019, 1080, 1082, 1152, 344, 530, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, 425, + 914, 425, 976, 651, 1269, 847, 752, 1164, 846, -1, + 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, + -1, 767, -1, -1, 770, -1, -1, -1, -1, 775, + -1, -1, 390, -1, -1, -1, -1, -1, 256, 257, + -1, -1, -1, 261, 790, -1, -1, 265, 794, 267, + -1, -1, 270, -1, 272, 273, 0, 275, -1, 277, + -1, 279, -1, 281, 282, 283, 284, -1, 512, 287, + 288, 429, -1, -1, -1, 293, -1, 295, 296, 297, + -1, -1, 300, 301, 302, -1, 304, -1, -1, 307, + -1, 309, 310, 311, 312, -1, -1, -1, 316, 317, + 318, -1, -1, 321, 322, 323, -1, 726, -1, -1, + -1, -1, 330, 331, -1, 333, 334, -1, 336, 337, + 338, 867, 868, -1, 342, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 581, -1, -1, + -1, 256, -1, -1, 362, 0, 261, 262, -1, -1, + 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 284, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -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, 363, 0, - -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, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 413, 284, - -1, 416, -1, 418, -1, 420, -1, -1, 423, -1, - -1, -1, 297, 298, 429, -1, -1, 302, -1, -1, + -1, -1, 297, 298, -1, -1, -1, 302, 934, -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, + 418, -1, 317, -1, -1, -1, 321, -1, -1, -1, + 325, -1, -1, -1, -1, -1, -1, 963, 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, 363, -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, -1, 0, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 413, 284, - -1, 416, -1, 418, -1, 420, -1, -1, 423, -1, - -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, 0, 256, -1, 362, 363, -1, - -1, 262, 367, 368, -1, 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, 298, -1, -1, - -1, 0, -1, -1, -1, -1, -1, -1, 413, -1, - -1, 416, -1, 418, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 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, 363, -1, 0, -1, 367, 368, -1, 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, -1, -1, -1, -1, -1, 0, -1, -1, - -1, -1, 413, -1, -1, 416, -1, 418, -1, -1, - -1, -1, -1, -1, 256, 257, -1, -1, 429, 261, - -1, -1, -1, 265, -1, 267, -1, -1, 270, -1, - 272, 273, -1, 275, -1, 277, -1, 279, -1, 281, - 282, 283, 284, -1, -1, 287, 288, -1, -1, -1, - -1, 293, -1, 295, 296, 297, -1, -1, 300, 301, - 302, -1, 304, -1, -1, 307, -1, 309, 310, 311, - 312, 0, -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, 257, -1, -1, -1, 261, -1, -1, -1, -1, - -1, -1, -1, -1, 0, -1, 272, -1, -1, -1, - 362, 277, -1, -1, -1, 281, 368, 369, 284, -1, - -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, - 296, 297, -1, -1, -1, 301, 302, -1, 257, -1, - -1, 307, 261, 309, 310, 311, 312, 0, -1, -1, - -1, 317, -1, 272, -1, 321, -1, 323, 277, -1, - -1, -1, 281, -1, -1, 284, 418, 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, - 0, -1, -1, -1, 333, -1, 272, 336, -1, 338, - -1, 277, -1, 342, -1, 281, -1, -1, 284, -1, + 996, -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, + -1, 416, -1, 418, -1, 420, -1, 0, 423, -1, + -1, -1, -1, 257, 429, -1, -1, 261, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 272, -1, + -1, -1, -1, 277, -1, -1, -1, 281, -1, -1, + 284, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 296, 297, -1, -1, -1, 301, 302, -1, + -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, -1, -1, 317, 1120, -1, -1, 321, 1124, 323, + -1, 1127, -1, -1, -1, -1, -1, -1, -1, 333, + -1, 335, 336, -1, 338, -1, -1, 1143, 342, -1, + -1, -1, 257, 256, -1, 1151, 261, -1, -1, -1, + 1156, -1, -1, -1, -1, -1, -1, 272, 362, -1, + -1, -1, 277, -1, 368, 369, 281, -1, -1, 284, -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, 0, -1, 272, - -1, 317, -1, -1, 277, 321, -1, 323, 281, -1, - -1, 284, -1, -1, -1, -1, -1, 333, -1, -1, - 336, -1, 338, 296, 297, -1, 342, -1, 301, 302, - -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, - -1, -1, -1, -1, 317, -1, 362, -1, 321, -1, - 323, -1, 368, 369, -1, -1, -1, -1, 257, -1, - 333, -1, 261, 336, 0, 338, -1, -1, -1, 342, - -1, -1, -1, 272, -1, -1, -1, -1, 277, -1, - -1, -1, 281, -1, -1, 284, -1, -1, -1, 362, - -1, -1, -1, -1, -1, -1, 369, 296, 297, -1, - -1, 257, 301, 302, -1, 261, -1, -1, 307, -1, + -1, 296, 297, 1189, -1, -1, 301, 302, -1, 893, + -1, -1, 307, 1199, 309, 310, 311, 312, -1, 1205, + -1, -1, 317, -1, -1, -1, 321, -1, 323, -1, + -1, 1217, -1, -1, 0, -1, -1, -1, 333, -1, + 335, 336, -1, 338, -1, -1, 339, 342, -1, -1, + -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, 362, -1, -1, + -1, -1, -1, -1, 369, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, -1, -1, 1273, 1274, -1, + -1, -1, -1, -1, -1, -1, 1282, 390, -1, -1, + -1, -1, -1, -1, 1290, 1291, -1, 1293, 401, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 413, -1, -1, 256, 257, -1, -1, 1313, -1, -1, + 1316, 264, 265, 266, 267, 268, 429, 270, 271, -1, + 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, + -1, -1, 285, -1, 287, 288, 289, 290, 291, 292, + 0, -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, -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, -1, 422, + 256, 257, -1, -1, -1, -1, 429, -1, 264, 265, + 266, 267, 268, -1, 270, 271, 0, 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, 368, -1, -1, 371, -1, -1, -1, -1, + 376, 377, 378, 379, 380, -1, 256, -1, 384, -1, + 386, 261, 262, -1, -1, -1, 392, 393, -1, -1, + -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, + -1, -1, -1, -1, 284, -1, -1, -1, -1, -1, + -1, 417, 418, 419, 420, -1, 422, 297, 298, -1, + -1, -1, 302, 429, -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, 363, -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, 256, -1, -1, -1, 0, 261, 262, -1, + -1, -1, -1, 413, -1, -1, 416, -1, 418, -1, + 420, -1, -1, 423, -1, -1, -1, -1, -1, 429, + 284, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -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, 363, + 0, -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, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 413, + 284, -1, 416, -1, 418, -1, 420, -1, -1, 423, + -1, -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, 363, + -1, -1, -1, 367, 368, 369, 370, 371, 372, -1, + 374, 375, 376, -1, 378, 379, 0, -1, 382, 383, + 384, 385, 256, -1, -1, 389, 390, 261, 262, -1, + 394, 395, 396, 397, 398, 399, 400, 401, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 413, + 284, -1, 416, -1, 418, -1, 420, -1, -1, 423, + -1, -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, 256, -1, 362, 363, + -1, -1, 262, 367, 368, -1, 370, 371, 372, -1, + 374, 375, 376, -1, 378, 379, 0, -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, 416, -1, 418, -1, -1, -1, -1, 0, + -1, -1, -1, -1, -1, 429, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 339, + -1, -1, 256, -1, 344, -1, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, + -1, -1, 0, 363, -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, 256, -1, -1, 0, -1, -1, 262, -1, + -1, -1, -1, 413, -1, -1, 416, -1, 418, -1, + 420, -1, -1, 423, -1, 339, -1, -1, -1, 429, + 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, -1, 298, -1, -1, -1, 0, -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, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, + 344, 0, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, -1, -1, -1, -1, -1, -1, 363, + -1, -1, -1, 367, 368, 429, 370, 371, 372, -1, + 374, 375, 376, -1, 378, 379, -1, -1, 382, 383, + 384, 385, -1, 257, 0, 389, 390, 261, -1, -1, + 394, 395, 396, 397, 398, 399, 400, 401, 272, -1, + -1, -1, -1, 277, -1, -1, -1, 281, -1, 413, + 284, -1, 416, -1, 418, -1, -1, -1, -1, -1, + -1, -1, 296, 297, -1, 429, 257, 301, 302, -1, + 261, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, 272, -1, 317, -1, -1, 277, 321, -1, 323, + 281, 0, -1, 284, -1, -1, -1, -1, -1, 333, + -1, -1, 336, -1, 338, 296, 297, -1, 342, 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, 0, -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, 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, 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, - -1, 277, 321, -1, 323, 281, -1, -1, 284, -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, 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, -1, 321, -1, - 323, 257, -1, -1, -1, 261, -1, -1, -1, -1, - 333, -1, -1, 336, -1, 338, 272, -1, -1, 342, - -1, 277, -1, -1, -1, 281, -1, -1, 284, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 362, - 296, 297, -1, -1, -1, 301, 302, -1, -1, -1, + 296, 297, -1, 342, -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, 317, -1, 362, -1, 321, -1, 323, 257, -1, + -1, -1, 261, -1, -1, -1, -1, 333, -1, -1, + 336, -1, 338, 272, -1, -1, 342, -1, 277, -1, + -1, -1, 281, -1, -1, 284, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 362, 296, 297, -1, + -1, -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, -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, 357, -1, -1, -1, -1, -1, 363, 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, -1, -1, 423, -1, -1, -1, -1, -1, 429, + -1, 285, 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, -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, 363, 298, -1, -1, -1, 368, 369, + 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, + 256, 378, 379, 327, 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, -1, -1, -1, -1, + -1, -1, 429, 377, 378, 379, 380, -1, 382, 383, + 384, 385, 386, 387, 388, 389, -1, -1, 392, 393, + 394, 395, 396, 397, 398, 399, -1, -1, -1, -1, + 298, -1, -1, 339, -1, -1, -1, -1, 344, -1, + 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, + -1, -1, 368, -1, 370, 262, 372, -1, 374, 375, + 376, 339, -1, -1, -1, -1, 344, -1, 346, 347, + 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 367, + 368, 298, 370, 371, 372, 373, 374, 375, 376, -1, + 378, 379, -1, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 429, 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, 363, -1, -1, -1, + -1, 368, 369, -1, 371, 372, 373, 374, -1, 376, + -1, 378, 379, -1, 381, 382, 383, 384, 385, 298, + 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, 418, -1, 420, -1, -1, 423, -1, -1, -1, + 339, -1, 429, -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, + 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, + -1, -1, -1, -1, 344, -1, 346, 347, 348, 349, + 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, + -1, -1, -1, -1, 363, -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, -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, -1, -1, 423, - -1, -1, -1, -1, -1, 429, -1, 285, 339, -1, + 410, 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, 367, 368, 369, 370, - 371, 372, 373, 374, 375, 376, 256, 378, 379, 327, + -1, -1, -1, -1, -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, -1, -1, -1, -1, 420, - 262, -1, -1, -1, -1, -1, -1, -1, 429, 377, - 378, 379, 380, -1, 382, 383, 384, 385, 386, 387, - 388, 389, -1, -1, 392, 393, 394, 395, 396, 397, - 398, 399, -1, -1, -1, -1, 298, -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, 256, -1, -1, 368, -1, - 370, 262, 372, -1, 374, 375, 376, 339, -1, -1, + 411, 412, 413, -1, 256, -1, 261, -1, 418, 420, + 262, -1, 423, -1, -1, -1, -1, -1, 429, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 284, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 297, -1, -1, -1, 298, 302, -1, -1, + -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, + -1, -1, 317, -1, -1, -1, 321, -1, -1, 256, + 325, -1, -1, -1, -1, 262, -1, -1, 333, 266, + -1, 336, -1, 338, -1, -1, -1, 339, -1, -1, -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 367, 368, 298, 370, 371, - 372, 373, 374, 375, 376, -1, 378, 379, -1, 381, - 382, 383, 384, 385, 386, 387, 388, 389, 390, 429, + 352, 353, 354, 355, 356, -1, -1, 362, -1, -1, + -1, 298, -1, -1, -1, -1, 368, -1, 370, 371, + 372, 373, 374, 375, 376, -1, 378, 314, -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, 363, -1, -1, -1, -1, 368, 369, -1, - 371, 372, 373, 374, -1, 376, -1, 378, 379, -1, - 381, 382, 383, 384, 385, 298, 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, 418, -1, 420, - -1, -1, 423, -1, -1, -1, 339, -1, 429, -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, 256, 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, -1, -1, -1, -1, -1, -1, -1, + 412, 413, -1, 418, -1, -1, -1, -1, 420, -1, + 357, 423, -1, -1, -1, -1, 363, 429, -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, + 256, 418, -1, 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, - -1, -1, -1, -1, 298, -1, -1, 339, -1, -1, - -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -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, -1, -1, -1, -1, -1, -1, -1, - -1, -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, 429, 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, -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, 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, 261, -1, 418, 420, 262, -1, 423, -1, - -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 284, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 297, -1, - -1, -1, 298, 302, -1, -1, 305, -1, 307, -1, - 309, 310, 311, 312, -1, -1, -1, -1, 317, -1, - -1, -1, 321, -1, -1, 256, 325, -1, -1, -1, - -1, 262, -1, -1, 333, 266, -1, 336, -1, 338, - -1, -1, -1, 339, -1, -1, -1, -1, 344, -1, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, 362, -1, -1, -1, 298, -1, -1, - -1, -1, 368, -1, 370, 371, 372, 373, 374, 375, - 376, -1, 378, 314, -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, 418, - -1, -1, -1, -1, 420, -1, 357, 423, -1, -1, - -1, -1, 363, 429, -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, 256, 418, -1, 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, + 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, 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, 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, -1, -1, 307, + -1, 309, 310, 311, 312, -1, -1, -1, -1, 317, + -1, -1, -1, 321, -1, -1, 298, -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, 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, -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, + 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, -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, + 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, 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, + -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, 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, @@ -11645,14 +11960,14 @@ void case_965() 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, + -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, 394, 395, 396, 397, + -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, @@ -11678,15 +11993,15 @@ void case_965() 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, + 376, -1, -1, -1, -1, -1, -1, -1, 384, 385, -1, -1, -1, 389, 390, -1, 256, -1, -1, -1, - 396, 397, 398, 399, 400, 401, -1, -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, 382, 383, 384, 385, -1, -1, - -1, 389, 390, -1, 256, -1, -1, -1, 396, 397, + -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, @@ -11700,7 +12015,7 @@ void case_965() -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, + 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, @@ -11712,7 +12027,7 @@ void case_965() 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, + 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, @@ -11726,7 +12041,7 @@ void case_965() 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, + -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, @@ -11740,75 +12055,24 @@ void case_965() 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, 262, 390, -1, -1, 266, -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, + 356, 298, -1, -1, -1, 429, -1, -1, -1, -1, + -1, -1, 368, -1, 370, -1, 372, 314, 374, 375, 376, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 390, -1, 256, -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, 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, 262, -1, -1, -1, 266, -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, 298, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, 429, - 374, 375, 376, 314, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 390, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 401, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 413, - -1, -1, -1, -1, -1, -1, 357, -1, -1, -1, - -1, -1, 363, -1, -1, 429, -1, 368, 369, -1, - 371, -1, 373, -1, 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, -1, 256, -1, 418, -1, 420, - -1, -1, 423, 264, 265, 266, 267, -1, 429, 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, 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, 266, - 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, + -1, -1, -1, -1, -1, -1, -1, 413, -1, -1, + 357, -1, -1, -1, -1, -1, 363, -1, -1, -1, + -1, 368, 369, 429, 371, -1, 373, -1, 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, -1, 256, + -1, 418, -1, 420, -1, -1, 423, 264, 265, 266, + 267, -1, 429, 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, @@ -11855,98 +12119,39 @@ void case_965() 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, + 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, 368, -1, -1, 371, -1, -1, -1, -1, - -1, 377, 378, 379, 380, -1, -1, -1, 384, -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, + -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, 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, -1, 377, 378, + -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, 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, 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, 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, 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, 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, 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, + -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, @@ -11955,17 +12160,17 @@ void case_965() 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, + 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, 370, -1, -1, -1, -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, + 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, + 288, 306, -1, -1, -1, -1, -1, 295, 313, -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, @@ -11979,6 +12184,65 @@ void case_965() -1, -1, 417, 418, 419, 420, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -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, 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, 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, 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, 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, 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, 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, @@ -11986,7 +12250,7 @@ void case_965() -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, 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, @@ -11994,159 +12258,188 @@ void case_965() -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, + -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, -1, -1, -1, -1, 417, 418, 419, 420, - 371, 372, 373, 374, 375, -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, 263, -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, 294, 295, 296, - 297, -1, -1, 300, -1, 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, 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, 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, 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, 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, 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, 362, -1, 364, 365, 261, - -1, -1, -1, 265, -1, 267, -1, -1, 270, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 417, 418, 419, 420, 371, 372, 373, 374, 375, + -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, 263, -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, 418, -1, -1, 316, 317, 318, -1, -1, 321, + -1, 293, 294, 295, 296, 297, -1, -1, 300, -1, + 302, -1, 304, -1, 306, 307, -1, 309, 310, 311, + 312, -1, -1, 315, 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, -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, -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, -1, 304, -1, -1, 307, -1, 309, - 310, 311, 312, -1, -1, -1, 316, 317, 318, -1, - -1, 321, 322, 323, 418, -1, -1, -1, -1, -1, - 330, 331, -1, 333, 334, -1, 336, 337, 338, -1, - -1, -1, 342, -1, -1, -1, -1, 261, -1, -1, - -1, 265, -1, 267, -1, -1, 270, -1, 272, 273, - -1, 275, 362, 277, -1, 279, -1, 281, 282, 283, - 284, -1, -1, 287, 288, -1, -1, 377, -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, - -1, -1, 284, -1, -1, -1, 330, 331, 418, 333, - 334, -1, 336, 337, 338, 297, -1, -1, 342, -1, - 302, -1, -1, 305, -1, 307, -1, 309, 310, 311, - 312, -1, -1, -1, -1, 317, -1, -1, 362, 321, - -1, -1, -1, 325, 368, -1, -1, 261, -1, -1, - -1, 333, -1, -1, 336, -1, 338, -1, -1, -1, + 362, -1, 364, 365, 261, -1, -1, -1, 265, -1, + 267, -1, -1, 270, -1, 272, 273, -1, 275, -1, + 277, -1, 279, -1, 281, 282, 283, 284, -1, -1, + 287, 288, -1, -1, -1, -1, 293, -1, 295, 296, + 297, -1, -1, 300, -1, 302, -1, 304, -1, -1, + 307, -1, 309, 310, 311, 312, 418, -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, -1, - 284, -1, -1, -1, -1, 357, -1, 261, -1, -1, - 362, -1, -1, 297, -1, -1, -1, 369, 302, 371, - -1, 373, -1, 307, 418, 309, 310, 311, 312, -1, - 284, -1, -1, 317, 386, -1, -1, 321, -1, -1, - -1, 325, -1, 297, -1, -1, -1, -1, 302, 333, - -1, -1, 336, 307, 338, 309, 310, 311, 312, -1, - -1, -1, -1, 317, -1, -1, 418, 321, -1, -1, - -1, -1, -1, -1, 264, 265, -1, 267, 362, 333, - 270, 271, 336, -1, 338, 275, 276, 277, -1, 279, - -1, -1, -1, -1, -1, 285, -1, -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, 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, 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, -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, + -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, -1, 304, + -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, + -1, 316, 317, 318, -1, -1, 321, 322, 323, 418, + -1, -1, -1, -1, -1, 330, 331, -1, 333, 334, + -1, 336, 337, 338, -1, -1, -1, 342, -1, -1, + -1, -1, 261, -1, -1, -1, 265, -1, 267, -1, + -1, 270, -1, 272, 273, -1, 275, 362, 277, -1, + 279, -1, 281, 282, 283, 284, -1, -1, 287, 288, + -1, -1, 377, -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, -1, -1, 284, -1, -1, + -1, 330, 331, 418, 333, 334, -1, 336, 337, 338, + 297, -1, -1, 342, -1, 302, -1, -1, 305, -1, + 307, -1, 309, 310, 311, 312, -1, -1, -1, -1, + 317, -1, -1, 362, 321, -1, -1, -1, 325, 368, + -1, -1, -1, -1, -1, -1, 333, -1, -1, 336, + -1, 338, 264, 265, -1, 267, -1, -1, 270, 271, + -1, -1, -1, 275, 276, 277, -1, 279, -1, -1, + 357, -1, -1, 285, -1, 362, 288, -1, -1, -1, + -1, -1, 369, 295, 371, -1, 373, -1, 300, 418, + 302, 303, 304, -1, 306, -1, -1, -1, -1, 386, + -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, 337, -1, -1, -1, 341, - -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, + 332, -1, 334, -1, -1, -1, -1, -1, -1, 341, + -1, 418, 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, + 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, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -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, 368, -1, -1, 371, -1, -1, -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, @@ -12156,10 +12449,10 @@ void case_965() 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, + 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, 367, -1, -1, + 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, @@ -12173,7 +12466,7 @@ void case_965() 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, -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, @@ -12186,7 +12479,7 @@ void case_965() -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, 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, @@ -12200,7 +12493,7 @@ void case_965() 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, + 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, @@ -12247,121 +12540,144 @@ void case_965() -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, 263, 300, -1, 302, 303, 304, -1, -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, 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, -1, -1, 317, -1, -1, -1, 321, + 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, 333, -1, 371, 336, -1, 338, -1, -1, 377, + -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, - 362, -1, -1, -1, -1, -1, 368, 369, -1, -1, - -1, -1, -1, -1, 263, -1, 265, -1, 267, 417, - 418, 270, 420, 272, 273, -1, 275, -1, 277, -1, - 279, -1, 281, 282, 283, -1, -1, -1, 287, 288, - -1, -1, -1, -1, 293, -1, 295, 296, -1, -1, - -1, 300, -1, -1, -1, 304, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 315, 316, -1, 318, - -1, -1, -1, 322, 323, -1, -1, -1, -1, -1, - -1, 330, 331, 264, 265, 334, 267, -1, 337, 270, - 271, -1, -1, 342, 275, 276, 277, -1, 279, -1, - -1, -1, -1, -1, 285, -1, -1, 288, -1, -1, - -1, -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, 363, -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, 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, 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, -1, -1, -1, -1, 392, 393, -1, -1, + -1, -1, 362, -1, -1, -1, -1, -1, 368, 369, + -1, -1, -1, -1, -1, -1, 263, -1, 265, -1, + 267, 417, 418, 270, 420, 272, 273, -1, 275, -1, + 277, -1, 279, -1, 281, 282, 283, -1, -1, -1, + 287, 288, -1, -1, -1, -1, 293, -1, 295, 296, + -1, -1, -1, 300, -1, -1, -1, 304, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 315, 316, + -1, 318, -1, -1, -1, 322, 323, -1, -1, -1, + -1, -1, -1, 330, 331, 264, 265, 334, 267, -1, + 337, 270, 271, -1, -1, 342, 275, 276, 277, -1, + 279, -1, -1, -1, -1, -1, 285, -1, -1, 288, + -1, -1, -1, -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, 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, + -1, -1, 418, -1, 300, -1, -1, -1, 304, -1, + 306, -1, -1, -1, 265, -1, 267, 313, -1, 270, + 316, -1, 318, -1, 275, -1, 322, -1, 279, 325, + -1, -1, 283, -1, 330, 331, -1, 288, 334, -1, + -1, 337, 293, -1, 295, -1, 418, -1, -1, 300, + -1, -1, -1, 304, 305, -1, -1, -1, 265, -1, + 267, -1, -1, 270, -1, 316, -1, 318, 275, -1, + -1, 322, 279, -1, -1, -1, -1, -1, 418, 330, + 331, 288, 265, 334, 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, 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, 261, 337, -1, -1, 316, -1, 318, - -1, 418, -1, 322, 272, -1, -1, -1, -1, 277, - -1, 330, 331, 281, -1, 334, 284, -1, 337, -1, - -1, -1, -1, -1, -1, 418, -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, 418, 301, 302, -1, -1, - -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, - -1, -1, 317, -1, 362, -1, 321, -1, 323, 418, - 368, 369, -1, -1, -1, 261, -1, -1, 333, -1, - -1, 336, -1, 338, -1, -1, 272, 342, -1, -1, + -1, 304, 418, 330, 331, -1, -1, 334, -1, -1, + 337, -1, -1, 316, -1, 318, 265, -1, 267, 322, + -1, 270, -1, -1, -1, -1, 275, 330, 331, -1, + 279, 334, -1, -1, 337, -1, 363, -1, -1, 288, + -1, -1, -1, -1, -1, -1, 295, 418, -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, 418, -1, -1, 301, 302, -1, -1, -1, -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, -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, 362, -1, -1, - 296, 297, -1, 368, 369, 301, 302, -1, 261, -1, - -1, 307, -1, 309, 310, 311, 312, -1, -1, 272, + -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, @@ -12380,30 +12696,26 @@ void case_965() -1, -1, 307, -1, 309, 310, 311, 312, -1, -1, 315, -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, + 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, -1, - -1, -1, 261, 368, 263, -1, 333, -1, 297, 336, + -1, -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, 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, -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, + 309, 310, 311, 312, -1, 284, 315, -1, 317, -1, + -1, -1, 321, -1, 261, 362, -1, -1, 297, -1, + -1, 368, 301, 302, 333, -1, -1, 336, 307, 338, + 309, 310, 311, 312, -1, -1, -1, 284, 317, -1, -1, -1, 321, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 362, 333, -1, -1, 336, -1, 338, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 297, -1, -1, 362, 333, 302, -1, 336, -1, 338, + 307, -1, 309, 310, 311, 312, -1, -1, -1, -1, + 317, -1, -1, -1, 321, -1, -1, -1, -1, -1, + -1, -1, -1, 362, -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, 362, + -1, -1, -1, -1, -1, 362, }; -#line 6470 "cs-parser.jay" +#line 6611 "cs-parser.jay" // // A class used to hold info about an operator declarator @@ -12617,10 +12929,10 @@ public void parse () report.Error (-25, lexer.Location, "Parsing error"); } else { // Used by compiler-tester to test internal errors - if (yacc_verbose_flag > 0) + if (yacc_verbose_flag > 0 || e is FatalException) throw; - report.Error (589, lexer.Location, "Internal compiler error during parsing"); + report.Error (589, lexer.Location, "Internal compiler error during parsing" + e); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay index 7f9fe163f..6e2e26750 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay @@ -147,6 +147,9 @@ namespace Mono.CSharp Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation; Location savedAttrParenOpenLocation, savedAttrParenCloseLocation, savedOperatorLocation; Stack> locationListStack = new Stack> (); // used for type parameters + Stack opt_intoStack = new Stack (); + + bool HadAttributeParens; List attributeCommas = new List (); List attributeArgumentCommas = new List (); List parameterListCommas = new List (); @@ -397,6 +400,8 @@ outer_declaration Attributes attrs = (Attributes) $4; report.Error (1730, attrs.Attrs [0].Location, "Assembly and module attributes must precede all other elements except using clauses and extern alias declarations"); + + current_namespace.UnattachedAttributes = attrs; } } | opt_extern_alias_directives opt_using_directives attribute_sections @@ -615,9 +620,7 @@ namespace_or_type_declaration current_namespace.DeclarationFound = true; } | attribute_sections CLOSE_BRACE { -#if FULL_AST current_namespace.UnattachedAttributes = (Attributes) $1; -#endif report.Error (1518, lexer.Location, "Attributes must be attached to class, delegate, enum, interface or struct"); lexer.putback ('}'); } @@ -779,6 +782,8 @@ attribute attributeArgumentCommas.Add (savedAttrParenCloseLocation); lbag.AddLocation ($$, attributeArgumentCommas); attributeArgumentCommas.Clear (); + } else if (HadAttributeParens) { + lbag.AddLocation ($$, savedAttrParenOpenLocation, savedAttrParenCloseLocation); } } ; @@ -788,12 +793,13 @@ attribute_name ; opt_attribute_arguments - : /* empty */ { $$ = null; } + : /* empty */ { $$ = null; HadAttributeParens = false; } | OPEN_PARENS attribute_arguments CLOSE_PARENS { savedAttrParenOpenLocation = GetLocation ($1); savedAttrParenCloseLocation = GetLocation ($3); $$ = $2; + HadAttributeParens = true; } ; @@ -1351,6 +1357,23 @@ method_header current_local_parameters = (ParametersCompiled) $7; + if (doc_support) + method.DocComment = Lexer.consume_doc_comment (); + + $$ = method; + } + | opt_attributes + opt_modifiers + member_type + method_declaration_name error + { + Error_SyntaxError (yyToken); + current_local_parameters = ParametersCompiled.Undefined; + + MemberName name = (MemberName) $4; + var method = Method.Create (current_type, (FullNamedExpression) $3, (Modifiers) $2, + name, current_local_parameters, (Attributes) $1, false); + if (doc_support) method.DocComment = Lexer.consume_doc_comment (); @@ -1498,12 +1521,18 @@ fixed_parameter $$ = new Parameter ((FullNamedExpression) $3, lt.Value, (Parameter.Modifier) $2, (Attributes) $1, lt.Location); lbag.AddLocation ($$, parameterModifierLocation); } + | attribute_sections error + { + Error_SyntaxError (yyToken); + Location l = GetLocation ($2); + $$ = new Parameter (null, null, Parameter.Modifier.NONE, (Attributes) $1, l); + } | opt_attributes opt_parameter_modifier parameter_type error { - Error_SyntaxError (yyToken); + Error_SyntaxError (yyToken); Location l = GetLocation ($4); $$ = new Parameter ((FullNamedExpression) $3, null, (Parameter.Modifier) $2, (Attributes) $1, l); lbag.AddLocation ($$, parameterModifierLocation); @@ -2290,6 +2319,7 @@ destructor_declaration Destructor d = new Destructor (current_type, (Modifiers) $2, ParametersCompiled.EmptyReadOnlyParameters, (Attributes) $1, lt.Location); + d.Identifier = lt.Value; if (doc_support) d.DocComment = ConsumeStoredComment (); @@ -2512,10 +2542,9 @@ event_accessor_block ; attributes_without_members - : attribute_sections CLOSE_BRACE { -#if FULL_AST + : attribute_sections CLOSE_BRACE + { current_type.UnattachedAttributes = (Attributes) $1; -#endif report.Error (1519, GetLocation ($1), "An attribute is missing member declaration"); lexer.putback ('}'); } @@ -2541,7 +2570,7 @@ enum_declaration report.Error (1675, name.Location, "Enums cannot have type parameters"); } - push_current_container (new Enum (current_container, (TypeExpression) $5, (Modifiers) $2, name, (Attributes) $1), null); + push_current_container (new Enum (current_container, (FullNamedExpression) $5, (Modifiers) $2, name, (Attributes) $1), null); if ($5 != null) { lbag.AddMember (current_container, GetModifierLocations (), GetLocation ($3), savedLocation, GetLocation ($7)); } else { @@ -2576,14 +2605,8 @@ opt_enum_base : /* empty */ | COLON type { - var te = $2 as TypeExpression; - if (te == null || !EnumSpec.IsValidUnderlyingType (te.Type)) { - Enum.Error_1008 (GetLocation ($2), report); - $$ = null; - } else { - savedLocation = GetLocation ($1); - $$ = $2; - } + savedLocation = GetLocation ($1); + $$ = $2; } | COLON error { @@ -2854,7 +2877,10 @@ opt_type_parameter_list FeatureIsNotAvailable (GetLocation ($1), "generics"); $$ = $2; - lbag.AppendTo ($$, GetLocation ($1), GetLocation ($3)); + var list = locationListStack.Pop (); + list.Add (GetLocation ($1)); + list.Add (GetLocation ($2)); + lbag.AddLocation ($2, list); } ; @@ -2864,13 +2890,14 @@ type_parameters var tparams = new TypeParameters (); tparams.Add ((TypeParameter)$1); $$ = tparams; + locationListStack.Push (new List ()); } | type_parameters COMMA type_parameter { var tparams = (TypeParameters) $1; tparams.Add ((TypeParameter)$3); $$ = tparams; - lbag.AddLocation ($3, GetLocation ($3)); + locationListStack.Peek ().Add (GetLocation ($2)); } ; @@ -3003,11 +3030,6 @@ base_type_name } $$ = $1; } - | error - { - Error_TypeExpected (lexer.Location); - $$ = null; - } ; /* @@ -3249,8 +3271,10 @@ member_initializer { if ($2 == null) $$ = null; - else + else { $$ = new CollectionElementInitializer ((List)$2, GetLocation ($1)); + lbag.AddLocation ($$, GetLocation ($2)); + } } | OPEN_BRACE CLOSE_BRACE { @@ -3301,10 +3325,10 @@ argument_list lbag.AppendTo (list, GetLocation ($2)); $$ = list; } - | argument_list COMMA + | argument_list COMMA error { - report.Error (839, GetLocation ($2), "An argument is missing"); - $$ = $1; + Error_SyntaxError (yyToken); + $$ = $1; } | COMMA error { @@ -3361,10 +3385,12 @@ element_access } | primary_expression OPEN_BRACKET_EXPR expression_list_arguments error { + Error_SyntaxError (yyToken); $$ = new ElementAccess ((Expression) $1, (Arguments) $3, GetLocation ($2)); } | primary_expression OPEN_BRACKET_EXPR error { + Error_SyntaxError (yyToken); $$ = new ElementAccess ((Expression) $1, null, GetLocation ($2)); } ; @@ -3505,8 +3531,9 @@ array_creation_expression } | NEW new_expr_type error { - Error_SyntaxError (1526, yyToken, "Unexpected symbol"); - $$ = new ArrayCreation ((FullNamedExpression) $2, null, GetLocation ($1)); + Error_SyntaxError (yyToken); + // It can be any of new expression, create the most common one + $$ = new New ((FullNamedExpression) $2, null, GetLocation ($1)); } ; @@ -3874,8 +3901,16 @@ unary_expression | AWAIT prefixed_unary_expression { if (!async_block) { - report.Error (1992, GetLocation ($1), - "The `await' operator can only be used when its containing method or lambda expression is marked with the `async' modifier"); + if (current_anonymous_method is LambdaExpression) { + report.Error (4034, GetLocation ($1), + "The `await' operator can only be used when its containing lambda expression is marked with the `async' modifier"); + } else if (current_anonymous_method is AnonymousMethodExpression) { + report.Error (4035, GetLocation ($1), + "The `await' operator can only be used when its containing anonymous method is marked with the `async' modifier"); + } else { + report.Error (4033, GetLocation ($1), + "The `await' operator can only be used when its containing method is marked with the `async' modifier"); + } } else { current_block.Explicit.RegisterAsyncAwait (); } @@ -4071,11 +4106,16 @@ null_coalescing_expression conditional_expression : null_coalescing_expression - | null_coalescing_expression INTERR expression COLON expression + | null_coalescing_expression INTERR expression COLON expression_or_error { $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, (Expression) $5, GetLocation ($2)); lbag.AddLocation ($$, GetLocation ($4)); } + | null_coalescing_expression INTERR expression error + { + Error_SyntaxError (yyToken); + $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, null, GetLocation ($2)); + } ; assignment_expression @@ -4494,6 +4534,12 @@ opt_class_base current_type.AddBasesForPart ((List) $2); lbag.AppendToMember (current_type, GetLocation ($1)); } + | COLON type_list error + { + Error_SyntaxError (yyToken); + + current_type.AddBasesForPart ((List) $2); + } ; opt_type_parameter_constraints_clauses @@ -4502,11 +4548,6 @@ opt_type_parameter_constraints_clauses { $$ = $1; } - | error - { - Error_SyntaxError (yyToken); - $$ = null; - } ; type_parameter_constraints_clauses @@ -4541,6 +4582,13 @@ type_parameter_constraints_clause $$ = new Constraints (new SimpleMemberName (lt.Value, lt.Location), (List) $4, GetLocation ($1)); lbag.AddLocation ($$, GetLocation ($3)); } + | WHERE IDENTIFIER error + { + Error_SyntaxError (yyToken); + + var lt = (Tokenizer.LocatedToken) $2; + $$ = new Constraints (new SimpleMemberName (lt.Value, lt.Location), null, GetLocation ($1)); + } ; type_parameter_constraints @@ -4675,6 +4723,11 @@ block_prepared { --lexer.parsing_block; $$ = end_block (GetLocation ($4)); + } | CLOSE_BRACE + { + report.Error (1525, GetLocation ($1), "Unexpected symbol '}', expected '{'"); + lexer.putback ('}'); + $$ = end_block (GetLocation ($1)); } ; @@ -4925,7 +4978,7 @@ block_variable_declaration current_block.AddLocalName (li); current_variable = new BlockVariableDeclaration ((FullNamedExpression) $1, li); } - opt_local_variable_initializer opt_variable_declarators SEMICOLON + opt_local_variable_initializer opt_variable_declarators semicolon_or_handle_error_close_brace { $$ = current_variable; current_variable = null; @@ -4950,6 +5003,16 @@ block_variable_declaration } ; +semicolon_or_handle_error_close_brace + : SEMICOLON + | CLOSE_BRACE { + // Redundant, but wont regress + report.Error (1525, lexer.Location, "Unexpected symbol }"); + lexer.putback ('}'); + $$ = $1; + } + ; + opt_local_variable_initializer : /* empty */ | ASSIGN block_variable_initializer @@ -5079,10 +5142,10 @@ expression_statement lbag.AddStatement ($$, GetLocation ($2)); } | statement_expression COMPLETE_COMPLETION { $$ = $1; } - | statement_expression CLOSE_BRACE { - $$ = $1; - lbag.AddStatement ($$, GetLocation ($2)); - report.Error (1525, "Unexpected symbol '}' after statement, expecting ';'"); + | statement_expression CLOSE_BRACE + { + $$ = $1; + report.Error (1002, GetLocation ($2), "; expected"); lexer.putback ('}'); } ; @@ -5245,6 +5308,11 @@ switch_label $$ = new SwitchLabel ((Expression) $2, GetLocation ($1)); lbag.AddLocation ($$, GetLocation ($3)); } + | CASE constant_expression error + { + Error_SyntaxError (yyToken); + $$ = new SwitchLabel ((Expression) $2, GetLocation ($1)); + } | DEFAULT_COLON { $$ = new SwitchLabel (null, GetLocation ($1)); @@ -5303,6 +5371,7 @@ for_statement current_block.IsCompilerGenerated = true; For f = new For (GetLocation ($1)); current_block.AddStatement (f); + lbag.AddStatement (f, current_block.StartLocation); $$ = f; } for_statement_cont @@ -5315,24 +5384,57 @@ for_statement for_statement_cont : opt_for_initializer SEMICOLON { - ((For) $0).Initializer = (Statement) $1; + For f = (For) $0; + f.Initializer = (Statement) $1; + lbag.AppendTo (f, GetLocation ($2)); + $$ = f; + } + for_statement_condition + { + $$ = $4; } - opt_for_condition SEMICOLON + | opt_for_initializer CLOSE_PARENS { + report.Error (1525, GetLocation ($2), "Unexpected symbol ')', expected ';'"); + For f = (For) $0; + f.Initializer = (Statement) $1; + lbag.AppendTo (f, GetLocation ($2)); + $$ = end_block (GetLocation ($2)); + } + ; + +for_statement_condition + : opt_for_condition SEMICOLON { - ((For) $0).Condition = (BooleanExpression) $4; + For f = (For) $0; + f.Condition = (BooleanExpression) $1; + lbag.AppendTo (f, GetLocation ($2)); + $$ = f; } - opt_for_iterator CLOSE_PARENS + for_statement_end { - ((For) $0).Iterator = (Statement) $7; + $$ = $4; } + | boolean_expression CLOSE_PARENS { + report.Error (1525, GetLocation ($2), "Unexpected symbol ')', expected ';'"); + For f = (For) $0; + f.Condition = (BooleanExpression) $1; + lbag.AppendTo (f, GetLocation ($2)); + $$ = end_block (GetLocation ($2)); + } + ; + +for_statement_end + : opt_for_iterator CLOSE_PARENS embedded_statement { - if ($10 is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) - Warning_EmptyStatement (GetLocation ($10)); + For f = (For) $0; + f.Iterator = (Statement) $1; + + if ($3 is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) + Warning_EmptyStatement (GetLocation ($3)); - For f = ((For) $0); - f.Statement = (Statement) $10; - lbag.AddStatement (f, current_block.StartLocation, GetLocation ($2), GetLocation ($5), GetLocation ($8)); + f.Statement = (Statement) $3; + lbag.AppendTo (f, GetLocation ($2)); $$ = end_block (GetLocation ($2)); } @@ -5389,6 +5491,7 @@ statement_expression_list } else { sl.Add ((Statement) $3); lbag.AppendTo (sl, GetLocation ($2)); + } $$ = sl; @@ -5403,7 +5506,7 @@ foreach_statement start_block (GetLocation ($2)); current_block.IsCompilerGenerated = true; - Foreach f = new Foreach ((Expression) $3, null, null, null, GetLocation ($1)); + Foreach f = new Foreach ((Expression) $3, null, null, null, null, GetLocation ($1)); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation ($2)); @@ -5412,7 +5515,7 @@ foreach_statement | FOREACH open_parens_any type identifier_inside_body error { Error_SyntaxError (yyToken); - + start_block (GetLocation ($2)); current_block.IsCompilerGenerated = true; @@ -5420,7 +5523,7 @@ foreach_statement var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location); current_block.AddLocalName (li); - Foreach f = new Foreach ((Expression) $3, li, null, null, GetLocation ($1)); + Foreach f = new Foreach ((Expression) $3, li, null, null, null, GetLocation ($1)); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation ($2)); @@ -5439,12 +5542,12 @@ foreach_statement { if ($9 is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation ($9)); - - Foreach f = new Foreach ((Expression) $3, (LocalVariable) $8, (Expression) $6, (Statement) $9, GetLocation ($1)); - current_block.AddStatement (f); + Foreach f = new Foreach ((Expression) $3, (LocalVariable) $8, (Expression) $6, (Statement) $9, current_block, GetLocation ($1)); lbag.AddStatement (f, GetLocation ($2), GetLocation ($5), GetLocation ($7)); - $$ = end_block (GetLocation ($7)); + end_block (GetLocation ($7)); + + $$ = f; } | FOREACH open_parens_any type identifier_inside_body error { @@ -5453,7 +5556,7 @@ foreach_statement var lt = $4 as Tokenizer.LocatedToken; var li = lt != null ? new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location) : null; - Foreach f = new Foreach ((Expression) $3, li, null, null, GetLocation ($1)); + Foreach f = new Foreach ((Expression) $3, li, null, null, null, GetLocation ($1)); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation ($2)); @@ -5461,7 +5564,7 @@ foreach_statement } | FOREACH open_parens_any type error { - Foreach f = new Foreach ((Expression) $3, null, null, null, GetLocation ($1)); + Foreach f = new Foreach ((Expression) $3, null, null, null, null, GetLocation ($1)); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation ($2)); @@ -5492,6 +5595,11 @@ continue_statement $$ = new Continue (GetLocation ($1)); lbag.AddStatement ($$, GetLocation ($2)); } + | CONTINUE error + { + Error_SyntaxError (yyToken); + $$ = new Continue (GetLocation ($1)); + } ; goto_statement @@ -5519,6 +5627,11 @@ return_statement $$ = new Return ((Expression) $2, GetLocation ($1)); lbag.AddStatement ($$, GetLocation ($3)); } + | RETURN error + { + Error_SyntaxError (yyToken); + $$ = new Return (null, GetLocation ($1)); + } ; throw_statement @@ -5527,6 +5640,11 @@ throw_statement $$ = new Throw ((Expression) $2, GetLocation ($1)); lbag.AddStatement ($$, GetLocation ($3)); } + | THROW error + { + Error_SyntaxError (yyToken); + $$ = new Throw (null, GetLocation ($1)); + } ; yield_statement @@ -5579,7 +5697,8 @@ try_statement } | TRY block catch_clauses FINALLY block { - $$ = new TryFinally (new TryCatch ((Block) $2, (List) $3, Location.Null, true), (Block) $5, GetLocation ($1)); + var loc = GetLocation ($1); + $$ = new TryFinally (new TryCatch ((Block) $2, (List) $3, loc, true), (Block) $5, loc); lbag.AddStatement ($$, GetLocation ($4)); } | TRY block error @@ -5837,7 +5956,9 @@ first_from_clause var lt = (Tokenizer.LocatedToken) $2; var rv = new Linq.RangeVariable (lt.Value, lt.Location); - $$ = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1))); + var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1)); + lbag.AddLocation (start, GetLocation ($3)); + $$ = new Linq.QueryExpression (start); } | FROM_FIRST type identifier_inside_body IN expression { @@ -5845,11 +5966,11 @@ first_from_clause var lt = (Tokenizer.LocatedToken) $3; var rv = new Linq.RangeVariable (lt.Value, lt.Location); - $$ = new Linq.QueryExpression ( - new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) { - IdentifierType = (FullNamedExpression)$2 - } - ); + var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) { + IdentifierType = (FullNamedExpression)$2 + }; + lbag.AddLocation (start, GetLocation ($4)); + $$ = new Linq.QueryExpression (start); } ; @@ -5860,7 +5981,9 @@ nested_from_clause var lt = (Tokenizer.LocatedToken) $2; var rv = new Linq.RangeVariable (lt.Value, lt.Location); - $$ = new Linq.QueryExpression (new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1))); + var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$4, rv, GetLocation ($1)); + lbag.AddLocation (start, GetLocation ($3)); + $$ = new Linq.QueryExpression (start); } | FROM type identifier_inside_body IN expression { @@ -5868,11 +5991,11 @@ nested_from_clause var lt = (Tokenizer.LocatedToken) $3; var rv = new Linq.RangeVariable (lt.Value, lt.Location); - $$ = new Linq.QueryExpression ( - new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) { - IdentifierType = (FullNamedExpression)$2 - } - ); + var start = new Linq.QueryStartClause ((Linq.QueryBlock)current_block, (Expression)$5, rv, GetLocation ($1)) { + IdentifierType = (FullNamedExpression)$2 + }; + lbag.AddLocation (start, GetLocation ($4)); + $$ = new Linq.QueryExpression (start); } ; @@ -5889,8 +6012,9 @@ from_clause current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; - ((Linq.QueryBlock)current_block).AddRangeVariable (sn); + + lbag.AddLocation ($$, GetLocation ($3)); } | FROM type identifier_inside_body IN { @@ -5909,11 +6033,13 @@ from_clause current_block = current_block.Parent; ((Linq.QueryBlock)current_block).AddRangeVariable (sn); + + lbag.AddLocation ($$, GetLocation ($4)); } ; query_body - : opt_query_body_clauses select_or_group_clause opt_query_continuation + : query_body_clauses select_or_group_clause opt_query_continuation { Linq.AQueryClause head = (Linq.AQueryClause)$2; @@ -5928,7 +6054,24 @@ query_body $$ = head; } - | opt_query_body_clauses COMPLETE_COMPLETION + | select_or_group_clause opt_query_continuation + { + Linq.AQueryClause head = (Linq.AQueryClause)$2; + + if ($1 != null) { + Linq.AQueryClause clause = (Linq.AQueryClause)$1; + clause.Tail.Next = head; + head = clause; + } + + $$ = head; + } + | query_body_clauses COMPLETE_COMPLETION + | query_body_clauses error + { + report.Error (742, GetLocation ($2), "Unexpected symbol `{0}'. A query body must end with select or group clause", GetSymbolName (yyToken)); + $$ = $1; + } | error { Error_SyntaxError (yyToken); @@ -5973,11 +6116,6 @@ select_or_group_clause } ; -opt_query_body_clauses - : /* empty */ - | query_body_clauses - ; - query_body_clauses : query_body_clause | query_body_clauses query_body_clause @@ -6085,7 +6223,7 @@ join_clause into = new Linq.RangeVariable (lt.Value, lt.Location); $$ = new Linq.GroupJoin (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1)); - lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9), GetLocation ($12)); + lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9), opt_intoStack.Pop ()); } current_block = block.Parent; @@ -6132,6 +6270,7 @@ join_clause $$ = new Linq.Join (block, sn, (Expression)$6, outer_selector, (Linq.QueryBlock) current_block, GetLocation ($1)) { IdentifierType = (FullNamedExpression)$2 }; + lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9)); } else { // // Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions @@ -6150,6 +6289,7 @@ join_clause $$ = new Linq.GroupJoin (block, sn, (Expression)$6, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1)) { IdentifierType = (FullNamedExpression)$2 }; + lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9), opt_intoStack.Pop ()); } current_block = block.Parent; @@ -6161,6 +6301,7 @@ opt_join_into : /* empty */ | INTO identifier_inside_body { + opt_intoStack.Push (GetLocation ($1)); $$ = $2; } ; @@ -6680,10 +6821,10 @@ public void parse () report.Error (-25, lexer.Location, "Parsing error"); } else { // Used by compiler-tester to test internal errors - if (yacc_verbose_flag > 0) + if (yacc_verbose_flag > 0 || e is FatalException) throw; - report.Error (589, lexer.Location, "Internal compiler error during parsing"); + report.Error (589, lexer.Location, "Internal compiler error during parsing" + e); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs index 8fc3d9c0a..35705d56e 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs @@ -137,6 +137,11 @@ namespace Mono.CSharp pos = 0; } + public override string ToString () + { + return string.Format ("Token '{0}' at {1},{2}", Value, row, column); + } + public Location Location { get { return new Location (row, column); } } @@ -376,6 +381,9 @@ namespace Mono.CSharp get { return ref_line; } + set { + ref_line = value; + } } // @@ -971,6 +979,7 @@ namespace Mono.CSharp case Token.UNCHECKED: case Token.UNSAFE: case Token.DEFAULT: + case Token.AWAIT: // // These can be part of a member access @@ -1262,10 +1271,24 @@ namespace Mono.CSharp int ntoken; int interrs = 1; int colons = 0; + int braces = 0; // // All shorcuts failed, do it hard way // while ((ntoken = xtoken ()) != Token.EOF) { + if (ntoken == Token.OPEN_BRACE) { + ++braces; + continue; + } + + if (ntoken == Token.CLOSE_BRACE) { + --braces; + continue; + } + + if (braces != 0) + continue; + if (ntoken == Token.SEMICOLON) break; @@ -1281,7 +1304,7 @@ namespace Mono.CSharp } } - next_token = colons != interrs ? Token.INTERR_NULLABLE : Token.INTERR; + next_token = colons != interrs && braces == 0 ? Token.INTERR_NULLABLE : Token.INTERR; break; } } @@ -1974,7 +1997,7 @@ namespace Mono.CSharp hidden_block_start = Location.Null; } - ref_line = line; + //ref_line = line; Location.Push (current_source); return true; } @@ -2070,7 +2093,7 @@ namespace Mono.CSharp hidden_block_start = Location.Null; } - ref_line = new_line; + //ref_line = new_line; return true; } @@ -2242,6 +2265,9 @@ namespace Mono.CSharp return true; } +#if !FULL_AST + static +#endif bool IsTokenIdentifierEqual (char[] identifier) { for (int i = 0; i < identifier.Length; ++i) { @@ -2288,6 +2314,7 @@ namespace Mono.CSharp Report.Warning (1709, 1, Location, "Filename specified for preprocessor directive is empty"); } + return string_builder.ToString (); } @@ -3003,6 +3030,9 @@ namespace Mono.CSharp return Token.IDENTIFIER; } +#if !FULL_AST + static +#endif string InternIdentifier (char[] charBuffer, int length) { // diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs index 83be8c1ff..2d2dcf8ff 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; +using Mono.CompilerServices.SymbolWriter; #if NET_2_1 using XmlElement = System.Object; @@ -298,7 +299,8 @@ namespace Mono.CSharp { PartialDefinitionExists = 1 << 14, // Set when corresponding partial method definition exists HasStructLayout = 1 << 15, // Has StructLayoutAttribute HasInstanceConstructor = 1 << 16, - HasUserOperators = 1 << 17 + HasUserOperators = 1 << 17, + CanBeReused = 1 << 18 } /// @@ -424,6 +426,15 @@ namespace Mono.CSharp { VerifyClsCompliance (); } + public bool IsAvailableForReuse { + get { + return (caching_flags & Flags.CanBeReused) != 0; + } + set { + caching_flags = value ? (caching_flags | Flags.CanBeReused) : (caching_flags & ~Flags.CanBeReused); + } + } + public bool IsCompilerGenerated { get { if ((mod_flags & Modifiers.COMPILER_GENERATED) != 0) @@ -675,7 +686,7 @@ namespace Mono.CSharp { do { var ns = m as NamespaceContainer; if (ns != null) - return ns.LookupExtensionMethod (this, extensionType, name, arity, ns, 0); + return ns.LookupExtensionMethod (this, extensionType, name, arity, 0); m = m.Parent; } while (m != null); @@ -809,6 +820,11 @@ namespace Mono.CSharp { Report.Warning (3008, 1, MemberName.Location, "Identifier `{0}' is not CLS-compliant", GetSignatureForError ()); } + public virtual string GetCallerMemberName () + { + return MemberName.Name; + } + // // Returns a string that represents the signature for this // member which should be used in XML documentation. @@ -844,6 +860,10 @@ namespace Mono.CSharp { } } + public virtual void WriteDebugSymbol (MonoSymbolFile file) + { + } + #region IMemberContext Members public virtual CompilerContext Compiler { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs index 96dcf7741..f0781401b 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs @@ -220,7 +220,7 @@ namespace Mono.CSharp { var p = parameters[i]; compiled[i] = new Parameter (new TypeExpression (parameters.Types[i], Location), p.Name, - p.ModFlags & (Parameter.Modifier.REF | Parameter.Modifier.OUT), + p.ModFlags & Parameter.Modifier.RefOutMask, p.OptAttributes == null ? null : p.OptAttributes.Clone (), Location); } @@ -255,7 +255,7 @@ namespace Mono.CSharp { int out_params = 0; foreach (Parameter p in Parameters.FixedParameters) { - if ((p.ModFlags & Parameter.Modifier.ISBYREF) != 0) + if ((p.ModFlags & Parameter.Modifier.RefOutMask) != 0) ++out_params; } @@ -265,12 +265,12 @@ namespace Mono.CSharp { int param = 0; for (int i = 0; i < Parameters.FixedParameters.Length; ++i) { Parameter p = parameters [i]; - if ((p.ModFlags & Parameter.Modifier.ISBYREF) == 0) + if ((p.ModFlags & Parameter.Modifier.RefOutMask) == 0) continue; end_params [param++] = new Parameter (new TypeExpression (p.Type, Location), p.Name, - p.ModFlags & (Parameter.Modifier.REF | Parameter.Modifier.OUT), + p.ModFlags & Parameter.Modifier.RefOutMask, p.OptAttributes == null ? null : p.OptAttributes.Clone (), Location); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs index 19340bf6c..e988178c4 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs @@ -241,7 +241,7 @@ namespace Mono.CSharp // // Handles node // - void HandleTypeParam (MemberCore mc, XmlElement node) + static void HandleTypeParam (MemberCore mc, XmlElement node) { if (!node.HasAttribute ("name")) return; @@ -262,7 +262,7 @@ namespace Mono.CSharp // // Handles node // - void HandleTypeParamRef (MemberCore mc, XmlElement node) + static void HandleTypeParamRef (MemberCore mc, XmlElement node) { if (!node.HasAttribute ("name")) return; @@ -397,10 +397,15 @@ namespace Mono.CSharp if (ParsedParameters != null) { var old_printer = mc.Module.Compiler.Report.SetPrinter (new NullReportPrinter ()); - foreach (var pp in ParsedParameters) { - pp.Resolve (mc); + try { + var context = new DocumentationMemberContext (mc, ParsedName ?? MemberName.Null); + + foreach (var pp in ParsedParameters) { + pp.Resolve (context); + } + } finally { + mc.Module.Compiler.Report.SetPrinter (old_printer); } - mc.Module.Compiler.Report.SetPrinter (old_printer); } if (type != null) { @@ -433,13 +438,15 @@ namespace Mono.CSharp if (m.Kind == MemberKind.Operator && !ParsedOperator.HasValue) continue; + var pm_params = pm.Parameters; + int i; for (i = 0; i < parsed_param_count; ++i) { var pparam = ParsedParameters[i]; - if (i >= pm.Parameters.Count || pparam == null || - pparam.TypeSpec != pm.Parameters.Types[i] || - (pparam.Modifier & Parameter.Modifier.SignatureMask) != (pm.Parameters.FixedParameters[i].ModFlags & Parameter.Modifier.SignatureMask)) { + if (i >= pm_params.Count || pparam == null || pparam.TypeSpec == null || + !TypeSpecComparer.Override.IsEqual (pparam.TypeSpec, pm_params.Types[i]) || + (pparam.Modifier & Parameter.Modifier.RefOutMask) != (pm_params.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask)) { if (i > parameters_match) { parameters_match = i; @@ -459,7 +466,7 @@ namespace Mono.CSharp continue; } } else { - if (parsed_param_count != pm.Parameters.Count) + if (parsed_param_count != pm_params.Count) continue; } } @@ -612,6 +619,97 @@ namespace Mono.CSharp } } + // + // Type lookup of documentation references uses context of type where + // the reference is used but type parameters from cref value + // + sealed class DocumentationMemberContext : IMemberContext + { + readonly MemberCore host; + MemberName contextName; + + public DocumentationMemberContext (MemberCore host, MemberName contextName) + { + this.host = host; + this.contextName = contextName; + } + + public TypeSpec CurrentType { + get { + return host.CurrentType; + } + } + + public TypeParameters CurrentTypeParameters { + get { + return contextName.TypeParameters; + } + } + + public MemberCore CurrentMemberDefinition { + get { + return host.CurrentMemberDefinition; + } + } + + public bool IsObsolete { + get { + return false; + } + } + + public bool IsUnsafe { + get { + return host.IsStatic; + } + } + + public bool IsStatic { + get { + return host.IsStatic; + } + } + + public ModuleContainer Module { + get { + return host.Module; + } + } + + public string GetSignatureForError () + { + return host.GetSignatureForError (); + } + + public ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity) + { + return null; + } + + public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc) + { + if (arity == 0) { + var tp = CurrentTypeParameters; + if (tp != null) { + for (int i = 0; i < tp.Count; ++i) { + var t = tp[i]; + if (t.Name == name) { + t.Type.DeclaredPosition = i; + return new TypeParameterExpr (t, loc); + } + } + } + } + + return host.Parent.LookupNamespaceOrType (name, arity, mode, loc); + } + + public FullNamedExpression LookupNamespaceAlias (string name) + { + throw new NotImplementedException (); + } + } + class DocumentationParameter { public readonly Parameter.Modifier Modifier; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs index 109fbb2fe..e86263da6 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs @@ -113,12 +113,13 @@ namespace Mono.CSharp input.Close (); } - public CSharpParser Parse (SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module) + public static CSharpParser Parse(SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module, int lineModifier = 0) { var file = new CompilationSourceFile (module, sourceFile); - module.AddTypeContainer (file); + module.AddTypeContainer(file); CSharpParser parser = new CSharpParser (reader, file); + parser.Lexer.Line += lineModifier; parser.Lexer.sbag = new SpecialsBag (); parser.parse (); return parser; @@ -213,6 +214,11 @@ namespace Mono.CSharp return false; } + if (settings.Platform == Platform.AnyCPU32Preferred && (settings.Target == Target.Library || settings.Target == Target.Module)) { + Report.Error (4023, "Platform option `anycpu32bitpreferred' is valid only for executables"); + return false; + } + TimeReporter tr = new TimeReporter (settings.Timestamps); ctx.TimeReporter = tr; tr.StartTotal (); @@ -253,6 +259,12 @@ namespace Mono.CSharp output_file = output_file_name; } else { output_file_name = Path.GetFileName (output_file); + + if (string.IsNullOrEmpty (Path.GetFileNameWithoutExtension (output_file_name)) || + output_file_name.IndexOfAny (Path.GetInvalidFileNameChars ()) >= 0) { + Report.Error (2021, "Output file name is not valid"); + return false; + } } #if STATIC @@ -403,7 +415,6 @@ namespace Mono.CSharp if (!full_flag) return; - SymbolWriter.Reset (); Linq.QueryBlock.TransparentParameter.Reset (); TypeInfo.Reset (); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs index 1c209d611..c9cea6927 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs @@ -495,41 +495,40 @@ namespace Mono.CSharp FieldExpr site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc); BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void); - SymbolWriter.OpenCompilerGeneratedBlock (ec); Arguments args = new Arguments (1); args.Add (new Argument (binder)); StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (instanceAccessExprType, "Create"), args))); - - if (s.Resolve (bc)) { - Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc), loc), s, loc); - init.Emit (ec); - } - - args = new Arguments (1 + dyn_args_count); - args.Add (new Argument (site_field_expr)); - if (arguments != null) { - int arg_pos = 1; - foreach (Argument a in arguments) { - if (a is NamedArgument) { - // Name is not valid in this context - args.Add (new Argument (a.Expr, a.ArgType)); - } else { - args.Add (a); - } - - if (inflate_using_mvar && a.Type != targs[arg_pos].Type) - a.Expr.Type = targs[arg_pos].Type; - ++arg_pos; + using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) { + if (s.Resolve (bc)) { + Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc), loc), s, loc); + init.Emit (ec); } - } - Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc); - if (target != null) - target.Emit (ec); + args = new Arguments (1 + dyn_args_count); + args.Add (new Argument (site_field_expr)); + if (arguments != null) { + int arg_pos = 1; + foreach (Argument a in arguments) { + if (a is NamedArgument) { + // Name is not valid in this context + args.Add (new Argument (a.Expr, a.ArgType)); + } else { + args.Add (a); + } + + if (inflate_using_mvar && a.Type != targs[arg_pos].Type) + a.Expr.Type = targs[arg_pos].Type; + + ++arg_pos; + } + } - SymbolWriter.CloseCompilerGeneratedBlock (ec); + Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc); + if (target != null) + target.Emit (ec); + } } public static MemberAccess GetBinderNamespace (Location loc) @@ -608,7 +607,9 @@ namespace Mono.CSharp public override void EmitStatement (EmitContext ec) { var stmt = new If (condition, new StatementExpression (invoke), new StatementExpression (assign), loc); - stmt.Emit (ec); + using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) { + stmt.Emit (ec); + } } } @@ -733,15 +734,6 @@ namespace Mono.CSharp this.member = member; } - // - // When a return type is known not to be dynamic - // - public DynamicInvocation (ATypeNameExpression member, Arguments args, TypeSpec type, Location loc) - : this (member, args, loc) - { - this.type = type; - } - public static DynamicInvocation CreateSpecialNameInvoke (ATypeNameExpression member, Arguments args, Location loc) { return new DynamicInvocation (member, args, loc) { @@ -957,7 +949,7 @@ namespace Mono.CSharp sealed class DynamicSiteClass : HoistedStoreyClass { public DynamicSiteClass (TypeDefinition parent, MemberBase host, TypeParameters tparams) - : base (parent, MakeMemberName (host, "DynamicSite", parent.DynamicSitesCounter, tparams, Location.Null), tparams, Modifiers.STATIC) + : base (parent, MakeMemberName (host, "DynamicSite", parent.DynamicSitesCounter, tparams, Location.Null), tparams, Modifiers.STATIC, MemberKind.Class) { parent.DynamicSitesCounter++; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs index d9abd9d37..4ccc3c3e9 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs @@ -118,6 +118,11 @@ namespace Mono.CSharp { bool IsFixed { get; } } + public interface IExpressionCleanup + { + void EmitCleanup (EmitContext ec); + } + /// /// Base class for expressions /// @@ -222,8 +227,7 @@ namespace Mono.CSharp { public static void Error_InvalidExpressionStatement (Report Report, Location loc) { - Report.Error (201, loc, "Only assignment, call, increment, decrement, and new object " + - "expressions can be used as a statement"); + Report.Error (201, loc, "Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement"); } public void Error_InvalidExpressionStatement (BlockContext ec) @@ -236,7 +240,7 @@ namespace Mono.CSharp { Report.Error (1547, loc, "Keyword `void' cannot be used in this context"); } - public virtual void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) + public virtual void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl) { Error_ValueCannotBeConvertedCore (ec, loc, target, expl); } @@ -316,7 +320,7 @@ namespace Mono.CSharp { TypeManager.CSharpName (type), name); } - public void Error_ValueAssignment (ResolveContext rc, Expression rhs) + public virtual void Error_ValueAssignment (ResolveContext rc, Expression rhs) { if (rhs == EmptyExpression.LValueMemberAccess || rhs == EmptyExpression.LValueMemberOutAccess) { rc.Report.SymbolRelatedToPreviousError (type); @@ -398,7 +402,7 @@ namespace Mono.CSharp { return e; } catch (Exception ex) { - if (loc.IsNull || ec.Module.Compiler.Settings.DebugFlags > 0 || ex is CompletionResult || ec.Report.IsDisabled) + if (loc.IsNull || ec.Module.Compiler.Settings.DebugFlags > 0 || ex is CompletionResult || ec.Report.IsDisabled || ex is FatalException) throw; ec.Report.Error (584, loc, "Internal compiler error: {0}", ex.Message); @@ -536,38 +540,40 @@ namespace Mono.CSharp { ec.EmitThis (); // Emit original code - EmitToFieldSource (ec); - - // - // Store the result to temporary field when we - // cannot load `this' directly - // - var field = ec.GetTemporaryField (type); - if (needs_temporary) { + var field = EmitToFieldSource (ec); + if (field == null) { // - // Create temporary local (we cannot load `this' before Emit) + // Store the result to temporary field when we + // cannot load `this' directly // - var temp = ec.GetTemporaryLocal (type); - ec.Emit (OpCodes.Stloc, temp); + field = ec.GetTemporaryField (type); + if (needs_temporary) { + // + // Create temporary local (we cannot load `this' before Emit) + // + var temp = ec.GetTemporaryLocal (type); + ec.Emit (OpCodes.Stloc, temp); - ec.EmitThis (); - ec.Emit (OpCodes.Ldloc, temp); - field.EmitAssignFromStack (ec); + ec.EmitThis (); + ec.Emit (OpCodes.Ldloc, temp); + field.EmitAssignFromStack (ec); - ec.FreeTemporaryLocal (temp, type); - } else { - field.EmitAssignFromStack (ec); + ec.FreeTemporaryLocal (temp, type); + } else { + field.EmitAssignFromStack (ec); + } } return field; } - protected virtual void EmitToFieldSource (EmitContext ec) + protected virtual FieldExpr EmitToFieldSource (EmitContext ec) { // // Default implementation calls Emit method // Emit (ec); + return null; } protected static void EmitExpressionsList (EmitContext ec, List expressions) @@ -751,6 +757,9 @@ namespace Mono.CSharp { public virtual void Error_OperatorCannotBeApplied (ResolveContext rc, Location loc, string oper, TypeSpec t) { + if (t == InternalType.ErrorType) + return; + rc.Report.Error (23, loc, "The `{0}' operator cannot be applied to operand of type `{1}'", oper, t.GetSignatureForError ()); } @@ -906,7 +915,7 @@ namespace Mono.CSharp { converted = Convert.ImplicitConversion (ec, source, btypes.ULong, source.loc); if (converted == null) { - source.Error_ValueCannotBeConverted (ec, source.loc, btypes.Int, false); + source.Error_ValueCannotBeConverted (ec, btypes.Int, false); return null; } } @@ -1022,6 +1031,12 @@ namespace Mono.CSharp { if (es == null) Error_InvalidExpressionStatement (ec); + if (ec.CurrentAnonymousMethod is AsyncInitializer && !(e is Assign) && + (e.Type.IsGenericTask || e.Type == ec.Module.PredefinedTypes.Task.TypeSpec)) { + ec.Report.Warning (4014, 1, e.Location, + "The statement is not awaited and execution of current method continues before the call is completed. Consider using `await' operator"); + } + return es; } @@ -1923,6 +1938,12 @@ namespace Mono.CSharp { #region Properties + public override bool IsSideEffectFree { + get { + return expr.IsSideEffectFree; + } + } + public Expression OriginalExpression { get { return orig_expr; @@ -1995,6 +2016,11 @@ namespace Mono.CSharp { expr.Emit (ec); } + public override Expression EmitToField (EmitContext ec) + { + return expr.EmitToField(ec); + } + public override void EmitBranchable (EmitContext ec, Label target, bool on_true) { expr.EmitBranchable (ec, target, on_true); @@ -2470,14 +2496,25 @@ namespace Mono.CSharp { ErrorIsInaccesible (rc, e.GetSignatureForError (), loc); return e; } + } else { + var me = MemberLookup (rc, false, rc.CurrentType, Name, Arity, restrictions & ~MemberLookupRestrictions.InvocableOnly, loc) as MemberExpr; + if (me != null) { + me.Error_UnexpectedKind (rc, me, "method group", me.KindName, loc); + return ErrorExpression.Instance; + } } e = rc.LookupNamespaceOrType (Name, -System.Math.Max (1, Arity), LookupMode.Probing, loc); if (e != null) { - if (!(e is TypeExpr) || (restrictions & MemberLookupRestrictions.InvocableOnly) == 0 || !e.Type.IsDelegate) { + if (e.Type.Arity != Arity) { Error_TypeArgumentsCannotBeUsed (rc, e.Type, Arity, loc); return e; } + + if (e is TypeExpr) { + e.Error_UnexpectedKind (rc, e, "variable", e.ExprClassName, loc); + return e; + } } rc.Report.Error (103, loc, "The name `{0}' does not exist in the current context", Name); @@ -2505,8 +2542,8 @@ namespace Mono.CSharp { return null; if (right_side != null) { - if (e is TypeExpr) { - e.Error_UnexpectedKind (ec, ResolveFlags.VariableOrValue, loc); + if (e is FullNamedExpression && e.eclass != ExprClass.Unresolved) { + e.Error_UnexpectedKind (ec, e, "variable", e.ExprClassName, loc); return null; } @@ -2515,7 +2552,6 @@ namespace Mono.CSharp { e = e.Resolve (ec); } - //if (ec.CurrentBlock == null || ec.CurrentBlock.CheckInvariantMeaningInBlock (Name, e, Location)) return e; } @@ -2576,6 +2612,10 @@ namespace Mono.CSharp { ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc); } + if (type.Kind == MemberKind.Void) { + mc.Module.Compiler.Report.Error (673, loc, "System.Void cannot be used from C#. Consider using `void'"); + } + // // Obsolete checks cannot be done when resolving base context as they // require type dependencies to be set but we are in process of resolving them @@ -3097,7 +3137,7 @@ namespace Mono.CSharp { int arity = type_arguments == null ? 0 : type_arguments.Count; - candidates = candidates.Container.LookupExtensionMethod (candidates.Context, ExtensionExpression.Type, Name, arity, candidates.Container, candidates.LookupIndex); + candidates = candidates.Container.LookupExtensionMethod (candidates.Context, ExtensionExpression.Type, Name, arity, candidates.LookupIndex); if (candidates == null) return null; @@ -3319,7 +3359,7 @@ namespace Mono.CSharp { call.Emit (ec, best_candidate, arguments, loc); } - public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) + public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl) { ec.Report.Error (428, loc, "Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using parentheses to invoke the method", Name, TypeManager.CSharpName (target)); @@ -4020,10 +4060,15 @@ namespace Mono.CSharp { Arguments orig_args = arguments; if (arg_count != param_count) { - for (int i = 0; i < pd.Count; ++i) { - if (pd.FixedParameters[i].HasDefaultValue) { - optional_count = pd.Count - i; - break; + // + // No arguments expansion when doing exact match for delegates + // + if ((restrictions & Restrictions.CovariantDelegate) == 0) { + for (int i = 0; i < pd.Count; ++i) { + if (pd.FixedParameters[i].HasDefaultValue) { + optional_count = pd.Count - i; + break; + } } } @@ -4199,7 +4244,8 @@ namespace Mono.CSharp { for (int i = 0; i < arg_count; i++) { Argument a = arguments[i]; if (a == null) { - if (!pd.FixedParameters[i].HasDefaultValue) { + var fp = pd.FixedParameters[i]; + if (!fp.HasDefaultValue) { arguments = orig_args; return arg_count * 2 + 2; } @@ -4208,7 +4254,7 @@ namespace Mono.CSharp { // Get the default value expression, we can use the same expression // if the type matches // - Expression e = pd.FixedParameters[i].DefaultValue; + Expression e = fp.DefaultValue; if (!(e is Constant) || e.Type.IsGenericOrParentIsGeneric || e.Type.IsGenericParameter) { // // LAMESPEC: No idea what the exact rules are for System.Reflection.Missing.Value instead of null @@ -4223,6 +4269,19 @@ namespace Mono.CSharp { e = e.Resolve (ec); } + if ((fp.ModFlags & Parameter.Modifier.CallerMask) != 0) { + // + // LAMESPEC: Attributes can be mixed together with build-in priority + // + if ((fp.ModFlags & Parameter.Modifier.CallerLineNumber) != 0) { + e = new IntLiteral (ec.BuiltinTypes, loc.Row, loc); + } else if ((fp.ModFlags & Parameter.Modifier.CallerFilePath) != 0) { + e = new StringLiteral (ec.BuiltinTypes, loc.NameFullPath, loc); + } else if (ec.MemberContext.CurrentMemberDefinition != null) { + e = new StringLiteral (ec.BuiltinTypes, ec.MemberContext.CurrentMemberDefinition.GetCallerMemberName (), loc); + } + } + arguments[i] = new Argument (e, Argument.AType.Default); continue; } @@ -4253,7 +4312,7 @@ namespace Mono.CSharp { continue; } } else { - score = IsArgumentCompatible (ec, a, p_mod & ~Parameter.Modifier.PARAMS, pt); + score = IsArgumentCompatible (ec, a, p_mod, pt); if (score < 0) dynamicArgument = true; @@ -4314,7 +4373,7 @@ namespace Mono.CSharp { // Types have to be identical when ref or out modifer // is used and argument is not of dynamic type // - if ((argument.Modifier | param_mod) != 0) { + if (((argument.Modifier | param_mod) & Parameter.Modifier.RefOutMask) != 0) { if (argument.Type != parameter) { // // Do full equality check after quick path @@ -4323,18 +4382,18 @@ namespace Mono.CSharp { // // Using dynamic for ref/out parameter can still succeed at runtime // - if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && argument.Modifier == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) + if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (argument.Modifier & Parameter.Modifier.RefOutMask) == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) return -1; return 2; } } - if (argument.Modifier != param_mod) { + if ((argument.Modifier & Parameter.Modifier.RefOutMask) != (param_mod & Parameter.Modifier.RefOutMask)) { // // Using dynamic for ref/out parameter can still succeed at runtime // - if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && argument.Modifier == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) + if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (argument.Modifier & Parameter.Modifier.RefOutMask) == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) return -1; return 1; @@ -4707,9 +4766,12 @@ namespace Mono.CSharp { if (custom_errors != null && custom_errors.ArgumentMismatch (ec, method, a, idx)) return; + if (a.Type == InternalType.ErrorType) + return; + if (a is CollectionElementInitializer.ElementInitializerArgument) { ec.Report.SymbolRelatedToPreviousError (method); - if ((expected_par.FixedParameters[idx].ModFlags & Parameter.Modifier.ISBYREF) != 0) { + if ((expected_par.FixedParameters[idx].ModFlags & Parameter.Modifier.RefOutMask) != 0) { ec.Report.Error (1954, loc, "The best overloaded collection initalizer method `{0}' cannot have 'ref', or `out' modifier", TypeManager.CSharpSignature (method)); return; @@ -4728,15 +4790,14 @@ namespace Mono.CSharp { Parameter.Modifier mod = idx >= expected_par.Count ? 0 : expected_par.FixedParameters[idx].ModFlags; string index = (idx + 1).ToString (); - if (((mod & (Parameter.Modifier.REF | Parameter.Modifier.OUT)) ^ - (a.Modifier & (Parameter.Modifier.REF | Parameter.Modifier.OUT))) != 0) { - if ((mod & Parameter.Modifier.ISBYREF) == 0) + if (((mod & Parameter.Modifier.RefOutMask) ^ (a.Modifier & Parameter.Modifier.RefOutMask)) != 0) { + if ((mod & Parameter.Modifier.RefOutMask) == 0) ec.Report.Error (1615, loc, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier", index, Parameter.GetModifierSignature (a.Modifier)); else ec.Report.Error (1620, loc, "Argument `#{0}' is missing `{1}' modifier", index, Parameter.GetModifierSignature (mod)); - } else if (a.Expr != ErrorExpression.Instance) { + } else { string p1 = a.GetSignatureForError (); string p2 = TypeManager.CSharpName (paramType); @@ -4865,8 +4926,8 @@ namespace Mono.CSharp { // // Types have to be identical when ref or out modifer is used // - if (a.Modifier != 0 || (p_mod & ~Parameter.Modifier.PARAMS) != 0) { - if ((p_mod & ~Parameter.Modifier.PARAMS) != a.Modifier) + if (((a.Modifier | p_mod) & Parameter.Modifier.RefOutMask) != 0) { + if ((a.Modifier & Parameter.Modifier.RefOutMask) != (p_mod & Parameter.Modifier.RefOutMask)) break; if (a.Expr.Type == pt || TypeSpecComparer.IsEqual (a.Expr.Type, pt)) @@ -5504,7 +5565,7 @@ namespace Mono.CSharp { base.EmitSideEffect (ec); } - public void AddressOf (EmitContext ec, AddressOp mode) + public virtual void AddressOf (EmitContext ec, AddressOp mode) { if ((mode & AddressOp.Store) != 0) spec.MemberDefinition.SetIsAssigned (); @@ -5931,10 +5992,11 @@ namespace Mono.CSharp { Emit (ec, false); } - protected override void EmitToFieldSource (EmitContext ec) + protected override FieldExpr EmitToFieldSource (EmitContext ec) { has_await_arguments = true; Emit (ec, false); + return null; } public abstract SLE.Expression MakeAssignExpression (BuilderContext ctx, Expression source); @@ -6191,6 +6253,12 @@ namespace Mono.CSharp { variable.li.CreateBuilder (ec); } + public override void Emit (EmitContext ec) + { + // Don't create sequence point + DoEmit (ec); + } + protected override void CloneTo (CloneContext clonectx, Statement target) { // Nothing @@ -6232,9 +6300,10 @@ namespace Mono.CSharp { // // Don't capture temporary variables except when using - // state machine redirection + // state machine redirection and block yields // - if (ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod is StateMachineInitializer && ec.IsVariableCapturingRequired) { + if (ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.IsIterator && + ec.CurrentBlock.Explicit.HasYield && ec.IsVariableCapturingRequired) { AnonymousMethodStorey storey = li.Block.Explicit.CreateAnonymousMethodStorey (ec); storey.CaptureLocalVariable (ec, li); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs index 0748486c3..126d2de86 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/enum.cs @@ -162,9 +162,9 @@ namespace Mono.CSharp { Modifiers.INTERNAL | Modifiers.PRIVATE; - readonly TypeExpr underlying_type_expr; + readonly FullNamedExpression underlying_type_expr; - public Enum (TypeContainer parent, TypeExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) + public Enum (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base (parent, name, attrs, MemberKind.Enum) { underlying_type_expr = type; @@ -181,7 +181,7 @@ namespace Mono.CSharp { } } - public TypeExpr BaseTypeExpression { + public FullNamedExpression BaseTypeExpression { get { return underlying_type_expr; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs index c9b864544..8b4a348a6 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs @@ -1041,10 +1041,6 @@ namespace Mono.CSharp { } - public override void EmitSymbolInfo () - { - } - protected override FieldExpr GetFieldExpression (EmitContext ec) { return new FieldExpr (field, field.Location); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs index 4f98d6cd1..3091426b4 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs @@ -103,7 +103,12 @@ namespace Mono.CSharp protected override Expression DoResolve (ResolveContext ec) { - return expr.Resolve (ec); + var res = expr.Resolve (ec); + var constant = res as Constant; + if (constant != null && constant.IsLiteral) + return Constant.CreateConstantFromValue (res.Type, constant.GetValue (), expr.Location); + + return res; } public override Expression DoResolveLValue (ResolveContext ec, Expression right_side) @@ -142,10 +147,12 @@ namespace Mono.CSharp // This routine will attempt to simplify the unary expression when the // argument is a constant. // - Constant TryReduceConstant (ResolveContext ec, Constant e) + Constant TryReduceConstant (ResolveContext ec, Constant constant) { - if (e is EmptyConstantCast) - return TryReduceConstant (ec, ((EmptyConstantCast) e).child); + var e = constant; + + while (e is EmptyConstantCast) + e = ((EmptyConstantCast) e).child; if (e is SideEffectConstant) { Constant r = TryReduceConstant (ec, ((SideEffectConstant) e).value); @@ -220,7 +227,7 @@ namespace Mono.CSharp return new LongConstant (ec.BuiltinTypes, -lvalue, e.Location); case BuiltinTypeSpec.Type.UInt: - UIntLiteral uil = e as UIntLiteral; + UIntLiteral uil = constant as UIntLiteral; if (uil != null) { if (uil.Value == int.MaxValue + (uint) 1) return new IntLiteral (ec.BuiltinTypes, int.MinValue, e.Location); @@ -230,13 +237,13 @@ namespace Mono.CSharp case BuiltinTypeSpec.Type.ULong: - ULongLiteral ull = e as ULongLiteral; + ULongLiteral ull = constant as ULongLiteral; if (ull != null && ull.Value == 9223372036854775808) return new LongLiteral (ec.BuiltinTypes, long.MinValue, e.Location); return null; case BuiltinTypeSpec.Type.Float: - FloatLiteral fl = e as FloatLiteral; + FloatLiteral fl = constant as FloatLiteral; // For better error reporting if (fl != null) return new FloatLiteral (ec.BuiltinTypes, -fl.Value, e.Location); @@ -244,7 +251,7 @@ namespace Mono.CSharp return new FloatConstant (ec.BuiltinTypes, -((FloatConstant) e).Value, e.Location); case BuiltinTypeSpec.Type.Double: - DoubleLiteral dl = e as DoubleLiteral; + DoubleLiteral dl = constant as DoubleLiteral; // For better error reporting if (dl != null) return new DoubleLiteral (ec.BuiltinTypes, -dl.Value, e.Location); @@ -1687,19 +1694,19 @@ namespace Mono.CSharp return null; } - eclass = ExprClass.Value; + if (type.IsPointer && !ec.IsUnsafe) { + UnsafeError (ec, loc); + } + eclass = ExprClass.Value; + Constant c = expr as Constant; if (c != null) { - c = c.TryReduce (ec, type, loc); + c = c.TryReduce (ec, type); if (c != null) return c; } - if (type.IsPointer && !ec.IsUnsafe) { - UnsafeError (ec, loc); - } - var res = Convert.ExplicitConversion (ec, expr, type, loc); if (res == expr) return EmptyCast.Create (res, type); @@ -2654,7 +2661,7 @@ namespace Mono.CSharp return left; if (left.IsZeroInteger) - return left.TryReduce (ec, right.Type, loc); + return left.TryReduce (ec, right.Type); break; @@ -3929,6 +3936,27 @@ namespace Mono.CSharp } } + public override Expression EmitToField (EmitContext ec) + { + if ((oper & Operator.LogicalMask) == 0) { + var await_expr = left as Await; + if (await_expr != null && right.IsSideEffectFree) { + await_expr.Statement.EmitPrologue (ec); + left = await_expr.Statement.GetResultExpression (ec); + return this; + } + + await_expr = right as Await; + if (await_expr != null && left.IsSideEffectFree) { + await_expr.Statement.EmitPrologue (ec); + right = await_expr.Statement.GetResultExpression (ec); + return this; + } + } + + return base.EmitToField (ec); + } + protected override void CloneTo (CloneContext clonectx, Expression t) { Binary target = (Binary) t; @@ -4245,7 +4273,7 @@ namespace Mono.CSharp // bool right_contains_await = ec.HasSet (BuilderContext.Options.AsyncBody) && arguments[1].Expr.ContainsEmitWithAwait (); if (right_contains_await) { - arguments[0] = arguments[0].EmitToField (ec); + arguments[0] = arguments[0].EmitToField (ec, false); arguments[0].Expr.Emit (ec); } else { arguments[0].Expr.Emit (ec); @@ -4476,7 +4504,7 @@ namespace Mono.CSharp // converted = GetOperatorTrue (ec, expr, loc); if (converted == null) { - expr.Error_ValueCannotBeConverted (ec, loc, type, false); + expr.Error_ValueCannotBeConverted (ec, type, false); return null; } @@ -4961,22 +4989,25 @@ namespace Mono.CSharp return this; } - public override Expression DoResolveLValue (ResolveContext ec, Expression right_side) + public override Expression DoResolveLValue (ResolveContext ec, Expression rhs) { - // is out param - if (right_side == EmptyExpression.OutAccess) + // + // Don't be too pedantic when variable is used as out param or for some broken code + // which uses property/indexer access to run some initialization + // + if (rhs == EmptyExpression.OutAccess || rhs.eclass == ExprClass.PropertyAccess || rhs.eclass == ExprClass.IndexerAccess) local_info.SetIsUsed (); if (local_info.IsReadonly && !ec.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.UsingInitializerScope)) { int code; string msg; - if (right_side == EmptyExpression.OutAccess) { + if (rhs == EmptyExpression.OutAccess) { code = 1657; msg = "Cannot pass `{0}' as a ref or out argument because it is a `{1}'"; - } else if (right_side == EmptyExpression.LValueMemberAccess) { + } else if (rhs == EmptyExpression.LValueMemberAccess) { code = 1654; msg = "Cannot assign to members of `{0}' because it is a `{1}'"; - } else if (right_side == EmptyExpression.LValueMemberOutAccess) { + } else if (rhs == EmptyExpression.LValueMemberOutAccess) { code = 1655; msg = "Cannot pass members of `{0}' as ref or out arguments because it is a `{1}'"; - } else if (right_side == EmptyExpression.UnaryAddress) { + } else if (rhs == EmptyExpression.UnaryAddress) { code = 459; msg = "Cannot take the address of {1} `{0}'"; } else { code = 1656; msg = "Cannot assign to `{0}' because it is a `{1}'"; @@ -4989,7 +5020,7 @@ namespace Mono.CSharp if (eclass == ExprClass.Unresolved) DoResolveBase (ec); - return base.DoResolveLValue (ec, right_side); + return base.DoResolveLValue (ec, rhs); } public override int GetHashCode () @@ -5052,11 +5083,11 @@ namespace Mono.CSharp } public override bool IsRef { - get { return (pi.Parameter.ModFlags & Parameter.Modifier.ISBYREF) != 0; } + get { return (pi.Parameter.ModFlags & Parameter.Modifier.RefOutMask) != 0; } } bool HasOutModifier { - get { return pi.Parameter.ModFlags == Parameter.Modifier.OUT; } + get { return (pi.Parameter.ModFlags & Parameter.Modifier.OUT) != 0; } } public override HoistedVariable GetHoistedVariable (AnonymousExpression ae) @@ -5138,7 +5169,7 @@ namespace Mono.CSharp if (ec.IsVariableCapturingRequired && !pi.Block.ParametersBlock.IsExpressionTree) { AnonymousMethodStorey storey = pi.Block.Explicit.CreateAnonymousMethodStorey (ec); - storey.CaptureParameter (ec, this); + storey.CaptureParameter (ec, pi, this); } } @@ -5249,6 +5280,12 @@ namespace Mono.CSharp return expr; } } + + public MethodGroupExpr MethodGroup { + get { + return mg; + } + } #endregion protected override void CloneTo (CloneContext clonectx, Expression t) @@ -5422,16 +5459,6 @@ namespace Mono.CSharp return mg.OverloadResolve (ec, ref arguments, null, OverloadResolver.Restrictions.None); } - static MetaType[] GetVarargsTypes (MethodSpec mb, Arguments arguments) - { - AParametersCollection pd = mb.Parameters; - - Argument a = arguments[pd.Count - 1]; - Arglist list = (Arglist) a.Expr; - - return list.ArgumentTypes; - } - public override string GetSignatureForError () { return mg.GetSignatureForError (); @@ -6059,18 +6086,11 @@ namespace Mono.CSharp Dictionary bounds; +#if STATIC // The number of constants in array initializers int const_initializers_count; bool only_constant_initializers; - - public List Arguments { - get { return this.arguments; } - } - - public FullNamedExpression NewType { - get { return this.requested_base_type; } - } - +#endif public ArrayCreation (FullNamedExpression requested_base_type, List exprs, ComposedTypeSpecifier rank, ArrayInitializer initializers, Location l) : this (requested_base_type, rank, initializers, l) { @@ -6125,7 +6145,11 @@ namespace Mono.CSharp return this.initializers; } } - + + public List Arguments { + get { return this.arguments; } + } + bool CheckIndices (ResolveContext ec, ArrayInitializer probe, int idx, bool specified_dims, int child_bounds) { if (initializers != null && bounds == null) { @@ -6198,7 +6222,7 @@ namespace Mono.CSharp Expression element = ResolveArrayElement (ec, o); if (element == null) continue; - +#if STATIC // Initializers with the default values can be ignored Constant c = element as Constant; if (c != null) { @@ -6208,7 +6232,7 @@ namespace Mono.CSharp } else { only_constant_initializers = false; } - +#endif array_data.Add (element); } } @@ -6311,7 +6335,9 @@ namespace Mono.CSharp protected bool ResolveInitializers (ResolveContext ec) { +#if STATIC only_constant_initializers = true; +#endif if (arguments != null) { bool res = true; @@ -6638,6 +6664,11 @@ namespace Mono.CSharp } public override void Emit (EmitContext ec) + { + EmitToFieldSource (ec); + } + + protected sealed override FieldExpr EmitToFieldSource (EmitContext ec) { if (first_emit != null) { first_emit.Emit (ec); @@ -6657,7 +6688,7 @@ namespace Mono.CSharp ec.EmitArrayNew ((ArrayContainer) type); if (initializers == null) - return; + return await_stack_field; if (await_stack_field != null) await_stack_field.EmitAssignFromStack (ec); @@ -6682,11 +6713,10 @@ namespace Mono.CSharp EmitDynamicInitializers (ec, true, await_stack_field); } - if (await_stack_field != null) - await_stack_field.Emit (ec); - if (first_emit_temp != null) first_emit_temp.Release (ec); + + return await_stack_field; } public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType) @@ -6985,15 +7015,7 @@ namespace Mono.CSharp return null; AnonymousMethodStorey storey = ae.Storey; - while (storey != null) { - AnonymousMethodStorey temp = storey.Parent as AnonymousMethodStorey; - if (temp == null) - return storey.HoistedThis; - - storey = temp; - } - - return null; + return storey != null ? storey.HoistedThis : null; } public static bool IsThisAvailable (ResolveContext ec, bool ignoreAnonymous) @@ -7022,11 +7044,20 @@ namespace Mono.CSharp var block = ec.CurrentBlock; if (block != null) { - if (block.ParametersBlock.TopBlock.ThisVariable != null) - variable_info = block.ParametersBlock.TopBlock.ThisVariable.VariableInfo; + var top = block.ParametersBlock.TopBlock; + if (top.ThisVariable != null) + variable_info = top.ThisVariable.VariableInfo; AnonymousExpression am = ec.CurrentAnonymousMethod; - if (am != null && ec.IsVariableCapturingRequired) { + if (am != null && ec.IsVariableCapturingRequired && !block.Explicit.HasCapturedThis) { + // + // Hoisted this is almost like hoisted variable but not exactly. When + // there is no variable hoisted we can simply emit an instance method + // without lifting this into a storey. Unfotunatelly this complicates + // this in other cases because we don't know where this will be hoisted + // until top-level block is fully resolved + // + top.AddThisReferenceFromChildrenBlock (block.Explicit); am.SetHasThisAccess (); } } @@ -7429,9 +7460,7 @@ namespace Mono.CSharp if (typearg == null) return null; - if (typearg.Kind == MemberKind.Void && !(QueriedType is TypeExpression)) { - ec.Report.Error (673, loc, "System.Void cannot be used from C#. Use typeof (void) to get the void type object"); - } else if (typearg.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { + if (typearg.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { ec.Report.Error (1962, QueriedType.Location, "The typeof operator cannot be used on the dynamic type"); } @@ -8435,8 +8464,11 @@ namespace Mono.CSharp return new IndexerExpr (indexers, type, this); } - ec.Report.Error (21, loc, "Cannot apply indexing with [] to an expression of type `{0}'", - type.GetSignatureForError ()); + if (type != InternalType.ErrorType) { + ec.Report.Error (21, loc, "Cannot apply indexing with [] to an expression of type `{0}'", + type.GetSignatureForError ()); + } + return null; } @@ -9258,11 +9290,15 @@ namespace Mono.CSharp return this; } + public override void Error_ValueAssignment (ResolveContext rc, Expression rhs) + { + } + public override void Error_UnexpectedKind (ResolveContext ec, ResolveFlags flags, Location loc) { } - public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) + public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl) { } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs index afe427c20..d38ecc945 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs @@ -232,12 +232,14 @@ namespace Mono.CSharp { if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder); - } else if (!(Parent is CompilerGeneratedClass) && member_type.HasDynamicElement) { + } else if (!Parent.IsCompilerGenerated && member_type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder, member_type, Location); } if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated) Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (FieldBuilder); + if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0) + Module.PredefinedAttributes.DebuggerBrowsable.EmitAttribute (FieldBuilder, System.Diagnostics.DebuggerBrowsableState.Never); if (OptAttributes != null) { OptAttributes.Emit (); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs index f8d349f78..6f1b92cbe 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs @@ -422,6 +422,12 @@ namespace Mono.CSharp { } } + bool ITypeDefinition.IsPartial { + get { + return false; + } + } + public bool IsMethodTypeParameter { get { return spec.IsMethodOwned; @@ -2146,10 +2152,6 @@ namespace Mono.CSharp { this.args = args; } - public TypeArguments TypeArguments { - get { return args; } - } - public override string GetSignatureForError () { return TypeManager.CSharpName (type); @@ -2504,7 +2506,7 @@ namespace Mono.CSharp { return false; } - bool HasDefaultConstructor (TypeSpec atype) + static bool HasDefaultConstructor (TypeSpec atype) { var tp = atype as TypeParameterSpec; if (tp != null) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs index 7a3081c7c..541a407fa 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs @@ -912,7 +912,7 @@ namespace Mono.CSharp // Test for a custom attribute type match. Custom attributes are not really predefined globaly // they can be assembly specific therefore we do check based on names only // - public bool HasAttribute (IList attributesData, string attrName, string attrNamespace) + public static bool HasAttribute (IList attributesData, string attrName, string attrNamespace) { if (attributesData.Count == 0) return false; @@ -1744,6 +1744,12 @@ namespace Mono.CSharp } } + bool ITypeDefinition.IsPartial { + get { + return false; + } + } + public override string Name { get { if (name == null) { @@ -1940,7 +1946,7 @@ namespace Mono.CSharp continue; // Ignore compiler generated methods - if (importer.HasAttribute (CustomAttributeData.GetCustomAttributes (mb), "CompilerGeneratedAttribute", MetadataImporter.CompilerServicesNamespace)) + if (MetadataImporter.HasAttribute (CustomAttributeData.GetCustomAttributes (mb), "CompilerGeneratedAttribute", MetadataImporter.CompilerServicesNamespace)) continue; } @@ -2068,6 +2074,12 @@ namespace Mono.CSharp } } + bool ITypeDefinition.IsPartial { + get { + return false; + } + } + public string Namespace { get { return null; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs index d47d2ddd2..2586eada9 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs @@ -11,12 +11,9 @@ // Copyright 2011 Xamarin Inc. // -// TODO: -// Flow analysis for Yield. -// - using System; using System.Collections.Generic; +using Mono.CompilerServices.SymbolWriter; #if STATIC using IKVM.Reflection.Emit; @@ -159,9 +156,10 @@ namespace Mono.CSharp Field pc_field; StateMachineMethod method; + int local_name_idx; - protected StateMachine (Block block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name) - : base (block, parent, host, tparams, name) + protected StateMachine (ParametersBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind) + : base (block, parent, host, tparams, name, kind) { } @@ -196,6 +194,14 @@ namespace Mono.CSharp return base.DoDefineMembers (); } + + protected override string GetVariableMangledName (LocalVariable local_info) + { + if (local_info.IsCompilerGenerated) + return base.GetVariableMangledName (local_info); + + return "<" + local_info.Name + ">__" + local_name_idx++.ToString ("X"); + } } class IteratorStorey : StateMachine @@ -398,17 +404,13 @@ namespace Mono.CSharp TypeExpr iterator_type_expr; Field current_field; Field disposing_field; - int local_name_idx; - TypeExpr enumerator_type; - TypeExpr enumerable_type; - TypeArguments generic_args; - TypeExpr generic_enumerator_type; - TypeExpr generic_enumerable_type; + TypeSpec generic_enumerator_type; + TypeSpec generic_enumerable_type; public IteratorStorey (Iterator iterator) : base (iterator.Container.ParametersBlock, iterator.Host, - iterator.OriginalMethod as MemberBase, iterator.OriginalMethod.CurrentTypeParameters, "Iterator") + iterator.OriginalMethod as MemberBase, iterator.OriginalMethod.CurrentTypeParameters, "Iterator", MemberKind.Class) { this.Iterator = iterator; } @@ -436,33 +438,30 @@ namespace Mono.CSharp mtype = Mutator.Mutate (mtype); iterator_type_expr = new TypeExpression (mtype, Location); - generic_args = new TypeArguments (iterator_type_expr); - var list = new List (); + var ifaces = new List (5); if (Iterator.IsEnumerable) { - enumerable_type = new TypeExpression (Compiler.BuiltinTypes.IEnumerable, Location); - list.Add (enumerable_type); + ifaces.Add (Compiler.BuiltinTypes.IEnumerable); if (Module.PredefinedTypes.IEnumerableGeneric.Define ()) { - generic_enumerable_type = new GenericTypeExpr (Module.PredefinedTypes.IEnumerableGeneric.TypeSpec, generic_args, Location); - list.Add (generic_enumerable_type); + generic_enumerable_type = Module.PredefinedTypes.IEnumerableGeneric.TypeSpec.MakeGenericType (Module, new[] { mtype }); + ifaces.Add (generic_enumerable_type); } } - enumerator_type = new TypeExpression (Compiler.BuiltinTypes.IEnumerator, Location); - list.Add (enumerator_type); - - list.Add (new TypeExpression (Compiler.BuiltinTypes.IDisposable, Location)); + ifaces.Add (Compiler.BuiltinTypes.IEnumerator); + ifaces.Add (Compiler.BuiltinTypes.IDisposable); var ienumerator_generic = Module.PredefinedTypes.IEnumeratorGeneric; if (ienumerator_generic.Define ()) { - generic_enumerator_type = new GenericTypeExpr (ienumerator_generic.TypeSpec, generic_args, Location); - list.Add (generic_enumerator_type); + generic_enumerator_type = ienumerator_generic.TypeSpec.MakeGenericType (Module, new [] { mtype }); + ifaces.Add (generic_enumerator_type); } - type_bases = list; + base_class = null; - return base.ResolveBaseTypes (out base_class); + base_type = Compiler.BuiltinTypes.Object; + return ifaces.ToArray (); } protected override bool DoDefineMembers () @@ -496,20 +495,20 @@ namespace Mono.CSharp var name = new MemberName ("GetEnumerator", null, explicit_iface, Location.Null); if (generic_enumerator_type != null) { - explicit_iface = new GenericTypeExpr (Module.PredefinedTypes.IEnumerableGeneric.Resolve (), generic_args, Location); + explicit_iface = new TypeExpression (generic_enumerable_type, Location); var gname = new MemberName ("GetEnumerator", null, explicit_iface, Location.Null); - Method gget_enumerator = GetEnumeratorMethod.Create (this, generic_enumerator_type, gname); + Method gget_enumerator = GetEnumeratorMethod.Create (this, new TypeExpression (generic_enumerator_type, Location), gname); // // Just call generic GetEnumerator implementation // var stmt = new Return (new Invocation (new DynamicMethodGroupExpr (gget_enumerator, Location), null), Location); - Method get_enumerator = GetEnumeratorMethod.Create (this, enumerator_type, name, stmt); + Method get_enumerator = GetEnumeratorMethod.Create (this, new TypeExpression (Compiler.BuiltinTypes.IEnumerator, Location), name, stmt); Members.Add (get_enumerator); Members.Add (gget_enumerator); } else { - Members.Add (GetEnumeratorMethod.Create (this, enumerator_type, name)); + Members.Add (GetEnumeratorMethod.Create (this, new TypeExpression (Compiler.BuiltinTypes.IEnumerator, Location), name)); } } @@ -522,7 +521,7 @@ namespace Mono.CSharp FullNamedExpression explicit_iface; if (is_generic) { - explicit_iface = new GenericTypeExpr (Module.PredefinedTypes.IEnumeratorGeneric.Resolve (), generic_args, Location); + explicit_iface = new TypeExpression (generic_enumerator_type, Location); type = iterator_type_expr; } else { explicit_iface = new TypeExpression (Module.Compiler.BuiltinTypes.IEnumerator, Location); @@ -563,16 +562,11 @@ 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) + protected override void EmitHoistedParameters (EmitContext ec, List hoisted) { base.EmitHoistedParameters (ec, hoisted); base.EmitHoistedParameters (ec, hoisted_params_copy); } - - protected override string GetVariableMangledName (LocalVariable local_info) - { - return "<" + local_info.Name + ">__" + local_name_idx++.ToString ("X"); - } } public class StateMachineMethod : Method @@ -587,9 +581,9 @@ namespace Mono.CSharp Block = new ToplevelBlock (host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null); } - public override EmitContext CreateEmitContext (ILGenerator ig) + public override EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod) { - EmitContext ec = new EmitContext (this, ig, MemberType); + EmitContext ec = new EmitContext (this, ig, MemberType, sourceMethod); ec.CurrentAnonymousMethod = expr; if (expr is AsyncInitializer) @@ -625,6 +619,12 @@ namespace Mono.CSharp { state_machine.EmitMoveNext (ec); } + + public override void Emit (EmitContext ec) + { + // Don't create sequence point + DoEmit (ec); + } } public readonly TypeDefinition Host; @@ -698,8 +698,6 @@ namespace Mono.CSharp protected override Expression DoResolve (ResolveContext ec) { - storey = (StateMachine) block.Parent.ParametersBlock.AnonymousMethodStorey; - var ctx = CreateBlockContext (ec); Block.Resolve (ctx); @@ -726,7 +724,7 @@ namespace Mono.CSharp public override void Emit (EmitContext ec) { // - // Load Iterator storey instance + // Load state machine instance // storey.Instance.Emit (ec); } @@ -745,11 +743,7 @@ namespace Mono.CSharp iterator_body_end = ec.DefineLabel (); - if (ec.EmitAccurateDebugInfo && ec.Mark (Block.Original.StartLocation)) { - ec.Emit (OpCodes.Nop); - } - - block.Emit (ec); + block.EmitEmbedded (ec); ec.MarkLabel (iterator_body_end); @@ -812,11 +806,7 @@ namespace Mono.CSharp iterator_body_end = ec.DefineLabel (); - if (ec.EmitAccurateDebugInfo && ec.Mark (Block.Original.StartLocation)) { - ec.Emit (OpCodes.Nop); - } - - block.Emit (ec); + block.EmitEmbedded (ec); ec.MarkLabel (iterator_body_end); @@ -901,16 +891,51 @@ namespace Mono.CSharp ec.Emit (OpCodes.Stloc, skip_finally); } } + + public void SetStateMachine (StateMachine stateMachine) + { + this.storey = stateMachine; + } } // - // Iterators are implemented as hidden anonymous block + // Iterators are implemented as state machine blocks // public class Iterator : StateMachineInitializer { + sealed class TryFinallyBlockProxyStatement : Statement + { + TryFinallyBlock block; + Iterator iterator; + + public TryFinallyBlockProxyStatement (Iterator iterator, TryFinallyBlock block) + { + this.iterator = iterator; + this.block = block; + } + + protected override void CloneTo (CloneContext clonectx, Statement target) + { + throw new NotSupportedException (); + } + + protected override void DoEmit (EmitContext ec) + { + // + // Restore redirection for any captured variables + // + ec.CurrentAnonymousMethod = iterator; + + using (ec.With (BuilderContext.Options.OmitDebugInfo, !ec.HasMethodSymbolBuilder)) { + block.EmitFinallyBody (ec); + } + } + } + public readonly IMethodData OriginalMethod; public readonly bool IsEnumerable; public readonly TypeSpec OriginalIteratorType; + int finally_hosts_counter; public Iterator (ParametersBlock block, IMethodData method, TypeDefinition host, TypeSpec iterator_type, bool is_enumerable) : base (block, host, host.Compiler.BuiltinTypes.Bool) @@ -921,7 +946,9 @@ namespace Mono.CSharp this.type = method.ReturnType; } - public Block Container { + #region Properties + + public ToplevelBlock Container { get { return OriginalMethod.Block; } } @@ -933,6 +960,22 @@ namespace Mono.CSharp get { return true; } } + #endregion + + public Method CreateFinallyHost (TryFinallyBlock block) + { + var method = new Method (storey, new TypeExpression (storey.Compiler.BuiltinTypes.Void, loc), + Modifiers.COMPILER_GENERATED, new MemberName (CompilerGeneratedContainer.MakeName (null, null, "Finally", finally_hosts_counter++), loc), + ParametersCompiled.EmptyReadOnlyParameters, null); + + method.Block = new ToplevelBlock (method.Compiler, method.ParameterInfo, loc); + method.Block.IsCompilerGenerated = true; + method.Block.AddStatement (new TryFinallyBlockProxyStatement (this, block)); + + storey.AddMember (method); + return method; + } + public void EmitYieldBreak (EmitContext ec, bool unwind_protect) { ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, move_next_error); @@ -968,11 +1011,13 @@ namespace Mono.CSharp public void EmitDispose (EmitContext ec) { + if (resume_points == null) + return; + 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) { + for (int i = 0; i < resume_points.Count; ++i) { ResumableStatement s = resume_points[i]; Label ret = s.PrepareForDispose (ec, end); if (ret.Equals (end) && labels == null) @@ -1062,7 +1107,7 @@ namespace Mono.CSharp for (int i = 0; i < parameters.Count; i++) { Parameter p = parameters [i]; Parameter.Modifier mod = p.ModFlags; - if ((mod & Parameter.Modifier.ISBYREF) != 0) { + if ((mod & Parameter.Modifier.RefOutMask) != 0) { parent.Compiler.Report.Error (1623, p.Location, "Iterators cannot have ref or out parameters"); return; @@ -1085,7 +1130,7 @@ namespace Mono.CSharp parent.Compiler.Report.Error (1629, method.Location, "Unsafe code may not appear in iterators"); } - method.Block.WrapIntoIterator (method, parent, iterator_type, is_enumerable); + method.Block = method.Block.ConvertToIterator (method, parent, iterator_type, is_enumerable); } static bool CheckType (TypeSpec ret, TypeContainer parent, out TypeSpec original_iterator_type, out bool is_enumerable) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.cs index f1cc07b19..d972450fc 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/lambda.cs @@ -81,7 +81,7 @@ namespace Mono.CSharp { TypeSpec [] ptypes = new TypeSpec [Parameters.Count]; for (int i = 0; i < d_params.Count; i++) { // D has no ref or out parameters - if ((d_params.FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) != 0) + if ((d_params.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != 0) return null; TypeSpec d_param = d_params.Types [i]; @@ -191,7 +191,7 @@ namespace Mono.CSharp { return Expr.CreateExpressionTree (ec); } - public override void Emit (EmitContext ec) + protected override void DoEmit (EmitContext ec) { if (statement != null) { statement.EmitStatement (ec); @@ -203,7 +203,7 @@ namespace Mono.CSharp { return; } - base.Emit (ec); + base.DoEmit (ec); } protected override bool DoResolve (BlockContext ec) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/linq.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/linq.cs index 4fd1254ff..1c93d6046 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/linq.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/linq.cs @@ -90,6 +90,13 @@ namespace Mono.CSharp.Linq return rmg; } + protected override Expression DoResolveDynamic (ResolveContext ec, Expression memberExpr) + { + ec.Report.Error (1979, loc, + "Query expressions with a source or join sequence of type `dynamic' are not allowed"); + return null; + } + #region IErrorHandler Members bool OverloadResolver.IErrorHandler.AmbiguousCandidates (ResolveContext ec, MemberSpec best, MemberSpec ambiguous) @@ -422,19 +429,6 @@ namespace Mono.CSharp.Linq public override Expression BuildQueryClause (ResolveContext ec, Expression lSide, Parameter parameter) { -/* - expr = expr.Resolve (ec); - if (expr == null) - return null; - - if (expr.Type == InternalType.Dynamic || expr.Type == TypeManager.void_type) { - ec.Report.Error (1979, expr.Location, - "Query expression with a source or join sequence of type `{0}' is not allowed", - TypeManager.CSharpName (expr.Type)); - return null; - } -*/ - if (IdentifierType != null) expr = CreateCastExpression (expr); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/literal.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/literal.cs index bb0370914..bdbd57a4f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/literal.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/literal.cs @@ -50,7 +50,7 @@ namespace Mono.CSharp { } - public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec t, bool expl) + public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec t, bool expl) { if (t.IsGenericParameter) { ec.Report.Error(403, loc, @@ -65,7 +65,7 @@ namespace Mono.CSharp return; } - base.Error_ValueCannotBeConverted (ec, loc, t, expl); + base.Error_ValueCannotBeConverted (ec, t, expl); } public override string GetValueAsLiteral () @@ -253,7 +253,7 @@ namespace Mono.CSharp { } - public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl) + public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl) { if (target.BuiltinType == BuiltinTypeSpec.Type.Float) { Error_664 (ec, loc, "float", "f"); @@ -265,7 +265,7 @@ namespace Mono.CSharp return; } - base.Error_ValueCannotBeConverted (ec, loc, target, expl); + base.Error_ValueCannotBeConverted (ec, target, expl); } static void Error_664 (ResolveContext ec, Location loc, string type, string suffix) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs index 9333ac817..337c378e5 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs @@ -11,7 +11,6 @@ // using System; -using System.IO; using System.Collections.Generic; using Mono.CompilerServices.SymbolWriter; using System.Diagnostics; @@ -81,15 +80,15 @@ namespace Mono.CSharp this.checksum = checksum; } - public SourceFileEntry CreateSymbolInfo (MonoSymbolWriter symwriter) + public SourceFileEntry CreateSymbolInfo (MonoSymbolFile symwriter) { if (hidden_lines != null) hidden_lines.Sort (); - if (guid != null) - file = symwriter.DefineDocument (FullPathName, guid, checksum); - else { - file = symwriter.DefineDocument (FullPathName); + if (guid != null) { + file = new SourceFileEntry (symwriter, FullPathName, guid, checksum); + } else { + file = new SourceFileEntry (symwriter, FullPathName); if (AutoGenerated) file.SetAutoGenerated (); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs index 2b4bbf7e7..5374da9db 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs @@ -73,15 +73,6 @@ namespace Mono.CSharp { public readonly TypeSpec MemberType; public readonly int Arity; // -1 to ignore the check - private MemberFilter (string name, MemberKind kind) - { - Name = name; - Kind = kind; - Parameters = null; - MemberType = null; - Arity = -1; - } - public MemberFilter (MethodSpec m) { Name = m.Name; @@ -797,7 +788,7 @@ namespace Mono.CSharp { while (true) { foreach (var entry in abstract_type.MemberCache.member_hash) { foreach (var name_entry in entry.Value) { - if ((name_entry.Modifiers & Modifiers.ABSTRACT) == 0) + if ((name_entry.Modifiers & (Modifiers.ABSTRACT | Modifiers.OVERRIDE)) != Modifiers.ABSTRACT) continue; if (name_entry.Kind != MemberKind.Method) @@ -846,6 +837,12 @@ namespace Mono.CSharp { if ((item.Modifiers & (Modifiers.OVERRIDE | Modifiers.VIRTUAL)) == 0) continue; + // + // Abstract override does not override anything + // + if ((item.Modifiers & Modifiers.ABSTRACT) != 0) + continue; + if (filter.Equals (item)) { --not_implemented_count; abstract_methods [i] = null; @@ -1163,8 +1160,9 @@ namespace Mono.CSharp { if (container.BaseType == null) { locase_members = new Dictionary (member_hash.Count); // StringComparer.OrdinalIgnoreCase); } else { - container.BaseType.MemberCache.VerifyClsCompliance (container.BaseType, report); - locase_members = new Dictionary (container.BaseType.MemberCache.locase_members); //, StringComparer.OrdinalIgnoreCase); + var btype = container.BaseType.GetDefinition (); + btype.MemberCache.VerifyClsCompliance (btype, report); + locase_members = new Dictionary (btype.MemberCache.locase_members); //, StringComparer.OrdinalIgnoreCase); } var is_imported_type = container.MemberDefinition.IsImported; @@ -1354,8 +1352,10 @@ namespace Mono.CSharp { type_a = parameters.Types [ii]; type_b = p_types [ii]; - if ((pd.FixedParameters [ii].ModFlags & Parameter.Modifier.ISBYREF) != - (parameters.FixedParameters [ii].ModFlags & Parameter.Modifier.ISBYREF)) + var a_byref = (pd.FixedParameters[ii].ModFlags & Parameter.Modifier.RefOutMask) != 0; + var b_byref = (parameters.FixedParameters[ii].ModFlags & Parameter.Modifier.RefOutMask) != 0; + + if (a_byref != b_byref) break; } while (TypeSpecComparer.Override.IsEqual (type_a, type_b) && ii-- != 0); @@ -1374,7 +1374,9 @@ namespace Mono.CSharp { // if (pd != null && member is MethodCore) { ii = method_param_count; - while (ii-- != 0 && parameters.FixedParameters[ii].ModFlags == pd.FixedParameters[ii].ModFlags && + while (ii-- != 0 && + (parameters.FixedParameters[ii].ModFlags & Parameter.Modifier.ModifierMask) == + (pd.FixedParameters[ii].ModFlags & Parameter.Modifier.ModifierMask) && parameters.ExtensionMethodType == pd.ExtensionMethodType) ; if (ii >= 0) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs index a45ccdcaf..5f15beb0b 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs @@ -18,6 +18,8 @@ using System.Security; using System.Security.Permissions; using System.Text; using System.Linq; +using Mono.CompilerServices.SymbolWriter; +using System.Runtime.CompilerServices; #if NET_2_1 using XmlElement = System.Object; @@ -37,8 +39,6 @@ using System.Reflection; using System.Reflection.Emit; #endif -using Mono.CompilerServices.SymbolWriter; - namespace Mono.CSharp { public abstract class MethodCore : InterfaceMemberBase, IParametersMember @@ -534,10 +534,13 @@ namespace Mono.CSharp { } if (a.Type == pa.MethodImpl) { - is_external_implementation = a.IsInternalCall (); - } + if ((ModFlags & Modifiers.ASYNC) != 0 && (a.GetMethodImplOptions () & MethodImplOptions.Synchronized) != 0) { + Report.Error (4015, a.Location, "`{0}': Async methods cannot use `MethodImplOptions.Synchronized'", + GetSignatureForError ()); + } - if (a.Type == pa.DllImport) { + is_external_implementation = a.IsInternalCall (); + } else if (a.Type == pa.DllImport) { const Modifiers extern_static = Modifiers.EXTERN | Modifiers.STATIC; if ((ModFlags & extern_static) != extern_static) { Report.Error (601, a.Location, "The DllImport attribute must be specified on a method marked `static' and `extern'"); @@ -565,9 +568,9 @@ namespace Mono.CSharp { return Parent.MemberCache.CheckExistingMembersOverloads (this, parameters); } - public virtual EmitContext CreateEmitContext (ILGenerator ig) + public virtual EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod) { - return new EmitContext (this, ig, MemberType); + return new EmitContext (this, ig, MemberType, sourceMethod); } public override bool Define () @@ -634,7 +637,7 @@ namespace Mono.CSharp { if ((ModFlags & Modifiers.PARTIAL) != 0) { for (int i = 0; i < parameters.Count; ++i) { IParameterData p = parameters.FixedParameters [i]; - if (p.ModFlags == Parameter.Modifier.OUT) { + if ((p.ModFlags & Parameter.Modifier.OUT) != 0) { Report.Error (752, Location, "`{0}': A partial method parameters cannot use `out' modifier", GetSignatureForError ()); } @@ -691,7 +694,6 @@ namespace Mono.CSharp { MethodData.Emit (Parent); Block = null; - MethodData = null; } protected void Error_ConditionalAttributeIsNotValid () @@ -776,53 +778,10 @@ namespace Mono.CSharp { #endregion - } - - public class SourceMethod : IMethodDef - { - MethodBase method; - - SourceMethod (MethodBase method, ICompileUnit file) + public override void WriteDebugSymbol (MonoSymbolFile file) { - this.method = method; - SymbolWriter.OpenMethod (file, this); - } - - public string Name { - get { return method.Name; } - } - - public int Token { - get { - MethodToken token; - var mb = method as MethodBuilder; - if (mb != null) - token = mb.GetToken (); - else - token = ((ConstructorBuilder) method).GetToken (); -#if STATIC - if (token.IsPseudoToken) - return ((ModuleBuilder) method.Module).ResolvePseudoToken (token.Token); -#endif - return token.Token; - } - } - - public void CloseMethod () - { - SymbolWriter.CloseMethod (); - } - - public static SourceMethod Create (TypeDefinition parent, MethodBase method) - { - if (!SymbolWriter.HasSymbolWriter) - return null; - - var source_file = parent.GetCompilationSourceFile (); - if (source_file == null) - return null; - - return new SourceMethod (method, source_file.SymbolUnitEntry); + if (MethodData != null) + MethodData.WriteDebugSymbol (file); } } @@ -933,7 +892,7 @@ namespace Mono.CSharp { var ac = parameters.Types [0] as ArrayContainer; return ac != null && ac.Rank == 1 && ac.Element.BuiltinType == BuiltinTypeSpec.Type.String && - (parameters[0].ModFlags & ~Parameter.Modifier.PARAMS) == Parameter.Modifier.NONE; + (parameters[0].ModFlags & Parameter.Modifier.RefOutMask) == 0; } public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc) @@ -981,7 +940,7 @@ namespace Mono.CSharp { } for (int i = 0; i < parameters.Count; ++i) { - if (parameters.FixedParameters [i].ModFlags == Parameter.Modifier.OUT) { + if ((parameters.FixedParameters [i].ModFlags & Parameter.Modifier.OUT) != 0) { Report.Error (685, Location, "Conditional method `{0}' cannot have an out parameter", GetSignatureForError ()); return; } @@ -1237,7 +1196,8 @@ namespace Mono.CSharp { Report.Error (1983, Location, "The return type of an async method must be void, Task, or Task"); } - AsyncInitializer.Create (this, block, parameters, Parent.PartialContainer, ReturnType, Location); + block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, Location); + ModFlags |= Modifiers.DEBUGGER_HIDDEN; } } @@ -1505,11 +1465,13 @@ namespace Mono.CSharp { } } - public class Constructor : MethodCore, IMethodData { + public class Constructor : MethodCore, IMethodData + { public ConstructorBuilder ConstructorBuilder; public ConstructorInitializer Initializer; SecurityType declarative_security; bool has_compliant_args; + SourceMethodBuilder debug_builder; // // Modifiers allowed for a constructor. @@ -1546,9 +1508,9 @@ namespace Mono.CSharp { } bool IMethodData.IsAccessor { - get { - return false; - } + get { + return false; + } } // @@ -1704,26 +1666,20 @@ namespace Mono.CSharp { if (Initializer != null) { // - // Use location of the constructor to emit sequence point of initializers - // at beginning of constructor name - // - // TODO: Need to extend mdb to support line regions to allow set a breakpoint at - // initializer + // mdb format does not support reqions. Try to workaround this by emitting the + // sequence point at initializer. Any breakpoint at constructor header should + // be adjusted to this sequence point as it's the next one which follows. // - block.AddScopeStatement (new StatementExpression (Initializer, Location)); + block.AddScopeStatement (new StatementExpression (Initializer)); } } if (block.Resolve (null, bc, this)) { - EmitContext ec = new EmitContext (this, ConstructorBuilder.GetILGenerator (), bc.ReturnType); + debug_builder = Parent.CreateMethodSymbolEntry (); + EmitContext ec = new EmitContext (this, ConstructorBuilder.GetILGenerator (), bc.ReturnType, debug_builder); ec.With (EmitContext.Options.ConstructorScope, true); - SourceMethod source = SourceMethod.Create (Parent, ConstructorBuilder); - block.Emit (ec); - - if (source != null) - source.CloseMethod (); } } @@ -1747,6 +1703,11 @@ namespace Mono.CSharp { return null; } + public override string GetCallerMemberName () + { + return IsStatic ? TypeConstructorName : ConstructorName; + } + public override string GetSignatureForDocumentation () { return Parent.GetSignatureForDocumentation () + ".#ctor" + parameters.GetSignatureForDocumentation (); @@ -1781,6 +1742,21 @@ namespace Mono.CSharp { return true; } + public override void WriteDebugSymbol (MonoSymbolFile file) + { + if (debug_builder == null) + return; + + var token = ConstructorBuilder.GetToken (); + int t = token.Token; +#if STATIC + if (token.IsPseudoToken) + t = Module.Builder.ResolvePseudoToken (t); +#endif + + debug_builder.DefineMethod (file, t); + } + #region IMethodData Members public MemberName MethodName { @@ -1795,16 +1771,11 @@ namespace Mono.CSharp { } } - public EmitContext CreateEmitContext (ILGenerator ig) + EmitContext IMethodData.CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod) { throw new NotImplementedException (); } - public bool IsExcluded() - { - return false; - } - #endregion } @@ -1824,7 +1795,7 @@ namespace Mono.CSharp { Attributes OptAttributes { get; } ToplevelBlock Block { get; set; } - EmitContext CreateEmitContext (ILGenerator ig); + EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod); } // @@ -1851,6 +1822,7 @@ namespace Mono.CSharp { protected MethodAttributes flags; protected TypeSpec declaring_type; protected MethodSpec parent_method; + SourceMethodBuilder debug_builder; MethodBuilder builder; public MethodBuilder MethodBuilder { @@ -2103,17 +2075,28 @@ namespace Mono.CSharp { if (block != null) { BlockContext bc = new BlockContext (mc, block, method.ReturnType); if (block.Resolve (null, bc, method)) { - EmitContext ec = method.CreateEmitContext (MethodBuilder.GetILGenerator ()); - - SourceMethod source = SourceMethod.Create (parent, MethodBuilder); + debug_builder = member.Parent.CreateMethodSymbolEntry (); + EmitContext ec = method.CreateEmitContext (MethodBuilder.GetILGenerator (), debug_builder); block.Emit (ec); - - if (source != null) - source.CloseMethod (); } } } + + public void WriteDebugSymbol (MonoSymbolFile file) + { + if (debug_builder == null) + return; + + var token = builder.GetToken (); + int t = token.Token; +#if STATIC + if (token.IsPseudoToken) + t = member.Module.Builder.ResolvePseudoToken (t); +#endif + + debug_builder.DefineMethod (file, t); + } } public class Destructor : MethodOrOperator @@ -2126,6 +2109,11 @@ namespace Mono.CSharp { public static readonly string MetadataName = "Finalize"; + public string Identifier { + get; + set; + } + public Destructor (TypeDefinition parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l) : base (parent, null, mod, AllowedModifiers, new MemberName (MetadataName, l), attrs, parameters) { @@ -2251,9 +2239,9 @@ namespace Mono.CSharp { } } - public EmitContext CreateEmitContext (ILGenerator ig) + public EmitContext CreateEmitContext (ILGenerator ig, SourceMethodBuilder sourceMethod) { - return new EmitContext (this, ig, ReturnType); + return new EmitContext (this, ig, ReturnType, sourceMethod); } public bool IsAccessor { @@ -2262,11 +2250,6 @@ namespace Mono.CSharp { } } - public bool IsExcluded () - { - return false; - } - public MemberName MethodName { get { return MemberName; @@ -2373,6 +2356,11 @@ namespace Mono.CSharp { return false; } + public override string GetCallerMemberName () + { + return base.GetCallerMemberName ().Substring (prefix.Length); + } + public override string GetSignatureForDocumentation () { // should not be called @@ -2384,6 +2372,12 @@ namespace Mono.CSharp { return false; } + public override void WriteDebugSymbol (MonoSymbolFile file) + { + if (method_data != null) + method_data.WriteDebugSymbol (file); + } + public MethodSpec Spec { get; protected set; } // diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs index 85d4ff42d..3117053fc 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs @@ -36,13 +36,14 @@ namespace Mono.CSharp // // Compiler generated container for static data // - sealed class StaticDataContainer : CompilerGeneratedClass + sealed class StaticDataContainer : CompilerGeneratedContainer { readonly Dictionary size_types; int fields; public StaticDataContainer (ModuleContainer module) - : base (module, new MemberName ("" + module.builder.ModuleVersionId.ToString ("B"), Location.Null), Modifiers.STATIC) + : base (module, new MemberName ("" + module.builder.ModuleVersionId.ToString ("B"), Location.Null), + Modifiers.STATIC | Modifiers.INTERNAL) { size_types = new Dictionary (); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs index 572d30b70..c2d4f3040 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs @@ -327,37 +327,6 @@ namespace Mono.CSharp { return te; } - TypeSpec LookupType (string name, int arity) - { - if (types == null) - return null; - - IList found; - if (types.TryGetValue (name, out found)) { - TypeSpec best = null; - - foreach (var ts in found) { - if (ts.Arity == arity) - return ts; - - // - // Lookup for the best candidate with closest arity match - // - if (arity < 0) { - if (best == null) { - best = ts; - } else if (System.Math.Abs (ts.Arity + arity) < System.Math.Abs (best.Arity + arity)) { - best = ts; - } - } - } - - return best; - } - - return null; - } - public FullNamedExpression LookupTypeOrNamespace (IMemberContext ctx, string name, int arity, LookupMode mode, Location loc) { var texpr = LookupType (ctx, name, arity, mode, loc); @@ -446,7 +415,7 @@ namespace Mono.CSharp { types = new Dictionary> (64); } - if (ts.IsStatic && ts.Arity == 0 && + if ((ts.IsStatic || ts.MemberDefinition.IsPartial) && ts.Arity == 0 && (ts.MemberDefinition.DeclaringAssembly == null || ts.MemberDefinition.DeclaringAssembly.HasExtensionMethod)) { if (extension_method_types == null) extension_method_types = new List (); @@ -664,9 +633,9 @@ namespace Mono.CSharp { public override void PrepareEmit () { - // Compiler.SymbolWriter - if (SymbolWriter.symwriter != null) { - CreateUnitSymbolInfo (SymbolWriter.symwriter); + var sw = Module.DeclaringAssembly.SymbolWriter; + if (sw != null) { + CreateUnitSymbolInfo (sw); } base.PrepareEmit (); @@ -675,10 +644,10 @@ namespace Mono.CSharp { // // Creates symbol file index in debug symbol file // - void CreateUnitSymbolInfo (MonoSymbolWriter symwriter) + void CreateUnitSymbolInfo (MonoSymbolFile symwriter) { var si = file.CreateSymbolInfo (symwriter); - comp_unit = symwriter.DefineCompilationUnit (si); + comp_unit = new CompileUnitEntry (symwriter, si);; if (include_files != null) { foreach (SourceFile include in include_files.Values) { @@ -869,7 +838,7 @@ namespace Mono.CSharp { base.EmitContainer (); } - public ExtensionMethodCandidates LookupExtensionMethod (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity, NamespaceContainer container, int position) + public ExtensionMethodCandidates LookupExtensionMethod (IMemberContext invocationContext, TypeSpec extensionType, string name, int arity, int position) { // // Here we try to resume the search for extension method at the point @@ -890,7 +859,8 @@ namespace Mono.CSharp { // checked before we hit A.N1 using // ExtensionMethodCandidates candidates; - for (; container != null; container = container.Parent) { + var container = this; + do { candidates = container.LookupExtensionMethodCandidates (invocationContext, extensionType, name, arity, ref position); if (candidates != null || container.MemberName == null) return candidates; @@ -916,7 +886,8 @@ namespace Mono.CSharp { } position = 0; - } + container = container.Parent; + } while (container != null); return null; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs index c2cdd700e..1e46767cf 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs @@ -494,7 +494,7 @@ namespace Mono.CSharp.Nullable ec.MarkLabel (end_label); } - Expression LiftExpression (ResolveContext ec, Expression expr) + static Expression LiftExpression (ResolveContext ec, Expression expr) { var lifted_type = new NullableType (expr.Type, expr.Location); if (lifted_type.ResolveAsType (ec) == null) @@ -860,7 +860,7 @@ namespace Mono.CSharp.Nullable if (lifted_type == null) return null; - if (left is UserCast || left is TypeCast) + if (left is UserCast || left is EmptyCast || left is OpcodeCast) left.Type = lifted_type; else left = EmptyCast.Create (left, lifted_type); @@ -875,7 +875,7 @@ namespace Mono.CSharp.Nullable if (r is ReducedExpression) r = ((ReducedExpression) r).OriginalExpression; - if (r is UserCast || r is TypeCast) + if (r is UserCast || r is EmptyCast || r is OpcodeCast) r.Type = lifted_type; else right = EmptyCast.Create (right, lifted_type); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/parameter.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/parameter.cs index 0a5590703..365f876f0 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/parameter.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/parameter.cs @@ -209,21 +209,23 @@ namespace Mono.CSharp { [Flags] public enum Modifier : byte { NONE = 0, - REF = REFMASK | ISBYREF, - OUT = OUTMASK | ISBYREF, - PARAMS = 4, - // This is a flag which says that it's either REF or OUT. - ISBYREF = 8, - REFMASK = 32, - OUTMASK = 64, - SignatureMask = REFMASK | OUTMASK, - This = 128 + PARAMS = 1 << 0, + REF = 1 << 1, + OUT = 1 << 2, + This = 1 << 3, + CallerMemberName = 1 << 4, + CallerLineNumber = 1 << 5, + CallerFilePath = 1 << 6, + + RefOutMask = REF | OUT, + ModifierMask = PARAMS | REF | OUT | This, + CallerMask = CallerMemberName | CallerLineNumber | CallerFilePath } static readonly string[] attribute_targets = new string[] { "param" }; FullNamedExpression texpr; - readonly Modifier modFlags; + Modifier modFlags; string name; Expression default_expr; protected TypeSpec parameter_type; @@ -233,7 +235,7 @@ namespace Mono.CSharp { TemporaryVariableReference expr_tree_variable; - HoistedVariable hoisted_variant; + HoistedParameter hoisted_variant; public Parameter (FullNamedExpression type, string name, Modifier mod, Attributes attrs, Location loc) { @@ -323,7 +325,7 @@ namespace Mono.CSharp { return; } - if (a.Type == pa.Out && (ModFlags & Modifier.REF) == Modifier.REF && + if (a.Type == pa.Out && (ModFlags & Modifier.REF) != 0 && !OptAttributes.Contains (pa.In)) { a.Report.Error (662, a.Location, "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and `Out' attributes or neither"); @@ -332,9 +334,7 @@ namespace Mono.CSharp { if (a.Type == pa.CLSCompliant) { a.Report.Warning (3022, 1, a.Location, "CLSCompliant attribute has no meaning when applied to parameters. Try putting it on the method instead"); - } - - if (a.Type == pa.DefaultParameterValue || a.Type == pa.OptionalParameter) { + } else if (a.Type == pa.DefaultParameterValue || a.Type == pa.OptionalParameter) { if (HasOptionalExpression) { a.Report.Error (1745, a.Location, "Cannot specify `{0}' attribute on optional parameter `{1}'", @@ -343,6 +343,21 @@ namespace Mono.CSharp { if (a.Type == pa.DefaultParameterValue) return; + } else if (a.Type == pa.CallerMemberNameAttribute) { + if ((modFlags & Modifier.CallerMemberName) == 0) { + a.Report.Error (4022, a.Location, + "The CallerMemberName attribute can only be applied to parameters with default value"); + } + } else if (a.Type == pa.CallerLineNumberAttribute) { + if ((modFlags & Modifier.CallerLineNumber) == 0) { + a.Report.Error (4020, a.Location, + "The CallerLineNumber attribute can only be applied to parameters with default value"); + } + } else if (a.Type == pa.CallerFilePathAttribute) { + if ((modFlags & Modifier.CallerFilePath) == 0) { + a.Report.Error (4021, a.Location, + "The CallerFilePath attribute can only be applied to parameters with default value"); + } } base.ApplyAttributeBuilder (a, ctor, cdata, pa); @@ -372,15 +387,15 @@ namespace Mono.CSharp { return null; this.idx = index; - - if ((modFlags & Parameter.Modifier.ISBYREF) != 0 && parameter_type.IsSpecialRuntimeType) { + + if ((modFlags & Parameter.Modifier.RefOutMask) != 0 && parameter_type.IsSpecialRuntimeType) { rc.Module.Compiler.Report.Error (1601, Location, "Method or delegate parameter cannot be of type `{0}'", GetSignatureForError ()); return null; } TypeManager.CheckTypeVariance (parameter_type, - (modFlags & Parameter.Modifier.ISBYREF) != 0 ? Variance.None : Variance.Contravariant, + (modFlags & Parameter.Modifier.RefOutMask) != 0 ? Variance.None : Variance.Contravariant, rc); if (parameter_type.IsStatic) { @@ -397,6 +412,54 @@ namespace Mono.CSharp { return parameter_type; } + void ResolveCallerAttributes (ResolveContext rc) + { + var pa = rc.Module.PredefinedAttributes; + TypeSpec caller_type; + + foreach (var attr in attributes.Attrs) { + var atype = attr.ResolveType (); + if (atype == null) + continue; + + if (atype == pa.CallerMemberNameAttribute) { + caller_type = rc.BuiltinTypes.String; + if (caller_type != parameter_type && !Convert.ImplicitReferenceConversionExists (caller_type, parameter_type)) { + rc.Report.Error (4019, attr.Location, + "The CallerMemberName attribute cannot be applied because there is no standard conversion from `{0}' to `{1}'", + caller_type.GetSignatureForError (), parameter_type.GetSignatureForError ()); + } + + modFlags |= Modifier.CallerMemberName; + continue; + } + + if (atype == pa.CallerLineNumberAttribute) { + caller_type = rc.BuiltinTypes.Int; + if (caller_type != parameter_type && !Convert.ImplicitNumericConversionExists (caller_type, parameter_type)) { + rc.Report.Error (4017, attr.Location, + "The CallerMemberName attribute cannot be applied because there is no standard conversion from `{0}' to `{1}'", + caller_type.GetSignatureForError (), parameter_type.GetSignatureForError ()); + } + + modFlags |= Modifier.CallerLineNumber; + continue; + } + + if (atype == pa.CallerFilePathAttribute) { + caller_type = rc.BuiltinTypes.String; + if (caller_type != parameter_type && !Convert.ImplicitReferenceConversionExists (caller_type, parameter_type)) { + rc.Report.Error (4018, attr.Location, + "The CallerFilePath attribute cannot be applied because there is no standard conversion from `{0}' to `{1}'", + caller_type.GetSignatureForError (), parameter_type.GetSignatureForError ()); + } + + modFlags |= Modifier.CallerFilePath; + continue; + } + } + } + public void ResolveDefaultValue (ResolveContext rc) { // @@ -404,14 +467,17 @@ namespace Mono.CSharp { // if (default_expr != null) { ((DefaultParameterValueExpression)default_expr).Resolve (rc, this); + if (attributes != null) + ResolveCallerAttributes (rc); + return; } if (attributes == null) return; - - var opt_attr = attributes.Search (rc.Module.PredefinedAttributes.OptionalParameter); - var def_attr = attributes.Search (rc.Module.PredefinedAttributes.DefaultParameterValue); + + var pa = rc.Module.PredefinedAttributes; + var def_attr = attributes.Search (pa.DefaultParameterValue); if (def_attr != null) { if (def_attr.Resolve () == null) return; @@ -466,6 +532,7 @@ namespace Mono.CSharp { return; } + var opt_attr = attributes.Search (pa.OptionalParameter); if (opt_attr != null) { default_expr = EmptyExpression.MissingValue; } @@ -482,7 +549,7 @@ namespace Mono.CSharp { // // Hoisted parameter variant // - public HoistedVariable HoistedVariant { + public HoistedParameter HoistedVariant { get { return hoisted_variant; } @@ -611,7 +678,7 @@ namespace Mono.CSharp { public ExpressionStatement CreateExpressionTreeVariable (BlockContext ec) { - if ((modFlags & Modifier.ISBYREF) != 0) + if ((modFlags & Modifier.RefOutMask) != 0) ec.Report.Error (1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier"); expr_tree_variable = TemporaryVariableReference.Create (ResolveParameterExpressionType (ec, Location).Type, ec.CurrentBlock.ParametersBlock, Location); @@ -636,7 +703,7 @@ namespace Mono.CSharp { public void EmitAddressOf (EmitContext ec) { - if ((ModFlags & Modifier.ISBYREF) != 0) { + if ((ModFlags & Modifier.RefOutMask) != 0) { ec.EmitArgumentLoad (idx); } else { ec.EmitArgumentAddress (idx); @@ -701,7 +768,7 @@ namespace Mono.CSharp { } public Parameter.Modifier ModFlags { - get { return modifiers & ~Parameter.Modifier.This; } + get { return modifiers; } } public string Name { @@ -750,7 +817,7 @@ namespace Mono.CSharp { public static ParameterAttributes GetParameterAttribute (Parameter.Modifier modFlags) { - return (modFlags & Parameter.Modifier.OUT) == Parameter.Modifier.OUT ? + return (modFlags & Parameter.Modifier.OUT) != 0 ? ParameterAttributes.Out : ParameterAttributes.None; } @@ -773,7 +840,7 @@ namespace Mono.CSharp { for (int i = 0; i < types.Length; ++i) { types[i] = Types[i].GetMetaInfo (); - if ((FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) == 0) + if ((FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) == 0) continue; // TODO MemberCache: Should go to MetaInfo getter @@ -808,7 +875,7 @@ namespace Mono.CSharp { sb.Append (types [i].GetSignatureForDocumentation ()); - if ((parameters[i].ModFlags & Parameter.Modifier.ISBYREF) != 0) + if ((parameters[i].ModFlags & Parameter.Modifier.RefOutMask) != 0) sb.Append ("@"); } sb.Append (")"); @@ -1027,8 +1094,7 @@ namespace Mono.CSharp { var a_type = a.Types[i]; var b_type = b.Types[i]; if (TypeSpecComparer.Override.IsEqual (a_type, b_type)) { - const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT; - if ((a.FixedParameters[i].ModFlags & ref_out) != (b.FixedParameters[i].ModFlags & ref_out)) + if ((a.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != (b.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask)) res |= 1; continue; @@ -1193,7 +1259,7 @@ namespace Mono.CSharp { // Each parameter expression is stored to local variable // to save some memory when referenced later. // - StatementExpression se = new StatementExpression (p.CreateExpressionTreeVariable (ec)); + StatementExpression se = new StatementExpression (p.CreateExpressionTreeVariable (ec), Location.Null); if (se.Resolve (ec)) { ec.CurrentBlock.AddScopeStatement (new TemporaryVariableReference.Declarator (p.ExpressionTreeVariableReference ())); ec.CurrentBlock.AddScopeStatement (se); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/pending.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/pending.cs index 2f4a009ce..b33128629 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/pending.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/pending.cs @@ -305,11 +305,10 @@ namespace Mono.CSharp { // // First check exact modifiers match // - const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT; - if ((cp[pi].ModFlags & ref_out) == (tp[pi].ModFlags & ref_out)) + if ((cp[pi].ModFlags & Parameter.Modifier.RefOutMask) == (tp[pi].ModFlags & Parameter.Modifier.RefOutMask)) continue; - if ((cp[pi].ModFlags & tp[pi].ModFlags & Parameter.Modifier.ISBYREF) != 0) { + if (((cp[pi].ModFlags | tp[pi].ModFlags) & Parameter.Modifier.RefOutMask) == Parameter.Modifier.RefOutMask) { ref_only_difference = true; continue; } @@ -508,7 +507,7 @@ namespace Mono.CSharp { } int top = param.Count; - var ec = new EmitContext (new ProxyMethodContext (container), proxy.GetILGenerator (), null); + var ec = new EmitContext (new ProxyMethodContext (container), proxy.GetILGenerator (), null, null); ec.EmitThis (); // TODO: GetAllParametersArguments for (int i = 0; i < top; i++) @@ -557,8 +556,7 @@ namespace Mono.CSharp { // // First check exact ref/out match // - const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT; - if ((parameters.FixedParameters[i].ModFlags & ref_out) == (candidate_param.FixedParameters[i].ModFlags & ref_out)) + if ((parameters.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) == (candidate_param.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask)) continue; modifiers_match = false; @@ -566,7 +564,7 @@ namespace Mono.CSharp { // // Different in ref/out only // - if ((parameters.FixedParameters[i].ModFlags & candidate_param.FixedParameters[i].ModFlags & Parameter.Modifier.ISBYREF) != 0) { + if ((parameters.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != (candidate_param.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask)) { if (similar_candidate == null) { if (!candidate.IsPublic) break; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs index 0e2ee579f..c72840cce 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs @@ -15,6 +15,7 @@ using System; using System.Collections.Generic; using System.Text; +using Mono.CompilerServices.SymbolWriter; #if NET_2_1 using XmlElement = System.Object; @@ -686,6 +687,15 @@ namespace Mono.CSharp Set.UpdateName (this); } + public override void WriteDebugSymbol (MonoSymbolFile file) + { + if (get != null) + get.WriteDebugSymbol (file); + + if (set != null) + set.WriteDebugSymbol (file); + } + // // Represents header string for documentation comment. // @@ -1339,6 +1349,12 @@ namespace Mono.CSharp base.Emit (); } + public override void WriteDebugSymbol (MonoSymbolFile file) + { + add.WriteDebugSymbol (file); + remove.WriteDebugSymbol (file); + } + // // Represents header string for documentation comment. // diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs index 5181e3f32..2de023c18 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/reflection.cs @@ -166,8 +166,11 @@ namespace Mono.CSharp { [System.Runtime.InteropServices.FieldOffset (0)] int i; + +#pragma warning disable 414 [System.Runtime.InteropServices.FieldOffset (0)] float f; +#pragma warning restore 414 public static int SingleToInt32Bits (float v) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs index 64fc1bf01..50d78f007 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs @@ -55,7 +55,8 @@ namespace Mono.CSharp { 2002, 2023, 2029, 3000, 3001, 3002, 3003, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, - 3021, 3022, 3023, 3024, 3026, 3027 + 3021, 3022, 3023, 3024, 3026, 3027, + 4014 }; static HashSet AllWarningsHashSet; @@ -232,7 +233,7 @@ namespace Mono.CSharp { } extra_information.Clear (); - printer.Print (msg); + printer.Print (msg, settings.ShowFullPaths); } public void Warning (int code, int level, Location loc, string format, string arg) @@ -285,7 +286,13 @@ namespace Mono.CSharp { ErrorMessage msg = new ErrorMessage (code, loc, error, extra_information); extra_information.Clear (); - printer.Print (msg); + printer.Print (msg, settings.ShowFullPaths); + + if (settings.Stacktrace) + Console.WriteLine (FriendlyStackTrace (new StackTrace (true))); + + if (printer.ErrorsCount == settings.FatalCounter) + throw new FatalException (msg.Text); } public void Error (int code, Location loc, string format, string arg) @@ -401,7 +408,42 @@ namespace Mono.CSharp { sb.Append (")"); return sb.ToString (); } -*/ +*/ + static string FriendlyStackTrace (StackTrace t) + { + StringBuilder sb = new StringBuilder (); + + bool foundUserCode = false; + + for (int i = 0; i < t.FrameCount; i++) { + StackFrame f = t.GetFrame (i); + var mb = f.GetMethod (); + + if (!foundUserCode && mb.ReflectedType == typeof (Report)) + continue; + + foundUserCode = true; + + sb.Append ("\tin "); + + if (f.GetFileLineNumber () > 0) + sb.AppendFormat ("(at {0}:{1}) ", f.GetFileName (), f.GetFileLineNumber ()); + + sb.AppendFormat ("{0}.{1} (", mb.ReflectedType.Name, mb.Name); + + bool first = true; + foreach (var pi in mb.GetParameters ()) { + if (!first) + sb.Append (", "); + first = false; + + sb.Append (pi.ParameterType.FullName); + } + sb.Append (")\n"); + } + + return sb.ToString (); + } } public abstract class AbstractMessage @@ -515,17 +557,8 @@ namespace Mono.CSharp { { #region Properties - public int FatalCounter { get; set; } - public int ErrorsCount { get; protected set; } - - public bool ShowFullPaths { get; set; } - - // - // Whether to dump a stack trace on errors. - // - public bool Stacktrace { get; set; } - + public int WarningsCount { get; private set; } // @@ -543,23 +576,20 @@ namespace Mono.CSharp { return txt; } - public virtual void Print (AbstractMessage msg) + public virtual void Print (AbstractMessage msg, bool showFullPath) { if (msg.IsWarning) { ++WarningsCount; } else { ++ErrorsCount; - - if (ErrorsCount == FatalCounter) - throw new Exception (msg.Text); } } - protected void Print (AbstractMessage msg, TextWriter output) + protected void Print (AbstractMessage msg, TextWriter output, bool showFullPath) { StringBuilder txt = new StringBuilder (); if (!msg.Location.IsNull) { - if (ShowFullPaths) + if (showFullPath) txt.Append (msg.Location.ToStringFullName ()); else txt.Append (msg.Location.ToString ()); @@ -612,7 +642,9 @@ namespace Mono.CSharp { // List merged_messages; - public override void Print (AbstractMessage msg) + bool showFullPaths; + + public override void Print (AbstractMessage msg, bool showFullPath) { // // This line is useful when debugging recorded messages @@ -624,7 +656,8 @@ namespace Mono.CSharp { session_messages.Add (msg); - base.Print (msg); + this.showFullPaths = showFullPath; + base.Print (msg, showFullPath); } public void EndSession () @@ -698,7 +731,7 @@ namespace Mono.CSharp { bool error_msg = false; foreach (AbstractMessage msg in messages_to_print) { - dest.Print (msg); + dest.Print (msg, showFullPaths); error_msg |= !msg.IsWarning; } @@ -715,10 +748,10 @@ namespace Mono.CSharp { this.writer = writer; } - public override void Print (AbstractMessage msg) + public override void Print (AbstractMessage msg, bool showFullPath) { - Print (msg, writer); - base.Print (msg); + Print (msg, writer, showFullPath); + base.Print (msg, showFullPath); } } @@ -835,60 +868,6 @@ namespace Mono.CSharp { return txt; } - - static string FriendlyStackTrace (StackTrace t) - { - StringBuilder sb = new StringBuilder (); - - bool foundUserCode = false; - - for (int i = 0; i < t.FrameCount; i++) { - StackFrame f = t.GetFrame (i); - var mb = f.GetMethod (); - - if (!foundUserCode && mb.ReflectedType == typeof (Report)) - continue; - - foundUserCode = true; - - sb.Append ("\tin "); - - if (f.GetFileLineNumber () > 0) - sb.AppendFormat ("(at {0}:{1}) ", f.GetFileName (), f.GetFileLineNumber ()); - - sb.AppendFormat ("{0}.{1} (", mb.ReflectedType.Name, mb.Name); - - bool first = true; - foreach (var pi in mb.GetParameters ()) { - if (!first) - sb.Append (", "); - first = false; - - sb.Append (pi.ParameterType.FullName); - } - sb.Append (")\n"); - } - - return sb.ToString (); - } - - public override void Print (AbstractMessage msg) - { - base.Print (msg); - - if (Stacktrace) - Console.WriteLine (FriendlyStackTrace (new StackTrace (true))); - } - - public static string FriendlyStackTrace (Exception e) - { - return FriendlyStackTrace (new StackTrace (e, true)); - } - - public static void StackTrace () - { - Console.WriteLine (FriendlyStackTrace (new StackTrace (true))); - } } class TimeReporter @@ -1015,6 +994,14 @@ namespace Mono.CSharp { } } + class FatalException : Exception + { + public FatalException (string message) + : base (message) + { + } + } + /// /// Handles #pragma warning /// diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs index 3b44ac067..679a3ab1f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs @@ -47,7 +47,12 @@ namespace Mono.CSharp { public enum Platform { - AnyCPU, X86, X64, IA64 + AnyCPU, + AnyCPU32Preferred, + Arm, + X86, + X64, + IA64 } public class CompilerSettings @@ -135,10 +140,15 @@ namespace Mono.CSharp { public bool GenerateDebugInfo; - // Compiler debug flags only + #region Compiler debug flags only public bool ParseOnly, TokenizeOnly, Timestamps; public int DebugFlags; public int VerboseParserFlag; + public int FatalCounter; + public bool Stacktrace; + #endregion + + public bool ShowFullPaths; // // Whether we are being linked against the standard libraries. @@ -1044,7 +1054,10 @@ namespace Mono.CSharp { return ParseResult.Error; } - switch (value.ToLower (CultureInfo.InvariantCulture)) { + switch (value.ToLowerInvariant ()) { + case "arm": + settings.Platform = Platform.Arm; + break; case "anycpu": settings.Platform = Platform.AnyCPU; break; @@ -1057,8 +1070,12 @@ namespace Mono.CSharp { case "itanium": settings.Platform = Platform.IA64; break; + case "anycpu32bitpreferred": + settings.Platform = Platform.AnyCPU32Preferred; + break; default: - report.Error (1672, "Invalid platform type for -platform. Valid options are `anycpu', `x86', `x64' or `itanium'"); + report.Error (1672, "Invalid -platform option `{0}'. Valid options are `anycpu', `anycpu32bitpreferred', `arm', `x86', `x64' or `itanium'", + value); return ParseResult.Error; } @@ -1111,7 +1128,7 @@ namespace Mono.CSharp { return ParseResult.Success; case "/fullpaths": - report.Printer.ShowFullPaths = true; + settings.ShowFullPaths = true; return ParseResult.Success; case "/keyfile": @@ -1271,7 +1288,7 @@ namespace Mono.CSharp { return ParseResult.Success; case "--stacktrace": - report.Printer.Stacktrace = true; + settings.Stacktrace = true; return ParseResult.Success; case "--linkresource": @@ -1435,12 +1452,12 @@ namespace Mono.CSharp { return ParseResult.Success; default: - if (arg.StartsWith ("--fatal")){ + if (arg.StartsWith ("--fatal", StringComparison.Ordinal)){ int fatal = 1; - if (arg.StartsWith ("--fatal=")) + if (arg.StartsWith ("--fatal=", StringComparison.Ordinal)) int.TryParse (arg.Substring (8), out fatal); - report.Printer.FatalCounter = fatal; + settings.FatalCounter = fatal; return ParseResult.Success; } if (arg.StartsWith ("--runtime:", StringComparison.Ordinal)) { @@ -1517,7 +1534,7 @@ namespace Mono.CSharp { void Usage () { output.WriteLine ( - "Mono C# compiler, Copyright 2001 - 2011 Novell, Inc.\n" + + "Mono C# compiler, Copyright 2001-2011 Novell, Inc., Copyright 2011-2012 Xamarin, Inc\n" + "mcs [options] source-files\n" + " --about About the Mono C# compiler\n" + " -addmodule:M1[,Mn] Adds the module to the generated assembly\n" + @@ -1542,7 +1559,8 @@ namespace Mono.CSharp { " -out:FILE Specifies output assembly name\n" + " -pkg:P1[,Pn] References packages P1..Pn\n" + " -platform:ARCH Specifies the target platform of the output assembly\n" + - " ARCH can be one of: anycpu, x86, x64 or itanium\n" + + " ARCH can be one of: anycpu, anycpu32bitpreferred, arm,\n" + + " x86, x64 or itanium. The default is anycpu.\n" + " -recurse:SPEC Recursively compiles files according to SPEC pattern\n" + " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" + " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" + diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs index 96bfb5371..4a71f027d 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs @@ -68,6 +68,10 @@ namespace Mono.CSharp { { ec.Mark (loc); DoEmit (ec); + + if (ec.StatementEpilogue != null) { + ec.EmitEpilogue (); + } } // @@ -856,6 +860,8 @@ namespace Mono.CSharp { ec.Report.Error (127, loc, "`{0}': A return keyword must not be followed by any expression when method returns void", ec.GetSignatureForError ()); + + return false; } } else { if (am.IsIterator) { @@ -874,12 +880,21 @@ namespace Mono.CSharp { return true; } + // TODO: Better error message + if (async_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 ()); + + return false; + } + 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", + "`{0}': A return keyword must not be followed by an expression when async method returns `Task'. Consider using `Task' return type", ec.GetSignatureForError ()); return false; } @@ -887,7 +902,13 @@ namespace Mono.CSharp { // // The return type is actually Task type argument // - block_return_type = async_type.TypeArguments[0]; + if (expr.Type == async_type) { + ec.Report.Error (4016, loc, + "`{0}': The return expression type of async method must be `{1}' rather than `Task<{1}>'", + ec.GetSignatureForError (), async_type.TypeArguments[0].GetSignatureForError ()); + } else { + block_return_type = async_type.TypeArguments[0]; + } } } else { var l = am as AnonymousMethodBody; @@ -901,7 +922,7 @@ namespace Mono.CSharp { if (expr == null) return false; - if (expr.Type != block_return_type) { + if (expr.Type != block_return_type && expr.Type != InternalType.ErrorType) { expr = Convert.ImplicitConversionRequired (ec, expr, block_return_type, loc); if (expr == null) { @@ -930,12 +951,16 @@ namespace Mono.CSharp { if (async_return != null) { async_return.EmitAssign (ec); + ec.EmitEpilogue (); + ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, async_body.BodyEnd); } return; } + ec.EmitEpilogue (); + if (unwind_protect || ec.EmitAccurateDebugInfo) ec.Emit (OpCodes.Stloc, ec.TemporaryReturn ()); } @@ -1190,9 +1215,9 @@ namespace Mono.CSharp { res = c; } else { TypeSpec type = ec.Switch.SwitchType; - res = c.TryReduce (ec, type, c.Location); + res = c.TryReduce (ec, type); if (res == null) { - c.Error_ValueCannotBeConverted (ec, loc, type, true); + c.Error_ValueCannotBeConverted (ec, type, true); return false; } @@ -1465,7 +1490,7 @@ namespace Mono.CSharp { declarators.Add (decl); } - void CreateEvaluatorVariable (BlockContext bc, LocalVariable li) + static void CreateEvaluatorVariable (BlockContext bc, LocalVariable li) { if (bc.Report.Errors != 0) return; @@ -1656,7 +1681,7 @@ namespace Mono.CSharp { if (TypeSpec.IsReferenceType (li.Type)) initializer.Error_ConstantCanBeInitializedWithNullOnly (bc, li.Type, initializer.Location, li.Name); else - initializer.Error_ValueCannotBeConverted (bc, initializer.Location, li.Type, false); + initializer.Error_ValueCannotBeConverted (bc, li.Type, false); return null; } @@ -1767,6 +1792,12 @@ namespace Mono.CSharp { } } + public bool IsCompilerGenerated { + get { + return (flags & Flags.CompilerGenerated) != 0; + } + } + public bool IsConstant { get { return (flags & Flags.Constant) != 0; @@ -2298,7 +2329,8 @@ namespace Mono.CSharp { if (warn) ec.Report.Warning (162, 2, loc, "Unreachable code detected"); - ec.StartFlowBranching (FlowBranching.BranchingType.Block, loc); + var fb = ec.StartFlowBranching (FlowBranching.BranchingType.Block, loc); + fb.CurrentUsageVector.IsUnreachable = true; bool ok = Resolve (ec); ec.KillFlowBranching (); @@ -2318,9 +2350,6 @@ namespace Mono.CSharp { EmitScopeInitializers (ec); DoEmit (ec); - - if (SymbolWriter.HasSymbolWriter) - EmitSymbolInfo (ec); } protected void EmitScopeInitializers (EmitContext ec) @@ -2329,10 +2358,6 @@ namespace Mono.CSharp { s.Emit (ec); } - protected virtual void EmitSymbolInfo (EmitContext ec) - { - } - #if DEBUG public override string ToString () { @@ -2398,14 +2423,22 @@ namespace Mono.CSharp { } public bool HasCapturedThis { - set { flags = value ? flags | Flags.HasCapturedThis : flags & ~Flags.HasCapturedThis; } + set { + flags = value ? flags | Flags.HasCapturedThis : flags & ~Flags.HasCapturedThis; + } get { return (flags & Flags.HasCapturedThis) != 0; } } + // + // Used to indicate that the block has reference to parent + // block and cannot be made static when defining anonymous method + // public bool HasCapturedVariable { - set { flags = value ? flags | Flags.HasCapturedVariable : flags & ~Flags.HasCapturedVariable; } + set { + flags = value ? flags | Flags.HasCapturedVariable : flags & ~Flags.HasCapturedVariable; + } get { return (flags & Flags.HasCapturedVariable) != 0; } @@ -2432,11 +2465,12 @@ namespace Mono.CSharp { return ec.CurrentAnonymousMethod.Storey; // - // When referencing a variable in parent iterator/async storey - // from nested anonymous method + // When referencing a variable inside iterator where all + // variables will be captured anyway we don't need to create + // another storey context // - if (ParametersBlock.am_storey is StateMachine) { - return ParametersBlock.am_storey; + if (ParametersBlock.StateMachine is IteratorStorey) { + return ParametersBlock.StateMachine; } if (am_storey == null) { @@ -2445,7 +2479,7 @@ namespace Mono.CSharp { // // Creates anonymous method storey for this block // - am_storey = new AnonymousMethodStorey (this, ec.CurrentMemberDefinition.Parent.PartialContainer, mc, ec.CurrentTypeParameters, "AnonStorey"); + am_storey = new AnonymousMethodStorey (this, ec.CurrentMemberDefinition.Parent.PartialContainer, mc, ec.CurrentTypeParameters, "AnonStorey", MemberKind.Class); } return am_storey; @@ -2454,7 +2488,7 @@ namespace Mono.CSharp { public override void Emit (EmitContext ec) { if (am_storey != null) { - DefineAnonymousStorey (ec); + DefineStoreyContainer (ec, am_storey); am_storey.EmitStoreyInstantiation (ec, this); } @@ -2465,16 +2499,12 @@ namespace Mono.CSharp { ec.Emit (OpCodes.Nop); } - bool emit_debug_info = SymbolWriter.HasSymbolWriter && Parent != null && !(am_storey is IteratorStorey); - if (emit_debug_info) + if (Parent != null) ec.BeginScope (); DoEmit (ec); - if (SymbolWriter.HasSymbolWriter) - EmitSymbolInfo (ec); - - if (emit_debug_info) + if (Parent != null) ec.EndScope (); if (ec.EmitAccurateDebugInfo && !HasUnreachableClosingBrace && !IsCompilerGenerated && ec.Mark (EndLocation)) { @@ -2482,57 +2512,112 @@ namespace Mono.CSharp { } } - void DefineAnonymousStorey (EmitContext ec) + protected void DefineStoreyContainer (EmitContext ec, AnonymousMethodStorey storey) { + if (ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null) { + storey.SetNestedStoryParent (ec.CurrentAnonymousMethod.Storey); + storey.Mutator = ec.CurrentAnonymousMethod.Storey.Mutator; + } + // // Creates anonymous method storey // - if (ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null) { + storey.CreateContainer (); + storey.DefineContainer (); + + if (Original.Explicit.HasCapturedThis && Original.ParametersBlock.TopBlock.ThisReferencesFromChildrenBlock != null) { + // - // Creates parent storey reference when hoisted this is accessible + // Only first storey in path will hold this reference. All children blocks will + // reference it indirectly using $ref field // - if (am_storey.OriginalSourceBlock.Explicit.HasCapturedThis) { - ExplicitBlock parent = am_storey.OriginalSourceBlock.Explicit.Parent.Explicit; + for (Block b = Original.Explicit.Parent; b != null; b = b.Parent) { + var s = b.Explicit.AnonymousMethodStorey; + if (s != null) { + storey.HoistedThis = s.HoistedThis; + break; + } + } - // - // Hoisted this exists in top-level parent storey only - // - while (parent.am_storey == null || parent.am_storey.Parent is AnonymousMethodStorey) - parent = parent.Parent.Explicit; + // + // We are the first storey on path and this has to be hoisted + // + if (storey.HoistedThis == null) { + foreach (ExplicitBlock ref_block in Original.ParametersBlock.TopBlock.ThisReferencesFromChildrenBlock) { + // + // ThisReferencesFromChildrenBlock holds all reference even if they + // are not on this path. It saves some memory otherwise it'd have to + // be in every explicit block. We run this check to see if the reference + // is valid for this storey + // + Block block_on_path = ref_block; + for (; block_on_path != null && block_on_path != Original; block_on_path = block_on_path.Parent); - am_storey.AddParentStoreyReference (ec, parent.am_storey); - } + if (block_on_path == null) + continue; - am_storey.SetNestedStoryParent (ec.CurrentAnonymousMethod.Storey); + if (storey.HoistedThis == null) + storey.AddCapturedThisField (ec); - // TODO MemberCache: Review - am_storey.Mutator = ec.CurrentAnonymousMethod.Storey.Mutator; - } + for (ExplicitBlock b = ref_block; b.AnonymousMethodStorey != storey; b = b.Parent.Explicit) { + if (b.AnonymousMethodStorey != null) { + b.AnonymousMethodStorey.AddParentStoreyReference (ec, storey); + b.AnonymousMethodStorey.HoistedThis = storey.HoistedThis; + + // + // Stop propagation inside same top block + // + if (b.ParametersBlock == ParametersBlock.Original) + break; + + b = b.ParametersBlock; + } + + var pb = b as ParametersBlock; + if (pb != null && pb.StateMachine != null) { + if (pb.StateMachine == storey) + break; + + pb.StateMachine.AddParentStoreyReference (ec, storey); + } - am_storey.CreateContainer (); - am_storey.DefineContainer (); + b.HasCapturedVariable = true; + } + } + } + } - var ref_blocks = am_storey.ReferencesFromChildrenBlock; + var ref_blocks = storey.ReferencesFromChildrenBlock; if (ref_blocks != null) { foreach (ExplicitBlock ref_block in ref_blocks) { - for (ExplicitBlock b = ref_block.Explicit; b.am_storey != am_storey; b = b.Parent.Explicit) { - if (b.am_storey != null) { - b.am_storey.AddParentStoreyReference (ec, am_storey); + for (ExplicitBlock b = ref_block; b.AnonymousMethodStorey != storey; b = b.Parent.Explicit) { + if (b.AnonymousMethodStorey != null) { + b.AnonymousMethodStorey.AddParentStoreyReference (ec, storey); + // // Stop propagation inside same top block - if (b.ParametersBlock.Original == ParametersBlock.Original) + // + if (b.ParametersBlock == ParametersBlock.Original) break; b = b.ParametersBlock; } + var pb = b as ParametersBlock; + if (pb != null && pb.StateMachine != null) { + if (pb.StateMachine == storey) + break; + + pb.StateMachine.AddParentStoreyReference (ec, storey); + } + b.HasCapturedVariable = true; } } } - am_storey.Define (); - am_storey.Parent.PartialContainer.AddCompilerGeneratedClass (am_storey); + storey.Define (); + storey.Parent.PartialContainer.AddCompilerGeneratedClass (storey); } public void RegisterAsyncAwait () @@ -2541,7 +2626,7 @@ namespace Mono.CSharp { while ((block.flags & Flags.AwaitBlock) == 0) { block.flags |= Flags.AwaitBlock; - if (block.Parent == null) + if (block is ParametersBlock) return; block = block.Parent.Explicit; @@ -2590,7 +2675,13 @@ namespace Mono.CSharp { #region Properties - public Block Block { + public ParametersBlock Block { + get { + return block; + } + } + + Block INamedBlockVariable.Block { get { return block; } @@ -2693,6 +2784,7 @@ namespace Mono.CSharp { bool resolved; protected bool unreachable; protected ToplevelBlock top_block; + protected StateMachine state_machine; public ParametersBlock (Block parent, ParametersCompiled parameters, Location start) : base (parent, 0, start, start) @@ -2732,6 +2824,7 @@ namespace Mono.CSharp { this.resolved = true; this.unreachable = source.unreachable; this.am_storey = source.am_storey; + this.state_machine = source.state_machine; ParametersBlock = this; @@ -2771,6 +2864,12 @@ namespace Mono.CSharp { } } + public StateMachine StateMachine { + get { + return state_machine; + } + } + public ToplevelBlock TopBlock { get { return top_block; @@ -2826,6 +2925,26 @@ namespace Mono.CSharp { return base.CreateExpressionTree (ec); } + public override void Emit (EmitContext ec) + { + if (state_machine != null && state_machine.OriginalSourceBlock != this) { + DefineStoreyContainer (ec, state_machine); + state_machine.EmitStoreyInstantiation (ec, this); + } + + base.Emit (ec); + } + + public void EmitEmbedded (EmitContext ec) + { + if (state_machine != null && state_machine.OriginalSourceBlock != this) { + DefineStoreyContainer (ec, state_machine); + state_machine.EmitStoreyInstantiation (ec, this); + } + + base.Emit (ec); + } + public ParameterInfo GetParameterInfo (Parameter p) { for (int i = 0; i < parameters.Count; ++i) { @@ -2836,7 +2955,7 @@ namespace Mono.CSharp { throw new ArgumentException ("Invalid parameter"); } - public Expression GetParameterReference (int index, Location loc) + public ParameterReference GetParameterReference (int index, Location loc) { return new ParameterReference (parameter_info[index], loc); } @@ -2887,7 +3006,7 @@ namespace Mono.CSharp { unreachable = top_level.End (); } } catch (Exception e) { - if (e is CompletionResult || rc.Report.IsDisabled) + if (e is CompletionResult || rc.Report.IsDisabled || e is FatalException) throw; if (rc.CurrentBlock != null) { @@ -2939,7 +3058,7 @@ namespace Mono.CSharp { for (int i = 0; i < orig_count; ++i) { Parameter.Modifier mod = parameters.FixedParameters[i].ModFlags; - if ((mod & Parameter.Modifier.OUT) != Parameter.Modifier.OUT) + if ((mod & Parameter.Modifier.OUT) == 0) continue; VariableInfo vi = new VariableInfo (parameters, i, ec.FlowOffset); @@ -2948,37 +3067,71 @@ namespace Mono.CSharp { } } - public void WrapIntoIterator (IMethodData method, TypeDefinition host, TypeSpec iterator_type, bool is_enumerable) + public ToplevelBlock ConvertToIterator (IMethodData method, TypeDefinition host, TypeSpec iterator_type, bool is_enumerable) { - ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, Location.Null); - pb.statements = statements; - pb.Original = this; + var iterator = new Iterator (this, method, host, iterator_type, is_enumerable); + var stateMachine = new IteratorStorey (iterator); - var iterator = new Iterator (pb, method, host, iterator_type, is_enumerable); - am_storey = new IteratorStorey (iterator); + state_machine = stateMachine; + iterator.SetStateMachine (stateMachine); - statements = new List (1); - AddStatement (new Return (iterator, iterator.Location)); - flags &= ~Flags.YieldBlock; - IsCompilerGenerated = true; + var tlb = new ToplevelBlock (host.Compiler, Parameters, Location.Null); + tlb.Original = this; + tlb.IsCompilerGenerated = true; + tlb.state_machine = stateMachine; + tlb.AddStatement (new Return (iterator, iterator.Location)); + return tlb; } - public void WrapIntoAsyncTask (IMemberContext context, TypeDefinition host, TypeSpec returnType) + public ParametersBlock ConvertToAsyncTask (IMemberContext context, TypeDefinition host, ParametersCompiled parameters, TypeSpec returnType, Location loc) { - ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, StartLocation); - pb.EndLocation = EndLocation; - pb.statements = statements; - pb.Original = this; + for (int i = 0; i < parameters.Count; i++) { + Parameter p = parameters[i]; + Parameter.Modifier mod = p.ModFlags; + if ((mod & Parameter.Modifier.RefOutMask) != 0) { + host.Compiler.Report.Error (1988, p.Location, + "Async methods cannot have ref or out parameters"); + return this; + } + + if (p is ArglistParameter) { + host.Compiler.Report.Error (4006, p.Location, + "__arglist is not allowed in parameter list of async methods"); + return this; + } + + if (parameters.Types[i].IsPointer) { + host.Compiler.Report.Error (4005, p.Location, + "Async methods cannot have unsafe parameters"); + return this; + } + } + + if (!HasAwait) { + host.Compiler.Report.Warning (1998, 1, loc, + "Async block lacks `await' operator and will run synchronously"); + } var block_type = host.Module.Compiler.BuiltinTypes.Void; - var initializer = new AsyncInitializer (pb, host, block_type); + var initializer = new AsyncInitializer (this, host, block_type); initializer.Type = block_type; - am_storey = new AsyncTaskStorey (context, initializer, returnType); + var stateMachine = new AsyncTaskStorey (this, context, initializer, returnType); - statements = new List (1); - AddStatement (new StatementExpression (initializer)); - flags &= ~Flags.AwaitBlock; + state_machine = stateMachine; + initializer.SetStateMachine (stateMachine); + + var b = this is ToplevelBlock ? + new ToplevelBlock (host.Compiler, Parameters, Location.Null) : + new ParametersBlock (Parent, parameters, Location.Null) { + IsAsync = true, + }; + + b.Original = this; + b.IsCompilerGenerated = true; + b.state_machine = stateMachine; + b.AddStatement (new StatementExpression (initializer)); + return b; } } @@ -2992,11 +3145,7 @@ namespace Mono.CSharp { Dictionary names; Dictionary labels; - public HoistedVariable HoistedThisVariable; - - public Report Report { - get { return compiler.Report; } - } + List this_references; public ToplevelBlock (CompilerContext ctx, Location loc) : this (ctx, ParametersCompiled.EmptyReadOnlyParameters, loc) @@ -3033,6 +3182,31 @@ namespace Mono.CSharp { } } + public Report Report { + get { + return compiler.Report; + } + } + + // + // Used by anonymous blocks to track references of `this' variable + // + public List ThisReferencesFromChildrenBlock { + get { + return this_references; + } + } + + // + // Returns the "this" instance variable of this block. + // See AddThisVariable() for more information. + // + public LocalVariable ThisVariable { + get { + return this_variable; + } + } + public void AddLocalName (string name, INamedBlockVariable li, bool ignoreChildrenBlocks) { if (names == null) @@ -3153,6 +3327,20 @@ namespace Mono.CSharp { existing_list.Add (label); } + public void AddThisReferenceFromChildrenBlock (ExplicitBlock block) + { + if (this_references == null) + this_references = new List (); + + if (!this_references.Contains (block)) + this_references.Add (block); + } + + public void RemoveThisReferenceFromChildrenBlock (ExplicitBlock block) + { + this_references.Remove (block); + } + // // Creates an arguments set from all parameters, useful for method proxy calls // @@ -3263,14 +3451,6 @@ namespace Mono.CSharp { return null; } - // - // Returns the "this" instance variable of this block. - // See AddThisVariable() for more information. - // - public LocalVariable ThisVariable { - get { return this_variable; } - } - // // This is used by non-static `struct' constructors which do not have an // initializer - in this case, the constructor must initialize all of the @@ -3344,15 +3524,6 @@ namespace Mono.CSharp { } #endif } - - protected override void EmitSymbolInfo (EmitContext ec) - { - AnonymousExpression ae = ec.CurrentAnonymousMethod; - if ((ae != null) && (ae.Storey != null)) - SymbolWriter.DefineScopeVariable (ae.Storey.ID); - - base.EmitSymbolInfo (ec); - } } public class SwitchLabel { @@ -4118,7 +4289,7 @@ namespace Mono.CSharp { var ctype = ec.CurrentMemberDefinition.Parent.PartialContainer; Field field = new Field (ctype, string_dictionary_type, Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED, - new MemberName (CompilerGeneratedClass.MakeName (null, "f", "switch$map", ec.Module.CounterSwitchTypes++), loc), null); + new MemberName (CompilerGeneratedContainer.MakeName (null, "f", "switch$map", ec.Module.CounterSwitchTypes++), loc), null); if (!field.Define ()) return; ctype.AddField (field); @@ -4321,6 +4492,7 @@ namespace Mono.CSharp { protected Statement stmt; Label dispose_try_block; bool prepared_for_dispose, emitted_dispose; + Method finally_host; protected TryFinallyBlock (Statement stmt, Location loc) : base (loc) @@ -4339,7 +4511,7 @@ namespace Mono.CSharp { #endregion protected abstract void EmitTryBody (EmitContext ec); - protected abstract void EmitFinallyBody (EmitContext ec); + public abstract void EmitFinallyBody (EmitContext ec); public override Label PrepareForDispose (EmitContext ec, Label end) { @@ -4367,7 +4539,14 @@ namespace Mono.CSharp { } ec.MarkLabel (start_finally); - EmitFinallyBody (ec); + + if (finally_host != null) { + var ce = new CallEmitter (); + ce.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); + ce.EmitPredefined (ec, finally_host.Spec, new Arguments (0)); + } else { + EmitFinallyBody (ec); + } ec.EndExceptionBlock (); } @@ -4411,12 +4590,10 @@ namespace Mono.CSharp { bool emit_dispatcher = j < labels.Length; if (emit_dispatcher) { - //SymbolWriter.StartIteratorDispatcher (ec.ig); ec.Emit (OpCodes.Ldloc, pc); ec.EmitInt (first_resume_pc); ec.Emit (OpCodes.Sub); ec.Emit (OpCodes.Switch, labels); - //SymbolWriter.EndIteratorDispatcher (ec.ig); } foreach (ResumableStatement s in resume_points) @@ -4427,10 +4604,34 @@ namespace Mono.CSharp { ec.BeginFinallyBlock (); - EmitFinallyBody (ec); + if (finally_host != null) { + var ce = new CallEmitter (); + ce.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); + ce.EmitPredefined (ec, finally_host.Spec, new Arguments (0)); + } else { + EmitFinallyBody (ec); + } ec.EndExceptionBlock (); } + + public override bool Resolve (BlockContext bc) + { + // + // Finally block inside iterator is called from MoveNext and + // Dispose methods that means we need to lift the block into + // newly created host method to emit the body only once. The + // original block then simply calls the newly generated method. + // + if (bc.CurrentIterator != null && !bc.IsInProbingMode) { + var b = stmt as Block; + if (b != null && b.Explicit.HasYield) { + finally_host = bc.CurrentIterator.CreateFinallyHost (this); + } + } + + return base.Resolve (bc); + } } // @@ -4619,7 +4820,7 @@ namespace Mono.CSharp { Statement.Emit (ec); } - protected override void EmitFinallyBody (EmitContext ec) + public override void EmitFinallyBody (EmitContext ec) { // // if (lock_taken) Monitor.Exit (expr_copy) @@ -5222,6 +5423,7 @@ namespace Mono.CSharp { if (ok) ec.CurrentBranching.CreateSibling (fini, FlowBranching.SiblingType.Finally); + using (ec.With (ResolveContext.Options.FinallyScope, true)) { if (!fini.Resolve (ec)) ok = false; @@ -5239,7 +5441,7 @@ namespace Mono.CSharp { stmt.Emit (ec); } - protected override void EmitFinallyBody (EmitContext ec) + public override void EmitFinallyBody (EmitContext ec) { fini.Emit (ec); } @@ -5501,7 +5703,7 @@ namespace Mono.CSharp { // Add conditional call when disposing possible null variable if (!type.IsStruct || type.IsNullableType) - dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc), loc), dispose, loc); + dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc), loc), dispose, dispose.loc); return dispose; } @@ -5583,7 +5785,7 @@ namespace Mono.CSharp { stmt.Emit (ec); } - protected override void EmitFinallyBody (EmitContext ec) + public override void EmitFinallyBody (EmitContext ec) { decl.EmitDispose (ec); } @@ -5649,27 +5851,43 @@ namespace Mono.CSharp { /// public class Foreach : Statement { - sealed class ArrayForeach : Statement + abstract class IteratorStatement : Statement { - readonly Foreach for_each; - readonly Statement statement; + protected readonly Foreach for_each; + + protected IteratorStatement (Foreach @foreach) + { + this.for_each = @foreach; + this.loc = @foreach.expr.Location; + } - Expression conv; + protected override void CloneTo (CloneContext clonectx, Statement target) + { + throw new NotImplementedException (); + } + + public override void Emit (EmitContext ec) + { + if (ec.EmitAccurateDebugInfo) { + ec.Emit (OpCodes.Nop); + } + + base.Emit (ec); + } + } + + sealed class ArrayForeach : IteratorStatement + { TemporaryVariableReference[] lengths; Expression [] length_exprs; StatementExpression[] counter; TemporaryVariableReference[] variables; TemporaryVariableReference copy; - Expression access; - LocalVariableReference variable; public ArrayForeach (Foreach @foreach, int rank) + : base (@foreach) { - for_each = @foreach; - statement = for_each.statement; - loc = @foreach.loc; - counter = new StatementExpression[rank]; variables = new TemporaryVariableReference[rank]; length_exprs = new Expression [rank]; @@ -5682,11 +5900,6 @@ namespace Mono.CSharp { lengths = new TemporaryVariableReference [rank]; } - protected override void CloneTo (CloneContext clonectx, Statement target) - { - throw new NotImplementedException (); - } - public override bool Resolve (BlockContext ec) { Block variables_block = for_each.variable.Block; @@ -5698,7 +5911,7 @@ namespace Mono.CSharp { for (int i = 0; i < rank; i++) { var v = TemporaryVariableReference.Create (ec.BuiltinTypes.Int, variables_block, loc); variables[i] = v; - counter[i] = new StatementExpression (new UnaryMutator (UnaryMutator.Mode.PostIncrement, v, loc)); + counter[i] = new StatementExpression (new UnaryMutator (UnaryMutator.Mode.PostIncrement, v, Location.Null)); counter[i].Resolve (ec); if (rank == 1) { @@ -5715,7 +5928,7 @@ namespace Mono.CSharp { list.Add (new Argument (v)); } - access = new ElementAccess (copy, list, loc).Resolve (ec); + var access = new ElementAccess (copy, list, loc).Resolve (ec); if (access == null) return false; @@ -5725,26 +5938,30 @@ namespace Mono.CSharp { var_type = access.Type; } else { var_type = for_each.type.ResolveAsType (ec); + + if (var_type == null) + return false; + + access = Convert.ExplicitConversion (ec, access, var_type, loc); + if (access == null) + return false; } - if (var_type == null) - return false; + for_each.variable.Type = var_type; - conv = Convert.ExplicitConversion (ec, access, var_type, loc); - if (conv == null) + var variable_ref = new LocalVariableReference (for_each.variable, loc).Resolve (ec); + if (variable_ref == null) return false; + for_each.body.AddScopeStatement (new StatementExpression (new CompilerAssign (variable_ref, access, Location.Null), for_each.variable.Location)); + bool ok = true; ec.StartFlowBranching (FlowBranching.BranchingType.Loop, loc); ec.CurrentBranching.CreateSibling (); - for_each.variable.Type = conv.Type; - variable = new LocalVariableReference (for_each.variable, loc); - variable.Resolve (ec); - ec.StartFlowBranching (FlowBranching.BranchingType.Embedded, loc); - if (!statement.Resolve (ec)) + if (!for_each.body.Resolve (ec)) ok = false; ec.EndFlowBranching (); @@ -5780,12 +5997,10 @@ namespace Mono.CSharp { ec.MarkLabel (loop [i]); } - variable.local_info.CreateBuilder (ec); - variable.EmitAssign (ec, conv, false, false); - - statement.Emit (ec); + for_each.body.Emit (ec); ec.MarkLabel (ec.LoopBegin); + ec.Mark (for_each.expr.Location); for (int i = rank - 1; i >= 0; i--){ counter [i].Emit (ec); @@ -5805,59 +6020,8 @@ namespace Mono.CSharp { } } - sealed class CollectionForeach : Statement, OverloadResolver.IErrorHandler + sealed class CollectionForeach : IteratorStatement, OverloadResolver.IErrorHandler { - class Body : Statement - { - TypeSpec type; - LocalVariableReference variable; - Expression current, conv; - Statement statement; - - public Body (TypeSpec type, LocalVariable variable, - Expression current, Statement statement, - Location loc) - { - this.type = type; - this.variable = new LocalVariableReference (variable, loc); - this.current = current; - this.statement = statement; - this.loc = loc; - } - - protected override void CloneTo (CloneContext clonectx, Statement target) - { - throw new NotImplementedException (); - } - - public override bool Resolve (BlockContext ec) - { - current = current.Resolve (ec); - if (current == null) - return false; - - conv = Convert.ExplicitConversion (ec, current, type, loc); - if (conv == null) - return false; - - variable.local_info.Type = conv.Type; - variable.Resolve (ec); - - if (!statement.Resolve (ec)) - return false; - - return true; - } - - protected override void DoEmit (EmitContext ec) - { - variable.local_info.CreateBuilder (ec); - variable.EmitAssign (ec, conv, false, false); - - statement.Emit (ec); - } - } - class RuntimeDispose : Using.VariableDeclaration { public RuntimeDispose (LocalVariable lv, Location loc) @@ -5900,23 +6064,15 @@ namespace Mono.CSharp { LocalVariable variable; Expression expr; Statement statement; - Expression var_type; ExpressionStatement init; TemporaryVariableReference enumerator_variable; bool ambiguous_getenumerator_name; - public CollectionForeach (Expression var_type, LocalVariable var, Expression expr, Statement stmt, Location l) + public CollectionForeach (Foreach @foreach, LocalVariable var, Expression expr) + : base (@foreach) { - this.var_type = var_type; this.variable = var; this.expr = expr; - statement = stmt; - loc = l; - } - - protected override void CloneTo (CloneContext clonectx, Statement target) - { - throw new NotImplementedException (); } void Error_WrongEnumerator (ResolveContext rc, MethodSpec enumerator) @@ -6078,7 +6234,7 @@ namespace Mono.CSharp { if (current_pe == null) return false; - VarExpr ve = var_type as VarExpr; + VarExpr ve = for_each.type as VarExpr; if (ve != null) { if (is_dynamic) { @@ -6094,16 +6250,26 @@ namespace Mono.CSharp { current_pe = EmptyCast.Create (current_pe, ec.BuiltinTypes.Dynamic); } - variable.Type = var_type.ResolveAsType (ec); + variable.Type = for_each.type.ResolveAsType (ec); + + if (variable.Type == null) + return false; + + current_pe = Convert.ExplicitConversion (ec, current_pe, variable.Type, loc); + if (current_pe == null) + return false; } - if (variable.Type == null) + var variable_ref = new LocalVariableReference (variable, loc).Resolve (ec); + if (variable_ref == null) return false; + for_each.body.AddScopeStatement (new StatementExpression (new CompilerAssign (variable_ref, current_pe, Location.Null), variable.Location)); + var init = new Invocation (get_enumerator_mg, null); statement = new While (new BooleanExpression (new Invocation (move_next_mg, null)), - new Body (variable.Type, variable, current_pe, statement, variable.Location), Location.Null); + for_each.body, Location.Null); var enum_type = enumerator_variable.Type; @@ -6183,13 +6349,15 @@ namespace Mono.CSharp { LocalVariable variable; Expression expr; Statement statement; + Block body; - public Foreach (Expression type, LocalVariable var, Expression expr, Statement stmt, Location l) + public Foreach (Expression type, LocalVariable var, Expression expr, Statement stmt, Block body, Location l) { this.type = type; this.variable = var; this.expr = expr; - statement = stmt; + this.statement = stmt; + this.body = body; loc = l; } @@ -6209,7 +6377,6 @@ namespace Mono.CSharp { get { return variable; } } - public override bool Resolve (BlockContext ec) { expr = expr.Resolve (ec); @@ -6221,6 +6388,8 @@ namespace Mono.CSharp { return false; } + body.AddStatement (statement); + if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.String) { statement = new ArrayForeach (this, 1); } else if (expr.Type is ArrayContainer) { @@ -6232,7 +6401,7 @@ namespace Mono.CSharp { return false; } - statement = new CollectionForeach (type, variable, expr, statement, loc); + statement = new CollectionForeach (this, variable, expr); } return statement.Resolve (ec); @@ -6240,6 +6409,8 @@ namespace Mono.CSharp { protected override void DoEmit (EmitContext ec) { + variable.CreateBuilder (ec); + Label old_begin = ec.LoopBegin, old_end = ec.LoopEnd; ec.LoopBegin = ec.DefineLabel (); ec.LoopEnd = ec.DefineLabel (); @@ -6256,6 +6427,7 @@ namespace Mono.CSharp { target.type = type.Clone (clonectx); target.expr = expr.Clone (clonectx); + target.body = (Block) body.Clone (clonectx); target.statement = statement.Clone (clonectx); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs index b6243c8ce..6eb3fc6e4 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs @@ -228,6 +228,9 @@ namespace Mono.CSharp public readonly PredefinedType Action; public readonly PredefinedType Task; public readonly PredefinedType TaskGeneric; + public readonly PredefinedType IAsyncStateMachine; + public readonly PredefinedType INotifyCompletion; + public readonly PredefinedType ICriticalNotifyCompletion; public PredefinedTypes (ModuleContainer module) { @@ -276,6 +279,9 @@ namespace Mono.CSharp 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); + IAsyncStateMachine = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "IAsyncStateMachine"); + INotifyCompletion = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "INotifyCompletion"); + ICriticalNotifyCompletion = new PredefinedType (module, MemberKind.Interface, "System.Runtime.CompilerServices", "ICriticalNotifyCompletion"); // // Define types which are used for comparison. It does not matter @@ -312,16 +318,29 @@ namespace Mono.CSharp { public readonly PredefinedMember ActivatorCreateInstance; public readonly PredefinedMember AsyncTaskMethodBuilderCreate; + public readonly PredefinedMember AsyncTaskMethodBuilderStart; public readonly PredefinedMember AsyncTaskMethodBuilderSetResult; public readonly PredefinedMember AsyncTaskMethodBuilderSetException; + public readonly PredefinedMember AsyncTaskMethodBuilderSetStateMachine; + public readonly PredefinedMember AsyncTaskMethodBuilderOnCompleted; + public readonly PredefinedMember AsyncTaskMethodBuilderOnCompletedUnsafe; public readonly PredefinedMember AsyncTaskMethodBuilderTask; public readonly PredefinedMember AsyncTaskMethodBuilderGenericCreate; + public readonly PredefinedMember AsyncTaskMethodBuilderGenericStart; public readonly PredefinedMember AsyncTaskMethodBuilderGenericSetResult; public readonly PredefinedMember AsyncTaskMethodBuilderGenericSetException; + public readonly PredefinedMember AsyncTaskMethodBuilderGenericSetStateMachine; + public readonly PredefinedMember AsyncTaskMethodBuilderGenericOnCompleted; + public readonly PredefinedMember AsyncTaskMethodBuilderGenericOnCompletedUnsafe; public readonly PredefinedMember AsyncTaskMethodBuilderGenericTask; public readonly PredefinedMember AsyncVoidMethodBuilderCreate; + public readonly PredefinedMember AsyncVoidMethodBuilderStart; public readonly PredefinedMember AsyncVoidMethodBuilderSetException; public readonly PredefinedMember AsyncVoidMethodBuilderSetResult; + public readonly PredefinedMember AsyncVoidMethodBuilderSetStateMachine; + public readonly PredefinedMember AsyncVoidMethodBuilderOnCompleted; + public readonly PredefinedMember AsyncVoidMethodBuilderOnCompletedUnsafe; + public readonly PredefinedMember DebuggerBrowsableAttributeCtor; public readonly PredefinedMember DecimalCtor; public readonly PredefinedMember DecimalCtorInt; public readonly PredefinedMember DecimalCtorLong; @@ -362,6 +381,8 @@ namespace Mono.CSharp var atypes = module.PredefinedAttributes; var btypes = module.Compiler.BuiltinTypes; + var tp = new TypeParameter (0, new MemberName ("T"), null, null, Variance.None); + ActivatorCreateInstance = new PredefinedMember (module, types.Activator, MemberFilter.Method ("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null)); @@ -371,10 +392,52 @@ namespace Mono.CSharp AsyncTaskMethodBuilderSetResult = new PredefinedMember (module, types.AsyncTaskMethodBuilder, MemberFilter.Method ("SetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, btypes.Void)); + AsyncTaskMethodBuilderSetStateMachine = new PredefinedMember (module, types.AsyncTaskMethodBuilder, + "SetStateMachine", MemberKind.Method, () => new[] { + types.IAsyncStateMachine.TypeSpec + }, btypes.Void); + AsyncTaskMethodBuilderSetException = new PredefinedMember (module, types.AsyncTaskMethodBuilder, MemberFilter.Method ("SetException", 0, ParametersCompiled.CreateFullyResolved (btypes.Exception), btypes.Void)); + AsyncTaskMethodBuilderOnCompleted = new PredefinedMember (module, types.AsyncTaskMethodBuilder, + MemberFilter.Method ("AwaitOnCompleted", 2, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + new ParameterData (null, Parameter.Modifier.REF) + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null) + }, false), + btypes.Void)); + + AsyncTaskMethodBuilderOnCompletedUnsafe = new PredefinedMember (module, types.AsyncTaskMethodBuilder, + MemberFilter.Method ("AwaitUnsafeOnCompleted", 2, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + new ParameterData (null, Parameter.Modifier.REF) + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null) + }, false), + btypes.Void)); + + AsyncTaskMethodBuilderStart = new PredefinedMember (module, types.AsyncTaskMethodBuilder, + MemberFilter.Method ("Start", 1, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + }, false), + btypes.Void)); + AsyncTaskMethodBuilderTask = new PredefinedMember (module, types.AsyncTaskMethodBuilder, MemberFilter.Property ("Task", null)); @@ -384,12 +447,54 @@ namespace Mono.CSharp AsyncTaskMethodBuilderGenericSetResult = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, "SetResult", MemberKind.Method, () => new TypeSpec[] { types.AsyncTaskMethodBuilderGeneric.TypeSpec.MemberDefinition.TypeParameters[0] - }); + }, btypes.Void); + + AsyncTaskMethodBuilderGenericSetStateMachine = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, + "SetStateMachine", MemberKind.Method, () => new[] { + types.IAsyncStateMachine.TypeSpec + }, btypes.Void); AsyncTaskMethodBuilderGenericSetException = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, MemberFilter.Method ("SetException", 0, ParametersCompiled.CreateFullyResolved (btypes.Exception), btypes.Void)); + AsyncTaskMethodBuilderGenericOnCompleted = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, + MemberFilter.Method ("AwaitOnCompleted", 2, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + new ParameterData (null, Parameter.Modifier.REF) + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null) + }, false), + btypes.Void)); + + AsyncTaskMethodBuilderGenericOnCompletedUnsafe = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, + MemberFilter.Method ("AwaitUnsafeOnCompleted", 2, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + new ParameterData (null, Parameter.Modifier.REF) + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null) + }, false), + btypes.Void)); + + AsyncTaskMethodBuilderGenericStart = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, + MemberFilter.Method ("Start", 1, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + }, false), + btypes.Void)); + AsyncTaskMethodBuilderGenericTask = new PredefinedMember (module, types.AsyncTaskMethodBuilderGeneric, MemberFilter.Property ("Task", null)); @@ -402,6 +507,51 @@ namespace Mono.CSharp AsyncVoidMethodBuilderSetResult = new PredefinedMember (module, types.AsyncVoidMethodBuilder, MemberFilter.Method ("SetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, btypes.Void)); + AsyncVoidMethodBuilderSetStateMachine = new PredefinedMember (module, types.AsyncVoidMethodBuilder, + "SetStateMachine", MemberKind.Method, () => new[] { + types.IAsyncStateMachine.TypeSpec + }, btypes.Void); + + AsyncVoidMethodBuilderOnCompleted = new PredefinedMember (module, types.AsyncVoidMethodBuilder, + MemberFilter.Method ("AwaitOnCompleted", 2, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + new ParameterData (null, Parameter.Modifier.REF) + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null) + }, false), + btypes.Void)); + + AsyncVoidMethodBuilderOnCompletedUnsafe = new PredefinedMember (module, types.AsyncVoidMethodBuilder, + MemberFilter.Method ("AwaitUnsafeOnCompleted", 2, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + new ParameterData (null, Parameter.Modifier.REF) + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (1, tp, SpecialConstraint.None, Variance.None, null) + }, false), + btypes.Void)); + + AsyncVoidMethodBuilderStart = new PredefinedMember (module, types.AsyncVoidMethodBuilder, + MemberFilter.Method ("Start", 1, + new ParametersImported ( + new[] { + new ParameterData (null, Parameter.Modifier.REF), + }, + new[] { + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + }, false), + btypes.Void)); + + DebuggerBrowsableAttributeCtor = new PredefinedMember (module, atypes.DebuggerBrowsable, + MemberFilter.Constructor (null)); + DecimalCtor = new PredefinedMember (module, btypes.Decimal, MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved ( btypes.Int, btypes.Int, btypes.Int, btypes.Bool, btypes.Byte))); @@ -469,9 +619,9 @@ namespace Mono.CSharp new ParameterData (null, Parameter.Modifier.NONE) }, new[] { - new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), - new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), - new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), + new TypeParameterSpec (0, tp, SpecialConstraint.None, Variance.None, null), }, false), null)); @@ -738,8 +888,8 @@ namespace Mono.CSharp }; } - public PredefinedMember (ModuleContainer module, PredefinedType type, string name, MemberKind kind, Func typesBuilder) - : this (module, type, new MemberFilter (name, 0, kind, null, null)) + public PredefinedMember (ModuleContainer module, PredefinedType type, string name, MemberKind kind, Func typesBuilder, TypeSpec returnType) + : this (module, type, new MemberFilter (name, 0, kind, null, returnType)) { filter_builder = typesBuilder; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs index 7ed97604a..7ad55a4be 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs @@ -1061,8 +1061,7 @@ namespace Mono.CSharp if (!IsEqual (a.Types[i], b.Types[i])) return false; - const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT; - if ((a.FixedParameters[i].ModFlags & ref_out) != (b.FixedParameters[i].ModFlags & ref_out)) + if ((a.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != (b.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask)) return false; } @@ -1303,6 +1302,7 @@ namespace Mono.CSharp { IAssemblyDefinition DeclaringAssembly { get; } string Namespace { get; } + bool IsPartial { get; } int TypeParametersCount { get; } TypeParameterSpec[] TypeParameters { get; } @@ -1325,12 +1325,6 @@ namespace Mono.CSharp readonly string name; - InternalType (string name, MemberCache cache) - : this (name) - { - this.cache = cache; - } - InternalType (string name) : base (MemberKind.InternalCompilerType, null, null, null, Modifiers.PUBLIC) { @@ -1362,6 +1356,12 @@ namespace Mono.CSharp } } + bool ITypeDefinition.IsPartial { + get { + return false; + } + } + public override string Name { get { return name; @@ -1474,6 +1474,12 @@ namespace Mono.CSharp public TypeSpec Element { get; private set; } + bool ITypeDefinition.IsPartial { + get { + return false; + } + } + public override string Name { get { throw new NotSupportedException (); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs index dee9e798d..dbd5709aa 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs @@ -2,7 +2,7 @@ // visit.cs: Visitors for parsed dom // // Authors: Mike Krüger (mkrueger@novell.com) -// Marek Safar (marek.safar@gmail.com) +// Marek Safar (marek.safar@gmail.com) // // Dual licensed under the terms of the MIT X11 or GNU GPL // @@ -26,16 +26,15 @@ namespace Mono.CSharp foreach (var container in mc.Containers) { container.Accept (this); } - } void VisitTypeDefinition (TypeDefinition tc) { - foreach (var container in tc.Members) { - container.Accept (this); + foreach (var member in tc.Members) { + member.Accept (this); } } - + public virtual void Visit (NamespaceContainer ns) { } diff --git a/ICSharpCode.NRefactory.CSharp/Properties/AssemblyInfo.cs b/ICSharpCode.NRefactory.CSharp/Properties/AssemblyInfo.cs index b1c65a5a1..88b738ea9 100644 --- a/ICSharpCode.NRefactory.CSharp/Properties/AssemblyInfo.cs +++ b/ICSharpCode.NRefactory.CSharp/Properties/AssemblyInfo.cs @@ -10,22 +10,4 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("ICSharpCode.NRefactory.CSharp")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("ICSharpCode")] -[assembly: AssemblyProduct("SharpDevelop/MonoDevelop")] -[assembly: AssemblyCopyright("Copyright 2010-2012 AlphaSierraPapa")] -[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("5.0.0.4")] +[assembly: AssemblyDescription("C# parser and semantic analysis")] diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/BaseRefactoringContext.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/BaseRefactoringContext.cs new file mode 100644 index 000000000..449be597d --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/BaseRefactoringContext.cs @@ -0,0 +1,172 @@ +// +// BaseRefactoringContext.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin +// +// 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.Threading; +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.NRefactory.CSharp.TypeSystem; +using ICSharpCode.NRefactory.Semantics; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem.Implementation; +using ICSharpCode.NRefactory.Editor; +using System.ComponentModel.Design; +using ICSharpCode.NRefactory.CSharp.Analysis; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public abstract class BaseRefactoringContext : IServiceProvider + { + readonly CSharpAstResolver resolver; + readonly CancellationToken cancellationToken; + + public virtual bool Supports(Version version) + { + return true; + } + + /// + /// Gets a value indicating if 'var' keyword should be used or explicit types. + /// + public virtual bool UseExplicitTypes { + get; + set; + } + + public CancellationToken CancellationToken { + get { return cancellationToken; } + } + + public virtual AstNode RootNode { + get { + return resolver.RootNode; + } + } + + public CSharpAstResolver Resolver { + get { + return resolver; + } + } + + public virtual CSharpParsedFile ParsedFile { + get { + return resolver.ParsedFile; + } + } + + public ICompilation Compilation { + get { return resolver.Compilation; } + } + + public BaseRefactoringContext (ICSharpCode.NRefactory.CSharp.Resolver.CSharpAstResolver resolver, System.Threading.CancellationToken cancellationToken) + { + this.resolver = resolver; + this.cancellationToken = cancellationToken; + } + + + #region Resolving + public ResolveResult Resolve (AstNode node) + { + return resolver.Resolve (node, cancellationToken); + } + + public CSharpResolver GetResolverStateBefore(AstNode node) + { + return resolver.GetResolverStateBefore (node, cancellationToken); + } + + public CSharpResolver GetResolverStateAfter(AstNode node) + { + return resolver.GetResolverStateAfter (node, cancellationToken); + } + + public IType ResolveType (AstType type) + { + return resolver.Resolve (type, cancellationToken).Type; + } + + public IType GetExpectedType (Expression expression) + { + return resolver.GetExpectedType(expression, cancellationToken); + } + + public Conversion GetConversion (Expression expression) + { + return resolver.GetConversion(expression, cancellationToken); + } + #endregion + + #region Code Analyzation + /// + /// Creates a new definite assignment analysis object with a given root statement. + /// + /// + /// The definite assignment analysis object. + /// + /// + /// The root statement. + /// + public DefiniteAssignmentAnalysis CreateDefiniteAssignmentAnalysis (Statement root) + { + return new DefiniteAssignmentAnalysis (root, resolver, CancellationToken); + } + #endregion + + /// + /// Translates the english input string to the context language. + /// + /// + /// The translated string. + /// + public virtual string TranslateString(string str) + { + return str; + } + + #region IServiceProvider implementation + readonly ServiceContainer services = new ServiceContainer(); + + /// + /// Gets a service container used to associate services with this context. + /// + public ServiceContainer Services { + get { return services; } + } + + /// + /// Retrieves a service from the refactoring context. + /// If the service is not found in the container. + /// + public object GetService(Type serviceType) + { + return services.GetService(serviceType); + } + #endregion + } + +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeAction.cs new file mode 100644 index 000000000..3bc59be60 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeAction.cs @@ -0,0 +1,73 @@ +// +// CodeAction.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin Inc. (http://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.Refactoring +{ + /// + /// A code action provides a code transformation with a description. + /// + public class CodeAction + { + /// + /// Gets the description. + /// + public string Description { + get; + private set; + } + + /// + /// Gets the code transformation. + /// + public Action