diff --git a/.gitignore b/.gitignore index a5807eb16..0031dcbe2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +bin +obj /lib/*.dll -/ICSharpCode.NRefactory.Tests/PartCover/* \ No newline at end of file +/ICSharpCode.NRefactory.Tests/PartCover/* +_ReSharper*/* diff --git a/ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore b/ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore deleted file mode 100644 index 9ce745d95..000000000 --- a/ICSharpCode.NRefactory.CSharp.AstVerifier/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -bin/ -obj/ \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj b/ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj index bd6e1e823..b75da9acd 100644 --- a/ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj +++ b/ICSharpCode.NRefactory.CSharp.AstVerifier/ICSharpCode.NRefactory.CSharp.AstVerifier.csproj @@ -1,49 +1,69 @@ - - - - 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 - - + + + + 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 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + v4.5 + + + none + false + bin\Release + prompt + 4 + true + v4.5 + + + + + + + + + + + + {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 index 43d3531b7..54ac57b80 100644 --- a/ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs +++ b/ICSharpCode.NRefactory.CSharp.AstVerifier/Main.cs @@ -59,7 +59,7 @@ namespace ICSharpCode.NRefactory.CSharp.AstVerifier if (!file.EndsWith (".cs")) continue; string text = File.ReadAllText (file); - var unit = CompilationUnit.Parse (text, file); + var unit = SyntaxTree.Parse (text, file); if (unit == null) continue; string generated = unit.GetText (); diff --git a/ICSharpCode.NRefactory.CSharp/.gitignore b/ICSharpCode.NRefactory.CSharp/.gitignore deleted file mode 100644 index 9ce745d95..000000000 --- a/ICSharpCode.NRefactory.CSharp/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -bin/ -obj/ \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs b/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs index 2812375b1..21b452696 100644 --- a/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs +++ b/ICSharpCode.NRefactory.CSharp/Analysis/ControlFlow.cs @@ -599,7 +599,8 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis ControlFlowNode bodyStart = builder.CreateStartNode(forStatement.EmbeddedStatement); ControlFlowNode bodyEnd = forStatement.EmbeddedStatement.AcceptVisitor(this, bodyStart); - Connect(bodyEnd, iteratorStart); + if (bodyEnd != null) + Connect(bodyEnd, iteratorStart); breakTargets.Pop(); continueTargets.Pop(); diff --git a/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs b/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs index fdcc4d717..0e2ad2b89 100644 --- a/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs +++ b/ICSharpCode.NRefactory.CSharp/Analysis/DefiniteAssignmentAnalysis.cs @@ -443,7 +443,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis // the special values are valid as output only, not as input Debug.Assert(data == CleanSpecialValues(data)); DefiniteAssignmentStatus status = data; - foreach (AstNode child in node.Children) { + for (AstNode child = node.FirstChild; child != null; child = child.NextSibling) { analysis.analysisCancellationToken.ThrowIfCancellationRequested(); Debug.Assert(!(child is Statement)); // statements are visited with the CFG, not with the visitor pattern @@ -721,7 +721,7 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis } DefiniteAssignmentStatus afterTrue = conditionalExpression.TrueExpression.AcceptVisitor(this, beforeTrue); - DefiniteAssignmentStatus afterFalse = conditionalExpression.TrueExpression.AcceptVisitor(this, beforeFalse); + DefiniteAssignmentStatus afterFalse = conditionalExpression.FalseExpression.AcceptVisitor(this, beforeFalse); return MergeStatus(CleanSpecialValues(afterTrue), CleanSpecialValues(afterFalse)); } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs index bc4d27de0..5d73c90db 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs @@ -1,4 +1,4 @@ -// +// // AstNode.cs // // Author: @@ -23,6 +23,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + using System; using System.Collections; using System.Collections.Generic; @@ -194,13 +195,13 @@ namespace ICSharpCode.NRefactory.CSharp /// /// 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. + /// The file name of the region is set based on the parent SyntaxTree's file name. /// If this node is not connected to a whole compilation, the file name will be null. /// public ICSharpCode.NRefactory.TypeSystem.DomRegion GetRegion() { - var cu = (this.Ancestors.LastOrDefault() ?? this) as CompilationUnit; - string fileName = (cu != null ? cu.FileName : null); + var syntaxTree = (this.Ancestors.LastOrDefault() ?? this) as SyntaxTree; + string fileName = (syntaxTree != null ? syntaxTree.FileName : null); return new ICSharpCode.NRefactory.TypeSystem.DomRegion(fileName, this.StartLocation, this.EndLocation); } @@ -288,17 +289,31 @@ namespace ICSharpCode.NRefactory.CSharp /// Gets all descendants of this node (excluding this node itself). /// public IEnumerable Descendants { - get { - return Utils.TreeTraversal.PreOrder (this.Children, n => n.Children); - } + get { return GetDescendants(false); } } /// /// Gets all descendants of this node (including this node itself). /// public IEnumerable DescendantsAndSelf { - get { - return Utils.TreeTraversal.PreOrder (this, n => n.Children); + get { return GetDescendants(true); } + } + + IEnumerable GetDescendants(bool includeSelf) + { + if (includeSelf) + yield return this; + Stack nextStack = new Stack(); + nextStack.Push(null); + AstNode pos = firstChild; + while (pos != null) { + if (pos.nextSibling != null) + nextStack.Push(pos.nextSibling); + yield return pos; + if (pos.firstChild != null) + pos = pos.firstChild; + else + pos = nextStack.Pop(); } } @@ -322,7 +337,7 @@ namespace ICSharpCode.NRefactory.CSharp { return Ancestors.OfType().FirstOrDefault(); } - + public AstNodeCollection GetChildrenByRole (Role role) where T : AstNode { return new AstNodeCollection (this, role); @@ -367,13 +382,6 @@ namespace ICSharpCode.NRefactory.CSharp } } - 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 { if (role == null) @@ -483,25 +491,24 @@ namespace ICSharpCode.NRefactory.CSharp newNode.SetRole(this.Role); newNode.prevSibling = prevSibling; newNode.nextSibling = nextSibling; - if (parent != null) { - if (prevSibling != null) { - Debug.Assert (prevSibling.nextSibling == this); - prevSibling.nextSibling = newNode; - } else { - Debug.Assert (parent.firstChild == this); - parent.firstChild = newNode; - } - if (nextSibling != null) { - Debug.Assert (nextSibling.prevSibling == this); - nextSibling.prevSibling = newNode; - } else { - Debug.Assert (parent.lastChild == this); - parent.lastChild = newNode; - } - parent = null; - prevSibling = null; - nextSibling = null; + + if (prevSibling != null) { + Debug.Assert (prevSibling.nextSibling == this); + prevSibling.nextSibling = newNode; + } else { + Debug.Assert (parent.firstChild == this); + parent.firstChild = newNode; + } + if (nextSibling != null) { + Debug.Assert (nextSibling.prevSibling == this); + nextSibling.prevSibling = newNode; + } else { + Debug.Assert (parent.lastChild == this); + parent.lastChild = newNode; } + parent = null; + prevSibling = null; + nextSibling = null; } public AstNode ReplaceWith (Func replaceFunction) diff --git a/ICSharpCode.NRefactory.CSharp/Ast/AstNodeCollection.cs b/ICSharpCode.NRefactory.CSharp/Ast/AstNodeCollection.cs index 4e28849be..b727dc211 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/AstNodeCollection.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/AstNodeCollection.cs @@ -204,5 +204,21 @@ namespace ICSharpCode.NRefactory.CSharp { node.InsertChildBefore(existingItem, newItem, role); } + + /// + /// Applies the to all nodes in this collection. + /// + public void AcceptVisitor(IAstVisitor visitor) + { + AstNode next; + for (AstNode cur = node.FirstChild; cur != null; cur = next) { + Debug.Assert(cur.Parent == node); + // Remember next before yielding cur. + // This allows removing/replacing nodes while iterating through the list. + next = cur.NextSibling; + if (cur.Role == role) + cur.AcceptVisitor(visitor); + } + } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs b/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs index 71d835709..022f3cc07 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/AstType.cs @@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory.CSharp return other == null || other.IsNull; } - public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode) + public override ITypeReference ToTypeReference(NameLookupMode lookupMode) { return SpecialType.UnknownType; } @@ -99,7 +99,7 @@ namespace ICSharpCode.NRefactory.CSharp return visitor.VisitPatternPlaceholder (this, child, data); } - public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode) + public override ITypeReference ToTypeReference(NameLookupMode lookupMode) { throw new NotSupportedException(); } @@ -135,7 +135,7 @@ namespace ICSharpCode.NRefactory.CSharp /// For resolving simple names, the current namespace and usings from the CurrentUsingScope /// (on CSharpTypeResolveContext only) is used. /// - public abstract ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type); + public abstract ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type); /// /// Creates a pointer type from this type by nesting it in a . diff --git a/ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs b/ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs index e13bf334c..e266c1a71 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/CSharpUtil.cs @@ -51,28 +51,11 @@ namespace ICSharpCode.NRefactory.CSharp if (condition is BinaryOperatorExpression) { var bOp = (BinaryOperatorExpression)condition; - switch (bOp.Operator) { - case BinaryOperatorType.GreaterThan: - bOp.Operator = BinaryOperatorType.LessThanOrEqual; - return bOp; - case BinaryOperatorType.GreaterThanOrEqual: - bOp.Operator = BinaryOperatorType.LessThan; - return bOp; - case BinaryOperatorType.Equality: - bOp.Operator = BinaryOperatorType.InEquality; - return bOp; - case BinaryOperatorType.InEquality: - bOp.Operator = BinaryOperatorType.Equality; - return bOp; - case BinaryOperatorType.LessThan: - bOp.Operator = BinaryOperatorType.GreaterThanOrEqual; - return bOp; - case BinaryOperatorType.LessThanOrEqual: - bOp.Operator = BinaryOperatorType.GreaterThan; - return bOp; - default: + var negatedOp = NegateRelationalOperator (bOp.Operator); + if (negatedOp == BinaryOperatorType.Any) return new UnaryOperatorExpression (UnaryOperatorType.Not, new ParenthesizedExpression (condition)); - } + bOp.Operator = negatedOp; + return bOp; } if (condition is ConditionalExpression) { var cEx = condition as ConditionalExpression; @@ -88,6 +71,31 @@ namespace ICSharpCode.NRefactory.CSharp return new UnaryOperatorExpression (UnaryOperatorType.Not, condition); } + + /// + /// Get negation of the specified relational operator + /// + /// + /// negation of the specified relational operator, or BinaryOperatorType.Any if it's not a relational operator + /// + public static BinaryOperatorType NegateRelationalOperator (BinaryOperatorType op) + { + switch (op) { + case BinaryOperatorType.GreaterThan: + return BinaryOperatorType.LessThanOrEqual; + case BinaryOperatorType.GreaterThanOrEqual: + return BinaryOperatorType.LessThan; + case BinaryOperatorType.Equality: + return BinaryOperatorType.InEquality; + case BinaryOperatorType.InEquality: + return BinaryOperatorType.Equality; + case BinaryOperatorType.LessThan: + return BinaryOperatorType.GreaterThanOrEqual; + case BinaryOperatorType.LessThanOrEqual: + return BinaryOperatorType.GreaterThan; + } + return BinaryOperatorType.Any; + } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs b/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs index 845f189d7..0103937a6 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/ComposedType.cs @@ -126,7 +126,7 @@ namespace ICSharpCode.NRefactory.CSharp return this; } - public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type) + public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type) { ITypeReference t = this.BaseType.ToTypeReference(lookupMode); if (this.HasNullableSpecifier) { diff --git a/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs b/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs index 68bce6c35..81982caf5 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/DepthFirstAstVisitor.cs @@ -44,9 +44,9 @@ namespace ICSharpCode.NRefactory.CSharp } } - public virtual void VisitCompilationUnit (CompilationUnit unit) + public virtual void VisitSyntaxTree (SyntaxTree syntaxTree) { - VisitChildren (unit); + VisitChildren (syntaxTree); } public virtual void VisitComment(Comment comment) @@ -642,7 +642,7 @@ namespace ICSharpCode.NRefactory.CSharp return default (T); } - public virtual T VisitCompilationUnit (CompilationUnit unit) + public virtual T VisitSyntaxTree (SyntaxTree unit) { return VisitChildren (unit); } @@ -1240,7 +1240,7 @@ namespace ICSharpCode.NRefactory.CSharp return default (S); } - public virtual S VisitCompilationUnit (CompilationUnit unit, T data) + public virtual S VisitSyntaxTree (SyntaxTree unit, T data) { return VisitChildren (unit, data); } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs index ffb3712f2..0bfc1c1d7 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/ArrayInitializerExpression.cs @@ -33,6 +33,18 @@ namespace ICSharpCode.NRefactory.CSharp /// public class ArrayInitializerExpression : Expression { + /// + /// For ease of use purposes in the resolver the ast representation + /// of { a, b, c } is { {a}, {b}, {c} }. + /// If IsSingleElement is true then this array initializer expression is a generated one. + /// That has no meaning in the source code (and contains no brace tokens). + /// + public virtual bool IsSingleElement { + get { + return false; + } + } + public ArrayInitializerExpression() { } @@ -61,7 +73,7 @@ namespace ICSharpCode.NRefactory.CSharp public override void AcceptVisitor (IAstVisitor visitor) { } - + public override T AcceptVisitor (IAstVisitor visitor) { return default (T); @@ -95,7 +107,7 @@ namespace ICSharpCode.NRefactory.CSharp { visitor.VisitArrayInitializerExpression (this); } - + public override T AcceptVisitor (IAstVisitor visitor) { return visitor.VisitArrayInitializerExpression (this); @@ -111,6 +123,69 @@ namespace ICSharpCode.NRefactory.CSharp ArrayInitializerExpression o = other as ArrayInitializerExpression; return o != null && this.Elements.DoMatch(o.Elements, match); } + + public static ArrayInitializerExpression CreateSingleElementInitializer () + { + return new SingleArrayInitializerExpression(); + } + /// + /// Single elements in array initializers are represented with this special class. + /// + class SingleArrayInitializerExpression : ArrayInitializerExpression + { + public override bool IsSingleElement { + get { + return true; + } + } + + } + + #region PatternPlaceholder + public static implicit operator ArrayInitializerExpression(PatternMatching.Pattern pattern) + { + return pattern != null ? new PatternPlaceholder(pattern) : null; + } + + sealed class PatternPlaceholder : ArrayInitializerExpression, PatternMatching.INode + { + readonly PatternMatching.Pattern child; + + public PatternPlaceholder(PatternMatching.Pattern child) + { + this.child = child; + } + + public override NodeType NodeType { + get { return NodeType.Pattern; } + } + + 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); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + return child.DoMatch(other, match); + } + + bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) + { + return child.DoMatchCollection(role, pos, match, backtrackingInfo); + } + } + #endregion } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs index 1b567de94..0ec466c3f 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/IdentifierExpression.cs @@ -55,7 +55,16 @@ namespace ICSharpCode.NRefactory.CSharp SetChildByRole(Roles.Identifier, CSharp.Identifier.Create (value)); } } - + + public Identifier IdentifierToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); + } + } + public AstNodeCollection TypeArguments { get { return GetChildrenByRole (Roles.TypeArgument); } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs index 98bc50232..4a433b46d 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/MemberReferenceExpression.cs @@ -34,8 +34,16 @@ namespace ICSharpCode.NRefactory.CSharp public class MemberReferenceExpression : Expression { public Expression Target { - get { return GetChildByRole (Roles.TargetExpression); } - set { SetChildByRole(Roles.TargetExpression, value); } + get { + return GetChildByRole(Roles.TargetExpression); + } + set { + SetChildByRole(Roles.TargetExpression, value); + } + } + + public CSharpTokenNode DotToken { + get { return GetChildByRole (Roles.Dot); } } public string MemberName { diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs index b7b8ada50..0751afe1e 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedArgumentExpression.cs @@ -30,13 +30,13 @@ namespace ICSharpCode.NRefactory.CSharp { } - public NamedArgumentExpression(string identifier, Expression expression) + public NamedArgumentExpression(string name, Expression expression) { - this.Identifier = identifier; + this.Name = name; this.Expression = expression; } - public string Identifier { + public string Name { get { return GetChildByRole (Roles.Identifier).Name; } @@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp } } - public Identifier IdentifierToken { + public Identifier NameToken { get { return GetChildByRole (Roles.Identifier); } @@ -81,7 +81,7 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { NamedArgumentExpression o = other as NamedArgumentExpression; - return o != null && MatchString(this.Identifier, o.Identifier) && this.Expression.DoMatch(o.Expression, match); + return o != null && MatchString(this.Name, o.Name) && this.Expression.DoMatch(o.Expression, match); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs index 663e3686d..92bc993b1 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/NamedExpression.cs @@ -40,13 +40,13 @@ namespace ICSharpCode.NRefactory.CSharp { } - public NamedExpression (string identifier, Expression expression) + public NamedExpression (string name, Expression expression) { - this.Identifier = identifier; + this.Name = name; this.Expression = expression; } - public string Identifier { + public string Name { get { return GetChildByRole (Roles.Identifier).Name; } @@ -55,7 +55,7 @@ namespace ICSharpCode.NRefactory.CSharp } } - public Identifier IdentifierToken { + public Identifier NameToken { get { return GetChildByRole (Roles.Identifier); } @@ -91,7 +91,7 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { var o = other as NamedExpression; - return o != null && MatchString(this.Identifier, o.Identifier) && this.Expression.DoMatch(o.Expression, match); + return o != null && MatchString(this.Name, o.Name) && this.Expression.DoMatch(o.Expression, match); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs index a7152fd1d..35c4a7203 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Expressions/PointerReferenceExpression.cs @@ -43,13 +43,22 @@ namespace ICSharpCode.NRefactory.CSharp public CSharpTokenNode ArrowToken { get { return GetChildByRole (ArrowRole); } } - + public string MemberName { get { return GetChildByRole (Roles.Identifier).Name; } set { - SetChildByRole(Roles.Identifier, Identifier.Create (value)); + SetChildByRole(Roles.Identifier, Identifier.Create (value)); + } + } + + public Identifier MemberNameToken { + get { + return GetChildByRole (Roles.Identifier); + } + set { + SetChildByRole (Roles.Identifier, value); } } @@ -61,7 +70,7 @@ namespace ICSharpCode.NRefactory.CSharp { visitor.VisitPointerReferenceExpression (this); } - + public override T AcceptVisitor (IAstVisitor visitor) { return visitor.VisitPointerReferenceExpression (this); diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs index 01198222b..a374f490d 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/NamespaceDeclaration.cs @@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp /// public class NamespaceDeclaration : AstNode { - public static readonly Role MemberRole = CompilationUnit.MemberRole; + public static readonly Role MemberRole = SyntaxTree.MemberRole; public override NodeType NodeType { get { diff --git a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs index 953f326c1..b630087ab 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/GeneralScope/PreProcessorDirective.cs @@ -86,13 +86,19 @@ namespace ICSharpCode.NRefactory.CSharp } } - public PreProcessorDirective (PreProcessorDirectiveType type, TextLocation startLocation, TextLocation endLocation) + public PreProcessorDirective(PreProcessorDirectiveType type, TextLocation startLocation, TextLocation endLocation) { this.Type = type; this.startLocation = startLocation; this.endLocation = endLocation; } - + + public PreProcessorDirective(PreProcessorDirectiveType type, string argument = null) + { + this.Type = type; + this.Argument = argument; + } + public override void AcceptVisitor (IAstVisitor visitor) { visitor.VisitPreProcessorDirective (this); diff --git a/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs b/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs index 58836e655..c375afacf 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/IAstVisitor.cs @@ -129,7 +129,7 @@ namespace ICSharpCode.NRefactory.CSharp void VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration); void VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer); - void VisitCompilationUnit(CompilationUnit compilationUnit); + void VisitSyntaxTree(SyntaxTree syntaxTree); void VisitSimpleType(SimpleType simpleType); void VisitMemberType(MemberType memberType); void VisitComposedType(ComposedType composedType); @@ -260,7 +260,7 @@ namespace ICSharpCode.NRefactory.CSharp S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration); S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer); - S VisitCompilationUnit(CompilationUnit compilationUnit); + S VisitSyntaxTree(SyntaxTree syntaxTree); S VisitSimpleType(SimpleType simpleType); S VisitMemberType(MemberType memberType); S VisitComposedType(ComposedType composedType); @@ -391,7 +391,7 @@ namespace ICSharpCode.NRefactory.CSharp S VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration, T data); S VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer, T data); - S VisitCompilationUnit(CompilationUnit compilationUnit, T data); + S VisitSyntaxTree(SyntaxTree syntaxTree, T data); S VisitSimpleType(SimpleType simpleType, T data); S VisitMemberType(MemberType memberType, T data); S VisitComposedType(ComposedType composedType, T data); diff --git a/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs b/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs index b017d45ba..76efbc7a8 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/MemberType.cs @@ -135,7 +135,7 @@ namespace ICSharpCode.NRefactory.CSharp return b.ToString(); } - public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type) + public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type) { TypeOrNamespaceReference t; if (this.IsDoubleColon) { @@ -154,7 +154,7 @@ namespace ICSharpCode.NRefactory.CSharp foreach (var ta in this.TypeArguments) { typeArguments.Add(ta.ToTypeReference(lookupMode)); } - return new MemberTypeOrNamespaceReference(t, this.MemberName, typeArguments); + return new MemberTypeOrNamespaceReference(t, this.MemberName, typeArguments, lookupMode); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs b/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs index 3d47dd81f..3291bccf7 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/ObservableAstVisitor.cs @@ -1,6 +1,6 @@ // // ObservableAstVisitor.cs -// +// // Author: // Mike Krüger // @@ -23,1178 +23,834 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + using System; namespace ICSharpCode.NRefactory.CSharp { - public class ObservableAstVisitor: IAstVisitor + public class ObservableAstVisitor : IAstVisitor { - S VisitChildren (AstNode node, T data) + void Visit(Action enter, Action leave, T node) where T : AstNode { + if (enter != null) + enter(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. + // if the visitor removes/replaces children. next = child.NextSibling; - child.AcceptVisitor (this, data); + child.AcceptVisitor (this); } - return default (S); + if (leave != null) + leave(node); } - public event Action CompilationUnitVisited; - - S IAstVisitor.VisitCompilationUnit (CompilationUnit unit, T data) + public event Action EnterSyntaxTree, LeaveSyntaxTree; + + void IAstVisitor.VisitSyntaxTree(SyntaxTree unit) { - var handler = CompilationUnitVisited; - if (handler != null) - handler (unit, data); - return VisitChildren (unit, data); + Visit(EnterSyntaxTree, LeaveSyntaxTree, unit); } - public event Action CommentVisited; - - S IAstVisitor.VisitComment (Comment comment, T data) + public event Action EnterComment, LeaveComment; + + void IAstVisitor.VisitComment(Comment comment) { - var handler = CommentVisited; - if (handler != null) - handler (comment, data); - return VisitChildren (comment, data); + Visit(EnterComment, LeaveComment, comment); } - - public event Action NewLineVisited; - - S IAstVisitor.VisitNewLine(NewLineNode newLineNode, T data) + + public event Action EnterNewLine, LeaveNewLine; + + void IAstVisitor.VisitNewLine(NewLineNode newLineNode) { - var handler = NewLineVisited; - if (handler != null) - handler(newLineNode, data); - return VisitChildren(newLineNode, data); + Visit(EnterNewLine, LeaveNewLine, newLineNode); } - - public event Action WhitespaceVisited; - - S IAstVisitor.VisitWhitespace(WhitespaceNode whitespace, T data) + + public event Action EnterWhitespace, LeaveWhitespace; + + void IAstVisitor.VisitWhitespace(WhitespaceNode whitespace) { - var handler = WhitespaceVisited; - if (handler != null) - handler(whitespace, data); - return VisitChildren(whitespace, data); + Visit(EnterWhitespace, LeaveWhitespace, whitespace); } - - public event Action TextVisited; - - S IAstVisitor.VisitText(TextNode textNode, T data) + + public event Action EnterText, LeaveText; + + void IAstVisitor.VisitText(TextNode textNode) { - var handler = TextVisited; - if (handler != null) - handler(textNode, data); - return VisitChildren(textNode, data); + Visit(EnterText, LeaveText, textNode); } - - public event Action PreProcessorDirectiveVisited; - S IAstVisitor.VisitPreProcessorDirective (PreProcessorDirective preProcessorDirective, T data) + + public event Action EnterPreProcessorDirective, LeavePreProcessorDirective; + void IAstVisitor.VisitPreProcessorDirective(PreProcessorDirective preProcessorDirective) { - var handler = PreProcessorDirectiveVisited; - if (handler != null) - handler (preProcessorDirective, data); - return VisitChildren (preProcessorDirective, data); + Visit(EnterPreProcessorDirective, LeavePreProcessorDirective, preProcessorDirective); } - public event Action DocumentationReferenceVisited; - - S IAstVisitor.VisitDocumentationReference (DocumentationReference documentationReference, T data) + public event Action EnterDocumentationReference, LeaveDocumentationReference; + + void IAstVisitor.VisitDocumentationReference(DocumentationReference documentationReference) { - var handler = DocumentationReferenceVisited; - if (handler != null) - handler (documentationReference, data); - return VisitChildren (documentationReference, data); + Visit(EnterDocumentationReference, LeaveDocumentationReference, documentationReference); } - public event Action IdentifierVisited; - - S IAstVisitor.VisitIdentifier (Identifier identifier, T data) + public event Action EnterIdentifier, LeaveIdentifier; + + void IAstVisitor.VisitIdentifier(Identifier identifier) { - var handler = IdentifierVisited; - if (handler != null) - handler (identifier, data); - return VisitChildren (identifier, data); + Visit(EnterIdentifier, LeaveIdentifier, identifier); } - public event Action CSharpTokenNodeVisited; - - S IAstVisitor.VisitCSharpTokenNode (CSharpTokenNode token, T data) + public event Action EnterCSharpTokenNode, LeaveCSharpTokenNode; + + void IAstVisitor.VisitCSharpTokenNode(CSharpTokenNode token) { - var handler = CSharpTokenNodeVisited; - if (handler != null) - handler (token, data); - return VisitChildren (token, data); + Visit(EnterCSharpTokenNode, LeaveCSharpTokenNode, token); } - public event Action PrimitiveTypeVisited; - - S IAstVisitor.VisitPrimitiveType (PrimitiveType primitiveType, T data) + public event Action EnterPrimitiveType, LeavePrimitiveType; + + void IAstVisitor.VisitPrimitiveType(PrimitiveType primitiveType) { - var handler = PrimitiveTypeVisited; - if (handler != null) - handler (primitiveType, data); - return VisitChildren (primitiveType, data); + Visit(EnterPrimitiveType, LeavePrimitiveType, primitiveType); } - public event Action ComposedTypeVisited; - - S IAstVisitor.VisitComposedType (ComposedType composedType, T data) + public event Action EnterComposedType, LeaveComposedType; + + void IAstVisitor.VisitComposedType(ComposedType composedType) { - var handler = ComposedTypeVisited; - if (handler != null) - handler (composedType, data); - return VisitChildren (composedType, data); + Visit(EnterComposedType, LeaveComposedType, composedType); } - public event Action SimpleTypeVisited; - - S IAstVisitor.VisitSimpleType (SimpleType simpleType, T data) + public event Action EnterSimpleType, LeaveSimpleType; + + void IAstVisitor.VisitSimpleType(SimpleType simpleType) { - var handler = SimpleTypeVisited; - if (handler != null) - handler (simpleType, data); - return VisitChildren (simpleType, data); + Visit(EnterSimpleType, LeaveSimpleType, simpleType); } - public event Action MemberTypeVisited; - - S IAstVisitor.VisitMemberType (MemberType memberType, T data) + public event Action EnterMemberType, LeaveMemberType; + + void IAstVisitor.VisitMemberType(MemberType memberType) { - var handler = MemberTypeVisited; - if (handler != null) - handler (memberType, data); - return VisitChildren (memberType, data); + Visit(EnterMemberType, LeaveMemberType, memberType); } - public event Action AttributeVisited; - - S IAstVisitor.VisitAttribute (Attribute attribute, T data) + public event Action EnterAttribute, LeaveAttribute; + + void IAstVisitor.VisitAttribute(Attribute attribute) { - var handler = AttributeVisited; - if (handler != null) - handler (attribute, data); - return VisitChildren (attribute, data); + Visit(EnterAttribute, LeaveAttribute, attribute); } - public event Action AttributeSectionVisited; - - S IAstVisitor.VisitAttributeSection (AttributeSection attributeSection, T data) + public event Action EnterAttributeSection, LeaveAttributeSection; + + void IAstVisitor.VisitAttributeSection(AttributeSection attributeSection) { - var handler = AttributeSectionVisited; - if (handler != null) - handler (attributeSection, data); - return VisitChildren (attributeSection, data); + Visit(EnterAttributeSection, LeaveAttributeSection, attributeSection); } - public event Action DelegateDeclarationVisited; - - S IAstVisitor.VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, T data) + public event Action EnterDelegateDeclaration, LeaveDelegateDeclaration; + + void IAstVisitor.VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration) { - var handler = DelegateDeclarationVisited; - if (handler != null) - handler (delegateDeclaration, data); - return VisitChildren (delegateDeclaration, data); + Visit(EnterDelegateDeclaration, LeaveDelegateDeclaration, delegateDeclaration); } - public event Action NamespaceDeclarationVisited; - - S IAstVisitor.VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, T data) + public event Action EnterNamespaceDeclaration, LeaveNamespaceDeclaration; + + void IAstVisitor.VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration) { - var handler = NamespaceDeclarationVisited; - if (handler != null) - handler (namespaceDeclaration, data); - return VisitChildren (namespaceDeclaration, data); + Visit(EnterNamespaceDeclaration, LeaveNamespaceDeclaration, namespaceDeclaration); } - public event Action TypeDeclarationVisited; - - S IAstVisitor.VisitTypeDeclaration (TypeDeclaration typeDeclaration, T data) + public event Action EnterTypeDeclaration, LeaveTypeDeclaration; + + void IAstVisitor.VisitTypeDeclaration(TypeDeclaration typeDeclaration) { - var handler = TypeDeclarationVisited; - if (handler != null) - handler (typeDeclaration, data); - return VisitChildren (typeDeclaration, data); + Visit(EnterTypeDeclaration, LeaveTypeDeclaration, typeDeclaration); } - public event Action TypeParameterDeclarationVisited; - - S IAstVisitor.VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration, T data) + public event Action EnterTypeParameterDeclaration, LeaveTypeParameterDeclaration; + + void IAstVisitor.VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration) { - var handler = TypeParameterDeclarationVisited; - if (handler != null) - handler (typeParameterDeclaration, data); - return VisitChildren (typeParameterDeclaration, data); + Visit(EnterTypeParameterDeclaration, LeaveTypeParameterDeclaration, typeParameterDeclaration); } - public event Action EnumMemberDeclarationVisited; - - S IAstVisitor.VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, T data) + public event Action EnterEnumMemberDeclaration, LeaveEnumMemberDeclaration; + + void IAstVisitor.VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration) { - var handler = EnumMemberDeclarationVisited; - if (handler != null) - handler (enumMemberDeclaration, data); - return VisitChildren (enumMemberDeclaration, data); + Visit(EnterEnumMemberDeclaration, LeaveEnumMemberDeclaration, enumMemberDeclaration); } - public event Action UsingDeclarationVisited; - - S IAstVisitor.VisitUsingDeclaration (UsingDeclaration usingDeclaration, T data) + public event Action EnterUsingDeclaration, LeaveUsingDeclaration; + + void IAstVisitor.VisitUsingDeclaration(UsingDeclaration usingDeclaration) { - var handler = UsingDeclarationVisited; - if (handler != null) - handler (usingDeclaration, data); - return VisitChildren (usingDeclaration, data); + Visit(EnterUsingDeclaration, LeaveUsingDeclaration, usingDeclaration); } - public event Action UsingAliasDeclarationVisited; - - S IAstVisitor.VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration, T data) + public event Action EnterUsingAliasDeclaration, LeaveUsingAliasDeclaration; + + void IAstVisitor.VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration) { - var handler = UsingAliasDeclarationVisited; - if (handler != null) - handler (usingDeclaration, data); - return VisitChildren (usingDeclaration, data); + Visit(EnterUsingAliasDeclaration, LeaveUsingAliasDeclaration, usingDeclaration); } - public event Action ExternAliasDeclarationVisited; - - S IAstVisitor.VisitExternAliasDeclaration (ExternAliasDeclaration externAliasDeclaration, T data) + public event Action EnterExternAliasDeclaration, LeaveExternAliasDeclaration; + + void IAstVisitor.VisitExternAliasDeclaration(ExternAliasDeclaration externAliasDeclaration) { - var handler = ExternAliasDeclarationVisited; - if (handler != null) - handler (externAliasDeclaration, data); - return VisitChildren (externAliasDeclaration, data); + Visit(EnterExternAliasDeclaration, LeaveExternAliasDeclaration, externAliasDeclaration); } - public event Action ConstructorDeclarationVisited; - - S IAstVisitor.VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, T data) + public event Action EnterConstructorDeclaration, LeaveConstructorDeclaration; + + void IAstVisitor.VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration) { - var handler = ConstructorDeclarationVisited; - if (handler != null) - handler (constructorDeclaration, data); - return VisitChildren (constructorDeclaration, data); + Visit(EnterConstructorDeclaration, LeaveConstructorDeclaration, constructorDeclaration); } - public event Action ConstructorInitializerVisited; - - S IAstVisitor.VisitConstructorInitializer (ConstructorInitializer constructorInitializer, T data) + public event Action EnterConstructorInitializer, LeaveConstructorInitializer; + + void IAstVisitor.VisitConstructorInitializer(ConstructorInitializer constructorInitializer) { - var handler = ConstructorInitializerVisited; - if (handler != null) - handler (constructorInitializer, data); - return VisitChildren (constructorInitializer, data); + Visit(EnterConstructorInitializer, LeaveConstructorInitializer, constructorInitializer); } - public event Action DestructorDeclarationVisited; - - S IAstVisitor.VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, T data) + public event Action EnterDestructorDeclaration, LeaveDestructorDeclaration; + + void IAstVisitor.VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration) { - var handler = DestructorDeclarationVisited; - if (handler != null) - handler (destructorDeclaration, data); - return VisitChildren (destructorDeclaration, data); + Visit(EnterDestructorDeclaration, LeaveDestructorDeclaration, destructorDeclaration); } - public event Action EventDeclarationVisited; - - S IAstVisitor.VisitEventDeclaration (EventDeclaration eventDeclaration, T data) + public event Action EnterEventDeclaration, LeaveEventDeclaration; + + void IAstVisitor.VisitEventDeclaration(EventDeclaration eventDeclaration) { - var handler = EventDeclarationVisited; - if (handler != null) - handler (eventDeclaration, data); - return VisitChildren (eventDeclaration, data); + Visit(EnterEventDeclaration, LeaveEventDeclaration, eventDeclaration); } - public event Action CustomEventDeclarationVisited; - - S IAstVisitor.VisitCustomEventDeclaration (CustomEventDeclaration eventDeclaration, T data) + public event Action EnterCustomEventDeclaration, LeaveCustomEventDeclaration; + + void IAstVisitor.VisitCustomEventDeclaration(CustomEventDeclaration eventDeclaration) { - var handler = CustomEventDeclarationVisited; - if (handler != null) - handler (eventDeclaration, data); - return VisitChildren (eventDeclaration, data); + Visit(EnterCustomEventDeclaration, LeaveCustomEventDeclaration, eventDeclaration); } - public event Action FieldDeclarationVisited; - - S IAstVisitor.VisitFieldDeclaration (FieldDeclaration fieldDeclaration, T data) + public event Action EnterFieldDeclaration, LeaveFieldDeclaration; + + void IAstVisitor.VisitFieldDeclaration(FieldDeclaration fieldDeclaration) { - var handler = FieldDeclarationVisited; - if (handler != null) - handler (fieldDeclaration, data); - return VisitChildren (fieldDeclaration, data); + Visit(EnterFieldDeclaration, LeaveFieldDeclaration, fieldDeclaration); } - public event Action FixedFieldDeclarationVisited; - - S IAstVisitor.VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, T data) + public event Action EnterFixedFieldDeclaration, LeaveFixedFieldDeclaration; + + void IAstVisitor.VisitFixedFieldDeclaration(FixedFieldDeclaration fixedFieldDeclaration) { - var handler = FixedFieldDeclarationVisited; - if (handler != null) - handler (fixedFieldDeclaration, data); - return VisitChildren (fixedFieldDeclaration, data); + Visit(EnterFixedFieldDeclaration, LeaveFixedFieldDeclaration, fixedFieldDeclaration); } - public event Action FixedVariableInitializerVisited; - - S IAstVisitor.VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer, T data) + public event Action EnterFixedVariableInitializer, LeaveFixedVariableInitializer; + + void IAstVisitor.VisitFixedVariableInitializer(FixedVariableInitializer fixedVariableInitializer) { - var handler = FixedVariableInitializerVisited; - if (handler != null) - handler (fixedVariableInitializer, data); - return VisitChildren (fixedVariableInitializer, data); + Visit(EnterFixedVariableInitializer, LeaveFixedVariableInitializer, fixedVariableInitializer); } - public event Action IndexerDeclarationVisited; - - S IAstVisitor.VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, T data) + public event Action EnterIndexerDeclaration, LeaveIndexerDeclaration; + + void IAstVisitor.VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration) { - var handler = IndexerDeclarationVisited; - if (handler != null) - handler (indexerDeclaration, data); - return VisitChildren (indexerDeclaration, data); + Visit(EnterIndexerDeclaration, LeaveIndexerDeclaration, indexerDeclaration); } - public event Action MethodDeclarationVisited; - - S IAstVisitor.VisitMethodDeclaration (MethodDeclaration methodDeclaration, T data) + public event Action EnterMethodDeclaration, LeaveMethodDeclaration; + + void IAstVisitor.VisitMethodDeclaration(MethodDeclaration methodDeclaration) { - var handler = MethodDeclarationVisited; - if (handler != null) - handler (methodDeclaration, data); - return VisitChildren (methodDeclaration, data); + Visit(EnterMethodDeclaration, LeaveMethodDeclaration, methodDeclaration); } - public event Action OperatorDeclarationVisited; - - S IAstVisitor.VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, T data) + public event Action EnterOperatorDeclaration, LeaveOperatorDeclaration; + + void IAstVisitor.VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) { - var handler = OperatorDeclarationVisited; - if (handler != null) - handler (operatorDeclaration, data); - return VisitChildren (operatorDeclaration, data); + Visit(EnterOperatorDeclaration, LeaveOperatorDeclaration, operatorDeclaration); } - public event Action PropertyDeclarationVisited; - - S IAstVisitor.VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, T data) + public event Action EnterPropertyDeclaration, LeavePropertyDeclaration; + + void IAstVisitor.VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { - var handler = PropertyDeclarationVisited; - if (handler != null) - handler (propertyDeclaration, data); - return VisitChildren (propertyDeclaration, data); + Visit(EnterPropertyDeclaration, LeavePropertyDeclaration, propertyDeclaration); } - public event Action AccessorVisited; - - S IAstVisitor.VisitAccessor (Accessor accessor, T data) + public event Action EnterAccessor, LeaveAccessor; + + void IAstVisitor.VisitAccessor(Accessor accessor) { - var handler = AccessorVisited; - if (handler != null) - handler (accessor, data); - return VisitChildren (accessor, data); + Visit(EnterAccessor, LeaveAccessor, accessor); } - public event Action VariableInitializerVisited; - - S IAstVisitor.VisitVariableInitializer (VariableInitializer variableInitializer, T data) + public event Action EnterVariableInitializer, LeaveVariableInitializer; + + void IAstVisitor.VisitVariableInitializer(VariableInitializer variableInitializer) { - var handler = VariableInitializerVisited; - if (handler != null) - handler (variableInitializer, data); - return VisitChildren (variableInitializer, data); + Visit(EnterVariableInitializer, LeaveVariableInitializer, variableInitializer); } - public event Action ParameterDeclarationVisited; - - S IAstVisitor.VisitParameterDeclaration (ParameterDeclaration parameterDeclaration, T data) + public event Action EnterParameterDeclaration, LeaveParameterDeclaration; + + void IAstVisitor.VisitParameterDeclaration(ParameterDeclaration parameterDeclaration) { - var handler = ParameterDeclarationVisited; - if (handler != null) - handler (parameterDeclaration, data); - return VisitChildren (parameterDeclaration, data); + Visit(EnterParameterDeclaration, LeaveParameterDeclaration, parameterDeclaration); } - public event Action ConstraintVisited; - - S IAstVisitor.VisitConstraint (Constraint constraint, T data) + public event Action EnterConstraint, LeaveConstraint; + + void IAstVisitor.VisitConstraint(Constraint constraint) { - var handler = ConstraintVisited; - if (handler != null) - handler (constraint, data); - return VisitChildren (constraint, data); + Visit(EnterConstraint, LeaveConstraint, constraint); } - public event Action BlockStatementVisited; - - S IAstVisitor.VisitBlockStatement (BlockStatement blockStatement, T data) + public event Action EnterBlockStatement, LeaveBlockStatement; + + void IAstVisitor.VisitBlockStatement(BlockStatement blockStatement) { - var handler = BlockStatementVisited; - if (handler != null) - handler (blockStatement, data); - return VisitChildren (blockStatement, data); + Visit(EnterBlockStatement, LeaveBlockStatement, blockStatement); } - public event Action ExpressionStatementVisited; - - S IAstVisitor.VisitExpressionStatement (ExpressionStatement expressionStatement, T data) + public event Action EnterExpressionStatement, LeaveExpressionStatement; + + void IAstVisitor.VisitExpressionStatement(ExpressionStatement expressionStatement) { - var handler = ExpressionStatementVisited; - if (handler != null) - handler (expressionStatement, data); - return VisitChildren (expressionStatement, data); + Visit(EnterExpressionStatement, LeaveExpressionStatement, expressionStatement); } - public event Action BreakStatementVisited; - - S IAstVisitor.VisitBreakStatement (BreakStatement breakStatement, T data) + public event Action EnterBreakStatement, LeaveBreakStatement; + + void IAstVisitor.VisitBreakStatement(BreakStatement breakStatement) { - var handler = BreakStatementVisited; - if (handler != null) - handler (breakStatement, data); - return VisitChildren (breakStatement, data); + Visit(EnterBreakStatement, LeaveBreakStatement, breakStatement); } - public event Action CheckedStatementVisited; - - S IAstVisitor.VisitCheckedStatement (CheckedStatement checkedStatement, T data) + public event Action EnterCheckedStatement, LeaveCheckedStatement; + + void IAstVisitor.VisitCheckedStatement(CheckedStatement checkedStatement) { - var handler = CheckedStatementVisited; - if (handler != null) - handler (checkedStatement, data); - return VisitChildren (checkedStatement, data); + Visit(EnterCheckedStatement, LeaveCheckedStatement, checkedStatement); } - public event Action ContinueStatementVisited; - - S IAstVisitor.VisitContinueStatement (ContinueStatement continueStatement, T data) + public event Action EnterContinueStatement, LeaveContinueStatement; + + void IAstVisitor.VisitContinueStatement(ContinueStatement continueStatement) { - var handler = ContinueStatementVisited; - if (handler != null) - handler (continueStatement, data); - return VisitChildren (continueStatement, data); + Visit(EnterContinueStatement, LeaveContinueStatement, continueStatement); } - public event Action DoWhileStatementVisited; - - S IAstVisitor.VisitDoWhileStatement (DoWhileStatement doWhileStatement, T data) + public event Action EnterDoWhileStatement, LeaveDoWhileStatement; + + void IAstVisitor.VisitDoWhileStatement(DoWhileStatement doWhileStatement) { - var handler = DoWhileStatementVisited; - if (handler != null) - handler (doWhileStatement, data); - return VisitChildren (doWhileStatement, data); + Visit(EnterDoWhileStatement, LeaveDoWhileStatement, doWhileStatement); } - public event Action EmptyStatementVisited; - - S IAstVisitor.VisitEmptyStatement (EmptyStatement emptyStatement, T data) + public event Action EnterEmptyStatement, LeaveEmptyStatement; + + void IAstVisitor.VisitEmptyStatement(EmptyStatement emptyStatement) { - var handler = EmptyStatementVisited; - if (handler != null) - handler (emptyStatement, data); - return VisitChildren (emptyStatement, data); + Visit(EnterEmptyStatement, LeaveEmptyStatement, emptyStatement); } - public event Action FixedStatementVisited; - - S IAstVisitor.VisitFixedStatement (FixedStatement fixedStatement, T data) + public event Action EnterFixedStatement, LeaveFixedStatement; + + void IAstVisitor.VisitFixedStatement(FixedStatement fixedStatement) { - var handler = FixedStatementVisited; - if (handler != null) - handler (fixedStatement, data); - return VisitChildren (fixedStatement, data); + Visit(EnterFixedStatement, LeaveFixedStatement, fixedStatement); } - public event Action ForeachStatementVisited; - - S IAstVisitor.VisitForeachStatement (ForeachStatement foreachStatement, T data) + public event Action EnterForeachStatement, LeaveForeachStatement; + + void IAstVisitor.VisitForeachStatement(ForeachStatement foreachStatement) { - var handler = ForeachStatementVisited; - if (handler != null) - handler (foreachStatement, data); - return VisitChildren (foreachStatement, data); + Visit(EnterForeachStatement, LeaveForeachStatement, foreachStatement); } - public event Action ForStatementVisited; - - S IAstVisitor.VisitForStatement (ForStatement forStatement, T data) + public event Action EnterForStatement, LeaveForStatement; + + void IAstVisitor.VisitForStatement(ForStatement forStatement) { - var handler = ForStatementVisited; - if (handler != null) - handler (forStatement, data); - return VisitChildren (forStatement, data); + Visit(EnterForStatement, LeaveForStatement, forStatement); } - public event Action GotoCaseStatementVisited; - - S IAstVisitor.VisitGotoCaseStatement (GotoCaseStatement gotoCaseStatement, T data) + public event Action EnterGotoCaseStatement, LeaveGotoCaseStatement; + + void IAstVisitor.VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement) { - var handler = GotoCaseStatementVisited; - if (handler != null) - handler (gotoCaseStatement, data); - return VisitChildren (gotoCaseStatement, data); + Visit(EnterGotoCaseStatement, LeaveGotoCaseStatement, gotoCaseStatement); } - public event Action GotoDefaultStatementVisited; - - S IAstVisitor.VisitGotoDefaultStatement (GotoDefaultStatement gotoDefaultStatement, T data) + public event Action EnterGotoDefaultStatement, LeaveGotoDefaultStatement; + + void IAstVisitor.VisitGotoDefaultStatement(GotoDefaultStatement gotoDefaultStatement) { - var handler = GotoDefaultStatementVisited; - if (handler != null) - handler (gotoDefaultStatement, data); - return VisitChildren (gotoDefaultStatement, data); + Visit(EnterGotoDefaultStatement, LeaveGotoDefaultStatement, gotoDefaultStatement); } - public event Action GotoStatementVisited; - - S IAstVisitor.VisitGotoStatement (GotoStatement gotoStatement, T data) + public event Action EnterGotoStatement, LeaveGotoStatement; + + void IAstVisitor.VisitGotoStatement(GotoStatement gotoStatement) { - var handler = GotoStatementVisited; - if (handler != null) - handler (gotoStatement, data); - return VisitChildren (gotoStatement, data); + Visit(EnterGotoStatement, LeaveGotoStatement, gotoStatement); } - public event Action IfElseStatementVisited; - - S IAstVisitor.VisitIfElseStatement (IfElseStatement ifElseStatement, T data) + public event Action EnterIfElseStatement, LeaveIfElseStatement; + + void IAstVisitor.VisitIfElseStatement(IfElseStatement ifElseStatement) { - var handler = IfElseStatementVisited; - if (handler != null) - handler (ifElseStatement, data); - return VisitChildren (ifElseStatement, data); + Visit(EnterIfElseStatement, LeaveIfElseStatement, ifElseStatement); } - public event Action LabelStatementVisited; - - S IAstVisitor.VisitLabelStatement (LabelStatement labelStatement, T data) + public event Action EnterLabelStatement, LeaveLabelStatement; + + void IAstVisitor.VisitLabelStatement(LabelStatement labelStatement) { - var handler = LabelStatementVisited; - if (handler != null) - handler (labelStatement, data); - return VisitChildren (labelStatement, data); + Visit(EnterLabelStatement, LeaveLabelStatement, labelStatement); } - public event Action LockStatementVisited; - - S IAstVisitor.VisitLockStatement (LockStatement lockStatement, T data) + public event Action EnterLockStatement, LeaveLockStatement; + + void IAstVisitor.VisitLockStatement(LockStatement lockStatement) { - var handler = LockStatementVisited; - if (handler != null) - handler (lockStatement, data); - return VisitChildren (lockStatement, data); + Visit(EnterLockStatement, LeaveLockStatement, lockStatement); } - public event Action ReturnStatementVisited; - - S IAstVisitor.VisitReturnStatement (ReturnStatement returnStatement, T data) + public event Action EnterReturnStatement, LeaveReturnStatement; + + void IAstVisitor.VisitReturnStatement(ReturnStatement returnStatement) { - var handler = ReturnStatementVisited; - if (handler != null) - handler (returnStatement, data); - return VisitChildren (returnStatement, data); + Visit(EnterReturnStatement, LeaveReturnStatement, returnStatement); } - public event Action SwitchStatementVisited; - - S IAstVisitor.VisitSwitchStatement (SwitchStatement switchStatement, T data) + public event Action EnterSwitchStatement, LeaveSwitchStatement; + + void IAstVisitor.VisitSwitchStatement(SwitchStatement switchStatement) { - var handler = SwitchStatementVisited; - if (handler != null) - handler (switchStatement, data); - return VisitChildren (switchStatement, data); + Visit(EnterSwitchStatement, LeaveSwitchStatement, switchStatement); } - public event Action SwitchSectionVisited; - - S IAstVisitor.VisitSwitchSection (SwitchSection switchSection, T data) + public event Action EnterSwitchSection, LeaveSwitchSection; + + void IAstVisitor.VisitSwitchSection(SwitchSection switchSection) { - var handler = SwitchSectionVisited; - if (handler != null) - handler (switchSection, data); - return VisitChildren (switchSection, data); + Visit(EnterSwitchSection, LeaveSwitchSection, switchSection); } - public event Action CaseLabelVisited; - - S IAstVisitor.VisitCaseLabel (CaseLabel caseLabel, T data) + public event Action EnterCaseLabel, LeaveCaseLabel; + + void IAstVisitor.VisitCaseLabel(CaseLabel caseLabel) { - var handler = CaseLabelVisited; - if (handler != null) - handler (caseLabel, data); - return VisitChildren (caseLabel, data); + Visit(EnterCaseLabel, LeaveCaseLabel, caseLabel); } - public event Action ThrowStatementVisited; - - S IAstVisitor.VisitThrowStatement (ThrowStatement throwStatement, T data) + public event Action EnterThrowStatement, LeaveThrowStatement; + + void IAstVisitor.VisitThrowStatement(ThrowStatement throwStatement) { - var handler = ThrowStatementVisited; - if (handler != null) - handler (throwStatement, data); - return VisitChildren (throwStatement, data); + Visit(EnterThrowStatement, LeaveThrowStatement, throwStatement); } - public event Action TryCatchStatementVisited; - - S IAstVisitor.VisitTryCatchStatement (TryCatchStatement tryCatchStatement, T data) + public event Action EnterTryCatchStatement, LeaveTryCatchStatement; + + void IAstVisitor.VisitTryCatchStatement(TryCatchStatement tryCatchStatement) { - var handler = TryCatchStatementVisited; - if (handler != null) - handler (tryCatchStatement, data); - return VisitChildren (tryCatchStatement, data); + Visit(EnterTryCatchStatement, LeaveTryCatchStatement, tryCatchStatement); } - public event Action CatchClauseVisited; - - S IAstVisitor.VisitCatchClause (CatchClause catchClause, T data) + public event Action EnterCatchClause, LeaveCatchClause; + + void IAstVisitor.VisitCatchClause(CatchClause catchClause) { - var handler = CatchClauseVisited; - if (handler != null) - handler (catchClause, data); - return VisitChildren (catchClause, data); + Visit(EnterCatchClause, LeaveCatchClause, catchClause); } - public event Action UncheckedStatementVisited; - - S IAstVisitor.VisitUncheckedStatement (UncheckedStatement uncheckedStatement, T data) + public event Action EnterUncheckedStatement, LeaveUncheckedStatement; + + void IAstVisitor.VisitUncheckedStatement(UncheckedStatement uncheckedStatement) { - var handler = UncheckedStatementVisited; - if (handler != null) - handler (uncheckedStatement, data); - return VisitChildren (uncheckedStatement, data); + Visit(EnterUncheckedStatement, LeaveUncheckedStatement, uncheckedStatement); } - public event Action UnsafeStatementVisited; - - S IAstVisitor.VisitUnsafeStatement (UnsafeStatement unsafeStatement, T data) + public event Action EnterUnsafeStatement, LeaveUnsafeStatement; + + void IAstVisitor.VisitUnsafeStatement(UnsafeStatement unsafeStatement) { - var handler = UnsafeStatementVisited; - if (handler != null) - handler (unsafeStatement, data); - return VisitChildren (unsafeStatement, data); + Visit(EnterUnsafeStatement, LeaveUnsafeStatement, unsafeStatement); } - public event Action UsingStatementVisited; - - S IAstVisitor.VisitUsingStatement (UsingStatement usingStatement, T data) + public event Action EnterUsingStatement, LeaveUsingStatement; + + void IAstVisitor.VisitUsingStatement(UsingStatement usingStatement) { - var handler = UsingStatementVisited; - if (handler != null) - handler (usingStatement, data); - return VisitChildren (usingStatement, data); + Visit(EnterUsingStatement, LeaveUsingStatement, usingStatement); } - public event Action VariableDeclarationStatementVisited; - - S IAstVisitor.VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, T data) + public event Action EnterVariableDeclarationStatement, LeaveVariableDeclarationStatement; + + void IAstVisitor.VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement) { - var handler = VariableDeclarationStatementVisited; - if (handler != null) - handler (variableDeclarationStatement, data); - return VisitChildren (variableDeclarationStatement, data); + Visit(EnterVariableDeclarationStatement, LeaveVariableDeclarationStatement, variableDeclarationStatement); } - public event Action WhileStatementVisited; - - S IAstVisitor.VisitWhileStatement (WhileStatement whileStatement, T data) + public event Action EnterWhileStatement, LeaveWhileStatement; + + void IAstVisitor.VisitWhileStatement(WhileStatement whileStatement) { - var handler = WhileStatementVisited; - if (handler != null) - handler (whileStatement, data); - return VisitChildren (whileStatement, data); + Visit(EnterWhileStatement, LeaveWhileStatement, whileStatement); } - public event Action YieldBreakStatementVisited; - - S IAstVisitor.VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement, T data) + public event Action EnterYieldBreakStatement, LeaveYieldBreakStatement; + + void IAstVisitor.VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement) { - var handler = YieldBreakStatementVisited; - if (handler != null) - handler (yieldBreakStatement, data); - return VisitChildren (yieldBreakStatement, data); + Visit(EnterYieldBreakStatement, LeaveYieldBreakStatement, yieldBreakStatement); } - public event Action YieldReturnStatementVisited; - - S IAstVisitor.VisitYieldReturnStatement (YieldReturnStatement yieldStatement, T data) + public event Action EnterYieldReturnStatement, LeaveYieldReturnStatement; + + void IAstVisitor.VisitYieldReturnStatement(YieldReturnStatement yieldStatement) { - var handler = YieldReturnStatementVisited; - if (handler != null) - handler (yieldStatement, data); - return VisitChildren (yieldStatement, data); + Visit(EnterYieldReturnStatement, LeaveYieldReturnStatement, yieldStatement); } - public event Action AnonymousMethodExpressionVisited; - - S IAstVisitor.VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression, T data) + public event Action EnterAnonymousMethodExpression, LeaveAnonymousMethodExpression; + + void IAstVisitor.VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression) { - var handler = AnonymousMethodExpressionVisited; - if (handler != null) - handler (anonymousMethodExpression, data); - return VisitChildren (anonymousMethodExpression, data); + Visit(EnterAnonymousMethodExpression, LeaveAnonymousMethodExpression, anonymousMethodExpression); } - public event Action LambdaExpressionVisited; - - S IAstVisitor.VisitLambdaExpression (LambdaExpression lambdaExpression, T data) + public event Action EnterLambdaExpression, LeaveLambdaExpression; + + void IAstVisitor.VisitLambdaExpression(LambdaExpression lambdaExpression) { - var handler = LambdaExpressionVisited; - if (handler != null) - handler (lambdaExpression, data); - return VisitChildren (lambdaExpression, data); + Visit(EnterLambdaExpression, LeaveLambdaExpression, lambdaExpression); } - public event Action AssignmentExpressionVisited; - - S IAstVisitor.VisitAssignmentExpression (AssignmentExpression assignmentExpression, T data) + public event Action EnterAssignmentExpression, LeaveAssignmentExpression; + + void IAstVisitor.VisitAssignmentExpression(AssignmentExpression assignmentExpression) { - var handler = AssignmentExpressionVisited; - if (handler != null) - handler (assignmentExpression, data); - return VisitChildren (assignmentExpression, data); + Visit(EnterAssignmentExpression, LeaveAssignmentExpression, assignmentExpression); } - public event Action BaseReferenceExpressionVisited; - - S IAstVisitor.VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression, T data) + public event Action EnterBaseReferenceExpression, LeaveBaseReferenceExpression; + + void IAstVisitor.VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression) { - var handler = BaseReferenceExpressionVisited; - if (handler != null) - handler (baseReferenceExpression, data); - return VisitChildren (baseReferenceExpression, data); + Visit(EnterBaseReferenceExpression, LeaveBaseReferenceExpression, baseReferenceExpression); } - public event Action BinaryOperatorExpressionVisited; - - S IAstVisitor.VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, T data) + public event Action EnterBinaryOperatorExpression, LeaveBinaryOperatorExpression; + + void IAstVisitor.VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression) { - var handler = BinaryOperatorExpressionVisited; - if (handler != null) - handler (binaryOperatorExpression, data); - return VisitChildren (binaryOperatorExpression, data); + Visit(EnterBinaryOperatorExpression, LeaveBinaryOperatorExpression, binaryOperatorExpression); } - public event Action CastExpressionVisited; - - S IAstVisitor.VisitCastExpression (CastExpression castExpression, T data) + public event Action EnterCastExpression, LeaveCastExpression; + + void IAstVisitor.VisitCastExpression(CastExpression castExpression) { - var handler = CastExpressionVisited; - if (handler != null) - handler (castExpression, data); - return VisitChildren (castExpression, data); + Visit(EnterCastExpression, LeaveCastExpression, castExpression); } - public event Action CheckedExpressionVisited; - - S IAstVisitor.VisitCheckedExpression (CheckedExpression checkedExpression, T data) + public event Action EnterCheckedExpression, LeaveCheckedExpression; + + void IAstVisitor.VisitCheckedExpression(CheckedExpression checkedExpression) { - var handler = CheckedExpressionVisited; - if (handler != null) - handler (checkedExpression, data); - return VisitChildren (checkedExpression, data); + Visit(EnterCheckedExpression, LeaveCheckedExpression, checkedExpression); } - public event Action ConditionalExpressionVisited; - - S IAstVisitor.VisitConditionalExpression (ConditionalExpression conditionalExpression, T data) + public event Action EnterConditionalExpression, LeaveConditionalExpression; + + void IAstVisitor.VisitConditionalExpression(ConditionalExpression conditionalExpression) { - var handler = ConditionalExpressionVisited; - if (handler != null) - handler (conditionalExpression, data); - return VisitChildren (conditionalExpression, data); + Visit(EnterConditionalExpression, LeaveConditionalExpression, conditionalExpression); } - public event Action IdentifierExpressionVisited; - - S IAstVisitor.VisitIdentifierExpression (IdentifierExpression identifierExpression, T data) + public event Action EnterIdentifierExpression, LeaveIdentifierExpression; + + void IAstVisitor.VisitIdentifierExpression(IdentifierExpression identifierExpression) { - var handler = IdentifierExpressionVisited; - if (handler != null) - handler (identifierExpression, data); - return VisitChildren (identifierExpression, data); + Visit(EnterIdentifierExpression, LeaveIdentifierExpression, identifierExpression); } - public event Action IndexerExpressionVisited; - - S IAstVisitor.VisitIndexerExpression (IndexerExpression indexerExpression, T data) + public event Action EnterIndexerExpression, LeaveIndexerExpression; + + void IAstVisitor.VisitIndexerExpression(IndexerExpression indexerExpression) { - var handler = IndexerExpressionVisited; - if (handler != null) - handler (indexerExpression, data); - return VisitChildren (indexerExpression, data); + Visit(EnterIndexerExpression, LeaveIndexerExpression, indexerExpression); } - public event Action InvocationExpressionVisited; - - S IAstVisitor.VisitInvocationExpression (InvocationExpression invocationExpression, T data) + public event Action EnterInvocationExpression, LeaveInvocationExpression; + + void IAstVisitor.VisitInvocationExpression(InvocationExpression invocationExpression) { - var handler = InvocationExpressionVisited; - if (handler != null) - handler (invocationExpression, data); - return VisitChildren (invocationExpression, data); + Visit(EnterInvocationExpression, LeaveInvocationExpression, invocationExpression); } - public event Action DirectionExpressionVisited; - - S IAstVisitor.VisitDirectionExpression (DirectionExpression directionExpression, T data) + public event Action EnterDirectionExpression, LeaveDirectionExpression; + + void IAstVisitor.VisitDirectionExpression(DirectionExpression directionExpression) { - var handler = DirectionExpressionVisited; - if (handler != null) - handler (directionExpression, data); - return VisitChildren (directionExpression, data); + Visit(EnterDirectionExpression, LeaveDirectionExpression, directionExpression); } - public event Action MemberReferenceExpressionVisited; - - S IAstVisitor.VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression, T data) + public event Action EnterMemberReferenceExpression, LeaveMemberReferenceExpression; + + void IAstVisitor.VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression) { - var handler = MemberReferenceExpressionVisited; - if (handler != null) - handler (memberReferenceExpression, data); - return VisitChildren (memberReferenceExpression, data); + Visit(EnterMemberReferenceExpression, LeaveMemberReferenceExpression, memberReferenceExpression); } - public event Action NullReferenceExpressionVisited; - - S IAstVisitor.VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression, T data) + public event Action EnterNullReferenceExpression, LeaveNullReferenceExpression; + + void IAstVisitor.VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression) { - var handler = NullReferenceExpressionVisited; - if (handler != null) - handler (nullReferenceExpression, data); - return VisitChildren (nullReferenceExpression, data); + Visit(EnterNullReferenceExpression, LeaveNullReferenceExpression, nullReferenceExpression); } - public event Action ObjectCreateExpressionVisited; - - S IAstVisitor.VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, T data) + public event Action EnterObjectCreateExpression, LeaveObjectCreateExpression; + + void IAstVisitor.VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression) { - var handler = ObjectCreateExpressionVisited; - if (handler != null) - handler (objectCreateExpression, data); - return VisitChildren (objectCreateExpression, data); + Visit(EnterObjectCreateExpression, LeaveObjectCreateExpression, objectCreateExpression); } - public event Action AnonymousTypeCreateExpressionVisited; - - S IAstVisitor.VisitAnonymousTypeCreateExpression (AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data) + public event Action EnterAnonymousTypeCreateExpression, LeaveAnonymousTypeCreateExpression; + + void IAstVisitor.VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression) { - var handler = AnonymousTypeCreateExpressionVisited; - if (handler != null) - handler (anonymousTypeCreateExpression, data); - return VisitChildren (anonymousTypeCreateExpression, data); + Visit(EnterAnonymousTypeCreateExpression, LeaveAnonymousTypeCreateExpression, anonymousTypeCreateExpression); } - public event Action ArrayCreateExpressionVisited; - - S IAstVisitor.VisitArrayCreateExpression (ArrayCreateExpression arraySCreateExpression, T data) + public event Action EnterArrayCreateExpression, LeaveArrayCreateExpression; + + void IAstVisitor.VisitArrayCreateExpression(ArrayCreateExpression arraySCreateExpression) { - var handler = ArrayCreateExpressionVisited; - if (handler != null) - handler (arraySCreateExpression, data); - return VisitChildren (arraySCreateExpression, data); + Visit(EnterArrayCreateExpression, LeaveArrayCreateExpression, arraySCreateExpression); } - public event Action ParenthesizedExpressionVisited; - - S IAstVisitor.VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, T data) + public event Action EnterParenthesizedExpression, LeaveParenthesizedExpression; + + void IAstVisitor.VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression) { - var handler = ParenthesizedExpressionVisited; - if (handler != null) - handler (parenthesizedExpression, data); - return VisitChildren (parenthesizedExpression, data); + Visit(EnterParenthesizedExpression, LeaveParenthesizedExpression, parenthesizedExpression); } - public event Action PointerReferenceExpressionVisited; - - S IAstVisitor.VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression, T data) + public event Action EnterPointerReferenceExpression, LeavePointerReferenceExpression; + + void IAstVisitor.VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression) { - var handler = PointerReferenceExpressionVisited; - if (handler != null) - handler (pointerReferenceExpression, data); - return VisitChildren (pointerReferenceExpression, data); + Visit(EnterPointerReferenceExpression, LeavePointerReferenceExpression, pointerReferenceExpression); } - public event Action PrimitiveExpressionVisited; - - S IAstVisitor.VisitPrimitiveExpression (PrimitiveExpression primitiveExpression, T data) + public event Action EnterPrimitiveExpression, LeavePrimitiveExpression; + + void IAstVisitor.VisitPrimitiveExpression(PrimitiveExpression primitiveExpression) { - var handler = PrimitiveExpressionVisited; - if (handler != null) - handler (primitiveExpression, data); - return VisitChildren (primitiveExpression, data); + Visit(EnterPrimitiveExpression, LeavePrimitiveExpression, primitiveExpression); } - public event Action SizeOfExpressionVisited; - - S IAstVisitor.VisitSizeOfExpression (SizeOfExpression sizeOfExpression, T data) + public event Action EnterSizeOfExpression, LeaveSizeOfExpression; + + void IAstVisitor.VisitSizeOfExpression(SizeOfExpression sizeOfExpression) { - var handler = SizeOfExpressionVisited; - if (handler != null) - handler (sizeOfExpression, data); - return VisitChildren (sizeOfExpression, data); + Visit(EnterSizeOfExpression, LeaveSizeOfExpression, sizeOfExpression); } - public event Action StackAllocExpressionVisited; - - S IAstVisitor.VisitStackAllocExpression (StackAllocExpression stackAllocExpression, T data) + public event Action EnterStackAllocExpression, LeaveStackAllocExpression; + + void IAstVisitor.VisitStackAllocExpression(StackAllocExpression stackAllocExpression) { - var handler = StackAllocExpressionVisited; - if (handler != null) - handler (stackAllocExpression, data); - return VisitChildren (stackAllocExpression, data); + Visit(EnterStackAllocExpression, LeaveStackAllocExpression, stackAllocExpression); } - public event Action ThisReferenceExpressionVisited; - - S IAstVisitor.VisitThisReferenceExpression (ThisReferenceExpression thisReferenceExpression, T data) + public event Action EnterThisReferenceExpression, LeaveThisReferenceExpression; + + void IAstVisitor.VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression) { - var handler = ThisReferenceExpressionVisited; - if (handler != null) - handler (thisReferenceExpression, data); - return VisitChildren (thisReferenceExpression, data); + Visit(EnterThisReferenceExpression, LeaveThisReferenceExpression, thisReferenceExpression); } - public event Action TypeOfExpressionVisited; - - S IAstVisitor.VisitTypeOfExpression (TypeOfExpression typeOfExpression, T data) + public event Action EnterTypeOfExpression, LeaveTypeOfExpression; + + void IAstVisitor.VisitTypeOfExpression(TypeOfExpression typeOfExpression) { - var handler = TypeOfExpressionVisited; - if (handler != null) - handler (typeOfExpression, data); - return VisitChildren (typeOfExpression, data); + Visit(EnterTypeOfExpression, LeaveTypeOfExpression, typeOfExpression); } - public event Action TypeReferenceExpressionVisited; - - S IAstVisitor.VisitTypeReferenceExpression (TypeReferenceExpression typeReferenceExpression, T data) + public event Action EnterTypeReferenceExpression, LeaveTypeReferenceExpression; + + void IAstVisitor.VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression) { - var handler = TypeReferenceExpressionVisited; - if (handler != null) - handler (typeReferenceExpression, data); - return VisitChildren (typeReferenceExpression, data); + Visit(EnterTypeReferenceExpression, LeaveTypeReferenceExpression, typeReferenceExpression); } - public event Action UnaryOperatorExpressionVisited; - - S IAstVisitor.VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression, T data) + public event Action EnterUnaryOperatorExpression, LeaveUnaryOperatorExpression; + + void IAstVisitor.VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression) { - var handler = UnaryOperatorExpressionVisited; - if (handler != null) - handler (unaryOperatorExpression, data); - return VisitChildren (unaryOperatorExpression, data); + Visit(EnterUnaryOperatorExpression, LeaveUnaryOperatorExpression, unaryOperatorExpression); } - public event Action UncheckedExpressionVisited; - - S IAstVisitor.VisitUncheckedExpression (UncheckedExpression uncheckedExpression, T data) + public event Action EnterUncheckedExpression, LeaveUncheckedExpression; + + void IAstVisitor.VisitUncheckedExpression(UncheckedExpression uncheckedExpression) { - var handler = UncheckedExpressionVisited; - if (handler != null) - handler (uncheckedExpression, data); - return VisitChildren (uncheckedExpression, data); + Visit(EnterUncheckedExpression, LeaveUncheckedExpression, uncheckedExpression); } - public event Action QueryExpressionVisited; - - S IAstVisitor.VisitQueryExpression (QueryExpression queryExpression, T data) + public event Action EnterQueryExpression, LeaveQueryExpression; + + void IAstVisitor.VisitQueryExpression(QueryExpression queryExpression) { - var handler = QueryExpressionVisited; - if (handler != null) - handler (queryExpression, data); - return VisitChildren (queryExpression, data); + Visit(EnterQueryExpression, LeaveQueryExpression, queryExpression); } - public event Action QueryContinuationClauseVisited; - - S IAstVisitor.VisitQueryContinuationClause (QueryContinuationClause queryContinuationClause, T data) + public event Action EnterQueryContinuationClause, LeaveQueryContinuationClause; + + void IAstVisitor.VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause) { - var handler = QueryContinuationClauseVisited; - if (handler != null) - handler (queryContinuationClause, data); - return VisitChildren (queryContinuationClause, data); + Visit(EnterQueryContinuationClause, LeaveQueryContinuationClause, queryContinuationClause); } - public event Action QueryFromClauseVisited; - - S IAstVisitor.VisitQueryFromClause (QueryFromClause queryFromClause, T data) + public event Action EnterQueryFromClause, LeaveQueryFromClause; + + void IAstVisitor.VisitQueryFromClause(QueryFromClause queryFromClause) { - var handler = QueryFromClauseVisited; - if (handler != null) - handler (queryFromClause, data); - return VisitChildren (queryFromClause, data); + Visit(EnterQueryFromClause, LeaveQueryFromClause, queryFromClause); } - public event Action QueryLetClauseVisited; - - S IAstVisitor.VisitQueryLetClause (QueryLetClause queryLetClause, T data) + public event Action EnterQueryLetClause, LeaveQueryLetClause; + + void IAstVisitor.VisitQueryLetClause(QueryLetClause queryLetClause) { - var handler = QueryLetClauseVisited; - if (handler != null) - handler (queryLetClause, data); - return VisitChildren (queryLetClause, data); + Visit(EnterQueryLetClause, LeaveQueryLetClause, queryLetClause); } - public event Action QueryWhereClauseVisited; - - S IAstVisitor.VisitQueryWhereClause (QueryWhereClause queryWhereClause, T data) + public event Action EnterQueryWhereClause, LeaveQueryWhereClause; + + void IAstVisitor.VisitQueryWhereClause(QueryWhereClause queryWhereClause) { - var handler = QueryWhereClauseVisited; - if (handler != null) - handler (queryWhereClause, data); - return VisitChildren (queryWhereClause, data); + Visit(EnterQueryWhereClause, LeaveQueryWhereClause, queryWhereClause); } - public event Action QueryJoinClauseVisited; - - S IAstVisitor.VisitQueryJoinClause (QueryJoinClause queryJoinClause, T data) + public event Action EnterQueryJoinClause, LeaveQueryJoinClause; + + void IAstVisitor.VisitQueryJoinClause(QueryJoinClause queryJoinClause) { - var handler = QueryJoinClauseVisited; - if (handler != null) - handler (queryJoinClause, data); - return VisitChildren (queryJoinClause, data); + Visit(EnterQueryJoinClause, LeaveQueryJoinClause, queryJoinClause); } - public event Action QueryOrderClauseVisited; - - S IAstVisitor.VisitQueryOrderClause (QueryOrderClause queryOrderClause, T data) + public event Action EnterQueryOrderClause, LeaveQueryOrderClause; + + void IAstVisitor.VisitQueryOrderClause(QueryOrderClause queryOrderClause) { - var handler = QueryOrderClauseVisited; - if (handler != null) - handler (queryOrderClause, data); - return VisitChildren (queryOrderClause, data); + Visit(EnterQueryOrderClause, LeaveQueryOrderClause, queryOrderClause); } - public event Action QueryOrderingVisited; - - S IAstVisitor.VisitQueryOrdering (QueryOrdering queryOrdering, T data) + public event Action EnterQueryOrdering, LeaveQueryOrdering; + + void IAstVisitor.VisitQueryOrdering(QueryOrdering queryOrdering) { - var handler = QueryOrderingVisited; - if (handler != null) - handler (queryOrdering, data); - return VisitChildren (queryOrdering, data); + Visit(EnterQueryOrdering, LeaveQueryOrdering, queryOrdering); } - public event Action QuerySelectClauseVisited; - - S IAstVisitor.VisitQuerySelectClause (QuerySelectClause querySelectClause, T data) + public event Action EnterQuerySelectClause, LeaveQuerySelectClause; + + void IAstVisitor.VisitQuerySelectClause(QuerySelectClause querySelectClause) { - var handler = QuerySelectClauseVisited; - if (handler != null) - handler (querySelectClause, data); - return VisitChildren (querySelectClause, data); + Visit(EnterQuerySelectClause, LeaveQuerySelectClause, querySelectClause); } - public event Action QueryGroupClauseVisited; - - S IAstVisitor.VisitQueryGroupClause (QueryGroupClause queryGroupClause, T data) + public event Action EnterQueryGroupClause, LeaveQueryGroupClause; + + void IAstVisitor.VisitQueryGroupClause(QueryGroupClause queryGroupClause) { - var handler = QueryGroupClauseVisited; - if (handler != null) - handler (queryGroupClause, data); - return VisitChildren (queryGroupClause, data); + Visit(EnterQueryGroupClause, LeaveQueryGroupClause, queryGroupClause); } - public event Action AsExpressionVisited; - - S IAstVisitor.VisitAsExpression (AsExpression asExpression, T data) + public event Action EnterAsExpression, LeaveAsExpression; + + void IAstVisitor.VisitAsExpression(AsExpression asExpression) { - var handler = AsExpressionVisited; - if (handler != null) - handler (asExpression, data); - return VisitChildren (asExpression, data); + Visit(EnterAsExpression, LeaveAsExpression, asExpression); } - public event Action IsExpressionVisited; - - S IAstVisitor.VisitIsExpression (IsExpression isExpression, T data) + public event Action EnterIsExpression, LeaveIsExpression; + + void IAstVisitor.VisitIsExpression(IsExpression isExpression) { - var handler = IsExpressionVisited; - if (handler != null) - handler (isExpression, data); - return VisitChildren (isExpression, data); + Visit(EnterIsExpression, LeaveIsExpression, isExpression); } - public event Action DefaultValueExpressionVisited; - - S IAstVisitor.VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression, T data) + public event Action EnterDefaultValueExpression, LeaveDefaultValueExpression; + + void IAstVisitor.VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression) { - var handler = DefaultValueExpressionVisited; - if (handler != null) - handler (defaultValueExpression, data); - return VisitChildren (defaultValueExpression, data); + Visit(EnterDefaultValueExpression, LeaveDefaultValueExpression, defaultValueExpression); } - public event Action UndocumentedExpressionVisited; - - S IAstVisitor.VisitUndocumentedExpression (UndocumentedExpression undocumentedExpression, T data) + public event Action EnterUndocumentedExpression, LeaveUndocumentedExpression; + + void IAstVisitor.VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression) { - var handler = UndocumentedExpressionVisited; - if (handler != null) - handler (undocumentedExpression, data); - return VisitChildren (undocumentedExpression, data); + Visit(EnterUndocumentedExpression, LeaveUndocumentedExpression, undocumentedExpression); } - public event Action ArrayInitializerExpressionVisited; - - S IAstVisitor.VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression, T data) + public event Action EnterArrayInitializerExpression, LeaveArrayInitializerExpression; + + void IAstVisitor.VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression) { - var handler = ArrayInitializerExpressionVisited; - if (handler != null) - handler (arrayInitializerExpression, data); - return VisitChildren (arrayInitializerExpression, data); + Visit(EnterArrayInitializerExpression, LeaveArrayInitializerExpression, arrayInitializerExpression); } - public event Action ArraySpecifierVisited; - - S IAstVisitor.VisitArraySpecifier (ArraySpecifier arraySpecifier, T data) + public event Action EnterArraySpecifier, LeaveArraySpecifier; + + void IAstVisitor.VisitArraySpecifier(ArraySpecifier arraySpecifier) { - var handler = ArraySpecifierVisited; - if (handler != null) - handler (arraySpecifier, data); - return VisitChildren (arraySpecifier, data); + Visit(EnterArraySpecifier, LeaveArraySpecifier, arraySpecifier); } - public event Action NamedArgumentExpressionVisited; - - S IAstVisitor.VisitNamedArgumentExpression (NamedArgumentExpression namedArgumentExpression, T data) + public event Action EnterNamedArgumentExpression, LeaveNamedArgumentExpression; + + void IAstVisitor.VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression) { - var handler = NamedArgumentExpressionVisited; - if (handler != null) - handler (namedArgumentExpression, data); - return VisitChildren (namedArgumentExpression, data); + Visit(EnterNamedArgumentExpression, LeaveNamedArgumentExpression, namedArgumentExpression); } - public event Action NamedExpressionVisited; - - S IAstVisitor.VisitNamedExpression (NamedExpression namedExpression, T data) + public event Action EnterNamedExpression, LeaveNamedExpression; + + void IAstVisitor.VisitNamedExpression(NamedExpression namedExpression) { - var handler = NamedExpressionVisited; - if (handler != null) - handler (namedExpression, data); - return VisitChildren (namedExpression, data); + Visit(EnterNamedExpression, LeaveNamedExpression, namedExpression); } - public event Action EmptyExpressionVisited; - - S IAstVisitor.VisitEmptyExpression (EmptyExpression emptyExpression, T data) + public event Action EnterEmptyExpression, LeaveEmptyExpression; + + void IAstVisitor.VisitEmptyExpression(EmptyExpression emptyExpression) { - var handler = EmptyExpressionVisited; - if (handler != null) - handler (emptyExpression, data); - return VisitChildren (emptyExpression, data); + Visit(EnterEmptyExpression, LeaveEmptyExpression, emptyExpression); } - S IAstVisitor.VisitPatternPlaceholder (AstNode placeholder, PatternMatching.Pattern pattern, T data) + void IAstVisitor.VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern) { - return VisitChildren (placeholder, data); } } } - - diff --git a/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs b/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs index bc367b3b6..9d8a575be 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/PrimitiveType.cs @@ -103,7 +103,7 @@ namespace ICSharpCode.NRefactory.CSharp return Keyword; } - public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type) + public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type) { KnownTypeCode typeCode = GetTypeCodeForPrimitiveType(this.Keyword); if (typeCode == KnownTypeCode.None) diff --git a/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs b/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs index 072432b46..79b4e0f9c 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/SimpleType.cs @@ -66,7 +66,7 @@ namespace ICSharpCode.NRefactory.CSharp return other == null || other.IsNull; } - public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode) + public override ITypeReference ToTypeReference(NameLookupMode lookupMode) { return SpecialType.UnknownType; } @@ -158,7 +158,7 @@ namespace ICSharpCode.NRefactory.CSharp return b.ToString(); } - public override ITypeReference ToTypeReference(SimpleNameLookupMode lookupMode = SimpleNameLookupMode.Type) + public override ITypeReference ToTypeReference(NameLookupMode lookupMode = NameLookupMode.Type) { var typeArguments = new List(); foreach (var ta in this.TypeArguments) { diff --git a/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs b/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs index b19036495..13e375b49 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/Statements/TryCatchStatement.cs @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp { 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 CatchClauseRole = new Role("CatchClause", CatchClause.Null); public static readonly TokenRole FinallyKeywordRole = new TokenRole ("finally"); public static readonly Role FinallyBlockRole = new Role("FinallyBlock", BlockStatement.Null); @@ -90,7 +90,39 @@ namespace ICSharpCode.NRefactory.CSharp public class CatchClause : AstNode { public static readonly TokenRole CatchKeywordRole = new TokenRole ("catch"); + + #region Null + public new static readonly CatchClause Null = new NullCatchClause (); + sealed class NullCatchClause : CatchClause + { + 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 CatchClause(PatternMatching.Pattern pattern) { diff --git a/ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs b/ICSharpCode.NRefactory.CSharp/Ast/SyntaxTree.cs similarity index 65% rename from ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs rename to ICSharpCode.NRefactory.CSharp/Ast/SyntaxTree.cs index 04dec11e7..2906696b3 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/CompilationUnit.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/SyntaxTree.cs @@ -1,5 +1,5 @@ // -// CompilationUnit.cs +// SyntaxTree.cs // // Author: // Mike Krüger @@ -23,6 +23,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + using System; using System.Collections.Generic; using ICSharpCode.NRefactory.CSharp.Resolver; @@ -35,7 +36,10 @@ using ICSharpCode.NRefactory.Editor; namespace ICSharpCode.NRefactory.CSharp { - public class CompilationUnit : AstNode + [Obsolete("CompilationUnit was renamed to SyntaxTree", true)] + public class CompilationUnit {} + + public class SyntaxTree : AstNode { public static readonly Role MemberRole = new Role("Member", AstNode.Null); @@ -48,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp string fileName; /// - /// Gets/Sets the file name of this compilation unit. + /// Gets/Sets the file name of this syntax tree. /// public string FileName { get { return fileName; } @@ -61,26 +65,43 @@ namespace ICSharpCode.NRefactory.CSharp public AstNodeCollection Members { get { return GetChildrenByRole(MemberRole); } } - + + IList conditionalSymbols = null; + List errors = new List (); public List Errors { get { return errors; } } - + + + /// + /// Gets the conditional symbols used to parse the source file. Note that this list contains + /// the conditional symbols at the start of the first token in the file - including the ones defined + /// in the source file. + /// + public IList ConditionalSymbols { + get { + return conditionalSymbols ?? EmptyList.Instance; + } + internal set { + conditionalSymbols = value; + } + } + /// /// Gets the expression that was on top of the parse stack. /// This is the only way to get an expression that isn't part of a statment. /// (eg. when an error follows an expression). /// - /// This is used for code completion to 'get the expression before a token - like ., <, ('. + /// This is used for code completion to 'get the expression before a token - like ., <, ('. /// public AstNode TopExpression { get; internal set; } - public CompilationUnit () + public SyntaxTree () { } @@ -103,67 +124,59 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { - CompilationUnit o = other as CompilationUnit; + SyntaxTree o = other as SyntaxTree; return o != null && GetChildrenByRole(MemberRole).DoMatch(o.GetChildrenByRole(MemberRole), match); } public override void AcceptVisitor (IAstVisitor visitor) { - visitor.VisitCompilationUnit (this); + visitor.VisitSyntaxTree (this); } public override T AcceptVisitor (IAstVisitor visitor) { - return visitor.VisitCompilationUnit (this); + return visitor.VisitSyntaxTree (this); } public override S AcceptVisitor (IAstVisitor visitor, T data) { - return visitor.VisitCompilationUnit (this, data); + return visitor.VisitSyntaxTree (this, data); } /// - /// Converts this compilation unit into a parsed file that can be stored in the type system. + /// Converts this syntax tree into a parsed file that can be stored in the type system. /// - public CSharpParsedFile ToTypeSystem () + public CSharpUnresolvedFile ToTypeSystem () { if (string.IsNullOrEmpty (this.FileName)) - throw new InvalidOperationException ("Cannot use ToTypeSystem() on a compilation unit without file name."); + throw new InvalidOperationException ("Cannot use ToTypeSystem() on a syntax tree without file name."); var v = new TypeSystemConvertVisitor (this.FileName); - v.VisitCompilationUnit (this); - return v.ParsedFile; + v.VisitSyntaxTree (this); + return v.UnresolvedFile; } - public static CompilationUnit Parse (string text, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) + public static SyntaxTree Parse (string program, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) { - var parser = new CSharpParser (); - if (settings != null) - parser.CompilerSettings = settings; - return parser.Parse (text, fileName); + var parser = new CSharpParser (settings); + return parser.Parse (program, fileName); } - public static CompilationUnit Parse (TextReader reader, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) + public static SyntaxTree 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); + var parser = new CSharpParser (settings); + return parser.Parse (reader, fileName); } - public static CompilationUnit Parse (Stream stream, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) + public static SyntaxTree 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); + var parser = new CSharpParser (settings); + return parser.Parse (stream, fileName); } - public static CompilationUnit Parse (ITextSource textSource, string fileName = "", CompilerSettings settings = null, CancellationToken cancellationToken = default (CancellationToken)) + public static SyntaxTree 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); + var parser = new CSharpParser (settings); + return parser.Parse (textSource, fileName); } } } diff --git a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs index c175485ab..02bc126ae 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/IndexerDeclaration.cs @@ -24,6 +24,7 @@ // 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 @@ -47,6 +48,16 @@ namespace ICSharpCode.NRefactory.CSharp set { SetChildByRole (PrivateImplementationTypeRole, value); } } + public override string Name { + get { return "Item"; } + set { throw new NotSupportedException(); } + } + + public override Identifier NameToken { + get { return Identifier.Null; } + set { throw new NotSupportedException(); } + } + public CSharpTokenNode LBracketToken { get { return GetChildByRole (Roles.LBracket); } } @@ -95,7 +106,7 @@ namespace ICSharpCode.NRefactory.CSharp protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { IndexerDeclaration o = other as IndexerDeclaration; - return o != null && MatchString(this.Name, o.Name) + return o != null && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) && this.Parameters.DoMatch(o.Parameters, match) diff --git a/ICSharpCode.NRefactory.CSharp/Ast/old_ObservableAstVisitor.cs b/ICSharpCode.NRefactory.CSharp/Ast/old_ObservableAstVisitor.cs new file mode 100644 index 000000000..6baf690df --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Ast/old_ObservableAstVisitor.cs @@ -0,0 +1,1201 @@ +// +// ObservableAstVisitor.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace ICSharpCode.NRefactory.CSharp +{ + [Obsolete("Use the non-generic version of the ObservableAstVisitor instead (the 'data' parameter and return value cannot be used meaningfully when using events)")] + public class ObservableAstVisitor: IAstVisitor + { + S VisitChildren (AstNode node, T data) + { + AstNode next; + for (var child = node.FirstChild; child != null; child = next) { + // Store next to allow the loop to continue + // if the visitor removes/replaces child. + next = child.NextSibling; + child.AcceptVisitor (this, data); + } + return default (S); + } + + public event Action CompilationUnitVisited; + + S IAstVisitor.VisitSyntaxTree (SyntaxTree unit, T data) + { + var handler = CompilationUnitVisited; + if (handler != null) + handler (unit, data); + return VisitChildren (unit, data); + } + + public event Action CommentVisited; + + S IAstVisitor.VisitComment (Comment comment, T data) + { + var handler = CommentVisited; + if (handler != null) + handler (comment, data); + return VisitChildren (comment, data); + } + + public event Action 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; + if (handler != null) + handler (preProcessorDirective, data); + 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) + { + var handler = IdentifierVisited; + if (handler != null) + handler (identifier, data); + return VisitChildren (identifier, data); + } + + public event Action CSharpTokenNodeVisited; + + S IAstVisitor.VisitCSharpTokenNode (CSharpTokenNode token, T data) + { + var handler = CSharpTokenNodeVisited; + if (handler != null) + handler (token, data); + return VisitChildren (token, data); + } + + public event Action PrimitiveTypeVisited; + + S IAstVisitor.VisitPrimitiveType (PrimitiveType primitiveType, T data) + { + var handler = PrimitiveTypeVisited; + if (handler != null) + handler (primitiveType, data); + return VisitChildren (primitiveType, data); + } + + public event Action ComposedTypeVisited; + + S IAstVisitor.VisitComposedType (ComposedType composedType, T data) + { + var handler = ComposedTypeVisited; + if (handler != null) + handler (composedType, data); + return VisitChildren (composedType, data); + } + + public event Action SimpleTypeVisited; + + S IAstVisitor.VisitSimpleType (SimpleType simpleType, T data) + { + var handler = SimpleTypeVisited; + if (handler != null) + handler (simpleType, data); + return VisitChildren (simpleType, data); + } + + public event Action MemberTypeVisited; + + S IAstVisitor.VisitMemberType (MemberType memberType, T data) + { + var handler = MemberTypeVisited; + if (handler != null) + handler (memberType, data); + return VisitChildren (memberType, data); + } + + public event Action AttributeVisited; + + S IAstVisitor.VisitAttribute (Attribute attribute, T data) + { + var handler = AttributeVisited; + if (handler != null) + handler (attribute, data); + return VisitChildren (attribute, data); + } + + public event Action AttributeSectionVisited; + + S IAstVisitor.VisitAttributeSection (AttributeSection attributeSection, T data) + { + var handler = AttributeSectionVisited; + if (handler != null) + handler (attributeSection, data); + return VisitChildren (attributeSection, data); + } + + public event Action DelegateDeclarationVisited; + + S IAstVisitor.VisitDelegateDeclaration (DelegateDeclaration delegateDeclaration, T data) + { + var handler = DelegateDeclarationVisited; + if (handler != null) + handler (delegateDeclaration, data); + return VisitChildren (delegateDeclaration, data); + } + + public event Action NamespaceDeclarationVisited; + + S IAstVisitor.VisitNamespaceDeclaration (NamespaceDeclaration namespaceDeclaration, T data) + { + var handler = NamespaceDeclarationVisited; + if (handler != null) + handler (namespaceDeclaration, data); + return VisitChildren (namespaceDeclaration, data); + } + + public event Action TypeDeclarationVisited; + + S IAstVisitor.VisitTypeDeclaration (TypeDeclaration typeDeclaration, T data) + { + var handler = TypeDeclarationVisited; + if (handler != null) + handler (typeDeclaration, data); + return VisitChildren (typeDeclaration, data); + } + + public event Action TypeParameterDeclarationVisited; + + S IAstVisitor.VisitTypeParameterDeclaration (TypeParameterDeclaration typeParameterDeclaration, T data) + { + var handler = TypeParameterDeclarationVisited; + if (handler != null) + handler (typeParameterDeclaration, data); + return VisitChildren (typeParameterDeclaration, data); + } + + public event Action EnumMemberDeclarationVisited; + + S IAstVisitor.VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, T data) + { + var handler = EnumMemberDeclarationVisited; + if (handler != null) + handler (enumMemberDeclaration, data); + return VisitChildren (enumMemberDeclaration, data); + } + + public event Action UsingDeclarationVisited; + + S IAstVisitor.VisitUsingDeclaration (UsingDeclaration usingDeclaration, T data) + { + var handler = UsingDeclarationVisited; + if (handler != null) + handler (usingDeclaration, data); + return VisitChildren (usingDeclaration, data); + } + + public event Action UsingAliasDeclarationVisited; + + S IAstVisitor.VisitUsingAliasDeclaration (UsingAliasDeclaration usingDeclaration, T data) + { + var handler = UsingAliasDeclarationVisited; + if (handler != null) + handler (usingDeclaration, data); + return VisitChildren (usingDeclaration, data); + } + + public event Action ExternAliasDeclarationVisited; + + S IAstVisitor.VisitExternAliasDeclaration (ExternAliasDeclaration externAliasDeclaration, T data) + { + var handler = ExternAliasDeclarationVisited; + if (handler != null) + handler (externAliasDeclaration, data); + return VisitChildren (externAliasDeclaration, data); + } + + public event Action ConstructorDeclarationVisited; + + S IAstVisitor.VisitConstructorDeclaration (ConstructorDeclaration constructorDeclaration, T data) + { + var handler = ConstructorDeclarationVisited; + if (handler != null) + handler (constructorDeclaration, data); + return VisitChildren (constructorDeclaration, data); + } + + public event Action ConstructorInitializerVisited; + + S IAstVisitor.VisitConstructorInitializer (ConstructorInitializer constructorInitializer, T data) + { + var handler = ConstructorInitializerVisited; + if (handler != null) + handler (constructorInitializer, data); + return VisitChildren (constructorInitializer, data); + } + + public event Action DestructorDeclarationVisited; + + S IAstVisitor.VisitDestructorDeclaration (DestructorDeclaration destructorDeclaration, T data) + { + var handler = DestructorDeclarationVisited; + if (handler != null) + handler (destructorDeclaration, data); + return VisitChildren (destructorDeclaration, data); + } + + public event Action EventDeclarationVisited; + + S IAstVisitor.VisitEventDeclaration (EventDeclaration eventDeclaration, T data) + { + var handler = EventDeclarationVisited; + if (handler != null) + handler (eventDeclaration, data); + return VisitChildren (eventDeclaration, data); + } + + public event Action CustomEventDeclarationVisited; + + S IAstVisitor.VisitCustomEventDeclaration (CustomEventDeclaration eventDeclaration, T data) + { + var handler = CustomEventDeclarationVisited; + if (handler != null) + handler (eventDeclaration, data); + return VisitChildren (eventDeclaration, data); + } + + public event Action FieldDeclarationVisited; + + S IAstVisitor.VisitFieldDeclaration (FieldDeclaration fieldDeclaration, T data) + { + var handler = FieldDeclarationVisited; + if (handler != null) + handler (fieldDeclaration, data); + return VisitChildren (fieldDeclaration, data); + } + + public event Action FixedFieldDeclarationVisited; + + S IAstVisitor.VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, T data) + { + var handler = FixedFieldDeclarationVisited; + if (handler != null) + handler (fixedFieldDeclaration, data); + return VisitChildren (fixedFieldDeclaration, data); + } + + public event Action FixedVariableInitializerVisited; + + S IAstVisitor.VisitFixedVariableInitializer (FixedVariableInitializer fixedVariableInitializer, T data) + { + var handler = FixedVariableInitializerVisited; + if (handler != null) + handler (fixedVariableInitializer, data); + return VisitChildren (fixedVariableInitializer, data); + } + + public event Action IndexerDeclarationVisited; + + S IAstVisitor.VisitIndexerDeclaration (IndexerDeclaration indexerDeclaration, T data) + { + var handler = IndexerDeclarationVisited; + if (handler != null) + handler (indexerDeclaration, data); + return VisitChildren (indexerDeclaration, data); + } + + public event Action MethodDeclarationVisited; + + S IAstVisitor.VisitMethodDeclaration (MethodDeclaration methodDeclaration, T data) + { + var handler = MethodDeclarationVisited; + if (handler != null) + handler (methodDeclaration, data); + return VisitChildren (methodDeclaration, data); + } + + public event Action OperatorDeclarationVisited; + + S IAstVisitor.VisitOperatorDeclaration (OperatorDeclaration operatorDeclaration, T data) + { + var handler = OperatorDeclarationVisited; + if (handler != null) + handler (operatorDeclaration, data); + return VisitChildren (operatorDeclaration, data); + } + + public event Action PropertyDeclarationVisited; + + S IAstVisitor.VisitPropertyDeclaration (PropertyDeclaration propertyDeclaration, T data) + { + var handler = PropertyDeclarationVisited; + if (handler != null) + handler (propertyDeclaration, data); + return VisitChildren (propertyDeclaration, data); + } + + public event Action AccessorVisited; + + S IAstVisitor.VisitAccessor (Accessor accessor, T data) + { + var handler = AccessorVisited; + if (handler != null) + handler (accessor, data); + return VisitChildren (accessor, data); + } + + public event Action VariableInitializerVisited; + + S IAstVisitor.VisitVariableInitializer (VariableInitializer variableInitializer, T data) + { + var handler = VariableInitializerVisited; + if (handler != null) + handler (variableInitializer, data); + return VisitChildren (variableInitializer, data); + } + + public event Action ParameterDeclarationVisited; + + S IAstVisitor.VisitParameterDeclaration (ParameterDeclaration parameterDeclaration, T data) + { + var handler = ParameterDeclarationVisited; + if (handler != null) + handler (parameterDeclaration, data); + return VisitChildren (parameterDeclaration, data); + } + + public event Action ConstraintVisited; + + S IAstVisitor.VisitConstraint (Constraint constraint, T data) + { + var handler = ConstraintVisited; + if (handler != null) + handler (constraint, data); + return VisitChildren (constraint, data); + } + + public event Action BlockStatementVisited; + + S IAstVisitor.VisitBlockStatement (BlockStatement blockStatement, T data) + { + var handler = BlockStatementVisited; + if (handler != null) + handler (blockStatement, data); + return VisitChildren (blockStatement, data); + } + + public event Action ExpressionStatementVisited; + + S IAstVisitor.VisitExpressionStatement (ExpressionStatement expressionStatement, T data) + { + var handler = ExpressionStatementVisited; + if (handler != null) + handler (expressionStatement, data); + return VisitChildren (expressionStatement, data); + } + + public event Action BreakStatementVisited; + + S IAstVisitor.VisitBreakStatement (BreakStatement breakStatement, T data) + { + var handler = BreakStatementVisited; + if (handler != null) + handler (breakStatement, data); + return VisitChildren (breakStatement, data); + } + + public event Action CheckedStatementVisited; + + S IAstVisitor.VisitCheckedStatement (CheckedStatement checkedStatement, T data) + { + var handler = CheckedStatementVisited; + if (handler != null) + handler (checkedStatement, data); + return VisitChildren (checkedStatement, data); + } + + public event Action ContinueStatementVisited; + + S IAstVisitor.VisitContinueStatement (ContinueStatement continueStatement, T data) + { + var handler = ContinueStatementVisited; + if (handler != null) + handler (continueStatement, data); + return VisitChildren (continueStatement, data); + } + + public event Action DoWhileStatementVisited; + + S IAstVisitor.VisitDoWhileStatement (DoWhileStatement doWhileStatement, T data) + { + var handler = DoWhileStatementVisited; + if (handler != null) + handler (doWhileStatement, data); + return VisitChildren (doWhileStatement, data); + } + + public event Action EmptyStatementVisited; + + S IAstVisitor.VisitEmptyStatement (EmptyStatement emptyStatement, T data) + { + var handler = EmptyStatementVisited; + if (handler != null) + handler (emptyStatement, data); + return VisitChildren (emptyStatement, data); + } + + public event Action FixedStatementVisited; + + S IAstVisitor.VisitFixedStatement (FixedStatement fixedStatement, T data) + { + var handler = FixedStatementVisited; + if (handler != null) + handler (fixedStatement, data); + return VisitChildren (fixedStatement, data); + } + + public event Action ForeachStatementVisited; + + S IAstVisitor.VisitForeachStatement (ForeachStatement foreachStatement, T data) + { + var handler = ForeachStatementVisited; + if (handler != null) + handler (foreachStatement, data); + return VisitChildren (foreachStatement, data); + } + + public event Action ForStatementVisited; + + S IAstVisitor.VisitForStatement (ForStatement forStatement, T data) + { + var handler = ForStatementVisited; + if (handler != null) + handler (forStatement, data); + return VisitChildren (forStatement, data); + } + + public event Action GotoCaseStatementVisited; + + S IAstVisitor.VisitGotoCaseStatement (GotoCaseStatement gotoCaseStatement, T data) + { + var handler = GotoCaseStatementVisited; + if (handler != null) + handler (gotoCaseStatement, data); + return VisitChildren (gotoCaseStatement, data); + } + + public event Action GotoDefaultStatementVisited; + + S IAstVisitor.VisitGotoDefaultStatement (GotoDefaultStatement gotoDefaultStatement, T data) + { + var handler = GotoDefaultStatementVisited; + if (handler != null) + handler (gotoDefaultStatement, data); + return VisitChildren (gotoDefaultStatement, data); + } + + public event Action GotoStatementVisited; + + S IAstVisitor.VisitGotoStatement (GotoStatement gotoStatement, T data) + { + var handler = GotoStatementVisited; + if (handler != null) + handler (gotoStatement, data); + return VisitChildren (gotoStatement, data); + } + + public event Action IfElseStatementVisited; + + S IAstVisitor.VisitIfElseStatement (IfElseStatement ifElseStatement, T data) + { + var handler = IfElseStatementVisited; + if (handler != null) + handler (ifElseStatement, data); + return VisitChildren (ifElseStatement, data); + } + + public event Action LabelStatementVisited; + + S IAstVisitor.VisitLabelStatement (LabelStatement labelStatement, T data) + { + var handler = LabelStatementVisited; + if (handler != null) + handler (labelStatement, data); + return VisitChildren (labelStatement, data); + } + + public event Action LockStatementVisited; + + S IAstVisitor.VisitLockStatement (LockStatement lockStatement, T data) + { + var handler = LockStatementVisited; + if (handler != null) + handler (lockStatement, data); + return VisitChildren (lockStatement, data); + } + + public event Action ReturnStatementVisited; + + S IAstVisitor.VisitReturnStatement (ReturnStatement returnStatement, T data) + { + var handler = ReturnStatementVisited; + if (handler != null) + handler (returnStatement, data); + return VisitChildren (returnStatement, data); + } + + public event Action SwitchStatementVisited; + + S IAstVisitor.VisitSwitchStatement (SwitchStatement switchStatement, T data) + { + var handler = SwitchStatementVisited; + if (handler != null) + handler (switchStatement, data); + return VisitChildren (switchStatement, data); + } + + public event Action SwitchSectionVisited; + + S IAstVisitor.VisitSwitchSection (SwitchSection switchSection, T data) + { + var handler = SwitchSectionVisited; + if (handler != null) + handler (switchSection, data); + return VisitChildren (switchSection, data); + } + + public event Action CaseLabelVisited; + + S IAstVisitor.VisitCaseLabel (CaseLabel caseLabel, T data) + { + var handler = CaseLabelVisited; + if (handler != null) + handler (caseLabel, data); + return VisitChildren (caseLabel, data); + } + + public event Action ThrowStatementVisited; + + S IAstVisitor.VisitThrowStatement (ThrowStatement throwStatement, T data) + { + var handler = ThrowStatementVisited; + if (handler != null) + handler (throwStatement, data); + return VisitChildren (throwStatement, data); + } + + public event Action TryCatchStatementVisited; + + S IAstVisitor.VisitTryCatchStatement (TryCatchStatement tryCatchStatement, T data) + { + var handler = TryCatchStatementVisited; + if (handler != null) + handler (tryCatchStatement, data); + return VisitChildren (tryCatchStatement, data); + } + + public event Action CatchClauseVisited; + + S IAstVisitor.VisitCatchClause (CatchClause catchClause, T data) + { + var handler = CatchClauseVisited; + if (handler != null) + handler (catchClause, data); + return VisitChildren (catchClause, data); + } + + public event Action UncheckedStatementVisited; + + S IAstVisitor.VisitUncheckedStatement (UncheckedStatement uncheckedStatement, T data) + { + var handler = UncheckedStatementVisited; + if (handler != null) + handler (uncheckedStatement, data); + return VisitChildren (uncheckedStatement, data); + } + + public event Action UnsafeStatementVisited; + + S IAstVisitor.VisitUnsafeStatement (UnsafeStatement unsafeStatement, T data) + { + var handler = UnsafeStatementVisited; + if (handler != null) + handler (unsafeStatement, data); + return VisitChildren (unsafeStatement, data); + } + + public event Action UsingStatementVisited; + + S IAstVisitor.VisitUsingStatement (UsingStatement usingStatement, T data) + { + var handler = UsingStatementVisited; + if (handler != null) + handler (usingStatement, data); + return VisitChildren (usingStatement, data); + } + + public event Action VariableDeclarationStatementVisited; + + S IAstVisitor.VisitVariableDeclarationStatement (VariableDeclarationStatement variableDeclarationStatement, T data) + { + var handler = VariableDeclarationStatementVisited; + if (handler != null) + handler (variableDeclarationStatement, data); + return VisitChildren (variableDeclarationStatement, data); + } + + public event Action WhileStatementVisited; + + S IAstVisitor.VisitWhileStatement (WhileStatement whileStatement, T data) + { + var handler = WhileStatementVisited; + if (handler != null) + handler (whileStatement, data); + return VisitChildren (whileStatement, data); + } + + public event Action YieldBreakStatementVisited; + + S IAstVisitor.VisitYieldBreakStatement (YieldBreakStatement yieldBreakStatement, T data) + { + var handler = YieldBreakStatementVisited; + if (handler != null) + handler (yieldBreakStatement, data); + return VisitChildren (yieldBreakStatement, data); + } + + public event Action YieldReturnStatementVisited; + + S IAstVisitor.VisitYieldReturnStatement (YieldReturnStatement yieldStatement, T data) + { + var handler = YieldReturnStatementVisited; + if (handler != null) + handler (yieldStatement, data); + return VisitChildren (yieldStatement, data); + } + + public event Action AnonymousMethodExpressionVisited; + + S IAstVisitor.VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression, T data) + { + var handler = AnonymousMethodExpressionVisited; + if (handler != null) + handler (anonymousMethodExpression, data); + return VisitChildren (anonymousMethodExpression, data); + } + + public event Action LambdaExpressionVisited; + + S IAstVisitor.VisitLambdaExpression (LambdaExpression lambdaExpression, T data) + { + var handler = LambdaExpressionVisited; + if (handler != null) + handler (lambdaExpression, data); + return VisitChildren (lambdaExpression, data); + } + + public event Action AssignmentExpressionVisited; + + S IAstVisitor.VisitAssignmentExpression (AssignmentExpression assignmentExpression, T data) + { + var handler = AssignmentExpressionVisited; + if (handler != null) + handler (assignmentExpression, data); + return VisitChildren (assignmentExpression, data); + } + + public event Action BaseReferenceExpressionVisited; + + S IAstVisitor.VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression, T data) + { + var handler = BaseReferenceExpressionVisited; + if (handler != null) + handler (baseReferenceExpression, data); + return VisitChildren (baseReferenceExpression, data); + } + + public event Action BinaryOperatorExpressionVisited; + + S IAstVisitor.VisitBinaryOperatorExpression (BinaryOperatorExpression binaryOperatorExpression, T data) + { + var handler = BinaryOperatorExpressionVisited; + if (handler != null) + handler (binaryOperatorExpression, data); + return VisitChildren (binaryOperatorExpression, data); + } + + public event Action CastExpressionVisited; + + S IAstVisitor.VisitCastExpression (CastExpression castExpression, T data) + { + var handler = CastExpressionVisited; + if (handler != null) + handler (castExpression, data); + return VisitChildren (castExpression, data); + } + + public event Action CheckedExpressionVisited; + + S IAstVisitor.VisitCheckedExpression (CheckedExpression checkedExpression, T data) + { + var handler = CheckedExpressionVisited; + if (handler != null) + handler (checkedExpression, data); + return VisitChildren (checkedExpression, data); + } + + public event Action ConditionalExpressionVisited; + + S IAstVisitor.VisitConditionalExpression (ConditionalExpression conditionalExpression, T data) + { + var handler = ConditionalExpressionVisited; + if (handler != null) + handler (conditionalExpression, data); + return VisitChildren (conditionalExpression, data); + } + + public event Action IdentifierExpressionVisited; + + S IAstVisitor.VisitIdentifierExpression (IdentifierExpression identifierExpression, T data) + { + var handler = IdentifierExpressionVisited; + if (handler != null) + handler (identifierExpression, data); + return VisitChildren (identifierExpression, data); + } + + public event Action IndexerExpressionVisited; + + S IAstVisitor.VisitIndexerExpression (IndexerExpression indexerExpression, T data) + { + var handler = IndexerExpressionVisited; + if (handler != null) + handler (indexerExpression, data); + return VisitChildren (indexerExpression, data); + } + + public event Action InvocationExpressionVisited; + + S IAstVisitor.VisitInvocationExpression (InvocationExpression invocationExpression, T data) + { + var handler = InvocationExpressionVisited; + if (handler != null) + handler (invocationExpression, data); + return VisitChildren (invocationExpression, data); + } + + public event Action DirectionExpressionVisited; + + S IAstVisitor.VisitDirectionExpression (DirectionExpression directionExpression, T data) + { + var handler = DirectionExpressionVisited; + if (handler != null) + handler (directionExpression, data); + return VisitChildren (directionExpression, data); + } + + public event Action MemberReferenceExpressionVisited; + + S IAstVisitor.VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression, T data) + { + var handler = MemberReferenceExpressionVisited; + if (handler != null) + handler (memberReferenceExpression, data); + return VisitChildren (memberReferenceExpression, data); + } + + public event Action NullReferenceExpressionVisited; + + S IAstVisitor.VisitNullReferenceExpression (NullReferenceExpression nullReferenceExpression, T data) + { + var handler = NullReferenceExpressionVisited; + if (handler != null) + handler (nullReferenceExpression, data); + return VisitChildren (nullReferenceExpression, data); + } + + public event Action ObjectCreateExpressionVisited; + + S IAstVisitor.VisitObjectCreateExpression (ObjectCreateExpression objectCreateExpression, T data) + { + var handler = ObjectCreateExpressionVisited; + if (handler != null) + handler (objectCreateExpression, data); + return VisitChildren (objectCreateExpression, data); + } + + public event Action AnonymousTypeCreateExpressionVisited; + + S IAstVisitor.VisitAnonymousTypeCreateExpression (AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data) + { + var handler = AnonymousTypeCreateExpressionVisited; + if (handler != null) + handler (anonymousTypeCreateExpression, data); + return VisitChildren (anonymousTypeCreateExpression, data); + } + + public event Action ArrayCreateExpressionVisited; + + S IAstVisitor.VisitArrayCreateExpression (ArrayCreateExpression arraySCreateExpression, T data) + { + var handler = ArrayCreateExpressionVisited; + if (handler != null) + handler (arraySCreateExpression, data); + return VisitChildren (arraySCreateExpression, data); + } + + public event Action ParenthesizedExpressionVisited; + + S IAstVisitor.VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, T data) + { + var handler = ParenthesizedExpressionVisited; + if (handler != null) + handler (parenthesizedExpression, data); + return VisitChildren (parenthesizedExpression, data); + } + + public event Action PointerReferenceExpressionVisited; + + S IAstVisitor.VisitPointerReferenceExpression (PointerReferenceExpression pointerReferenceExpression, T data) + { + var handler = PointerReferenceExpressionVisited; + if (handler != null) + handler (pointerReferenceExpression, data); + return VisitChildren (pointerReferenceExpression, data); + } + + public event Action PrimitiveExpressionVisited; + + S IAstVisitor.VisitPrimitiveExpression (PrimitiveExpression primitiveExpression, T data) + { + var handler = PrimitiveExpressionVisited; + if (handler != null) + handler (primitiveExpression, data); + return VisitChildren (primitiveExpression, data); + } + + public event Action SizeOfExpressionVisited; + + S IAstVisitor.VisitSizeOfExpression (SizeOfExpression sizeOfExpression, T data) + { + var handler = SizeOfExpressionVisited; + if (handler != null) + handler (sizeOfExpression, data); + return VisitChildren (sizeOfExpression, data); + } + + public event Action StackAllocExpressionVisited; + + S IAstVisitor.VisitStackAllocExpression (StackAllocExpression stackAllocExpression, T data) + { + var handler = StackAllocExpressionVisited; + if (handler != null) + handler (stackAllocExpression, data); + return VisitChildren (stackAllocExpression, data); + } + + public event Action ThisReferenceExpressionVisited; + + S IAstVisitor.VisitThisReferenceExpression (ThisReferenceExpression thisReferenceExpression, T data) + { + var handler = ThisReferenceExpressionVisited; + if (handler != null) + handler (thisReferenceExpression, data); + return VisitChildren (thisReferenceExpression, data); + } + + public event Action TypeOfExpressionVisited; + + S IAstVisitor.VisitTypeOfExpression (TypeOfExpression typeOfExpression, T data) + { + var handler = TypeOfExpressionVisited; + if (handler != null) + handler (typeOfExpression, data); + return VisitChildren (typeOfExpression, data); + } + + public event Action TypeReferenceExpressionVisited; + + S IAstVisitor.VisitTypeReferenceExpression (TypeReferenceExpression typeReferenceExpression, T data) + { + var handler = TypeReferenceExpressionVisited; + if (handler != null) + handler (typeReferenceExpression, data); + return VisitChildren (typeReferenceExpression, data); + } + + public event Action UnaryOperatorExpressionVisited; + + S IAstVisitor.VisitUnaryOperatorExpression (UnaryOperatorExpression unaryOperatorExpression, T data) + { + var handler = UnaryOperatorExpressionVisited; + if (handler != null) + handler (unaryOperatorExpression, data); + return VisitChildren (unaryOperatorExpression, data); + } + + public event Action UncheckedExpressionVisited; + + S IAstVisitor.VisitUncheckedExpression (UncheckedExpression uncheckedExpression, T data) + { + var handler = UncheckedExpressionVisited; + if (handler != null) + handler (uncheckedExpression, data); + return VisitChildren (uncheckedExpression, data); + } + + public event Action QueryExpressionVisited; + + S IAstVisitor.VisitQueryExpression (QueryExpression queryExpression, T data) + { + var handler = QueryExpressionVisited; + if (handler != null) + handler (queryExpression, data); + return VisitChildren (queryExpression, data); + } + + public event Action QueryContinuationClauseVisited; + + S IAstVisitor.VisitQueryContinuationClause (QueryContinuationClause queryContinuationClause, T data) + { + var handler = QueryContinuationClauseVisited; + if (handler != null) + handler (queryContinuationClause, data); + return VisitChildren (queryContinuationClause, data); + } + + public event Action QueryFromClauseVisited; + + S IAstVisitor.VisitQueryFromClause (QueryFromClause queryFromClause, T data) + { + var handler = QueryFromClauseVisited; + if (handler != null) + handler (queryFromClause, data); + return VisitChildren (queryFromClause, data); + } + + public event Action QueryLetClauseVisited; + + S IAstVisitor.VisitQueryLetClause (QueryLetClause queryLetClause, T data) + { + var handler = QueryLetClauseVisited; + if (handler != null) + handler (queryLetClause, data); + return VisitChildren (queryLetClause, data); + } + + public event Action QueryWhereClauseVisited; + + S IAstVisitor.VisitQueryWhereClause (QueryWhereClause queryWhereClause, T data) + { + var handler = QueryWhereClauseVisited; + if (handler != null) + handler (queryWhereClause, data); + return VisitChildren (queryWhereClause, data); + } + + public event Action QueryJoinClauseVisited; + + S IAstVisitor.VisitQueryJoinClause (QueryJoinClause queryJoinClause, T data) + { + var handler = QueryJoinClauseVisited; + if (handler != null) + handler (queryJoinClause, data); + return VisitChildren (queryJoinClause, data); + } + + public event Action QueryOrderClauseVisited; + + S IAstVisitor.VisitQueryOrderClause (QueryOrderClause queryOrderClause, T data) + { + var handler = QueryOrderClauseVisited; + if (handler != null) + handler (queryOrderClause, data); + return VisitChildren (queryOrderClause, data); + } + + public event Action QueryOrderingVisited; + + S IAstVisitor.VisitQueryOrdering (QueryOrdering queryOrdering, T data) + { + var handler = QueryOrderingVisited; + if (handler != null) + handler (queryOrdering, data); + return VisitChildren (queryOrdering, data); + } + + public event Action QuerySelectClauseVisited; + + S IAstVisitor.VisitQuerySelectClause (QuerySelectClause querySelectClause, T data) + { + var handler = QuerySelectClauseVisited; + if (handler != null) + handler (querySelectClause, data); + return VisitChildren (querySelectClause, data); + } + + public event Action QueryGroupClauseVisited; + + S IAstVisitor.VisitQueryGroupClause (QueryGroupClause queryGroupClause, T data) + { + var handler = QueryGroupClauseVisited; + if (handler != null) + handler (queryGroupClause, data); + return VisitChildren (queryGroupClause, data); + } + + public event Action AsExpressionVisited; + + S IAstVisitor.VisitAsExpression (AsExpression asExpression, T data) + { + var handler = AsExpressionVisited; + if (handler != null) + handler (asExpression, data); + return VisitChildren (asExpression, data); + } + + public event Action IsExpressionVisited; + + S IAstVisitor.VisitIsExpression (IsExpression isExpression, T data) + { + var handler = IsExpressionVisited; + if (handler != null) + handler (isExpression, data); + return VisitChildren (isExpression, data); + } + + public event Action DefaultValueExpressionVisited; + + S IAstVisitor.VisitDefaultValueExpression (DefaultValueExpression defaultValueExpression, T data) + { + var handler = DefaultValueExpressionVisited; + if (handler != null) + handler (defaultValueExpression, data); + return VisitChildren (defaultValueExpression, data); + } + + public event Action UndocumentedExpressionVisited; + + S IAstVisitor.VisitUndocumentedExpression (UndocumentedExpression undocumentedExpression, T data) + { + var handler = UndocumentedExpressionVisited; + if (handler != null) + handler (undocumentedExpression, data); + return VisitChildren (undocumentedExpression, data); + } + + public event Action ArrayInitializerExpressionVisited; + + S IAstVisitor.VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression, T data) + { + var handler = ArrayInitializerExpressionVisited; + if (handler != null) + handler (arrayInitializerExpression, data); + return VisitChildren (arrayInitializerExpression, data); + } + + public event Action ArraySpecifierVisited; + + S IAstVisitor.VisitArraySpecifier (ArraySpecifier arraySpecifier, T data) + { + var handler = ArraySpecifierVisited; + if (handler != null) + handler (arraySpecifier, data); + return VisitChildren (arraySpecifier, data); + } + + public event Action NamedArgumentExpressionVisited; + + S IAstVisitor.VisitNamedArgumentExpression (NamedArgumentExpression namedArgumentExpression, T data) + { + var handler = NamedArgumentExpressionVisited; + if (handler != null) + handler (namedArgumentExpression, data); + return VisitChildren (namedArgumentExpression, data); + } + + public event Action NamedExpressionVisited; + + S IAstVisitor.VisitNamedExpression (NamedExpression namedExpression, T data) + { + var handler = NamedExpressionVisited; + if (handler != null) + handler (namedExpression, data); + return VisitChildren (namedExpression, data); + } + + public event Action EmptyExpressionVisited; + + S IAstVisitor.VisitEmptyExpression (EmptyExpression emptyExpression, T data) + { + var handler = EmptyExpressionVisited; + if (handler != null) + handler (emptyExpression, data); + return VisitChildren (emptyExpression, data); + } + + S IAstVisitor.VisitPatternPlaceholder (AstNode placeholder, PatternMatching.Pattern pattern, T data) + { + return VisitChildren (placeholder, data); + } + } +} + + diff --git a/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs b/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs index b7475d4ce..fccba4622 100644 --- a/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs +++ b/ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs @@ -31,34 +31,57 @@ namespace ICSharpCode.NRefactory.CSharp public class CSharpProjectContent : IProjectContent { string assemblyName; - Dictionary parsedFiles; + string projectFileName; + string location; + Dictionary unresolvedFiles; List assemblyReferences; + CompilerSettings compilerSettings; public CSharpProjectContent() { - this.assemblyName = string.Empty; - this.parsedFiles = new Dictionary(Platform.FileNameComparer); + this.unresolvedFiles = new Dictionary(Platform.FileNameComparer); this.assemblyReferences = new List(); + this.compilerSettings = new CompilerSettings(); + compilerSettings.Freeze(); } protected CSharpProjectContent(CSharpProjectContent pc) { this.assemblyName = pc.assemblyName; - this.parsedFiles = new Dictionary(pc.parsedFiles, Platform.FileNameComparer); + this.projectFileName = pc.projectFileName; + this.location = pc.location; + this.unresolvedFiles = new Dictionary(pc.unresolvedFiles, Platform.FileNameComparer); this.assemblyReferences = new List(pc.assemblyReferences); + this.compilerSettings = pc.compilerSettings; } - public IEnumerable Files { - get { return parsedFiles.Values; } + public IEnumerable Files { + get { return unresolvedFiles.Values; } } public IEnumerable AssemblyReferences { get { return assemblyReferences; } } + public string ProjectFileName { + get { return projectFileName; } + } + public string AssemblyName { get { return assemblyName; } } + + public string Location { + get { return location; } + } + + public CompilerSettings CompilerSettings { + get { return compilerSettings; } + } + + object IProjectContent.CompilerSettings { + get { return compilerSettings; } + } public IEnumerable AssemblyAttributes { get { @@ -78,10 +101,10 @@ namespace ICSharpCode.NRefactory.CSharp } } - public IParsedFile GetFile(string fileName) + public IUnresolvedFile GetFile(string fileName) { - IParsedFile file; - if (parsedFiles.TryGetValue(fileName, out file)) + IUnresolvedFile file; + if (unresolvedFiles.TryGetValue(fileName, out file)) return file; else return null; @@ -112,7 +135,36 @@ namespace ICSharpCode.NRefactory.CSharp return pc; } + public IProjectContent SetProjectFileName(string newProjectFileName) + { + CSharpProjectContent pc = Clone(); + pc.projectFileName = newProjectFileName; + return pc; + } + + public IProjectContent SetLocation(string newLocation) + { + CSharpProjectContent pc = Clone(); + pc.location = newLocation; + return pc; + } + + public IProjectContent SetCompilerSettings(object compilerSettings) + { + if (!(compilerSettings is CompilerSettings)) + throw new ArgumentException("Settings must be an instance of " + typeof(CompilerSettings).FullName, "compilerSettings"); + CSharpProjectContent pc = Clone(); + pc.compilerSettings = (CompilerSettings)compilerSettings; + pc.compilerSettings.Freeze(); + return pc; + } + public IProjectContent AddAssemblyReferences(IEnumerable references) + { + return AddAssemblyReferences(references.ToArray()); + } + + public IProjectContent AddAssemblyReferences(params IAssemblyReference[] references) { CSharpProjectContent pc = Clone(); pc.assemblyReferences.AddRange(references); @@ -120,13 +172,62 @@ namespace ICSharpCode.NRefactory.CSharp } public IProjectContent RemoveAssemblyReferences(IEnumerable references) + { + return RemoveAssemblyReferences(references.ToArray()); + } + + public IProjectContent RemoveAssemblyReferences(params IAssemblyReference[] references) + { + CSharpProjectContent pc = Clone(); + foreach (var r in references) + pc.assemblyReferences.Remove(r); + return pc; + } + + /// + /// Adds the specified files to the project content. + /// If a file with the same name already exists, updated the existing file. + /// + public IProjectContent AddOrUpdateFiles(IEnumerable newFiles) { CSharpProjectContent pc = Clone(); - pc.assemblyReferences.RemoveAll(r => references.Contains(r)); + foreach (var file in newFiles) { + pc.unresolvedFiles[file.FileName] = file; + } return pc; } - public IProjectContent UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile) + /// + /// Adds the specified files to the project content. + /// If a file with the same name already exists, this method updates the existing file. + /// + public IProjectContent AddOrUpdateFiles(params IUnresolvedFile[] newFiles) + { + return AddOrUpdateFiles((IEnumerable)newFiles); + } + + /// + /// Removes the files with the specified names. + /// + public IProjectContent RemoveFiles(IEnumerable fileNames) + { + CSharpProjectContent pc = Clone(); + foreach (var fileName in fileNames) { + pc.unresolvedFiles.Remove(fileName); + } + return pc; + } + + /// + /// Removes the files with the specified names. + /// + public IProjectContent RemoveFiles(params string[] fileNames) + { + return RemoveFiles((IEnumerable)fileNames); + } + + [Obsolete("Use RemoveFiles/AddOrUpdateFiles instead")] + public IProjectContent UpdateProjectContent(IUnresolvedFile oldFile, IUnresolvedFile newFile) { if (oldFile == null && newFile == null) return this; @@ -136,23 +237,24 @@ namespace ICSharpCode.NRefactory.CSharp } CSharpProjectContent pc = Clone(); if (newFile == null) - pc.parsedFiles.Remove(oldFile.FileName); + pc.unresolvedFiles.Remove(oldFile.FileName); else - pc.parsedFiles[newFile.FileName] = newFile; + pc.unresolvedFiles[newFile.FileName] = newFile; return pc; } - public IProjectContent UpdateProjectContent(IEnumerable oldFiles, IEnumerable newFiles) + [Obsolete("Use RemoveFiles/AddOrUpdateFiles instead")] + public IProjectContent UpdateProjectContent(IEnumerable oldFiles, IEnumerable newFiles) { CSharpProjectContent pc = Clone(); if (oldFiles != null) { foreach (var oldFile in oldFiles) { - pc.parsedFiles.Remove(oldFile.FileName); + pc.unresolvedFiles.Remove(oldFile.FileName); } } if (newFiles != null) { foreach (var newFile in newFiles) { - pc.parsedFiles.Add(newFile.FileName, newFile); + pc.unresolvedFiles.Add(newFile.FileName, newFile); } } return pc; diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index 8f1f98f00..704218dd3 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -1,4 +1,4 @@ -// +// // CSharpCompletionEngine.cs // // Author: @@ -44,9 +44,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion #region Additional input properties public CSharpFormattingOptions FormattingPolicy { get; set; } - + public string EolMarker { get; set; } - + public string IndentString { get; set; } #endregion @@ -55,52 +55,50 @@ namespace ICSharpCode.NRefactory.CSharp.Completion public bool AutoSelect; public string DefaultCompletionString; public bool CloseOnSquareBrackets; - #endregion +#endregion - public CSharpCompletionEngine (IDocument document, ICompletionDataFactory factory, IProjectContent content, CSharpTypeResolveContext ctx, CompilationUnit unit, CSharpParsedFile parsedFile) : base (content, ctx, unit, parsedFile) + public CSharpCompletionEngine(IDocument document, ICompletionContextProvider completionContextProvider, ICompletionDataFactory factory, IProjectContent content, CSharpTypeResolveContext ctx) : base (content, completionContextProvider, ctx) { if (document == null) { - throw new ArgumentNullException ("document"); + throw new ArgumentNullException("document"); } if (factory == null) { - throw new ArgumentNullException ("factory"); + throw new ArgumentNullException("factory"); } this.document = document; this.factory = factory; // Set defaults for additional input properties - this.FormattingPolicy = FormattingOptionsFactory.CreateMono (); + this.FormattingPolicy = FormattingOptionsFactory.CreateMono(); this.EolMarker = Environment.NewLine; this.IndentString = "\t"; } - - public bool TryGetCompletionWord (int offset, out int startPos, out int wordLength) + + 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 != '_') + 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 != '_') + 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; @@ -116,9 +114,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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)); + var text = new HashSet(result.Select(r => r.CompletionText)); result = result.Concat(nonWsResult.Where(r => !text.Contains(r.CompletionText))); } } @@ -128,7 +129,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return Enumerable.Empty(); } - + IEnumerable GenerateNameProposals(AstType type) { if (type is PrimitiveType) { @@ -161,13 +162,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (type is SimpleType) { name = ((SimpleType)type).Identifier; } else if (type is MemberType) { - name = ((SimpleType)type).Identifier; + name = ((MemberType)type).MemberName; } else { yield break; } - + var names = WordParser.BreakWords(name); - + var possibleName = new StringBuilder(); for (int i = 0; i < names.Count; i++) { possibleName.Length = 0; @@ -183,12 +184,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion yield return possibleName.ToString(); } } - + IEnumerable HandleMemberReferenceCompletion(ExpressionResult expr) { if (expr == null) return null; - + // do not complete . (but ..) if (expr.Node is PrimitiveExpression) { var pexpr = (PrimitiveExpression)expr.Node; @@ -196,17 +197,31 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return null; } } - - var resolveResult = ResolveExpression (expr); + var resolveResult = ResolveExpression(expr); if (resolveResult == null) { return null; } if (expr.Node is AstType) { - return CreateTypeAndNamespaceCompletionData(location, resolveResult.Item1, expr.Node, resolveResult.Item2); + // need to look at paren.parent because of "catch (.A" expression + if (expr.Node.Parent != null && expr.Node.Parent.Parent is CatchClause) + return HandleCatchClauseType(expr); + return CreateTypeAndNamespaceCompletionData( + location, + resolveResult.Item1, + expr.Node, + resolveResult.Item2 + ); } - return CreateCompletionData(location, resolveResult.Item1, expr.Node, resolveResult.Item2); + + + return CreateCompletionData( + location, + resolveResult.Item1, + expr.Node, + resolveResult.Item2 + ); } - + bool IsInPreprocessorDirective() { var text = GetMemberTextToCaret().Item1; @@ -214,34 +229,67 @@ namespace ICSharpCode.NRefactory.CSharp.Completion miniLexer.Parse(); return miniLexer.IsInPreprocessorDirective; } - - IEnumerable HandleObjectInitializer(CompilationUnit unit, AstNode n) + + IEnumerable HandleObjectInitializer(SyntaxTree unit, AstNode n) { var p = n.Parent; while (p != null && !(p is ObjectCreateExpression)) { p = p.Parent; } + var parent = (ArrayInitializerExpression)n.Parent; + if (parent.IsSingleElement) + parent = (ArrayInitializerExpression)parent.Parent; if (p != null) { var contextList = new CompletionDataWrapper(this); - var initializerResult = ResolveExpression(p, unit); + var initializerResult = ResolveExpression(p); if (initializerResult != null && initializerResult.Item1.Type.Kind != TypeKind.Unknown) { - + // check 3 cases: + // 1) New initalizer { xpr + // 2) Object initializer { prop = val1, field = val2, xpr + // 3) Array initializer { new Foo (), a, xpr + // in case 1 all object/array initializer options should be given - in the others not. + + AstNode prev = null; + if (parent.Elements.Count > 1) { + prev = parent.Elements.First(); + if (prev is ArrayInitializerExpression && ((ArrayInitializerExpression)prev).IsSingleElement) + prev = ((ArrayInitializerExpression)prev).Elements.FirstOrDefault(); + } + + if (prev != null && !(prev is NamedExpression)) { + AddContextCompletion(contextList, GetState(), n); + // case 3) + return contextList.Result; + } + 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())) { + + if (prev != null && (prev is NamedExpression)) { + // case 2) return contextList.Result; } + + // case 1) + + // check if the object is a list, if not only provide object initalizers + var list = typeof(System.Collections.IList).ToTypeReference().Resolve(Compilation); + if (initializerResult.Item1.Type.Kind != TypeKind.Array && list != null) { + var def = initializerResult.Item1.Type.GetDefinition(); + if (def != null && !def.IsDerivedFrom(list.GetDefinition())) + return contextList.Result; + } + + AddContextCompletion(contextList, GetState(), n); + return contextList.Result; } } return null; } - + IEnumerable MagicKeyCompletion(char completionChar, bool controlSpace) { - ExpressionResult expr; Tuple resolveResult; switch (completionChar) { // Magic key completion @@ -266,11 +314,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return null; case '>': if (!IsInsideDocComment()) { + if (offset > 2 && document.GetCharAt(offset - 2) == '-' && !IsInsideCommentStringOrDirective()) { + return HandleMemberReferenceCompletion(GetExpressionBeforeCursor()); + } 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] == '/') { @@ -285,13 +335,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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; + 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, ""); + document.Insert(offset, "", AnchorMovementType.BeforeInsertion); } } return null; - + // Parameter completion case '(': if (IsInsideCommentStringOrDirective()) { @@ -312,7 +365,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } var methodGroup = invocationResult.Item1 as MethodGroupResolveResult; if (methodGroup != null) { - return CreateParameterCompletion(methodGroup, invocationResult.Item2, invoke.Node, invoke.Unit, 0, controlSpace); + return CreateParameterCompletion( + methodGroup, + invocationResult.Item2, + invoke.Node, + invoke.Unit, + 0, + controlSpace + ); } if (controlSpace) { @@ -326,9 +386,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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); + // completionContext = CompletionWidget.CreateCodeCompletionContext (cpos2); + // int currentParameter2 = MethodParameterDataProvider.GetCurrentParameterIndex (CompletionWidget, completionContext) - 1; + // return CreateParameterCompletion (CreateResolver (), location, ExpressionContext.MethodBody, provider.Methods, currentParameter); break; // Completion on space: @@ -348,7 +408,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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())); @@ -359,15 +419,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion AutoCompleteEmptyMatch = false; return proposeNameList.Result; } -// int tokenIndex = offset; -// string token = GetPreviousToken (ref tokenIndex, false); -// if (result.ExpressionContext == ExpressionContext.ObjectInitializer) { -// resolver = CreateResolver (); -// ExpressionContext exactContext = new NewCSharpExpressionFinder (dom).FindExactContextForObjectInitializer (document, resolver.Unit, Document.FileName, resolver.CallingType); -// IReturnType objectInitializer = ((ExpressionContext.TypeExpressionContext)exactContext).UnresolvedType; -// if (objectInitializer != null && objectInitializer.ArrayDimensions == 0 && objectInitializer.PointerNestingLevel == 0 && (token == "{" || token == ",")) -// return CreateCtrlSpaceCompletionData (completionContext, result); -// } + // int tokenIndex = offset; + // string token = GetPreviousToken (ref tokenIndex, false); + // if (result.ExpressionContext == ExpressionContext.ObjectInitializer) { + // resolver = CreateResolver (); + // ExpressionContext exactContext = new NewCSharpExpressionFinder (dom).FindExactContextForObjectInitializer (document, resolver.Unit, Document.FileName, resolver.CallingType); + // IReturnType objectInitializer = ((ExpressionContext.TypeExpressionContext)exactContext).UnresolvedType; + // 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); @@ -383,7 +443,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (!GetParameterCompletionCommandOffset(out cpos)) { break; } - int currentParameter = GetCurrentParameterIndex(cpos, 0) - 1; + int currentParameter = GetCurrentParameterIndex(cpos - 1, this.offset) - 1; if (currentParameter < 0) { return null; } @@ -397,7 +457,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } methodGroup = invocationResult.Item1 as MethodGroupResolveResult; if (methodGroup != null) { - return CreateParameterCompletion(methodGroup, invocationResult.Item2, invoke.Node, invoke.Unit, currentParameter, controlSpace); + return CreateParameterCompletion( + methodGroup, + invocationResult.Item2, + invoke.Node, + invoke.Unit, + currentParameter, + controlSpace); } return null; case "=": @@ -415,35 +481,38 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } if (resolveResult.Item1.Type.Kind == TypeKind.Enum) { var wrapper = new CompletionDataWrapper(this); - AddContextCompletion(wrapper, resolveResult.Item2, expressionOrVariableDeclaration.Node, expressionOrVariableDeclaration.Unit); + AddContextCompletion( + wrapper, + resolveResult.Item2, + expressionOrVariableDeclaration.Node); AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); AutoCompleteEmptyMatch = false; return wrapper.Result; } -// -// if (resolvedType.FullName == DomReturnType.Bool.FullName) { -// CompletionDataList completionList = new ProjectDomCompletionDataList (); -// CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location); -// completionList.AutoCompleteEmptyMatch = false; -// cdc.Add ("true", "md-keyword"); -// cdc.Add ("false", "md-keyword"); -// resolver.AddAccessibleCodeCompletionData (result.ExpressionContext, cdc); -// return completionList; -// } -// if (resolvedType.ClassType == ClassType.Delegate && token == "=") { -// CompletionDataList completionList = new ProjectDomCompletionDataList (); -// string parameterDefinition = AddDelegateHandlers (completionList, resolvedType); -// string varName = GetPreviousMemberReferenceExpression (tokenIndex); -// completionList.Add (new EventCreationCompletionData (document, varName, resolvedType, null, parameterDefinition, resolver.CallingMember, resolvedType)); -// -// CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location); -// resolver.AddAccessibleCodeCompletionData (result.ExpressionContext, cdc); -// foreach (var data in completionList) { -// if (data is MemberCompletionData) -// ((MemberCompletionData)data).IsDelegateExpected = true; -// } -// return completionList; -// } + // + // if (resolvedType.FullName == DomReturnType.Bool.FullName) { + // CompletionDataList completionList = new ProjectDomCompletionDataList (); + // CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location); + // completionList.AutoCompleteEmptyMatch = false; + // cdc.Add ("true", "md-keyword"); + // cdc.Add ("false", "md-keyword"); + // resolver.AddAccessibleCodeCompletionData (result.ExpressionContext, cdc); + // return completionList; + // } + // if (resolvedType.ClassType == ClassType.Delegate && token == "=") { + // CompletionDataList completionList = new ProjectDomCompletionDataList (); + // string parameterDefinition = AddDelegateHandlers (completionList, resolvedType); + // string varName = GetPreviousMemberReferenceExpression (tokenIndex); + // completionList.Add (new EventCreationCompletionData (document, varName, resolvedType, null, parameterDefinition, resolver.CallingMember, resolvedType)); + // + // CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location); + // resolver.AddAccessibleCodeCompletionData (result.ExpressionContext, cdc); + // foreach (var data in completionList) { + // if (data is MemberCompletionData) + // ((MemberCompletionData)data).IsDelegateExpected = true; + // } + // return completionList; + // } return null; case "+=": case "-=": @@ -453,7 +522,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (expressionOrVariableDeclaration == null) { return null; } - + resolveResult = ResolveExpression(expressionOrVariableDeclaration); if (resolveResult == null) { return null; @@ -474,7 +543,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var wrapper = new CompletionDataWrapper(this); if (currentType != null) { // bool includeProtected = DomType.IncludeProtected (dom, typeFromDatabase, resolver.CallingType); - foreach (var method in currentType.Methods) { + foreach (var method in ctx.CurrentTypeDefinition.Methods) { if (MatchDelegate(delegateType, method) /*&& method.IsAccessibleFrom (dom, resolver.CallingType, resolver.CallingMember, includeProtected) &&*/) { wrapper.AddMember(method); // data.SetText (data.CompletionText + ";"); @@ -482,11 +551,22 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } if (token == "+=") { - string parameterDefinition = AddDelegateHandlers(wrapper, delegateType); + string parameterDefinition = AddDelegateHandlers( + wrapper, + delegateType + ); string varName = GetPreviousMemberReferenceExpression(tokenIndex); - wrapper.Result.Add(factory.CreateEventCreationCompletionData(varName, delegateType, evt, parameterDefinition, currentMember, currentType)); + wrapper.Result.Add( + factory.CreateEventCreationCompletionData( + varName, + delegateType, + evt, + parameterDefinition, + currentMember, + currentType) + ); } - + return wrapper.Result; } return null; @@ -497,8 +577,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (token == "enum") return HandleEnumContext(); var wrapper = new CompletionDataWrapper(this); - - AddTypesAndNamespaces(wrapper, GetState(), null, t => currentType != null && !currentType.ReflectionName.Equals(t.ReflectionName) ? t : null); + + AddTypesAndNamespaces( + wrapper, + GetState(), + null, + t => currentType != null && !currentType.ReflectionName.Equals(t.ReflectionName) ? t : null + ); return wrapper.Result; } return null; @@ -540,38 +625,41 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (currentType != null && currentType.Kind == TypeKind.Enum) { return HandleEnumContext(); } - 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)); + 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; + return HandleCatchClauseType(identifierStart); } } 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 = ";,.[](){}+-*/%^?:&|~!<>="; @@ -581,8 +669,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (!(Char.IsWhiteSpace(prevCh) || allowedChars.IndexOf(prevCh) >= 0)) { return null; } - - // Do not pop up completion on identifier identifier (should be handled by keyword completion). + + // 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") { @@ -593,21 +681,21 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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); } } - + if (identifierStart == null) { var accCtx = HandleAccessorContext(); if (accCtx != null) { @@ -620,8 +708,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (n != null && n.Parent is AnonymousTypeCreateExpression) { AutoSelect = false; } - - // Handle foreach (type name _ + + // Handle foreach (type name _ if (n is IdentifierExpression) { var prev = n.GetPrevNode() as ForeachStatement; if (prev != null && prev.InExpression.IsNull) { @@ -631,18 +719,34 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return null; } - } - // Handle object/enumerable initialzer expressions: "new O () { P$" + // var astResolver = new CSharpAstResolver( + // GetState(), + // identifierStart.Unit, + // CSharpUnresolvedFile + // ); + // + // foreach (var type in CreateFieldAction.GetValidTypes(astResolver, (Expression)n)) { + // if (type.Kind == TypeKind.Delegate) { + // AddDelegateHandlers(contextList, type, false, false); + // AutoSelect = false; + // AutoCompleteEmptyMatch = false; + // } + // } + } + + // 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 invokeResult = ResolveExpression( + invokeParent.Target + ); var mgr = invokeResult != null ? invokeResult.Item1 as MethodGroupResolveResult : null; if (mgr != null) { int idx = 0; @@ -659,24 +763,23 @@ namespace ICSharpCode.NRefactory.CSharp.Completion AutoCompleteEmptyMatch = false; } foreach (var p in method.Parameters) { - contextList.AddVariable(p); + contextList.AddNamedParameterVariable(p); } } idx++; - foreach (var list in mgr.GetExtensionMethods ()) { + foreach (var list in mgr.GetEligibleExtensionMethods (true)) { 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(n.Parent, identifierStart.Unit); + var invokeResult = ResolveExpression(n.Parent); var mgr = invokeResult != null ? invokeResult.Item1 as ResolveResult : null; if (mgr != null) { foreach (var constructor in mgr.Type.GetConstructors ()) { @@ -686,20 +789,24 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } } - + 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); + resolveResult = ResolveExpression(evaluationExpr); if (resolveResult != null && resolveResult.Item1.Type.Kind == TypeKind.Enum) { var wrapper = new CompletionDataWrapper(this); - AddContextCompletion(wrapper, resolveResult.Item2, evaluationExpr, identifierStart.Unit); + AddContextCompletion( + wrapper, + resolveResult.Item2, + evaluationExpr + ); AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); AutoCompleteEmptyMatch = false; return wrapper.Result; @@ -713,6 +820,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return null; } + if (n is ArrayInitializerExpression) { // check for new [] {...} expression -> no need to resolve the type there var parent = n.Parent as ArrayCreateExpression; @@ -720,16 +828,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return DefaultControlSpaceItems(); } - var initalizerResult = ResolveExpression(n.Parent, identifierStart.Unit); + var initalizerResult = ResolveExpression(n.Parent); 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; @@ -762,18 +869,25 @@ namespace ICSharpCode.NRefactory.CSharp.Completion contextList.AddCustom("return"); } if (n is MemberType) { - resolveResult = ResolveExpression(((MemberType)n).Target, identifierStart.Unit); - return CreateTypeAndNamespaceCompletionData(location, resolveResult.Item1, ((MemberType)n).Target, resolveResult.Item2); + resolveResult = ResolveExpression( + ((MemberType)n).Target + ); + 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 (); + 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)); + var astResolver = CompletionContextProvider.GetResolver(csResolver, identifierStart.Unit); + astResolver.ApplyNavigator(new NodeListResolveVisitorNavigator(nodes)); try { csResolver = astResolver.GetResolverStateBefore(n); } catch (Exception) { @@ -796,97 +910,140 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } // identifier has already started with the first letter offset--; - AddContextCompletion(contextList, csResolver, identifierStart.Node, identifierStart.Unit); + AddContextCompletion( + contextList, + csResolver, + identifierStart.Node + ); return contextList.Result; -// if (stub.Parent is BlockStatement) + // if (stub.Parent is BlockStatement) -// result = FindExpression (dom, completionContext, -1); -// if (result == null) -// return null; -// else if (result.ExpressionContext != ExpressionContext.IdentifierExpected) { -// triggerWordLength = 1; -// bool autoSelect = true; -// IType returnType = null; -// if ((prevCh == ',' || prevCh == '(') && GetParameterCompletionCommandOffset (out cpos)) { -// ctx = CompletionWidget.CreateCodeCompletionContext (cpos); -// NRefactoryParameterDataProvider dataProvider = ParameterCompletionCommand (ctx) as NRefactoryParameterDataProvider; -// if (dataProvider != null) { -// int i = dataProvider.GetCurrentParameterIndex (CompletionWidget, ctx) - 1; -// foreach (var method in dataProvider.Methods) { -// if (i < method.Parameters.Count) { -// returnType = dom.GetType (method.Parameters [i].ReturnType); -// autoSelect = returnType == null || returnType.ClassType != ClassType.Delegate; -// break; -// } -// } -// } -// } -// // Bug 677531 - Auto-complete doesn't always highlight generic parameter in method signature -// //if (result.ExpressionContext == ExpressionContext.TypeName) -// // autoSelect = false; -// CompletionDataList dataList = CreateCtrlSpaceCompletionData (completionContext, result); -// AddEnumMembers (dataList, returnType); -// dataList.AutoSelect = autoSelect; -// return dataList; -// } else { -// result = FindExpression (dom, completionContext, 0); -// tokenIndex = offset; -// -// // check foreach case, unfortunately the expression finder is too dumb to handle full type names -// // should be overworked if the expression finder is replaced with a mcs ast based analyzer. -// var possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // starting letter -// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // varname -// -// // read return types to '(' token -// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // varType -// if (possibleForeachToken == ">") { -// while (possibleForeachToken != null && possibleForeachToken != "(") { -// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); -// } -// } else { -// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // ( -// if (possibleForeachToken == ".") -// while (possibleForeachToken != null && possibleForeachToken != "(") -// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); -// } -// possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // foreach -// -// if (possibleForeachToken == "foreach") { -// result.ExpressionContext = ExpressionContext.ForeachInToken; -// } else { -// return null; -// // result.ExpressionContext = ExpressionContext.IdentifierExpected; -// } -// result.Expression = ""; -// result.Region = DomRegion.Empty; -// -// return CreateCtrlSpaceCompletionData (completionContext, result); -// } -// break; + // result = FindExpression (dom, completionContext, -1); + // if (result == null) + // return null; + // else if (result.ExpressionContext != ExpressionContext.IdentifierExpected) { + // triggerWordLength = 1; + // bool autoSelect = true; + // IType returnType = null; + // if ((prevCh == ',' || prevCh == '(') && GetParameterCompletionCommandOffset (out cpos)) { + // ctx = CompletionWidget.CreateCodeCompletionContext (cpos); + // NRefactoryParameterDataProvider dataProvider = ParameterCompletionCommand (ctx) as NRefactoryParameterDataProvider; + // if (dataProvider != null) { + // int i = dataProvider.GetCurrentParameterIndex (CompletionWidget, ctx) - 1; + // foreach (var method in dataProvider.Methods) { + // if (i < method.Parameters.Count) { + // returnType = dom.GetType (method.Parameters [i].ReturnType); + // autoSelect = returnType == null || returnType.ClassType != ClassType.Delegate; + // break; + // } + // } + // } + // } + // // Bug 677531 - Auto-complete doesn't always highlight generic parameter in method signature + // //if (result.ExpressionContext == ExpressionContext.TypeName) + // // autoSelect = false; + // CompletionDataList dataList = CreateCtrlSpaceCompletionData (completionContext, result); + // AddEnumMembers (dataList, returnType); + // dataList.AutoSelect = autoSelect; + // return dataList; + // } else { + // result = FindExpression (dom, completionContext, 0); + // tokenIndex = offset; + // + // // check foreach case, unfortunately the expression finder is too dumb to handle full type names + // // should be overworked if the expression finder is replaced with a mcs ast based analyzer. + // var possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // starting letter + // possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // varname + // + // // read return types to '(' token + // possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // varType + // if (possibleForeachToken == ">") { + // while (possibleForeachToken != null && possibleForeachToken != "(") { + // possibleForeachToken = GetPreviousToken (ref tokenIndex, false); + // } + // } else { + // possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // ( + // if (possibleForeachToken == ".") + // while (possibleForeachToken != null && possibleForeachToken != "(") + // possibleForeachToken = GetPreviousToken (ref tokenIndex, false); + // } + // possibleForeachToken = GetPreviousToken (ref tokenIndex, false); // foreach + // + // if (possibleForeachToken == "foreach") { + // result.ExpressionContext = ExpressionContext.ForeachInToken; + // } else { + // return null; + // // result.ExpressionContext = ExpressionContext.IdentifierExpected; + // } + // result.Expression = ""; + // result.Region = DomRegion.Empty; + // + // return CreateCtrlSpaceCompletionData (completionContext, result); + // } + // break; } return null; } - - string[] validEnumBaseTypes = { "byte", "sbyte", "short", "int", "long", "ushort", "uint", "ulong" }; + + IEnumerable HandleCatchClauseType(ExpressionResult identifierStart) + { + Func typePred = delegate (IType type) { + if (type.GetAllBaseTypes().Any(t => t.ReflectionName == "System.Exception")) + return type; + return null; + }; + if (identifierStart.Node is CatchClause) { + var wrapper = new CompletionDataWrapper(this); + AddTypesAndNamespaces( + wrapper, + GetState(), + identifierStart.Node, + typePred, + m => false + ); + return wrapper.Result; + } + + var resolveResult = ResolveExpression(identifierStart); + return CreateCompletionData( + location, + resolveResult.Item1, + identifierStart.Node, + resolveResult.Item2, + typePred + ); + } + + string[] validEnumBaseTypes = { + "byte", + "sbyte", + "short", + "int", + "long", + "ushort", + "uint", + "ulong" + }; + IEnumerable HandleEnumContext() { - var cu = ParseStub("a", false); - if (cu == null) { + var syntaxTree = ParseStub("a", false); + if (syntaxTree == null) { return null; } - - var curType = cu.GetNodeAt (location); + + var curType = syntaxTree.GetNodeAt(location); if (curType == null || curType.ClassType != ClassType.Enum) { - cu = ParseStub("a {}", false); - var node = cu.GetNodeAt(location); + syntaxTree = ParseStub("a {}", false); + var node = syntaxTree.GetNodeAt(location); if (node != null) { var wrapper = new CompletionDataWrapper(this); AddKeywords(wrapper, validEnumBaseTypes); return wrapper.Result; } } - - var member = cu.GetNodeAt(location); + + var member = syntaxTree.GetNodeAt(location); if (member != null && member.NameToken.EndLocation < location) { return DefaultControlSpaceItems(); } @@ -897,8 +1054,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion { string token; while (null != (token = GetPreviousToken (ref offset, true)) && !IsInsideCommentStringOrDirective ()) { + if (token == "from") { - return true; + return !IsInsideCommentStringOrDirective(offset); } if (token == ";" || token == "{") { return false; @@ -944,18 +1102,21 @@ namespace ICSharpCode.NRefactory.CSharp.Completion xp = GetExpressionAtCursor(); } AstNode node; - CompilationUnit unit; + SyntaxTree unit; Tuple rr; if (xp != null) { node = xp.Node; - rr = ResolveExpression(node, xp.Unit); + rr = ResolveExpression(node); unit = xp.Unit; } else { - unit = ParseStub("a", false); - node = unit.GetNodeAt(location); - rr = ResolveExpression(node, unit); + unit = ParseStub("foo", false); + node = unit.GetNodeAt( + location.Line, + location.Column + 2, + n => n is Expression || n is AstType + ); + rr = ResolveExpression(node); } - if (node is Identifier && node.Parent is ForeachStatement) { var foreachStmt = (ForeachStatement)node.Parent; foreach (var possibleName in GenerateNameProposals (foreachStmt.VariableType)) { @@ -963,12 +1124,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion wrapper.Result.Add(factory.CreateLiteralCompletionData(possibleName.ToString())); } } - + AutoSelect = false; AutoCompleteEmptyMatch = false; return wrapper.Result; } - + if (node is Identifier && node.Parent is ParameterDeclaration) { if (!controlSpace) { return null; @@ -986,15 +1147,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return wrapper.Result; } } - if (Unit != null && (node == null || node is TypeDeclaration)) { - var constructor = Unit.GetNodeAt(location.Line, location.Column - 3); + /* if (Unit != null && (node == null || node is TypeDeclaration)) { + var constructor = Unit.GetNodeAt( + location.Line, + location.Column - 3 + ); if (constructor != null && !constructor.ColonToken.IsNull && constructor.Initializer.IsNull) { 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); @@ -1008,7 +1172,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (csResolver == null) { if (node != null) { csResolver = GetState(); - //var astResolver = new CSharpAstResolver (csResolver, node, xp != null ? xp.Item1 : CSharpParsedFile); + //var astResolver = new CSharpAstResolver (csResolver, node, xp != null ? xp.Item1 : CSharpUnresolvedFile); try { //csResolver = astResolver.GetResolverStateBefore (node); @@ -1021,13 +1185,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion csResolver = GetState(); } } - - AddContextCompletion(wrapper, csResolver, node, unit); + AddContextCompletion(wrapper, csResolver, node); return wrapper.Result; } - void AddContextCompletion(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, CompilationUnit unit) + void AddContextCompletion(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node) { if (state != null && !(node is AstType)) { foreach (var variable in state.LocalVariables) { @@ -1037,16 +1200,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion wrapper.AddVariable(variable); } } - - if (currentMember is IUnresolvedParameterizedMember && !(node is AstType)) { - var param = (IParameterizedMember)currentMember.CreateResolved(ctx); + + if (state.CurrentMember is IParameterizedMember && !(node is AstType)) { + var param = (IParameterizedMember)state.CurrentMember; foreach (var p in param.Parameters) { wrapper.AddVariable(p); } } - if (currentMember is IUnresolvedMethod) { - var method = (IUnresolvedMethod)currentMember; + if (state.CurrentMember is IMethod) { + var method = (IMethod)state.CurrentMember; foreach (var p in method.TypeParameters) { wrapper.AddTypeParameter(p); } @@ -1064,9 +1227,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion wrapper.Result.Add(factory.CreateLiteralCompletionData("global")); if (!(node is AstType)) { - if (currentMember != null) { + if (currentMember != null || node is Expression) { AddKeywords(wrapper, statementStartKeywords); AddKeywords(wrapper, expressionLevelKeywords); + if (node == null || node is TypeDeclaration) + AddKeywords(wrapper, typeLevelKeywords); } else if (currentType != null) { AddKeywords(wrapper, typeLevelKeywords); } else { @@ -1088,15 +1253,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion AddKeywords(wrapper, parameterTypePredecessorKeywords); } } - AddKeywords(wrapper, primitiveTypesKeywords); - if (currentMember != null) { + if (currentMember != null && (node is IdentifierExpression || node is SimpleType) && (node.Parent is ExpressionStatement || node.Parent is ForeachStatement || node.Parent is UsingStatement)) { wrapper.AddCustom("var"); + wrapper.AddCustom("dynamic"); } wrapper.Result.AddRange(factory.CreateCodeTemplateCompletionData()); - if (node != null && node.Role == Roles.Argument) { - var resolved = ResolveExpression(node.Parent, unit); + var resolved = ResolveExpression(node.Parent); var invokeResult = resolved != null ? resolved.Item1 as CSharpInvocationResolveResult : null; if (invokeResult != null) { int argNum = 0; @@ -1113,6 +1277,27 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } + if (node is Expression) { + var root = node; + while (root.Parent != null) + root = root.Parent; + var astResolver = CompletionContextProvider.GetResolver(state, root); + foreach (var type in CreateFieldAction.GetValidTypes(astResolver, (Expression)node)) { + if (type.Kind == TypeKind.Enum) { + AddEnumMembers(wrapper, type, state); + } else if (type.Kind == TypeKind.Delegate) { + AddDelegateHandlers(wrapper, type, true, true); + AutoSelect = false; + AutoCompleteEmptyMatch = false; + } + } + } + + // Add 'this' keyword for first parameter (extension method case) + if (node != null && node.Parent is ParameterDeclaration && + node.Parent.PrevSibling != null && node.Parent.PrevSibling.Role == Roles.LPar) { + wrapper.AddCustom("this"); + } } static bool IsInSwitchContext(AstNode node) @@ -1130,27 +1315,36 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return false; } - void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func typePred = null, Predicate memberPred = null) + void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func typePred = null, Predicate memberPred = null, Action callback = null) { + var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly); if (currentType != null) { - for (var ct = currentType; ct != null; ct = ct.DeclaringTypeDefinition) { + for (var ct = ctx.CurrentTypeDefinition; ct != null; ct = ct.DeclaringTypeDefinition) { foreach (var nestedType in ct.NestedTypes) { string name = nestedType.Name; - if (IsAttributeContext(node) && name.EndsWith("Attribute") && name.Length > "Attribute".Length) + 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); + + var type = typePred(nestedType); + if (type != null) { + var a2 = wrapper.AddType(type, name); + if (a2 != null && callback != null) { + callback(a2, type); + } + } continue; } } if (this.currentMember != null && !(node is AstType)) { var def = ctx.CurrentTypeDefinition ?? Compilation.MainAssembly.GetTypeDefinition(currentType); if (def != null) { + bool isProtectedAllowed = true; foreach (var member in def.GetMembers ()) { if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") { continue; @@ -1161,6 +1355,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (member.IsExplicitInterfaceImplementation) { continue; } + if (!lookup.IsAccessible(member, isProtectedAllowed)) { + continue; + } + if (memberPred == null || memberPred(member)) { wrapper.AddMember(member); } @@ -1176,38 +1374,51 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } } - foreach (var p in currentType.TypeParameters) { - wrapper.AddTypeParameter(p); + if (ctx.CurrentTypeDefinition != null) { + foreach (var p in ctx.CurrentTypeDefinition.TypeParameters) { + wrapper.AddTypeParameter(p); + } } } - var scope = CSharpParsedFile.GetUsingScope(location).Resolve(Compilation); + var scope = ctx.CurrentUsingScope; for (var n = scope; n != null; n = n.Parent) { foreach (var pair in n.UsingAliases) { - wrapper.AddNamespace(pair.Key); + wrapper.AddAlias(pair.Key); } foreach (var u in n.Usings) { foreach (var type in u.Types) { + if (!lookup.IsAccessible(type, false)) + continue; + IType addType = typePred != null ? typePred(type) : type; if (addType != null) { string name = type.Name; if (IsAttributeContext(node) && name.EndsWith("Attribute") && name.Length > "Attribute".Length) { name = name.Substring(0, name.Length - "Attribute".Length); } - wrapper.AddType(addType, name); + var a = wrapper.AddType(addType, name); + if (a != null && callback != null) { + callback(a, type); + } } } } foreach (var type in n.Namespace.Types) { + if (!lookup.IsAccessible(type, false)) + continue; IType addType = typePred != null ? typePred(type) : type; if (addType != null) { - wrapper.AddType(addType, addType.Name); + var a2 = wrapper.AddType(addType, addType.Name); + if (a2 != null && callback != null) { + callback(a2, type); + } } } foreach (var curNs in n.Namespace.ChildNamespaces) { - wrapper.AddNamespace(curNs.Name); + wrapper.AddNamespace(curNs); } } } @@ -1225,8 +1436,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return null; } switch (word) { - case "using": case "namespace": + return null; + case "using": if (currentType != null) { return null; } @@ -1235,65 +1447,65 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return wrapper.Result; case "case": return CreateCaseCompletionData(location); -// case ",": -// case ":": -// if (result.ExpressionContext == ExpressionContext.InheritableType) { -// IType cls = NRefactoryResolver.GetTypeAtCursor (Document.CompilationUnit, Document.FileName, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset)); -// CompletionDataList completionList = new ProjectDomCompletionDataList (); -// List namespaceList = GetUsedNamespaces (); -// var col = new CSharpTextEditorCompletion.CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, null, location); -// bool isInterface = false; -// HashSet baseTypeNames = new HashSet (); -// if (cls != null) { -// baseTypeNames.Add (cls.Name); -// if (cls.ClassType == ClassType.Struct) -// isInterface = true; -// } -// int tokenIndex = offset; -// -// // Search base types " : [Type1, ... ,TypeN,] " -// string token = null; -// do { -// token = GetPreviousToken (ref tokenIndex, false); -// if (string.IsNullOrEmpty (token)) -// break; -// token = token.Trim (); -// if (Char.IsLetterOrDigit (token [0]) || token [0] == '_') { -// IType baseType = dom.SearchType (Document.CompilationUnit, cls, result.Region.Start, token); -// if (baseType != null) { -// if (baseType.ClassType != ClassType.Interface) -// isInterface = true; -// baseTypeNames.Add (baseType.Name); -// } -// } -// } while (token != ":"); -// foreach (object o in dom.GetNamespaceContents (namespaceList, true, true)) { -// IType type = o as IType; -// if (type != null && (type.IsStatic || type.IsSealed || baseTypeNames.Contains (type.Name) || isInterface && type.ClassType != ClassType.Interface)) { -// continue; -// } -// if (o is Namespace && !namespaceList.Any (ns => ns.StartsWith (((Namespace)o).FullName))) -// continue; -// col.Add (o); -// } -// // Add inner classes -// Stack innerStack = new Stack (); -// innerStack.Push (cls); -// while (innerStack.Count > 0) { -// IType curType = innerStack.Pop (); -// if (curType == null) -// continue; -// foreach (IType innerType in curType.InnerTypes) { -// if (innerType != cls) -// // don't add the calling class as possible base type -// col.Add (innerType); -// } -// if (curType.DeclaringType != null) -// innerStack.Push (curType.DeclaringType); -// } -// return completionList; -// } -// break; + // case ",": + // case ":": + // if (result.ExpressionContext == ExpressionContext.InheritableType) { + // IType cls = NRefactoryResolver.GetTypeAtCursor (Document.CompilationUnit, Document.FileName, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset)); + // CompletionDataList completionList = new ProjectDomCompletionDataList (); + // List namespaceList = GetUsedNamespaces (); + // var col = new CSharpTextEditorCompletion.CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, null, location); + // bool isInterface = false; + // HashSet baseTypeNames = new HashSet (); + // if (cls != null) { + // baseTypeNames.Add (cls.Name); + // if (cls.ClassType == ClassType.Struct) + // isInterface = true; + // } + // int tokenIndex = offset; + // + // // Search base types " : [Type1, ... ,TypeN,] " + // string token = null; + // do { + // token = GetPreviousToken (ref tokenIndex, false); + // if (string.IsNullOrEmpty (token)) + // break; + // token = token.Trim (); + // if (Char.IsLetterOrDigit (token [0]) || token [0] == '_') { + // IType baseType = dom.SearchType (Document.CompilationUnit, cls, result.Region.Start, token); + // if (baseType != null) { + // if (baseType.ClassType != ClassType.Interface) + // isInterface = true; + // baseTypeNames.Add (baseType.Name); + // } + // } + // } while (token != ":"); + // foreach (object o in dom.GetNamespaceContents (namespaceList, true, true)) { + // IType type = o as IType; + // if (type != null && (type.IsStatic || type.IsSealed || baseTypeNames.Contains (type.Name) || isInterface && type.ClassType != ClassType.Interface)) { + // continue; + // } + // if (o is Namespace && !namespaceList.Any (ns => ns.StartsWith (((Namespace)o).FullName))) + // continue; + // col.Add (o); + // } + // // Add inner classes + // Stack innerStack = new Stack (); + // innerStack.Push (cls); + // while (innerStack.Count > 0) { + // IType curType = innerStack.Pop (); + // if (curType == null) + // continue; + // foreach (IType innerType in curType.InnerTypes) { + // if (innerType != cls) + // // don't add the calling class as possible base type + // col.Add (innerType); + // } + // if (curType.DeclaringType != null) + // innerStack.Push (curType.DeclaringType); + // } + // return completionList; + // } + // break; case "is": case "as": if (currentType == null) { @@ -1307,7 +1519,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion parent = parent.Parent; } if (parent is VariableDeclarationStatement) { - var resolved = ResolveExpression(parent, isAsExpression.Unit); + var resolved = ResolveExpression(parent); if (resolved != null) { isAsType = resolved.Item1.Type; } @@ -1315,57 +1527,62 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } 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); + 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); -// NRefactoryResolver resolver = CreateResolver (); -// ResolveResult resolveResult = resolver.Resolve (expressionResult, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset)); -// if (resolveResult != null && resolveResult.ResolvedType != null) { -// CompletionDataCollector col = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location); -// IType foundType = null; -// if (word == "as") { -// ExpressionContext exactContext = new NewCSharpExpressionFinder (dom).FindExactContextForAsCompletion (document, Document.CompilationUnit, Document.FileName, resolver.CallingType); -// if (exactContext is ExpressionContext.TypeExpressionContext) { -// foundType = resolver.SearchType (((ExpressionContext.TypeExpressionContext)exactContext).Type); -// AddAsCompletionData (col, foundType); -// } -// } -// -// if (foundType == null) -// foundType = resolver.SearchType (resolveResult.ResolvedType); -// -// if (foundType != null) { -// if (foundType.ClassType == ClassType.Interface) -// foundType = resolver.SearchType (DomReturnType.Object); -// -// foreach (IType type in dom.GetSubclasses (foundType)) { -// if (type.IsSpecialName || type.Name.StartsWith ("<")) -// continue; -// AddAsCompletionData (col, type); -// } -// } -// List namespaceList = GetUsedNamespaces (); -// foreach (object o in dom.GetNamespaceContents (namespaceList, true, true)) { -// if (o is IType) { -// IType type = (IType)o; -// if (type.ClassType != ClassType.Interface || type.IsSpecialName || type.Name.StartsWith ("<")) -// continue; -// // if (foundType != null && !dom.GetInheritanceTree (foundType).Any (x => x.FullName == type.FullName)) -// // continue; -// AddAsCompletionData (col, type); -// continue; -// } -// if (o is Namespace) -// continue; -// col.Add (o); -// } -// return completionList; -// } -// result.ExpressionContext = ExpressionContext.TypeName; -// return CreateCtrlSpaceCompletionData (completionContext, result); -// } + // { + // CompletionDataList completionList = new ProjectDomCompletionDataList (); + // ExpressionResult expressionResult = FindExpression (dom, completionContext, wordStart - document.Caret.Offset); + // NRefactoryResolver resolver = CreateResolver (); + // ResolveResult resolveResult = resolver.Resolve (expressionResult, new TextLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset)); + // if (resolveResult != null && resolveResult.ResolvedType != null) { + // CompletionDataCollector col = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location); + // IType foundType = null; + // if (word == "as") { + // ExpressionContext exactContext = new NewCSharpExpressionFinder (dom).FindExactContextForAsCompletion (document, Document.CompilationUnit, Document.FileName, resolver.CallingType); + // if (exactContext is ExpressionContext.TypeExpressionContext) { + // foundType = resolver.SearchType (((ExpressionContext.TypeExpressionContext)exactContext).Type); + // AddAsCompletionData (col, foundType); + // } + // } + // + // if (foundType == null) + // foundType = resolver.SearchType (resolveResult.ResolvedType); + // + // if (foundType != null) { + // if (foundType.ClassType == ClassType.Interface) + // foundType = resolver.SearchType (DomReturnType.Object); + // + // foreach (IType type in dom.GetSubclasses (foundType)) { + // if (type.IsSpecialName || type.Name.StartsWith ("<")) + // continue; + // AddAsCompletionData (col, type); + // } + // } + // List namespaceList = GetUsedNamespaces (); + // foreach (object o in dom.GetNamespaceContents (namespaceList, true, true)) { + // if (o is IType) { + // IType type = (IType)o; + // if (type.ClassType != ClassType.Interface || type.IsSpecialName || type.Name.StartsWith ("<")) + // continue; + // // if (foundType != null && !dom.GetInheritanceTree (foundType).Any (x => x.FullName == type.FullName)) + // // continue; + // AddAsCompletionData (col, type); + // continue; + // } + // if (o is Namespace) + // continue; + // col.Add (o); + // } + // return completionList; + // } + // result.ExpressionContext = ExpressionContext.TypeName; + // return CreateCtrlSpaceCompletionData (completionContext, result); + // } case "override": // Look for modifiers, in order to find the beginning of the declaration int firstMod = wordStart; @@ -1435,92 +1652,20 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return wrapper.Result; case "new": int j = offset - 4; -// string token = GetPreviousToken (ref j, true); + // string token = GetPreviousToken (ref j, true); 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++; - } - } - } - } + if (expressionOrVariableDeclaration == null) + return null; + var astResolver = CompletionContextProvider.GetResolver(GetState(), expressionOrVariableDeclaration.Unit); + hintType = CreateFieldAction.GetValidTypes( + astResolver, + expressionOrVariableDeclaration.Node as Expression + ) + .FirstOrDefault(); - 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++; - } - } - } - } - - 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(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(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); + return CreateTypeCompletionData(hintType); case "yield": var yieldDataList = new CompletionDataWrapper(this); DefaultCompletionString = "return"; @@ -1529,11 +1674,15 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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); + + AddContextCompletion( + inList, + rr != null ? rr.Item2 : GetState(), + expr.Node + ); return inList.Result; } return null; @@ -1550,11 +1699,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return true; } - + string GetLineIndent(int lineNr) { var line = document.GetLineByNumber(lineNr); - for (int j = offset; j < line.EndOffset; j++) { + for (int j = line.Offset; j < line.EndOffset; j++) { char ch = document.GetCharAt(j); if (!char.IsWhiteSpace(ch)) { return document.GetText(line.Offset, j - line.Offset - 1); @@ -1562,41 +1711,83 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return ""; } - static CSharpAmbience amb = new CSharpAmbience (); - - IEnumerable CreateTypeCompletionData(IType hintType, AstType hintTypeAst) + + static CSharpAmbience amb = new CSharpAmbience(); + + class Category : CompletionCategory + { + public Category(string displayText, string icon) : base (displayText, icon) + { + } + + public override int CompareTo(CompletionCategory other) + { + return 0; + } + } + + IEnumerable CreateTypeCompletionData(IType hintType) { var wrapper = new CompletionDataWrapper(this); var state = GetState(); Func pred = null; + Action typeCallback = null; + var inferredTypesCategory = new Category("Inferred Types", null); + var derivedTypesCategory = new Category("Derived Types", null); + if (hintType != null) { - if (hintType.Kind != TypeKind.Unknown) { - 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 null; + var lookup = new MemberLookup( + ctx.CurrentTypeDefinition, + Compilation.MainAssembly + ); + typeCallback = (data, t) => { + //check if type is in inheritance tree. + if (hintType.GetDefinition() != null && + t.GetDefinition() != null && + t.GetDefinition().IsDerivedFrom(hintType.GetDefinition())) { + data.CompletionCategory = derivedTypesCategory; } + }; + pred = t => { if (t.Kind == TypeKind.Interface && hintType.Kind != TypeKind.Array) { return null; } // check for valid constructors 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))) + 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; + var inferedType = typeInference.FindTypeInBounds( + new [] { t }, + new [] { hintType } + ); + if (inferedType != SpecialType.UnknownType) { + var newType = wrapper.AddType(inferedType, amb.ConvertType(inferedType)); + if (newType != null) { + newType.CompletionCategory = inferredTypesCategory; + } + return null; + } + return t; }; if (!(hintType.Kind == TypeKind.Interface && hintType.Kind != TypeKind.Array)) { DefaultCompletionString = GetShortType(hintType, GetState()); - wrapper.AddType(hintType, DefaultCompletionString); + var hint = wrapper.AddType(hintType, DefaultCompletionString); + if (hint != null) { + hint.CompletionCategory = derivedTypesCategory; + } } if (hintType is ParameterizedType && hintType.TypeParameterCount == 1 && hintType.FullName == "System.Collections.Generic.IEnumerable") { var arg = ((ParameterizedType)hintType).TypeArguments.FirstOrDefault(); @@ -1604,13 +1795,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion wrapper.AddType(array, amb.ConvertType(array)); } } else { - DefaultCompletionString = hintTypeAst.ToString(); - wrapper.AddType(hintType, DefaultCompletionString); + var hint = wrapper.AddType(hintType, DefaultCompletionString); + if (hint != null) { + DefaultCompletionString = hint.DisplayText; + hint.CompletionCategory = derivedTypesCategory; + } } } - AddTypesAndNamespaces(wrapper, state, null, pred, m => false); - if (hintType == null || hintType == SpecialType.UnknownType) + AddTypesAndNamespaces(wrapper, state, null, pred, m => false, typeCallback); + if (hintType == null || hintType == SpecialType.UnknownType) { AddKeywords(wrapper, primitiveTypesKeywords.Where(k => k != "void")); + } + CloseOnSquareBrackets = true; AutoCompleteEmptyMatch = true; return wrapper.Result; @@ -1618,8 +1814,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion IEnumerable GetOverrideCompletionData(IUnresolvedTypeDefinition type, string modifiers) { - var wrapper = new CompletionDataWrapper (this); - var alreadyInserted = new List (); + var wrapper = new CompletionDataWrapper(this); + var alreadyInserted = new List(); //bool addedVirtuals = false; int declarationBegin = offset; @@ -1638,13 +1834,19 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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) { - var wrapper = new CompletionDataWrapper (this); + var wrapper = new CompletionDataWrapper(this); int declarationBegin = offset; int j = declarationBegin; for (int i = 0; i < 3; i++) { @@ -1662,7 +1864,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } - var methods = new List (); + var methods = new List(); foreach (var part in type.Parts) { foreach (var method in part.Methods) { @@ -1676,7 +1878,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } foreach (var method in methods) { - wrapper.Add(factory.CreateNewPartialCompletionData(declarationBegin, method.DeclaringTypeDefinition, method)); + wrapper.Add(factory.CreateNewPartialCompletionData( + declarationBegin, + method.DeclaringTypeDefinition, + method + ) + ); } return wrapper.Result; @@ -1707,7 +1914,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return; } foreach (var m in curType.GetMembers ().Reverse ()) { - if (m.IsSynthetic || curType.Kind != TypeKind.Interface && !m.IsOverridable) { + if (curType.Kind != TypeKind.Interface && !m.IsOverridable) { continue; } // filter out the "Finalize" methods, because finalizers should be done with destructors. @@ -1715,15 +1922,23 @@ namespace ICSharpCode.NRefactory.CSharp.Completion continue; } - var data = factory.CreateNewOverrideCompletionData(declarationBegin, currentType, m); + var data = factory.CreateNewOverrideCompletionData( + declarationBegin, + currentType, + m + ); // check if the member is already implemented - bool foundMember = curType.GetMembers().Any(cm => SignatureComparer.Ordinal.Equals(cm, m) && cm.DeclaringTypeDefinition == curType.GetDefinition()); + bool foundMember = curType.GetMembers().Any(cm => SignatureComparer.Ordinal.Equals( + cm, + m + ) && cm.DeclaringTypeDefinition == curType.GetDefinition() + ); if (foundMember) { continue; } if (alreadyInserted.Any(cm => SignatureComparer.Ordinal.Equals(cm, m))) continue; - alreadyInserted.Add (m); + alreadyInserted.Add(m); data.CompletionCategory = col.GetCompletionCategory(m.DeclaringTypeDefinition); col.Add(data); } @@ -1732,6 +1947,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion static void AddKeywords(CompletionDataWrapper wrapper, IEnumerable keywords) { foreach (string keyword in keywords) { + if (wrapper.Result.Any(data => data.DisplayText == keyword)) + continue; wrapper.AddCustom(keyword); } } @@ -1743,7 +1960,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (result != ".") { result = null; } else { - var names = new List (); + var names = new List(); while (result == ".") { result = GetPreviousToken(ref tokenIndex, false); if (result == "this") { @@ -1768,7 +1985,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return result; } - bool MatchDelegate(IType delegateType, IUnresolvedMethod method) + bool MatchDelegate(IType delegateType, IMethod method) { var delegateMethod = delegateType.GetDelegateInvokeMethod(); if (delegateMethod == null || delegateMethod.Parameters.Count != method.Parameters.Count) { @@ -1776,13 +1993,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } 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)) { return false; } } return true; } - + string AddDelegateHandlers(CompletionDataWrapper completionList, IType delegateType, bool addSemicolon = true, bool addDefault = true) { IMethod delegateMethod = delegateType.GetDelegateInvokeMethod(); @@ -1790,26 +2007,54 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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); - } - var sb = new StringBuilder ("("); - var sbWithoutTypes = new StringBuilder ("("); + var oldDelegate = completionList.Result.FirstOrDefault(cd => cd.DisplayText == "delegate"); + if (oldDelegate != null) + completionList.Result.Remove(oldDelegate); + completionList.AddCustom( + "delegate", + "Creates anonymous delegate.", + "delegate {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString + ); + } + var sb = new StringBuilder("("); + var sbWithoutTypes = new StringBuilder("("); + var state = GetState(); + var builder = new TypeSystemAstBuilder(state); + for (int k = 0; k < delegateMethod.Parameters.Count; k++) { if (k > 0) { sb.Append(", "); sbWithoutTypes.Append(", "); } - var parameterType = delegateMethod.Parameters [k].Type; - sb.Append(GetShortType(parameterType, GetState())); - sb.Append(" "); - sb.Append(delegateMethod.Parameters [k].Name); + var convertedParameter = builder.ConvertParameter (delegateMethod.Parameters [k]); + if (convertedParameter.ParameterModifier == ParameterModifier.Params) + convertedParameter.ParameterModifier = ParameterModifier.None; + sb.Append(convertedParameter.GetText (FormattingPolicy)); 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 ? ";" : "")); + completionList.AddCustom( + "delegate" + sb, + "Creates anonymous delegate.", + "delegate" + sb + " {" + EolMarker + thisLineIndent + IndentString + "|" + delegateEndString + ); + + if (!completionList.Result.Any(data => data.DisplayText == sb.ToString())) { + completionList.AddCustom( + sb.ToString(), + "Creates typed lambda expression.", + sb + " => |" + (addSemicolon ? ";" : "") + ); + } + + if (!delegateMethod.Parameters.Any (p => p.IsOut || p.IsRef) && !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 '(' @@ -1823,7 +2068,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion }*/ return sb.ToString(); } - + bool IsAccessibleFrom(IEntity member, ITypeDefinition calledType, IMember currentMember, bool includeProtected) { if (currentMember == null) { @@ -1838,9 +2083,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } if (member.DeclaringTypeDefinition != null) { if (member.DeclaringTypeDefinition.Kind == TypeKind.Interface) { - return IsAccessibleFrom(member.DeclaringTypeDefinition, calledType, currentMember, includeProtected); + return IsAccessibleFrom( + member.DeclaringTypeDefinition, + calledType, + currentMember, + includeProtected + ); } - + if (member.IsProtected && !(member.DeclaringTypeDefinition.IsProtectedOrInternal && !includeProtected)) { return includeProtected; } @@ -1851,16 +2101,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion bool result = true; // easy case, projects are the same /*// if (type1.ProjectContent == type2.ProjectContent) { -// result = true; -// } else + // result = true; + // } else if (type1.ProjectContent != null) { // maybe type2 hasn't project dom set (may occur in some cases), check if the file is in the project //TODO !! -// result = type1.ProjectContent.Annotation ().GetProjectFile (type2.Region.FileName) != null; + // result = type1.ProjectContent.Annotation ().GetProjectFile (type2.Region.FileName) != null; result = false; } else if (type2.ProjectContent != null) { //TODO!! -// result = type2.ProjectContent.Annotation ().GetProjectFile (type1.Region.FileName) != null; + // result = type2.ProjectContent.Annotation ().GetProjectFile (type1.Region.FileName) != null; result = false; } else { // should never happen ! @@ -1894,24 +2144,20 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } 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) { return null; } - - var hintType = GuessHintType(resolvedNode); - var result = new CompletionDataWrapper (this); + var exprParent = resolvedNode.GetParent(); + var unit = exprParent != null ? exprParent.GetParent() : null; + + var astResolver = unit != null ? CompletionContextProvider.GetResolver(state, unit) : null; + IType hintType = exprParent != null && astResolver != null ? + CreateFieldAction.GetValidTypes(astResolver, exprParent) .FirstOrDefault() : + null; + var result = new CompletionDataWrapper(this); if (resolveResult is NamespaceResolveResult) { var nr = (NamespaceResolveResult)resolveResult; if (!(resolvedNode.Parent is UsingDeclaration || resolvedNode.Parent != null && resolvedNode.Parent.Parent is UsingDeclaration)) { @@ -1927,7 +2173,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } foreach (var ns in nr.Namespace.ChildNamespaces) { - result.AddNamespace(ns.Name); + result.AddNamespace(ns); } } else if (resolveResult is TypeResolveResult) { var type = resolveResult.Type; @@ -1940,7 +2186,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return result.Result; } - + IEnumerable CreateTypeList() { foreach (var cl in Compilation.RootNamespace.Types) { @@ -1948,11 +2194,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } foreach (var ns in Compilation.RootNamespace.ChildNamespaces) { - yield return factory.CreateNamespaceCompletionData(ns.Name); + yield return factory.CreateNamespaceCompletionData(ns); } } - IEnumerable CreateParameterCompletion(MethodGroupResolveResult resolveResult, CSharpResolver state, AstNode invocation, CompilationUnit unit, int parameter, bool controlSpace) + IEnumerable CreateParameterCompletion(MethodGroupResolveResult resolveResult, CSharpResolver state, AstNode invocation, SyntaxTree unit, int parameter, bool controlSpace) { var result = new CompletionDataWrapper(this); var addedEnums = new HashSet(); @@ -1974,9 +2220,28 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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)); + result.Result.Add( + factory.CreateEventCreationCompletionData( + varName, + resolvedType, + null, + parameterDefinition, + currentMember, + currentType) + ); + } + } + + foreach (var method in resolveResult.Methods) { + if (parameter < method.Parameters.Count && method.Parameters [parameter].Type.Kind == TypeKind.Delegate) { + AutoSelect = false; + AutoCompleteEmptyMatch = false; + } + foreach (var p in method.Parameters) { + result.AddNamedParameterVariable(p); } } + if (!controlSpace) { if (addedEnums.Count + addedDelegates.Count == 0) { return Enumerable.Empty(); @@ -1984,7 +2249,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion AutoCompleteEmptyMatch = false; AutoSelect = false; } - AddContextCompletion(result, state, invocation, unit); + AddContextCompletion(result, state, invocation); // resolver.AddAccessibleCodeCompletionData (ExpressionContext.MethodBody, cdc); // if (addedDelegates.Count > 0) { @@ -1998,7 +2263,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion string GetShortType(IType type, CSharpResolver state) { - var builder = new TypeSystemAstBuilder (state); + var builder = new TypeSystemAstBuilder(state); var dt = state.CurrentTypeDefinition; var declaring = type.DeclaringType != null ? type.DeclaringType.GetDefinition() : null; if (declaring != null) { @@ -2020,18 +2285,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return; } 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)); - } - } + completionList.AddEnumMembers(resolvedType, state, typeString); DefaultCompletionString = typeString; } - IEnumerable CreateCompletionData(TextLocation location, ResolveResult resolveResult, AstNode resolvedNode, CSharpResolver state) + IEnumerable CreateCompletionData(TextLocation location, ResolveResult resolveResult, AstNode resolvedNode, CSharpResolver state, Func typePred = null) { if (resolveResult == null /*|| resolveResult.IsError*/) { return null; @@ -2042,20 +2300,32 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var namespaceContents = new CompletionDataWrapper(this); foreach (var cl in nr.Namespace.Types) { - namespaceContents.AddType(cl, cl.Name); + IType addType = typePred != null ? typePred(cl) : cl; + if (addType != null) + namespaceContents.AddType(addType, addType.Name); } foreach (var ns in nr.Namespace.ChildNamespaces) { - namespaceContents.AddNamespace(ns.Name); + namespaceContents.AddNamespace(ns); } return namespaceContents.Result; } IType type = resolveResult.Type; + if (resolvedNode.Parent is PointerReferenceExpression && (type is PointerType)) { + type = ((PointerType)type).ElementType; + } + //var typeDef = resolveResult.Type.GetDefinition(); var result = new CompletionDataWrapper(this); bool includeStaticMembers = false; + var lookup = new MemberLookup( + ctx.CurrentTypeDefinition, + Compilation.MainAssembly + ); + + if (resolveResult is LocalResolveResult) { if (resolvedNode is IdentifierExpression) { var mrr = (LocalResolveResult)resolveResult; @@ -2064,17 +2334,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } if (resolveResult is TypeResolveResult && type.Kind == TypeKind.Enum) { foreach (var field in type.GetFields ()) { + if (!lookup.IsAccessible(field, false)) + continue; result.AddMember(field); } - foreach (var m in type.GetMethods ()) { - 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); @@ -2083,7 +2349,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion includeStaticMembers = mrr.Member.Name == mrr.Type.Name; TypeResolveResult trr; - if (state.IsVariableReferenceWithSameType(resolveResult, ((IdentifierExpression)resolvedNode).Identifier, out trr)) { + if (state.IsVariableReferenceWithSameType( + resolveResult, + ((IdentifierExpression)resolvedNode).Identifier, + out trr + )) { if (currentMember != null && mrr.Member.IsStatic ^ currentMember.IsStatic) { skipNonStaticMembers = true; @@ -2091,18 +2361,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion 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 = ctx.CurrentUsingScope; + for (var n = scope; n != null; n = n.Parent) { foreach (var pair in n.UsingAliases) { if (pair.Key == mrr.Member.Name) { @@ -2175,7 +2440,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (member.IsShadowing) { filteredList.RemoveAll(m => m.Name == member.Name); } - filteredList.Add(member); } @@ -2187,7 +2451,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (resolveResult is TypeResolveResult || includeStaticMembers) { foreach (var nested in type.GetNestedTypes ()) { - result.AddType(nested, nested.Name); + if (!lookup.IsAccessible(nested.GetDefinition(), isProtectedAllowed)) + continue; + IType addType = typePred != null ? typePred(nested) : nested; + if (addType != null) + result.AddType(addType, addType.Name); } } else { @@ -2221,7 +2489,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return result.Result; } - + IEnumerable CreateCaseCompletionData(TextLocation location) { var unit = ParseStub("a: break;"); @@ -2243,7 +2511,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (resolveResult == null || resolveResult.Item1.Type.Kind != TypeKind.Enum) { return null; } - var wrapper = new CompletionDataWrapper (this); + var wrapper = new CompletionDataWrapper(this); AddEnumMembers(wrapper, resolveResult.Item1.Type, resolveResult.Item2); AutoCompleteEmptyMatch = false; return wrapper.Result; @@ -2252,7 +2520,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion #region Parsing methods ExpressionResult GetExpressionBeforeCursor() { - CompilationUnit baseUnit; + SyntaxTree baseUnit; if (currentMember == null) { baseUnit = ParseStub("a", false); var type = baseUnit.GetNodeAt(location); @@ -2266,41 +2534,45 @@ namespace ICSharpCode.NRefactory.CSharp.Completion type = baseUnit.GetNodeAt(location); } if (type != null) { - return new ExpressionResult ((AstNode)type.Target, baseUnit); + return new ExpressionResult((AstNode)type.Target, baseUnit); } } - baseUnit = ParseStub("a()", false); + baseUnit = ParseStub("a", false); var curNode = baseUnit.GetNodeAt(location); - // hack for local variable declaration missing ';' issue - remove that if it works. - if (curNode is EntityDeclaration || baseUnit.GetNodeAt(location) == null) { - baseUnit = ParseStub("a()"); + if (curNode is EntityDeclaration || baseUnit.GetNodeAt(location) == null && baseUnit.GetNodeAt(location) == null) { + baseUnit = ParseStub("a"); curNode = baseUnit.GetNodeAt(location); } - + // Hack for handle object initializer continuation expressions - if (curNode is EntityDeclaration || baseUnit.GetNodeAt(location) == null) { - baseUnit = ParseStub("a()};"); + if (curNode is EntityDeclaration || baseUnit.GetNodeAt(location) == null && baseUnit.GetNodeAt(location) == null) { + baseUnit = ParseStub("a};"); } var mref = baseUnit.GetNodeAt(location); if (currentMember == null && currentType == null) { if (mref != null) { - return new ExpressionResult ((AstNode)mref.Target, baseUnit); + 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) { - mref = invoke.Target as MemberReferenceExpression; + var type = baseUnit.GetNodeAt(location); + if (type != null) { + return new ExpressionResult((AstNode)type.Target, baseUnit); + } + + var pref = baseUnit.GetNodeAt(location); + if (pref != null) { + return new ExpressionResult((AstNode)pref.Target, baseUnit); } } AstNode expr = null; if (mref != null) { - expr = mref.Target.Clone(); - mref.Parent.ReplaceWith(expr); + expr = mref.Target; } else { Expression tref = baseUnit.GetNodeAt(location); MemberType memberType = tref != null ? ((TypeReferenceExpression)tref).Type as MemberType : null; @@ -2315,29 +2587,29 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } else { tref = baseUnit.GetNodeAt(location); if (tref == null) { - tref = new TypeReferenceExpression (memberType.Clone()); + 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 ()); + expr = new TypeReferenceExpression(memberType.Target.Clone()); + expr.AddAnnotation(new ObjectCreateExpression()); } } } } - + if (memberType == null) { return null; } if (expr == null) { - expr = new TypeReferenceExpression (memberType.Target.Clone()); + expr = new TypeReferenceExpression(memberType.Target.Clone()); } tref.ReplaceWith(expr); } exit: - return new ExpressionResult ((AstNode)expr, baseUnit); + return new ExpressionResult((AstNode)expr, baseUnit); } - + ExpressionResult GetExpressionAtCursor() { // TextLocation memberLocation; @@ -2349,55 +2621,76 @@ namespace ICSharpCode.NRefactory.CSharp.Completion // memberLocation = location; // } var baseUnit = ParseStub("a"); - var tmpUnit = baseUnit; - AstNode expr = baseUnit.GetNodeAt(location, n => n is IdentifierExpression || n is MemberReferenceExpression); + 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); // try insertStatement - if (expr == null && baseUnit.GetNodeAt(location.Line, location.Column) != null) { + if (expr == null && baseUnit.GetNodeAt( + location.Line, + location.Column + ) != null) { tmpUnit = baseUnit = ParseStub("a();", false); - expr = baseUnit.GetNodeAt(location.Line, location.Column + 1); + expr = baseUnit.GetNodeAt( + location.Line, + location.Column + 1 + ); } - + if (expr == null) { baseUnit = ParseStub("()"); - expr = baseUnit.GetNodeAt(location.Line, location.Column - 1); + expr = baseUnit.GetNodeAt( + location.Line, + location.Column - 1 + ); if (expr == null) { expr = baseUnit.GetNodeAt(location.Line, location.Column - 1); } } - + if (expr == null) { baseUnit = ParseStub("a", false); - expr = baseUnit.GetNodeAt(location, n => n is IdentifierExpression || n is MemberReferenceExpression || n is CatchClause); + 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 forStmt = node != null ? node.PrevSibling as ForStatement : null; if (forStmt != null && forStmt.EmbeddedStatement.IsNull) { expr = forStmt; - var id = new IdentifierExpression ("stub"); - forStmt.EmbeddedStatement = new BlockStatement () { Statements = { new ExpressionStatement (id) }}; + var id = new IdentifierExpression("stub"); + forStmt.EmbeddedStatement = new BlockStatement() { Statements = { new ExpressionStatement (id) }}; expr = id; baseUnit = tmpUnit; } } 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"); expr = forStmt.VariableNameToken; @@ -2405,26 +2698,38 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } 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); + 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); + 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); + expr = baseUnit.GetNodeAt( + location.Line, + location.Column + ); if (expr != null) { expr = baseUnit.GetNodeAt(location.Line, location.Column) ?? expr; } @@ -2432,53 +2737,51 @@ namespace ICSharpCode.NRefactory.CSharp.Completion expr = baseUnit.GetNodeAt(location.Line, location.Column); } } + if (expr == null) { return null; } - return new ExpressionResult (expr, baseUnit); + return new ExpressionResult(expr, baseUnit); } ExpressionResult GetExpressionAt(int offset) { - var parser = new CSharpParser (); + var parser = new CSharpParser(); string text = this.document.GetText(0, this.offset); - var sb = new StringBuilder (text); + 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 completionUnit = parser.Parse(sb.ToString()); var loc = document.GetLocation(offset); - var expr = completionUnit.GetNodeAt(loc, n => n is Expression || n is VariableDeclarationStatement); + var expr = completionUnit.GetNodeAt( + loc, + n => n is Expression || n is VariableDeclarationStatement + ); if (expr == null) { return null; } - return new ExpressionResult (expr, completionUnit); + return new ExpressionResult(expr, completionUnit); } ExpressionResult GetNewExpressionAt(int offset) { - var parser = new CSharpParser (); + var parser = new CSharpParser(); string text = this.document.GetText(0, this.offset); - var sb = new StringBuilder (text); + 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 completionUnit = parser.Parse(sb.ToString()); var loc = document.GetLocation(offset); var expr = completionUnit.GetNodeAt(loc, n => n is Expression); if (expr == null) { // try without ";" - sb = new StringBuilder (text); + 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(); + completionUnit = parser.Parse(sb.ToString()); loc = document.GetLocation(offset); expr = completionUnit.GetNodeAt(loc, n => n is Expression); @@ -2486,11 +2789,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return null; } } - return new ExpressionResult (expr, completionUnit); + return new ExpressionResult(expr, completionUnit); } - #endregion +#endregion #region Helper methods string GetPreviousToken(ref int i, bool allowLineChange) @@ -2509,7 +2812,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } if (!char.IsLetterOrDigit(c)) { - return new string (c, 1); + return new string(c, 1); } int endOffset = i + 1; @@ -2525,8 +2828,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return document.GetText(i, endOffset - i); } - - #endregion + +#endregion #region Preprocessor @@ -2547,49 +2850,214 @@ namespace ICSharpCode.NRefactory.CSharp.Completion yield return factory.CreateLiteralCompletionData("region"); yield return factory.CreateLiteralCompletionData("endregion"); } - #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" }); + 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" + } + ); + + string GetLastClosingXmlCommentTag() + { + var line = document.GetLineByNumber(location.Line); + + restart: + string lineText = document.GetText(line); + if (!lineText.Trim().StartsWith("///")) + return null; + int startIndex = Math.Min(location.Column - 1, lineText.Length - 1) - 1; + while (startIndex > 0 && lineText [startIndex] != '<') { + --startIndex; + if (lineText [startIndex] == '/') { + // already closed. + startIndex = -1; + break; + } + } + if (startIndex < 0 && line.PreviousLine != null) { + line = line.PreviousLine; + goto restart; + } + + if (startIndex >= 0) { + int endIndex = startIndex; + while (endIndex + 1 < lineText.Length && lineText [endIndex] != '>' && !Char.IsWhiteSpace (lineText [endIndex + 1])) { + endIndex++; + } + string tag = endIndex - startIndex - 1 > 0 ? lineText.Substring( + startIndex + 1, + endIndex - startIndex - 1 + ) : null; + if (!string.IsNullOrEmpty(tag) && commentTags.IndexOf(tag) >= 0) { + return tag; + } + } + return null; + } 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"); + var closingTag = GetLastClosingXmlCommentTag(); + if (closingTag != null) { + yield return factory.CreateLiteralCompletionData( + "/" + closingTag + ">" + ); + } + + 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( + "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 +#endregion #region Keywords - static string[] expressionLevelKeywords = new string [] { "as", "is", "else", "out", "ref", "null", "delegate", "default"}; - static string[] primitiveTypesKeywords = new string [] { "void", "object", "bool", "byte", "sbyte", "char", "short", "int", "long", "ushort", "uint", "ulong", "float", "double", "decimal", "string"}; + static string[] expressionLevelKeywords = new string [] { + "as", + "is", + "else", + "out", + "ref", + "null", + "delegate", + "default" + }; + static string[] primitiveTypesKeywords = new string [] { + "void", + "object", + "bool", + "byte", + "sbyte", + "char", + "short", + "int", + "long", + "ushort", + "uint", + "ulong", + "float", + "double", + "decimal", + "string" + }; static string[] statementStartKeywords = new string [] { "base", "new", "sizeof", "this", "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", "catch" }; static string[] globalLevelKeywords = new string [] { @@ -2608,9 +3076,28 @@ namespace ICSharpCode.NRefactory.CSharp.Completion "operator", "explicit", "implicit", "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 + 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 4bfa2f9d4..85cf16368 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs @@ -51,10 +51,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion #region Input properties public CSharpTypeResolveContext ctx { get; private set; } - public CompilationUnit Unit { get; private set; } - - public CSharpParsedFile CSharpParsedFile { get; private set; } - public IProjectContent ProjectContent { get; private set; } ICompilation compilation; @@ -68,40 +64,36 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } #endregion - protected CSharpCompletionEngineBase (IProjectContent content, CSharpTypeResolveContext ctx, CompilationUnit unit, CSharpParsedFile parsedFile) + protected CSharpCompletionEngineBase(IProjectContent content, ICompletionContextProvider completionContextProvider, CSharpTypeResolveContext ctx) { if (content == null) - throw new ArgumentNullException ("content"); + throw new ArgumentNullException("content"); if (ctx == null) - throw new ArgumentNullException ("ctx"); - if (unit == null) - throw new ArgumentNullException ("unit"); - if (parsedFile == null) - throw new ArgumentNullException ("parsedFile"); + throw new ArgumentNullException("ctx"); + if (completionContextProvider == null) + throw new ArgumentNullException("completionContextProvider"); this.ProjectContent = content; + this.CompletionContextProvider = completionContextProvider; this.ctx = ctx; - this.Unit = unit; - this.CSharpParsedFile = parsedFile; } - public IMemberProvider MemberProvider { + public ICompletionContextProvider CompletionContextProvider { get; - set; + private set; } - protected void SetOffset (int offset) + public void SetOffset (int offset) { Reset (); this.offset = offset; this.location = document.GetLocation (offset); - var provider = MemberProvider ?? new DefaultMemberProvider (this); - provider.GetCurrentMembers (offset, out currentType, out currentMember); + CompletionContextProvider.GetCurrentMembers (offset, out currentType, out currentMember); } - protected bool GetParameterCompletionCommandOffset(out int cpos) + public bool GetParameterCompletionCommandOffset (out int cpos) { // Start calculating the parameter offset from the beginning of the // current member, instead of the beginning of the file. @@ -110,12 +102,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (mem == null || (mem is IType)) { return false; } - int startPos = document.GetOffset(mem.Region.BeginLine, mem.Region.BeginColumn); + int startPos = document.GetOffset (mem.Region.BeginLine, mem.Region.BeginColumn); int parenDepth = 0; int chevronDepth = 0; - Stack indexStack = new Stack(); + Stack indexStack = new Stack (); while (cpos > startPos) { - char c = document.GetCharAt(cpos); + char c = document.GetCharAt (cpos); if (c == ')') { parenDepth++; } @@ -124,14 +116,14 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } if (c == '}') { if (indexStack.Count > 0) { - parenDepth = indexStack.Pop(); + parenDepth = indexStack.Pop (); } else { parenDepth = 0; } chevronDepth = 0; } if (indexStack.Count == 0 && (parenDepth == 0 && c == '(' || chevronDepth == 0 && c == '<')) { - int p = GetCurrentParameterIndex (cpos + 1, startPos); + int p = GetCurrentParameterIndex (startPos, cpos + 1); if (p != -1) { cpos++; return true; @@ -154,94 +146,144 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return false; } - protected int GetCurrentParameterIndex (int offset, int memberStart) + public int GetCurrentParameterIndex (int triggerOffset, int endOffset) { - int cursor = this.offset; - int i = offset; - - if (i > cursor) { - return -1; - } - if (i == cursor) { - return 1; + char lastChar = document.GetCharAt (endOffset - 1); + if (lastChar == '(' || lastChar == '<') { + return 0; } - // 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++; + var parameter = new Stack (); + var bracketStack = new Stack> (); + bool inSingleComment = false, inString = false, inVerbatimString = false, inChar = false, inMultiLineComment = false; + 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) { + break; } + bracketStack.Push (parameter); + parameter = new Stack (); break; - case '\'': - if (!insideString && !insideSingleLineComment && !insideMultiLineComment) { - insideQuote = !insideQuote; + case '[': + case '(': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; } + parameter.Push (0); break; - case '"': - if (!insideQuote && !insideSingleLineComment && !insideMultiLineComment) { - insideString = !insideString; + case '}': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (bracketStack.Count > 0) { + parameter = bracketStack.Pop (); + } else { + return -1; + } + break; + case ']': + case ')': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (parameter.Count > 0) { + parameter.Pop (); + } else { + return -1; + } + break; + case '<': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + parameter.Push (0); + break; + case '>': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (parameter.Count > 0) { + parameter.Pop (); + } + break; + case ',': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (parameter.Count > 0) { + parameter.Push (parameter.Pop () + 1); } break; case '/': - if (!insideQuote && !insideString && !insideMultiLineComment) { - if (document.GetCharAt (i) == '/') { - insideSingleLineComment = true; - } - if (document.GetCharAt (i) == '*') { - insideMultiLineComment = true; - } + if (inString || inChar || inVerbatimString) { + break; + } + if (nextCh == '/') { + i++; + inSingleComment = true; + } + if (nextCh == '*') { + inMultiLineComment = true; } break; case '*': - if (insideMultiLineComment && document.GetCharAt (i) == '/') { - insideMultiLineComment = false; + if (inString || inChar || inVerbatimString || inSingleComment) { + break; + } + if (nextCh == '/') { + i++; + inMultiLineComment = false; + } + break; + case '@': + if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { + break; + } + if (nextCh == '"') { + i++; + inVerbatimString = true; } break; case '\n': case '\r': - insideSingleLineComment = false; - break; - case '{': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) { - bracket++; - indexStack.Push (index); - } + inSingleComment = false; + inString = false; + inChar = false; break; - case '}': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) { - bracket--; - if (indexStack.Count > 0) - index = indexStack.Pop (); + case '\\': + if (inString || inChar) { + i++; } break; - case '(': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) { - parentheses++; + case '"': + if (inSingleComment || inMultiLineComment || inChar) { + break; } - break; - case ')': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment) { - parentheses--; + if (inVerbatimString) { + if (nextCh == '"') { + i++; + break; + } + inVerbatimString = false; + break; } + inString = !inString; break; - case ',': - if (!insideQuote && !insideString && !insideSingleLineComment && !insideMultiLineComment && parentheses == 1 && bracket == 0) { - index++; + case '\'': + if (inSingleComment || inMultiLineComment || inString || inVerbatimString) { + break; } + inChar = !inChar; 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; + } + if (parameter.Count == 0 || bracketStack.Count > 0) { + return -1; + } + + return parameter.Pop() + 1; } #region Context helper methods @@ -309,6 +351,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion IsInString = false; IsInChar = false; IsFistNonWs = true; + IsInPreprocessorDirective = false; break; case '\\': if (IsInString || IsInChar) @@ -340,6 +383,21 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } + + protected bool IsInsideCommentStringOrDirective(int offset) + { + var lexer = new MiniLexer(document.Text); + lexer.Parse(0, offset); + return + lexer.IsInSingleComment || + lexer.IsInString || + lexer.IsInVerbatimString || + lexer.IsInChar || + lexer.IsInMultiLineComment || + lexer.IsInPreprocessorDirective; + } + + protected bool IsInsideCommentStringOrDirective() { var text = GetMemberTextToCaret(); @@ -436,13 +494,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion state.CurrentMember = currentMember; state.CurrentTypeDefinition = currentType; - state.CurrentUsingScope = CSharpParsedFile.GetUsingScope (location); + state.CurrentUsingScope = CSharpUnresolvedFile.GetUsingScope (location); if (state.CurrentMember != null) { var node = Unit.GetNodeAt (location); if (node == null) return state; var navigator = new NodeListResolveVisitorNavigator (new[] { node }); - var visitor = new ResolveVisitor (state, CSharpParsedFile, navigator); + var visitor = new ResolveVisitor (state, CSharpUnresolvedFile, navigator); Unit.AcceptVisitor (visitor, null); try { var newState = visitor.GetResolverStateBefore (node); @@ -597,7 +655,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion wrapper.Append (';'); } - protected CompilationUnit ParseStub(string continuation, bool appendSemicolon = true, string afterContinuation = null) + protected SyntaxTree ParseStub(string continuation, bool appendSemicolon = true, string afterContinuation = null) { var mt = GetMemberTextToCaret(); if (mt == null) { @@ -623,52 +681,29 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (closingBrackets > 0) { wrapper.Append(new string('}', closingBrackets)); } - using (var stream = new System.IO.StringReader (wrapper.ToString ())) { - try { - var parser = new CSharpParser (); - var result = parser.Parse(stream, "stub.cs", memberLocation.Line - 1 - generatedLines); - return result; - } catch (Exception) { - Console.WriteLine("------"); - Console.WriteLine(wrapper); - throw; - } - } + var parser = new CSharpParser (); + foreach (var sym in CompletionContextProvider.ConditionalSymbols) + parser.CompilerSettings.ConditionalSymbols.Add (sym); + parser.InitialLocation = new TextLocation(memberLocation.Line - generatedLines, 1); + var result = parser.Parse(wrapper.ToString ()); + return result; } - string cachedText = null; +// string cachedText = null; protected virtual void Reset () { - cachedText = null; +// cachedText = null; } protected Tuple GetMemberTextToCaret() { - int startOffset; - if (currentMember != null && currentType != null && currentType.Kind != TypeKind.Enum) { - startOffset = document.GetOffset(currentMember.Region.Begin); - } else if (currentType != null) { - startOffset = document.GetOffset(currentType.Region.Begin); - } else { - startOffset = 0; - } - while (startOffset > 0) { - 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, document.GetLocation (startOffset)); + return CompletionContextProvider.GetMemberTextToCaret(offset, currentType, currentMember); } protected ExpressionResult GetInvocationBeforeCursor(bool afterBracket) { - CompilationUnit baseUnit; + SyntaxTree baseUnit; baseUnit = ParseStub("a", false); var section = baseUnit.GetNodeAt(location.Line, location.Column - 2); @@ -723,10 +758,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion public class ExpressionResult { public AstNode Node { get; private set; } - public CompilationUnit Unit { get; private set; } + public SyntaxTree Unit { get; private set; } - public ExpressionResult (AstNode item2, CompilationUnit item3) + public ExpressionResult (AstNode item2, SyntaxTree item3) { this.Node = item2; this.Unit = item3; @@ -740,10 +775,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion protected Tuple ResolveExpression (ExpressionResult tuple) { - return ResolveExpression (tuple.Node, tuple.Unit); + return ResolveExpression (tuple.Node); } - protected Tuple ResolveExpression(AstNode expr, CompilationUnit unit) + protected Tuple ResolveExpression(AstNode expr) { if (expr == null) { return null; @@ -757,12 +792,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion resolveNode = expr; } try { - var ctx = CSharpParsedFile.GetResolver(Compilation, location); - var root = expr.AncestorsAndSelf.FirstOrDefault(n => n is EntityDeclaration || n is CompilationUnit); + var root = expr.AncestorsAndSelf.FirstOrDefault(n => n is EntityDeclaration || n is SyntaxTree); if (root == null) { return null; } - var csResolver = new CSharpAstResolver (ctx, root, CSharpParsedFile); + if (root is Accessor) + root = root.Parent; + var csResolver = CompletionContextProvider.GetResolver (GetState(), root); var result = csResolver.Resolve(resolveNode); var state = csResolver.GetResolverStateBefore(resolveNode); return Tuple.Create(result, state); @@ -773,128 +809,5 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } #endregion - - class DefaultMemberProvider : IMemberProvider - { - CSharpCompletionEngineBase engine; - - - public DefaultMemberProvider (CSharpCompletionEngineBase engine) - { - this.engine = engine; - } - - public void GetCurrentMembers (int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember) - { - //var document = engine.document; - var location = engine.location; - - currentType = null; - - foreach (var type in engine.CSharpParsedFile.TopLevelTypeDefinitions) { - if (type.Region.Begin < location) - currentType = type; - } - currentType = FindInnerType (currentType, location); - - // location is beyond last reported end region, now we need to check, if the end region changed - if (currentType != null && currentType.Region.End < location) { - if (!IsInsideType (currentType, location)) - currentType = null; - } - currentMember = null; - if (currentType != null) { - foreach (var member in currentType.Members) { - if (member.Region.Begin < location && (currentMember == null || currentMember.Region.Begin < member.Region.Begin)) - currentMember = member; - } - } - - // location is beyond last reported end region, now we need to check, if the end region changed - // NOTE: Enums are a special case, there the "last" field needs to be treated as current member - if (currentMember != null && currentMember.Region.End < location && currentType.Kind != TypeKind.Enum) { - if (!IsInsideType (currentMember, location)) - currentMember = null; - } - var stack = GetBracketStack (engine.GetMemberTextToCaret ().Item1); - if (stack.Count == 0) - currentMember = null; - } - - IUnresolvedTypeDefinition FindInnerType (IUnresolvedTypeDefinition parent, TextLocation location) - { - if (parent == null) - return null; - var currentType = parent; - foreach (var type in parent.NestedTypes) { - if (type.Region.Begin < location && location < type.Region.End) - currentType = FindInnerType (type, location); - } - - return currentType; - } - - bool IsInsideType (IUnresolvedEntity currentType, TextLocation location) - { - var document = engine.document; - - int startOffset = document.GetOffset (currentType.Region.Begin); - int endOffset = document.GetOffset (location); - //bool foundEndBracket = false; - - var bracketStack = new Stack (); - - bool isInString = false, isInChar = false; - bool isInLineComment = false, isInBlockComment = false; - - for (int i = startOffset; i < endOffset; i++) { - char ch = document.GetCharAt (i); - switch (ch) { - case '(': - case '[': - case '{': - if (!isInString && !isInChar && !isInLineComment && !isInBlockComment) - bracketStack.Push (ch); - break; - case ')': - case ']': - case '}': - if (!isInString && !isInChar && !isInLineComment && !isInBlockComment) - if (bracketStack.Count > 0) - bracketStack.Pop (); - break; - case '\r': - case '\n': - isInLineComment = false; - break; - case '/': - if (isInBlockComment) { - if (i > 0 && document.GetCharAt (i - 1) == '*') - isInBlockComment = false; - } else if (!isInString && !isInChar && i + 1 < document.TextLength) { - char nextChar = document.GetCharAt (i + 1); - if (nextChar == '/') - isInLineComment = true; - if (!isInLineComment && nextChar == '*') - isInBlockComment = true; - } - break; - case '"': - if (!(isInChar || isInLineComment || isInBlockComment)) - isInString = !isInString; - break; - case '\'': - if (!(isInString || isInLineComment || isInBlockComment)) - isInChar = !isInChar; - break; - default : - break; - } - } - 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 76c266244..721c0f0a8 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs @@ -1,4 +1,4 @@ -// +// // CSharpParameterCompletionEngine.cs // // Author: @@ -39,7 +39,7 @@ 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, ICompletionContextProvider completionContextProvider, IParameterCompletionDataFactory factory, IProjectContent content, CSharpTypeResolveContext ctx) : base (content, completionContextProvider, ctx) { if (document == null) { throw new ArgumentNullException("document"); @@ -53,13 +53,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion public ExpressionResult GetIndexerBeforeCursor() { - CompilationUnit baseUnit; + SyntaxTree baseUnit; if (currentMember == null && currentType == null) { return null; } - if (Unit == null) { - return null; - } baseUnit = ParseStub("x] = a[1"); //var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; @@ -76,13 +73,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion public ExpressionResult GetConstructorInitializerBeforeCursor() { - CompilationUnit baseUnit; + SyntaxTree baseUnit; if (currentMember == null && currentType == null) { return null; } - if (Unit == null) { - return null; - } baseUnit = ParseStub("a) {}", false); var expr = baseUnit.GetNodeAt (location); @@ -94,13 +88,10 @@ namespace ICSharpCode.NRefactory.CSharp.Completion public ExpressionResult GetTypeBeforeCursor() { - CompilationUnit baseUnit; + SyntaxTree baseUnit; if (currentMember == null && currentType == null) { return null; } - if (Unit == null) { - return null; - } baseUnit = ParseStub("x> a"); //var memberLocation = currentMember != null ? currentMember.Region.Begin : currentType.Region.Begin; @@ -113,25 +104,24 @@ namespace ICSharpCode.NRefactory.CSharp.Completion IEnumerable CollectMethods(AstNode resolvedNode, MethodGroupResolveResult resolveResult) { - // var lookup = new MemberLookup (ctx.CurrentTypeDefinition, Compilation.MainAssembly); + var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly); bool onlyStatic = false; - if (resolvedNode is IdentifierExpression && currentMember != null && currentMember.IsStatic) { + if (resolvedNode is IdentifierExpression && currentMember != null && currentMember.IsStatic || resolveResult.TargetResult is TypeResolveResult) { onlyStatic = true; } - foreach (var method in resolveResult.Methods) { if (method.IsConstructor) { continue; } - // if (!lookup.IsAccessible (member, true)) - // continue; + if (!lookup.IsAccessible (method, true)) + continue; if (onlyStatic && !method.IsStatic) { continue; } yield return method; } - foreach (var extMethods in resolveResult.GetExtensionMethods ()) { + foreach (var extMethods in resolveResult.GetEligibleExtensionMethods (true)) { foreach (var method in extMethods) { yield return method; } @@ -172,7 +162,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } } if (invoke.Node is ObjectCreateExpression) { - var createType = ResolveExpression(((ObjectCreateExpression)invoke.Node).Type, invoke.Unit); + var createType = ResolveExpression(((ObjectCreateExpression)invoke.Node).Type); if (createType.Item1.Type.Kind == TypeKind.Unknown) return null; return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), createType.Item1.Type); @@ -235,7 +225,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (GetCurrentParameterIndex(document.GetOffset(invoke.Node.StartLocation), offset) < 0) return null; if (invoke.Node is ObjectCreateExpression) { - var createType = ResolveExpression(((ObjectCreateExpression)invoke.Node).Type, invoke.Unit); + var createType = ResolveExpression(((ObjectCreateExpression)invoke.Node).Type); return factory.CreateConstructorProvider(document.GetOffset(invoke.Node.StartLocation), createType.Item1.Type); } @@ -317,17 +307,12 @@ namespace ICSharpCode.NRefactory.CSharp.Completion List GetUsedNamespaces() { - var scope = CSharpParsedFile.GetUsingScope(location); + var scope = ctx.CurrentUsingScope; var result = new List(); - var resolver = new CSharpResolver(ctx); while (scope != null) { - result.Add(scope.NamespaceName); + result.Add(scope.Namespace.FullName); - foreach (var u in scope.Usings) { - var ns = u.ResolveNamespace(resolver); - if (ns == null) { - continue; - } + foreach (var ns in scope.Usings) { result.Add(ns.FullName); } scope = scope.Parent; @@ -335,144 +320,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return result; } - public int GetCurrentParameterIndex(int triggerOffset, int endOffset) - { - char lastChar = document.GetCharAt(endOffset - 1); - if (lastChar == '(' || lastChar == '<') { - return 0; - } - var parameter = new Stack(); - var bracketStack = new Stack>(); - bool inSingleComment = false, inString = false, inVerbatimString = false, inChar = false, inMultiLineComment = false; - 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) { - break; - } - bracketStack.Push(parameter); - parameter = new Stack(); - break; - case '[': - case '(': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { - break; - } - parameter.Push(0); - break; - case '}': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { - break; - } - if (bracketStack.Count > 0) { - parameter = bracketStack.Pop(); - } else { - return -1; - } - break; - case ']': - case ')': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { - break; - } - if (parameter.Count > 0) { - parameter.Pop(); - } else { - return -1; - } - break; - case '<': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { - break; - } - parameter.Push(0); - break; - case '>': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { - break; - } - if (parameter.Count > 0) { - parameter.Pop(); - } - break; - case ',': - if (inString || inChar || inVerbatimString || inSingleComment || inMultiLineComment) { - break; - } - if (parameter.Count > 0) { - parameter.Push(parameter.Pop() + 1); - } - break; - case '/': - if (inString || inChar || inVerbatimString) { - break; - } - if (nextCh == '/') { - i++; - inSingleComment = true; - } - if (nextCh == '*') { - inMultiLineComment = true; - } - break; - case '*': - if (inString || inChar || inVerbatimString || inSingleComment) { - break; - } - if (nextCh == '/') { - i++; - inMultiLineComment = false; - } - break; - 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; - } - inString = !inString; - break; - case '\'': - if (inSingleComment || inMultiLineComment || inString || inVerbatimString) { - break; - } - inChar = !inChar; - break; - } - } - if (parameter.Count == 0 || bracketStack.Count > 0) { - return -1; - } - return parameter.Pop() + 1; - } + } } diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs b/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs index 48ae77269..5455faa85 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using ICSharpCode.NRefactory.Completion; using ICSharpCode.NRefactory.TypeSystem; using System.Linq; +using ICSharpCode.NRefactory.CSharp.Resolver; namespace ICSharpCode.NRefactory.CSharp.Completion { @@ -35,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion { CSharpCompletionEngine completion; List result = new List (); - + public List Result { get { return result; @@ -47,119 +48,109 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return completion.factory; } } - + public CompletionDataWrapper (CSharpCompletionEngine completion) { this.completion = completion; } - + public void Add (ICompletionData data) { result.Add (data); } + public void AddCustom (string displayText, string description = null, string completionText = null) { result.Add (Factory.CreateLiteralCompletionData (displayText, description, completionText)); } - + HashSet usedNamespaces = new HashSet (); - - public void AddNamespace (string name) + + public void AddNamespace (INamespace ns) { - if (string.IsNullOrEmpty (name) || usedNamespaces.Contains (name)) + if (usedNamespaces.Contains (ns.Name)) return; - usedNamespaces.Add (name); - result.Add (Factory.CreateNamespaceCompletionData (name)); + usedNamespaces.Add (ns.Name); + result.Add (Factory.CreateNamespaceCompletionData (ns)); } - - HashSet usedTypes = new HashSet (); - public void AddType (IType type, string shortType) + public void AddAlias(string alias) { - if (type == null || string.IsNullOrEmpty (shortType) || usedTypes.Contains (shortType)) - return; - usedTypes.Add (shortType); - result.Add (Factory.CreateTypeCompletionData (type, shortType)); + result.Add (Factory.CreateLiteralCompletionData (alias)); } - - public void AddType (IUnresolvedTypeDefinition type, string shortType) + + + HashSet usedTypes = new HashSet (); + + public ICompletionData AddType(IType type, string shortType) { - if (type == null || string.IsNullOrEmpty (shortType) || usedTypes.Contains (shortType)) - return; - usedTypes.Add (shortType); - result.Add (Factory.CreateTypeCompletionData (type, shortType)); + if (type == null || string.IsNullOrEmpty(shortType) || usedTypes.Contains(shortType)) + return null; + if (type.Name == "Void" && type.Namespace == "System") + return null; + + var def = type.GetDefinition (); + if (def != null && def.ParentAssembly != completion.ctx.CurrentAssembly && !def.IsBrowsable ()) + return null; + + usedTypes.Add(shortType); + var iCompletionData = Factory.CreateTypeCompletionData(type, shortType); + result.Add(iCompletionData); + return iCompletionData; } - + Dictionary> data = new Dictionary> (); - - public void AddVariable (IVariable variable) + + public ICompletionData AddVariable(IVariable variable) { - if (data.ContainsKey (variable.Name)) - return; - data [variable.Name] = new List (); - result.Add (Factory.CreateVariableCompletionData (variable)); + if (data.ContainsKey(variable.Name)) + return null; + data [variable.Name] = new List(); + var cd = Factory.CreateVariableCompletionData(variable); + result.Add(cd); + return cd; } + + public ICompletionData AddNamedParameterVariable(IVariable variable) + { + var name = variable.Name + ":"; + if (data.ContainsKey(name)) + return null; + data [name] = new List(); - public void AddTypeParameter (IUnresolvedTypeParameter variable) + var cd = Factory.CreateVariableCompletionData(variable); + cd.CompletionText += ":"; + cd.DisplayText += ":"; + result.Add(cd); + return cd; + } + + public void AddTypeParameter (ITypeParameter variable) { if (data.ContainsKey (variable.Name)) return; data [variable.Name] = new List (); result.Add (Factory.CreateVariableCompletionData (variable)); } - - public ICompletionData AddMember (IUnresolvedMember member) - { - var newData = Factory.CreateEntityCompletionData (member); - -// newData.HideExtensionParameter = HideExtensionParameter; - string memberKey = newData.DisplayText; - if (memberKey == null) - return null; - if (member is IMember) { - newData.CompletionCategory = GetCompletionCategory (member.DeclaringTypeDefinition.Resolve (completion.ctx)); - } - List existingData; - data.TryGetValue (memberKey, out existingData); - - if (existingData != null) { - var a = member as IEntity; - foreach (var d in existingData) { - if (!(d is IEntityCompletionData)) - continue; - var b = ((IEntityCompletionData)d).Entity; - if (a == null || b == null || a.EntityType == b.EntityType) { - d.AddOverload (newData); - return d; - } - } - if (newData != null) { - result.Add (newData); - data [memberKey].Add (newData); - } - } else { - result.Add (newData); - data [memberKey] = new List (); - data [memberKey].Add (newData); - } - return newData; - } - + public ICompletionData AddMember (IMember member) { var newData = Factory.CreateEntityCompletionData (member); -// newData.HideExtensionParameter = HideExtensionParameter; + if (member.ParentAssembly != completion.ctx.CurrentAssembly && !member.IsBrowsable ()) + return null; + string memberKey = newData.DisplayText; if (memberKey == null) return null; + if (member is IMember) { newData.CompletionCategory = GetCompletionCategory (member.DeclaringTypeDefinition); } List existingData; data.TryGetValue (memberKey, out existingData); - + if (existingData != null) { var a = member as IEntity; foreach (var d in existingData) { @@ -182,7 +173,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion } return newData; } - + internal CompletionCategory GetCompletionCategory (IType type) { if (type == null) @@ -191,7 +182,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion completionCategories [type] = new TypeCompletionCategory (type); return completionCategories [type]; } - + Dictionary completionCategories = new Dictionary (); class TypeCompletionCategory : CompletionCategory { @@ -210,15 +201,34 @@ namespace ICSharpCode.NRefactory.CSharp.Completion var compareCategory = other as TypeCompletionCategory; if (compareCategory == null) return -1; - + if (Type.ReflectionName == compareCategory.Type.ReflectionName) return 0; - + if (Type.GetAllBaseTypes ().Any (t => t.ReflectionName == compareCategory.Type.ReflectionName)) return -1; return 1; } } + HashSet addedEnums = new HashSet (); + public void AddEnumMembers (IType resolvedType, CSharpResolver state, string typeString) + { + if (addedEnums.Contains (resolvedType)) + return; + addedEnums.Add (resolvedType); + if (typeString.Contains(".")) { + AddType(resolvedType, typeString); + } + foreach (var field in resolvedType.GetFields ()) { + if (field.IsPublic && (field.IsConst || field.IsStatic)) { + Result.Add(Factory.CreateEntityCompletionData( + field, + typeString + "." + field.Name + ) + ); + } + } + } } } diff --git a/ICSharpCode.NRefactory.CSharp/Completion/ICompletionContextProvider.cs b/ICSharpCode.NRefactory.CSharp/Completion/ICompletionContextProvider.cs new file mode 100644 index 000000000..c590007fb --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Completion/ICompletionContextProvider.cs @@ -0,0 +1,213 @@ +// +// IMemberProvider.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2012 Xamarin Inc. +// +// 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; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.Editor; +using ICSharpCode.NRefactory.CSharp.TypeSystem; +using System.Linq; +using ICSharpCode.NRefactory.CSharp.Resolver; + +namespace ICSharpCode.NRefactory.CSharp.Completion +{ + public interface ICompletionContextProvider + { + IList ConditionalSymbols { + get; + } + + void GetCurrentMembers (int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember); + + Tuple GetMemberTextToCaret(int caretOffset, IUnresolvedTypeDefinition currentType, IUnresolvedMember currentMember); + + CSharpAstResolver GetResolver (CSharpResolver resolver, AstNode rootNode); + } + + public class DefaultCompletionContextProvider : ICompletionContextProvider + { + readonly IDocument document; + readonly CSharpUnresolvedFile unresolvedFile; + readonly List symbols = new List (); + + public IList ConditionalSymbols { + get { + return symbols; + } + } + + public DefaultCompletionContextProvider (IDocument document, CSharpUnresolvedFile unresolvedFile) + { + if (document == null) + throw new ArgumentNullException("document"); + if (unresolvedFile == null) + throw new ArgumentNullException("unresolvedFile"); + this.document = document; + this.unresolvedFile = unresolvedFile; + } + + public void AddSymbol (string sym) + { + symbols.Add (sym); + } + public void GetCurrentMembers(int offset, out IUnresolvedTypeDefinition currentType, out IUnresolvedMember currentMember) + { + //var document = engine.document; + var location = document.GetLocation(offset); + + currentType = null; + + foreach (var type in unresolvedFile.TopLevelTypeDefinitions) { + if (type.Region.Begin < location) + currentType = type; + } + currentType = FindInnerType (currentType, location); + + // location is beyond last reported end region, now we need to check, if the end region changed + if (currentType != null && currentType.Region.End < location) { + if (!IsInsideType (currentType, location)) + currentType = null; + } + currentMember = null; + if (currentType != null) { + foreach (var member in currentType.Members) { + if (member.Region.Begin < location && (currentMember == null || currentMember.Region.Begin < member.Region.Begin)) + currentMember = member; + } + } + + // location is beyond last reported end region, now we need to check, if the end region changed + // NOTE: Enums are a special case, there the "last" field needs to be treated as current member + if (currentMember != null && currentMember.Region.End < location && currentType.Kind != TypeKind.Enum) { + if (!IsInsideType (currentMember, location)) + currentMember = null; + }/* + var stack = GetBracketStack (engine.GetMemberTextToCaret ().Item1); + if (stack.Count == 0) + currentMember = null;*/ + } + + IUnresolvedTypeDefinition FindInnerType (IUnresolvedTypeDefinition parent, TextLocation location) + { + if (parent == null) + return null; + var currentType = parent; + foreach (var type in parent.NestedTypes) { + if (type.Region.Begin < location && location < type.Region.End) + currentType = FindInnerType (type, location); + } + + return currentType; + } + + bool IsInsideType (IUnresolvedEntity currentType, TextLocation location) + { + int startOffset = document.GetOffset (currentType.Region.Begin); + int endOffset = document.GetOffset (location); + //bool foundEndBracket = false; + + var bracketStack = new Stack (); + + bool isInString = false, isInChar = false; + bool isInLineComment = false, isInBlockComment = false; + + for (int i = startOffset; i < endOffset; i++) { + char ch = document.GetCharAt (i); + switch (ch) { + case '(': + case '[': + case '{': + if (!isInString && !isInChar && !isInLineComment && !isInBlockComment) + bracketStack.Push (ch); + break; + case ')': + case ']': + case '}': + if (!isInString && !isInChar && !isInLineComment && !isInBlockComment) + if (bracketStack.Count > 0) + bracketStack.Pop (); + break; + case '\r': + case '\n': + isInLineComment = false; + break; + case '/': + if (isInBlockComment) { + if (i > 0 && document.GetCharAt (i - 1) == '*') + isInBlockComment = false; + } else if (!isInString && !isInChar && i + 1 < document.TextLength) { + char nextChar = document.GetCharAt (i + 1); + if (nextChar == '/') + isInLineComment = true; + if (!isInLineComment && nextChar == '*') + isInBlockComment = true; + } + break; + case '"': + if (!(isInChar || isInLineComment || isInBlockComment)) + isInString = !isInString; + break; + case '\'': + if (!(isInString || isInLineComment || isInBlockComment)) + isInChar = !isInChar; + break; + default : + break; + } + } + return bracketStack.Any (t => t == '{'); + } + + public Tuple GetMemberTextToCaret(int caretOffset, IUnresolvedTypeDefinition currentType, IUnresolvedMember currentMember) + { + int startOffset; + if (currentMember != null && currentType != null && currentType.Kind != TypeKind.Enum) { + startOffset = document.GetOffset(currentMember.Region.Begin); + } else if (currentType != null) { + startOffset = document.GetOffset(currentType.Region.Begin); + } else { + startOffset = 0; + } + while (startOffset > 0) { + char ch = document.GetCharAt(startOffset - 1); + if (ch != ' ' && ch != '\t') { + break; + } + --startOffset; + } + + return Tuple.Create (document.GetText (startOffset, caretOffset - startOffset), document.GetLocation (startOffset)); + } + + + public CSharpAstResolver GetResolver (CSharpResolver resolver, AstNode rootNode) + { + return new CSharpAstResolver (resolver, rootNode, unresolvedFile); + } + + + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Completion/ICompletionDataFactory.cs b/ICSharpCode.NRefactory.CSharp/Completion/ICompletionDataFactory.cs index fe367f4eb..95309db44 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/ICompletionDataFactory.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/ICompletionDataFactory.cs @@ -32,14 +32,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion { public interface ICompletionDataFactory { - ICompletionData CreateEntityCompletionData (IUnresolvedEntity entity); - ICompletionData CreateEntityCompletionData (IUnresolvedEntity entity, string text); ICompletionData CreateEntityCompletionData (IEntity entity); ICompletionData CreateEntityCompletionData (IEntity entity, string text); ICompletionData CreateTypeCompletionData (IType type, string shortType); - ICompletionData CreateTypeCompletionData (IUnresolvedTypeDefinition type, string shortType); - + /// /// Creates a generic completion data. /// @@ -54,11 +51,11 @@ namespace ICSharpCode.NRefactory.CSharp.Completion /// ICompletionData CreateLiteralCompletionData (string title, string description = null, string insertText = null); - ICompletionData CreateNamespaceCompletionData (string name); + ICompletionData CreateNamespaceCompletionData (INamespace name); ICompletionData CreateVariableCompletionData (IVariable variable); - ICompletionData CreateVariableCompletionData (IUnresolvedTypeParameter parameter); + ICompletionData CreateVariableCompletionData (ITypeParameter parameter); ICompletionData CreateEventCreationCompletionData (string varName, IType delegateType, IEvent evt, string parameterDefinition, IUnresolvedMember currentMember, IUnresolvedTypeDefinition currentType); diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs index a47de8058..8a12bc84a 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs @@ -1,4 +1,4 @@ -// +// // AstFormattingVisitor.cs // // Author: @@ -97,6 +97,11 @@ namespace ICSharpCode.NRefactory.CSharp get; set; } + + public DomRegion FormattingRegion { + get; + set; + } public AstFormattingVisitor(CSharpFormattingOptions policy, IDocument document, TextEditorOptions options = null) { @@ -111,6 +116,22 @@ namespace ICSharpCode.NRefactory.CSharp this.options = options ?? TextEditorOptions.Default; curIndent = new Indent(this.options); } + + protected override void VisitChildren (AstNode node) + { + if (!FormattingRegion.IsEmpty) { + if (node.EndLocation < FormattingRegion.Begin || node.StartLocation > FormattingRegion.End) + return; + } + + 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); + } + } /// /// Applies the changes to the input document. @@ -152,10 +173,10 @@ namespace ICSharpCode.NRefactory.CSharp } if (change.Offset < previousChange.Offset + previousChange.RemovalLength) { #if DEBUG - Console.WriteLine ("change 1:" + change); + Console.WriteLine ("change 1:" + change + " at " + document.GetLocation (change.Offset)); Console.WriteLine (change.StackTrace); - Console.WriteLine ("change 2:" + change); + Console.WriteLine ("change 2:" + previousChange + " at " + document.GetLocation (previousChange.Offset)); Console.WriteLine (previousChange.StackTrace); #endif throw new InvalidOperationException ("Detected overlapping changes " + change + "/" + previousChange); @@ -178,9 +199,9 @@ namespace ICSharpCode.NRefactory.CSharp changes.Clear(); } - public override void VisitCompilationUnit(CompilationUnit unit) + public override void VisitSyntaxTree(SyntaxTree unit) { - base.VisitCompilationUnit(unit); + base.VisitSyntaxTree(unit); } public void EnsureBlankLinesAfter(AstNode node, int blankLines) @@ -228,26 +249,32 @@ namespace ICSharpCode.NRefactory.CSharp for (int i = 0; i < blankLines; i++) { sb.Append(this.options.EolMarker); } + if (end - start == 0 && sb.Length == 0) + return; AddChange(start, end - start, sb.ToString()); } public override void VisitUsingDeclaration(UsingDeclaration usingDeclaration) { - if (!(usingDeclaration.PrevSibling is UsingDeclaration || usingDeclaration.PrevSibling is UsingAliasDeclaration)) { + if (usingDeclaration.PrevSibling != null && !(usingDeclaration.PrevSibling is UsingDeclaration || usingDeclaration.PrevSibling is UsingAliasDeclaration)) { EnsureBlankLinesBefore(usingDeclaration, policy.BlankLinesBeforeUsings); - } - if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling is UsingAliasDeclaration)) { + } else if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling is UsingAliasDeclaration)) { + FixIndentationForceNewLine(usingDeclaration.StartLocation); EnsureBlankLinesAfter(usingDeclaration, policy.BlankLinesAfterUsings); + } else { + FixIndentationForceNewLine(usingDeclaration.StartLocation); } } public override void VisitUsingAliasDeclaration(UsingAliasDeclaration usingDeclaration) { - if (!(usingDeclaration.PrevSibling is UsingDeclaration || usingDeclaration.PrevSibling is UsingAliasDeclaration)) { + if (usingDeclaration.PrevSibling != null && !(usingDeclaration.PrevSibling is UsingDeclaration || usingDeclaration.PrevSibling is UsingAliasDeclaration)) { EnsureBlankLinesBefore(usingDeclaration, policy.BlankLinesBeforeUsings); - } - if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling is UsingAliasDeclaration)) { + } else if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling is UsingAliasDeclaration)) { + FixIndentationForceNewLine(usingDeclaration.StartLocation); EnsureBlankLinesAfter(usingDeclaration, policy.BlankLinesAfterUsings); + } else { + FixIndentationForceNewLine(usingDeclaration.StartLocation); } } @@ -445,7 +472,7 @@ namespace ICSharpCode.NRefactory.CSharp return i; } - int ForceSpacesBeforeRemoveNewLines(AstNode n) + int ForceSpacesBeforeRemoveNewLines(AstNode n, bool forceSpace = true) { if (n == null || n.IsNull) { return 0; @@ -459,7 +486,7 @@ namespace ICSharpCode.NRefactory.CSharp i--; } var length = System.Math.Max(0, (offset - 1) - i); - AddChange(i + 1, length, " "); + AddChange(i + 1, length, forceSpace ? " " : ""); return i; } @@ -470,12 +497,22 @@ namespace ICSharpCode.NRefactory.CSharp switch (policy.PropertyFormatting) { case PropertyFormatting.AllowOneLine: bool isSimple = IsSimpleAccessor(propertyDeclaration.Getter) && IsSimpleAccessor(propertyDeclaration.Setter); - if (!isSimple || propertyDeclaration.LBraceToken.StartLocation.Line != propertyDeclaration.RBraceToken.StartLocation.Line) { + int accessorLine = propertyDeclaration.RBraceToken.StartLocation.Line; + if (!propertyDeclaration.Getter.IsNull && propertyDeclaration.Setter.IsNull) { + accessorLine = propertyDeclaration.Getter.StartLocation.Line; + } else if (propertyDeclaration.Getter.IsNull && !propertyDeclaration.Setter.IsNull) { + accessorLine = propertyDeclaration.Setter.StartLocation.Line; + } else { + var acc = propertyDeclaration.Getter.StartLocation < propertyDeclaration.Setter.StartLocation ? + propertyDeclaration.Getter : propertyDeclaration.Setter; + accessorLine = acc.StartLocation.Line; + } + if (!isSimple || propertyDeclaration.LBraceToken.StartLocation.Line != accessorLine) { EnforceBraceStyle(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken, propertyDeclaration.RBraceToken); } else { ForceSpacesBefore(propertyDeclaration.Getter, true); ForceSpacesBefore(propertyDeclaration.Setter, true); - ForceSpacesBefore(propertyDeclaration.RBraceToken, true); + ForceSpacesBeforeRemoveNewLines(propertyDeclaration.RBraceToken, true); oneLine = true; } break; @@ -574,11 +611,9 @@ namespace ICSharpCode.NRefactory.CSharp { ForceSpacesBefore(indexerDeclaration.LBracketToken, policy.SpaceBeforeIndexerDeclarationBracket); ForceSpacesAfter(indexerDeclaration.LBracketToken, policy.SpaceWithinIndexerDeclarationBracket); - ForceSpacesBefore(indexerDeclaration.RBracketToken, policy.SpaceWithinIndexerDeclarationBracket); - FormatCommas(indexerDeclaration, policy.SpaceBeforeIndexerDeclarationParameterComma, policy.SpaceAfterIndexerDeclarationParameterComma); + FormatParameters(indexerDeclaration); - FormatAttributedNode(indexerDeclaration); EnforceBraceStyle(policy.PropertyBraceStyle, indexerDeclaration.LBraceToken, indexerDeclaration.RBraceToken); if (policy.IndentPropertyBody) { @@ -785,7 +820,120 @@ namespace ICSharpCode.NRefactory.CSharp FixIndentationForceNewLine(child.StartLocation); } } - + + + void FormatParameters(AstNode node) + { + Wrapping methodCallArgumentWrapping; + bool newLineAferMethodCallOpenParentheses; + bool methodClosingParenthesesOnNewLine; + bool spaceWithinMethodCallParentheses; + bool spaceAfterMethodCallParameterComma; + bool spaceBeforeMethodCallParameterComma; + + CSharpTokenNode rParToken; + AstNodeCollection parameters; + + var constructorDeclaration = node as ConstructorDeclaration; + if (constructorDeclaration != null) { + methodCallArgumentWrapping = policy.MethodDeclarationParameterWrapping; + newLineAferMethodCallOpenParentheses = policy.NewLineAferMethodDeclarationOpenParentheses; + methodClosingParenthesesOnNewLine = policy.MethodDeclarationClosingParenthesesOnNewLine; + + spaceWithinMethodCallParentheses = policy.SpaceWithinConstructorDeclarationParentheses; + spaceAfterMethodCallParameterComma = policy.SpaceAfterConstructorDeclarationParameterComma; + spaceBeforeMethodCallParameterComma = policy.SpaceBeforeConstructorDeclarationParameterComma; + rParToken = constructorDeclaration.RParToken; + parameters = constructorDeclaration.Parameters; + } else if (node is IndexerDeclaration) { + var indexer = (IndexerDeclaration)node; + methodCallArgumentWrapping = policy.IndexerDeclarationParameterWrapping; + newLineAferMethodCallOpenParentheses = policy.NewLineAferIndexerDeclarationOpenBracket; + methodClosingParenthesesOnNewLine = policy.IndexerDeclarationClosingBracketOnNewLine; + + spaceWithinMethodCallParentheses = policy.SpaceWithinIndexerDeclarationBracket; + spaceAfterMethodCallParameterComma = policy.SpaceAfterIndexerDeclarationParameterComma; + spaceBeforeMethodCallParameterComma = policy.SpaceBeforeIndexerDeclarationParameterComma; + rParToken = indexer.RBracketToken; + parameters = indexer.Parameters; + } else if (node is OperatorDeclaration) { + var op = (OperatorDeclaration)node; + methodCallArgumentWrapping = policy.MethodDeclarationParameterWrapping; + newLineAferMethodCallOpenParentheses = policy.NewLineAferMethodDeclarationOpenParentheses; + methodClosingParenthesesOnNewLine = policy.MethodDeclarationClosingParenthesesOnNewLine; + spaceWithinMethodCallParentheses = policy.SpaceWithinMethodDeclarationParentheses; + spaceAfterMethodCallParameterComma = policy.SpaceAfterMethodDeclarationParameterComma; + spaceBeforeMethodCallParameterComma = policy.SpaceBeforeMethodDeclarationParameterComma; + rParToken = op.RParToken; + parameters = op.Parameters; + } else { + var methodDeclaration = node as MethodDeclaration; + methodCallArgumentWrapping = policy.MethodDeclarationParameterWrapping; + newLineAferMethodCallOpenParentheses = policy.NewLineAferMethodDeclarationOpenParentheses; + methodClosingParenthesesOnNewLine = policy.MethodDeclarationClosingParenthesesOnNewLine; + spaceWithinMethodCallParentheses = policy.SpaceWithinMethodDeclarationParentheses; + spaceAfterMethodCallParameterComma = policy.SpaceAfterMethodDeclarationParameterComma; + spaceBeforeMethodCallParameterComma = policy.SpaceBeforeMethodDeclarationParameterComma; + rParToken = methodDeclaration.RParToken; + parameters = methodDeclaration.Parameters; + } + if (FormattingMode == ICSharpCode.NRefactory.CSharp.FormattingMode.OnTheFly) + methodCallArgumentWrapping = Wrapping.DoNotChange; + + bool wrapMethodCall = DoWrap(methodCallArgumentWrapping, rParToken, parameters.Count); + if (wrapMethodCall && parameters.Any()) { + if (newLineAferMethodCallOpenParentheses) { + curIndent.Push(IndentType.Continuation); + foreach (var arg in parameters) { + FixStatementIndentation(arg.StartLocation); + } + curIndent.Pop(); + } else { + int extraSpaces = parameters.First().StartLocation.Column - 1 - curIndent.IndentString.Length; + curIndent.ExtraSpaces += extraSpaces; + foreach (var arg in parameters.Skip(1)) { + FixStatementIndentation(arg.StartLocation); + } + curIndent.ExtraSpaces -= extraSpaces; + } + if (!rParToken.IsNull) { + if (methodClosingParenthesesOnNewLine) { + FixStatementIndentation(rParToken.StartLocation); + } else { + ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses); + } + } + } else { + foreach (var arg in parameters) { + if (arg.PrevSibling != null) { + if (methodCallArgumentWrapping == Wrapping.DoNotWrap) { + ForceSpacesBeforeRemoveNewLines(arg, spaceAfterMethodCallParameterComma && arg.PrevSibling.Role == Roles.Comma); + } else { + ForceSpacesBefore(arg, spaceAfterMethodCallParameterComma && arg.PrevSibling.Role == Roles.Comma); + } + } + arg.AcceptVisitor(this); + } + if (!rParToken.IsNull) { + if (methodCallArgumentWrapping == Wrapping.DoNotWrap) { + ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses); + } else { + bool sameLine = rParToken.GetPrevNode().StartLocation.Line == rParToken.StartLocation.Line; + if (sameLine) { + ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses); + } else { + FixStatementIndentation(rParToken.StartLocation); + } + } + } + } + if (!rParToken.IsNull) { + foreach (CSharpTokenNode comma in rParToken.Parent.Children.Where(n => n.Role == Roles.Comma)) { + ForceSpacesBefore(comma, spaceBeforeMethodCallParameterComma); + } + } + } + public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration) { FormatAttributedNode(methodDeclaration); @@ -793,12 +941,11 @@ namespace ICSharpCode.NRefactory.CSharp ForceSpacesBefore(methodDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses); if (methodDeclaration.Parameters.Any()) { ForceSpacesAfter(methodDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses); - ForceSpacesBefore(methodDeclaration.RParToken, policy.SpaceWithinMethodDeclarationParentheses); + FormatParameters(methodDeclaration); } else { ForceSpacesAfter(methodDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); ForceSpacesBefore(methodDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); } - FormatCommas(methodDeclaration, policy.SpaceBeforeMethodDeclarationParameterComma, policy.SpaceAfterMethodDeclarationParameterComma); if (!methodDeclaration.Body.IsNull) { EnforceBraceStyle(policy.MethodBraceStyle, methodDeclaration.Body.LBraceToken, methodDeclaration.Body.RBraceToken); @@ -816,12 +963,11 @@ namespace ICSharpCode.NRefactory.CSharp ForceSpacesBefore(operatorDeclaration.LParToken, policy.SpaceBeforeMethodDeclarationParentheses); if (operatorDeclaration.Parameters.Any()) { ForceSpacesAfter(operatorDeclaration.LParToken, policy.SpaceWithinMethodDeclarationParentheses); - ForceSpacesBefore(operatorDeclaration.RParToken, policy.SpaceWithinMethodDeclarationParentheses); + FormatParameters(operatorDeclaration); } else { ForceSpacesAfter(operatorDeclaration.LParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); ForceSpacesBefore(operatorDeclaration.RParToken, policy.SpaceBetweenEmptyMethodDeclarationParentheses); } - FormatCommas(operatorDeclaration, policy.SpaceBeforeMethodDeclarationParameterComma, policy.SpaceAfterMethodDeclarationParameterComma); if (!operatorDeclaration.Body.IsNull) { EnforceBraceStyle(policy.MethodBraceStyle, operatorDeclaration.Body.LBraceToken, operatorDeclaration.Body.RBraceToken); @@ -839,13 +985,12 @@ namespace ICSharpCode.NRefactory.CSharp ForceSpacesBefore(constructorDeclaration.LParToken, policy.SpaceBeforeConstructorDeclarationParentheses); if (constructorDeclaration.Parameters.Any()) { ForceSpacesAfter(constructorDeclaration.LParToken, policy.SpaceWithinConstructorDeclarationParentheses); - ForceSpacesBefore(constructorDeclaration.RParToken, policy.SpaceWithinConstructorDeclarationParentheses); + FormatParameters(constructorDeclaration); } else { ForceSpacesAfter(constructorDeclaration.LParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses); ForceSpacesBefore(constructorDeclaration.RParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses); } - FormatCommas(constructorDeclaration, policy.SpaceBeforeConstructorDeclarationParameterComma, policy.SpaceAfterConstructorDeclarationParameterComma); - + if (!constructorDeclaration.Body.IsNull) { EnforceBraceStyle(policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken, constructorDeclaration.Body.RBraceToken); VisitBlockWithoutFixingBraces(constructorDeclaration.Body, policy.IndentMethodBody); @@ -1174,6 +1319,8 @@ namespace ICSharpCode.NRefactory.CSharp TextReplaceAction AddChange(int offset, int removedChars, string insertedText) { + if (removedChars == 0 && string.IsNullOrEmpty (insertedText)) + return null; var action = new TextReplaceAction (offset, removedChars, insertedText); changes.Add(action); return action; @@ -1283,11 +1430,14 @@ namespace ICSharpCode.NRefactory.CSharp } if (!ifElseStatement.FalseStatement.IsNull) { - PlaceOnNewLine(policy.PlaceElseOnNewLine || !(ifElseStatement.TrueStatement is BlockStatement) && policy.IfElseBraceForcement != BraceForcement.AddBraces, ifElseStatement.ElseToken); + var placeElseOnNewLine = policy.ElseNewLinePlacement; + if (!(ifElseStatement.TrueStatement is BlockStatement) && policy.IfElseBraceForcement != BraceForcement.AddBraces) + placeElseOnNewLine = NewLinePlacement.NewLine; + PlaceOnNewLine(placeElseOnNewLine, ifElseStatement.ElseToken); var forcement = policy.IfElseBraceForcement; if (ifElseStatement.FalseStatement is IfElseStatement) { forcement = BraceForcement.DoNotChange; - PlaceOnNewLine(policy.PlaceElseIfOnNewLine, ((IfElseStatement)ifElseStatement.FalseStatement).IfToken); + PlaceOnNewLine(policy.ElseIfNewLinePlacement, ((IfElseStatement)ifElseStatement.FalseStatement).IfToken); } FixEmbeddedStatment(policy.StatementBraceStyle, forcement, ifElseStatement.ElseToken, policy.AllowIfBlockInline, ifElseStatement.FalseStatement, ifElseStatement.FalseStatement is IfElseStatement); } @@ -1378,7 +1528,7 @@ namespace ICSharpCode.NRefactory.CSharp } foreach (CatchClause clause in tryCatchStatement.CatchClauses) { - PlaceOnNewLine(policy.PlaceCatchOnNewLine, clause.CatchToken); + PlaceOnNewLine(policy.CatchNewLinePlacement, clause.CatchToken); if (!clause.LParToken.IsNull) { ForceSpacesBefore(clause.LParToken, policy.SpaceBeforeCatchParentheses); @@ -1389,7 +1539,7 @@ namespace ICSharpCode.NRefactory.CSharp } if (!tryCatchStatement.FinallyBlock.IsNull) { - PlaceOnNewLine(policy.PlaceFinallyOnNewLine, tryCatchStatement.FinallyToken); + PlaceOnNewLine(policy.FinallyNewLinePlacement, tryCatchStatement.FinallyToken); FixEmbeddedStatment(policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.FinallyBlock); } @@ -1443,7 +1593,7 @@ namespace ICSharpCode.NRefactory.CSharp public override void VisitDoWhileStatement(DoWhileStatement doWhileStatement) { - PlaceOnNewLine(policy.PlaceWhileOnNewLine, doWhileStatement.WhileToken); + PlaceOnNewLine(policy.WhileNewLinePlacement, doWhileStatement.WhileToken); FixEmbeddedStatment(policy.StatementBraceStyle, policy.WhileBraceForcement, doWhileStatement.EmbeddedStatement); } @@ -1495,6 +1645,8 @@ namespace ICSharpCode.NRefactory.CSharp { if (!anonymousMethodExpression.Body.IsNull) { EnforceBraceStyle(policy.AnonymousMethodBraceStyle, anonymousMethodExpression.Body.LBraceToken, anonymousMethodExpression.Body.RBraceToken); + VisitBlockWithoutFixingBraces(anonymousMethodExpression.Body, policy.IndentBlocks); + return; } base.VisitAnonymousMethodExpression(anonymousMethodExpression); } @@ -1600,29 +1752,156 @@ namespace ICSharpCode.NRefactory.CSharp } } + bool DoWrap (Wrapping wrapping, AstNode wrapNode, int argumentCount) + { + return wrapping == Wrapping.WrapAlways || + options.WrapLineLength > 0 && argumentCount > 1 && wrapping == Wrapping.WrapIfTooLong && wrapNode.StartLocation.Column >= options.WrapLineLength; + } + + void FormatArguments(AstNode node) + { + Wrapping methodCallArgumentWrapping; + bool newLineAferMethodCallOpenParentheses; + bool methodClosingParenthesesOnNewLine; + bool spaceWithinMethodCallParentheses; + bool spaceAfterMethodCallParameterComma; + bool spaceBeforeMethodCallParameterComma; + + CSharpTokenNode rParToken; + AstNodeCollection arguments; + var indexer = node as IndexerExpression; + if (indexer != null) { + methodCallArgumentWrapping = policy.IndexerArgumentWrapping; + newLineAferMethodCallOpenParentheses = policy.NewLineAferIndexerOpenBracket; + methodClosingParenthesesOnNewLine = policy.IndexerClosingBracketOnNewLine; + spaceWithinMethodCallParentheses = policy.SpacesWithinBrackets; + spaceAfterMethodCallParameterComma = policy.SpaceAfterBracketComma; + spaceBeforeMethodCallParameterComma = policy.SpaceBeforeBracketComma; + + rParToken = indexer.RBracketToken; + arguments = indexer.Arguments; + } else if (node is ObjectCreateExpression) { + var oce = node as ObjectCreateExpression; + methodCallArgumentWrapping = policy.MethodCallArgumentWrapping; + newLineAferMethodCallOpenParentheses = policy.NewLineAferMethodCallOpenParentheses; + methodClosingParenthesesOnNewLine = policy.MethodCallClosingParenthesesOnNewLine; + spaceWithinMethodCallParentheses = policy.SpacesWithinNewParentheses; + spaceAfterMethodCallParameterComma = policy.SpaceAfterNewParameterComma; + spaceBeforeMethodCallParameterComma = policy.SpaceBeforeNewParameterComma; + + rParToken = oce.RParToken; + arguments = oce.Arguments; + } else { + InvocationExpression invocationExpression = node as InvocationExpression; + methodCallArgumentWrapping = policy.MethodCallArgumentWrapping; + newLineAferMethodCallOpenParentheses = policy.NewLineAferMethodCallOpenParentheses; + methodClosingParenthesesOnNewLine = policy.MethodCallClosingParenthesesOnNewLine; + spaceWithinMethodCallParentheses = policy.SpaceWithinMethodCallParentheses; + spaceAfterMethodCallParameterComma = policy.SpaceAfterMethodCallParameterComma; + spaceBeforeMethodCallParameterComma = policy.SpaceBeforeMethodCallParameterComma; + + rParToken = invocationExpression.RParToken; + arguments = invocationExpression.Arguments; + } + + if (FormattingMode == ICSharpCode.NRefactory.CSharp.FormattingMode.OnTheFly) + methodCallArgumentWrapping = Wrapping.DoNotChange; + + bool wrapMethodCall = DoWrap(methodCallArgumentWrapping, rParToken, arguments.Count); + if (wrapMethodCall && arguments.Any()) { + if (newLineAferMethodCallOpenParentheses) { + curIndent.Push(IndentType.Continuation); + foreach (var arg in arguments) { + FixStatementIndentation(arg.StartLocation); + } + curIndent.Pop(); + } else { + int extraSpaces = arguments.First().StartLocation.Column - 1 - curIndent.IndentString.Length; + curIndent.ExtraSpaces += extraSpaces; + foreach (var arg in arguments.Skip(1)) { + FixStatementIndentation(arg.StartLocation); + } + curIndent.ExtraSpaces -= extraSpaces; + } + if (!rParToken.IsNull) { + if (methodClosingParenthesesOnNewLine) { + FixStatementIndentation(rParToken.StartLocation); + } else { + ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses); + } + } + } else { + foreach (var arg in arguments) { + if (arg.PrevSibling != null) { + if (methodCallArgumentWrapping == Wrapping.DoNotWrap) { + ForceSpacesBeforeRemoveNewLines(arg, spaceAfterMethodCallParameterComma && arg.PrevSibling.Role == Roles.Comma); + } else { + ForceSpacesBefore(arg, spaceAfterMethodCallParameterComma && arg.PrevSibling.Role == Roles.Comma); + } + } + arg.AcceptVisitor(this); + } + if (!rParToken.IsNull) { + if (methodCallArgumentWrapping == Wrapping.DoNotWrap) { + ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses); + } else { + bool sameLine = rParToken.GetPrevNode().EndLocation.Line == rParToken.StartLocation.Line; + if (sameLine) { + ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses); + } else { + FixStatementIndentation(rParToken.StartLocation); + } + } + } + } + if (!rParToken.IsNull) { + foreach (CSharpTokenNode comma in rParToken.Parent.Children.Where(n => n.Role == Roles.Comma)) { + ForceSpacesBefore(comma, spaceBeforeMethodCallParameterComma); + } + } + } + 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); } else { ForceSpacesAfter(invocationExpression.LParToken, policy.SpaceBetweenEmptyMethodCallParentheses); ForceSpacesBefore(invocationExpression.RParToken, policy.SpaceBetweenEmptyMethodCallParentheses); } - FormatCommas(invocationExpression, policy.SpaceBeforeMethodCallParameterComma, policy.SpaceAfterMethodCallParameterComma); - base.VisitInvocationExpression(invocationExpression); + if (!invocationExpression.Target.IsNull) + invocationExpression.Target.AcceptVisitor(this); + + if (invocationExpression.Target is MemberReferenceExpression) { + var mt = (MemberReferenceExpression)invocationExpression.Target; + if (mt.Target is InvocationExpression) { + if (DoWrap(policy.ChainedMethodCallWrapping, mt.DotToken, 2)) { + curIndent.Push(IndentType.Continuation); + FixStatementIndentation(mt.DotToken.StartLocation); + curIndent.Pop(); + } else { + if (policy.ChainedMethodCallWrapping == Wrapping.DoNotWrap) + ForceSpacesBeforeRemoveNewLines(mt.DotToken, false); + } + } + } + FormatArguments(invocationExpression); } 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); - base.VisitIndexerExpression(indexerExpression); + if (!indexerExpression.Target.IsNull) + indexerExpression.Target.AcceptVisitor(this); + + FormatArguments(indexerExpression); + + + } public override void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression) @@ -1667,23 +1946,18 @@ namespace ICSharpCode.NRefactory.CSharp ForceSpacesBefore(objectCreateExpression.LParToken, policy.SpaceBeforeNewParentheses); if (objectCreateExpression.Arguments.Any()) { - if (!objectCreateExpression.LParToken.IsNull) { + if (!objectCreateExpression.LParToken.IsNull) ForceSpacesAfter(objectCreateExpression.LParToken, policy.SpacesWithinNewParentheses); - } - if (!objectCreateExpression.RParToken.IsNull) { - ForceSpacesBefore(objectCreateExpression.RParToken, policy.SpacesWithinNewParentheses); - } } else { - if (!objectCreateExpression.LParToken.IsNull) { + if (!objectCreateExpression.LParToken.IsNull) ForceSpacesAfter(objectCreateExpression.LParToken, policy.SpacesBetweenEmptyNewParentheses); - } - if (!objectCreateExpression.RParToken.IsNull) { - ForceSpacesBefore(objectCreateExpression.RParToken, policy.SpacesBetweenEmptyNewParentheses); - } } - FormatCommas(objectCreateExpression, policy.SpaceBeforeNewParameterComma, policy.SpaceAfterNewParameterComma); - - base.VisitObjectCreateExpression(objectCreateExpression); + + if (!objectCreateExpression.Type.IsNull) + objectCreateExpression.Type.AcceptVisitor(this); + + FormatArguments(objectCreateExpression); + } public override void VisitArrayCreateExpression(ArrayCreateExpression arrayObjectCreateExpression) @@ -1694,7 +1968,7 @@ namespace ICSharpCode.NRefactory.CSharp public override void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression) { - if (policy.ArrayInitializerWrapping == Wrapping.WrapAlways) { + if (DoWrap(policy.ArrayInitializerWrapping, arrayInitializerExpression.RBraceToken, arrayInitializerExpression.Elements.Count)) { EnforceBraceStyle(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.LBraceToken, arrayInitializerExpression.RBraceToken); curIndent.Push(IndentType.Block); foreach (var init in arrayInitializerExpression.Elements) { @@ -1728,6 +2002,12 @@ namespace ICSharpCode.NRefactory.CSharp base.VisitNamedArgumentExpression(namedArgumentExpression); } + public override void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression) + { + ForceSpacesAfter(memberReferenceExpression.DotToken, false); + base.VisitMemberReferenceExpression(memberReferenceExpression); + } + #endregion void ForceSpaceBefore(int offset, bool forceSpace) @@ -1804,15 +2084,20 @@ namespace ICSharpCode.NRefactory.CSharp } } - void PlaceOnNewLine(bool newLine, AstNode keywordNode) + void PlaceOnNewLine(NewLinePlacement newLine, AstNode keywordNode) { - if (keywordNode == null) { + if (keywordNode == null || newLine == NewLinePlacement.DoNotCare) { return; } + + var prev = keywordNode.GetPrevNode (); + if (prev is Comment || prev is PreProcessorDirective) + return; + int offset = document.GetOffset(keywordNode.StartLocation); int whitespaceStart = SearchWhitespaceStart(offset); - string indentString = newLine ? this.options.EolMarker + this.curIndent.IndentString : " "; + string indentString = newLine == NewLinePlacement.NewLine ? this.options.EolMarker + this.curIndent.IndentString : " "; AddChange(whitespaceStart, offset - whitespaceStart, indentString); } diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs b/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs index 0cf8d42a0..23152e5bd 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/CSharpFormattingOptions.cs @@ -56,11 +56,18 @@ namespace ICSharpCode.NRefactory.CSharp } public enum Wrapping { + DoNotChange, DoNotWrap, WrapAlways, WrapIfTooLong } + public enum NewLinePlacement { + DoNotCare, + NewLine, + SameLine + } + public class CSharpFormattingOptions { public string Name { @@ -298,27 +305,27 @@ namespace ICSharpCode.NRefactory.CSharp #endregion #region NewLines - public bool PlaceElseOnNewLine { // tested + public NewLinePlacement ElseNewLinePlacement { // tested get; set; } - public bool PlaceElseIfOnNewLine { // tested + public NewLinePlacement ElseIfNewLinePlacement { // tested get; set; } - public bool PlaceCatchOnNewLine { // tested + public NewLinePlacement CatchNewLinePlacement { // tested get; set; } - public bool PlaceFinallyOnNewLine { // tested + public NewLinePlacement FinallyNewLinePlacement { // tested get; set; } - public bool PlaceWhileOnNewLine { // tested + public NewLinePlacement WhileNewLinePlacement { // tested get; set; } @@ -786,6 +793,70 @@ namespace ICSharpCode.NRefactory.CSharp set; } + public Wrapping ChainedMethodCallWrapping { + get; + set; + } + + public Wrapping MethodCallArgumentWrapping { + get; + set; + } + + public bool NewLineAferMethodCallOpenParentheses { + get; + set; + } + + public bool MethodCallClosingParenthesesOnNewLine { + get; + set; + } + + public Wrapping IndexerArgumentWrapping { + get; + set; + } + + public bool NewLineAferIndexerOpenBracket { + get; + set; + } + + public bool IndexerClosingBracketOnNewLine { + get; + set; + } + + public Wrapping MethodDeclarationParameterWrapping { + get; + set; + } + + public bool NewLineAferMethodDeclarationOpenParentheses { + get; + set; + } + + public bool MethodDeclarationClosingParenthesesOnNewLine { + get; + set; + } + + public Wrapping IndexerDeclarationParameterWrapping { + get; + set; + } + + public bool NewLineAferIndexerDeclarationOpenBracket { + get; + set; + } + + public bool IndexerDeclarationClosingBracketOnNewLine { + get; + set; + } #endregion internal CSharpFormattingOptions() diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/FormattingOptionsFactory.cs b/ICSharpCode.NRefactory.CSharp/Formatter/FormattingOptionsFactory.cs index 331a1579c..354d5865f 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/FormattingOptionsFactory.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/FormattingOptionsFactory.cs @@ -43,9 +43,9 @@ namespace ICSharpCode.NRefactory.CSharp /// /// Creates mono indent style CSharpFormatting options. /// - public static CSharpFormattingOptions CreateMono() + public static CSharpFormattingOptions CreateMono () { - return new CSharpFormattingOptions() { + return new CSharpFormattingOptions () { IndentNamespaceBody = true, IndentClassBody = true, IndentInterfaceBody = true, @@ -81,10 +81,10 @@ namespace ICSharpCode.NRefactory.CSharp AllowEventRemoveBlockInline = true, StatementBraceStyle = BraceStyle.EndOfLine, - PlaceElseOnNewLine = false, - PlaceCatchOnNewLine = false, - PlaceFinallyOnNewLine = false, - PlaceWhileOnNewLine = false, + ElseNewLinePlacement = NewLinePlacement.SameLine, + CatchNewLinePlacement = NewLinePlacement.SameLine, + FinallyNewLinePlacement = NewLinePlacement.SameLine, + WhileNewLinePlacement = NewLinePlacement.SameLine, ArrayInitializerWrapping = Wrapping.WrapIfTooLong, ArrayInitializerBraceStyle = BraceStyle.EndOfLine, @@ -94,7 +94,7 @@ namespace ICSharpCode.NRefactory.CSharp SpaceBeforeDelegateDeclarationParentheses = true, SpaceAfterMethodCallParameterComma = true, SpaceAfterConstructorDeclarationParameterComma = true, - + SpaceBeforeNewParentheses = true, SpacesWithinNewParentheses = false, SpacesBetweenEmptyNewParentheses = false, @@ -152,6 +152,7 @@ namespace ICSharpCode.NRefactory.CSharp PropertyFormatting = PropertyFormatting.AllowOneLine, SpaceBeforeMethodDeclarationParameterComma = false, SpaceAfterMethodDeclarationParameterComma = true, + SpaceAfterDelegateDeclarationParameterComma = true, SpaceBeforeFieldDeclarationComma = false, SpaceAfterFieldDeclarationComma = true, SpaceBeforeLocalVariableDeclarationComma = false, @@ -175,6 +176,21 @@ namespace ICSharpCode.NRefactory.CSharp BlankLinesBetweenMembers = 1, KeepCommentsAtFirstColumn = true, + ChainedMethodCallWrapping = Wrapping.DoNotChange, + MethodCallArgumentWrapping = Wrapping.DoNotChange, + NewLineAferMethodCallOpenParentheses = true, + MethodCallClosingParenthesesOnNewLine = true, + + IndexerArgumentWrapping = Wrapping.DoNotChange, + NewLineAferIndexerOpenBracket = false, + IndexerClosingBracketOnNewLine = false, + + IfElseBraceForcement = BraceForcement.DoNotChange, + ForBraceForcement = BraceForcement.DoNotChange, + ForEachBraceForcement = BraceForcement.DoNotChange, + WhileBraceForcement = BraceForcement.DoNotChange, + UsingBraceForcement = BraceForcement.DoNotChange, + FixedBraceForcement = BraceForcement.DoNotChange }; } @@ -183,7 +199,23 @@ namespace ICSharpCode.NRefactory.CSharp /// public static CSharpFormattingOptions CreateSharpDevelop() { - return new CSharpFormattingOptions() { + var baseOptions = CreateKRStyle(); + baseOptions.IfElseBraceForcement = BraceForcement.AddBraces; + baseOptions.ForBraceForcement = BraceForcement.AddBraces; + baseOptions.ForEachBraceForcement = BraceForcement.AddBraces; + baseOptions.WhileBraceForcement = BraceForcement.AddBraces; + baseOptions.UsingBraceForcement = BraceForcement.AddBraces; + baseOptions.FixedBraceForcement = BraceForcement.AddBraces; + return baseOptions; + } + + /// + /// The K&R style, so named because it was used in Kernighan and Ritchie's book The C Programming Language, + /// is commonly used in C. It is less common for C++, C#, and others. + /// + public static CSharpFormattingOptions CreateKRStyle () + { + return new CSharpFormattingOptions () { IndentNamespaceBody = true, IndentClassBody = true, IndentInterfaceBody = true, @@ -219,10 +251,10 @@ namespace ICSharpCode.NRefactory.CSharp AllowEventRemoveBlockInline = true, StatementBraceStyle = BraceStyle.EndOfLine, - PlaceElseOnNewLine = false, - PlaceCatchOnNewLine = false, - PlaceFinallyOnNewLine = false, - PlaceWhileOnNewLine = false, + ElseNewLinePlacement = NewLinePlacement.SameLine, + CatchNewLinePlacement = NewLinePlacement.SameLine, + FinallyNewLinePlacement = NewLinePlacement.SameLine, + WhileNewLinePlacement = NewLinePlacement.SameLine, ArrayInitializerWrapping = Wrapping.WrapIfTooLong, ArrayInitializerBraceStyle = BraceStyle.EndOfLine, @@ -291,6 +323,7 @@ namespace ICSharpCode.NRefactory.CSharp PropertyFormatting = PropertyFormatting.AllowOneLine, SpaceBeforeMethodDeclarationParameterComma = false, SpaceAfterMethodDeclarationParameterComma = true, + SpaceAfterDelegateDeclarationParameterComma = true, SpaceBeforeFieldDeclarationComma = false, SpaceAfterFieldDeclarationComma = true, SpaceBeforeLocalVariableDeclarationComma = false, @@ -313,6 +346,21 @@ namespace ICSharpCode.NRefactory.CSharp BlankLinesBetweenMembers = 1, KeepCommentsAtFirstColumn = true, + ChainedMethodCallWrapping = Wrapping.DoNotChange, + MethodCallArgumentWrapping = Wrapping.DoNotChange, + NewLineAferMethodCallOpenParentheses = true, + MethodCallClosingParenthesesOnNewLine = true, + + IndexerArgumentWrapping = Wrapping.DoNotChange, + NewLineAferIndexerOpenBracket = false, + IndexerClosingBracketOnNewLine = false, + + IfElseBraceForcement = BraceForcement.DoNotChange, + ForBraceForcement = BraceForcement.DoNotChange, + ForEachBraceForcement = BraceForcement.DoNotChange, + WhileBraceForcement = BraceForcement.DoNotChange, + UsingBraceForcement = BraceForcement.DoNotChange, + FixedBraceForcement = BraceForcement.DoNotChange }; } @@ -321,19 +369,65 @@ namespace ICSharpCode.NRefactory.CSharp /// public static CSharpFormattingOptions CreateAllman() { - var baseOptions = CreateSharpDevelop(); - baseOptions.AnonymousMethodBraceStyle = BraceStyle.EndOfLine; - baseOptions.PropertyBraceStyle = BraceStyle.EndOfLine; - baseOptions.PropertyGetBraceStyle = BraceStyle.EndOfLine; - baseOptions.PropertySetBraceStyle = BraceStyle.EndOfLine; + var baseOptions = CreateKRStyle(); + baseOptions.AnonymousMethodBraceStyle = BraceStyle.NextLine; + baseOptions.PropertyBraceStyle = BraceStyle.NextLine; + baseOptions.PropertyGetBraceStyle = BraceStyle.NextLine; + baseOptions.PropertySetBraceStyle = BraceStyle.NextLine; - baseOptions.EventBraceStyle = BraceStyle.EndOfLine; - baseOptions.EventAddBraceStyle = BraceStyle.EndOfLine; - baseOptions.EventRemoveBraceStyle = BraceStyle.EndOfLine; - baseOptions.StatementBraceStyle = BraceStyle.EndOfLine; - baseOptions.ArrayInitializerBraceStyle = BraceStyle.EndOfLine; + baseOptions.EventBraceStyle = BraceStyle.NextLine; + baseOptions.EventAddBraceStyle = BraceStyle.NextLine; + baseOptions.EventRemoveBraceStyle = BraceStyle.NextLine; + baseOptions.StatementBraceStyle = BraceStyle.NextLine; + baseOptions.ArrayInitializerBraceStyle = BraceStyle.NextLine; return baseOptions; } + + /// + /// The Whitesmiths style, also called Wishart style to a lesser extent, is less common today than the previous three. It was originally used in the documentation for the first commercial C compiler, the Whitesmiths Compiler. + /// + public static CSharpFormattingOptions CreateWhitesmiths() + { + var baseOptions = CreateKRStyle(); + + baseOptions.NamespaceBraceStyle = BraceStyle.NextLineShifted; + baseOptions.ClassBraceStyle = BraceStyle.NextLineShifted; + baseOptions.InterfaceBraceStyle = BraceStyle.NextLineShifted; + baseOptions.StructBraceStyle = BraceStyle.NextLineShifted; + baseOptions.EnumBraceStyle = BraceStyle.NextLineShifted; + baseOptions.MethodBraceStyle = BraceStyle.NextLineShifted; + baseOptions.ConstructorBraceStyle = BraceStyle.NextLineShifted; + baseOptions.DestructorBraceStyle = BraceStyle.NextLineShifted; + baseOptions.AnonymousMethodBraceStyle = BraceStyle.NextLineShifted; + baseOptions.PropertyBraceStyle = BraceStyle.NextLineShifted; + baseOptions.PropertyGetBraceStyle = BraceStyle.NextLineShifted; + baseOptions.PropertySetBraceStyle = BraceStyle.NextLineShifted; + + baseOptions.EventBraceStyle = BraceStyle.NextLineShifted; + baseOptions.EventAddBraceStyle = BraceStyle.NextLineShifted; + baseOptions.EventRemoveBraceStyle = BraceStyle.NextLineShifted; + baseOptions.StatementBraceStyle = BraceStyle.NextLineShifted; + return baseOptions; + } + + /// + /// Like the Allman and Whitesmiths styles, GNU style puts braces on a line by themselves, indented by 2 spaces, + /// except when opening a function definition, where they are not indented. + /// In either case, the contained code is indented by 2 spaces from the braces. + /// Popularised by Richard Stallman, the layout may be influenced by his background of writing Lisp code. + /// In Lisp the equivalent to a block (a progn) + /// is a first class data entity and giving it its own indent level helps to emphasize that, + /// whereas in C a block is just syntax. + /// Although not directly related to indentation, GNU coding style also includes a space before the bracketed + /// list of arguments to a function. + /// + public static CSharpFormattingOptions CreateGNU() + { + var baseOptions = CreateAllman(); + baseOptions.StatementBraceStyle = BraceStyle.NextLineShifted2; + return baseOptions; + } + } } diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/GeneratedCodeSettings.cs b/ICSharpCode.NRefactory.CSharp/Formatter/GeneratedCodeSettings.cs index 827a3dc94..2095b0d33 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/GeneratedCodeSettings.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/GeneratedCodeSettings.cs @@ -1,4 +1,4 @@ -// +// // GeneratedCodeSettings.cs // // Author: @@ -177,7 +177,9 @@ namespace ICSharpCode.NRefactory.CSharp 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); + mem.Parent.InsertChildBefore (mem, cmt, Roles.Comment); + mem.Parent.InsertChildBefore (mem, cmt2, Roles.Comment); + mem.Parent.InsertChildBefore (mem, cmt3, Roles.Comment); if (cmt.PrevSibling is EntityDeclaration) mem.Parent.InsertChildBefore (cmt, new UnixNewLine (), Roles.NewLine); diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs b/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs index 322aa211d..1db659b8f 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/Indent.cs @@ -80,7 +80,19 @@ namespace ICSharpCode.NRefactory.CSharp indentString = new string(' ', curIndent); return; } - indentString = new string('\t', curIndent / options.TabSize) + new string(' ', curIndent % options.TabSize); + indentString = new string('\t', curIndent / options.TabSize) + new string(' ', curIndent % options.TabSize) + new string (' ', ExtraSpaces); + } + + int extraSpaces; + + public int ExtraSpaces { + get { + return extraSpaces; + } + set { + extraSpaces = value; + Update(); + } } string indentString; diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/TextEditorOptions.cs b/ICSharpCode.NRefactory.CSharp/Formatter/TextEditorOptions.cs index 6ea176374..7c3eef2d2 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/TextEditorOptions.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/TextEditorOptions.cs @@ -94,12 +94,22 @@ namespace ICSharpCode.NRefactory.CSharp set; } + /// + /// Gets or sets the length of the desired line length. The formatting engine will wrap at wrap points set to Wrapping.WrapIfTooLong if the line length is too long. + /// 0 means do not wrap. + /// + public int WrapLineLength { + get; + set; + } + public TextEditorOptions() { TabsToSpaces = false; TabSize = 4; IndentSize = 4; ContinuationIndent = 4; + WrapLineLength = 0; EolMarker = Environment.NewLine; } } diff --git a/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj b/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj index 290699e9e..a62692406 100644 --- a/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj +++ b/ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj @@ -14,12 +14,13 @@ false 10.0.0 2.0 - true + True ..\ICSharpCode.NRefactory.snk False File - ..\ICSharpCode.NRefactory\bin\$(Configuration)\ICSharpCode.NRefactory.CSharp.xml + ..\bin\$(Configuration)\ICSharpCode.NRefactory.CSharp.xml 1591,1587,1570 + ..\bin\$(Configuration)\ AnyCPU @@ -29,25 +30,43 @@ 4096 - ..\ICSharpCode.NRefactory\bin\Debug\ False False - DEBUG;TRACE;FULL_AST + DEBUG;TRACE;FULL_AST;NET_4_0 - ..\ICSharpCode.NRefactory\bin\Release\ True False - TRACE;FULL_AST + TRACE;FULL_AST;NET_4_0 PdbOnly false - full + Full true + + False + False + DEBUG;TRACE;FULL_AST;NET_4_0;NET_4_5 + v4.5 + + + Full + true + + + True + False + TRACE;FULL_AST;NET_4_0;NET_4_5 + v4.5 + + + PdbOnly + false + @@ -70,7 +89,7 @@ - + @@ -131,6 +150,7 @@ + @@ -184,6 +204,7 @@ + @@ -241,14 +262,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -271,14 +358,14 @@ - + - + @@ -294,7 +381,6 @@ - @@ -370,6 +456,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -383,14 +511,17 @@ + + - - - + + + + diff --git a/ICSharpCode.NRefactory.CSharp/SimpleNameLookupMode.cs b/ICSharpCode.NRefactory.CSharp/NameLookupMode.cs similarity index 98% rename from ICSharpCode.NRefactory.CSharp/SimpleNameLookupMode.cs rename to ICSharpCode.NRefactory.CSharp/NameLookupMode.cs index 00acb9324..07165410e 100644 --- a/ICSharpCode.NRefactory.CSharp/SimpleNameLookupMode.cs +++ b/ICSharpCode.NRefactory.CSharp/NameLookupMode.cs @@ -20,7 +20,7 @@ using System; namespace ICSharpCode.NRefactory.CSharp { - public enum SimpleNameLookupMode + public enum NameLookupMode { /// /// Normal name lookup in expressions diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs index 4ee6ad30e..665e15e71 100644 --- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpOutputVisitor.cs @@ -917,7 +917,7 @@ namespace ICSharpCode.NRefactory.CSharp public void VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression) { StartNode(namedArgumentExpression); - namedArgumentExpression.IdentifierToken.AcceptVisitor(this); + namedArgumentExpression.NameToken.AcceptVisitor(this); WriteToken(Roles.Colon); Space(); namedArgumentExpression.Expression.AcceptVisitor(this); @@ -927,7 +927,7 @@ namespace ICSharpCode.NRefactory.CSharp public void VisitNamedExpression(NamedExpression namedExpression) { StartNode(namedExpression); - namedExpression.IdentifierToken.AcceptVisitor(this); + namedExpression.NameToken.AcceptVisitor(this); Space(); WriteToken(Roles.Assign); Space(); @@ -1007,6 +1007,14 @@ namespace ICSharpCode.NRefactory.CSharp EndNode(primitiveExpression); } + public static string PrintPrimitiveValue(object val) + { + StringWriter writer = new StringWriter(); + CSharpOutputVisitor visitor = new CSharpOutputVisitor(writer, new CSharpFormattingOptions()); + visitor.WritePrimitiveValue(val); + return writer.ToString(); + } + void WritePrimitiveValue(object val) { if (val == null) { @@ -1837,16 +1845,19 @@ namespace ICSharpCode.NRefactory.CSharp label.AcceptVisitor(this); first = false; } - if (policy.IndentCaseBody) { + bool isBlock = switchSection.Statements.Count == 1 && switchSection.Statements.Single() is BlockStatement; + if (policy.IndentCaseBody && !isBlock) { formatter.Indent(); } - foreach (var statement in switchSection.Statements) { + if (!isBlock) NewLine(); + + foreach (var statement in switchSection.Statements) { statement.AcceptVisitor(this); } - if (policy.IndentCaseBody) { + if (policy.IndentCaseBody && !isBlock) { formatter.Unindent(); } @@ -2161,6 +2172,7 @@ namespace ICSharpCode.NRefactory.CSharp WriteAttributes(indexerDeclaration.Attributes); WriteModifiers(indexerDeclaration.ModifierTokens); indexerDeclaration.ReturnType.AcceptVisitor(this); + Space(); WritePrivateImplementationType(indexerDeclaration.PrivateImplementationType); WriteKeyword(IndexerDeclaration.ThisKeywordRole); Space(policy.SpaceBeforeMethodDeclarationParentheses); @@ -2293,10 +2305,10 @@ namespace ICSharpCode.NRefactory.CSharp EndNode(variableInitializer); } - public void VisitCompilationUnit(CompilationUnit compilationUnit) + public void VisitSyntaxTree(SyntaxTree syntaxTree) { // don't do node tracking as we visit all children directly - foreach (AstNode node in compilationUnit.Children) { + foreach (AstNode node in syntaxTree.Children) { node.AcceptVisitor(this); } } diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs index 6b55c1490..b7db64702 100644 --- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CodeDomConvertVisitor.cs @@ -21,12 +21,12 @@ using System.CodeDom; using System.Collections.Generic; using System.IO; using System.Linq; +using ICSharpCode.NRefactory.CSharp.Refactoring; using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.CSharp.TypeSystem; using ICSharpCode.NRefactory.PatternMatching; using ICSharpCode.NRefactory.Semantics; using ICSharpCode.NRefactory.TypeSystem; -using ICSharpCode.NRefactory.TypeSystem.Implementation; namespace ICSharpCode.NRefactory.CSharp { @@ -40,35 +40,44 @@ namespace ICSharpCode.NRefactory.CSharp { //ICompilation compilation = MinimalResolveContext.Instance; CSharpAstResolver resolver; - bool useFullyQualifiedTypeNames; /// /// Gets/Sets whether the visitor should use fully-qualified type references. /// - public bool UseFullyQualifiedTypeNames { - get { return useFullyQualifiedTypeNames; } - set { useFullyQualifiedTypeNames = value; } + public bool UseFullyQualifiedTypeNames { get; set; } + + /// + /// Gets whether the visitor is allowed to produce snippet nodes for + /// code that cannot be converted. + /// The default is true. If this property is set to false, + /// unconvertible code will throw a NotSupportedException. + /// + public bool AllowSnippetNodes { get; set; } + + public CodeDomConvertVisitor() + { + this.AllowSnippetNodes = true; } /// - /// Converts a compilation unit to CodeDom. + /// Converts a syntax tree to CodeDom. /// - /// The input compilation unit. + /// The input syntax tree. /// The current compilation. - /// CSharpParsedFile, used for resolving. + /// CSharpUnresolvedFile, used for resolving. /// Converted CodeCompileUnit /// /// This conversion process requires a resolver because it needs to distinguish field/property/event references etc. /// - public CodeCompileUnit Convert(ICompilation compilation, CompilationUnit compilationUnit, CSharpParsedFile parsedFile) + public CodeCompileUnit Convert(ICompilation compilation, SyntaxTree syntaxTree, CSharpUnresolvedFile unresolvedFile) { - if (compilationUnit == null) - throw new ArgumentNullException("compilationUnit"); + if (syntaxTree == null) + throw new ArgumentNullException("syntaxTree"); if (compilation == null) throw new ArgumentNullException("compilation"); - CSharpAstResolver resolver = new CSharpAstResolver(compilation, compilationUnit, parsedFile); - return (CodeCompileUnit)Convert(compilationUnit, resolver); + CSharpAstResolver resolver = new CSharpAstResolver(compilation, syntaxTree, unresolvedFile); + return (CodeCompileUnit)Convert(syntaxTree, resolver); } /// @@ -136,7 +145,15 @@ namespace ICSharpCode.NRefactory.CSharp CodeTypeReference Convert(IType type) { - return new CodeTypeReference(type.ReflectionName); + if (type.Kind == TypeKind.Array) { + ArrayType a = (ArrayType)type; + return new CodeTypeReference(Convert(a.ElementType), a.Dimensions); + } else if (type is ParameterizedType) { + var pt = (ParameterizedType)type; + return new CodeTypeReference(pt.GetDefinition().ReflectionName, pt.TypeArguments.Select(Convert).ToArray()); + } else { + return new CodeTypeReference(type.ReflectionName); + } } CodeStatement Convert(Statement stmt) @@ -148,6 +165,8 @@ namespace ICSharpCode.NRefactory.CSharp { List result = new List(); foreach (Statement stmt in block.Statements) { + if (stmt is EmptyStatement) + continue; CodeStatement s = Convert(stmt); if (s != null) result.Add(s); @@ -160,6 +179,8 @@ namespace ICSharpCode.NRefactory.CSharp BlockStatement block = embeddedStatement as BlockStatement; if (block != null) { return ConvertBlock(block); + } else if (embeddedStatement is EmptyStatement) { + return new CodeStatement[0]; } CodeStatement s = Convert(embeddedStatement); if (s != null) @@ -170,6 +191,8 @@ namespace ICSharpCode.NRefactory.CSharp string MakeSnippet(AstNode node) { + if (!AllowSnippetNodes) + throw new NotSupportedException(); StringWriter w = new StringWriter(); CSharpOutputVisitor v = new CSharpOutputVisitor(w, FormattingOptionsFactory.CreateMono ()); node.AcceptVisitor(v); @@ -371,7 +394,7 @@ namespace ICSharpCode.NRefactory.CSharp TypeResolveResult trr = rr as TypeResolveResult; if (trr != null) { CodeTypeReference typeRef; - if (useFullyQualifiedTypeNames) { + if (UseFullyQualifiedTypeNames) { typeRef = Convert(trr.Type); } else { typeRef = new CodeTypeReference(identifierExpression.Identifier); @@ -380,7 +403,7 @@ namespace ICSharpCode.NRefactory.CSharp return new CodeTypeReferenceExpression(typeRef); } MethodGroupResolveResult mgrr = rr as MethodGroupResolveResult; - if (mgrr != null) { + if (mgrr != null || identifierExpression.TypeArguments.Any()) { return new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), identifierExpression.Identifier, Convert(identifierExpression.TypeArguments)); } return new CodeVariableReferenceExpression(identifierExpression.Identifier); @@ -635,7 +658,7 @@ namespace ICSharpCode.NRefactory.CSharp foreach (Expression expr in attribute.Arguments) { NamedExpression ne = expr as NamedExpression; if (ne != null) - attr.Arguments.Add(new CodeAttributeArgument(ne.Identifier, Convert(ne.Expression))); + attr.Arguments.Add(new CodeAttributeArgument(ne.Name, Convert(ne.Expression))); else attr.Arguments.Add(new CodeAttributeArgument(Convert(expr))); } @@ -658,7 +681,7 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration) { CodeTypeDelegate d = new CodeTypeDelegate(delegateDeclaration.Name); - d.Attributes = ConvertMemberAttributes(delegateDeclaration.Modifiers); + d.Attributes = ConvertMemberAttributes(delegateDeclaration.Modifiers, EntityType.TypeDefinition); d.CustomAttributes.AddRange(Convert(delegateDeclaration.Attributes)); d.ReturnType = Convert(delegateDeclaration.ReturnType); d.Parameters.AddRange(Convert(delegateDeclaration.Parameters)); @@ -666,13 +689,15 @@ namespace ICSharpCode.NRefactory.CSharp return d; } - static MemberAttributes ConvertMemberAttributes(Modifiers modifiers) + MemberAttributes ConvertMemberAttributes(Modifiers modifiers, EntityType entityType) { MemberAttributes a = 0; if ((modifiers & Modifiers.Abstract) != 0) a |= MemberAttributes.Abstract; if ((modifiers & Modifiers.Sealed) != 0) a |= MemberAttributes.Final; + if (entityType != EntityType.TypeDefinition && (modifiers & (Modifiers.Abstract | Modifiers.Override | Modifiers.Virtual)) == 0) + a |= MemberAttributes.Final; if ((modifiers & Modifiers.Static) != 0) a |= MemberAttributes.Static; if ((modifiers & Modifiers.Override) != 0) @@ -719,7 +744,7 @@ namespace ICSharpCode.NRefactory.CSharp { //bool isNestedType = typeStack.Count > 0; CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(typeDeclaration.Name); - typeDecl.Attributes = ConvertMemberAttributes(typeDeclaration.Modifiers); + typeDecl.Attributes = ConvertMemberAttributes(typeDeclaration.Modifiers, EntityType.TypeDefinition); typeDecl.CustomAttributes.AddRange(Convert(typeDeclaration.Attributes)); switch (typeDeclaration.ClassType) { @@ -809,7 +834,12 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitEmptyStatement(EmptyStatement emptyStatement) { - return null; + return EmptyStatement(); + } + + CodeStatement EmptyStatement() + { + return new CodeExpressionStatement(new CodeObjectCreateExpression(new CodeTypeReference(typeof(object)))); } CodeObject IAstVisitor.VisitExpressionStatement(ExpressionStatement expressionStatement) @@ -817,10 +847,55 @@ namespace ICSharpCode.NRefactory.CSharp AssignmentExpression assignment = expressionStatement.Expression as AssignmentExpression; if (assignment != null && assignment.Operator == AssignmentOperatorType.Assign) { return new CodeAssignStatement(Convert(assignment.Left), Convert(assignment.Right)); + } else if (assignment != null && CanBeDuplicatedForCompoundAssignment(assignment.Left)) { + CodeBinaryOperatorType op; + switch (assignment.Operator) { + case AssignmentOperatorType.Add: + op = CodeBinaryOperatorType.Add; + break; + case AssignmentOperatorType.Subtract: + op = CodeBinaryOperatorType.Subtract; + break; + case AssignmentOperatorType.Multiply: + op = CodeBinaryOperatorType.Multiply; + break; + case AssignmentOperatorType.Divide: + op = CodeBinaryOperatorType.Divide; + break; + case AssignmentOperatorType.Modulus: + op = CodeBinaryOperatorType.Modulus; + break; + case AssignmentOperatorType.BitwiseAnd: + op = CodeBinaryOperatorType.BitwiseAnd; + break; + case AssignmentOperatorType.BitwiseOr: + op = CodeBinaryOperatorType.BitwiseOr; + break; + default: + return MakeSnippetStatement(expressionStatement); + } + var cboe = new CodeBinaryOperatorExpression(Convert(assignment.Left), op, Convert(assignment.Right)); + return new CodeAssignStatement(Convert(assignment.Left), cboe); + } + UnaryOperatorExpression unary = expressionStatement.Expression as UnaryOperatorExpression; + if (unary != null && CanBeDuplicatedForCompoundAssignment(unary.Expression)) { + var op = unary.Operator; + if (op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement) { + var cboe = new CodeBinaryOperatorExpression(Convert(unary.Expression), CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1)); + return new CodeAssignStatement(Convert(unary.Expression), cboe); + } else if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement) { + var cboe = new CodeBinaryOperatorExpression(Convert(unary.Expression), CodeBinaryOperatorType.Subtract, new CodePrimitiveExpression(1)); + return new CodeAssignStatement(Convert(unary.Expression), cboe); + } } return new CodeExpressionStatement(Convert(expressionStatement.Expression)); } + bool CanBeDuplicatedForCompoundAssignment(Expression expr) + { + return expr is IdentifierExpression; + } + CodeObject IAstVisitor.VisitFixedStatement(FixedStatement fixedStatement) { return MakeSnippetStatement(fixedStatement); @@ -956,7 +1031,7 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitWhileStatement(WhileStatement whileStatement) { - return new CodeIterationStatement(null, Convert(whileStatement.Condition), null, ConvertEmbeddedStatement(whileStatement.EmbeddedStatement)); + return new CodeIterationStatement(EmptyStatement(), Convert(whileStatement.Condition), EmptyStatement(), ConvertEmbeddedStatement(whileStatement.EmbeddedStatement)); } CodeObject IAstVisitor.VisitYieldBreakStatement(YieldBreakStatement yieldBreakStatement) @@ -977,7 +1052,7 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration) { CodeConstructor ctor = new CodeConstructor(); - ctor.Attributes = ConvertMemberAttributes(constructorDeclaration.Modifiers); + ctor.Attributes = ConvertMemberAttributes(constructorDeclaration.Modifiers, EntityType.Constructor); ctor.CustomAttributes.AddRange(Convert(constructorDeclaration.Attributes)); if (constructorDeclaration.Initializer.ConstructorInitializerType == ConstructorInitializerType.This) { ctor.ChainedConstructorArgs.AddRange(Convert(constructorDeclaration.Initializer.Arguments)); @@ -1019,7 +1094,7 @@ namespace ICSharpCode.NRefactory.CSharp } CodeMemberEvent e = new CodeMemberEvent(); - e.Attributes = ConvertMemberAttributes(eventDeclaration.Modifiers); + e.Attributes = ConvertMemberAttributes(eventDeclaration.Modifiers, EntityType.Event); e.CustomAttributes.AddRange(Convert(eventDeclaration.Attributes)); e.Name = vi.Name; e.Type = Convert(eventDeclaration.ReturnType); @@ -1037,7 +1112,7 @@ namespace ICSharpCode.NRefactory.CSharp { foreach (VariableInitializer vi in fieldDeclaration.Variables) { CodeMemberField f = new CodeMemberField(Convert(fieldDeclaration.ReturnType), vi.Name); - f.Attributes = ConvertMemberAttributes(fieldDeclaration.Modifiers); + f.Attributes = ConvertMemberAttributes(fieldDeclaration.Modifiers, EntityType.Field); f.CustomAttributes.AddRange(Convert(fieldDeclaration.Attributes)); f.InitExpression = ConvertVariableInitializer(vi.Initializer, fieldDeclaration.ReturnType); AddTypeMember(f); @@ -1048,7 +1123,7 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration) { CodeMemberProperty p = new CodeMemberProperty(); - p.Attributes = ConvertMemberAttributes(indexerDeclaration.Modifiers); + p.Attributes = ConvertMemberAttributes(indexerDeclaration.Modifiers, EntityType.Indexer); p.CustomAttributes.AddRange(Convert(indexerDeclaration.Attributes)); p.Name = "Items"; p.PrivateImplementationType = Convert(indexerDeclaration.PrivateImplementationType); @@ -1069,7 +1144,7 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitMethodDeclaration(MethodDeclaration methodDeclaration) { CodeMemberMethod m = new CodeMemberMethod(); - m.Attributes = ConvertMemberAttributes(methodDeclaration.Modifiers); + m.Attributes = ConvertMemberAttributes(methodDeclaration.Modifiers, EntityType.Method); m.CustomAttributes.AddRange(Convert(methodDeclaration.Attributes.Where(a => a.AttributeTarget != "return"))); m.ReturnTypeCustomAttributes.AddRange(Convert(methodDeclaration.Attributes.Where(a => a.AttributeTarget == "return"))); @@ -1087,7 +1162,7 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration) { CodeMemberMethod m = new CodeMemberMethod(); - m.Attributes = ConvertMemberAttributes(operatorDeclaration.Modifiers); + m.Attributes = ConvertMemberAttributes(operatorDeclaration.Modifiers, EntityType.Method); m.CustomAttributes.AddRange(Convert(operatorDeclaration.Attributes.Where(a => a.AttributeTarget != "return"))); m.ReturnTypeCustomAttributes.AddRange(Convert(operatorDeclaration.Attributes.Where(a => a.AttributeTarget == "return"))); @@ -1129,7 +1204,7 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { CodeMemberProperty p = new CodeMemberProperty(); - p.Attributes = ConvertMemberAttributes(propertyDeclaration.Modifiers); + p.Attributes = ConvertMemberAttributes(propertyDeclaration.Modifiers, EntityType.Property); p.CustomAttributes.AddRange(Convert(propertyDeclaration.Attributes)); p.Name = propertyDeclaration.Name; p.PrivateImplementationType = Convert(propertyDeclaration.PrivateImplementationType); @@ -1161,10 +1236,10 @@ namespace ICSharpCode.NRefactory.CSharp throw new NotSupportedException(); // should be handled by the parent node } - CodeObject IAstVisitor.VisitCompilationUnit(CompilationUnit compilationUnit) + CodeObject IAstVisitor.VisitSyntaxTree(SyntaxTree syntaxTree) { CodeCompileUnit cu = new CodeCompileUnit(); - foreach (AstNode node in compilationUnit.Children) { + foreach (AstNode node in syntaxTree.Children) { CodeObject o = node.AcceptVisitor(this); CodeNamespace ns = o as CodeNamespace; @@ -1181,7 +1256,7 @@ namespace ICSharpCode.NRefactory.CSharp CodeObject IAstVisitor.VisitSimpleType(SimpleType simpleType) { - if (useFullyQualifiedTypeNames) { + if (UseFullyQualifiedTypeNames) { IType type = Resolve(simpleType).Type; if (type.Kind != TypeKind.Unknown) return Convert(type); @@ -1198,7 +1273,7 @@ namespace ICSharpCode.NRefactory.CSharp tr.TypeArguments.AddRange(Convert(memberType.TypeArguments)); return tr; } - if (useFullyQualifiedTypeNames || memberType.IsDoubleColon) { + if (UseFullyQualifiedTypeNames || memberType.IsDoubleColon) { IType type = Resolve(memberType).Type; if (type.Kind != TypeKind.Unknown) return Convert(type); @@ -1309,7 +1384,7 @@ namespace ICSharpCode.NRefactory.CSharp return null; } - CodeObject IAstVisitor.VisitPatternPlaceholder(AstNode placeholder, ICSharpCode.NRefactory.PatternMatching.Pattern pattern) + CodeObject IAstVisitor.VisitPatternPlaceholder(AstNode placeholder, Pattern pattern) { return null; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs index 3c6929bae..2ac9f86e4 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs @@ -36,12 +36,14 @@ namespace ICSharpCode.NRefactory.CSharp { public class CSharpParser { + CompilerSettings compilerSettings; + class ConversionVisitor : StructuralVisitor { - CompilationUnit unit = new CompilationUnit (); + SyntaxTree unit = new SyntaxTree (); internal bool convertTypeSystemMode; - public CompilationUnit Unit { + public SyntaxTree Unit { get { return unit; } @@ -177,7 +179,7 @@ namespace ICSharpCode.NRefactory.CSharp } return result; } - + AstType ConvertToType (Mono.CSharp.Expression typeName) { if (typeName == null) // may happen in typeof(Generic<,,,,>) @@ -190,7 +192,7 @@ namespace ICSharpCode.NRefactory.CSharp if (typeName is Mono.CSharp.QualifiedAliasMember) { var qam = (Mono.CSharp.QualifiedAliasMember)typeName; - var memberType = new MemberType (); + var memberType = new MemberType (); memberType.Target = new SimpleType (qam.alias, Convert (qam.Location)); memberType.IsDoubleColon = true; memberType.MemberName = qam.Name; @@ -244,12 +246,12 @@ namespace ICSharpCode.NRefactory.CSharp if (typeName is SpecialContraintExpr) { var sce = (SpecialContraintExpr)typeName; switch (sce.Constraint) { - case SpecialConstraint.Class: - return new PrimitiveType ("class", Convert (sce.Location)); - case SpecialConstraint.Struct: - return new PrimitiveType ("struct", Convert (sce.Location)); - case SpecialConstraint.Constructor: - return new PrimitiveType ("new", Convert (sce.Location)); + case SpecialConstraint.Class: + return new PrimitiveType ("class", Convert (sce.Location)); + case SpecialConstraint.Struct: + return new PrimitiveType ("struct", Convert (sce.Location)); + case SpecialConstraint.Constructor: + return new PrimitiveType ("new", Convert (sce.Location)); } } return new SimpleType ("unknown"); @@ -267,7 +269,7 @@ namespace ICSharpCode.NRefactory.CSharp int pos = 0; if (loc != null) result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.LPar); - + if (attr.PositionalArguments != null) { foreach (var arg in attr.PositionalArguments) { var na = arg as NamedArgument; @@ -289,7 +291,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.Comma); } } - if (attr.NamedArguments != null) { + if (attr.NamedArguments != null) { foreach (NamedArgument na in attr.NamedArguments) { var newArg = new NamedExpression (); newArg.AddChild (Identifier.Create (na.Name, Convert (na.Location)), Roles.Identifier); @@ -333,12 +335,16 @@ namespace ICSharpCode.NRefactory.CSharp if (loc != null && pos < loc.Count) result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.Colon); } - + + int attributeCount = 0; foreach (var attr in GetAttributes (optAttributes)) { result.AddChild (attr, Roles.Attribute); + attributeCount++; } + // Left and right bracket + commas between the attributes + int locCount = 2 + attributeCount - 1; // optional comma - if (loc != null && pos < loc.Count - 1 && !loc [pos].Equals (loc [pos + 1])) + if (loc != null && pos < loc.Count - 1 && loc.Count == locCount + 1) result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.Comma); if (loc != null && pos < loc.Count) result.AddChild (new CSharpTokenNode (Convert (loc [pos++])), Roles.RBracket); @@ -387,13 +393,13 @@ namespace ICSharpCode.NRefactory.CSharp } // public override void Visit (UsingsBag.Namespace nspace) // { -// -// +// +// // VisitNamespaceUsings (nspace); // VisitNamespaceBody (nspace); -// +// // } -// +// void ConvertNamespaceName (MemberName memberName, NamespaceDeclaration namespaceDecl) { AstNode insertPos = null; @@ -439,7 +445,7 @@ namespace ICSharpCode.NRefactory.CSharp ud.AddChild (new CSharpTokenNode (Convert (loc [1])), Roles.Semicolon); AddToNamespace (ud); } - + public override void Visit (UsingExternAlias uea) { var ud = new ExternAliasDeclaration (); @@ -666,7 +672,7 @@ namespace ICSharpCode.NRefactory.CSharp if (namespaceStack.Count > 0) { namespaceStack.Peek ().AddChild (child, NamespaceDeclaration.MemberRole); } else { - unit.AddChild (child, CompilationUnit.MemberRole); + unit.AddChild (child, SyntaxTree.MemberRole); } } @@ -680,23 +686,28 @@ namespace ICSharpCode.NRefactory.CSharp AddModifiers(newType, location); int curLoc = 0; 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); + 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++])), Roles.Colon); - newType.AddChild (ConvertToType (e.BaseTypeExpression), Roles.BaseType); + 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++])), Roles.LBrace); - typeStack.Push (newType); + newType.AddChild(new CSharpTokenNode(Convert(location [curLoc++])), Roles.LBrace); + typeStack.Push(newType); - foreach (EnumMember member in e.Members) { - Visit (member); + foreach (var m in e.Members) { + EnumMember member = m as EnumMember; + if (member == null) { + Console.WriteLine("WARNING - ENUM MEMBER: " + m); + continue; + } + Visit(member); if (location != null && curLoc < location.Count - 1) //last one is closing brace - newType.AddChild (new CSharpTokenNode (Convert (location [curLoc++])), Roles.Comma); + newType.AddChild(new CSharpTokenNode(Convert(location [curLoc++])), Roles.Comma); } if (location != null && location.Count > 2) { @@ -733,12 +744,13 @@ namespace ICSharpCode.NRefactory.CSharp public override void Visit (FixedField f) { var location = LocationsBag.GetMemberLocation (f); + int locationIdx = 0; var newField = new FixedFieldDeclaration (); AddAttributeSection (newField, f); AddModifiers (newField, location); if (location != null && location.Count > 0) - newField.AddChild (new CSharpTokenNode (Convert (location [0])), FixedFieldDeclaration.FixedKeywordRole); + newField.AddChild (new CSharpTokenNode (Convert (location [locationIdx++])), FixedFieldDeclaration.FixedKeywordRole); if (f.TypeExpression != null) newField.AddChild (ConvertToType (f.TypeExpression), Roles.Type); @@ -749,7 +761,7 @@ namespace ICSharpCode.NRefactory.CSharp var bracketLocations = LocationsBag.GetLocations (f.Initializer); if (bracketLocations != null && bracketLocations.Count > 1) variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0])), Roles.LBracket); - + variable.AddChild ((Expression)f.Initializer.Accept (this), Roles.Expression); if (bracketLocations != null && bracketLocations.Count > 1) variable.AddChild (new CSharpTokenNode (Convert (bracketLocations [0])), Roles.RBracket); @@ -775,8 +787,8 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (variable, FixedFieldDeclaration.VariableRole); } } - if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Semicolon); + if (location != null && location.Count > locationIdx) + newField.AddChild (new CSharpTokenNode (Convert (location [locationIdx])), Roles.Semicolon); typeStack.Peek ().AddChild (newField, Roles.TypeMemberRole); } @@ -792,10 +804,10 @@ namespace ICSharpCode.NRefactory.CSharp VariableInitializer variable = new VariableInitializer (); variable.AddChild (Identifier.Create (f.MemberName.Name, Convert (f.MemberName.Location)), Roles.Identifier); - + int locationIdx = 0; if (f.Initializer != null) { if (location != null) - variable.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Assign); + variable.AddChild (new CSharpTokenNode (Convert (location [locationIdx++])), Roles.Assign); variable.AddChild ((Expression)f.Initializer.Accept (this), Roles.Expression); } newField.AddChild (variable, Roles.Variable); @@ -815,8 +827,8 @@ namespace ICSharpCode.NRefactory.CSharp newField.AddChild (variable, Roles.Variable); } } - if (location != null) - newField.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1])), Roles.Semicolon); + if (location != null &&location.Count > locationIdx) + newField.AddChild (new CSharpTokenNode (Convert (location [locationIdx++])), Roles.Semicolon); typeStack.Peek ().AddChild (newField, Roles.TypeMemberRole); } @@ -1056,7 +1068,7 @@ namespace ICSharpCode.NRefactory.CSharp modifierTable [Mono.CSharp.Modifiers.ASYNC] = ICSharpCode.NRefactory.CSharp.Modifiers.Async; keywordTable = new string[255]; - for (int i = 0; i< keywordTable.Length; i++) + for (int i = 0; i< keywordTable.Length; i++) keywordTable [i] = "unknown"; keywordTable [(int)BuiltinTypeSpec.Type.Other] = "void"; @@ -1568,6 +1580,9 @@ namespace ICSharpCode.NRefactory.CSharp var expr = statementErrorExpression.Expr.Accept (this) as Expression; if (expr != null) result.AddChild ((Expression)expr, Roles.Expression); + var location = LocationsBag.GetLocations (statementErrorExpression); + if (location != null) + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Semicolon); return result; } @@ -2112,7 +2127,7 @@ namespace ICSharpCode.NRefactory.CSharp result.AddChild (new CSharpTokenNode (Convert (memberAccess.DotLocation)), Roles.Dot); } } - + result.AddChild (Identifier.Create (memberAccess.Name, Convert (memberAccess.Location)), Roles.Identifier); AddTypeArguments (result, memberAccess); @@ -2131,7 +2146,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (Constant constant) { - if (constant.GetValue () == null) + if (constant.GetValue () == null) return new NullReferenceExpression (Convert (constant.Location)); string literalValue; if (constant is ILiteralConstant) { @@ -2176,21 +2191,21 @@ 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; + 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) @@ -2205,27 +2220,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, 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.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)), 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; + 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; @@ -2321,65 +2336,67 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new BinaryOperatorExpression (); 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; - 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; + 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)), BinaryOperatorExpression.GetOperatorRole (result.Operator)); + var location = LocationsBag.GetLocations (binaryExpression); + if (location != null) + result.AddChild (new CSharpTokenNode (Convert (location[0])), BinaryOperatorExpression.GetOperatorRole (result.Operator)); if (binaryExpression.Right != null) result.AddChild ((Expression)binaryExpression.Right.Accept (this), BinaryOperatorExpression.RightRole); return result; @@ -2391,7 +2408,9 @@ 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)), BinaryOperatorExpression.NullCoalescingRole); + var location = LocationsBag.GetLocations (nullCoalescingOperator); + if (location != null) + result.AddChild (new CSharpTokenNode (Convert (location[0])), BinaryOperatorExpression.NullCoalescingRole); if (nullCoalescingOperator.RightExpression != null) result.AddChild ((Expression)nullCoalescingOperator.RightExpression.Accept (this), BinaryOperatorExpression.RightRole); return result; @@ -2429,29 +2448,29 @@ namespace ICSharpCode.NRefactory.CSharp ParameterDeclaration parameterDeclarationExpression = new ParameterDeclaration (); AddAttributeSection (parameterDeclarationExpression, p); switch (p.ModFlags) { - case Parameter.Modifier.OUT: - parameterDeclarationExpression.ParameterModifier = ParameterModifier.Out; - if (location != null) - 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])), ParameterDeclaration.RefModifierRole); - break; - case Parameter.Modifier.PARAMS: - parameterDeclarationExpression.ParameterModifier = ParameterModifier.Params; - if (location != null) - 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])), ParameterDeclaration.ThisModifierRole); + case Parameter.Modifier.OUT: + parameterDeclarationExpression.ParameterModifier = ParameterModifier.Out; + if (location != null) + 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])), ParameterDeclaration.RefModifierRole); + break; + case Parameter.Modifier.PARAMS: + parameterDeclarationExpression.ParameterModifier = ParameterModifier.Params; + if (location != null) + 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])), ParameterDeclaration.ThisModifierRole); + } } - } - break; + break; } if (p.TypeExpression != null) // lambdas may have no types (a, b) => ... parameterDeclarationExpression.AddChild (ConvertToType (p.TypeExpression), Roles.Type); @@ -2486,33 +2505,33 @@ namespace ICSharpCode.NRefactory.CSharp List varianceLocation; switch (arg.Variance) { - case Variance.Contravariant: - tp.Variance = VarianceModifier.Contravariant; - varianceLocation = LocationsBag.GetLocations (arg); - if (varianceLocation != null) - 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])), TypeParameterDeclaration.OutVarianceKeywordRole); - break; - default: - tp.Variance = VarianceModifier.Invariant; - break; - + case Variance.Contravariant: + tp.Variance = VarianceModifier.Contravariant; + varianceLocation = LocationsBag.GetLocations (arg); + if (varianceLocation != null) + 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])), TypeParameterDeclaration.OutVarianceKeywordRole); + break; + default: + tp.Variance = VarianceModifier.Invariant; + break; + } 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)), Roles.Identifier); parent.AddChild (tp, Roles.TypeParameter); @@ -2684,94 +2703,117 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (NewAnonymousType newAnonymousType) { var result = new AnonymousTypeCreateExpression (); - if (newAnonymousType.Parameters == null) - return result; - foreach (var par in newAnonymousType.Parameters) { - if (par == null) - continue; - var location = LocationsBag.GetLocations (par); - - if (location == null) { - if (par.Expr != null) - result.AddChild ((Expression)par.Expr.Accept (this), Roles.Expression); - } else { - var namedExpression = new NamedExpression (); - 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), Roles.Expression); - result.AddChild (namedExpression, Roles.Expression); + var location = LocationsBag.GetLocations (newAnonymousType); + result.AddChild (new CSharpTokenNode (Convert (newAnonymousType.Location)), ObjectCreateExpression.NewKeywordRole); + if (location != null) + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.LBrace); + if (newAnonymousType.Parameters != null) { + foreach (var par in newAnonymousType.Parameters) { + if (par == null) + continue; + var parLocation = LocationsBag.GetLocations (par); + + if (parLocation == null) { + if (par.Expr != null) + result.AddChild ((Expression)par.Expr.Accept (this), Roles.Expression); + } else { + var namedExpression = new NamedExpression (); + namedExpression.AddChild (Identifier.Create (par.Name, Convert (par.Location)), Roles.Identifier); + namedExpression.AddChild (new CSharpTokenNode (Convert (parLocation [0])), Roles.Assign); + if (par.Expr != null) + namedExpression.AddChild ((Expression)par.Expr.Accept (this), Roles.Expression); + result.AddChild (namedExpression, Roles.Expression); + } } } + if (location != null && location.Count > 1) + result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.RBrace); return result; } - - ArrayInitializerExpression ConvertCollectionOrObjectInitializers (CollectionOrObjectInitializers minit) + + ArrayInitializerExpression ConvertCollectionOrObjectInitializers(CollectionOrObjectInitializers minit) { if (minit == null) return null; - var init = new ArrayInitializerExpression (); - AddConvertCollectionOrObjectInitializers (init, minit); + var init = new ArrayInitializerExpression(); + AddConvertCollectionOrObjectInitializers(init, minit); return init; } - - void AddConvertCollectionOrObjectInitializers (Expression init, CollectionOrObjectInitializers minit) + + void AddConvertCollectionOrObjectInitializers(Expression init, CollectionOrObjectInitializers minit) { - var initLoc = LocationsBag.GetLocations (minit); - var commaLoc = LocationsBag.GetLocations (minit.Initializers); + var initLoc = LocationsBag.GetLocations(minit); + var commaLoc = LocationsBag.GetLocations(minit.Initializers); int curComma = 0; if (initLoc != null) - init.AddChild (new CSharpTokenNode (Convert (initLoc [0])), 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 (); - - parent.AddChild (new CSharpTokenNode (Convert (expr.Location)), Roles.LBrace); - + AstNode parent; + // For ease of use purposes in the resolver the ast representation + // of { a, b, c } is { {a}, {b}, {c} } - but the generated ArrayInitializerExpression + // can be identified by expr.IsSingleElement. + if (!collectionInit.IsSingle) { + parent = new ArrayInitializerExpression(); + parent.AddChild(new CSharpTokenNode(Convert(collectionInit.Location)), Roles.LBrace); + } else { + parent = ArrayInitializerExpression.CreateSingleElementInitializer (); + } 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), 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 [0])), Roles.RBrace); - - init.AddChild (parent, Roles.Expression); + + if (!collectionInit.IsSingle) { + var braceLocs = LocationsBag.GetLocations(expr); + if (braceLocs != null) + parent.AddChild(new CSharpTokenNode(Convert(braceLocs [0])), Roles.RBrace); + } + init.AddChild((ArrayInitializerExpression)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)), Roles.Identifier); - var assignLoc = LocationsBag.GetLocations (eleInit); + var nexpr = new NamedExpression(); + 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])), 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, Roles.Expression); + var arrInit = new ArrayInitializerExpression(); + AddConvertCollectionOrObjectInitializers( + arrInit, + eleInit.Source as CollectionOrObjectInitializers + ); + nexpr.AddChild(arrInit, Roles.Expression); } else { - nexpr.AddChild ((Expression)eleInit.Source.Accept (this), Roles.Expression); + nexpr.AddChild((Expression)eleInit.Source.Accept(this), Roles.Expression); } } - - init.AddChild (nexpr, Roles.Expression); + + init.AddChild(nexpr, Roles.Expression); } } if (commaLoc != null && curComma < commaLoc.Count) - init.AddChild (new CSharpTokenNode (Convert (commaLoc [curComma++])), 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])), Roles.Comma); - init.AddChild (new CSharpTokenNode (Convert (initLoc [initLoc.Count - 1])), 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) { @@ -2803,7 +2845,7 @@ namespace ICSharpCode.NRefactory.CSharp 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) { // skip first array rank. @@ -2833,7 +2875,7 @@ namespace ICSharpCode.NRefactory.CSharp next = next.Next; } - if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Count != 0) { + if (arrayCreationExpression.Initializers != null) { var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers); ArrayInitializerExpression initializer = new ArrayInitializerExpression (); @@ -2848,9 +2890,11 @@ namespace ICSharpCode.NRefactory.CSharp initializer.AddChild (new CSharpTokenNode (Convert (commaLocations [i])), Roles.Comma); } } - - if (initLocation != null) + if (initLocation != null) { + if (initLocation.Count == 2) // optional comma + initializer.AddChild (new CSharpTokenNode(Convert(initLocation [0])), Roles.Comma); initializer.AddChild (new CSharpTokenNode (Convert (initLocation [initLocation.Count - 1])), Roles.RBrace); + } result.AddChild (initializer, ArrayCreateExpression.InitializerRole); } @@ -3042,7 +3086,9 @@ 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)), AssignmentExpression.AssignRole); + var location = LocationsBag.GetLocations (simpleAssign); + if (location != null) + result.AddChild (new CSharpTokenNode (Convert (location[0])), AssignmentExpression.AssignRole); if (simpleAssign.Source != null) { result.AddChild ((Expression)simpleAssign.Source.Accept (this), AssignmentExpression.RightRole); } @@ -3053,41 +3099,43 @@ namespace ICSharpCode.NRefactory.CSharp { var result = new AssignmentExpression (); 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; - 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; + 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)), AssignmentExpression.GetOperatorRole (result.Operator)); + var location = LocationsBag.GetLocations (compoundAssign); + if (location != null) + result.AddChild (new CSharpTokenNode (Convert (location[0])), AssignmentExpression.GetOperatorRole (result.Operator)); if (compoundAssign.Source != null) result.AddChild ((Expression)compoundAssign.Source.Accept (this), AssignmentExpression.RightRole); return result; @@ -3173,7 +3221,7 @@ namespace ICSharpCode.NRefactory.CSharp if (location != null) { if (location.Count == 2) // optional comma - result.AddChild (new CSharpTokenNode (Convert (location [1])), Roles.Comma); + result.AddChild (new CSharpTokenNode (Convert (location [0])), Roles.Comma); result.AddChild (new CSharpTokenNode (Convert (location [location.Count - 1])), Roles.RBrace); } return result; @@ -3182,25 +3230,36 @@ namespace ICSharpCode.NRefactory.CSharp #endregion #region LINQ expressions + QueryOrderClause currentQueryOrderClause; + public override object Visit (Mono.CSharp.Linq.QueryExpression queryExpression) { - var result = new QueryExpression (); - - var currentClause = queryExpression.next; - - while (currentClause != null) { - QueryClause clause = (QueryClause)currentClause.Accept (this); - if (clause is QueryContinuationClause) { - // insert preceding query at beginning of QueryContinuationClause - clause.InsertChildAfter (null, result, QueryContinuationClause.PrecedingQueryRole); - // create a new QueryExpression for the remaining query - result = new QueryExpression (); + var oldQueryOrderClause = currentQueryOrderClause; + try { + currentQueryOrderClause = null; + var result = new QueryExpression (); + + var currentClause = queryExpression.next; + + while (currentClause != null) { + QueryClause clause = (QueryClause)currentClause.Accept (this); + if (clause is QueryContinuationClause) { + // insert preceding query at beginning of QueryContinuationClause + clause.InsertChildAfter (null, result, QueryContinuationClause.PrecedingQueryRole); + // create a new QueryExpression for the remaining query + result = new QueryExpression (); + } + if (clause != null) { + result.AddChild (clause, QueryExpression.ClauseRole); + } + currentClause = currentClause.next; } - result.AddChild (clause, QueryExpression.ClauseRole); - currentClause = currentClause.next; + + return result; + } + finally { + currentQueryOrderClause = oldQueryOrderClause; } - - return result; } public override object Visit (Mono.CSharp.Linq.QueryStartClause queryStart) @@ -3366,7 +3425,7 @@ namespace ICSharpCode.NRefactory.CSharp public override object Visit (Mono.CSharp.Linq.OrderByAscending orderByAscending) { - var result = new QueryOrderClause (); + currentQueryOrderClause = new QueryOrderClause(); var ordering = new QueryOrdering (); if (orderByAscending.Expr != null) @@ -3376,13 +3435,13 @@ namespace ICSharpCode.NRefactory.CSharp ordering.Direction = QueryOrderingDirection.Ascending; ordering.AddChild (new CSharpTokenNode (Convert (location [0])), QueryOrdering.AscendingKeywordRole); } - result.AddChild (ordering, QueryOrderClause.OrderingRole); - return result; + currentQueryOrderClause.AddChild (ordering, QueryOrderClause.OrderingRole); + return currentQueryOrderClause; } public override object Visit (Mono.CSharp.Linq.OrderByDescending orderByDescending) { - var result = new QueryOrderClause (); + currentQueryOrderClause = new QueryOrderClause (); var ordering = new QueryOrdering (); if (orderByDescending.Expr != null) @@ -3392,14 +3451,12 @@ namespace ICSharpCode.NRefactory.CSharp ordering.Direction = QueryOrderingDirection.Descending; ordering.AddChild (new CSharpTokenNode (Convert (location [0])), QueryOrdering.DescendingKeywordRole); } - result.AddChild (ordering, QueryOrderClause.OrderingRole); - return result; + currentQueryOrderClause.AddChild (ordering, QueryOrderClause.OrderingRole); + return currentQueryOrderClause; } public override object Visit (Mono.CSharp.Linq.ThenByAscending thenByAscending) { - var result = new QueryOrderClause (); - var ordering = new QueryOrdering (); if (thenByAscending.Expr != null) ordering.AddChild ((Expression)thenByAscending.Expr.Accept (this), Roles.Expression); @@ -3408,14 +3465,12 @@ namespace ICSharpCode.NRefactory.CSharp ordering.Direction = QueryOrderingDirection.Ascending; ordering.AddChild (new CSharpTokenNode (Convert (location [0])), QueryOrdering.AscendingKeywordRole); } - result.AddChild (ordering, QueryOrderClause.OrderingRole); - return result; + currentQueryOrderClause.AddChild (ordering, QueryOrderClause.OrderingRole); + return null; } public override object Visit (Mono.CSharp.Linq.ThenByDescending thenByDescending) { - var result = new QueryOrderClause (); - var ordering = new QueryOrdering (); if (thenByDescending.Expr != null) ordering.AddChild ((Expression)thenByDescending.Expr.Accept (this), Roles.Expression); @@ -3424,8 +3479,8 @@ namespace ICSharpCode.NRefactory.CSharp ordering.Direction = QueryOrderingDirection.Descending; ordering.AddChild (new CSharpTokenNode (Convert (location [0])), QueryOrdering.DescendingKeywordRole); } - result.AddChild (ordering, QueryOrderClause.OrderingRole); - return result; + currentQueryOrderClause.AddChild (ordering, QueryOrderClause.OrderingRole); + return null; } public override object Visit (Await awaitExpr) @@ -3438,17 +3493,83 @@ namespace ICSharpCode.NRefactory.CSharp return result; } #endregion + + #region XmlDoc + public DocumentationReference ConvertXmlDoc(DocumentationBuilder doc) + { + DocumentationReference result = new DocumentationReference(); + if (doc.ParsedName != null) { + if (doc.ParsedName.Name == "") { + result.EntityType = EntityType.Indexer; + } else { + result.MemberName = doc.ParsedName.Name; + } + if (doc.ParsedName.Left != null) { + result.DeclaringType = ConvertToType(doc.ParsedName.Left); + } else if (doc.ParsedBuiltinType != null) { + result.DeclaringType = ConvertToType(doc.ParsedBuiltinType); + } + if (doc.ParsedName.TypeParameters != null) { + for (int i = 0; i < doc.ParsedName.TypeParameters.Count; i++) { + result.TypeArguments.Add(ConvertToType(doc.ParsedName.TypeParameters[i])); + } + } + } else if (doc.ParsedBuiltinType != null) { + result.EntityType = EntityType.TypeDefinition; + result.DeclaringType = ConvertToType(doc.ParsedBuiltinType); + } + if (doc.ParsedParameters != null) { + result.HasParameterList = true; + result.Parameters.AddRange(doc.ParsedParameters.Select(ConvertXmlDocParameter)); + } + if (doc.ParsedOperator != null) { + result.EntityType = EntityType.Operator; + result.OperatorType = (OperatorType)doc.ParsedOperator; + if (result.OperatorType == OperatorType.Implicit || result.OperatorType == OperatorType.Explicit) { + var returnTypeParam = result.Parameters.LastOrNullObject(); + returnTypeParam.Remove(); // detach from parameter list + var returnType = returnTypeParam.Type; + returnType.Remove(); + result.ConversionOperatorReturnType = returnType; + } + if (result.Parameters.Count == 0) { + // reset HasParameterList if necessary + result.HasParameterList = false; + } + } + return result; + } + + ParameterDeclaration ConvertXmlDocParameter(DocumentationParameter p) + { + ParameterDeclaration result = new ParameterDeclaration(); + switch (p.Modifier) { + case Parameter.Modifier.OUT: + result.ParameterModifier = ParameterModifier.Out; + break; + case Parameter.Modifier.REF: + result.ParameterModifier = ParameterModifier.Ref; + break; + case Parameter.Modifier.PARAMS: + result.ParameterModifier = ParameterModifier.Params; + break; + } + if (p.Type != null) { + result.Type = ConvertToType(p.Type); + } + return result; + } + #endregion } public CSharpParser () { - CompilerSettings = new CompilerSettings (); - CompilerSettings.Unsafe = true; + compilerSettings = new CompilerSettings(); } public CSharpParser (CompilerSettings args) { - CompilerSettings = args; + compilerSettings = args ?? new CompilerSettings(); } static AstNode GetOuterLeft (AstNode node) @@ -3489,8 +3610,8 @@ namespace ICSharpCode.NRefactory.CSharp 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 = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content + StartsLine = comment.StartsLine, + Content = isMultilineDocumentationComment ? comment.Content.Substring(1) : comment.Content }; } else { var directive = special as SpecialsBag.PreProcessorDirective; @@ -3569,6 +3690,7 @@ namespace ICSharpCode.NRefactory.CSharp } ErrorReportPrinter errorReportPrinter = new ErrorReportPrinter (null); + [Obsolete("Use the Errors/Warnings/ErrorsAndWarnings properties instead")] public ErrorReportPrinter ErrorPrinter { get { return errorReportPrinter; @@ -3587,28 +3709,50 @@ namespace ICSharpCode.NRefactory.CSharp } } - public CompilationUnit Parse (ITextSource textSource, string fileName, int lineModifier = 0) + public IEnumerable Errors { + get { + return errorReportPrinter.Errors.Where(e => e.ErrorType == ErrorType.Error); + } + } + + public IEnumerable Warnings { + get { + return errorReportPrinter.Errors.Where(e => e.ErrorType == ErrorType.Warning); + } + } + + public IEnumerable ErrorsAndWarnings { + get { return errorReportPrinter.Errors; } + } + + /// + /// Parses a C# code file. + /// + /// The source code to parse. + /// The file name. Used to identify the file (e.g. when building a type system). + /// This can be an arbitrary identifier, NRefactory never tries to access the file on disk. + /// Returns the syntax tree. + public SyntaxTree Parse (string program, string fileName = "") { - return Parse (textSource.CreateReader (), fileName, lineModifier); + return Parse (new StringTextSource (program), fileName); } - public CompilationUnit Parse (TextReader reader, string fileName, int lineModifier = 0) + /// + /// Parses a C# code file. + /// + /// The text reader containing the source code to parse. + /// The file name. Used to identify the file (e.g. when building a type system). + /// This can be an arbitrary identifier, NRefactory never tries to access the file on disk. + /// Returns the syntax tree. + public SyntaxTree Parse (TextReader reader, string fileName = "") { - // TODO: can we optimize this to avoid the text->stream->text roundtrip? - using (MemoryStream stream = new MemoryStream ()) { - StreamWriter w = new StreamWriter (stream, Encoding.UTF8); - char[] buffer = new char[2048]; - int read; - while ((read = reader.ReadBlock(buffer, 0, buffer.Length)) > 0) - w.Write (buffer, 0, read); - w.Flush (); // we can't close the StreamWriter because that would also close the MemoryStream - stream.Position = 0; - - return Parse (stream, fileName, lineModifier); - } + return Parse(new StringTextSource (reader.ReadToEnd ()), fileName); } - public CompilationUnit Parse(CompilerCompilationUnit top, string fileName, int lineModifier = 0) + /// + /// Converts a Mono.CSharp syntax tree into an NRefactory syntax tree. + /// + public SyntaxTree Parse(CompilerCompilationUnit top, string fileName) { if (top == null) { return null; @@ -3622,116 +3766,227 @@ namespace ICSharpCode.NRefactory.CSharp if (top.LastYYValue is Mono.CSharp.Expression) { conversionVisitor.Unit.TopExpression = ((Mono.CSharp.Expression)top.LastYYValue).Accept(conversionVisitor) as AstNode; } + conversionVisitor.Unit.FileName = fileName; + conversionVisitor.Unit.ConditionalSymbols = top.Conditionals.Concat (compilerSettings.ConditionalSymbols).ToArray (); return conversionVisitor.Unit; } public CompilerSettings CompilerSettings { - get; - internal set; + get { return compilerSettings; } + set { + if (value == null) + throw new ArgumentNullException(); + compilerSettings = value; + } } + /// + /// Callback that gets called with the Mono.CSharp syntax tree whenever some code is parsed. + /// public Action CompilationUnitCallback { get; set; } + /// + /// Specifies whether to run the parser in a special mode for generating the type system. + /// If this property is true, the syntax tree will only contain nodes relevant for the + /// call and might be missing other nodes (e.g. method bodies). + /// The default is false. + /// public bool GenerateTypeSystemMode { get; set; } - public CompilationUnit Parse (string program, string fileName) - { - return Parse (new StringReader (program), fileName); + TextLocation initialLocation = new TextLocation(1, 1); + + /// + /// Specifies the text location where parsing starts. + /// This property can be used when parsing a part of a file to make the locations of the AstNodes + /// refer to the position in the whole file. + /// The default is (1,1). + /// + public TextLocation InitialLocation { + get { return initialLocation; } + set { initialLocation = value; } } internal static object parseLock = new object (); - public CompilationUnit Parse(Stream stream, string fileName, int lineModifier = 0) + /// + /// Parses a C# code file. + /// + /// The stream containing the source code to parse. + /// The file name. Used to identify the file (e.g. when building a type system). + /// This can be an arbitrary identifier, NRefactory never tries to access the file on disk. + /// Returns the syntax tree. + public SyntaxTree Parse (Stream stream, string fileName = "") + { + return Parse (new StreamReader (stream), fileName); + } + + /// + /// Parses a C# code file. + /// + /// The source code to parse. + /// The file name. Used to identify the file (e.g. when building a type system). + /// This can be an arbitrary identifier, NRefactory never tries to access the file on disk. + /// + /// Returns the syntax tree. + public SyntaxTree Parse(ITextSource program, string fileName = "") + { + return Parse(program, fileName, initialLocation.Line, initialLocation.Column); + } + + SyntaxTree Parse(ITextSource program, string fileName, int initialLine, int initialColumn) { lock (parseLock) { errorReportPrinter = new ErrorReportPrinter (""); - var ctx = new CompilerContext (CompilerSettings, errorReportPrinter); + var ctx = new CompilerContext (compilerSettings.ToMono(), errorReportPrinter); ctx.Settings.TabSize = 1; - var reader = new SeekableStreamReader (stream, Encoding.UTF8); + var reader = new SeekableStreamReader (program); var file = new SourceFile (fileName, fileName, 0); Location.Initialize (new List (new [] { file })); var module = new ModuleContainer (ctx); - var parser = Driver.Parse (reader, file, module, lineModifier); - - var top = new CompilerCompilationUnit () { + var session = new ParserSession (); + session.LocationsBag = new LocationsBag (); + var report = new Report (ctx, errorReportPrinter); + var parser = Driver.Parse (reader, file, module, session, report, initialLine - 1, initialColumn - 1); + var top = new CompilerCompilationUnit () { ModuleCompiled = module, - LocationsBag = parser.LocationsBag, - SpecialsBag = parser.Lexer.sbag + LocationsBag = session.LocationsBag, + SpecialsBag = parser.Lexer.sbag, + Conditionals = parser.Lexer.SourceFile.Conditionals }; - var unit = Parse (top, fileName, lineModifier); + var unit = Parse (top, fileName); unit.Errors.AddRange (errorReportPrinter.Errors); CompilerCallableEntryPoint.Reset (); return unit; } } - public IEnumerable ParseTypeMembers (TextReader reader, int lineModifier = 0) + public IEnumerable ParseTypeMembers (string code) + { + return ParseTypeMembers(code, initialLocation.Line, initialLocation.Column); + } + + IEnumerable ParseTypeMembers (string code, int initialLine, int initialColumn) { - string code = "unsafe partial class MyClass { " + Environment.NewLine + reader.ReadToEnd () + "}"; - var cu = Parse (new StringReader (code), "parsed.cs", lineModifier - 1); - if (cu == null) + const string prefix = "unsafe partial class MyClass { "; + var syntaxTree = Parse (new StringTextSource (prefix + code + "}"), "parsed.cs", initialLine, initialColumn - prefix.Length); + if (syntaxTree == null) return Enumerable.Empty (); - var td = cu.Children.FirstOrDefault () as TypeDeclaration; - if (td != null) - return td.Members; + var td = syntaxTree.FirstChild as TypeDeclaration; + if (td != null) { + var members = td.Members.ToArray(); + // detach members from parent + foreach (var m in members) + m.Remove(); + return members; + } return Enumerable.Empty (); } - public IEnumerable ParseStatements (TextReader reader, int lineModifier = 0) + public IEnumerable ParseStatements (string code) { - string code = "void M() { " + Environment.NewLine + reader.ReadToEnd () + "}"; - var members = ParseTypeMembers (new StringReader (code), lineModifier - 1); + return ParseStatements(code, initialLocation.Line, initialLocation.Column); + } + + IEnumerable ParseStatements (string code, int initialLine, int initialColumn) + { + // the dummy method is async so that 'await' expressions are parsed as expected + const string prefix = "async void M() { "; + var members = ParseTypeMembers (prefix + code + "}", initialLine, initialColumn - prefix.Length); var method = members.FirstOrDefault () as MethodDeclaration; - if (method != null && method.Body != null) - return method.Body.Statements; + if (method != null && method.Body != null) { + var statements = method.Body.Statements.ToArray(); + // detach statements from parent + foreach (var st in statements) + st.Remove(); + return statements; + } return Enumerable.Empty (); } - public AstType ParseTypeReference (TextReader reader) + public AstType ParseTypeReference (string code) { - string code = reader.ReadToEnd () + " a;"; - var members = ParseTypeMembers (new StringReader (code)); + var members = ParseTypeMembers (code + " a;"); var field = members.FirstOrDefault () as FieldDeclaration; - if (field != null) - return field.ReturnType; + if (field != null) { + AstType type = field.ReturnType; + type.Remove(); + return type; + } return AstType.Null; } - public AstNode ParseExpression (TextReader reader) + public Expression ParseExpression (string code) { - var es = ParseStatements (new StringReader ("tmp = " + Environment.NewLine + reader.ReadToEnd () + ";"), -1).FirstOrDefault () as ExpressionStatement; + const string prefix = "tmp = "; + var statements = ParseStatements (prefix + code + ";", initialLocation.Line, initialLocation.Column - prefix.Length); + var es = statements.FirstOrDefault () as ExpressionStatement; if (es != null) { AssignmentExpression ae = es.Expression as AssignmentExpression; - if (ae != null) - return ae.Right; + if (ae != null) { + Expression expr = ae.Right; + expr.Remove(); + return expr; + } } - return null; + return Expression.Null; } + /* /// - /// Parses a file snippet; guessing what the code snippet represents (compilation unit, type members, block, type reference, expression). + /// Parses a file snippet; guessing what the code snippet represents (whole file, type members, block, type reference, expression). /// - public AstNode ParseSnippet (TextReader reader) + public AstNode ParseSnippet (string code) { // TODO: add support for parsing a part of a file throw new NotImplementedException (); } + */ public DocumentationReference ParseDocumentationReference (string cref) { + // see Mono.CSharp.DocumentationBuilder.HandleXrefCommon if (cref == null) throw new ArgumentNullException ("cref"); + + // Additional symbols for < and > are allowed for easier XML typing cref = cref.Replace ('{', '<').Replace ('}', '>'); - // TODO: add support for parsing cref attributes - // (documentation_parsing production, see DocumentationBuilder.HandleXrefCommon) - throw new NotImplementedException (); + + lock (parseLock) { + errorReportPrinter = new ErrorReportPrinter(""); + var ctx = new CompilerContext(compilerSettings.ToMono(), errorReportPrinter); + ctx.Settings.TabSize = 1; + var reader = new SeekableStreamReader(new StringTextSource (cref)); + var file = new SourceFile("", "", 0); + Location.Initialize(new List (new [] { file })); + var module = new ModuleContainer(ctx); + module.DocumentationBuilder = new DocumentationBuilder(module); + var source_file = new CompilationSourceFile (module); + var report = new Report (ctx, errorReportPrinter); + ParserSession session = new ParserSession (); + session.LocationsBag = new LocationsBag (); + var parser = new Mono.CSharp.CSharpParser (reader, source_file, report, session); + parser.Lexer.Line += initialLocation.Line - 1; + parser.Lexer.Column += initialLocation.Column - 1; + parser.Lexer.putback_char = Tokenizer.DocumentationXref; + parser.Lexer.parsing_generic_declaration_doc = true; + parser.parse (); + if (report.Errors > 0) { +// Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'", +// mc.GetSignatureForError (), cref); + } + + ConversionVisitor conversionVisitor = new ConversionVisitor (false, session.LocationsBag); + DocumentationReference docRef = conversionVisitor.ConvertXmlDoc(module.DocumentationBuilder); + CompilerCallableEntryPoint.Reset(); + return docRef; + } } } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/CompilerSettings.cs b/ICSharpCode.NRefactory.CSharp/Parser/CompilerSettings.cs new file mode 100644 index 000000000..e71331e92 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Parser/CompilerSettings.cs @@ -0,0 +1,151 @@ +// 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 System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem.Implementation; + +namespace ICSharpCode.NRefactory.CSharp +{ + /// + /// C# compiler settings. + /// + [Serializable] + public class CompilerSettings : AbstractFreezable + { + protected override void FreezeInternal() + { + conditionalSymbols = FreezableHelper.FreezeList(conditionalSymbols); + specificWarningsAsErrors = FreezableHelper.FreezeList(specificWarningsAsErrors); + disabledWarnings = FreezableHelper.FreezeList(disabledWarnings); + base.FreezeInternal(); + } + + /// + /// Creates a new CompilerSettings instance. + /// + public CompilerSettings() + { + } + + bool allowUnsafeBlocks = true; + + /// + /// Gets/Sets whether unsafe code is allowed. + /// The default is true. If set to false, parsing unsafe code will result in parser errors. + /// + public bool AllowUnsafeBlocks { + get { return allowUnsafeBlocks; } + set { + FreezableHelper.ThrowIfFrozen(this); + allowUnsafeBlocks = value; + } + } + + bool checkForOverflow; + + /// + /// Gets/Sets whether overflow checking is enabled. + /// The default is false. This setting effects semantic analysis. + /// + public bool CheckForOverflow { + get { return checkForOverflow; } + set { checkForOverflow = value; } + } + + Version languageVersion = new Version((int)Mono.CSharp.LanguageVersion.Default, 0); + + /// + /// Gets/Sets the language version used by the parser. + /// Using language constructs newer than the supplied version will result in parser errors. + /// + public Version LanguageVersion { + get { return languageVersion; } + set { + FreezableHelper.ThrowIfFrozen(this); + if (value == null) + throw new ArgumentNullException(); + languageVersion = value; + } + } + + IList conditionalSymbols = new List(); + + /// + /// Gets/Sets the list of conditional symbols that are defined project-wide. + /// + public IList ConditionalSymbols { + get { return conditionalSymbols; } + } + + bool treatWarningsAsErrors; + + public bool TreatWarningsAsErrors { + get { return treatWarningsAsErrors; } + set { + FreezableHelper.ThrowIfFrozen(this); + treatWarningsAsErrors = value; + } + } + + IList specificWarningsAsErrors = new List(); + + /// + /// Allows treating specific warnings as errors without setting to true. + /// + public IList SpecificWarningsAsErrors { + get { return specificWarningsAsErrors; } + } + + int warningLevel = 4; + + public int WarningLevel { + get { return warningLevel; } + set { + FreezableHelper.ThrowIfFrozen(this); + warningLevel = value; + } + } + + IList disabledWarnings = new List(); + + /// + /// Allows treating specific warnings as errors without setting to true. + /// + public IList DisabledWarnings { + get { return disabledWarnings; } + } + + internal Mono.CSharp.CompilerSettings ToMono() + { + var s = new Mono.CSharp.CompilerSettings(); + s.Unsafe = allowUnsafeBlocks; + s.Checked = checkForOverflow; + s.Version = (Mono.CSharp.LanguageVersion)languageVersion.Major; + s.WarningsAreErrors = treatWarningsAsErrors; + s.WarningLevel = warningLevel; + foreach (int code in disabledWarnings) + s.SetIgnoreWarning(code); + foreach (int code in specificWarningsAsErrors) + s.AddWarningAsError(code); + foreach (string sym in conditionalSymbols) + s.AddConditionalSymbol(sym); + return s; + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Parser/SeekableStreamReader.cs b/ICSharpCode.NRefactory.CSharp/Parser/SeekableStreamReader.cs new file mode 100644 index 000000000..5a853c54e --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Parser/SeekableStreamReader.cs @@ -0,0 +1,103 @@ +// +// SeekableStreamReader.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 ICSharpCode.NRefactory.Editor; +using System.IO; +using System.Text; + +namespace Mono.CSharp +{ + public class SeekableStreamReader : IDisposable + { + public const int DefaultReadAheadSize = 2048; + + readonly ITextSource textSource; + + int pos; + + static string GetAllText(Stream stream, Encoding encoding) { + using (var rdr = new StreamReader(stream, encoding)) { + return rdr.ReadToEnd(); + } + } + + public SeekableStreamReader (Stream stream, Encoding encoding, char[] sharedBuffer = null) : this(new StringTextSource(GetAllText(stream, encoding))) + { + } + + public SeekableStreamReader (ITextSource source) + { + this.textSource = source; + } + + + public void Dispose () + { + } + + /// + /// This value corresponds to the current position in a stream of characters. + /// The StreamReader hides its manipulation of the underlying byte stream and all + /// character set/decoding issues. Thus, we cannot use this position to guess at + /// the corresponding position in the underlying byte stream even though there is + /// a correlation between them. + /// + public int Position { + get { + return pos; + } + + set { + pos = value; + } + } + + public char GetChar (int position) + { + return textSource.GetCharAt (position); + } + + public char[] ReadChars (int fromPosition, int toPosition) + { + return textSource.GetText (fromPosition, toPosition - fromPosition).ToCharArray (); + } + + public int Peek () + { + if (pos >= textSource.TextLength) + return -1; + return textSource.GetCharAt (pos); + } + + public int Read () + { + if (pos >= textSource.TextLength) + return -1; + return textSource.GetCharAt (pos++); + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs index 664cdf0cf..9b83bf3be 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolFile.cs @@ -53,7 +53,7 @@ namespace Mono.CompilerServices.SymbolWriter } } - internal class MyBinaryWriter : BinaryWriter + sealed class MyBinaryWriter : BinaryWriter { public MyBinaryWriter (Stream stream) : base (stream) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs index c9beaa0d4..88d604f2e 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/MonoSymbolTable.cs @@ -183,6 +183,7 @@ namespace Mono.CompilerServices.SymbolWriter { #region This is actually written to the symbol file public readonly int Row; + public int Column; public readonly int File; public readonly int Offset; public readonly bool IsHidden; // Obsolete is never used @@ -195,28 +196,35 @@ namespace Mono.CompilerServices.SymbolWriter public int Compare (LineNumberEntry l1, LineNumberEntry l2) { return l1.Row == l2.Row ? - l1.Offset.CompareTo (l2.Offset) : + l1.Column.CompareTo (l2.Column) : l1.Row.CompareTo (l2.Row); } } - public static readonly LineNumberEntry Null = new LineNumberEntry (0, 0, 0); + public static readonly LineNumberEntry Null = new LineNumberEntry (0, 0, 0, 0); + + public LineNumberEntry (int file, int row, int column, int offset) + : this (file, row, offset, column, false) + { + } public LineNumberEntry (int file, int row, int offset) - : this (file, row, offset, false) - { } + : this (file, row, -1, offset, false) + { + } - public LineNumberEntry (int file, int row, int offset, bool is_hidden) + public LineNumberEntry (int file, int row, int column, int offset, bool is_hidden) { this.File = file; this.Row = row; + this.Column = column; this.Offset = offset; this.IsHidden = is_hidden; } public override string ToString () { - return String.Format ("[Line {0}:{1}:{2}]", File, Row, Offset); + return String.Format ("[Line {0}:{1,2}:{3}]", File, Row, Column, Offset); } } @@ -675,8 +683,7 @@ namespace Mono.CompilerServices.SymbolWriter creating = true; } - public SourceFileEntry (MonoSymbolFile file, string file_name, - byte[] guid, byte[] checksum) + public SourceFileEntry (MonoSymbolFile file, string file_name, byte[] guid, byte[] checksum) : this (file, file_name) { this.guid = guid; @@ -694,13 +701,15 @@ namespace Mono.CompilerServices.SymbolWriter DataOffset = (int) bw.BaseStream.Position; bw.Write (file_name); - if (guid == null) { - guid = Guid.NewGuid ().ToByteArray (); + if (guid == null) + guid = new byte[16]; + + if (hash == null) { try { - using (FileStream fs = new FileStream (file_name, FileMode.Open, FileAccess.Read)) { - MD5 md5 = MD5.Create (); - hash = md5.ComputeHash (fs); - } + using (FileStream fs = new FileStream (file_name, FileMode.Open, FileAccess.Read)) { + MD5 md5 = MD5.Create (); + hash = md5.ComputeHash (fs); + } } catch { hash = new byte [16]; } @@ -791,7 +800,6 @@ namespace Mono.CompilerServices.SymbolWriter public const int Default_LineRange = 8; public const byte Default_OpcodeBase = 9; - public const bool SuppressDuplicates = true; #endregion public const byte DW_LNS_copy = 1; @@ -822,7 +830,7 @@ namespace Mono.CompilerServices.SymbolWriter this._line_numbers = lines; } - internal void Write (MonoSymbolFile file, MyBinaryWriter bw) + internal void Write (MonoSymbolFile file, MyBinaryWriter bw, bool readColumnsInfo) { int start = (int) bw.BaseStream.Position; @@ -832,11 +840,6 @@ namespace Mono.CompilerServices.SymbolWriter int line_inc = LineNumbers [i].Row - last_line; int offset_inc = LineNumbers [i].Offset - last_offset; - if (SuppressDuplicates && (i+1 < LineNumbers.Length)) { - if (LineNumbers [i+1].Equals (LineNumbers [i])) - continue; - } - if (LineNumbers [i].File != last_file) { bw.Write (DW_LNS_set_file); bw.WriteLeb128 (LineNumbers [i].File); @@ -884,17 +887,23 @@ namespace Mono.CompilerServices.SymbolWriter bw.Write ((byte) 1); bw.Write (DW_LNE_end_sequence); + for (int i = 0; i < LineNumbers.Length; i++) { + var ln = LineNumbers [i]; + if (ln.Row >= 0) + bw.WriteLeb128 (ln.Column); + } + file.ExtendedLineNumberSize += (int) bw.BaseStream.Position - start; } - internal static LineNumberTable Read (MonoSymbolFile file, MyBinaryReader br) + internal static LineNumberTable Read (MonoSymbolFile file, MyBinaryReader br, bool readColumnsInfo) { LineNumberTable lnt = new LineNumberTable (file); - lnt.DoRead (file, br); + lnt.DoRead (file, br, readColumnsInfo); return lnt; } - void DoRead (MonoSymbolFile file, MyBinaryReader br) + void DoRead (MonoSymbolFile file, MyBinaryReader br, bool includesColumns) { var lines = new List (); @@ -911,7 +920,7 @@ namespace Mono.CompilerServices.SymbolWriter if (opcode == DW_LNE_end_sequence) { if (modified) lines.Add (new LineNumberEntry ( - stm_file, stm_line, stm_offset, is_hidden)); + stm_file, stm_line, -1, stm_offset, is_hidden)); break; } else if (opcode == DW_LNE_MONO_negate_is_hidden) { is_hidden = !is_hidden; @@ -929,7 +938,7 @@ namespace Mono.CompilerServices.SymbolWriter switch (opcode) { case DW_LNS_copy: lines.Add (new LineNumberEntry ( - stm_file, stm_line, stm_offset, is_hidden)); + stm_file, stm_line, -1, stm_offset, is_hidden)); modified = false; break; case DW_LNS_advance_pc: @@ -959,13 +968,20 @@ namespace Mono.CompilerServices.SymbolWriter stm_offset += opcode / LineRange; stm_line += LineBase + (opcode % LineRange); lines.Add (new LineNumberEntry ( - stm_file, stm_line, stm_offset, is_hidden)); + stm_file, stm_line, -1, stm_offset, is_hidden)); modified = false; } } - _line_numbers = new LineNumberEntry [lines.Count]; - lines.CopyTo (_line_numbers, 0); + _line_numbers = lines.ToArray (); + + if (includesColumns) { + for (int i = 0; i < _line_numbers.Length; ++i) { + var ln = _line_numbers[i]; + if (ln.Row >= 0) + ln.Column = br.ReadLeb128 (); + } + } } public bool GetMethodBounds (out LineNumberEntry start, out LineNumberEntry end) @@ -1022,7 +1038,8 @@ namespace Mono.CompilerServices.SymbolWriter [Flags] public enum Flags { - LocalNamesAmbiguous = 1 + LocalNamesAmbiguous = 1, + ColumnsInfoIncluded = 1 << 1 } public const int Size = 12; @@ -1176,7 +1193,7 @@ namespace Mono.CompilerServices.SymbolWriter } LineNumberTableOffset = (int) bw.BaseStream.Position; - lnt.Write (file, bw); + lnt.Write (file, bw, (flags & Flags.ColumnsInfoIncluded) != 0); DataOffset = (int) bw.BaseStream.Position; @@ -1204,7 +1221,7 @@ namespace Mono.CompilerServices.SymbolWriter long old_pos = reader.BaseStream.Position; reader.BaseStream.Position = LineNumberTableOffset; - lnt = LineNumberTable.Read (SymbolFile, reader); + lnt = LineNumberTable.Read (SymbolFile, reader, (flags & Flags.ColumnsInfoIncluded) != 0); reader.BaseStream.Position = old_pos; return lnt; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/SourceMethodBuilder.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/SourceMethodBuilder.cs index 1ff399cdc..b45bf8a1f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/SourceMethodBuilder.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/SourceMethodBuilder.cs @@ -64,7 +64,7 @@ namespace Mono.CompilerServices.SymbolWriter 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); + var lne = new LineNumberEntry (file_idx, line, column, offset, is_hidden); if (method_lines.Count > 0) { var prev = method_lines[method_lines.Count - 1]; @@ -185,7 +185,7 @@ namespace Mono.CompilerServices.SymbolWriter { MethodEntry entry = new MethodEntry ( file, _comp_unit.Entry, token, ScopeVariables, - Locals, method_lines.ToArray (), Blocks, null, 0, ns_id); + Locals, method_lines.ToArray (), Blocks, null, MethodEntry.Flags.ColumnsInfoIncluded, ns_id); file.AddMethod (entry); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs index 7ef97558f..9a2c4a334 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/anonymous.cs @@ -315,7 +315,7 @@ namespace Mono.CSharp { } var hoisted = localVariable.HoistedVariant; - if (hoisted != null && hoisted.Storey != this && hoisted.Storey.Kind == MemberKind.Struct) { + if (hoisted != null && hoisted.Storey != this && hoisted.Storey is StateMachine) { // TODO: It's too late the field is defined in HoistedLocalVariable ctor hoisted.Storey.hoisted_locals.Remove (hoisted); hoisted = null; @@ -331,7 +331,7 @@ namespace Mono.CSharp { hoisted_locals.Add (hoisted); } - if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit) + if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoisted.Storey is StateMachine)) hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit); } @@ -343,7 +343,7 @@ namespace Mono.CSharp { var hoisted = parameterInfo.Parameter.HoistedVariant; - if (parameterInfo.Block.StateMachine is AsyncTaskStorey) { + if (parameterInfo.Block.StateMachine != null) { // // Another storey in same block exists but state machine does not // have parameter captured. We need to add it there as well to @@ -365,7 +365,7 @@ namespace Mono.CSharp { // 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 != null && hoisted.Storey != this && hoisted.Storey is StateMachine) { if (hoisted_local_params == null) hoisted_local_params = new List (); @@ -488,7 +488,7 @@ namespace Mono.CSharp { // When the current context is async (or iterator) lift local storey // instantiation to the currect storey // - if (ec.CurrentAnonymousMethod is StateMachineInitializer) { + if (ec.CurrentAnonymousMethod is StateMachineInitializer && (block.HasYield || block.HasAwait)) { // // Unfortunately, normal capture mechanism could not be used because we are // too late in the pipeline and standart assign cannot be used either due to @@ -702,7 +702,7 @@ namespace Mono.CSharp { public override void Emit (EmitContext ec) { ResolveContext rc = new ResolveContext (ec.MemberContext); - Expression e = hv.GetFieldExpression (ec).CreateExpressionTree (rc); + Expression e = hv.GetFieldExpression (ec).CreateExpressionTree (rc, false); // This should never fail e = e.Resolve (rc); if (e != null) @@ -816,7 +816,7 @@ namespace Mono.CSharp { sealed class HoistedFieldAssign : CompilerAssign { public HoistedFieldAssign (Expression target, Expression source) - : base (target, source, source.Location) + : base (target, source, target.Location) { } @@ -960,11 +960,16 @@ namespace Mono.CSharp { return Block.Parameters; } } - + public bool IsAsync { get; internal set; } + + public ReportPrinter TypeInferenceReportPrinter { + get; set; + } + #endregion // @@ -975,7 +980,13 @@ namespace Mono.CSharp { { using (ec.With (ResolveContext.Options.InferReturnType, false)) { using (ec.Set (ResolveContext.Options.ProbingMode)) { - return Compatible (ec, delegate_type) != null; + var prev = ec.Report.SetPrinter (TypeInferenceReportPrinter ?? new NullReportPrinter ()); + + var res = Compatible (ec, delegate_type) != null; + + ec.Report.SetPrinter (prev); + + return res; } } } @@ -1109,12 +1120,23 @@ namespace Mono.CSharp { } using (ec.Set (ResolveContext.Options.ProbingMode | ResolveContext.Options.InferReturnType)) { + ReportPrinter prev; + if (TypeInferenceReportPrinter != null) { + prev = ec.Report.SetPrinter (TypeInferenceReportPrinter); + } else { + prev = null; + } + var body = CompatibleMethodBody (ec, tic, null, delegate_type); if (body != null) { am = body.Compatible (ec, body); } else { am = null; } + + if (TypeInferenceReportPrinter != null) { + ec.Report.SetPrinter (prev); + } } if (am == null) @@ -1476,8 +1498,15 @@ namespace Mono.CSharp { if (ec.HasSet (ResolveContext.Options.ExpressionTreeConversion)) flags |= ResolveContext.Options.ExpressionTreeConversion; + if (ec.HasSet (ResolveContext.Options.BaseInitializer)) + flags |= ResolveContext.Options.BaseInitializer; + aec.Set (flags); + var bc = ec as BlockContext; + if (bc != null) + aec.FlowOffset = bc.FlowOffset; + var errors = ec.Report.Errors; bool res = Block.Resolve (ec.CurrentBranching, aec, null); @@ -1988,11 +2017,11 @@ namespace Mono.CSharp { IntConstant FNV_prime = new IntConstant (Compiler.BuiltinTypes, 16777619, loc); rs_hashcode = new Binary (Binary.Operator.Multiply, - new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode, loc), - FNV_prime, loc); + new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode), + FNV_prime); Expression field_to_string = new Conditional (new BooleanExpression (new Binary (Binary.Operator.Inequality, - new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc), loc)), + new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc))), new Invocation (new MemberAccess ( new MemberAccess (new This (f.Location), f.Name), "ToString"), null), new StringConstant (Compiler.BuiltinTypes, string.Empty, loc), loc); @@ -2003,9 +2032,7 @@ namespace Mono.CSharp { string_concat, new Binary (Binary.Operator.Addition, new StringConstant (Compiler.BuiltinTypes, " " + p.Name + " = ", loc), - field_to_string, - loc), - loc); + field_to_string)); continue; } @@ -2015,18 +2042,15 @@ namespace Mono.CSharp { string_concat = new Binary (Binary.Operator.Addition, new Binary (Binary.Operator.Addition, string_concat, - new StringConstant (Compiler.BuiltinTypes, ", " + p.Name + " = ", loc), - loc), - field_to_string, - loc); + new StringConstant (Compiler.BuiltinTypes, ", " + p.Name + " = ", loc)), + field_to_string); - rs_equals = new Binary (Binary.Operator.LogicalAnd, rs_equals, field_equal, loc); + rs_equals = new Binary (Binary.Operator.LogicalAnd, rs_equals, field_equal); } string_concat = new Binary (Binary.Operator.Addition, string_concat, - new StringConstant (Compiler.BuiltinTypes, " }", loc), - loc); + new StringConstant (Compiler.BuiltinTypes, " }", loc)); // // Equals (object obj) override @@ -2037,9 +2061,9 @@ namespace Mono.CSharp { new As (equals_block.GetParameterReference (0, loc), current_type, loc), loc))); - Expression equals_test = new Binary (Binary.Operator.Inequality, other_variable, new NullLiteral (loc), loc); + Expression equals_test = new Binary (Binary.Operator.Inequality, other_variable, new NullLiteral (loc)); if (rs_equals != null) - equals_test = new Binary (Binary.Operator.LogicalAnd, equals_test, rs_equals, loc); + equals_test = new Binary (Binary.Operator.LogicalAnd, equals_test, rs_equals); equals_block.AddStatement (new Return (equals_test, loc)); equals.Block = equals_block; @@ -2081,19 +2105,19 @@ namespace Mono.CSharp { var hash_variable = new LocalVariableReference (li_hash, loc); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 13, loc), loc), loc))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 13, loc))))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable, - new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 7, loc), loc), loc))); + new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 7, loc))))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 3, loc), loc), loc))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 3, loc))))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.ExclusiveOr, hash_variable, - new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 17, loc), loc), loc))); + new Binary (Binary.Operator.RightShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 17, loc))))); hashcode_block.AddStatement (new StatementExpression ( new CompoundAssign (Binary.Operator.Addition, hash_variable, - new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 5, loc), loc), loc))); + new Binary (Binary.Operator.LeftShift, hash_variable, new IntConstant (Compiler.BuiltinTypes, 5, loc))))); hashcode_block.AddStatement (new Return (hash_variable, loc)); hashcode.Block = hashcode_top; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs index 9da98b8a8..22e28eaf7 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/argument.cs @@ -320,20 +320,20 @@ namespace Mono.CSharp if (a.Expr is Constant) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "Constant", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "Constant", loc)); } else if (a.ArgType == Argument.AType.Ref) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsRef", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsRef", loc)); info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc)); } else if (a.ArgType == Argument.AType.Out) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsOut", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsOut", loc)); info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc)); } else if (a.ArgType == Argument.AType.DynamicTypeName) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsStaticType", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsStaticType", loc)); } var arg_type = a.Expr.Type; @@ -354,14 +354,14 @@ namespace Mono.CSharp } info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc)); } string named_value; NamedArgument na = a as NamedArgument; if (na != null) { info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags, - new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "NamedArgument", loc), loc); + new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "NamedArgument", loc)); named_value = na.Name; } else { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs index 1cdbf4518..f95a4d3cf 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assembly.cs @@ -624,9 +624,16 @@ namespace Mono.CSharp new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"), new Arguments[] { pos, named }, loc, false); g.AttachTo (module, module); - var ctor = g.Resolve (); - if (ctor != null) { - g.ExtractSecurityPermissionSet (ctor, ref declarative_security); + + // Disable no-location warnings (e.g. obsolete) for compiler generated attribute + Compiler.Report.DisableReporting (); + try { + var ctor = g.Resolve (); + if (ctor != null) { + g.ExtractSecurityPermissionSet (ctor, ref declarative_security); + } + } finally { + Compiler.Report.EnableReporting (); } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs index 673d586d1..ce8e25430 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/assign.cs @@ -543,11 +543,11 @@ namespace Mono.CSharp { ExpressionStatement resolved; IMemberContext mc; - public FieldInitializer (FieldSpec spec, Expression expression, IMemberContext mc) - : base (new FieldExpr (spec, expression.Location), expression, expression.Location) + public FieldInitializer (FieldBase mc, Expression expression, Location loc) + : base (new FieldExpr (mc.Spec, expression.Location), expression, loc) { this.mc = mc; - if (!spec.IsStatic) + if (!mc.IsStatic) ((FieldExpr)target).InstanceExpression = new CompilerGeneratedThis (mc.CurrentType, expression.Location); } @@ -660,15 +660,15 @@ namespace Mono.CSharp { } } - public CompoundAssign (Binary.Operator op, Expression target, Expression source, Location loc) - : base (target, source, loc) + public CompoundAssign (Binary.Operator op, Expression target, Expression source) + : base (target, source, target.Location) { right = source; this.op = op; } - public CompoundAssign (Binary.Operator op, Expression target, Expression source, Expression left, Location loc) - : this (op, target, source, loc) + public CompoundAssign (Binary.Operator op, Expression target, Expression source, Expression left) + : this (op, target, source) { this.left = left; } @@ -731,7 +731,7 @@ namespace Mono.CSharp { if (left == null) left = new TargetExpression (target); - source = new Binary (op, left, right, true, loc); + source = new Binary (op, left, right, true); if (target is DynamicMemberAssignable) { Arguments targs = ((DynamicMemberAssignable) target).Arguments; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs index 4c0cce612..e962e7d62 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/async.cs @@ -227,7 +227,9 @@ namespace Mono.CSharp // // awaiter = expr.GetAwaiter (); // - fe_awaiter.EmitAssign (ec, expr, false, false); + using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) { + fe_awaiter.EmitAssign (ec, expr, false, false); + } Label skip_continuation = ec.DefineLabel (); @@ -284,14 +286,8 @@ namespace Mono.CSharp awaiter.IsAvailableForReuse = true; - if (ResultType.Kind != MemberKind.Void) { - var storey = (AsyncTaskStorey) machine_initializer.Storey; - - if (storey.HoistedReturn != null) - storey.HoistedReturn.EmitAssign (ec); - else - ec.Emit (OpCodes.Pop); - } + if (ResultType.Kind != MemberKind.Void) + ec.Emit (OpCodes.Pop); } void Error_WrongAwaiterPattern (ResolveContext rc, TypeSpec awaiter) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs index 47eaad62e..eff7a5231 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/attribute.cs @@ -1016,7 +1016,7 @@ namespace Mono.CSharp { if (pos_args.Count == 1 && pos_args[0].Expr is Constant) { var value = ((Constant) pos_args[0].Expr).GetValue () as string; if (string.IsNullOrEmpty (value)) - Error_AttributeEmitError ("DllName cannot be empty"); + Error_AttributeEmitError ("DllName cannot be empty or null"); } } else if (Type == predefined.MethodImpl && pt.BuiltinType == BuiltinTypeSpec.Type.Short && !System.Enum.IsDefined (typeof (MethodImplOptions), ((Constant) arg_expr).GetValue ().ToString ())) { @@ -1476,6 +1476,12 @@ namespace Mono.CSharp { Encode (type.MemberDefinition.IsImported ? old_type.AssemblyQualifiedName : old_type.FullName); } + public void EncodeTypeName (TypeContainer type) + { + Encode (type.GetSignatureForMetadata ()); + } + + // // Encodes single property named argument per call // @@ -1629,6 +1635,10 @@ namespace Mono.CSharp { // New in .NET 4.0 public readonly PredefinedDynamicAttribute Dynamic; + // New in .NET 4.5 + public readonly PredefinedStateMachineAttribute AsyncStateMachine; + public readonly PredefinedStateMachineAttribute IteratorStateMachine; + // // Optional types which are used as types and for member lookup // @@ -1690,6 +1700,11 @@ namespace Mono.CSharp { StructLayout = new PredefinedAttribute (module, "System.Runtime.InteropServices", "StructLayoutAttribute"); FieldOffset = new PredefinedAttribute (module, "System.Runtime.InteropServices", "FieldOffsetAttribute"); + AsyncStateMachine = new PredefinedStateMachineAttribute (module, "System.Runtime.CompilerServices", "AsyncStateMachineAttribute"); + IteratorStateMachine = new PredefinedStateMachineAttribute (module, "System.Runtime.CompilerServices", "IteratorStateMachineAttribute") { + IsIterator = true + }; + CallerMemberNameAttribute = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "CallerMemberNameAttribute"); CallerLineNumberAttribute = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "CallerLineNumberAttribute"); CallerFilePathAttribute = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "CallerFilePathAttribute"); @@ -1877,6 +1892,34 @@ namespace Mono.CSharp { } } + public class PredefinedStateMachineAttribute : PredefinedAttribute + { + public PredefinedStateMachineAttribute (ModuleContainer module, string ns, string name) + : base (module, ns, name) + { + } + + public bool IsIterator { get; set; } + + public void EmitAttribute (MethodBuilder builder, StateMachine type) + { + var predefined_ctor = IsIterator ? + module.PredefinedMembers.IteratorStateMachineAttributeCtor : + module.PredefinedMembers.AsyncStateMachineAttributeCtor; + + var ctor = predefined_ctor.Get (); + + if (ctor == null) + return; + + AttributeEncoder encoder = new AttributeEncoder (); + encoder.EncodeTypeName (type); + encoder.EncodeEmptyNamedArguments (); + + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + } + } + public class PredefinedDynamicAttribute : PredefinedAttribute { MethodSpec tctor; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs index 9e2cfc8b9..8724e48b5 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cfold.cs @@ -187,7 +187,7 @@ namespace Mono.CSharp { // if ((lt.BuiltinType == BuiltinTypeSpec.Type.Bool && right is NullLiteral) || (rt.BuiltinType == BuiltinTypeSpec.Type.Bool && left is NullLiteral)) { - var b = new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + var b = new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); // false | null => null // null | false => null @@ -231,7 +231,7 @@ namespace Mono.CSharp { // if ((lt.BuiltinType == BuiltinTypeSpec.Type.Bool && right is NullLiteral) || (rt.BuiltinType == BuiltinTypeSpec.Type.Bool && left is NullLiteral)) { - var b = new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + var b = new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); // false & null => false // null & false => false @@ -469,7 +469,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -566,7 +566,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -662,7 +662,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -762,7 +762,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (!DoBinaryNumericPromotions (ec, ref left, ref right)) @@ -852,7 +852,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } IntConstant ic = right.ConvertImplicitly (ec.BuiltinTypes.Int) as IntConstant; @@ -873,7 +873,7 @@ namespace Mono.CSharp { // null << value => null if (left is NullLiteral) - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); left = left.ConvertImplicitly (ec.BuiltinTypes.Int); if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int) @@ -889,7 +889,7 @@ namespace Mono.CSharp { if (left is NullLiteral && right is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } IntConstant sic = right.ConvertImplicitly (ec.BuiltinTypes.Int) as IntConstant; @@ -909,7 +909,7 @@ namespace Mono.CSharp { // null >> value => null if (left is NullLiteral) - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); left = left.ConvertImplicitly (ec.BuiltinTypes.Int); if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int) @@ -925,7 +925,7 @@ namespace Mono.CSharp { if (left.IsNull || right.IsNull) { return ReducedExpression.Create ( new BoolConstant (ec.BuiltinTypes, left.IsNull == right.IsNull, left.Location), - new Binary (oper, left, right, loc)); + new Binary (oper, left, right)); } if (left is StringConstant && right is StringConstant) @@ -969,7 +969,7 @@ namespace Mono.CSharp { if (left.IsNull || right.IsNull) { return ReducedExpression.Create ( new BoolConstant (ec.BuiltinTypes, left.IsNull != right.IsNull, left.Location), - new Binary (oper, left, right, loc)); + new Binary (oper, left, right)); } if (left is StringConstant && right is StringConstant) @@ -1011,11 +1011,11 @@ namespace Mono.CSharp { if (left is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (left is Nullable.LiftedNull) { - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); } } @@ -1051,11 +1051,11 @@ namespace Mono.CSharp { if (left is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (left is Nullable.LiftedNull) { - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); } } @@ -1091,11 +1091,11 @@ namespace Mono.CSharp { if (left is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (left is Nullable.LiftedNull) { - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); } } @@ -1131,11 +1131,11 @@ namespace Mono.CSharp { if (left is NullLiteral) { var lifted_int = new Nullable.NullableType (ec.BuiltinTypes.Int, loc); lifted_int.ResolveAsType (ec); - return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, lifted_int, right).Resolve (ec); } if (left is Nullable.LiftedNull) { - return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right, loc).Resolve (ec); + return (Constant) new Nullable.LiftedBinaryOperator (oper, left, right).Resolve (ec); } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs index de601e145..645f53245 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/class.cs @@ -70,6 +70,12 @@ namespace Mono.CSharp } } + public Dictionary DefinedNames { + get { + return defined_names; + } + } + public TypeDefinition PartialContainer { get { return main_container; @@ -340,12 +346,31 @@ namespace Mono.CSharp return MemberName.GetSignatureForError (); } + public string GetSignatureForMetadata () + { +#if STATIC + var name = TypeNameParser.Escape (MemberName.Basename); + + if (Parent is TypeDefinition) { + return Parent.GetSignatureForMetadata () + "+" + name; + } + + if (Parent != null && Parent.MemberName != null) + return Parent.GetSignatureForMetadata () + "." + name; + + return name; +#else + throw new NotImplementedException (); +#endif + } + public virtual void RemoveContainer (TypeContainer cont) { if (containers != null) containers.Remove (cont); - defined_names.Remove (cont.Basename); + var tc = Parent == Module ? Module : this; + tc.defined_names.Remove (cont.Basename); } public virtual void VerifyMembers () @@ -1838,13 +1863,20 @@ namespace Mono.CSharp return; string class_indexer_name = null; - has_normal_indexers = true; // // Check normal indexers for consistent name, explicit interface implementation // indexers are ignored // foreach (var indexer in indexers) { + // + // FindMembers can return unfiltered full hierarchy names + // + if (indexer.DeclaringType != spec) + continue; + + has_normal_indexers = true; + if (class_indexer_name == null) { indexer_name = class_indexer_name = indexer.Name; continue; @@ -1922,7 +1954,7 @@ namespace Mono.CSharp continue; // - // Don't be pendatic over serializable attributes + // Don't be pedantic when type requires specific layout // if (f.OptAttributes != null || PartialContainer.HasStructLayout) continue; @@ -1934,10 +1966,6 @@ namespace Mono.CSharp } else if (TypeSpec.IsReferenceType (f.MemberType)) { value = "null"; } else { - // Ignore this warning for struct value fields (they are always initialized) - if (f.MemberType.IsStruct) - continue; - value = null; } @@ -2403,16 +2431,6 @@ namespace Mono.CSharp base.AddNameToContainer (symbol, name); } - public override void VerifyMembers () - { - base.VerifyMembers (); - - if (containers != null) { - foreach (var t in containers) - t.VerifyMembers (); - } - } - public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.IsValidSecurityAttribute ()) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs index 026d41069..9bb706675 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/codegen.cs @@ -944,10 +944,10 @@ namespace Mono.CSharp if (method.ReturnType.Kind == MemberKind.Void && method.IsConditionallyExcluded (ec.MemberContext, loc)) return; - EmitPredefined (ec, method, Arguments); + EmitPredefined (ec, method, Arguments, loc); } - public void EmitPredefined (EmitContext ec, MethodSpec method, Arguments Arguments) + public void EmitPredefined (EmitContext ec, MethodSpec method, Arguments Arguments, Location? loc = null) { Expression instance_copy = null; @@ -1006,6 +1006,18 @@ namespace Mono.CSharp ec.Emit (OpCodes.Constrained, InstanceExpression.Type); } + if (loc != null) { + // + // Emit explicit sequence point for expressions like Foo.Bar () to help debugger to + // break at right place when LHS expression can be stepped-into + // + // TODO: The list is probably not comprehensive, need to do more testing + // + if (InstanceExpression is PropertyExpr || InstanceExpression is Invocation || InstanceExpression is IndexerExpr || + InstanceExpression is New || InstanceExpression is DelegateInvocation) + ec.Mark (loc.Value); + } + // // Set instance expression to actual result expression. When it contains await it can be // picked up by caller diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs index 5eb93d129..31cba91fe 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/const.cs @@ -59,7 +59,7 @@ namespace Mono.CSharp { if ((field_attr & FieldAttributes.InitOnly) != 0) Parent.PartialContainer.RegisterFieldForInitialization (this, - new FieldInitializer (spec, initializer, this)); + new FieldInitializer (this, initializer, Location)); if (declarators != null) { var t = new TypeExpression (MemberType, TypeExpression.Location); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs index 5f309854b..0e45bd5de 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/context.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Security.Cryptography; namespace Mono.CSharp { @@ -730,4 +731,28 @@ namespace Mono.CSharp return new FlagsHandle (this, options, enable ? options : 0); } } + + // + // Parser session objects. We could recreate all these objects for each parser + // instance but the best parser performance the session object can be reused + // + public class ParserSession + { + MD5 md5; + + public readonly char[] StreamReaderBuffer = new char[SeekableStreamReader.DefaultReadAheadSize * 2]; + public readonly Dictionary[] Identifiers = new Dictionary[Tokenizer.MaxIdentifierLength + 1]; + public readonly List ParametersStack = new List (4); + public readonly char[] IDBuilder = new char[Tokenizer.MaxIdentifierLength]; + public readonly char[] NumberBuilder = new char[Tokenizer.MaxNumberLength]; + + public LocationsBag LocationsBag { get; set; } + public bool UseJayGlobalArrays { get; set; } + public Tokenizer.LocatedToken[] LocatedTokens { get; set; } + + public MD5 GetChecksumAlgorithm () + { + return md5 ?? (md5 = MD5.Create ()); + } + } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs index a9a304dfc..3020c8814 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/convert.cs @@ -1337,8 +1337,7 @@ namespace Mono.CSharp { try { c = c.ConvertImplicitly (target_type); } catch { - Console.WriteLine ("Conversion error happened in line {0}", loc); - throw; + throw new InternalErrorException ("Conversion error", loc); } if (c != null) return c; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs index 77893426d..b9491273a 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs @@ -12,12 +12,7 @@ // // (C) 2001 Ximian, Inc (http://www.ximian.com) // (C) 2004-2011 Novell, Inc -// Copyright 2011 Xamarin Inc. -// -// TODO: -// (1) Figure out why error productions dont work. `type-declaration' is a -// great spot to put an `error' because you can reproduce it with this input: -// "public X { }" +// Copyright 2011-2012 Xamarin Inc. // using System.Text; @@ -83,7 +78,7 @@ namespace Mono.CSharp /// /// An out-of-band stack. /// - static Stack oob_stack; + Stack oob_stack; /// /// Controls the verbosity of the errors produced by the parser @@ -139,12 +134,19 @@ namespace Mono.CSharp // share the bucket for very common constructs which can never // be recursive // - static List parameters_bucket = new List (6); + List parameters_bucket; // // Full AST support members // - LocationsBag lbag; + readonly LocationsBag lbag; + + public LocationsBag LocationsBag { + get { + return lbag; + } + } + List> mod_locations; Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation; Location savedAttrParenOpenLocation, savedAttrParenCloseLocation, savedOperatorLocation; @@ -168,10 +170,10 @@ namespace Mono.CSharp public void yyerror (string message) { yyerror(message, null); } - +#pragma warning disable 649 /* An EOF token */ public int eof_token; - +#pragma warning restore 649 /** (syntax) error message. Can be overwritten to control message format. @param message text to be displayed. @@ -521,6 +523,8 @@ namespace Mono.CSharp //t "enum_member_declaration : opt_attributes IDENTIFIER", //t "$$59 :", //t "enum_member_declaration : opt_attributes IDENTIFIER $$59 ASSIGN constant_expression", +//t "enum_member_declaration : opt_attributes IDENTIFIER error", +//t "enum_member_declaration : attributes_without_members", //t "$$60 :", //t "$$61 :", //t "$$62 :", @@ -631,6 +635,7 @@ namespace Mono.CSharp //t "member_access : builtin_types DOT GENERATE_COMPLETION", //t "member_access : builtin_types DOT IDENTIFIER GENERATE_COMPLETION", //t "invocation_expression : primary_expression open_parens_any opt_argument_list close_parens", +//t "invocation_expression : primary_expression open_parens_any argument_list error", //t "opt_object_or_collection_initializer :", //t "opt_object_or_collection_initializer : object_or_collection_initializer", //t "object_or_collection_initializer : OPEN_BRACE opt_member_initializer_list close_brace_or_complete_completion", @@ -756,7 +761,6 @@ namespace Mono.CSharp //t "additive_expression : multiplicative_expression", //t "additive_expression : additive_expression PLUS multiplicative_expression", //t "additive_expression : additive_expression MINUS multiplicative_expression", -//t "additive_expression : parenthesized_expression MINUS multiplicative_expression", //t "additive_expression : additive_expression AS type", //t "additive_expression : additive_expression IS type", //t "shift_expression : additive_expression", @@ -1048,10 +1052,12 @@ namespace Mono.CSharp //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 expression error", //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 RETURN expression error", //t "yield_statement : identifier_inside_body BREAK SEMICOLON", //t "opt_expression :", //t "opt_expression : expression", @@ -1243,7 +1249,9 @@ namespace Mono.CSharp //t return "[unknown]"; //t } +#pragma warning disable 414 int yyExpectingState; +#pragma warning restore 414 /** computes list of expected tokens on error by tracing the tables. @param state for which to compute the list. @return list of token names. @@ -1309,7 +1317,9 @@ namespace Mono.CSharp static int[] global_yyStates; static object[] global_yyVals; +#pragma warning disable 649 protected bool use_global_stacks; +#pragma warning restore 649 object[] yyVals; // value stack object yyVal; // value stack ptr int yyToken; // current input @@ -1415,20 +1425,20 @@ namespace Mono.CSharp yyVal = yyV > yyTop ? null : yyVals[yyV]; // yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]); switch (yyN) { case 1: -#line 390 "cs-parser.jay" +#line 385 "cs-parser.jay" { Lexer.check_incorrect_doc_comment (); } break; case 2: -#line 391 "cs-parser.jay" +#line 386 "cs-parser.jay" { Lexer.CompleteOnEOF = false; } break; case 6: case_6(); break; case 7: -#line 410 "cs-parser.jay" +#line 405 "cs-parser.jay" { module.AddAttributes ((Attributes) yyVals[0+yyTop], current_namespace); } @@ -1440,7 +1450,7 @@ case 13: case_13(); break; case 14: -#line 455 "cs-parser.jay" +#line 450 "cs-parser.jay" { Error_SyntaxError (yyToken); } @@ -1479,7 +1489,7 @@ case 39: case_39(); break; case 40: -#line 621 "cs-parser.jay" +#line 616 "cs-parser.jay" { current_namespace.DeclarationFound = true; } @@ -1512,18 +1522,18 @@ case 56: case_56(); break; case 57: -#line 735 "cs-parser.jay" +#line 730 "cs-parser.jay" { yyVal = "event"; savedCloseLocation = GetLocation (yyVals[0+yyTop]); } break; case 58: -#line 736 "cs-parser.jay" +#line 731 "cs-parser.jay" { yyVal = "return"; savedCloseLocation = GetLocation (yyVals[0+yyTop]); } break; case 59: case_59(); break; case 60: -#line 753 "cs-parser.jay" +#line 748 "cs-parser.jay" { yyVal = new List (4) { (Attribute) yyVals[0+yyTop] }; } @@ -1532,7 +1542,7 @@ case 61: case_61(); break; case 62: -#line 768 "cs-parser.jay" +#line 763 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1541,14 +1551,14 @@ case 63: case_63(); break; case 65: -#line 796 "cs-parser.jay" +#line 791 "cs-parser.jay" { yyVal = null; HadAttributeParens = false; } break; case 66: case_66(); break; case 67: -#line 808 "cs-parser.jay" +#line 803 "cs-parser.jay" { yyVal = null; } break; case 68: @@ -1564,13 +1574,13 @@ case 71: case_71(); break; case 72: -#line 852 "cs-parser.jay" +#line 847 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop]); } break; case 74: -#line 860 "cs-parser.jay" +#line 855 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1582,29 +1592,29 @@ case 76: case_76(); break; case 77: -#line 886 "cs-parser.jay" +#line 881 "cs-parser.jay" { yyVal = null; } break; case 78: -#line 890 "cs-parser.jay" +#line 885 "cs-parser.jay" { yyVal = Argument.AType.Ref; } break; case 79: -#line 894 "cs-parser.jay" +#line 889 "cs-parser.jay" { yyVal = Argument.AType.Out; } break; case 82: -#line 906 "cs-parser.jay" +#line 901 "cs-parser.jay" { lexer.parsing_modifiers = true; } break; case 83: -#line 910 "cs-parser.jay" +#line 905 "cs-parser.jay" { lexer.parsing_modifiers = true; } @@ -1613,7 +1623,7 @@ case 95: case_95(); break; case 96: -#line 941 "cs-parser.jay" +#line 936 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1634,7 +1644,7 @@ case 101: case_101(); break; case 102: -#line 984 "cs-parser.jay" +#line 979 "cs-parser.jay" { Error_SyntaxError (yyToken); } @@ -1646,13 +1656,13 @@ case 104: case_104(); break; case 107: -#line 1025 "cs-parser.jay" +#line 1020 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 108: -#line 1029 "cs-parser.jay" +#line 1024 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1661,7 +1671,7 @@ case 109: case_109(); break; case 110: -#line 1045 "cs-parser.jay" +#line 1040 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1685,7 +1695,7 @@ case 118: case_118(); break; case 119: -#line 1124 "cs-parser.jay" +#line 1119 "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"); } @@ -1697,13 +1707,13 @@ case 122: case_122(); break; case 125: -#line 1154 "cs-parser.jay" +#line 1149 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 126: -#line 1158 "cs-parser.jay" +#line 1153 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1712,7 +1722,7 @@ case 127: case_127(); break; case 128: -#line 1171 "cs-parser.jay" +#line 1166 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1721,13 +1731,13 @@ case 129: case_129(); break; case 132: -#line 1190 "cs-parser.jay" +#line 1185 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 133: -#line 1194 "cs-parser.jay" +#line 1189 "cs-parser.jay" { current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -1736,7 +1746,7 @@ case 134: case_134(); break; case 135: -#line 1210 "cs-parser.jay" +#line 1205 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1757,13 +1767,13 @@ case 142: case_142(); break; case 143: -#line 1281 "cs-parser.jay" +#line 1276 "cs-parser.jay" { valid_param_mod = ParameterModifierType.All; } break; case 144: -#line 1285 "cs-parser.jay" +#line 1280 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1772,7 +1782,7 @@ case 145: case_145(); break; case 146: -#line 1311 "cs-parser.jay" +#line 1306 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } @@ -1781,7 +1791,7 @@ case 147: case_147(); break; case 148: -#line 1321 "cs-parser.jay" +#line 1316 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1796,11 +1806,11 @@ case 151: case_151(); break; case 153: -#line 1386 "cs-parser.jay" +#line 1381 "cs-parser.jay" { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } break; case 154: -#line 1390 "cs-parser.jay" +#line 1385 "cs-parser.jay" { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } break; case 156: @@ -1825,13 +1835,13 @@ case 162: case_162(); break; case 163: -#line 1462 "cs-parser.jay" +#line 1457 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[0+yyTop] } ); } break; case 164: -#line 1466 "cs-parser.jay" +#line 1461 "cs-parser.jay" { yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true); } @@ -1858,7 +1868,7 @@ case 171: case_171(); break; case 172: -#line 1547 "cs-parser.jay" +#line 1542 "cs-parser.jay" { ++lexer.parsing_block; } @@ -1867,11 +1877,11 @@ case 173: case_173(); break; case 174: -#line 1588 "cs-parser.jay" +#line 1583 "cs-parser.jay" { yyVal = Parameter.Modifier.NONE; } break; case 176: -#line 1596 "cs-parser.jay" +#line 1591 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -1904,7 +1914,7 @@ case 185: case_185(); break; case 186: -#line 1689 "cs-parser.jay" +#line 1684 "cs-parser.jay" { Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS); } @@ -1925,7 +1935,7 @@ case 191: case_191(); break; case 192: -#line 1743 "cs-parser.jay" +#line 1738 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue; } @@ -1934,7 +1944,7 @@ case 193: case_193(); break; case 194: -#line 1772 "cs-parser.jay" +#line 1767 "cs-parser.jay" { lexer.PropertyParsing = false; } @@ -1964,7 +1974,7 @@ case 207: case_207(); break; case 208: -#line 1921 "cs-parser.jay" +#line 1916 "cs-parser.jay" { lexer.ConstraintsParsing = true; } @@ -1982,55 +1992,55 @@ case 212: case_212(); break; case 213: -#line 1960 "cs-parser.jay" +#line 1955 "cs-parser.jay" { Error_SyntaxError (yyToken); } break; case 216: -#line 1972 "cs-parser.jay" +#line 1967 "cs-parser.jay" { lexer.parsing_modifiers = true; } break; case 217: -#line 1976 "cs-parser.jay" +#line 1971 "cs-parser.jay" { lexer.parsing_modifiers = true; } break; case 218: -#line 1983 "cs-parser.jay" +#line 1978 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; case 219: -#line 1987 "cs-parser.jay" +#line 1982 "cs-parser.jay" { report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants"); } break; case 224: -#line 1995 "cs-parser.jay" +#line 1990 "cs-parser.jay" { report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators"); } break; case 225: -#line 1999 "cs-parser.jay" +#line 1994 "cs-parser.jay" { report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors"); } break; case 226: -#line 2003 "cs-parser.jay" +#line 1998 "cs-parser.jay" { report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations"); } break; case 227: -#line 2009 "cs-parser.jay" +#line 2004 "cs-parser.jay" { } break; @@ -2038,14 +2048,14 @@ case 228: case_228(); break; case 230: -#line 2042 "cs-parser.jay" +#line 2037 "cs-parser.jay" { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } break; case 232: case_232(); break; case 233: -#line 2058 "cs-parser.jay" +#line 2053 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2054,95 +2064,95 @@ case 234: case_234(); break; case 236: -#line 2104 "cs-parser.jay" +#line 2099 "cs-parser.jay" { yyVal = Operator.OpType.LogicalNot; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 237: -#line 2105 "cs-parser.jay" +#line 2100 "cs-parser.jay" { yyVal = Operator.OpType.OnesComplement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 238: -#line 2106 "cs-parser.jay" +#line 2101 "cs-parser.jay" { yyVal = Operator.OpType.Increment; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 239: -#line 2107 "cs-parser.jay" +#line 2102 "cs-parser.jay" { yyVal = Operator.OpType.Decrement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 240: -#line 2108 "cs-parser.jay" +#line 2103 "cs-parser.jay" { yyVal = Operator.OpType.True; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 241: -#line 2109 "cs-parser.jay" +#line 2104 "cs-parser.jay" { yyVal = Operator.OpType.False; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 242: -#line 2111 "cs-parser.jay" +#line 2106 "cs-parser.jay" { yyVal = Operator.OpType.Addition; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 243: -#line 2112 "cs-parser.jay" +#line 2107 "cs-parser.jay" { yyVal = Operator.OpType.Subtraction; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 244: -#line 2114 "cs-parser.jay" +#line 2109 "cs-parser.jay" { yyVal = Operator.OpType.Multiply; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 245: -#line 2115 "cs-parser.jay" +#line 2110 "cs-parser.jay" { yyVal = Operator.OpType.Division; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 246: -#line 2116 "cs-parser.jay" +#line 2111 "cs-parser.jay" { yyVal = Operator.OpType.Modulus; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 247: -#line 2117 "cs-parser.jay" +#line 2112 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseAnd; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 248: -#line 2118 "cs-parser.jay" +#line 2113 "cs-parser.jay" { yyVal = Operator.OpType.BitwiseOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 249: -#line 2119 "cs-parser.jay" +#line 2114 "cs-parser.jay" { yyVal = Operator.OpType.ExclusiveOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 250: -#line 2120 "cs-parser.jay" +#line 2115 "cs-parser.jay" { yyVal = Operator.OpType.LeftShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 251: -#line 2121 "cs-parser.jay" +#line 2116 "cs-parser.jay" { yyVal = Operator.OpType.RightShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 252: -#line 2122 "cs-parser.jay" +#line 2117 "cs-parser.jay" { yyVal = Operator.OpType.Equality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 253: -#line 2123 "cs-parser.jay" +#line 2118 "cs-parser.jay" { yyVal = Operator.OpType.Inequality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 254: -#line 2124 "cs-parser.jay" +#line 2119 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 255: -#line 2125 "cs-parser.jay" +#line 2120 "cs-parser.jay" { yyVal = Operator.OpType.LessThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 256: -#line 2126 "cs-parser.jay" +#line 2121 "cs-parser.jay" { yyVal = Operator.OpType.GreaterThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 257: -#line 2127 "cs-parser.jay" +#line 2122 "cs-parser.jay" { yyVal = Operator.OpType.LessThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); } break; case 258: -#line 2134 "cs-parser.jay" +#line 2129 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2151,7 +2161,7 @@ case 259: case_259(); break; case 260: -#line 2153 "cs-parser.jay" +#line 2148 "cs-parser.jay" { valid_param_mod = ParameterModifierType.DefaultValue; } @@ -2178,11 +2188,11 @@ case 267: case_267(); break; case 269: -#line 2259 "cs-parser.jay" +#line 2254 "cs-parser.jay" { current_block = null; yyVal = null; } break; case 272: -#line 2271 "cs-parser.jay" +#line 2266 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2191,7 +2201,7 @@ case 273: case_273(); break; case 274: -#line 2281 "cs-parser.jay" +#line 2276 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2227,7 +2237,7 @@ case 284: case_284(); break; case 286: -#line 2397 "cs-parser.jay" +#line 2392 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2236,13 +2246,13 @@ case 287: case_287(); break; case 290: -#line 2414 "cs-parser.jay" +#line 2409 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } break; case 291: -#line 2418 "cs-parser.jay" +#line 2413 "cs-parser.jay" { current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]); } @@ -2251,7 +2261,7 @@ case 292: case_292(); break; case 293: -#line 2431 "cs-parser.jay" +#line 2426 "cs-parser.jay" { ++lexer.parsing_block; } @@ -2263,7 +2273,7 @@ case 295: case_295(); break; case 296: -#line 2456 "cs-parser.jay" +#line 2451 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -2314,7 +2324,7 @@ case 315: case_315(); break; case 318: -#line 2624 "cs-parser.jay" +#line 2619 "cs-parser.jay" { lbag.AppendToMember (current_container, GetLocation (yyVals[0+yyTop])); } @@ -2332,23 +2342,23 @@ case 323: case_323(); break; case 324: -#line 2682 "cs-parser.jay" + case_324(); + break; +case 326: +#line 2693 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue; } break; -case 325: - case_325(); +case 327: + case_327(); break; -case 326: -#line 2701 "cs-parser.jay" +case 328: +#line 2712 "cs-parser.jay" { lexer.ConstraintsParsing = false; } break; -case 327: - case_327(); - break; case 329: case_329(); break; @@ -2358,15 +2368,12 @@ case 331: case 333: case_333(); break; -case 334: - case_334(); +case 335: + case_335(); break; case 336: case_336(); break; -case 337: - case_337(); - break; case 338: case_338(); break; @@ -2374,23 +2381,23 @@ case 339: case_339(); break; case 340: -#line 2807 "cs-parser.jay" - { - lexer.parsing_generic_declaration = true; - } + case_340(); break; case 341: case_341(); break; case 342: - case_342(); +#line 2818 "cs-parser.jay" + { + lexer.parsing_generic_declaration = true; + } + break; +case 343: + case_343(); break; case 344: case_344(); break; -case 345: - case_345(); - break; case 346: case_346(); break; @@ -2403,12 +2410,12 @@ case 348: case 349: case_349(); break; +case 350: + case_350(); + break; case 351: case_351(); break; -case 352: - case_352(); - break; case 353: case_353(); break; @@ -2418,21 +2425,24 @@ case 354: case 355: case_355(); break; +case 356: + case_356(); + break; case 357: -#line 2929 "cs-parser.jay" + case_357(); + break; +case 359: +#line 2940 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } break; -case 358: -#line 2936 "cs-parser.jay" +case 360: +#line 2947 "cs-parser.jay" { lexer.parsing_generic_declaration = true; } break; -case 360: - case_360(); - break; case 362: case_362(); break; @@ -2440,136 +2450,133 @@ case 364: case_364(); break; case 366: -#line 2974 "cs-parser.jay" - { - yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); - } - break; -case 367: - case_367(); + case_366(); break; case 368: -#line 2993 "cs-parser.jay" +#line 2985 "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 369: case_369(); break; case 370: -#line 3002 "cs-parser.jay" +#line 3004 "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 371: -#line 3006 "cs-parser.jay" - { - yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); - } + case_371(); break; case 372: - case_372(); +#line 3013 "cs-parser.jay" + { + yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); + } break; case 373: - case_373(); +#line 3017 "cs-parser.jay" + { + yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); + } break; case 374: case_374(); break; case 375: -#line 3040 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } + case_375(); break; case 376: -#line 3041 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } + case_376(); break; case 377: -#line 3042 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } +#line 3051 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); } break; case 378: -#line 3043 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } +#line 3052 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); } break; case 379: -#line 3044 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } +#line 3053 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); } break; case 380: -#line 3045 "cs-parser.jay" - { yyVal = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation (yyVals[0+yyTop])); } +#line 3054 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); } + break; +case 381: +#line 3055 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); } break; case 382: -#line 3050 "cs-parser.jay" +#line 3056 "cs-parser.jay" + { yyVal = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation (yyVals[0+yyTop])); } + break; +case 384: +#line 3061 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.SByte, GetLocation (yyVals[0+yyTop])); } break; -case 383: -#line 3051 "cs-parser.jay" +case 385: +#line 3062 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Byte, GetLocation (yyVals[0+yyTop])); } break; -case 384: -#line 3052 "cs-parser.jay" +case 386: +#line 3063 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Short, GetLocation (yyVals[0+yyTop])); } break; -case 385: -#line 3053 "cs-parser.jay" +case 387: +#line 3064 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UShort, GetLocation (yyVals[0+yyTop])); } break; -case 386: -#line 3054 "cs-parser.jay" +case 388: +#line 3065 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Int, GetLocation (yyVals[0+yyTop])); } break; -case 387: -#line 3055 "cs-parser.jay" +case 389: +#line 3066 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.UInt, GetLocation (yyVals[0+yyTop])); } break; -case 388: -#line 3056 "cs-parser.jay" +case 390: +#line 3067 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Long, GetLocation (yyVals[0+yyTop])); } break; -case 389: -#line 3057 "cs-parser.jay" +case 391: +#line 3068 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.ULong, GetLocation (yyVals[0+yyTop])); } break; -case 390: -#line 3058 "cs-parser.jay" +case 392: +#line 3069 "cs-parser.jay" { yyVal = new TypeExpression (compiler.BuiltinTypes.Char, GetLocation (yyVals[0+yyTop])); } break; -case 411: - case_411(); +case 413: + case_413(); break; -case 412: - case_412(); +case 414: + case_414(); break; -case 416: -#line 3105 "cs-parser.jay" +case 418: +#line 3116 "cs-parser.jay" { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); } break; -case 417: -#line 3109 "cs-parser.jay" +case 419: +#line 3120 "cs-parser.jay" { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); } break; -case 418: -#line 3110 "cs-parser.jay" +case 420: +#line 3121 "cs-parser.jay" { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); } break; -case 423: - case_423(); - break; -case 424: -#line 3143 "cs-parser.jay" - { - yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); - } - break; case 425: case_425(); break; case 426: - case_426(); +#line 3154 "cs-parser.jay" + { + yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); + } break; case 427: case_427(); @@ -2578,63 +2585,60 @@ case 428: case_428(); break; case 429: -#line 3178 "cs-parser.jay" - { - yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop])); - } + case_429(); break; case 430: case_430(); break; case 431: -#line 3186 "cs-parser.jay" +#line 3189 "cs-parser.jay" { - yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location); + yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop])); } break; case 432: case_432(); break; case 433: - case_433(); +#line 3197 "cs-parser.jay" + { + yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location); + } break; case 434: -#line 3202 "cs-parser.jay" - { yyVal = null; } + case_434(); + break; +case 435: + case_435(); break; case 436: case_436(); break; case 437: - case_437(); - break; -case 438: -#line 3225 "cs-parser.jay" +#line 3221 "cs-parser.jay" { yyVal = null; } break; case 439: -#line 3229 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_439(); break; case 440: case_440(); break; case 441: - case_441(); +#line 3244 "cs-parser.jay" + { yyVal = null; } break; case 442: - case_442(); +#line 3248 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 443: case_443(); break; case 444: -#line 3262 "cs-parser.jay" - { - yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop])); - } + case_444(); break; case 445: case_445(); @@ -2643,20 +2647,23 @@ case 446: case_446(); break; case 447: - case_447(); +#line 3281 "cs-parser.jay" + { + yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop])); + } break; -case 450: -#line 3292 "cs-parser.jay" - { yyVal = null; } +case 448: + case_448(); break; -case 452: - case_452(); +case 449: + case_449(); break; -case 453: - case_453(); +case 450: + case_450(); break; -case 454: - case_454(); +case 453: +#line 3312 "cs-parser.jay" + { yyVal = null; } break; case 455: case_455(); @@ -2665,32 +2672,32 @@ case 456: case_456(); break; case 457: -#line 3344 "cs-parser.jay" - { - yyVal = new Argument ((Expression) yyVals[0+yyTop]); - } + case_457(); break; -case 461: - case_461(); +case 458: + case_458(); break; -case 462: - case_462(); +case 459: + case_459(); break; -case 463: - case_463(); +case 460: +#line 3365 "cs-parser.jay" + { + yyVal = new Argument ((Expression) yyVals[0+yyTop]); + } break; case 464: case_464(); break; +case 465: + case_465(); + break; case 466: case_466(); break; case 467: case_467(); break; -case 468: - case_468(); - break; case 469: case_469(); break; @@ -2707,43 +2714,43 @@ case 473: case_473(); break; case 474: -#line 3441 "cs-parser.jay" - { - yyVal = new Argument ((Expression) yyVals[0+yyTop]); - } + case_474(); + break; +case 475: + case_475(); break; case 476: -#line 3449 "cs-parser.jay" - { - yyVal = new This (GetLocation (yyVals[0+yyTop])); - } + case_476(); break; case 477: - case_477(); - break; -case 478: - case_478(); +#line 3462 "cs-parser.jay" + { + yyVal = new Argument ((Expression) yyVals[0+yyTop]); + } break; case 479: -#line 3469 "cs-parser.jay" +#line 3470 "cs-parser.jay" { - yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); + yyVal = new This (GetLocation (yyVals[0+yyTop])); } break; case 480: -#line 3476 "cs-parser.jay" - { - yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); - } + case_480(); break; case 481: case_481(); break; case 482: - case_482(); +#line 3490 "cs-parser.jay" + { + yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); + } break; case 483: - case_483(); +#line 3497 "cs-parser.jay" + { + yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); + } break; case 484: case_484(); @@ -2758,10 +2765,7 @@ case 487: case_487(); break; case 488: -#line 3543 "cs-parser.jay" - { - ++lexer.parsing_type; - } + case_488(); break; case 489: case_489(); @@ -2769,18 +2773,21 @@ case 489: case 490: case_490(); break; -case 493: -#line 3570 "cs-parser.jay" - { yyVal = null; } +case 491: +#line 3564 "cs-parser.jay" + { + ++lexer.parsing_type; + } break; -case 495: - case_495(); +case 492: + case_492(); break; -case 496: - case_496(); +case 493: + case_493(); break; -case 497: - case_497(); +case 496: +#line 3591 "cs-parser.jay" + { yyVal = null; } break; case 498: case_498(); @@ -2791,68 +2798,68 @@ case 499: case 500: case_500(); break; -case 504: - case_504(); +case 501: + case_501(); break; -case 505: - case_505(); +case 502: + case_502(); break; -case 506: - case_506(); +case 503: + case_503(); break; case 507: -#line 3648 "cs-parser.jay" + case_507(); + break; +case 508: + case_508(); + break; +case 509: + case_509(); + break; +case 510: +#line 3669 "cs-parser.jay" { yyVal = 2; } break; -case 508: -#line 3652 "cs-parser.jay" +case 511: +#line 3673 "cs-parser.jay" { yyVal = ((int) yyVals[-1+yyTop]) + 1; } break; -case 509: -#line 3659 "cs-parser.jay" +case 512: +#line 3680 "cs-parser.jay" { yyVal = null; } break; -case 510: -#line 3663 "cs-parser.jay" +case 513: +#line 3684 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 511: - case_511(); - break; -case 512: - case_512(); - break; -case 513: - case_513(); - break; case 514: case_514(); break; case 515: -#line 3707 "cs-parser.jay" - { - lexer.TypeOfParsing = true; - } + case_515(); break; case 516: case_516(); break; -case 519: - case_519(); +case 517: + case_517(); break; -case 520: - case_520(); +case 518: +#line 3728 "cs-parser.jay" + { + lexer.TypeOfParsing = true; + } break; -case 521: - case_521(); +case 519: + case_519(); break; case 522: case_522(); @@ -2882,151 +2889,151 @@ case 530: case_530(); break; case 531: -#line 3827 "cs-parser.jay" - { - start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], false, GetLocation (yyVals[-1+yyTop])); - } + case_531(); break; case 532: case_532(); break; case 533: -#line 3840 "cs-parser.jay" - { - start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], true, GetLocation (yyVals[-2+yyTop])); - } + case_533(); break; case 534: - case_534(); +#line 3848 "cs-parser.jay" + { + start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], false, GetLocation (yyVals[-1+yyTop])); + } break; case 535: -#line 3857 "cs-parser.jay" + case_535(); + break; +case 536: +#line 3861 "cs-parser.jay" { - yyVal = ParametersCompiled.Undefined; + start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], true, GetLocation (yyVals[-2+yyTop])); } break; case 537: -#line 3865 "cs-parser.jay" + case_537(); + break; +case 538: +#line 3878 "cs-parser.jay" + { + yyVal = ParametersCompiled.Undefined; + } + break; +case 540: +#line 3886 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 538: - case_538(); +case 541: + case_541(); break; -case 539: - case_539(); +case 542: + case_542(); break; -case 541: -#line 3891 "cs-parser.jay" +case 544: +#line 3912 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 542: -#line 3895 "cs-parser.jay" +case 545: +#line 3916 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 543: - case_543(); +case 546: + case_546(); break; -case 544: - case_544(); +case 547: + case_547(); break; -case 546: -#line 3931 "cs-parser.jay" +case 549: +#line 3952 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 547: -#line 3935 "cs-parser.jay" +case 550: +#line 3956 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 548: -#line 3939 "cs-parser.jay" +case 551: +#line 3960 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 549: -#line 3943 "cs-parser.jay" +case 552: +#line 3964 "cs-parser.jay" { yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 550: -#line 3947 "cs-parser.jay" +case 553: +#line 3968 "cs-parser.jay" { yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 551: -#line 3951 "cs-parser.jay" +case 554: +#line 3972 "cs-parser.jay" { yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 553: - case_553(); - break; -case 554: - case_554(); - break; -case 555: - case_555(); +case 556: + case_556(); break; case 557: 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 559: - case_559(); + case_558(); break; case 560: -#line 3992 "cs-parser.jay" + case_560(); + break; +case 561: + case_561(); + break; +case 562: +#line 4009 "cs-parser.jay" { yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 561: -#line 3996 "cs-parser.jay" +case 563: +#line 4013 "cs-parser.jay" { yyVal = new Is ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } break; -case 563: - case_563(); - break; -case 564: - case_564(); +case 565: + case_565(); break; case 566: case_566(); break; -case 567: - case_567(); - break; case 568: case_568(); break; case 569: case_569(); break; +case 570: + case_570(); + break; case 571: case_571(); break; -case 572: - case_572(); +case 573: + case_573(); break; case 574: case_574(); @@ -3049,14 +3056,8 @@ case 584: case 586: case_586(); break; -case 587: - case_587(); - break; case 588: -#line 4125 "cs-parser.jay" - { - yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_588(); break; case 589: case_589(); @@ -3104,27 +3105,27 @@ case 603: case_603(); break; case 604: -#line 4222 "cs-parser.jay" - { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } + case_604(); break; case 605: case_605(); break; -case 608: -#line 4238 "cs-parser.jay" +case 606: +#line 4241 "cs-parser.jay" + { yyVal = ParametersCompiled.EmptyReadOnlyParameters; } + break; +case 607: + case_607(); + break; +case 610: +#line 4257 "cs-parser.jay" { start_block (Location.Null); } break; -case 609: - case_609(); - break; case 611: case_611(); break; -case 612: - case_612(); - break; case 613: case_613(); break; @@ -3135,62 +3136,62 @@ case 615: case_615(); break; case 616: -#line 4283 "cs-parser.jay" - { - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; - } + case_616(); break; case 617: case_617(); break; case 618: - case_618(); - break; -case 619: -#line 4297 "cs-parser.jay" +#line 4302 "cs-parser.jay" { - valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; +case 619: + case_619(); + break; case 620: case_620(); break; case 621: - case_621(); - break; -case 627: -#line 4322 "cs-parser.jay" +#line 4316 "cs-parser.jay" { - yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); + valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 628: - case_628(); +case 622: + case_622(); + break; +case 623: + case_623(); break; case 629: - case_629(); +#line 4341 "cs-parser.jay" + { + yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop])); + } break; case 630: case_630(); break; +case 631: + case_631(); + break; case 632: -#line 4351 "cs-parser.jay" + case_632(); + break; +case 634: +#line 4370 "cs-parser.jay" { yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]); } break; -case 633: -#line 4364 "cs-parser.jay" +case 635: +#line 4383 "cs-parser.jay" { lexer.ConstraintsParsing = true; } break; -case 634: - case_634(); - break; -case 635: - case_635(); - break; case 636: case_636(); break; @@ -3198,28 +3199,28 @@ case 637: case_637(); break; case 638: -#line 4409 "cs-parser.jay" - { yyVal = null; } + case_638(); break; case 639: -#line 4411 "cs-parser.jay" - { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } + case_639(); break; case 640: - case_640(); +#line 4428 "cs-parser.jay" + { yyVal = null; } break; case 641: -#line 4424 "cs-parser.jay" +#line 4430 "cs-parser.jay" + { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); } + break; +case 642: + case_642(); + break; +case 643: +#line 4443 "cs-parser.jay" { lexer.parsing_modifiers = false; } break; -case 643: - case_643(); - break; -case 644: - case_644(); - break; case 645: case_645(); break; @@ -3262,24 +3263,24 @@ case 657: case 658: case_658(); break; +case 659: + case_659(); + break; case 660: case_660(); break; -case 661: - case_661(); +case 662: + case_662(); break; case 663: -#line 4550 "cs-parser.jay" + case_663(); + break; +case 665: +#line 4569 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; -case 664: - case_664(); - break; -case 665: - case_665(); - break; case 666: case_666(); break; @@ -3299,29 +3300,29 @@ case 671: case_671(); break; case 672: -#line 4643 "cs-parser.jay" + case_672(); + break; +case 673: + case_673(); + break; +case 674: +#line 4662 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop])); } break; -case 673: -#line 4647 "cs-parser.jay" +case 675: +#line 4666 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop])); } break; -case 674: -#line 4654 "cs-parser.jay" +case 676: +#line 4673 "cs-parser.jay" { yyVal = Variance.None; } break; -case 675: - case_675(); - break; -case 676: - case_676(); - break; case 677: case_677(); break; @@ -3329,16 +3330,16 @@ case 678: case_678(); break; case 679: -#line 4699 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_679(); break; case 680: case_680(); break; case 681: - case_681(); +#line 4718 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 682: case_682(); @@ -3349,42 +3350,42 @@ case 683: case 684: case_684(); break; -case 689: -#line 4748 "cs-parser.jay" +case 685: + case_685(); + break; +case 686: + case_686(); + break; +case 691: +#line 4767 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 690: -#line 4752 "cs-parser.jay" +case 692: +#line 4771 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 692: - case_692(); +case 694: + case_694(); break; -case 693: - case_693(); +case 695: + case_695(); break; -case 696: -#line 4786 "cs-parser.jay" +case 698: +#line 4805 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 697: -#line 4790 "cs-parser.jay" +case 699: +#line 4809 "cs-parser.jay" { current_block.AddStatement ((Statement) yyVals[0+yyTop]); } break; -case 726: - case_726(); - break; -case 727: - case_727(); - break; case 728: case_728(); break; @@ -3394,11 +3395,11 @@ case 729: case 730: case_730(); break; -case 733: - case_733(); +case 731: + case_731(); break; -case 734: - case_734(); +case 732: + case_732(); break; case 735: case_735(); @@ -3407,35 +3408,35 @@ case 736: case_736(); break; case 737: -#line 4934 "cs-parser.jay" + case_737(); + break; +case 738: + case_738(); + break; +case 739: +#line 4953 "cs-parser.jay" { yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 738: -#line 4938 "cs-parser.jay" +case 740: +#line 4957 "cs-parser.jay" { yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]); } break; -case 739: - case_739(); - break; case 741: case_741(); break; -case 742: -#line 4959 "cs-parser.jay" +case 743: + case_743(); + break; +case 744: +#line 4978 "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; @@ -3445,123 +3446,123 @@ case 747: case 748: case_748(); break; +case 749: + case_749(); + break; case 750: case_750(); break; case 752: case_752(); break; -case 753: - case_753(); - break; case 754: case_754(); break; -case 758: - case_758(); +case 755: + case_755(); break; -case 761: - case_761(); +case 756: + case_756(); break; -case 762: - case_762(); +case 760: + case_760(); break; case 763: -#line 5094 "cs-parser.jay" - { - report.Error (145, lexer.Location, "A const field requires a value to be provided"); - } + case_763(); break; case 764: case_764(); break; -case 769: - case_769(); +case 765: +#line 5113 "cs-parser.jay" + { + report.Error (145, lexer.Location, "A const field requires a value to be provided"); + } + break; +case 766: + case_766(); break; case 771: case_771(); break; -case 772: - case_772(); - break; case 773: case_773(); break; case 774: -#line 5144 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } + case_774(); break; case 775: case_775(); break; case 776: -#line 5154 "cs-parser.jay" +#line 5163 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; case 777: -#line 5155 "cs-parser.jay" - { yyVal = yyVals[-1+yyTop]; } + case_777(); break; case 778: - case_778(); +#line 5173 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } break; case 779: - case_779(); +#line 5174 "cs-parser.jay" + { yyVal = yyVals[-1+yyTop]; } break; case 780: case_780(); break; -case 783: - case_783(); +case 781: + case_781(); break; -case 784: - case_784(); +case 782: + case_782(); break; case 785: case_785(); break; case 786: -#line 5230 "cs-parser.jay" - { - start_block (GetLocation (yyVals[0+yyTop])); - } + case_786(); break; case 787: case_787(); break; case 788: - case_788(); +#line 5249 "cs-parser.jay" + { + start_block (GetLocation (yyVals[0+yyTop])); + } break; case 789: case_789(); break; +case 790: + case_790(); + break; case 791: case_791(); break; -case 792: - case_792(); - break; case 793: case_793(); break; case 794: -#line 5281 "cs-parser.jay" + case_794(); + break; +case 795: + case_795(); + break; +case 796: +#line 5300 "cs-parser.jay" { current_block = current_block.CreateSwitchBlock (lexer.Location); } break; -case 795: -#line 5285 "cs-parser.jay" +case 797: +#line 5304 "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; @@ -3569,17 +3570,17 @@ case 799: case_799(); break; case 800: -#line 5319 "cs-parser.jay" + case_800(); + break; +case 801: + case_801(); + break; +case 802: +#line 5338 "cs-parser.jay" { yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop])); } break; -case 805: - case_805(); - break; -case 806: - case_806(); - break; case 807: case_807(); break; @@ -3593,16 +3594,13 @@ case 810: case_810(); break; case 811: -#line 5380 "cs-parser.jay" - { - yyVal = yyVals[0+yyTop]; - } + case_811(); break; case 812: case_812(); break; case 813: -#line 5395 "cs-parser.jay" +#line 5399 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } @@ -3611,46 +3609,49 @@ case 814: case_814(); break; case 815: - case_815(); - break; -case 816: -#line 5416 "cs-parser.jay" +#line 5414 "cs-parser.jay" { yyVal = yyVals[0+yyTop]; } break; +case 816: + case_816(); + break; case 817: case_817(); break; case 818: - case_818(); +#line 5435 "cs-parser.jay" + { + yyVal = yyVals[0+yyTop]; + } break; case 819: case_819(); break; case 820: -#line 5449 "cs-parser.jay" - { yyVal = new EmptyStatement (lexer.Location); } + case_820(); + break; +case 821: + case_821(); break; case 822: - case_822(); +#line 5469 "cs-parser.jay" + { yyVal = new EmptyStatement (lexer.Location); } break; -case 823: - case_823(); +case 824: + case_824(); break; case 825: -#line 5470 "cs-parser.jay" - { yyVal = null; } + case_825(); break; case 827: -#line 5475 "cs-parser.jay" - { yyVal = new EmptyStatement (lexer.Location); } - break; -case 831: - case_831(); +#line 5490 "cs-parser.jay" + { yyVal = null; } break; -case 832: - case_832(); +case 829: +#line 5495 "cs-parser.jay" + { yyVal = new EmptyStatement (lexer.Location); } break; case 833: case_833(); @@ -3667,11 +3668,11 @@ case 836: case 837: case_837(); break; -case 844: - case_844(); +case 838: + case_838(); break; -case 845: - case_845(); +case 839: + case_839(); break; case 846: case_846(); @@ -3703,77 +3704,77 @@ case 854: case 855: case_855(); break; +case 856: + case_856(); + break; +case 857: + case_857(); + break; case 858: -#line 5692 "cs-parser.jay" - { - yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); - } + case_858(); break; case 859: case_859(); break; -case 860: - case_860(); - break; -case 861: - case_861(); - break; case 862: - case_862(); +#line 5735 "cs-parser.jay" + { + yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false); + } break; case 863: case_863(); break; +case 864: + case_864(); + break; +case 865: + case_865(); + break; case 866: -#line 5742 "cs-parser.jay" - { - yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); - } + case_866(); break; case 867: case_867(); break; -case 868: -#line 5761 "cs-parser.jay" - { - yyVal = yyVals[-1+yyTop]; - } - break; -case 869: - case_869(); - break; case 870: -#line 5779 "cs-parser.jay" +#line 5785 "cs-parser.jay" { - yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Catch ((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])); - } + case_871(); break; case 872: - case_872(); - break; -case 873: -#line 5796 "cs-parser.jay" +#line 5804 "cs-parser.jay" { - yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); + yyVal = yyVals[-1+yyTop]; } break; +case 873: + case_873(); + break; case 874: - case_874(); +#line 5822 "cs-parser.jay" + { + yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 875: - case_875(); +#line 5829 "cs-parser.jay" + { + yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + } break; case 876: case_876(); break; case 877: - case_877(); +#line 5839 "cs-parser.jay" + { + yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); + } break; case 878: case_878(); @@ -3793,26 +3794,26 @@ case 882: case 883: case_883(); break; +case 884: + case_884(); + break; case 885: case_885(); break; case 886: -#line 5901 "cs-parser.jay" - { - Error_MissingInitializer (lexer.Location); - } + case_886(); break; case 887: case_887(); break; -case 888: - case_888(); - break; case 889: case_889(); break; case 890: - case_890(); +#line 5944 "cs-parser.jay" + { + Error_MissingInitializer (lexer.Location); + } break; case 891: case_891(); @@ -3830,29 +3831,32 @@ case 895: case_895(); break; case 896: -#line 6006 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_896(); break; case 897: case_897(); break; case 898: -#line 6022 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_898(); break; case 899: case_899(); break; case 900: - case_900(); +#line 6049 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } break; case 901: case_901(); break; +case 902: +#line 6065 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } + break; case 903: case_903(); break; @@ -3860,13 +3864,7 @@ 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(); + case_905(); break; case 907: case_907(); @@ -3875,37 +3873,40 @@ case 908: case_908(); break; case 909: - case_909(); +#line 6129 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } + break; +case 910: + case_910(); break; case 911: case_911(); break; -case 917: -#line 6140 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } +case 912: + case_912(); + break; +case 913: + case_913(); break; -case 918: - case_918(); +case 915: + case_915(); break; -case 919: -#line 6159 "cs-parser.jay" +case 921: +#line 6183 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); } break; -case 920: - case_920(); - break; -case 921: - case_921(); - break; case 922: case_922(); break; case 923: - case_923(); +#line 6202 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } break; case 924: case_924(); @@ -3922,14 +3923,14 @@ case 927: case 928: case_928(); break; +case 929: + case_929(); + break; case 930: case_930(); break; case 931: -#line 6313 "cs-parser.jay" - { - current_block = new Linq.QueryBlock (current_block, lexer.Location); - } + case_931(); break; case 932: case_932(); @@ -3938,124 +3939,136 @@ case 934: case_934(); break; case 935: - case_935(); +#line 6356 "cs-parser.jay" + { + current_block = new Linq.QueryBlock (current_block, lexer.Location); + } break; -case 937: - case_937(); +case 936: + case_936(); 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(); + case_939(); 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]); - } + case_942(); break; case 943: - case_943(); +#line 6402 "cs-parser.jay" + { + yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); + } break; case 944: case_944(); break; +case 945: + case_945(); + break; case 946: - case_946(); +#line 6419 "cs-parser.jay" + { + yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]); + } break; case 947: case_947(); break; +case 948: + case_948(); + break; case 950: case_950(); break; case 951: case_951(); break; -case 959: -#line 6498 "cs-parser.jay" +case 954: + case_954(); + break; +case 955: + case_955(); + break; +case 963: +#line 6541 "cs-parser.jay" { module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop]; } break; -case 960: -#line 6505 "cs-parser.jay" +case 964: +#line 6548 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; } break; -case 961: - case_961(); +case 965: + case_965(); break; -case 962: - case_962(); +case 966: + case_966(); break; -case 963: -#line 6522 "cs-parser.jay" +case 967: +#line 6565 "cs-parser.jay" { yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], MemberCache.IndexerNameAlias, Location.Null); } break; -case 964: -#line 6526 "cs-parser.jay" +case 968: +#line 6569 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 965: - case_965(); +case 969: + case_969(); break; -case 966: - case_966(); +case 970: + case_970(); break; -case 967: - case_967(); +case 971: + case_971(); break; -case 968: - case_968(); +case 972: + case_972(); break; -case 970: -#line 6562 "cs-parser.jay" +case 974: +#line 6605 "cs-parser.jay" { yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]); } break; -case 972: -#line 6570 "cs-parser.jay" +case 976: +#line 6613 "cs-parser.jay" { valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out; } break; -case 973: -#line 6574 "cs-parser.jay" +case 977: +#line 6617 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; } break; -case 974: -#line 6581 "cs-parser.jay" +case 978: +#line 6624 "cs-parser.jay" { yyVal = new List (0); } break; -case 976: - case_976(); +case 980: + case_980(); break; -case 977: - case_977(); +case 981: + case_981(); break; -case 978: - case_978(); +case 982: + case_982(); break; #line default } @@ -4093,7 +4106,7 @@ case 978: All more than 3 lines long rules are wrapped into a method */ void case_6() -#line 398 "cs-parser.jay" +#line 393 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { Attributes attrs = (Attributes) yyVals[0+yyTop]; @@ -4105,7 +4118,7 @@ void case_6() } void case_8() -#line 412 "cs-parser.jay" +#line 407 "cs-parser.jay" { if (yyToken == Token.EXTERN_ALIAS) report.Error (439, lexer.Location, "An extern alias declaration must precede all other elements"); @@ -4114,7 +4127,7 @@ void case_8() } void case_13() -#line 432 "cs-parser.jay" +#line 427 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -4137,14 +4150,14 @@ void case_13() } void case_17() -#line 465 "cs-parser.jay" +#line 460 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_18() -#line 473 "cs-parser.jay" +#line 468 "cs-parser.jay" { var un = new UsingNamespace ((ATypeNameExpression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); current_namespace.AddUsing (un); @@ -4153,7 +4166,7 @@ void case_18() } void case_19() -#line 480 "cs-parser.jay" +#line 475 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lang_version != LanguageVersion.ISO_1 && lt.Value == "global") { @@ -4167,14 +4180,14 @@ void case_19() } void case_20() -#line 492 "cs-parser.jay" +#line 487 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_21() -#line 505 "cs-parser.jay" +#line 500 "cs-parser.jay" { Attributes attrs = (Attributes) yyVals[-2+yyTop]; var name = (MemberName) yyVals[0+yyTop]; @@ -4204,14 +4217,14 @@ void case_21() } void case_22() -#line 533 "cs-parser.jay" +#line 528 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_23() -#line 538 "cs-parser.jay" +#line 533 "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])); @@ -4222,14 +4235,14 @@ void case_23() } void case_24() -#line 550 "cs-parser.jay" +#line 545 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName (lt.Value, lt.Location); } void case_25() -#line 555 "cs-parser.jay" +#line 550 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], lt.Value, lt.Location) { @@ -4238,14 +4251,14 @@ void case_25() } void case_26() -#line 562 "cs-parser.jay" +#line 557 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new MemberName ("", lexer.Location); } void case_39() -#line 600 "cs-parser.jay" +#line 595 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { TypeContainer ds = (TypeContainer)yyVals[0+yyTop]; @@ -4266,7 +4279,7 @@ void case_39() } void case_41() -#line 622 "cs-parser.jay" +#line 617 "cs-parser.jay" { current_namespace.UnattachedAttributes = (Attributes) yyVals[-1+yyTop]; report.Error (1518, lexer.Location, "Attributes must be attached to class, delegate, enum, interface or struct"); @@ -4274,7 +4287,7 @@ void case_41() } void case_49() -#line 655 "cs-parser.jay" +#line 650 "cs-parser.jay" { var sect = (List) yyVals[0+yyTop]; yyVal = new Attributes (sect); @@ -4287,7 +4300,7 @@ void case_49() } void case_50() -#line 666 "cs-parser.jay" +#line 661 "cs-parser.jay" { Attributes attrs = yyVals[-1+yyTop] as Attributes; var sect = (List) yyVals[0+yyTop]; @@ -4302,21 +4315,21 @@ void case_50() } void case_51() -#line 682 "cs-parser.jay" +#line 677 "cs-parser.jay" { lexer.parsing_attribute_section = true; savedOpenLocation = GetLocation (yyVals[0+yyTop]); } void case_52() -#line 687 "cs-parser.jay" +#line 682 "cs-parser.jay" { lexer.parsing_attribute_section = false; yyVal = yyVals[0+yyTop]; } void case_53() -#line 695 "cs-parser.jay" +#line 690 "cs-parser.jay" { current_attr_target = (string) yyVals[-1+yyTop]; if (current_attr_target == "assembly" || current_attr_target == "module") { @@ -4325,7 +4338,7 @@ void case_53() } void case_54() -#line 702 "cs-parser.jay" +#line 697 "cs-parser.jay" { /* when attribute target is invalid*/ if (current_attr_target == string.Empty) @@ -4343,7 +4356,7 @@ void case_54() } void case_55() -#line 718 "cs-parser.jay" +#line 713 "cs-parser.jay" { yyVal = yyVals[-2+yyTop]; if (yyVals[-1+yyTop] != null) { @@ -4354,7 +4367,7 @@ void case_55() } void case_56() -#line 730 "cs-parser.jay" +#line 725 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = CheckAttributeTarget (lt.Value, lt.Location); @@ -4362,7 +4375,7 @@ void case_56() } void case_59() -#line 738 "cs-parser.jay" +#line 733 "cs-parser.jay" { if (yyToken == Token.IDENTIFIER) { Error_SyntaxError (yyToken); @@ -4374,7 +4387,7 @@ void case_59() } void case_61() -#line 755 "cs-parser.jay" +#line 750 "cs-parser.jay" { var attrs = (List) yyVals[-2+yyTop]; attrs.Add ((Attribute) yyVals[0+yyTop]); @@ -4384,7 +4397,7 @@ void case_61() } void case_63() -#line 770 "cs-parser.jay" +#line 765 "cs-parser.jay" { --lexer.parsing_block; @@ -4406,7 +4419,7 @@ void case_63() } void case_66() -#line 798 "cs-parser.jay" +#line 793 "cs-parser.jay" { savedAttrParenOpenLocation = GetLocation (yyVals[-2+yyTop]); savedAttrParenCloseLocation = GetLocation (yyVals[0+yyTop]); @@ -4415,7 +4428,7 @@ void case_66() } void case_68() -#line 810 "cs-parser.jay" +#line 805 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); @@ -4423,7 +4436,7 @@ void case_68() } void case_69() -#line 816 "cs-parser.jay" +#line 811 "cs-parser.jay" { Arguments a = new Arguments (4); a.Add ((Argument) yyVals[0+yyTop]); @@ -4431,7 +4444,7 @@ void case_69() } void case_70() -#line 822 "cs-parser.jay" +#line 817 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] != null) { @@ -4448,7 +4461,7 @@ void case_70() } void case_71() -#line 837 "cs-parser.jay" +#line 832 "cs-parser.jay" { Arguments[] o = (Arguments[]) yyVals[-2+yyTop]; if (o [1] == null) { @@ -4460,7 +4473,7 @@ void case_71() } void case_75() -#line 862 "cs-parser.jay" +#line 857 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4469,7 +4482,7 @@ void case_75() } void case_76() -#line 872 "cs-parser.jay" +#line 867 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "named argument"); @@ -4483,7 +4496,7 @@ void case_76() } void case_95() -#line 926 "cs-parser.jay" +#line 921 "cs-parser.jay" { report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration", GetSymbolName (yyToken)); @@ -4492,14 +4505,14 @@ void case_95() } void case_97() -#line 943 "cs-parser.jay" +#line 938 "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 949 "cs-parser.jay" +#line 944 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -4514,14 +4527,14 @@ void case_98() } void case_99() -#line 962 "cs-parser.jay" +#line 957 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } void case_100() -#line 967 "cs-parser.jay" +#line 962 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -4529,7 +4542,7 @@ void case_100() } void case_101() -#line 973 "cs-parser.jay" +#line 968 "cs-parser.jay" { if (yyVals[0+yyTop] == null) { lbag.AppendToMember (current_container, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop])); @@ -4540,7 +4553,7 @@ void case_101() } void case_103() -#line 991 "cs-parser.jay" +#line 986 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var mod = (Modifiers) yyVals[-3+yyTop]; @@ -4555,7 +4568,7 @@ void case_103() } void case_104() -#line 1004 "cs-parser.jay" +#line 999 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4568,7 +4581,7 @@ void case_104() } void case_109() -#line 1034 "cs-parser.jay" +#line 1029 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4576,7 +4589,7 @@ void case_109() } void case_111() -#line 1047 "cs-parser.jay" +#line 1042 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -4584,14 +4597,14 @@ void case_111() } void case_112() -#line 1053 "cs-parser.jay" +#line 1048 "cs-parser.jay" { report.Error (145, lexer.Location, "A const field requires a value to be provided"); yyVal = null; } void case_115() -#line 1068 "cs-parser.jay" +#line 1063 "cs-parser.jay" { lexer.parsing_generic_declaration = false; @@ -4606,7 +4619,7 @@ void case_115() } void case_116() -#line 1083 "cs-parser.jay" +#line 1078 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4619,7 +4632,7 @@ void case_116() } void case_117() -#line 1096 "cs-parser.jay" +#line 1091 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "fixed size buffers"); @@ -4632,7 +4645,7 @@ void case_117() } void case_118() -#line 1107 "cs-parser.jay" +#line 1102 "cs-parser.jay" { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment (); @@ -4646,7 +4659,7 @@ void case_118() } void case_121() -#line 1130 "cs-parser.jay" +#line 1125 "cs-parser.jay" { ++lexer.parsing_block; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -4654,7 +4667,7 @@ void case_121() } void case_122() -#line 1136 "cs-parser.jay" +#line 1131 "cs-parser.jay" { --lexer.parsing_block; current_field.Initializer = (Expression) yyVals[0+yyTop]; @@ -4664,7 +4677,7 @@ void case_122() } void case_127() -#line 1163 "cs-parser.jay" +#line 1158 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); @@ -4672,7 +4685,7 @@ void case_127() } void case_129() -#line 1173 "cs-parser.jay" +#line 1168 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -4681,7 +4694,7 @@ void case_129() } void case_134() -#line 1199 "cs-parser.jay" +#line 1194 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) yyVals[0+yyTop]); @@ -4689,7 +4702,7 @@ void case_134() } void case_136() -#line 1212 "cs-parser.jay" +#line 1207 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstInitializer (current_field, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); @@ -4697,14 +4710,14 @@ void case_136() } void case_137() -#line 1218 "cs-parser.jay" +#line 1213 "cs-parser.jay" { report.Error (443, lexer.Location, "Value or constant expected"); yyVal = null; } void case_140() -#line 1228 "cs-parser.jay" +#line 1223 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); @@ -4712,7 +4725,7 @@ void case_140() } void case_141() -#line 1237 "cs-parser.jay" +#line 1232 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.NotAllowed; @@ -4724,7 +4737,7 @@ void case_141() } void case_142() -#line 1247 "cs-parser.jay" +#line 1242 "cs-parser.jay" { Method method = (Method) yyVals[-2+yyTop]; method.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -4752,7 +4765,7 @@ void case_142() } void case_145() -#line 1287 "cs-parser.jay" +#line 1282 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4773,14 +4786,14 @@ void case_145() } void case_147() -#line 1314 "cs-parser.jay" +#line 1309 "cs-parser.jay" { lexer.parsing_generic_declaration = false; valid_param_mod = ParameterModifierType.All; } void case_149() -#line 1323 "cs-parser.jay" +#line 1318 "cs-parser.jay" { lexer.ConstraintsParsing = false; valid_param_mod = 0; @@ -4806,7 +4819,7 @@ void case_149() } void case_150() -#line 1350 "cs-parser.jay" +#line 1345 "cs-parser.jay" { MemberName name = (MemberName) yyVals[-3+yyTop]; report.Error (1585, name.Location, @@ -4824,7 +4837,7 @@ void case_150() } void case_151() -#line 1369 "cs-parser.jay" +#line 1364 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.Undefined; @@ -4840,7 +4853,7 @@ void case_151() } void case_156() -#line 1396 "cs-parser.jay" +#line 1391 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); @@ -4848,7 +4861,7 @@ void case_156() } void case_157() -#line 1402 "cs-parser.jay" +#line 1397 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add ((Parameter) yyVals[0+yyTop]); @@ -4859,7 +4872,7 @@ void case_157() } void case_158() -#line 1411 "cs-parser.jay" +#line 1406 "cs-parser.jay" { var pars_list = (List) yyVals[-2+yyTop]; pars_list.Add (new ArglistParameter (GetLocation (yyVals[0+yyTop]))); @@ -4870,7 +4883,7 @@ void case_158() } void case_159() -#line 1420 "cs-parser.jay" +#line 1415 "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"); @@ -4880,7 +4893,7 @@ void case_159() } void case_160() -#line 1428 "cs-parser.jay" +#line 1423 "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"); @@ -4895,7 +4908,7 @@ void case_160() } void case_161() -#line 1441 "cs-parser.jay" +#line 1436 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4904,7 +4917,7 @@ void case_161() } void case_162() -#line 1448 "cs-parser.jay" +#line 1443 "cs-parser.jay" { report.Error (257, GetLocation (yyVals[-2+yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); @@ -4918,14 +4931,14 @@ void case_162() } void case_165() -#line 1468 "cs-parser.jay" +#line 1463 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = ParametersCompiled.EmptyReadOnlyParameters; } void case_166() -#line 1476 "cs-parser.jay" +#line 1471 "cs-parser.jay" { parameters_bucket.Clear (); Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4936,7 +4949,7 @@ void case_166() } void case_167() -#line 1485 "cs-parser.jay" +#line 1480 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter) yyVals[0+yyTop]; @@ -4956,7 +4969,7 @@ void case_167() } void case_168() -#line 1509 "cs-parser.jay" +#line 1504 "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); @@ -4964,7 +4977,7 @@ void case_168() } void case_169() -#line 1518 "cs-parser.jay" +#line 1513 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; report.Error (1552, lt.Location, "Array type specifier, [], must appear before parameter name"); @@ -4973,7 +4986,7 @@ void case_169() } void case_170() -#line 1525 "cs-parser.jay" +#line 1520 "cs-parser.jay" { Error_SyntaxError (yyToken); Location l = GetLocation (yyVals[0+yyTop]); @@ -4981,7 +4994,7 @@ void case_170() } void case_171() -#line 1534 "cs-parser.jay" +#line 1529 "cs-parser.jay" { Error_SyntaxError (yyToken); Location l = GetLocation (yyVals[0+yyTop]); @@ -4990,7 +5003,7 @@ void case_171() } void case_173() -#line 1549 "cs-parser.jay" +#line 1544 "cs-parser.jay" { --lexer.parsing_block; if (lang_version <= LanguageVersion.V_3) { @@ -5029,7 +5042,7 @@ void case_173() } void case_177() -#line 1598 "cs-parser.jay" +#line 1593 "cs-parser.jay" { Parameter.Modifier p2 = (Parameter.Modifier)yyVals[0+yyTop]; Parameter.Modifier mod = (Parameter.Modifier)yyVals[-1+yyTop] | p2; @@ -5052,7 +5065,7 @@ void case_177() } void case_178() -#line 1622 "cs-parser.jay" +#line 1617 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Ref) == 0) Error_ParameterModifierNotValid ("ref", GetLocation (yyVals[0+yyTop])); @@ -5061,7 +5074,7 @@ void case_178() } void case_179() -#line 1629 "cs-parser.jay" +#line 1624 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.Out) == 0) Error_ParameterModifierNotValid ("out", GetLocation (yyVals[0+yyTop])); @@ -5070,7 +5083,7 @@ void case_179() } void case_180() -#line 1636 "cs-parser.jay" +#line 1631 "cs-parser.jay" { if ((valid_param_mod & ParameterModifierType.This) == 0) Error_ParameterModifierNotValid ("this", GetLocation (yyVals[0+yyTop])); @@ -5082,7 +5095,7 @@ void case_180() } void case_181() -#line 1649 "cs-parser.jay" +#line 1644 "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); @@ -5090,7 +5103,7 @@ void case_181() } void case_182() -#line 1655 "cs-parser.jay" +#line 1650 "cs-parser.jay" { report.Error (1751, GetLocation (yyVals[-4+yyTop]), "Cannot specify a default value for a parameter array"); @@ -5100,14 +5113,14 @@ void case_182() } void case_183() -#line 1663 "cs-parser.jay" +#line 1658 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_184() -#line 1671 "cs-parser.jay" +#line 1666 "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"); @@ -5115,7 +5128,7 @@ void case_184() } void case_185() -#line 1677 "cs-parser.jay" +#line 1672 "cs-parser.jay" { Parameter.Modifier mod = (Parameter.Modifier)yyVals[0+yyTop]; if ((mod & Parameter.Modifier.This) != 0) { @@ -5127,21 +5140,21 @@ void case_185() } void case_187() -#line 1694 "cs-parser.jay" +#line 1689 "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_188() -#line 1705 "cs-parser.jay" +#line 1700 "cs-parser.jay" { if (doc_support) tmpComment = Lexer.consume_doc_comment (); } void case_189() -#line 1710 "cs-parser.jay" +#line 1705 "cs-parser.jay" { var type = (FullNamedExpression) yyVals[-3+yyTop]; current_property = new Property (current_type, type, (Modifiers) yyVals[-4+yyTop], @@ -5157,7 +5170,7 @@ void case_189() } void case_190() -#line 1724 "cs-parser.jay" +#line 1719 "cs-parser.jay" { lexer.PropertyParsing = false; @@ -5166,14 +5179,14 @@ void case_190() } void case_191() -#line 1731 "cs-parser.jay" +#line 1726 "cs-parser.jay" { lbag.AppendToMember (current_property, GetLocation (yyVals[0+yyTop])); current_property = null; } void case_193() -#line 1745 "cs-parser.jay" +#line 1740 "cs-parser.jay" { valid_param_mod = 0; var type = (FullNamedExpression) yyVals[-6+yyTop]; @@ -5200,7 +5213,7 @@ void case_193() } void case_195() -#line 1774 "cs-parser.jay" +#line 1769 "cs-parser.jay" { if (current_property.AccessorFirst != null && current_property.AccessorFirst.Block == null) ((Indexer) current_property).ParameterInfo.CheckParameters (current_property); @@ -5213,7 +5226,7 @@ void case_195() } void case_200() -#line 1793 "cs-parser.jay" +#line 1788 "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 ()); @@ -5226,7 +5239,7 @@ void case_200() } void case_201() -#line 1807 "cs-parser.jay" +#line 1802 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5249,7 +5262,7 @@ void case_201() } void case_202() -#line 1828 "cs-parser.jay" +#line 1823 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Get.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5272,7 +5285,7 @@ void case_202() } void case_203() -#line 1852 "cs-parser.jay" +#line 1847 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "access modifiers on properties"); @@ -5300,7 +5313,7 @@ void case_203() } void case_204() -#line 1878 "cs-parser.jay" +#line 1873 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { current_property.Set.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5323,28 +5336,28 @@ void case_204() } void case_206() -#line 1903 "cs-parser.jay" +#line 1898 "cs-parser.jay" { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; } void case_207() -#line 1908 "cs-parser.jay" +#line 1903 "cs-parser.jay" { Error_SyntaxError (1043, yyToken, "Invalid accessor body"); yyVal = null; } void case_209() -#line 1923 "cs-parser.jay" +#line 1918 "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_210() -#line 1929 "cs-parser.jay" +#line 1924 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -5360,7 +5373,7 @@ void case_210() } void case_211() -#line 1943 "cs-parser.jay" +#line 1938 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) @@ -5368,7 +5381,7 @@ void case_211() } void case_212() -#line 1949 "cs-parser.jay" +#line 1944 "cs-parser.jay" { if (yyVals[0+yyTop] == null) { lbag.AppendToMember (current_container, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); @@ -5379,7 +5392,7 @@ void case_212() } void case_228() -#line 2011 "cs-parser.jay" +#line 2006 "cs-parser.jay" { OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop]; if (decl != null) { @@ -5409,14 +5422,14 @@ void case_228() } void case_232() -#line 2048 "cs-parser.jay" +#line 2043 "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_234() -#line 2060 "cs-parser.jay" +#line 2055 "cs-parser.jay" { valid_param_mod = 0; @@ -5458,7 +5471,7 @@ void case_234() } void case_259() -#line 2136 "cs-parser.jay" +#line 2131 "cs-parser.jay" { valid_param_mod = 0; @@ -5475,7 +5488,7 @@ void case_259() } void case_261() -#line 2155 "cs-parser.jay" +#line 2150 "cs-parser.jay" { valid_param_mod = 0; @@ -5492,7 +5505,7 @@ void case_261() } void case_262() -#line 2170 "cs-parser.jay" +#line 2165 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -5500,7 +5513,7 @@ void case_262() } void case_263() -#line 2176 "cs-parser.jay" +#line 2171 "cs-parser.jay" { Error_SyntaxError (yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; @@ -5508,7 +5521,7 @@ void case_263() } void case_264() -#line 2186 "cs-parser.jay" +#line 2181 "cs-parser.jay" { Constructor c = (Constructor) yyVals[-1+yyTop]; c.Block = (ToplevelBlock) yyVals[0+yyTop]; @@ -5522,7 +5535,7 @@ void case_264() } void case_265() -#line 2203 "cs-parser.jay" +#line 2198 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5533,7 +5546,7 @@ void case_265() } void case_266() -#line 2212 "cs-parser.jay" +#line 2207 "cs-parser.jay" { valid_param_mod = 0; current_local_parameters = (ParametersCompiled) yyVals[-1+yyTop]; @@ -5564,7 +5577,7 @@ void case_266() } void case_267() -#line 2241 "cs-parser.jay" +#line 2236 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { var c = (Constructor) yyVals[-1+yyTop]; @@ -5581,7 +5594,7 @@ void case_267() } void case_273() -#line 2273 "cs-parser.jay" +#line 2268 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorBaseInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -5589,7 +5602,7 @@ void case_273() } void case_275() -#line 2283 "cs-parser.jay" +#line 2278 "cs-parser.jay" { --lexer.parsing_block; yyVal = new ConstructorThisInitializer ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop])); @@ -5597,7 +5610,7 @@ void case_275() } void case_276() -#line 2289 "cs-parser.jay" +#line 2284 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ConstructorThisInitializer (null, GetLocation (yyVals[0+yyTop])); @@ -5605,14 +5618,14 @@ void case_276() } void case_277() -#line 2295 "cs-parser.jay" +#line 2290 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } void case_278() -#line 2303 "cs-parser.jay" +#line 2298 "cs-parser.jay" { if (doc_support) { tmpComment = Lexer.consume_doc_comment (); @@ -5623,7 +5636,7 @@ void case_278() } void case_279() -#line 2312 "cs-parser.jay" +#line 2307 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; if (lt.Value != current_container.MemberName.Name){ @@ -5646,7 +5659,7 @@ void case_279() } void case_280() -#line 2338 "cs-parser.jay" +#line 2333 "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); @@ -5660,7 +5673,7 @@ void case_280() } void case_281() -#line 2352 "cs-parser.jay" +#line 2347 "cs-parser.jay" { if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment (); @@ -5672,7 +5685,7 @@ void case_281() } void case_282() -#line 2365 "cs-parser.jay" +#line 2360 "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); @@ -5682,7 +5695,7 @@ void case_282() } void case_283() -#line 2373 "cs-parser.jay" +#line 2368 "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"); @@ -5691,7 +5704,7 @@ void case_283() } void case_284() -#line 2380 "cs-parser.jay" +#line 2375 "cs-parser.jay" { if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment (); @@ -5704,14 +5717,14 @@ void case_284() } void case_287() -#line 2399 "cs-parser.jay" +#line 2394 "cs-parser.jay" { --lexer.parsing_block; current_event_field.Initializer = (Expression) yyVals[0+yyTop]; } void case_292() -#line 2423 "cs-parser.jay" +#line 2418 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null); @@ -5719,7 +5732,7 @@ void case_292() } void case_294() -#line 2433 "cs-parser.jay" +#line 2428 "cs-parser.jay" { --lexer.parsing_block; var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; @@ -5728,7 +5741,7 @@ void case_294() } void case_295() -#line 2442 "cs-parser.jay" +#line 2437 "cs-parser.jay" { if (current_container.Kind == MemberKind.Interface) { report.Error (68, lexer.Location, "`{0}': event in interface cannot have an initializer", @@ -5742,28 +5755,28 @@ void case_295() } void case_299() -#line 2463 "cs-parser.jay" +#line 2458 "cs-parser.jay" { report.Error (65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError ()); } void case_300() -#line 2468 "cs-parser.jay" +#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_301() -#line 2473 "cs-parser.jay" +#line 2468 "cs-parser.jay" { report.Error (1055, GetLocation (yyVals[0+yyTop]), "An add or remove accessor expected"); yyVal = null; } void case_302() -#line 2481 "cs-parser.jay" +#line 2476 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5777,7 +5790,7 @@ void case_302() } void case_303() -#line 2493 "cs-parser.jay" +#line 2488 "cs-parser.jay" { lexer.EventParsing = true; @@ -5792,7 +5805,7 @@ void case_303() } void case_304() -#line 2509 "cs-parser.jay" +#line 2504 "cs-parser.jay" { if (yyVals[-1+yyTop] != ModifierNone) { report.Error (1609, GetLocation (yyVals[-1+yyTop]), "Modifiers cannot be placed on event accessor declarations"); @@ -5806,7 +5819,7 @@ void case_304() } void case_305() -#line 2521 "cs-parser.jay" +#line 2516 "cs-parser.jay" { lexer.EventParsing = true; @@ -5821,14 +5834,14 @@ void case_305() } void case_306() -#line 2537 "cs-parser.jay" +#line 2532 "cs-parser.jay" { report.Error (73, lexer.Location, "An add or remove accessor must have a body"); yyVal = null; } void case_308() -#line 2546 "cs-parser.jay" +#line 2541 "cs-parser.jay" { current_type.UnattachedAttributes = (Attributes) yyVals[-1+yyTop]; report.Error (1519, GetLocation (yyVals[-1+yyTop]), "An attribute is missing member declaration"); @@ -5836,14 +5849,14 @@ void case_308() } void case_309() -#line 2559 "cs-parser.jay" +#line 2554 "cs-parser.jay" { if (doc_support) enumTypeComment = Lexer.consume_doc_comment (); } void case_310() -#line 2564 "cs-parser.jay" +#line 2559 "cs-parser.jay" { if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; @@ -5862,7 +5875,7 @@ void case_310() } void case_311() -#line 2581 "cs-parser.jay" +#line 2576 "cs-parser.jay" { /* here will be evaluated after CLOSE_BLACE is consumed.*/ if (doc_support) @@ -5870,7 +5883,7 @@ void case_311() } void case_312() -#line 2587 "cs-parser.jay" +#line 2582 "cs-parser.jay" { lbag.AppendToMember (current_container, GetLocation (yyVals[-1+yyTop])); if (yyVals[0+yyTop] != null) { @@ -5888,28 +5901,28 @@ void case_312() } void case_314() -#line 2607 "cs-parser.jay" +#line 2602 "cs-parser.jay" { savedLocation = GetLocation (yyVals[-1+yyTop]); yyVal = yyVals[0+yyTop]; } void case_315() -#line 2612 "cs-parser.jay" +#line 2607 "cs-parser.jay" { Error_TypeExpected (GetLocation (yyVals[-1+yyTop])); yyVal = null; } void case_320() -#line 2630 "cs-parser.jay" +#line 2625 "cs-parser.jay" { lbag.AppendToMember (current_container, GetLocation (yyVals[-1+yyTop])); yyVal = yyVals[0+yyTop]; } void case_321() -#line 2638 "cs-parser.jay" +#line 2633 "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]); @@ -5924,7 +5937,7 @@ void case_321() } void case_322() -#line 2651 "cs-parser.jay" +#line 2646 "cs-parser.jay" { ++lexer.parsing_block; if (doc_support) { @@ -5934,7 +5947,7 @@ void case_322() } void case_323() -#line 2659 "cs-parser.jay" +#line 2654 "cs-parser.jay" { --lexer.parsing_block; @@ -5949,8 +5962,25 @@ void case_323() yyVal = em; } -void case_325() -#line 2684 "cs-parser.jay" +void case_324() +#line 2668 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + + var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; + var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) yyVals[-2+yyTop]); + ((Enum) current_type).AddEnumMember (em); + + if (doc_support) { + em.DocComment = Lexer.consume_doc_comment (); + Lexer.doc_state = XmlCommentState.Allowed; + } + + yyVal = em; + } + +void case_327() +#line 2695 "cs-parser.jay" { valid_param_mod = 0; @@ -5966,8 +5996,8 @@ void case_325() lexer.ConstraintsParsing = true; } -void case_327() -#line 2703 "cs-parser.jay" +void case_329() +#line 2714 "cs-parser.jay" { if (doc_support) { current_delegate.DocComment = Lexer.consume_doc_comment (); @@ -5983,8 +6013,8 @@ void case_327() current_delegate = null; } -void case_329() -#line 2722 "cs-parser.jay" +void case_331() +#line 2733 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "nullable types"); @@ -5992,8 +6022,8 @@ void case_329() yyVal = ComposedTypeSpecifier.CreateNullable (GetLocation (yyVals[0+yyTop])); } -void case_331() -#line 2733 "cs-parser.jay" +void case_333() +#line 2744 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6002,23 +6032,23 @@ void case_331() lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_333() -#line 2745 "cs-parser.jay" +void case_335() +#line 2756 "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_334() -#line 2754 "cs-parser.jay" +void case_336() +#line 2765 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_336() -#line 2766 "cs-parser.jay" +void case_338() +#line 2777 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); @@ -6030,15 +6060,15 @@ void case_336() yyVal = yyVals[-1+yyTop];; } -void case_337() -#line 2777 "cs-parser.jay" +void case_339() +#line 2788 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = new TypeArguments (); } -void case_338() -#line 2785 "cs-parser.jay" +void case_340() +#line 2796 "cs-parser.jay" { TypeArguments type_args = new TypeArguments (); type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -6046,8 +6076,8 @@ void case_338() locationListStack.Push (new List ()); } -void case_339() -#line 2792 "cs-parser.jay" +void case_341() +#line 2803 "cs-parser.jay" { TypeArguments type_args = (TypeArguments) yyVals[-2+yyTop]; type_args.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -6055,16 +6085,16 @@ void case_339() locationListStack.Peek ().Add (GetLocation (yyVals[-1+yyTop])); } -void case_341() -#line 2809 "cs-parser.jay" +void case_343() +#line 2820 "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_342() -#line 2818 "cs-parser.jay" +void case_344() +#line 2829 "cs-parser.jay" { MemberName mn = (MemberName)yyVals[0+yyTop]; if (mn.TypeParameters != null) @@ -6072,38 +6102,38 @@ void case_342() mn.GetSignatureForError ())); } -void case_344() -#line 2829 "cs-parser.jay" +void case_346() +#line 2840 "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_345() -#line 2838 "cs-parser.jay" +void case_347() +#line 2849 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeDefinition.DefaultIndexerName, GetLocation (yyVals[0+yyTop])); } -void case_346() -#line 2843 "cs-parser.jay" +void case_348() +#line 2854 "cs-parser.jay" { lexer.parsing_generic_declaration = false; yyVal = new MemberName (TypeDefinition.DefaultIndexerName, null, (ATypeNameExpression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop])); } -void case_347() -#line 2851 "cs-parser.jay" +void case_349() +#line 2862 "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_348() -#line 2857 "cs-parser.jay" +void case_350() +#line 2868 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -6112,16 +6142,16 @@ void case_348() lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_349() -#line 2865 "cs-parser.jay" +void case_351() +#line 2876 "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_351() -#line 2875 "cs-parser.jay" +void case_353() +#line 2886 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "generics"); @@ -6133,8 +6163,8 @@ void case_351() lbag.AddLocation (yyVals[-1+yyTop], list); } -void case_352() -#line 2889 "cs-parser.jay" +void case_354() +#line 2900 "cs-parser.jay" { var tparams = new TypeParameters (); tparams.Add ((TypeParameter)yyVals[0+yyTop]); @@ -6142,8 +6172,8 @@ void case_352() locationListStack.Push (new List ()); } -void case_353() -#line 2896 "cs-parser.jay" +void case_355() +#line 2907 "cs-parser.jay" { var tparams = (TypeParameters) yyVals[-2+yyTop]; tparams.Add ((TypeParameter)yyVals[0+yyTop]); @@ -6151,15 +6181,15 @@ void case_353() locationListStack.Peek ().Add (GetLocation (yyVals[-1+yyTop])); } -void case_354() -#line 2906 "cs-parser.jay" +void case_356() +#line 2917 "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_355() -#line 2911 "cs-parser.jay" +void case_357() +#line 2922 "cs-parser.jay" { if (GetTokenName (yyToken) == "type") report.Error (81, GetLocation (yyVals[0+yyTop]), "Type parameter declaration must be an identifier not a type"); @@ -6169,29 +6199,29 @@ void case_355() yyVal = new TypeParameter (MemberName.Null, null, Variance.None); } -void case_360() -#line 2945 "cs-parser.jay" +void case_362() +#line 2956 "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 2954 "cs-parser.jay" +void case_364() +#line 2965 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_364() -#line 2963 "cs-parser.jay" +void case_366() +#line 2974 "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_367() -#line 2979 "cs-parser.jay" +void case_369() +#line 2990 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { yyVal = new ComposedCast ((ATypeNameExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); @@ -6204,23 +6234,23 @@ void case_367() } } -void case_369() -#line 2995 "cs-parser.jay" +void case_371() +#line 3006 "cs-parser.jay" { if (yyVals[0+yyTop] != null) yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_372() -#line 3011 "cs-parser.jay" +void case_374() +#line 3022 "cs-parser.jay" { var types = new List (2); types.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = types; } -void case_373() -#line 3017 "cs-parser.jay" +void case_375() +#line 3028 "cs-parser.jay" { var types = (List) yyVals[-2+yyTop]; types.Add ((FullNamedExpression) yyVals[0+yyTop]); @@ -6228,8 +6258,8 @@ void case_373() yyVal = types; } -void case_374() -#line 3027 "cs-parser.jay" +void case_376() +#line 3038 "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 ()); @@ -6237,29 +6267,29 @@ void case_374() yyVal = yyVals[0+yyTop]; } -void case_411() -#line 3091 "cs-parser.jay" +void case_413() +#line 3102 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location); } -void case_412() -#line 3095 "cs-parser.jay" +void case_414() +#line 3106 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionSimpleName (MemberName.MakeName (lt.Value, null), lt.Location); } -void case_423() -#line 3136 "cs-parser.jay" +void case_425() +#line 3147 "cs-parser.jay" { yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_425() -#line 3148 "cs-parser.jay" +void case_427() +#line 3159 "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) { @@ -6267,8 +6297,8 @@ void case_425() }; } -void case_426() -#line 3155 "cs-parser.jay" +void case_428() +#line 3166 "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) { @@ -6276,8 +6306,8 @@ void case_426() }; } -void case_427() -#line 3162 "cs-parser.jay" +void case_429() +#line 3173 "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) { @@ -6285,8 +6315,8 @@ void case_427() }; } -void case_428() -#line 3169 "cs-parser.jay" +void case_430() +#line 3180 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6295,56 +6325,65 @@ void case_428() lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_430() -#line 3179 "cs-parser.jay" +void case_432() +#line 3190 "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 3187 "cs-parser.jay" +void case_434() +#line 3198 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location); } -void case_433() -#line 3195 "cs-parser.jay" +void case_435() +#line 3206 "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_436() -#line 3208 "cs-parser.jay" +#line 3211 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + + yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); + } + +void case_439() +#line 3227 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) { - yyVal = CollectionOrObjectInitializers.Empty; - /* TODO: lbag*/ + yyVal = new CollectionOrObjectInitializers (new List (), GetLocation (yyVals[-2+yyTop])); + lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } else { yyVal = new CollectionOrObjectInitializers ((List) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } } -void case_437() -#line 3218 "cs-parser.jay" +void case_440() +#line 3237 "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_440() -#line 3234 "cs-parser.jay" +void case_443() +#line 3253 "cs-parser.jay" { var a = new List (); a.Add ((Expression) yyVals[0+yyTop]); yyVal = a; } -void case_441() -#line 3240 "cs-parser.jay" +void case_444() +#line 3259 "cs-parser.jay" { var a = (List)yyVals[-2+yyTop]; a.Add ((Expression) yyVals[0+yyTop]); @@ -6352,23 +6391,23 @@ void case_441() yyVal = a; } -void case_442() -#line 3246 "cs-parser.jay" +void case_445() +#line 3265 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } -void case_443() -#line 3254 "cs-parser.jay" +void case_446() +#line 3273 "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_445() -#line 3263 "cs-parser.jay" +void case_448() +#line 3282 "cs-parser.jay" { CompletionSimpleName csn = yyVals[-1+yyTop] as CompletionSimpleName; if (csn == null) @@ -6377,8 +6416,8 @@ void case_445() yyVal = new CompletionElementInitializer (csn.Prefix, csn.Location); } -void case_446() -#line 3271 "cs-parser.jay" +void case_449() +#line 3290 "cs-parser.jay" { if (yyVals[-1+yyTop] == null) yyVal = null; @@ -6388,23 +6427,24 @@ void case_446() } } -void case_447() -#line 3280 "cs-parser.jay" +void case_450() +#line 3299 "cs-parser.jay" { report.Error (1920, GetLocation (yyVals[-1+yyTop]), "An element initializer cannot be empty"); - yyVal = null; + yyVal = new CollectionElementInitializer (new List (), GetLocation (yyVals[-1+yyTop])); + lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_452() -#line 3298 "cs-parser.jay" +void case_455() +#line 3318 "cs-parser.jay" { Arguments list = new Arguments (4); list.Add ((Argument) yyVals[0+yyTop]); yyVal = list; } -void case_453() -#line 3304 "cs-parser.jay" +void case_456() +#line 3324 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; if (list [list.Count - 1] is NamedArgument) @@ -6415,8 +6455,8 @@ void case_453() yyVal = list; } -void case_454() -#line 3314 "cs-parser.jay" +void case_457() +#line 3334 "cs-parser.jay" { Arguments list = (Arguments) yyVals[-2+yyTop]; NamedArgument a = (NamedArgument) yyVals[0+yyTop]; @@ -6432,79 +6472,80 @@ void case_454() yyVal = list; } -void case_455() -#line 3329 "cs-parser.jay" +void case_458() +#line 3349 "cs-parser.jay" { + lexer.putback (')'); /* TODO: Wrong but what can I do*/ Error_SyntaxError (yyToken); yyVal = yyVals[-2+yyTop]; } -void case_456() -#line 3334 "cs-parser.jay" +void case_459() +#line 3355 "cs-parser.jay" { report.Error (839, GetLocation (yyVals[-1+yyTop]), "An argument is missing"); yyVal = null; } -void case_461() -#line 3355 "cs-parser.jay" +void case_464() +#line 3376 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_462() -#line 3360 "cs-parser.jay" +void case_465() +#line 3381 "cs-parser.jay" { yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_463() -#line 3365 "cs-parser.jay" +void case_466() +#line 3386 "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_464() -#line 3370 "cs-parser.jay" +void case_467() +#line 3391 "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_466() -#line 3382 "cs-parser.jay" +void case_469() +#line 3403 "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" +void case_470() +#line 3408 "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 3392 "cs-parser.jay" +void case_471() +#line 3413 "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" +void case_472() +#line 3421 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); yyVal = list; } -void case_470() -#line 3406 "cs-parser.jay" +void case_473() +#line 3427 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6512,23 +6553,23 @@ void case_470() yyVal = list; } -void case_471() -#line 3412 "cs-parser.jay" +void case_474() +#line 3433 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = yyVals[-1+yyTop]; } -void case_472() -#line 3420 "cs-parser.jay" +void case_475() +#line 3441 "cs-parser.jay" { Arguments args = new Arguments (4); args.Add ((Argument) yyVals[0+yyTop]); yyVal = args; } -void case_473() -#line 3426 "cs-parser.jay" +void case_476() +#line 3447 "cs-parser.jay" { Arguments args = (Arguments) yyVals[-2+yyTop]; if (args [args.Count - 1] is NamedArgument && !(yyVals[0+yyTop] is NamedArgument)) @@ -6539,22 +6580,22 @@ void case_473() yyVal = args; } -void case_477() -#line 3454 "cs-parser.jay" +void case_480() +#line 3475 "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_478() -#line 3459 "cs-parser.jay" +void case_481() +#line 3480 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new ElementAccess (null, null, GetLocation (yyVals[-1+yyTop])); } -void case_481() -#line 3481 "cs-parser.jay" +void case_484() +#line 3502 "cs-parser.jay" { if (yyVals[0+yyTop] != null) { if (lang_version <= LanguageVersion.ISO_2) @@ -6568,8 +6609,8 @@ void case_481() lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_482() -#line 3494 "cs-parser.jay" +void case_485() +#line 3515 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "collection initializers"); @@ -6577,8 +6618,8 @@ void case_482() yyVal = new NewInitialize ((FullNamedExpression) yyVals[-1+yyTop], null, (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_483() -#line 3506 "cs-parser.jay" +void case_486() +#line 3527 "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])) { @@ -6587,8 +6628,8 @@ void case_483() lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_484() -#line 3514 "cs-parser.jay" +void case_487() +#line 3535 "cs-parser.jay" { if (yyVals[0+yyTop] == null) report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer"); @@ -6596,8 +6637,8 @@ void case_484() yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop])); } -void case_485() -#line 3521 "cs-parser.jay" +void case_488() +#line 3542 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays"); @@ -6605,30 +6646,30 @@ void case_485() yyVal = new ImplicitlyTypedArrayCreation ((ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); } -void case_486() -#line 3528 "cs-parser.jay" +void case_489() +#line 3549 "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_487() -#line 3533 "cs-parser.jay" +void case_490() +#line 3554 "cs-parser.jay" { 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_489() -#line 3545 "cs-parser.jay" +void case_492() +#line 3566 "cs-parser.jay" { --lexer.parsing_type; yyVal = yyVals[0+yyTop]; } -void case_490() -#line 3553 "cs-parser.jay" +void case_493() +#line 3574 "cs-parser.jay" { if (lang_version <= LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types"); @@ -6639,16 +6680,16 @@ void case_490() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_495() -#line 3576 "cs-parser.jay" +void case_498() +#line 3597 "cs-parser.jay" { var a = new List (4); a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); yyVal = a; } -void case_496() -#line 3582 "cs-parser.jay" +void case_499() +#line 3603 "cs-parser.jay" { var a = (List) yyVals[-2+yyTop]; a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]); @@ -6657,60 +6698,60 @@ void case_496() yyVal = a; } -void case_497() -#line 3593 "cs-parser.jay" +void case_500() +#line 3614 "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_498() -#line 3599 "cs-parser.jay" +void case_501() +#line 3620 "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_499() -#line 3605 "cs-parser.jay" +void case_502() +#line 3626 "cs-parser.jay" { MemberAccess ma = (MemberAccess) yyVals[0+yyTop]; yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location); } -void case_500() -#line 3610 "cs-parser.jay" +void case_503() +#line 3631 "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_504() -#line 3625 "cs-parser.jay" +void case_507() +#line 3646 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_505() -#line 3633 "cs-parser.jay" +void case_508() +#line 3654 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension (1, GetLocation (yyVals[-1+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_506() -#line 3638 "cs-parser.jay" +void case_509() +#line 3659 "cs-parser.jay" { yyVal = ComposedTypeSpecifier.CreateArrayDimension ((int)yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_511() -#line 3668 "cs-parser.jay" +void case_514() +#line 3689 "cs-parser.jay" { var ai = new ArrayInitializer (0, GetLocation (yyVals[-1+yyTop])); ai.VariableDeclaration = current_variable; @@ -6718,8 +6759,8 @@ void case_511() yyVal = ai; } -void case_512() -#line 3675 "cs-parser.jay" +void case_515() +#line 3696 "cs-parser.jay" { var ai = new ArrayInitializer ((List) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop])); ai.VariableDeclaration = current_variable; @@ -6731,16 +6772,16 @@ void case_512() yyVal = ai; } -void case_513() -#line 3689 "cs-parser.jay" +void case_516() +#line 3710 "cs-parser.jay" { var list = new List (4); list.Add ((Expression) yyVals[0+yyTop]); yyVal = list; } -void case_514() -#line 3695 "cs-parser.jay" +void case_517() +#line 3716 "cs-parser.jay" { var list = (List) yyVals[-2+yyTop]; list.Add ((Expression) yyVals[0+yyTop]); @@ -6748,31 +6789,31 @@ void case_514() yyVal = list; } -void case_516() -#line 3709 "cs-parser.jay" +void case_519() +#line 3730 "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_519() -#line 3720 "cs-parser.jay" +void case_522() +#line 3741 "cs-parser.jay" { Error_TypeExpected (lexer.Location); yyVal = null; } -void case_520() -#line 3728 "cs-parser.jay" +void case_523() +#line 3749 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; yyVal = new SimpleName (lt.Value, (int) yyVals[0+yyTop], lt.Location); } -void case_521() -#line 3734 "cs-parser.jay" +void case_524() +#line 3755 "cs-parser.jay" { var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var lt2 = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6781,8 +6822,8 @@ void case_521() lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_522() -#line 3742 "cs-parser.jay" +void case_525() +#line 3763 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; @@ -6791,8 +6832,8 @@ void case_522() }; } -void case_523() -#line 3750 "cs-parser.jay" +void case_526() +#line 3771 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -6801,8 +6842,8 @@ void case_523() }; } -void case_524() -#line 3758 "cs-parser.jay" +void case_527() +#line 3779 "cs-parser.jay" { var tne = (ATypeNameExpression) yyVals[-3+yyTop]; if (tne.HasTypeArguments) @@ -6814,17 +6855,17 @@ void case_524() }; } -void case_525() -#line 3772 "cs-parser.jay" -{ +void case_528() +#line 3793 "cs-parser.jay" +{ if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "generics"); yyVal = yyVals[0+yyTop]; } -void case_526() -#line 3782 "cs-parser.jay" +void case_529() +#line 3803 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; if (lang_version == LanguageVersion.ISO_1) @@ -6833,36 +6874,36 @@ void case_526() yyVal = lt; } -void case_527() -#line 3793 "cs-parser.jay" +void case_530() +#line 3814 "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_528() -#line 3801 "cs-parser.jay" +void case_531() +#line 3822 "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_529() -#line 3809 "cs-parser.jay" +void case_532() +#line 3830 "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_530() -#line 3817 "cs-parser.jay" +void case_533() +#line 3838 "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_532() -#line 3829 "cs-parser.jay" +void case_535() +#line 3850 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); if ((ParametersCompiled) yyVals[-2+yyTop] != ParametersCompiled.Undefined) { @@ -6872,8 +6913,8 @@ void case_532() } } -void case_534() -#line 3842 "cs-parser.jay" +void case_537() +#line 3863 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); @@ -6884,8 +6925,8 @@ void case_534() } } -void case_538() -#line 3867 "cs-parser.jay" +void case_541() +#line 3888 "cs-parser.jay" { valid_param_mod = 0; yyVal = yyVals[-1+yyTop]; @@ -6893,8 +6934,8 @@ void case_538() savedCloseLocation = GetLocation (yyVals[-2+yyTop]); } -void case_539() -#line 3877 "cs-parser.jay" +void case_542() +#line 3898 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "default value expression"); @@ -6903,15 +6944,15 @@ void case_539() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_543() -#line 3897 "cs-parser.jay" +void case_546() +#line 3918 "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_544() -#line 3902 "cs-parser.jay" +void case_547() +#line 3923 "cs-parser.jay" { if (!async_block) { if (current_anonymous_method is LambdaExpression) { @@ -6931,227 +6972,235 @@ void case_544() yyVal = new Await ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); } -void case_553() -#line 3957 "cs-parser.jay" +void case_556() +#line 3978 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.Multiply, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_554() -#line 3962 "cs-parser.jay" +void case_557() +#line 3983 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.Division, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_555() -#line 3967 "cs-parser.jay" +void case_558() +#line 3988 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.Modulus, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_557() -#line 3976 "cs-parser.jay" +void case_560() +#line 3997 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.Addition, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -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_563() +void case_561() #line 4002 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.LeftShift, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_564() -#line 4007 "cs-parser.jay" +void case_565() +#line 4019 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.RightShift, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_566() -#line 4016 "cs-parser.jay" +#line 4024 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.LessThan, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_567() -#line 4021 "cs-parser.jay" +void case_568() +#line 4033 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.GreaterThan, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.LessThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_568() -#line 4026 "cs-parser.jay" +void case_569() +#line 4038 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.LessThanOrEqual, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.GreaterThan, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_569() -#line 4031 "cs-parser.jay" +void case_570() +#line 4043 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.LessThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_571() -#line 4040 "cs-parser.jay" +#line 4048 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.Equality, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_572() -#line 4045 "cs-parser.jay" +void case_573() +#line 4057 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.Inequality, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.Equality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_574() -#line 4054 "cs-parser.jay" +#line 4062 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.BitwiseAnd, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.Inequality, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_576() -#line 4063 "cs-parser.jay" +#line 4071 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.ExclusiveOr, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_578() -#line 4072 "cs-parser.jay" +#line 4080 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.BitwiseOr, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_580() -#line 4081 "cs-parser.jay" +#line 4089 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.LogicalAnd, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_582() -#line 4090 "cs-parser.jay" +#line 4098 "cs-parser.jay" { - yyVal = new Binary (Binary.Operator.LogicalOr, - (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Binary (Binary.Operator.LogicalAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_584() -#line 4099 "cs-parser.jay" +#line 4107 "cs-parser.jay" +{ + yyVal = new Binary (Binary.Operator.LogicalOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); + } + +void case_586() +#line 4116 "cs-parser.jay" { if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "null coalescing operator"); - yyVal = new Nullable.NullCoalescingOperator ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new Nullable.NullCoalescingOperator ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } -void case_586() -#line 4110 "cs-parser.jay" +void case_588() +#line 4128 "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 4115 "cs-parser.jay" +void case_589() +#line 4133 "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_590() -#line 4132 "cs-parser.jay" +#line 4141 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new SimpleAssign ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_591() -#line 4137 "cs-parser.jay" +#line 4146 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new CompoundAssign (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_592() -#line 4142 "cs-parser.jay" +#line 4151 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new CompoundAssign (Binary.Operator.Division, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_593() -#line 4147 "cs-parser.jay" +#line 4156 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new CompoundAssign (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_594() -#line 4152 "cs-parser.jay" +#line 4161 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new CompoundAssign (Binary.Operator.Addition, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_595() -#line 4157 "cs-parser.jay" +#line 4166 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new CompoundAssign (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_596() -#line 4162 "cs-parser.jay" +#line 4171 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new CompoundAssign (Binary.Operator.LeftShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_597() -#line 4167 "cs-parser.jay" +#line 4176 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new CompoundAssign (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_598() -#line 4172 "cs-parser.jay" +#line 4181 "cs-parser.jay" { - yyVal = new CompoundAssign ( - Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop])); + yyVal = new CompoundAssign (Binary.Operator.BitwiseAnd, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); } void case_599() -#line 4180 "cs-parser.jay" +#line 4186 "cs-parser.jay" +{ + yyVal = new CompoundAssign (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); + } + +void case_600() +#line 4191 "cs-parser.jay" +{ + yyVal = new CompoundAssign (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]); + lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop])); + } + +void case_601() +#line 4199 "cs-parser.jay" { var pars = new List (4); pars.Add ((Parameter) yyVals[0+yyTop]); @@ -7159,8 +7208,8 @@ void case_599() yyVal = pars; } -void case_600() -#line 4187 "cs-parser.jay" +void case_602() +#line 4206 "cs-parser.jay" { var pars = (List) yyVals[-2+yyTop]; Parameter p = (Parameter)yyVals[0+yyTop]; @@ -7174,39 +7223,39 @@ void case_600() yyVal = pars; } -void case_601() -#line 4203 "cs-parser.jay" +void case_603() +#line 4222 "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_602() -#line 4209 "cs-parser.jay" +void case_604() +#line 4228 "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_603() -#line 4215 "cs-parser.jay" +void case_605() +#line 4234 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location); } -void case_605() -#line 4223 "cs-parser.jay" +void case_607() +#line 4242 "cs-parser.jay" { var pars_list = (List) yyVals[0+yyTop]; yyVal = new ParametersCompiled (pars_list.ToArray ()); lbag.AddLocation (yyVal, parameterListCommas); } -void case_609() -#line 4240 "cs-parser.jay" +void case_611() +#line 4259 "cs-parser.jay" { Block b = end_block (Location.Null); b.IsCompilerGenerated = true; @@ -7214,94 +7263,94 @@ void case_609() yyVal = b; } -void case_611() -#line 4251 "cs-parser.jay" +void case_613() +#line 4270 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = EmptyExpression.Null; } -void case_612() -#line 4259 "cs-parser.jay" +void case_614() +#line 4278 "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_613() -#line 4265 "cs-parser.jay" +void case_615() +#line 4284 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_614() -#line 4270 "cs-parser.jay" +void case_616() +#line 4289 "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_615() -#line 4276 "cs-parser.jay" +void case_617() +#line 4295 "cs-parser.jay" { yyVal = end_anonymous ((ParametersBlock) yyVals[0+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_617() -#line 4285 "cs-parser.jay" +void case_619() +#line 4304 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], false, GetLocation (yyVals[-4+yyTop])); } -void case_618() -#line 4290 "cs-parser.jay" +void case_620() +#line 4309 "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_620() -#line 4299 "cs-parser.jay" +void case_622() +#line 4318 "cs-parser.jay" { valid_param_mod = 0; start_anonymous (true, (ParametersCompiled) yyVals[-2+yyTop], true, GetLocation (yyVals[-5+yyTop])); } -void case_621() -#line 4304 "cs-parser.jay" +void case_623() +#line 4323 "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_628() -#line 4327 "cs-parser.jay" +void case_630() +#line 4346 "cs-parser.jay" { yyVal = new RefValueExpr ((Expression) yyVals[-3+yyTop], (FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-5+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_629() -#line 4332 "cs-parser.jay" +void case_631() +#line 4351 "cs-parser.jay" { yyVal = new RefTypeExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_630() -#line 4337 "cs-parser.jay" +void case_632() +#line 4356 "cs-parser.jay" { yyVal = new MakeRefExpr ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_634() -#line 4366 "cs-parser.jay" +void case_636() +#line 4385 "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) { @@ -7312,8 +7361,8 @@ void case_634() lbag.AddMember (current_container, GetModifierLocations (), GetLocation (yyVals[-2+yyTop])); } -void case_635() -#line 4377 "cs-parser.jay" +void case_637() +#line 4396 "cs-parser.jay" { lexer.ConstraintsParsing = false; @@ -7328,16 +7377,16 @@ void case_635() lexer.parsing_modifiers = true; } -void case_636() -#line 4391 "cs-parser.jay" +void case_638() +#line 4410 "cs-parser.jay" { --lexer.parsing_declaration; if (doc_support) Lexer.doc_state = XmlCommentState.Allowed; } -void case_637() -#line 4397 "cs-parser.jay" +void case_639() +#line 4416 "cs-parser.jay" { if (yyVals[0+yyTop] == null) { lbag.AppendToMember (current_container, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop])); @@ -7347,16 +7396,16 @@ void case_637() yyVal = pop_current_class (); } -void case_640() -#line 4416 "cs-parser.jay" +void case_642() +#line 4435 "cs-parser.jay" { mod_locations = null; yyVal = ModifierNone; lexer.parsing_modifiers = false; } -void case_643() -#line 4430 "cs-parser.jay" +void case_645() +#line 4449 "cs-parser.jay" { var m1 = (Modifiers) yyVals[-1+yyTop]; var m2 = (Modifiers) yyVals[0+yyTop]; @@ -7373,8 +7422,8 @@ void case_643() yyVal = m1 | m2; } -void case_644() -#line 4449 "cs-parser.jay" +void case_646() +#line 4468 "cs-parser.jay" { yyVal = Modifiers.NEW; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7383,92 +7432,92 @@ void case_644() report.Error (1530, GetLocation (yyVals[0+yyTop]), "Keyword `new' is not allowed on namespace elements"); } -void case_645() -#line 4457 "cs-parser.jay" +void case_647() +#line 4476 "cs-parser.jay" { yyVal = Modifiers.PUBLIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_646() -#line 4462 "cs-parser.jay" +void case_648() +#line 4481 "cs-parser.jay" { yyVal = Modifiers.PROTECTED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_647() -#line 4467 "cs-parser.jay" +void case_649() +#line 4486 "cs-parser.jay" { yyVal = Modifiers.INTERNAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_648() -#line 4472 "cs-parser.jay" +void case_650() +#line 4491 "cs-parser.jay" { yyVal = Modifiers.PRIVATE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_649() -#line 4477 "cs-parser.jay" +void case_651() +#line 4496 "cs-parser.jay" { yyVal = Modifiers.ABSTRACT; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_650() -#line 4482 "cs-parser.jay" +void case_652() +#line 4501 "cs-parser.jay" { yyVal = Modifiers.SEALED; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_651() -#line 4487 "cs-parser.jay" +void case_653() +#line 4506 "cs-parser.jay" { yyVal = Modifiers.STATIC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_652() -#line 4492 "cs-parser.jay" +void case_654() +#line 4511 "cs-parser.jay" { yyVal = Modifiers.READONLY; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_653() -#line 4497 "cs-parser.jay" +void case_655() +#line 4516 "cs-parser.jay" { yyVal = Modifiers.VIRTUAL; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_654() -#line 4502 "cs-parser.jay" +void case_656() +#line 4521 "cs-parser.jay" { yyVal = Modifiers.OVERRIDE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_655() -#line 4507 "cs-parser.jay" +void case_657() +#line 4526 "cs-parser.jay" { yyVal = Modifiers.EXTERN; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_656() -#line 4512 "cs-parser.jay" +void case_658() +#line 4531 "cs-parser.jay" { yyVal = Modifiers.VOLATILE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_657() -#line 4517 "cs-parser.jay" +void case_659() +#line 4536 "cs-parser.jay" { yyVal = Modifiers.UNSAFE; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); @@ -7476,38 +7525,38 @@ void case_657() Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } -void case_658() -#line 4524 "cs-parser.jay" +void case_660() +#line 4543 "cs-parser.jay" { yyVal = Modifiers.ASYNC; StoreModifierLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_660() -#line 4533 "cs-parser.jay" +void case_662() +#line 4552 "cs-parser.jay" { current_type.AddBasesForPart ((List) yyVals[0+yyTop]); lbag.AppendToMember (current_type, GetLocation (yyVals[-1+yyTop])); } -void case_661() -#line 4538 "cs-parser.jay" +void case_663() +#line 4557 "cs-parser.jay" { Error_SyntaxError (yyToken); current_type.AddBasesForPart ((List) yyVals[-1+yyTop]); } -void case_664() -#line 4555 "cs-parser.jay" +void case_666() +#line 4574 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((Constraints) yyVals[0+yyTop]); yyVal = constraints; } -void case_665() -#line 4561 "cs-parser.jay" +void case_667() +#line 4580 "cs-parser.jay" { var constraints = (List) yyVals[-1+yyTop]; Constraints new_constraint = (Constraints)yyVals[0+yyTop]; @@ -7524,16 +7573,16 @@ void case_665() yyVal = constraints; } -void case_666() -#line 4580 "cs-parser.jay" +void case_668() +#line 4599 "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_667() -#line 4586 "cs-parser.jay" +void case_669() +#line 4605 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -7541,16 +7590,16 @@ void case_667() yyVal = new Constraints (new SimpleMemberName (lt.Value, lt.Location), null, GetLocation (yyVals[-2+yyTop])); } -void case_668() -#line 4596 "cs-parser.jay" +void case_670() +#line 4615 "cs-parser.jay" { var constraints = new List (1); constraints.Add ((FullNamedExpression) yyVals[0+yyTop]); yyVal = constraints; } -void case_669() -#line 4602 "cs-parser.jay" +void case_671() +#line 4621 "cs-parser.jay" { var constraints = (List) yyVals[-2+yyTop]; var prev = constraints [constraints.Count - 1] as SpecialContraintExpr; @@ -7575,8 +7624,8 @@ void case_669() yyVal = constraints; } -void case_670() -#line 4629 "cs-parser.jay" +void case_672() +#line 4648 "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 ()); @@ -7584,15 +7633,15 @@ void case_670() yyVal = yyVals[0+yyTop]; } -void case_671() -#line 4636 "cs-parser.jay" +void case_673() +#line 4655 "cs-parser.jay" { yyVal = new SpecialContraintExpr (SpecialConstraint.Constructor, GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_675() -#line 4656 "cs-parser.jay" +void case_677() +#line 4675 "cs-parser.jay" { if (lang_version <= LanguageVersion.V_3) FeatureIsNotAvailable (lexer.Location, "generic type variance"); @@ -7600,65 +7649,65 @@ void case_675() yyVal = yyVals[0+yyTop]; } -void case_676() -#line 4666 "cs-parser.jay" +void case_678() +#line 4685 "cs-parser.jay" { yyVal = Variance.Covariant; savedLocation = GetLocation (yyVals[0+yyTop]); } -void case_677() -#line 4671 "cs-parser.jay" +void case_679() +#line 4690 "cs-parser.jay" { yyVal = Variance.Contravariant; savedLocation = GetLocation (yyVals[0+yyTop]); } -void case_678() -#line 4692 "cs-parser.jay" +void case_680() +#line 4711 "cs-parser.jay" { ++lexer.parsing_block; start_block (GetLocation (yyVals[0+yyTop])); } -void case_680() -#line 4704 "cs-parser.jay" +void case_682() +#line 4723 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_681() -#line 4709 "cs-parser.jay" +void case_683() +#line 4728 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (lexer.Location); } -void case_682() -#line 4718 "cs-parser.jay" +void case_684() +#line 4737 "cs-parser.jay" { ++lexer.parsing_block; current_block.StartLocation = GetLocation (yyVals[0+yyTop]); } -void case_683() -#line 4723 "cs-parser.jay" +void case_685() +#line 4742 "cs-parser.jay" { --lexer.parsing_block; yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_684() -#line 4727 "cs-parser.jay" +void case_686() +#line 4746 "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" +void case_694() +#line 4775 "cs-parser.jay" { Error_SyntaxError (yyToken); var lt =(Tokenizer.LocatedToken) yyVals[-1+yyTop]; @@ -7667,43 +7716,43 @@ void case_692() yyVal = null; } -void case_693() -#line 4765 "cs-parser.jay" +void case_695() +#line 4784 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_726() -#line 4829 "cs-parser.jay" +void case_728() +#line 4848 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } -void case_727() -#line 4834 "cs-parser.jay" +void case_729() +#line 4853 "cs-parser.jay" { report.Error (1023, GetLocation (yyVals[0+yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } -void case_728() -#line 4839 "cs-parser.jay" +void case_730() +#line 4858 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_729() -#line 4847 "cs-parser.jay" +void case_731() +#line 4866 "cs-parser.jay" { /* Uses lexer.Location because semicolon location is not kept in quick mode*/ yyVal = new EmptyStatement (lexer.Location); } -void case_730() -#line 4855 "cs-parser.jay" +void case_732() +#line 4874 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop]; LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location); @@ -7712,8 +7761,8 @@ void case_730() current_block.AddStatement (labeled); } -void case_733() -#line 4868 "cs-parser.jay" +void case_735() +#line 4887 "cs-parser.jay" { if (yyVals[-1+yyTop] is VarExpr) yyVals[-1+yyTop] = new SimpleName ("var", ((VarExpr) yyVals[-1+yyTop]).Location); @@ -7721,8 +7770,8 @@ void case_733() yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_734() -#line 4884 "cs-parser.jay" +void case_736() +#line 4903 "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*/ @@ -7753,8 +7802,8 @@ void case_734() } } -void case_735() -#line 4914 "cs-parser.jay" +void case_737() +#line 4933 "cs-parser.jay" { ATypeNameExpression expr = yyVals[-1+yyTop] as ATypeNameExpression; @@ -7766,8 +7815,8 @@ void case_735() } } -void case_736() -#line 4925 "cs-parser.jay" +void case_738() +#line 4944 "cs-parser.jay" { if (yyVals[0+yyTop] == null) yyVal = yyVals[-1+yyTop]; @@ -7775,31 +7824,31 @@ void case_736() yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]); } -void case_739() -#line 4940 "cs-parser.jay" +void case_741() +#line 4959 "cs-parser.jay" { Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report); yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop])); } -void case_741() -#line 4949 "cs-parser.jay" +void case_743() +#line 4968 "cs-parser.jay" { ((ComposedTypeSpecifier) yyVals[-1+yyTop]).Next = (ComposedTypeSpecifier) yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_744() -#line 4965 "cs-parser.jay" +void case_746() +#line 4984 "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"); - yyVal = Tokenizer.LocatedToken.Create ("await", GetLocation (yyVals[0+yyTop])); + yyVal = new Tokenizer.LocatedToken ("await", GetLocation (yyVals[0+yyTop])); } } -void case_745() -#line 4975 "cs-parser.jay" +void case_747() +#line 4994 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -7807,16 +7856,16 @@ void case_745() current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_746() -#line 4982 "cs-parser.jay" +void case_748() +#line 5001 "cs-parser.jay" { yyVal = current_variable; current_variable = null; lbag.AppendTo (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_747() -#line 4988 "cs-parser.jay" +void case_749() +#line 5007 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7824,8 +7873,8 @@ void case_747() current_variable = new BlockConstantDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_748() -#line 4995 "cs-parser.jay" +void case_750() +#line 5014 "cs-parser.jay" { if (current_variable.Initializer != null) { lbag.AddLocation (current_variable, GetLocation (yyVals[-6+yyTop]), savedLocation, GetLocation (yyVals[0+yyTop])); @@ -7836,8 +7885,8 @@ void case_748() current_variable = null; } -void case_750() -#line 5008 "cs-parser.jay" +void case_752() +#line 5027 "cs-parser.jay" { /* Redundant, but wont regress*/ report.Error (1525, lexer.Location, "Unexpected symbol }"); @@ -7845,15 +7894,15 @@ void case_750() yyVal = yyVals[0+yyTop]; } -void case_752() -#line 5019 "cs-parser.jay" +void case_754() +#line 5038 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } -void case_753() -#line 5024 "cs-parser.jay" +void case_755() +#line 5043 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7868,8 +7917,8 @@ void case_753() lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); } -void case_754() -#line 5038 "cs-parser.jay" +void case_756() +#line 5057 "cs-parser.jay" { if (yyToken == Token.OPEN_BRACKET_EXPR) { report.Error (650, lexer.Location, @@ -7879,8 +7928,8 @@ void case_754() } } -void case_758() -#line 5056 "cs-parser.jay" +void case_760() +#line 5075 "cs-parser.jay" { foreach (var d in current_variable.Declarators) { if (d.Initializer == null) @@ -7888,8 +7937,8 @@ void case_758() } } -void case_761() -#line 5071 "cs-parser.jay" +void case_763() +#line 5090 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7899,8 +7948,8 @@ void case_761() lbag.AddLocation (d, GetLocation (yyVals[-1+yyTop])); } -void case_762() -#line 5080 "cs-parser.jay" +void case_764() +#line 5099 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location); @@ -7910,15 +7959,15 @@ void case_762() lbag.AddLocation (d, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_764() -#line 5096 "cs-parser.jay" +void case_766() +#line 5115 "cs-parser.jay" { savedLocation = GetLocation (yyVals[-1+yyTop]); current_variable.Initializer = (Expression) yyVals[0+yyTop]; } -void case_769() -#line 5114 "cs-parser.jay" +void case_771() +#line 5133 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.Constant, lt.Location); @@ -7928,37 +7977,37 @@ void case_769() lbag.AddLocation (d, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_771() -#line 5127 "cs-parser.jay" +void case_773() +#line 5146 "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_772() -#line 5132 "cs-parser.jay" +void case_774() +#line 5151 "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_773() -#line 5140 "cs-parser.jay" +void case_775() +#line 5159 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_775() -#line 5146 "cs-parser.jay" +void case_777() +#line 5165 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; report.Error (1002, GetLocation (yyVals[0+yyTop]), "; expected"); lexer.putback ('}'); } -void case_778() -#line 5164 "cs-parser.jay" +void case_780() +#line 5183 "cs-parser.jay" { ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement; if (s == null) { @@ -7969,8 +8018,8 @@ void case_778() } } -void case_779() -#line 5177 "cs-parser.jay" +void case_781() +#line 5196 "cs-parser.jay" { Expression expr = (Expression) yyVals[0+yyTop]; ExpressionStatement s; @@ -7979,15 +8028,15 @@ void case_779() yyVal = new StatementExpression (s); } -void case_780() -#line 5185 "cs-parser.jay" +void case_782() +#line 5204 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_783() -#line 5199 "cs-parser.jay" +void case_785() +#line 5218 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -7996,8 +8045,8 @@ void case_783() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_784() -#line 5208 "cs-parser.jay" +void case_786() +#line 5227 "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])); @@ -8008,8 +8057,8 @@ void case_784() Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); } -void case_785() -#line 5218 "cs-parser.jay" +void case_787() +#line 5237 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8017,16 +8066,16 @@ void case_785() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_787() -#line 5232 "cs-parser.jay" +void case_789() +#line 5251 "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_788() -#line 5238 "cs-parser.jay" +void case_790() +#line 5257 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8034,15 +8083,15 @@ void case_788() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_789() -#line 5248 "cs-parser.jay" +void case_791() +#line 5267 "cs-parser.jay" { report.Warning (1522, 1, current_block.StartLocation, "Empty switch block"); yyVal = new List (); } -void case_791() -#line 5257 "cs-parser.jay" +void case_793() +#line 5276 "cs-parser.jay" { var sections = new List (4); @@ -8050,8 +8099,8 @@ void case_791() yyVal = sections; } -void case_792() -#line 5264 "cs-parser.jay" +void case_794() +#line 5283 "cs-parser.jay" { var sections = (List) yyVals[-1+yyTop]; @@ -8059,15 +8108,15 @@ void case_792() yyVal = sections; } -void case_793() -#line 5271 "cs-parser.jay" +void case_795() +#line 5290 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new List (); } -void case_796() -#line 5290 "cs-parser.jay" +void case_798() +#line 5309 "cs-parser.jay" { var labels = new List (2); @@ -8075,8 +8124,8 @@ void case_796() yyVal = labels; } -void case_797() -#line 5297 "cs-parser.jay" +void case_799() +#line 5316 "cs-parser.jay" { var labels = (List) (yyVals[-1+yyTop]); labels.Add ((SwitchLabel) yyVals[0+yyTop]); @@ -8084,22 +8133,22 @@ void case_797() yyVal = labels; } -void case_798() -#line 5307 "cs-parser.jay" +void case_800() +#line 5326 "cs-parser.jay" { yyVal = new SwitchLabel ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_799() -#line 5312 "cs-parser.jay" +void case_801() +#line 5331 "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" +void case_807() +#line 5350 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8108,8 +8157,8 @@ void case_805() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_806() -#line 5339 "cs-parser.jay" +void case_808() +#line 5358 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8117,31 +8166,31 @@ void case_806() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_807() -#line 5349 "cs-parser.jay" +void case_809() +#line 5368 "cs-parser.jay" { - yyVal = new Do ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-2+yyTop], GetLocation (yyVals[-6+yyTop])); + yyVal = new Do ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-2+yyTop], GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-4+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_808() -#line 5354 "cs-parser.jay" +void case_810() +#line 5373 "cs-parser.jay" { Error_SyntaxError (yyToken); - yyVal = new Do ((Statement) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop])); + yyVal = new Do ((Statement) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]), Location.Null); } -void case_809() -#line 5359 "cs-parser.jay" +void case_811() +#line 5378 "cs-parser.jay" { Error_SyntaxError (yyToken); - yyVal = new Do ((Statement) yyVals[-4+yyTop], (BooleanExpression) yyVals[-1+yyTop], GetLocation (yyVals[-5+yyTop])); + yyVal = new Do ((Statement) yyVals[-4+yyTop], (BooleanExpression) yyVals[-1+yyTop], GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-3+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-2+yyTop])); } -void case_810() -#line 5369 "cs-parser.jay" +void case_812() +#line 5388 "cs-parser.jay" { start_block (GetLocation (yyVals[0+yyTop])); current_block.IsCompilerGenerated = true; @@ -8151,8 +8200,8 @@ void case_810() yyVal = f; } -void case_812() -#line 5386 "cs-parser.jay" +void case_814() +#line 5405 "cs-parser.jay" { For f = (For) yyVals[-2+yyTop]; f.Initializer = (Statement) yyVals[-1+yyTop]; @@ -8160,8 +8209,8 @@ void case_812() yyVal = f; } -void case_814() -#line 5396 "cs-parser.jay" +void case_816() +#line 5415 "cs-parser.jay" { report.Error (1525, GetLocation (yyVals[0+yyTop]), "Unexpected symbol ')', expected ';'"); For f = (For) yyVals[-2+yyTop]; @@ -8170,8 +8219,8 @@ void case_814() yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_815() -#line 5407 "cs-parser.jay" +void case_817() +#line 5426 "cs-parser.jay" { For f = (For) yyVals[-2+yyTop]; f.Condition = (BooleanExpression) yyVals[-1+yyTop]; @@ -8179,8 +8228,8 @@ void case_815() yyVal = f; } -void case_817() -#line 5417 "cs-parser.jay" +void case_819() +#line 5437 "cs-parser.jay" { report.Error (1525, GetLocation (yyVals[0+yyTop]), "Unexpected symbol ')', expected ';'"); For f = (For) yyVals[-2+yyTop]; @@ -8189,8 +8238,8 @@ void case_817() yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_818() -#line 5429 "cs-parser.jay" +void case_820() +#line 5449 "cs-parser.jay" { For f = (For) yyVals[-3+yyTop]; f.Iterator = (Statement) yyVals[-2+yyTop]; @@ -8204,15 +8253,15 @@ void case_818() yyVal = end_block (GetLocation (yyVals[-1+yyTop])); } -void case_819() -#line 5442 "cs-parser.jay" +void case_821() +#line 5462 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = end_block (current_block.StartLocation); } -void case_822() -#line 5455 "cs-parser.jay" +void case_824() +#line 5475 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop]; var li = new LocalVariable (current_block, lt.Value, lt.Location); @@ -8220,15 +8269,15 @@ void case_822() current_variable = new BlockVariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_823() -#line 5462 "cs-parser.jay" +void case_825() +#line 5482 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_831() -#line 5486 "cs-parser.jay" +void case_833() +#line 5506 "cs-parser.jay" { var sl = yyVals[-2+yyTop] as StatementList; if (sl == null) { @@ -8243,8 +8292,8 @@ void case_831() yyVal = sl; } -void case_832() -#line 5503 "cs-parser.jay" +void case_834() +#line 5523 "cs-parser.jay" { report.Error (230, GetLocation (yyVals[-3+yyTop]), "Type and identifier are both required in a foreach statement"); @@ -8258,8 +8307,8 @@ void case_832() yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_833() -#line 5516 "cs-parser.jay" +void case_835() +#line 5536 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8277,8 +8326,8 @@ void case_833() yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_834() -#line 5533 "cs-parser.jay" +void case_836() +#line 5553 "cs-parser.jay" { start_block (GetLocation (yyVals[-5+yyTop])); current_block.IsCompilerGenerated = true; @@ -8288,8 +8337,8 @@ void case_834() yyVal = li; } -void case_835() -#line 5542 "cs-parser.jay" +void case_837() +#line 5562 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8301,8 +8350,8 @@ void case_835() yyVal = f; } -void case_836() -#line 5553 "cs-parser.jay" +void case_838() +#line 5573 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); current_block.IsCompilerGenerated = true; @@ -8316,8 +8365,8 @@ void case_836() yyVal = end_block (GetLocation (yyVals[0+yyTop])); } -void case_837() -#line 5566 "cs-parser.jay" +void case_839() +#line 5586 "cs-parser.jay" { Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, null, GetLocation (yyVals[-3+yyTop])); current_block.AddStatement (f); @@ -8326,79 +8375,86 @@ void case_837() yyVal = f; } -void case_844() -#line 5586 "cs-parser.jay" +void case_846() +#line 5606 "cs-parser.jay" { yyVal = new Break (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_845() -#line 5594 "cs-parser.jay" +void case_847() +#line 5614 "cs-parser.jay" { yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_846() -#line 5599 "cs-parser.jay" +void case_848() +#line 5619 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Continue (GetLocation (yyVals[-1+yyTop])); } -void case_847() -#line 5607 "cs-parser.jay" +void case_849() +#line 5627 "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_848() -#line 5613 "cs-parser.jay" +void case_850() +#line 5633 "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_849() -#line 5618 "cs-parser.jay" +void case_851() +#line 5638 "cs-parser.jay" { yyVal = new GotoDefault (GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_850() -#line 5626 "cs-parser.jay" +void case_852() +#line 5646 "cs-parser.jay" { yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_851() -#line 5631 "cs-parser.jay" +void case_853() +#line 5651 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); + } + +void case_854() +#line 5656 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Return (null, GetLocation (yyVals[-1+yyTop])); } -void case_852() -#line 5639 "cs-parser.jay" +void case_855() +#line 5664 "cs-parser.jay" { yyVal = new Throw ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_853() -#line 5644 "cs-parser.jay" +void case_856() +#line 5669 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = new Throw (null, GetLocation (yyVals[-1+yyTop])); } -void case_854() -#line 5652 "cs-parser.jay" +void case_857() +#line 5677 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; string s = lt.Value; @@ -8415,8 +8471,28 @@ void case_854() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_855() -#line 5668 "cs-parser.jay" +void case_858() +#line 5693 "cs-parser.jay" +{ + Error_SyntaxError (yyToken); + + var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; + string s = lt.Value; + if (s != "yield"){ + report.Error (1003, lt.Location, "; expected"); + } else if (yyVals[-1+yyTop] == null) { + report.Error (1627, GetLocation (yyVals[0+yyTop]), "Expression expected after yield return"); + } else if (lang_version == LanguageVersion.ISO_1){ + FeatureIsNotAvailable (lt.Location, "iterators"); + } + + current_block.Explicit.RegisterIteratorYield (); + yyVal = new Yield ((Expression) yyVals[-1+yyTop], lt.Location); + lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); + } + +void case_859() +#line 5711 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; string s = lt.Value; @@ -8431,30 +8507,30 @@ void case_855() lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); } -void case_859() -#line 5694 "cs-parser.jay" +void case_863() +#line 5737 "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_860() -#line 5699 "cs-parser.jay" +void case_864() +#line 5742 "cs-parser.jay" { 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_861() -#line 5705 "cs-parser.jay" +void case_865() +#line 5748 "cs-parser.jay" { Error_SyntaxError (1524, yyToken); yyVal = new TryCatch ((Block) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]), false); } -void case_862() -#line 5713 "cs-parser.jay" +void case_866() +#line 5756 "cs-parser.jay" { var l = new List (2); @@ -8462,8 +8538,8 @@ void case_862() yyVal = l; } -void case_863() -#line 5720 "cs-parser.jay" +void case_867() +#line 5763 "cs-parser.jay" { var l = (List) yyVals[-1+yyTop]; @@ -8476,8 +8552,8 @@ void case_863() yyVal = l; } -void case_867() -#line 5744 "cs-parser.jay" +void case_871() +#line 5787 "cs-parser.jay" { start_block (GetLocation (yyVals[-3+yyTop])); var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop])); @@ -8493,8 +8569,8 @@ void case_867() yyVal = c; } -void case_869() -#line 5763 "cs-parser.jay" +void case_873() +#line 5806 "cs-parser.jay" { if (yyToken == Token.CLOSE_PARENS) { report.Error (1015, lexer.Location, @@ -8506,15 +8582,15 @@ void case_869() yyVal = new Catch (null, GetLocation (yyVals[-2+yyTop])); } -void case_872() -#line 5791 "cs-parser.jay" +void case_876() +#line 5834 "cs-parser.jay" { if (!settings.Unsafe) Error_UnsafeCodeNotAllowed (GetLocation (yyVals[0+yyTop])); } -void case_874() -#line 5801 "cs-parser.jay" +void case_878() +#line 5844 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8523,8 +8599,8 @@ void case_874() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_875() -#line 5809 "cs-parser.jay" +void case_879() +#line 5852 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8532,8 +8608,8 @@ void case_875() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_876() -#line 5819 "cs-parser.jay" +void case_880() +#line 5862 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8544,15 +8620,15 @@ void case_876() current_variable = new Fixed.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_877() -#line 5829 "cs-parser.jay" +void case_881() +#line 5872 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_878() -#line 5834 "cs-parser.jay" +void case_882() +#line 5877 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8563,8 +8639,8 @@ void case_878() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_879() -#line 5847 "cs-parser.jay" +void case_883() +#line 5890 "cs-parser.jay" { start_block (GetLocation (yyVals[-2+yyTop])); @@ -8575,15 +8651,15 @@ void case_879() current_variable = new Using.VariableDeclaration ((FullNamedExpression) yyVals[-1+yyTop], li); } -void case_880() -#line 5857 "cs-parser.jay" +void case_884() +#line 5900 "cs-parser.jay" { yyVal = current_variable; current_variable = null; } -void case_881() -#line 5862 "cs-parser.jay" +void case_885() +#line 5905 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8594,8 +8670,8 @@ void case_881() yyVal = end_block (GetLocation (yyVals[-2+yyTop])); } -void case_882() -#line 5872 "cs-parser.jay" +void case_886() +#line 5915 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); @@ -8604,8 +8680,8 @@ void case_882() lbag.AddStatement (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop])); } -void case_883() -#line 5880 "cs-parser.jay" +void case_887() +#line 5923 "cs-parser.jay" { Error_SyntaxError (yyToken); @@ -8613,23 +8689,23 @@ void case_883() lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_885() -#line 5891 "cs-parser.jay" +void case_889() +#line 5934 "cs-parser.jay" { /* It has to be here for the parent to safely restore artificial block*/ Error_SyntaxError (yyToken); } -void case_887() -#line 5903 "cs-parser.jay" +void case_891() +#line 5946 "cs-parser.jay" { current_variable.Initializer = (Expression) yyVals[0+yyTop]; lbag.AppendTo (current_variable, GetLocation (yyVals[-1+yyTop])); yyVal = current_variable; } -void case_888() -#line 5915 "cs-parser.jay" +void case_892() +#line 5958 "cs-parser.jay" { lexer.query_parsing = false; @@ -8642,8 +8718,8 @@ void case_888() current_block = current_block.Parent; } -void case_889() -#line 5927 "cs-parser.jay" +void case_893() +#line 5970 "cs-parser.jay" { Linq.AQueryClause from = yyVals[-1+yyTop] as Linq.AQueryClause; @@ -8654,8 +8730,8 @@ void case_889() current_block = current_block.Parent; } -void case_890() -#line 5938 "cs-parser.jay" +void case_894() +#line 5981 "cs-parser.jay" { lexer.query_parsing = false; yyVal = yyVals[-1+yyTop]; @@ -8664,16 +8740,16 @@ void case_890() current_block = current_block.Parent; } -void case_891() -#line 5945 "cs-parser.jay" +void case_895() +#line 5988 "cs-parser.jay" { yyVal = yyVals[-1+yyTop]; current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; } -void case_892() -#line 5954 "cs-parser.jay" +void case_896() +#line 5997 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8684,8 +8760,8 @@ void case_892() yyVal = new Linq.QueryExpression (start); } -void case_893() -#line 5964 "cs-parser.jay" +void case_897() +#line 6007 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8698,8 +8774,8 @@ void case_893() yyVal = new Linq.QueryExpression (start); } -void case_894() -#line 5979 "cs-parser.jay" +void case_898() +#line 6022 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8710,8 +8786,8 @@ void case_894() yyVal = new Linq.QueryExpression (start); } -void case_895() -#line 5989 "cs-parser.jay" +void case_899() +#line 6032 "cs-parser.jay" { current_block = new Linq.QueryBlock (current_block, lexer.Location); @@ -8724,8 +8800,8 @@ void case_895() yyVal = new Linq.QueryExpression (start); } -void case_897() -#line 6008 "cs-parser.jay" +void case_901() +#line 6051 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8738,8 +8814,8 @@ void case_897() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_899() -#line 6024 "cs-parser.jay" +void case_903() +#line 6067 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8756,8 +8832,8 @@ void case_899() lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop])); } -void case_900() -#line 6043 "cs-parser.jay" +void case_904() +#line 6086 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[-1+yyTop]; @@ -8773,8 +8849,8 @@ void case_900() yyVal = head; } -void case_901() -#line 6058 "cs-parser.jay" +void case_905() +#line 6101 "cs-parser.jay" { Linq.AQueryClause head = (Linq.AQueryClause)yyVals[0+yyTop]; @@ -8787,22 +8863,22 @@ void case_901() yyVal = head; } -void case_903() -#line 6071 "cs-parser.jay" +void case_907() +#line 6114 "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" +void case_908() +#line 6119 "cs-parser.jay" { Error_SyntaxError (yyToken); yyVal = null; } -void case_906() -#line 6088 "cs-parser.jay" +void case_910() +#line 6131 "cs-parser.jay" { yyVal = new Linq.Select ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8810,8 +8886,8 @@ void case_906() current_block = current_block.Parent; } -void case_907() -#line 6095 "cs-parser.jay" +void case_911() +#line 6138 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8820,8 +8896,8 @@ void case_907() linq_clause_blocks.Push ((Linq.QueryBlock)current_block); } -void case_908() -#line 6103 "cs-parser.jay" +void case_912() +#line 6146 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8829,8 +8905,8 @@ void case_908() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_909() -#line 6110 "cs-parser.jay" +void case_913() +#line 6153 "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])); @@ -8839,15 +8915,15 @@ void case_909() current_block = current_block.Parent; } -void case_911() -#line 6122 "cs-parser.jay" +void case_915() +#line 6165 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-1+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-1+yyTop]; } -void case_918() -#line 6142 "cs-parser.jay" +void case_922() +#line 6185 "cs-parser.jay" { var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop]; var sn = new Linq.RangeVariable (lt.Value, lt.Location); @@ -8860,8 +8936,8 @@ void case_918() ((Linq.QueryBlock)current_block).AddRangeVariable (sn); } -void case_920() -#line 6161 "cs-parser.jay" +void case_924() +#line 6204 "cs-parser.jay" { yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop])); @@ -8869,8 +8945,8 @@ void case_920() current_block = current_block.Parent; } -void case_921() -#line 6171 "cs-parser.jay" +void case_925() +#line 6214 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8879,8 +8955,8 @@ void case_921() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_922() -#line 6179 "cs-parser.jay" +void case_926() +#line 6222 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8889,8 +8965,8 @@ void case_922() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_923() -#line 6187 "cs-parser.jay" +void case_927() +#line 6230 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8899,8 +8975,8 @@ void case_923() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_924() -#line 6195 "cs-parser.jay" +void case_928() +#line 6238 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8939,8 +9015,8 @@ void case_924() ((Linq.QueryBlock)current_block).AddRangeVariable (into); } -void case_925() -#line 6233 "cs-parser.jay" +void case_929() +#line 6276 "cs-parser.jay" { if (linq_clause_blocks == null) linq_clause_blocks = new Stack (); @@ -8949,8 +9025,8 @@ void case_925() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_926() -#line 6241 "cs-parser.jay" +void case_930() +#line 6284 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -8959,8 +9035,8 @@ void case_926() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_927() -#line 6249 "cs-parser.jay" +void case_931() +#line 6292 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -8969,8 +9045,8 @@ void case_927() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_928() -#line 6257 "cs-parser.jay" +void case_932() +#line 6300 "cs-parser.jay" { current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop])); current_block.SetEndLocation (lexer.Location); @@ -9013,15 +9089,15 @@ void case_928() ((Linq.QueryBlock)current_block).AddRangeVariable (into); } -void case_930() -#line 6303 "cs-parser.jay" +void case_934() +#line 6346 "cs-parser.jay" { opt_intoStack.Push (GetLocation (yyVals[-1+yyTop])); yyVal = yyVals[0+yyTop]; } -void case_932() -#line 6315 "cs-parser.jay" +void case_936() +#line 6358 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -9029,8 +9105,8 @@ void case_932() yyVal = yyVals[0+yyTop]; } -void case_934() -#line 6326 "cs-parser.jay" +void case_938() +#line 6369 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -9038,15 +9114,15 @@ void case_934() current_block = new Linq.QueryBlock (current_block, lexer.Location); } -void case_935() -#line 6333 "cs-parser.jay" +void case_939() +#line 6376 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } -void case_937() -#line 6342 "cs-parser.jay" +void case_941() +#line 6385 "cs-parser.jay" { current_block.SetEndLocation (lexer.Location); current_block = current_block.Parent; @@ -9054,43 +9130,43 @@ void case_937() current_block = new Linq.QueryBlock ((Linq.QueryBlock) current_block, lexer.Location); } -void case_938() -#line 6349 "cs-parser.jay" +void case_942() +#line 6392 "cs-parser.jay" { ((Linq.AQueryClause)yyVals[-3+yyTop]).Tail.Next = (Linq.AQueryClause)yyVals[0+yyTop]; yyVal = yyVals[-3+yyTop]; } -void case_940() -#line 6361 "cs-parser.jay" +void case_944() +#line 6404 "cs-parser.jay" { yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_941() -#line 6366 "cs-parser.jay" +void case_945() +#line 6409 "cs-parser.jay" { yyVal = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_943() -#line 6378 "cs-parser.jay" +void case_947() +#line 6421 "cs-parser.jay" { yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_944() -#line 6383 "cs-parser.jay" +void case_948() +#line 6426 "cs-parser.jay" { yyVal = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)yyVals[-1+yyTop]); lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop])); } -void case_946() -#line 6393 "cs-parser.jay" +void case_950() +#line 6436 "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*/ @@ -9107,8 +9183,8 @@ void case_946() linq_clause_blocks.Push ((Linq.QueryBlock) current_block); } -void case_947() -#line 6409 "cs-parser.jay" +void case_951() +#line 6452 "cs-parser.jay" { var current_block = linq_clause_blocks.Pop (); var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop]; @@ -9118,8 +9194,8 @@ void case_947() }; } -void case_950() -#line 6436 "cs-parser.jay" +void case_954() +#line 6479 "cs-parser.jay" { current_container = current_type = new Class (current_container, new MemberName (""), Modifiers.PUBLIC, null); @@ -9148,8 +9224,8 @@ void case_950() start_block (lexer.Location); } -void case_951() -#line 6464 "cs-parser.jay" +void case_955() +#line 6507 "cs-parser.jay" { --lexer.parsing_block; Method method = (Method) oob_stack.Pop (); @@ -9160,16 +9236,16 @@ void case_951() current_local_parameters = null; } -void case_961() -#line 6507 "cs-parser.jay" +void case_965() +#line 6550 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; yyVal = null; } -void case_962() -#line 6513 "cs-parser.jay" +void case_966() +#line 6556 "cs-parser.jay" { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3+yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[0+yyTop]; @@ -9177,15 +9253,15 @@ void case_962() yyVal = new MemberName (lt.Value); } -void case_965() -#line 6528 "cs-parser.jay" +void case_969() +#line 6571 "cs-parser.jay" { module.DocumentationBuilder.ParsedParameters = (List)yyVals[-1+yyTop]; yyVal = new MemberName ((MemberName) yyVals[-6+yyTop], MemberCache.IndexerNameAlias, Location.Null); } -void case_966() -#line 6533 "cs-parser.jay" +void case_970() +#line 6576 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -9194,8 +9270,8 @@ void case_966() yyVal = null; } -void case_967() -#line 6541 "cs-parser.jay" +void case_971() +#line 6584 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); p.Add (new DocumentationParameter ((FullNamedExpression) yyVals[-1+yyTop])); @@ -9204,8 +9280,8 @@ void case_967() yyVal = null; } -void case_968() -#line 6549 "cs-parser.jay" +void case_972() +#line 6592 "cs-parser.jay" { var p = (List)yyVals[0+yyTop] ?? new List (1); module.DocumentationBuilder.ParsedParameters = p; @@ -9213,24 +9289,24 @@ void case_968() yyVal = null; } -void case_976() -#line 6587 "cs-parser.jay" +void case_980() +#line 6630 "cs-parser.jay" { var parameters = new List (); parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); yyVal = parameters; } -void case_977() -#line 6593 "cs-parser.jay" +void case_981() +#line 6636 "cs-parser.jay" { var parameters = yyVals[-2+yyTop] as List; parameters.Add ((DocumentationParameter) yyVals[0+yyTop]); yyVal = parameters; } -void case_978() -#line 6602 "cs-parser.jay" +void case_982() +#line 6645 "cs-parser.jay" { if (yyVals[-1+yyTop] != null) yyVal = new DocumentationParameter ((Parameter.Modifier) yyVals[-1+yyTop], (FullNamedExpression) yyVals[0+yyTop]); @@ -9272,72 +9348,73 @@ void case_978() 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, + 186, 187, 186, 186, 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, - 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, + 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, 217, 237, 237, 238, 238, + 239, 239, 241, 241, 241, 242, 242, 242, 242, 242, + 243, 243, 159, 159, 236, 236, 236, 236, 236, 248, + 248, 247, 247, 249, 249, 249, 249, 250, 218, 218, + 218, 246, 246, 246, 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, 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, 244, 244, 244, 244, 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, 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, + 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, 389, 390, 390, 391, 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, 245, 245, + 240, 240, 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, @@ -9372,2466 +9449,2419 @@ void case_978() 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, + 2, 0, 5, 3, 1, 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, - 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, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 3, 4, 4, 4, 3, + 3, 4, 3, 4, 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, 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, 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, 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, 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, + 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, 2, 3, 4, + 3, 3, 3, 2, 3, 2, 4, 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, 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, 11, 14, 0, 952, 0, 0, 956, 0, + 0, 15, 17, 379, 385, 392, 380, 382, 0, 381, + 0, 388, 390, 377, 0, 384, 386, 378, 389, 391, + 387, 342, 973, 0, 383, 963, 0, 10, 1, 0, + 0, 0, 12, 0, 782, 0, 0, 0, 0, 0, + 0, 0, 0, 420, 0, 0, 0, 0, 0, 0, + 0, 418, 0, 0, 0, 479, 0, 419, 0, 518, + 0, 876, 0, 0, 0, 629, 0, 0, 0, 0, + 0, 0, 0, 680, 0, 731, 0, 0, 0, 0, + 0, 0, 0, 0, 417, 0, 618, 0, 781, 0, + 714, 0, 0, 0, 0, 394, 395, 396, 397, 398, + 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, + 409, 410, 411, 412, 415, 416, 625, 548, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 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, + 626, 624, 627, 628, 698, 700, 0, 696, 699, 715, + 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, + 716, 0, 0, 0, 783, 784, 803, 804, 805, 806, + 840, 841, 842, 843, 844, 845, 0, 0, 0, 20, + 0, 0, 332, 0, 334, 960, 16, 953, 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, + 252, 253, 0, 0, 976, 0, 965, 0, 964, 3, 51, 0, 0, 0, 40, 37, 39, 42, 43, 44, - 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, + 45, 46, 49, 13, 0, 0, 0, 846, 421, 422, + 874, 0, 0, 0, 0, 0, 0, 0, 848, 847, + 0, 540, 534, 539, 730, 780, 701, 728, 727, 729, + 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, + 712, 713, 0, 0, 0, 812, 0, 0, 0, 746, + 745, 0, 0, 0, 0, 0, 0, 0, 0, 854, + 0, 0, 0, 0, 393, 0, 0, 0, 856, 861, + 0, 0, 0, 875, 0, 0, 0, 744, 740, 0, + 0, 0, 0, 0, 0, 0, 361, 0, 0, 0, + 0, 0, 0, 0, 0, 621, 0, 547, 0, 0, + 545, 549, 550, 544, 554, 553, 551, 552, 614, 529, + 0, 414, 413, 0, 0, 0, 0, 0, 732, 0, + 331, 0, 738, 739, 0, 482, 483, 0, 0, 0, + 736, 737, 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, 955, 697, 747, 735, 0, + 778, 779, 908, 923, 0, 0, 909, 911, 0, 935, + 894, 892, 916, 0, 0, 914, 917, 918, 919, 920, + 895, 893, 0, 0, 0, 336, 0, 18, 0, 0, + 0, 972, 0, 343, 0, 0, 0, 974, 0, 0, + 38, 651, 657, 649, 0, 646, 656, 650, 648, 647, + 654, 652, 653, 659, 655, 658, 660, 0, 0, 644, + 41, 50, 481, 0, 477, 478, 0, 0, 475, 0, + 749, 0, 0, 0, 810, 0, 777, 775, 776, 0, + 0, 0, 633, 0, 851, 849, 634, 0, 0, 503, + 0, 0, 0, 494, 0, 498, 508, 510, 0, 490, + 0, 0, 0, 0, 0, 485, 0, 488, 0, 492, + 363, 853, 852, 0, 0, 855, 865, 0, 0, 0, + 866, 0, 0, 877, 0, 0, 743, 0, 373, 369, + 370, 0, 0, 368, 371, 372, 0, 0, 0, 555, + 0, 0, 536, 0, 616, 695, 0, 0, 0, 689, + 691, 692, 693, 425, 426, 0, 339, 340, 0, 179, + 178, 180, 0, 0, 0, 0, 365, 0, 601, 0, + 0, 859, 0, 0, 0, 430, 0, 433, 0, 431, + 0, 471, 0, 0, 0, 0, 0, 460, 463, 0, + 0, 455, 462, 461, 590, 591, 592, 593, 594, 595, + 596, 597, 598, 600, 599, 556, 558, 557, 562, 563, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 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, + 0, 0, 0, 0, 0, 586, 0, 0, 507, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 907, 906, + 0, 915, 0, 905, 0, 0, 333, 970, 971, 357, + 0, 0, 0, 354, 0, 0, 176, 0, 0, 980, + 966, 968, 59, 57, 58, 0, 0, 52, 0, 0, + 60, 62, 26, 24, 0, 0, 0, 641, 0, 645, + 429, 0, 480, 0, 531, 0, 542, 165, 187, 0, + 0, 0, 155, 0, 0, 0, 166, 535, 0, 880, + 0, 832, 813, 0, 823, 0, 834, 0, 850, 787, + 0, 879, 0, 0, 493, 0, 509, 511, 0, 0, + 447, 0, 0, 443, 0, 0, 472, 0, 513, 487, + 0, 0, 140, 514, 138, 139, 516, 0, 530, 790, + 0, 870, 0, 863, 0, 867, 522, 0, 0, 0, + 358, 0, 520, 0, 0, 532, 887, 0, 883, 808, + 0, 898, 0, 896, 0, 0, 631, 632, 0, 0, + 0, 694, 682, 683, 681, 690, 609, 615, 608, 0, + 0, 338, 604, 0, 0, 0, 546, 858, 857, 733, + 434, 428, 432, 427, 533, 470, 469, 468, 465, 464, + 0, 459, 423, 424, 435, 436, 0, 589, 0, 756, + 0, 0, 613, 612, 924, 900, 0, 925, 0, 910, + 912, 921, 0, 936, 0, 904, 950, 19, 335, 679, + 678, 0, 677, 0, 353, 982, 177, 977, 0, 0, + 53, 0, 0, 0, 0, 0, 0, 360, 0, 635, + 0, 0, 79, 78, 0, 476, 0, 0, 0, 0, + 0, 170, 541, 0, 0, 0, 0, 0, 824, 816, + 814, 0, 835, 0, 0, 878, 500, 499, 450, 0, + 0, 961, 962, 439, 445, 0, 448, 0, 474, 0, + 0, 0, 0, 0, 788, 873, 0, 864, 0, 528, + 523, 0, 0, 519, 0, 886, 0, 807, 899, 897, + 0, 537, 0, 617, 611, 341, 603, 602, 619, 467, + 0, 458, 457, 456, 588, 140, 0, 772, 754, 0, + 0, 0, 761, 0, 902, 0, 929, 0, 0, 944, + 945, 938, 0, 356, 355, 981, 0, 0, 61, 55, + 0, 63, 25, 22, 0, 0, 309, 0, 213, 0, + 102, 0, 76, 766, 113, 114, 0, 0, 0, 769, + 185, 186, 0, 0, 0, 0, 158, 167, 159, 161, + 811, 0, 0, 0, 0, 0, 833, 0, 0, 449, + 451, 452, 446, 440, 444, 0, 505, 0, 473, 484, + 438, 517, 515, 0, 869, 0, 0, 0, 524, 0, + 889, 0, 0, 630, 622, 0, 466, 0, 0, 752, + 751, 748, 762, 901, 0, 0, 0, 0, 922, 0, + 951, 969, 0, 0, 0, 68, 69, 72, 73, 0, + 326, 315, 314, 0, 636, 209, 97, 0, 750, 770, + 171, 0, 183, 0, 0, 0, 809, 891, 0, 0, + 0, 0, 815, 0, 836, 786, 489, 486, 795, 0, + 802, 0, 0, 793, 0, 798, 871, 527, 526, 888, + 884, 0, 620, 0, 0, 903, 926, 0, 913, 0, + 0, 940, 0, 74, 66, 0, 0, 0, 310, 0, + 0, 0, 0, 0, 172, 0, 162, 160, 881, 825, + 819, 817, 0, 0, 789, 794, 0, 799, 0, 0, + 623, 0, 764, 0, 930, 947, 948, 941, 54, 0, + 70, 71, 0, 0, 0, 0, 0, 0, 0, 771, + 169, 0, 182, 0, 0, 837, 801, 800, 0, 684, + 686, 872, 885, 773, 0, 0, 0, 75, 0, 0, + 327, 0, 0, 325, 311, 0, 319, 376, 0, 374, + 0, 637, 0, 666, 210, 98, 173, 882, 821, 818, + 0, 0, 830, 0, 927, 0, 942, 0, 0, 0, + 308, 0, 0, 663, 0, 0, 0, 667, 0, 0, + 0, 0, 0, 931, 28, 23, 328, 324, 0, 0, + 320, 375, 669, 0, 0, 0, 99, 820, 685, 0, + 0, 0, 0, 312, 674, 0, 675, 672, 0, 670, + 95, 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, 928, 0, 329, 323, 0, 0, 0, + 638, 83, 0, 269, 264, 268, 0, 211, 217, 0, + 934, 932, 673, 671, 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, 347, 0, 345, 0, 0, 188, + 0, 0, 0, 0, 0, 639, 212, 0, 103, 0, + 344, 0, 0, 0, 0, 117, 0, 0, 0, 0, + 0, 0, 151, 143, 0, 0, 192, 0, 348, 0, + 230, 229, 228, 0, 101, 0, 282, 0, 260, 119, + 0, 258, 0, 0, 0, 121, 0, 349, 0, 0, + 189, 0, 0, 0, 346, 233, 112, 110, 0, 0, + 286, 0, 0, 0, 0, 0, 147, 0, 266, 0, + 0, 0, 0, 125, 0, 0, 0, 0, 350, 351, + 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, 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, + 12, 13, 52, 22, 23, 324, 235, 685, 856, 1050, + 1170, 1515, 853, 236, 237, 238, 239, 240, 241, 242, + 243, 678, 449, 679, 680, 958, 681, 682, 962, 854, + 1045, 1046, 1047, 266, 599, 1140, 110, 865, 1244, 1245, + 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, + 1256, 468, 689, 1327, 972, 1147, 1112, 1182, 1210, 1272, + 1338, 1178, 1389, 1366, 1414, 1415, 1416, 974, 1412, 975, + 746, 1304, 1377, 1351, 1402, 520, 1395, 1371, 1431, 938, + 1400, 1403, 1404, 1499, 1432, 1433, 1429, 1257, 1311, 1283, + 1328, 702, 1379, 1478, 1348, 1435, 1508, 469, 267, 703, + 704, 705, 706, 707, 665, 575, 1152, 666, 667, 871, + 1330, 1356, 1446, 1407, 1480, 1331, 1382, 1504, 1528, 1447, + 1448, 1526, 1512, 1513, 970, 1111, 1209, 1269, 1313, 1270, + 1271, 1305, 1363, 1334, 1306, 327, 223, 1411, 1308, 1396, + 1393, 1258, 1285, 1324, 1475, 1437, 1162, 1476, 600, 1521, + 1522, 1323, 1392, 1368, 1424, 1419, 1390, 1456, 1461, 1422, + 1425, 1426, 1507, 1462, 1420, 1421, 1517, 1505, 1506, 967, + 1054, 1175, 1145, 1202, 1176, 1177, 1219, 1108, 1199, 1232, + 540, 193, 112, 353, 195, 569, 444, 224, 1343, 663, + 664, 842, 858, 328, 409, 539, 304, 1179, 1180, 45, + 114, 305, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 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, + 134, 135, 136, 252, 815, 742, 1010, 516, 732, 894, + 733, 734, 1003, 137, 198, 738, 602, 603, 604, 809, + 478, 479, 297, 1008, 740, 410, 299, 503, 504, 505, + 506, 509, 748, 313, 764, 765, 911, 263, 484, 779, + 264, 483, 138, 139, 140, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 825, 152, 578, 579, + 580, 788, 789, 790, 153, 566, 781, 354, 1026, 554, + 1092, 154, 498, 968, 1110, 1207, 1309, 470, 1183, 1184, + 1239, 1240, 843, 558, 339, 785, 1194, 559, 560, 268, + 269, 270, 157, 158, 159, 271, 272, 273, 274, 275, + 276, 277, 278, 279, 280, 281, 282, 171, 283, 585, + 172, 173, 320, 822, 638, 941, 1032, 868, 696, 978, + 939, 942, 1070, 943, 979, 980, 284, 174, 175, 176, + 1082, 1014, 1083, 1084, 1085, 1127, 1086, 177, 178, 179, + 180, 713, 491, 714, 1073, 996, 1074, 1190, 1155, 1191, + 715, 995, 716, 1193, 1123, 181, 182, 183, 184, 185, + 186, 306, 530, 531, 1016, 1129, 316, 994, 878, 1154, + 1023, 917, 1130, 187, 422, 188, 423, 944, 1035, 424, + 425, 654, 645, 646, 948, 426, 427, 428, 429, 430, + 949, 640, 946, 1134, 1213, 1274, 1037, 1166, 1231, 834, + 648, 835, 1101, 1040, 1102, 1167, 953, 17, 19, 46, + 47, 227, 668, 850, 445, 669, 670, }; - 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, + protected static readonly short [] yySindex = { -167, + 0, -194, 51, 72, 108,12563, 0, 231, 0, 0, + 108, 72, 0, 0, -63, 0, 6715, 108, 0, -179, + -254, 0, 0, 0, 0, 0, 0, 0, 244, 0, + 327, 0, 0, 0, 3845, 0, 0, 0, 0, 0, + 0, 0, 0, 439, 0, 0, 575, 0, 0, 231, + 215, 108, 0, 319, 0, 264, 358, 279,12045, -163, + 9, 399, 6872, 0, 9, 9, 9, -137, 9, 9, + 706, 0, 8561, 9, 9, 0, 8718, 0, 482, 0, + 279, 0, 9, 419, 9, 0, 1465, 1465, 501, 9, + 9, -216,11828, 0,11148, 0,11828,11828,11828,11828, +11828,11828,11828,11828, 0, 133, 0, 7831, 0, 131, + 0, 437, 505, 318, 429, 0, 0, 0, 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, 1044, 775, + 84, 280, 559, 260, 523, 568, 580, 593, -288, 609, + 0, 0, 0, 0, 0, 0, 3546, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 168, 614, 250, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 317, 332, 215, 0, + 451, 191, 0, 587, 0, 0, 0, 0, 7831, 7831, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 665, 599, 0, 629, 0, 69, 0, 0, + 0, 215,13031, 713, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 794, 641,11284, 0, 0, 0, + 0,11148, 9, 9, 785, 331, 318, 168, 0, 0, + 7831, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, -176, -267,12045, 0, 7831,11148, 716, 0, + 0, 734,11148,11148, 9503, -251, -118, 772, 8126, 0, +11828, 133, 889, 800, 0, 818, 7831,11148, 0, 0, + 830, 591, 9, 0,11148, 482,10604, 0, 0, 419, +11148, 419, -279, 539, 854, 168, 0, 614, 429, 919, + 168,11148,11148,11148, 399, 0, 840, 0, 7029, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, + 4270, 0, 0,12518, -279, 843, 857,11148, 0, 809, + 0, -294, 0, 0, 356, 0, 0, 810, 8875,10468, + 0, 0,11148,11148,11148,11148,11148,11148,11148,11148, +11148,11148,11148,11828,11828,11828, 7831, 7831,11828,11828, +11828,11828,11828,11828,11828,11828,11828,11828,11828,11828, +11828,11828,11828,11828,11148, 0, 0, 0, 0, 614, + 0, 0, 0, 0, 1465, 1465, 0, 0, 168, 0, + 0, 0, 0, 374, 875, 0, 0, 0, 0, 0, + 0, 0, 215, 713, 821, 0, 841, 0, 809, 665, + 665, 0, -86, 0, 551, 665, 873, 0, -184,13031, + 0, 0, 0, 0, -174, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 198,13061, 0, + 0, 0, 0, 809, 0, 0, 872, 534, 0, 888, + 0, 890, 144, 482, 0, 9, 0, 0, 0, 168, +10604, -156, 0, 885, 0, 0, 0, -40, 53, 0, + 438, 0, 897, 0, 892, 0, 0, 0, 596, 0, + 8245, 615,11148, 772,10468, 0, 7500, 0, 419, 0, + 0, 0, 0, 896, 92, 0, 0, 279, 482, -159, + 0, 4111, 900, 0, 135, 168, 0, 136, 0, 0, + 0,11148, 975, 0, 0, 0,11148, 979, 901, 0, + 904, 906, 0,12518, 0, 0, -186, 44, 7029, 0, + 0, 0, 0, 0, 0, 482, 0, 0, -268, 0, + 0, 0, 419, -279, 168, 8421, 0, 907, 0, 908, +11828, 0, 1029, 920, 7029, 0, -300, 0, 240, 0, + 809, 0, 81,11148,11148, 924, 1041, 0, 0, 123, + -80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, + 775, 775, 84, 84, 280, 280, 280, 280, 559, 559, + 260, 523, 568, 580, 593, 0, -161, -149, 0, 9032, + 1005, 168, 1006, 168, 9032, 9032, 921,11148, 0, 0, + 875, 0, 168, 0, 422, 809, 0, 0, 0, 0, + 481, 215, 31, 0, 8421, 551, 0, 931, 930, 0, + 0, 0, 0, 0, 0, -279, 933, 0, 934, 936, + 0, 0, 0, 0, 938, 8578, 894, 0, 267, 0, + 0, 321, 0,11284, 0, 932, 0, 0, 0, 454, + -47, 942, 0, 941, 943, 944, 0, 0,11148, 0, + 168, 0, 0, 704, 0, 945, 0, 427, 0, 0, + 6872, 0, 6872, 8404, 0, 9503, 0, 0,10740, 151, + 0, 114, -34, 0, 887, 899, 0, 91, 0, 0, + 948, 949, 0, 0, 0, 0, 0, 950, 0, 0, + 958, 0, 4429, 0, 482, 0, 0, 419, 617, 905, + 0, 175, 0, 955, 956, 0, 0, 6872, 0, 0, + 6872, 0,11148, 0,11148, 7831, 0, 0, 482, 959, + 482, 0, 0, 0, 0, 0, 0, 0, 0, 9032, + 7831, 0, 0, 168,12518, 987, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, +10332, 0, 0, 0, 0, 0, 7657, 0, 9032, 0, + 7814, 964, 0, 0, 0, 0, 1038, 0, 1039, 0, + 0, 0, 566, 0, 966, 0, 0, 0, 0, 0, + 0, 926, 0, -86, 0, 0, 0, 0, 551, 551, + 0, 821, 976, 974, 937, 981, 894, 0, 977, 0, + 1093, 1095, 0, 0,11148, 0,10876, 980, 454, 8421, + 7831, 0, 0, -233, 1100, 1102, 137, 984, 0, 0, + 0,11148, 0,11148, 1080, 0, 0, 0, 0, 41, +11012, 0, 0, 0, 0, 7950, 0, 1105, 0, 614, +11148, 999, 8404, 1001, 0, 0, 168, 0, 196, 0, + 0, 809, 905, 0, 168, 0, -62, 0, 0, 0, + 995, 0, 1027, 0, 0, 0, 0, 0, 0, 0, + 729, 0, 0, 0, 0, 0, 8126, 0, 0, 168, + 13, 964, 0, 9032, 0, 9032, 0, 1020, 9032, 0, + 0, 0, 584, 0, 0, 0, 1004, 821, 0, 0, +11420, 0, 0, 0, 1007, 4594, 0, 894, 0, 894, + 0, 894, 0, 0, 0, 0, 168, 1000, 980, 0, + 0, 0, -166, -164, 1003, 1008, 0, 0, 0, 0, + 0, 1010, 8404, 964, -149,11148, 0, 1009, 6872, 0, + 0, 0, 0, 0, 0, 1014, 0, 772, 0, 0, + 0, 0, 0, -172, 0, 1015, 809, 905, 0, 905, + 0, 964, 1016, 0, 0, 482, 0, 952, 998, 0, + 0, 0, 0, 0, 9032, 1042, 9032, 9032, 0,11148, + 0, 0, 936, 208, 746, 0, 0, 0, 0, 72, + 0, 0, 0, 1023, 0, 0, 0, 1013, 0, 0, + 0, 428, 0, 1021, 1135, 1140, 0, 0, 964, 1025, + 964, 1037, 0, 1035, 0, 0, 0, 0, 0,11148, + 0, 1046, -153, 0, -153, 0, 0, 0, 0, 0, + 0, 482, 0,11148, 8109, 0, 0, 1068, 0, 760, + 1045, 0, 1048, 0, 0,11420, 108, 144, 0, 1049, + 1049, 1049,10876, 1050, 0,11148, 0, 0, 0, 0, + 0, 0, 6872, -139, 0, 0, 7029, 0, 784, 6872, + 0, 1056, 0, 9032, 0, 0, 0, 0, 0,11148, + 0, 0, 215, 1055, 215, 7831, 1077, 1077, 1077, 0, + 0,11148, 0, 6872, 9189, 0, 0, 0, 7029, 0, + 0, 0, 0, 0, 1082, 9032,11148, 0, 215, 1060, + 0, 1017, 789, 0, 0, 1057, 0, 0, 36, 0, + 1018, 0, 1077, 0, 0, 0, 0, 0, 0, 0, + 1061, 945, 0, 7029, 0, 1089, 0, 1063, 1077, 1184, + 0, 1073, 215, 0, 7831, -105, 1075, 0, 1090, 1092, + 6872, 1076, 9032, 0, 0, 0, 0, 0, 1079, 1063, + 0, 0, 0,12124, 120, 215, 0, 0, 0, 1106, + 9032, 1085,11148, 0, 0, 1094, 0, 0, 1097, 0, + 0,13061, 0, 1098, 120, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 583,13061, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1099, 215, + 0, 120, 168, 0, 1106, 0, 0, 1091,12124,12290, + 0, 0, 20, 0, 0, 0,12322, 0, 0, 1101, + 0, 0, 0, 0, 7831, 7831, 265, 8126, 278, 419, + 1127, 0, -279, 946, 0, 1163, 0, 0, 1063, 0, + 0, 0, 1063, 0, 1052, 1054, 0, 7831, -151, 0, + 7831, 0, 1059, 1103, 0, -279, 0, -45,10251, 0, + 1104, 1062, 73, 506, 3845, 0, 0, 1063, 0, -279, + 0, 1111, 1065, 1110, 1108, 0, 1114, 1054, 1115, 144, + 1107, 1117, 0, 0, 1116, 1128, 0, 809, 0, 795, + 0, 0, 0, 1123, 0, -52, 0, 1121, 0, 0, + 1129, 0, 1125, 1131, 1136, 0, 1133, 0, 144, 144, + 0, 144, 1124, 1138, 0, 0, 0, 0, 1141, 128, + 0, 1142, 144, 1253, 1143, 144, 0, 20, 0, 8404, + 1109, 1144, 1133, 0, 1147, 1149, 130, 1154, 0, 0, + 144,10876, 1112, 1152, 1141, 0, 0,13061, 0, 215, + 215, 0, 1126, 1153, 1142, 0, 1173, 0,11148, 1130, + 1170, 1143, 0, 1175, 144, 0, -96, 0, 1168, 0, + 0, 0, 0, 0,13061, 0, 130, 130, 1145, 1178, + 0, -52, 0, 0, 256, 1157,13061, 0,13061, 0, + 0, 8404, 1171, 0, 0, 0, 1181, 1129, 0, 0, + 0, 1182, 0, 294, 0, 0, 0, 1077, 847, 1185, + 0, 0, 0, 0, 0, 0, 0, 0, 1241, 1295, + 0, 0, 0, 0, 0, 0, 1189, 1193, 8404, 0, + 0, 0, 0, 130, 526, 526, 0, 1077, 0, 0, + 0, 55, 55, 0, 0, 0, 0, 0, 0, 0, +10468,10468, 0, 0, 0, 0, 0, 1197, 1194, 1195, + 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, + protected static readonly short [] yyRindex = { 1410, + 0, 0, 7186, 1410, 0, 0, 0, 1568, 0, 0, + 1513, 1341, 0, 0, 0, 0, 0, 1513, 0, 0, + 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1569, 0, 0, 1569, 0, 0, 1568, + 3215, 1788, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1203, 0, 0, 0, 0, 0, 0, 0, 0, + 8735, 0, 1196, 0, 0, 0, 1196, 0, 0, 0, + 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, + 0, 0, 153, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 4587, 0, 0, 0, 0, + 0, 0, 286, 4680, 1796, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 4836, 4904, + 5144, 5348, 5688, 5892, 6028, 6164, 6300, 6436, 1187, 2889, + 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 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, 199, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 3258, 0, + 512, 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, 1533, 136, 0, 0, 0, 0, 0, 0, - 0, 3372, 355, 3415, 0, 0, 0, 0, 0, 0, + 0, 0, 1569, 237, 0, 0, 0, 0, 0, 0, + 0, 3338, 320, 3381, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 3695, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3633, 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, 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, 1205, 0, 0, 0, 0, 0, + 0, 3633, 1202, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2421, + 0, 2931, 420, 2551, 0, 0, 0, 2681, 2551, 0, + 0, 0, 0, 0, 1203, 0, 0, 0, 152, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1199, 2785, 0, 0, 1196, 0, 3633, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 146, 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, 0, 1605, 0, 0, 0, 0, 0, 0, 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, 3913, 0, 0, 0, 0, 0, + 0, 0, 3424, 3467, 0, 0, 0, 0, 2275, 1569, + 1569, 0, -10, 0, 7517, 1569, 1595, 0, 0, 245, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 453,11977, 0, + 0, 0, 0, 3633, 0, 0, 0, 0, 0, 0, + 0, 0,12366, 0, 0, 0, 0, 0, 0, 0, + 711, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 604, 693, 0, 0, 1228, 0, 0, 0, 0, 0, + 165, 0, 0, 4110, 1225, 0, 0, 0, 670, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1982, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, - 5269, 5373, 5509, 5577, 5713, 5781, 5849, 5917, 6053, 6121, - 6257, 6393, 6529, 6665, 1918, 0, 0, 563, 0, 0, + 0, 0, 0, 1199, 0, 0, 6555, 0, 176, 0, + 0, 0, 0, 0, 0, 9346, 0, 0, 0, 0, + 0, 0, 5, 802, 0, 0, 0, 1227, 0, 0, + 0, 0, 1202, 0, 0, 0, 3633, 0, 3633, 0, + 4269, 0, 0, 0, 0, -191, 0, 0, 0, 0, + 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, + 5008, 5076, 5212, 5280, 5416, 5484, 5552, 5620, 5756, 5824, + 5960, 6096, 6232, 6368, 6492, 0, 0, 675, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3913, 0, 0, 0, 0, 2275, 0, 0, 0, 0, + 1183, 9694, 0, 0, 0, 8892, 0, 0, 755, 0, + 0, 0, 0, 0, 0, 683, 698, 0, 0, 1230, + 0, 0, 0, 0, 1236, 0, 0, 0, 0, 0, + 0,11556, 0, 0, 0, 758, 0, 0, 0, 9049, +12442, 0, 0, 759, 766, 796, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 722, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1238, 0, 0, 0, 3699, + 0, 0, 177, 0, 98, 3792, 0, 0, 0, 0, + 0, 1232, 0, 0, 0, 0, 0, 1239, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -51, 676, 0, + 0, 0, 0, 0, 1237, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9346, 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, 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, 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, 567, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -181, 0, 472, 0, 0, 0, 0, 0, + 0, 0, 0, -10, 0, 0, 0, 0, 9049, 7674, + 0, 1240, 0, 700, 0, 0, 0, 0, 1244, 0, + 1201, 1206, 0, 0, 0, 0, 0, 1245, 9206, 0, + 0, 0, 0,12474, 0, 0, 0, 798, 0, 0, + 0, 0, 0, 0, 2149, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3951, + 0, 4428, 1246, 0, 0, 0, 1243, 0, 0, 0, + 0, 333, 0, 0, 0, 0, 798, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 657, 0, 0, 0, 0, 0, 0, 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, + 807, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1247, 0, + 0, 0, 0, 0, 814, 820, 0, 0, 0, 0, + 0, 0, 0, 1248, 608, 1250, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4110, 0, 0, + 0, 0, 0, 1249, 0, 0, 333, 0, 0, 846, + 0, 1248, 0, 0, 0, 9346, 0, 643, 654, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1230, 9540, 0, 0, 0, 0, 0,12605, 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, 630, 0, 737, 0, 0, 0, 0, 1255, 0, + 736, 1252, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1261, 0, 7343, 0, 0, 0, 0, 0, + 0, 9346, 0, 0, 0, 0, 0, 0, 0, -154, + 484, 0, 0, 0, 0, 0,12681,12366, 0, 218, + 218, 218, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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,12724, 0, -285, 0, 1263, 1263, 1263, 0, + 0, 0, 0, 0, 1259, 0, 0, 0, -182, 0, + 0, 0, 0, 0, 0, 0, 0, 0,12767, 0, + 0, 0, 9997, 0, 0, 1264, 0, 0, 369, 0, + 0, 0, 533, 0, 0, 0, 0, 0, 0, 0, + 0, 1262, 0, 1267, 0, 0, 0, 3172, 1260, 537, + 0, 0, -269, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3089, + 0, 0, 0, 0, 9799,10083, 0, 0, 0, 642, + 0, 0, 0, 0, 0, 0, 0, 0, 478, 0, + 0,12148, 0, 0, 9898, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,12216, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0,10177, + 0, 9799, 0, 0, 642, 0, 0, 0, 0, 453, + 0, 0, 0, 0, 0, 0, 453, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1096, + 457, 0,10219, 0, 0, 0, 4810, 0, 3089, 0, + 0, 0, 3089, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 271, 0, 1272, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3089, 0, 543, + 0, 494, 0, 0, 0, 0, 0, 0, 0,12366, + 819, 0, 0, 0, 0, 0, 0, 1235, 0, 516, + 0, 0, 0, 0, 0, 0, 0, 824, 0, 0, + 0, 0, 0, 0, 0, 0, 1265, 0,12366,12366, + 0,12398, 0, 0, 0, 0, 0, 0, 1268,12991, + 0, 1269,12366,11692, 1270,12366, 0, 0, 0, 0, + 0, 0, 1271, 0, 0, 0,12961, 0, 0, 0, +12366, 0, 0, 0, 1273, 0, 0, 378, 0,12885, +12923, 0, 0, 0, 1278, 0, 0, 0, 0, 0, + 0, 1279, 0, 0,12366, 0, 664, 0, 825, 0, + 0, 0, 0, 0, 861, 0,12809,12847, 0, 0, + 0, 0, 0, 0, 0, 0, 1325, 0, 1393, 0, + 0, 0, 829, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 571, 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, 0, 556, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0,12961, 9534,11864, 0, 571, 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, + 1225, 1225, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, }; protected static readonly short [] yyGindex = { 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, 1607, 0, 0, 0, 2, -16, -180, -48, -43, + 0, 1647, 1655, 101, 0, 4, 0, 0, 0, 0, + 0,-1020, -693, -215, -482, 0, 0, 0, 0, 0, + -224, 0, 0, 0, 703, 0, 811, 0, 0, 0, + 0, 560, 563, -17, -226, 0, -46, 0, 393, 0, + 430, -573, -569, -553, -471, -469, -462, -444, -435, 0, +-1042,-1171, 0, 1, 0, 129, 0,-1095, 0, 0, + 0, -44, 220, 0, 0, 0, 258,-1073, 0, -273, + -293, 992, 0, 0, 0, -899, 212, 0, 0, -501, + 0, 0, 281, 0, 0, 249, 0, 0, 287, 0, + -579, -976, 0, 0, 0, 0, 0, 382, -13, 0, + 0, 815, 816, 822, 988, -528, 0, 0, -321, 823, + 377, 0,-1327, 0, 0, 0, 0, 0, 0, 0, + 0, 182, 0, 0, 0, 0, 0, 0, 0, 0, + 432, 0, 0, 0, 0, -335, 362, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 441, 0, -514, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 201, 0, + 0, 288, 0, 0, 283, 285, 210, 0, 0, 0, + 0, 0, 0, 0, 0, 511, 0, 0, 0, 0, + -39, 0, 552, -173, 0, 0, 364, 0, 421, 0, + 882, 0, 1204, -286, -265, -56, 947, 0, 524, 0, + -30, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, -256, 0, 367, 0, -333, 0, -773, 0, 0, + 0, 832, 0, -296, -126, 1012, 0, 917, 0, 1155, + 1368, 1053, 0, 0, 731, 1678, 0, 0, 0, 0, + 1028, 0, 0, 0, 0, 0, -506, 1416, 0, 0, + 0, 0, 0, 1190, 855, 845, 748, 852, 1356, 1358, + 1355, 1357, 1359, 0, 1360, 0, -611, 0, 0, 968, + 1207, -714, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -298, 0, 0, 0, 0, -458, 0, 585, + 0, 487, 0, 573, 0, 0, 0, 646, -534, -5, + -313, -3, 0, 1618, 0, 68, 0, 70, 74, 99, + 125, 142, 149, 156, 157, 163, 171, 0, -674, 0, + -7, 0, 0, 782, 0, 707, 0, 0, 0, 0, + 685, -322, 762, -863, 0, 803, -461, 0, 0, 0, + 0, 0, 0, 708, 0, 0, 701, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 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, + 0, 0, 634, 0, 0, 0, 0, 0, 0, 0, + 0, -27, 0, 1274, 0, 0, 0, 876, 0, 0, + 0, 0, 0, 0, -168, 0, 0, 0, 0, 0, + 1374, 1150, 0, 0, 0, 1376, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 517, 0, 0, 0, 0, + 0, 0, 0, 0, 636, 0, 0, 0, 0, 0, + 0, 64, 957, 0, 0, 0, 962, }; protected static readonly short [] yyTable = { 109, - 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, + 741, 189, 233, 111, 518, 18, 43, 234, 433, 472, + 690, 155, 521, 156, 494, 747, 451, 436, 577, 432, + 476, 292, 538, 192, 786, 562, 115, 319, 257, 712, + 406, 514, 576, 830, 831, 549, 601, 1028, 502, 1150, + 325, 330, 326, 331, 251, 337, 885, 794, 886, 311, + 800, 258, 1185, 1186, 904, 303, 364, 959, 372, 310, + 335, 14, 544, 356, 629, 312, 924, 314, 115, 782, + 1280, 673, 115, 363, 943, 371, 190, 340, 1033, 485, + 20, 683, 316, 1079, 160, 797, 161, 1287, 1, 1061, + 162, 1063, 259, 916, 818, 1080, 918, 674, 318, 717, + 487, 946, 1174, 1217, 1345, 791, 820, 985, 488, 528, + 229, 350, 403, 351, 1080, 163, 1157, 1002, 507, 1481, + 1482, 197, 508, 587, 404, 408, 755, 801, 1011, 675, + 288, 1144, 47, 588, 351, 231, 846, 510, 289, 109, + 233, 164, 476, 111, 639, 434, 290, 792, 47, 436, + 1223, 155, 197, 156, 440, 441, 349, 943, 165, 1473, + 1174, 489, 943, 486, 943, 166, 115, 943, 943, 660, + 943, 943, 167, 168, 196, 816, 1514, 1216, 925, 169, + 629, 436, 629, 450, 946, 797, 586, 170, 434, 946, + 2, 946, 943, 1021, 946, 946, 761, 946, 946, 1234, + 477, 291, 336, 1387, 350, 1033, 290, 935, 872, 472, + 1353, 481, 260, 819, 735, 720, 482, 451, 577, 946, + 739, 895, 887, 15, 160, 290, 161, 351, 448, 475, + 162, 821, 576, 676, 480, 1158, 352, 629, 191, 797, + 577, 352, 492, 684, 6, 562, 1455, 943, 511, 1081, + 512, 1062, 249, 1064, 257, 163, 3, 4, 5, 6, + 366, 291, 524, 537, 257, 657, 1346, 541, 1081, 1224, + 493, 562, 546, 1479, 946, 497, 499, 490, 1474, 543, + 291, 164, 231, 47, 548, 1489, 442, 1490, 1336, 545, + 525, 1204, 1337, 817, 115, 47, 899, 533, 165, 535, + 691, 250, 534, 497, 513, 166, 568, 16, 722, 536, + 1523, 1093, 167, 168, 959, 551, 552, 1365, 993, 169, + 359, 231, 477, 477, 1076, 1354, 115, 170, 1388, 577, + 584, 721, 1034, 561, 1036, 563, 806, 1039, 1451, 896, + 583, 983, 619, 620, 847, 387, 899, 750, 115, 1103, + 761, 475, 598, 959, 54, 605, 606, 607, 608, 609, + 610, 611, 612, 613, 614, 615, 359, 366, 641, 643, + 642, 644, 647, 1375, 366, 1241, 366, 1131, 366, 249, + 1030, 388, 1500, 1417, 233, 1444, 94, 637, 1031, 434, + 767, 770, 991, 447, 661, 1310, 357, 1359, 1319, 698, + 436, 1012, 1405, 1406, 844, 1408, 1019, 47, 1000, 1205, + 877, 783, 1520, 802, 901, 804, 1427, 805, 746, 1434, + 997, 94, 366, 1096, 723, 1098, 1099, 261, 250, 2, + 1524, 285, 286, 287, 1450, 293, 294, 472, 655, 701, + 307, 308, 20, 710, 358, 718, 845, 315, 1156, 317, + 807, 321, 677, 564, 694, 1163, 333, 334, 1472, 577, + 900, 389, 390, 751, 901, 959, 746, 476, 477, 502, + 708, 959, 784, 576, 686, 349, 472, 931, 687, 1188, + 370, 892, 839, 711, 699, 760, 42, 48, 231, 769, + 1360, 1068, 352, 349, 813, 737, 231, 598, 231, 745, + 115, 6, 436, 658, 659, 359, 768, 771, 992, 671, + 565, 1088, 231, 1089, 752, 754, 642, 453, 1486, 687, + 1317, 642, 1165, 350, 772, 642, 342, 746, 793, 774, + 290, 891, 441, 1320, 577, 759, 1228, 290, 860, 688, + 642, 350, 893, 688, 442, 454, 351, 981, 199, 1496, + 349, 814, 787, 561, 1196, 563, 661, 1497, 290, 741, + 352, 734, 861, 437, 351, 741, 438, 642, 115, 1318, + 1487, 194, 413, 976, 453, 352, 808, 808, 352, 561, + 687, 563, 1321, 231, 661, 291, 642, 413, 1104, 862, + 933, 642, 912, 441, 115, 827, 642, 829, 350, 735, + 642, 1230, 454, 352, 688, 442, 837, 352, 897, 352, + 352, 352, 352, 1017, 741, 642, 734, 352, 1498, 1275, + 315, 351, 824, 370, 786, 411, 863, 824, 824, 649, + 833, 200, 245, 864, 1007, 352, 246, 342, 194, 194, + 642, 342, 642, 337, 115, 94, 115, 477, 330, 249, + 521, 115, 1261, 351, 330, 414, 1262, 397, 398, 194, + 415, 642, 416, 515, 879, 417, 418, 803, 419, 420, + 414, 1069, 1263, 391, 392, 415, 475, 416, 412, 532, + 417, 418, 883, 419, 420, 342, 247, 859, 249, 337, + 365, 497, 642, 712, 244, 257, 1261, 1072, 250, 1069, + 1262, 337, 541, 330, 337, 337, 745, 662, 907, 366, + 367, 737, 414, 745, 739, 913, 1263, 415, 337, 416, + 884, 350, 417, 418, 640, 419, 420, 937, 641, 368, + 115, 921, 115, 248, 1049, 662, 1341, 250, 657, 939, + 369, 908, 1243, 1260, 351, 421, 926, 927, 640, 1355, + 194, 194, 641, 745, 1264, 919, 1265, 920, 352, 570, + 431, 869, 1243, 1266, 477, 922, 571, 787, 1373, 262, + 477, 352, 824, 589, 840, 640, 337, 115, 572, 641, + 115, 1267, 337, 590, 1041, 361, 841, 1260, 337, 1243, + 1268, 337, 337, 598, 437, 661, 1114, 838, 1264, 598, + 1265, 824, 650, 745, 318, 337, 1124, 1266, 1115, 225, + 937, 226, 194, 562, 318, 937, 668, 937, 724, 976, + 937, 937, 939, 937, 937, 1267, 984, 939, 350, 939, + 701, 435, 939, 939, 1268, 939, 939, 337, 194, 413, + 745, 350, 1153, 839, 668, 562, 527, 973, 94, 493, + 194, 351, 709, 668, 360, 677, 570, 965, 194, 528, + 1015, 361, 1018, 571, 351, 352, 998, 280, 1020, 280, + 690, 332, 94, 1001, 280, 572, 529, 362, 1187, 1049, + 562, 1361, 352, 1009, 337, 745, 352, 337, 337, 352, + 318, 352, 94, 1029, 753, 361, 352, 933, 1438, 665, + 937, 1215, 194, 693, 321, 194, 399, 694, 665, 342, + 321, 437, 939, 342, 477, 337, 342, 322, 342, 950, + 951, 1053, 414, 342, 318, 364, 824, 415, 824, 416, + 1058, 824, 417, 418, 757, 419, 420, 664, 194, 194, + 393, 394, 757, 1048, 1307, 225, 664, 228, 472, 1160, + 1161, 1307, 44, 451, 395, 396, 400, 342, 1284, 1277, + 1491, 677, 1169, 113, 401, 727, 194, 194, 1055, 728, + 1056, 501, 1057, 361, 337, 745, 337, 501, 497, 753, + 933, 753, 296, 753, 736, 933, 194, 933, 508, 909, + 933, 933, 402, 933, 933, 337, 337, 1511, 405, 168, + 194, 168, 318, 168, 439, 113, 1529, 1530, 115, 113, + 774, 521, 787, 443, 774, 337, 774, 824, 774, 824, + 824, 763, 1100, 337, 758, 763, 337, 763, 758, 763, + 270, 270, 758, 329, 329, 225, 364, 364, 364, 270, + 364, 364, 753, 364, 330, 364, 446, 330, 753, 473, + 753, 1107, 337, 337, 329, 337, 337, 56, 474, 477, + 502, 335, 493, 415, 701, 415, 502, 64, 64, 65, + 933, 64, 295, 65, 296, 880, 1132, 745, 787, 881, + 471, 231, 822, 762, 415, 415, 822, 364, 1048, 364, + 1143, 495, 364, 826, 233, 493, 1172, 826, 493, 434, + 1027, 1173, 817, 113, 415, 194, 181, 757, 181, 496, + 181, 757, 415, 1136, 1137, 415, 824, 1105, 976, 1106, + 233, 561, 1168, 563, 979, 434, 979, 194, 156, 436, + 156, 765, 115, 765, 493, 163, 115, 163, 517, 115, + 625, 626, 627, 628, 522, 329, 329, 542, 824, 1100, + 1160, 1161, 1352, 561, 1172, 563, 1201, 231, 337, 1173, + 384, 385, 386, 115, 337, 164, 1352, 164, 115, 890, + 337, 890, 362, 605, 337, 605, 1242, 1259, 67, 1238, + 67, 1173, 555, 187, 1383, 187, 1384, 337, 561, 157, + 563, 157, 120, 523, 120, 824, 1242, 285, 127, 285, + 127, 1173, 292, 115, 292, 526, 452, 329, 351, 443, + 1501, 1502, 547, 824, 581, 493, 194, 525, 525, 337, + 115, 1259, 351, 1242, 642, 642, 1291, 591, 1173, 453, + 653, 113, 582, 329, 1238, 623, 624, 194, 355, 1148, + 1149, 672, 454, 621, 622, 329, 692, 456, 629, 630, + 1315, 1316, 457, 329, 458, 459, 460, 461, 656, 695, + 719, 697, 462, 113, 725, 726, 463, 749, 773, 1312, + 1325, 766, 775, 1344, 776, 777, 1347, 778, 464, 796, + 795, 465, 338, 466, 798, 113, 341, 342, 343, 344, + 345, 346, 347, 348, 811, 799, 812, 329, 826, 828, + 329, 832, 848, 849, 194, 437, 701, 467, 851, 852, + 855, 42, 867, 873, 874, 196, 875, 876, 882, 902, + 1362, 898, 817, 903, 905, 910, 914, 194, 915, 929, + 923, 945, 947, 329, 329, 701, 701, 940, 701, 952, + 34, 1418, 194, 954, 961, 960, 194, 964, 969, 701, + 971, 966, 701, 977, 963, 989, 359, 990, 1445, 999, + 1006, 329, 329, 1326, 993, 511, 1024, 701, 1013, 1025, + 1038, 1457, 1459, 1042, 1094, 1059, 1065, 1051, 1095, 359, + 1075, 1066, 745, 1077, 1312, 1067, 1087, 1091, 1097, 1109, + 1117, 701, 359, 1113, 493, 1118, 1119, 359, 1445, 1445, + 232, 1116, 359, 194, 359, 359, 359, 359, 1121, 33, + 1122, 1467, 359, 1125, 1135, 1181, 359, 1139, 1138, 1151, + 359, 194, 194, 1146, 373, 1164, 1171, 1198, 359, 1195, + 1203, 359, 1211, 359, 1200, 1206, 1214, 113, 1215, 1218, + 1220, 1225, 585, 1229, 745, 374, 375, 376, 377, 378, + 379, 380, 381, 382, 383, 1445, 1226, 359, 1227, 1233, + 1276, 1273, 1293, 1322, 1278, 1281, 1288, 1335, 1314, 1339, + 1279, 1340, 1357, 1350, 477, 477, 1349, 1367, 329, 1358, + 1369, 745, 1360, 1370, 1372, 1374, 1380, 1376, 194, 1378, + 338, 1516, 1516, 1386, 1381, 1397, 1409, 1394, 1525, 1525, + 329, 1391, 1398, 598, 598, 113, 1401, 1399, 1428, 194, + 1410, 1483, 31, 359, 1413, 1423, 1430, 194, 1442, 1440, + 1443, 550, 329, 1449, 1488, 585, 1439, 1453, 1464, 1452, + 585, 113, 585, 585, 585, 585, 585, 585, 585, 585, + 585, 585, 585, 1463, 1466, 1469, 1471, 1468, 1477, 1484, + 1493, 1492, 1503, 1495, 585, 1487, 585, 1486, 585, 1509, + 585, 585, 585, 1510, 1531, 1532, 1533, 9, 975, 538, + 606, 860, 496, 616, 617, 618, 585, 861, 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, + 550, 550, 550, 550, 967, 497, 453, 34, 607, 29, + 676, 34, 21, 454, 506, 495, 29, 337, 521, 30, + 313, 329, 34, 30, 868, 585, 791, 34, 208, 759, + 767, 34, 768, 96, 34, 827, 760, 828, 792, 664, + 829, 317, 329, 831, 687, 664, 34, 34, 344, 642, + 123, 34, 34, 105, 288, 130, 124, 34, 106, 34, + 34, 34, 34, 289, 131, 642, 230, 34, 53, 21, + 1043, 34, 959, 34, 1290, 1141, 33, 113, 1142, 113, + 33, 1485, 1454, 34, 1282, 34, 34, 857, 34, 1494, + 1470, 33, 34, 1441, 1436, 1329, 33, 870, 986, 987, + 33, 982, 1342, 33, 1527, 988, 1364, 194, 1286, 329, + 550, 1289, 34, 1460, 1458, 33, 33, 1519, 34, 34, + 33, 33, 1465, 1221, 113, 1518, 33, 113, 33, 33, + 33, 33, 329, 1385, 1333, 955, 33, 1005, 1222, 24, + 33, 25, 33, 934, 26, 763, 593, 329, 1078, 27, + 890, 329, 33, 28, 33, 33, 866, 33, 298, 810, + 553, 33, 30, 888, 631, 633, 194, 632, 634, 32, + 780, 635, 928, 636, 33, 1294, 1212, 1208, 34, 31, + 797, 33, 1159, 31, 407, 194, 1071, 1120, 33, 1133, + 36, 1060, 37, 1090, 31, 1128, 38, 32, 1192, 31, + 1126, 1292, 1022, 31, 39, 40, 31, 651, 41, 652, + 836, 322, 1197, 756, 0, 0, 957, 0, 31, 31, + 956, 0, 0, 31, 31, 0, 329, 329, 0, 31, + 0, 31, 31, 31, 31, 0, 0, 290, 0, 31, + 194, 194, 0, 31, 0, 31, 0, 0, 194, 0, + 0, 0, 0, 0, 0, 31, 194, 194, 31, 194, + 31, 0, 0, 0, 31, 1332, 0, 0, 0, 0, + 506, 0, 0, 0, 0, 506, 506, 1332, 0, 194, + 0, 0, 194, 0, 31, 0, 0, 0, 0, 0, + 1332, 31, 323, 329, 0, 0, 0, 0, 506, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1332, + 0, 506, 506, 0, 0, 0, 506, 0, 0, 506, + 0, 506, 329, 506, 506, 506, 506, 0, 0, 0, + 0, 506, 0, 0, 0, 506, 0, 0, 0, 506, + 0, 0, 0, 0, 0, 0, 0, 506, 0, 0, + 506, 0, 506, 506, 0, 113, 0, 0, 506, 0, + 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, + 506, 0, 0, 0, 0, 0, 506, 506, 0, 0, + 0, 506, 506, 0, 506, 506, 506, 506, 506, 506, + 506, 862, 506, 506, 0, 506, 506, 506, 506, 506, + 506, 506, 506, 506, 506, 0, 506, 506, 506, 506, + 506, 506, 506, 506, 506, 506, 506, 506, 506, 506, + 506, 506, 506, 506, 506, 506, 506, 506, 0, 0, + 506, 0, 506, 0, 506, 0, 0, 506, 0, 0, + 0, 0, 0, 506, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 32, 0, 0, 0, 32, 0, + 0, 393, 0, 0, 0, 0, 0, 393, 0, 32, + 0, 0, 0, 0, 32, 0, 0, 0, 32, 113, + 0, 32, 0, 113, 0, 0, 113, 0, 0, 0, + 0, 0, 0, 32, 32, 550, 0, 0, 32, 32, + 0, 0, 329, 393, 32, 0, 32, 32, 32, 32, + 113, 0, 0, 0, 32, 113, 0, 0, 32, 0, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 32, 0, 0, 32, 0, 32, 0, 0, 0, 32, 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, + 113, 0, 0, 0, 0, 0, 0, 0, 785, 32, + 0, 329, 0, 0, 0, 32, 32, 113, 330, 0, + 0, 0, 0, 393, 330, 0, 393, 393, 393, 393, + 329, 393, 0, 393, 393, 0, 393, 393, 393, 393, + 393, 0, 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, + 0, 0, 0, 330, 0, 393, 0, 0, 393, 0, + 0, 0, 0, 0, 393, 329, 329, 0, 0, 0, + 0, 0, 0, 329, 0, 0, 0, 862, 862, 0, + 0, 329, 329, 0, 329, 862, 862, 862, 862, 862, + 0, 862, 862, 0, 862, 862, 862, 862, 862, 862, + 862, 862, 0, 0, 329, 0, 862, 329, 862, 862, + 862, 862, 862, 862, 337, 0, 862, 0, 0, 0, + 862, 862, 0, 862, 862, 862, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 862, 0, 862, 0, 862, + 862, 0, 0, 862, 0, 862, 862, 862, 862, 862, + 862, 862, 862, 862, 862, 862, 862, 0, 862, 0, + 0, 862, 862, 0, 0, 862, 862, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, + 862, 862, 862, 862, 862, 0, 0, 0, 862, 862, + 0, 0, 862, 0, 0, 0, 0, 862, 862, 862, + 862, 862, 0, 0, 0, 862, 0, 862, 0, 0, + 0, 0, 0, 862, 862, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 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, 862, 862, + 862, 862, 0, 862, 785, 785, 0, 0, 0, 0, + 862, 0, 785, 785, 785, 785, 785, 0, 785, 785, + 742, 785, 785, 785, 785, 785, 785, 785, 0, 0, + 0, 0, 0, 785, 0, 785, 785, 785, 785, 785, + 785, 0, 0, 785, 0, 0, 0, 785, 785, 0, + 785, 785, 785, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 785, 0, 785, 0, 785, 785, 0, 0, + 785, 0, 785, 785, 785, 785, 785, 785, 785, 785, + 785, 785, 785, 785, 0, 785, 0, 0, 785, 785, + 0, 0, 785, 785, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 785, 785, 785, + 785, 785, 0, 0, 0, 785, 785, 0, 0, 785, + 0, 0, 0, 0, 785, 785, 785, 785, 785, 0, + 337, 0, 785, 0, 785, 337, 337, 0, 0, 0, + 785, 785, 0, 0, 0, 0, 0, 0, 0, 0, + 330, 0, 0, 0, 0, 0, 0, 0, 337, 0, + 0, 0, 0, 0, 0, 785, 785, 785, 785, 0, + 785, 337, 337, 0, 0, 0, 337, 785, 0, 337, + 0, 337, 0, 337, 337, 337, 337, 0, 0, 0, + 0, 337, 0, 0, 0, 337, 0, 0, 0, 337, + 0, 0, 0, 0, 0, 0, 0, 337, 0, 0, + 337, 0, 337, 337, 0, 0, 0, 0, 337, 0, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 0, 0, 0, 0, 337, 337, 0, 0, + 0, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 0, 337, 337, 0, 0, 337, 337, 337, 337, + 337, 0, 0, 337, 337, 0, 0, 0, 337, 337, + 337, 337, 337, 337, 337, 337, 742, 0, 0, 0, + 367, 742, 742, 0, 0, 0, 0, 337, 0, 0, + 337, 0, 337, 0, 337, 0, 0, 337, 0, 0, + 0, 0, 0, 337, 742, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 742, 742, 0, + 0, 0, 742, 0, 0, 742, 0, 742, 0, 742, + 742, 742, 742, 0, 0, 0, 0, 742, 0, 0, + 0, 742, 0, 0, 0, 742, 0, 0, 0, 0, + 0, 0, 0, 742, 0, 0, 742, 0, 742, 742, + 0, 0, 0, 0, 742, 0, 742, 742, 742, 742, + 742, 742, 742, 742, 742, 742, 742, 0, 0, 0, + 0, 0, 742, 742, 337, 0, 0, 742, 742, 742, + 742, 742, 742, 0, 742, 742, 742, 0, 742, 742, + 0, 0, 742, 742, 742, 742, 330, 0, 0, 742, + 742, 330, 330, 0, 742, 742, 742, 742, 742, 742, + 742, 742, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 742, 330, 0, 742, 0, 742, 0, + 742, 0, 0, 742, 0, 0, 0, 330, 330, 742, + 0, 0, 330, 0, 0, 330, 0, 330, 0, 330, + 330, 330, 330, 0, 0, 0, 0, 330, 0, 0, + 0, 330, 0, 0, 0, 330, 0, 0, 0, 0, + 0, 0, 0, 330, 0, 0, 330, 0, 330, 330, + 0, 0, 0, 0, 330, 0, 330, 330, 330, 330, + 330, 330, 330, 330, 330, 330, 330, 0, 0, 0, + 0, 0, 330, 330, 0, 0, 0, 330, 330, 330, + 330, 330, 330, 0, 330, 330, 330, 0, 330, 330, + 362, 0, 330, 330, 330, 330, 367, 0, 0, 330, + 330, 367, 367, 0, 330, 330, 330, 330, 330, 330, + 330, 330, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 330, 367, 0, 330, 0, 330, 0, + 330, 0, 0, 330, 0, 0, 0, 367, 367, 330, + 0, 0, 367, 0, 0, 367, 0, 367, 0, 367, + 367, 367, 367, 0, 0, 0, 0, 367, 0, 0, + 0, 367, 0, 0, 0, 367, 0, 0, 0, 0, + 0, 0, 0, 367, 0, 0, 367, 0, 367, 367, + 0, 0, 0, 0, 367, 0, 367, 367, 367, 367, + 367, 367, 367, 367, 367, 367, 367, 0, 0, 0, + 337, 0, 367, 367, 0, 0, 337, 367, 367, 0, + 367, 367, 367, 0, 367, 367, 367, 0, 367, 367, + 0, 0, 367, 367, 367, 367, 0, 0, 0, 367, + 367, 0, 0, 0, 367, 367, 367, 367, 367, 367, + 367, 367, 337, 0, 0, 0, 0, 0, 27, 0, + 0, 0, 0, 367, 0, 0, 367, 0, 367, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 367, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 337, 0, 0, 0, 0, 337, 0, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 0, 0, 587, 0, 0, 337, 0, 0, + 0, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 0, 337, 337, 0, 0, 337, 337, 337, 337, + 337, 27, 0, 337, 337, 0, 0, 0, 337, 337, + 337, 337, 337, 337, 337, 337, 362, 0, 0, 0, + 0, 0, 362, 0, 0, 0, 0, 337, 0, 0, + 337, 0, 337, 0, 337, 0, 0, 337, 0, 0, + 0, 0, 0, 337, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 587, 362, 0, + 0, 0, 587, 0, 587, 587, 587, 587, 587, 587, + 587, 587, 587, 587, 587, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 587, 957, 587, 0, + 587, 0, 587, 587, 587, 0, 0, 0, 0, 362, + 0, 0, 0, 0, 362, 0, 362, 362, 362, 362, + 362, 362, 362, 362, 362, 362, 362, 0, 0, 0, + 0, 0, 0, 362, 0, 0, 0, 362, 362, 0, + 362, 362, 362, 0, 362, 362, 362, 0, 362, 362, + 0, 0, 362, 362, 362, 362, 0, 587, 0, 362, + 362, 0, 0, 0, 362, 362, 362, 362, 362, 362, + 362, 362, 0, 0, 0, 0, 0, 47, 0, 0, + 0, 0, 0, 362, 27, 27, 362, 0, 362, 27, + 0, 0, 0, 27, 0, 27, 0, 0, 27, 362, + 27, 27, 0, 27, 0, 27, 0, 27, 0, 27, + 27, 27, 27, 0, 0, 27, 27, 0, 0, 0, + 7, 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, 0, 0, 0, 0, 0, 27, 27, + 0, 27, 27, 958, 27, 27, 27, 0, 27, 0, + 27, 0, 27, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 0, 0, 0, 0, 27, 0, + 27, 0, 27, 0, 0, 27, 27, 27, 0, 0, + 0, 0, 0, 0, 0, 27, 48, 27, 27, 0, + 0, 5, 27, 27, 0, 47, 0, 0, 27, 0, + 27, 27, 27, 27, 0, 0, 47, 0, 27, 0, + 0, 47, 27, 0, 27, 47, 0, 0, 47, 0, + 0, 0, 0, 0, 27, 0, 27, 27, 0, 27, + 47, 47, 0, 27, 957, 47, 47, 0, 47, 0, + 0, 47, 0, 47, 47, 47, 47, 0, 0, 47, + 0, 47, 0, 27, 47, 47, 0, 47, 47, 27, + 27, 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, 0, 47, 0, + 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 47, 0, 0, 47, 47, 47, 0, 0, 47, 47, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, + 0, 0, 0, 0, 47, 0, 0, 0, 47, 47, + 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 47, 47, 0, 0, 7, 47, 47, + 0, 48, 0, 0, 47, 0, 47, 47, 47, 47, + 0, 0, 48, 0, 47, 0, 0, 48, 47, 0, + 47, 48, 0, 0, 48, 0, 0, 0, 0, 0, + 47, 0, 0, 47, 0, 47, 48, 48, 0, 47, + 958, 48, 48, 0, 47, 0, 0, 48, 0, 48, + 48, 48, 48, 0, 0, 47, 0, 48, 0, 47, + 47, 48, 0, 48, 47, 0, 0, 47, 0, 0, + 0, 0, 0, 48, 0, 0, 48, 0, 48, 47, + 47, 0, 48, 48, 47, 47, 0, 48, 0, 0, + 47, 0, 47, 47, 47, 47, 0, 0, 48, 0, + 47, 0, 48, 48, 47, 0, 47, 48, 0, 0, + 48, 0, 0, 0, 0, 0, 47, 0, 0, 47, + 0, 47, 48, 48, 0, 47, 0, 48, 48, 0, + 0, 0, 0, 48, 0, 48, 48, 48, 48, 0, + 0, 0, 0, 48, 0, 47, 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, 337, 87, + 88, 0, 0, 0, 337, 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, + 337, 102, 0, 0, 0, 0, 0, 103, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 783, 783, 783, 783, 783, 0, 0, - 0, 783, 783, 0, 0, 783, 0, 0, 0, 0, - 783, 783, 783, 783, 783, 0, 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, 337, 0, 0, 0, 0, 0, + 337, 0, 105, 106, 107, 108, 0, 0, 0, 0, + 0, 337, 0, 0, 196, 0, 337, 0, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 0, 0, 0, 0, 0, 337, 337, 0, 0, 0, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 0, + 337, 337, 0, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 0, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 0, 508, 0, 0, + 337, 0, 337, 508, 0, 337, 0, 0, 0, 0, + 0, 337, 0, 0, 0, 0, 337, 0, 0, 337, + 0, 337, 337, 0, 0, 0, 337, 337, 0, 0, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 508, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, 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, - 48, 48, 0, 47, 0, 48, 48, 0, 0, 0, - 0, 48, 0, 48, 48, 48, 48, 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, + 337, 337, 0, 0, 0, 0, 0, 0, 337, 0, + 0, 337, 0, 0, 0, 0, 0, 337, 0, 201, + 508, 0, 0, 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, 508, 508, + 508, 508, 508, 508, 508, 508, 508, 508, 949, 508, + 508, 202, 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, 504, 0, 0, 0, + 0, 508, 504, 0, 0, 0, 0, 0, 0, 0, + 508, 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, 504, 0, + 0, 949, 0, 0, 0, 0, 949, 0, 949, 949, + 949, 949, 949, 949, 949, 949, 949, 949, 0, 0, 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, + 949, 0, 949, 0, 949, 0, 949, 949, 949, 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, 0, + 504, 504, 504, 504, 504, 504, 504, 0, 504, 504, + 0, 504, 504, 504, 504, 504, 504, 504, 504, 504, + 504, 949, 504, 504, 504, 504, 504, 504, 504, 504, + 504, 504, 504, 504, 504, 504, 504, 504, 504, 504, + 504, 504, 504, 504, 0, 512, 757, 0, 0, 0, + 504, 512, 0, 504, 0, 24, 0, 25, 0, 504, 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, + 0, 0, 0, 0, 0, 32, 0, 512, 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, 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, - 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, 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, - 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, 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, - 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, - 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, 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, 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, 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, + 39, 40, 0, 0, 41, 0, 0, 758, 512, 0, + 0, 0, 0, 512, 0, 512, 512, 512, 512, 512, + 512, 512, 512, 512, 512, 512, 0, 0, 0, 0, + 0, 0, 0, 290, 0, 0, 0, 512, 0, 512, + 512, 512, 512, 512, 512, 512, 0, 512, 512, 0, + 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, + 0, 512, 512, 512, 512, 512, 512, 512, 512, 512, + 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, + 512, 512, 512, 0, 337, 567, 0, 0, 323, 512, + 337, 0, 512, 0, 24, 0, 25, 0, 512, 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, 337, 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, 337, 0, 0, + 0, 0, 337, 0, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 337, 0, 337, 337, + 337, 337, 337, 337, 337, 0, 337, 337, 0, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 0, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 0, 437, 906, 0, 0, 355, 337, 437, + 0, 337, 0, 24, 0, 25, 0, 337, 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, 437, 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, 437, 0, 0, 0, + 0, 437, 0, 437, 437, 437, 437, 437, 437, 437, + 437, 437, 437, 437, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 437, 0, 437, 437, 437, + 437, 437, 437, 437, 0, 437, 437, 0, 437, 437, + 437, 437, 437, 437, 437, 437, 437, 437, 0, 437, + 437, 437, 437, 437, 437, 437, 437, 437, 437, 437, + 437, 437, 437, 437, 437, 437, 437, 437, 437, 437, + 437, 0, 337, 0, 0, 0, 355, 437, 337, 1052, + 437, 0, 745, 0, 0, 0, 437, 0, 24, 0, + 25, 0, 0, 26, 0, 0, 0, 0, 27, 0, + 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, + 0, 30, 0, 0, 337, 0, 0, 0, 32, 0, + 0, 0, 0, 33, 0, 0, 0, 34, 0, 0, + 745, 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, 0, 0, 0, 0, 543, 0, 0, 0, 0, + 0, 543, 0, 337, 0, 0, 0, 0, 0, 337, + 0, 0, 0, 0, 337, 337, 337, 337, 337, 337, + 337, 745, 337, 0, 337, 337, 0, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 543, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 0, 0, 0, 0, 337, 0, 337, 0, 0, 337, + 0, 355, 0, 0, 0, 337, 0, 0, 543, 0, + 0, 0, 0, 543, 0, 543, 543, 543, 543, 543, + 543, 543, 543, 543, 543, 543, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 543, 0, 543, + 0, 543, 0, 543, 543, 543, 0, 543, 543, 0, + 543, 543, 543, 543, 543, 543, 543, 543, 543, 543, + 358, 0, 0, 543, 543, 543, 543, 543, 543, 543, + 543, 543, 543, 543, 543, 543, 543, 543, 543, 543, + 543, 555, 543, 358, 0, 0, 0, 555, 0, 0, + 0, 0, 0, 0, 0, 0, 358, 0, 543, 0, + 0, 358, 0, 0, 231, 0, 358, 0, 358, 358, + 358, 358, 0, 0, 0, 0, 358, 0, 0, 0, + 358, 0, 0, 555, 358, 0, 0, 0, 0, 0, + 0, 0, 358, 0, 0, 358, 0, 358, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 559, + 0, 0, 0, 0, 0, 559, 0, 0, 0, 0, + 0, 358, 0, 0, 555, 0, 0, 0, 0, 555, + 0, 555, 555, 555, 555, 555, 555, 555, 555, 555, + 555, 555, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 559, 0, 555, 0, 555, 0, 555, 0, 555, + 555, 555, 0, 555, 555, 0, 0, 555, 555, 555, + 555, 555, 555, 555, 555, 555, 0, 358, 0, 555, + 555, 555, 555, 555, 555, 555, 555, 0, 0, 0, + 0, 0, 559, 0, 0, 0, 0, 559, 555, 559, + 559, 559, 559, 559, 559, 559, 559, 559, 559, 559, + 0, 0, 0, 560, 555, 0, 0, 0, 0, 560, + 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, 560, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 559, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 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, 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, 561, 559, 0, 0, 0, 0, 561, 0, 0, + 0, 0, 0, 0, 0, 0, 560, 0, 0, 0, + 0, 560, 0, 560, 560, 560, 560, 560, 560, 560, + 560, 560, 560, 560, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 561, 0, 560, 0, 560, 0, 560, + 0, 560, 560, 560, 0, 560, 560, 0, 0, 560, + 560, 560, 560, 0, 0, 0, 560, 560, 0, 564, + 0, 560, 560, 560, 560, 560, 560, 560, 560, 0, + 0, 0, 0, 0, 561, 0, 0, 0, 0, 561, + 560, 561, 561, 561, 561, 561, 561, 561, 561, 561, + 561, 561, 0, 0, 0, 0, 560, 0, 0, 0, + 0, 0, 0, 561, 0, 561, 0, 561, 0, 561, + 561, 561, 0, 561, 561, 0, 0, 561, 561, 561, + 561, 0, 0, 0, 561, 561, 0, 565, 0, 561, + 561, 561, 561, 561, 561, 561, 561, 0, 0, 0, + 0, 0, 564, 0, 0, 0, 0, 564, 561, 564, + 564, 564, 564, 564, 564, 564, 564, 564, 564, 564, + 0, 0, 0, 0, 561, 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, 565, 565, 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, 566, 566, 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, 570, 570, 570, 570, 0, 0, 0, + 570, 570, 0, 572, 0, 0, 0, 570, 570, 570, + 570, 570, 570, 0, 0, 0, 0, 0, 571, 0, + 0, 0, 0, 571, 570, 571, 571, 571, 571, 571, + 571, 571, 571, 571, 571, 571, 0, 0, 0, 0, + 570, 0, 0, 0, 0, 0, 0, 571, 0, 571, + 0, 571, 0, 571, 571, 571, 0, 0, 0, 0, + 0, 571, 571, 571, 571, 0, 0, 0, 571, 571, + 0, 573, 0, 0, 0, 571, 571, 571, 571, 571, + 571, 0, 0, 0, 0, 0, 572, 0, 0, 0, + 0, 572, 571, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 0, 0, 0, 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, 573, 573, 573, 573, 0, 0, 0, + 0, 0, 574, 0, 0, 0, 0, 574, 573, 574, + 574, 574, 574, 574, 574, 574, 574, 574, 574, 574, + 0, 0, 0, 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, 574, 574, 574, 574, 0, 0, 0, 0, 0, + 575, 0, 0, 0, 0, 575, 574, 575, 575, 575, + 575, 575, 575, 575, 575, 575, 575, 575, 0, 0, + 0, 0, 574, 0, 0, 0, 0, 0, 0, 575, + 0, 575, 0, 575, 0, 575, 575, 575, 0, 0, + 0, 0, 0, 0, 0, 575, 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, 576, 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, 577, 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, 578, 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, 579, 0, + 0, 0, 0, 579, 0, 581, 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, 0, 0, 0, 0, 580, 0, 0, 0, + 0, 580, 0, 582, 0, 0, 0, 0, 0, 0, + 0, 580, 580, 0, 0, 0, 0, 0, 581, 0, + 0, 0, 0, 581, 580, 581, 581, 581, 581, 581, + 581, 581, 581, 581, 581, 581, 0, 0, 0, 0, + 580, 0, 0, 0, 0, 0, 0, 581, 0, 581, + 0, 581, 0, 581, 581, 581, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 581, + 0, 583, 0, 0, 0, 0, 0, 0, 0, 581, + 581, 0, 0, 0, 0, 0, 582, 0, 0, 0, + 0, 582, 581, 582, 582, 582, 582, 582, 582, 582, + 582, 582, 582, 582, 0, 0, 0, 0, 581, 0, + 0, 0, 0, 0, 0, 582, 0, 582, 0, 582, + 0, 582, 582, 582, 0, 0, 0, 584, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 582, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 582, 582, 0, + 0, 0, 0, 0, 583, 0, 0, 0, 0, 583, + 582, 583, 583, 583, 583, 583, 583, 583, 583, 583, + 583, 583, 0, 0, 0, 0, 582, 0, 0, 0, + 0, 0, 0, 583, 0, 583, 0, 583, 0, 583, + 583, 583, 0, 0, 0, 0, 337, 0, 0, 0, + 745, 0, 0, 0, 0, 583, 0, 0, 0, 0, + 584, 0, 0, 0, 0, 584, 583, 584, 584, 584, + 584, 584, 584, 584, 584, 584, 584, 584, 583, 0, + 0, 0, 337, 0, 0, 0, 0, 0, 0, 584, + 0, 584, 0, 584, 583, 584, 584, 584, 745, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 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, 584, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 584, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 584, 0, 0, 0, 0, 0, + 0, 337, 0, 0, 0, 0, 0, 337, 0, 0, + 584, 0, 337, 337, 0, 337, 0, 337, 0, 745, + 337, 0, 337, 337, 0, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 0, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 0, 0, + 55, 0, 337, 0, 337, 0, 0, 337, 56, 24, + 57, 25, 0, 337, 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, - 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, 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, 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, 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, 0, 0, 0, 0, 0, - 103, 104, 0, 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, - 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, 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, 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, + 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, 933, 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, 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, + 0, 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, 302, 0, 0, 0, 729, 1001, 0, 0, 95, - 0, 0, 0, 0, 0, 97, 98, 99, 100, 0, + 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, 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, 954, 0, 0, 0, 105, 557, 107, 108, 954, + 954, 954, 954, 0, 0, 954, 954, 0, 954, 954, + 954, 954, 954, 954, 954, 0, 0, 0, 0, 0, + 954, 0, 954, 954, 954, 954, 954, 954, 0, 0, + 954, 0, 0, 0, 954, 954, 0, 954, 954, 954, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 954, + 0, 954, 0, 954, 954, 0, 0, 954, 0, 954, + 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, + 954, 0, 954, 0, 0, 954, 954, 0, 0, 954, + 954, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 954, 954, 954, 954, 954, 0, + 0, 0, 954, 0, 0, 0, 954, 0, 0, 0, + 0, 954, 954, 954, 954, 954, 0, 0, 0, 954, + 0, 954, 0, 0, 0, 0, 0, 954, 954, 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, 796, 0, + 0, 0, 954, 954, 954, 954, 796, 796, 796, 796, + 0, 0, 796, 796, 0, 796, 796, 796, 796, 796, + 796, 796, 0, 0, 0, 0, 0, 796, 0, 796, + 796, 796, 796, 796, 796, 0, 0, 796, 0, 0, + 0, 796, 796, 0, 796, 796, 796, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 796, 0, 796, 0, + 796, 796, 0, 0, 796, 0, 796, 796, 796, 796, + 796, 796, 796, 796, 796, 796, 796, 796, 0, 796, + 0, 0, 796, 796, 0, 0, 796, 796, 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, 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, 796, 796, 796, 796, 796, 0, 0, 0, 796, + 0, 0, 0, 796, 0, 0, 0, 0, 796, 796, + 796, 796, 796, 0, 0, 0, 796, 0, 796, 0, + 0, 0, 0, 0, 796, 796, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 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, + 0, 0, 0, 0, 0, 743, 0, 0, 0, 796, + 796, 796, 796, 56, 24, 0, 25, 0, 0, 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, 0, + 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, 301, 0, 0, 0, 517, 744, 0, 0, 95, 0, 0, 0, 0, 0, 97, 98, 99, 100, - 0, 0, 0, 101, 0, 102, 0, 0, 0, 0, + 0, 0, 0, 101, 0, 102, 0, 0, 978, 0, 0, 103, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 310, 0, 0, 0, 105, 303, 107, 108, + 0, 0, 932, 0, 0, 0, 105, 302, 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, 27, 61, 62, 174, 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, 594, 0, 0, 0, 0, 0, 174, 595, + 0, 0, 36, 174, 37, 74, 0, 174, 38, 0, + 0, 76, 0, 78, 0, 80, 39, 40, 254, 174, + 41, 174, 0, 0, 0, 174, 0, 596, 0, 0, + 87, 88, 0, 174, 174, 0, 0, 174, 0, 0, + 174, 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, + 101, 0, 102, 978, 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, 591, - 0, 0, 0, 105, 303, 107, 108, 56, 24, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 936, + 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, 24, 0, 25, 64, 0, + 62, 174, 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, + 33, 37, 74, 937, 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, + 39, 40, 0, 0, 41, 0, 0, 322, 0, 0, + 0, 0, 89, 90, 91, 92, 301, 0, 0, 0, + 517, 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, 302, 107, 108, 64, 0, 0, 30, 0, 0, + 0, 0, 0, 0, 32, 0, 0, 0, 355, 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, 301, 0, 0, 0, 729, 1004, 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, 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, + 0, 0, 0, 0, 743, 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, 937, 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, 519, 0, 0, 0, 0, 89, 90, 91, + 92, 301, 0, 0, 0, 517, 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, 302, 107, 108, 64, + 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, + 0, 0, 0, 355, 33, 0, 71, 72, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, + 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, 301, 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, 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, 743, + 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, 573, 0, 0, + 0, 0, 89, 90, 91, 92, 301, 0, 0, 0, + 517, 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, - 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, 300, 0, 0, 0, + 105, 302, 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, 758, 0, 0, 0, 0, 89, + 90, 91, 92, 301, 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, 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, 309, 0, 0, 0, 105, 302, 107, + 108, 56, 24, 0, 25, 0, 0, 26, 253, 0, + 0, 0, 27, 61, 62, 355, 28, 0, 0, 491, + 0, 491, 64, 0, 491, 30, 0, 0, 0, 491, + 0, 0, 32, 491, 0, 0, 0, 33, 0, 71, + 72, 34, 491, 0, 0, 0, 0, 0, 0, 491, + 0, 0, 0, 36, 491, 37, 74, 0, 491, 38, + 0, 0, 76, 0, 78, 0, 80, 39, 40, 254, + 491, 41, 491, 0, 0, 0, 491, 0, 86, 0, + 0, 87, 88, 0, 491, 491, 0, 0, 491, 0, + 0, 491, 0, 0, 0, 0, 89, 90, 91, 92, + 301, 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, 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, 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, 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, + 592, 0, 0, 0, 105, 302, 107, 108, 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, - 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, 595, 0, 0, 87, 88, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 61, 62, 491, 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, 93, 0, 0, - 0, 0, 0, 0, 0, 95, 0, 0, 596, 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, 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, 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, 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, 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, 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, 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, - 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, + 0, 0, 0, 0, 0, 0, 0, 823, 0, 0, + 0, 105, 106, 107, 108, 56, 24, 0, 25, 0, + 0, 26, 253, 0, 0, 0, 27, 61, 62, 175, + 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, 0, 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, 301, 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, 1189, 0, 0, 0, 105, 302, + 107, 108, 56, 24, 0, 25, 0, 0, 26, 253, + 0, 0, 0, 27, 61, 62, 174, 28, 0, 0, + 184, 0, 184, 64, 0, 184, 30, 0, 0, 0, + 184, 0, 0, 32, 184, 0, 0, 0, 33, 0, + 71, 72, 34, 184, 0, 0, 0, 0, 0, 0, + 184, 0, 0, 0, 36, 184, 37, 74, 0, 184, 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, 512, 0, 0, 0, 95, + 254, 184, 41, 184, 0, 0, 0, 184, 0, 86, + 0, 0, 87, 88, 0, 184, 184, 0, 0, 184, + 0, 0, 184, 0, 0, 0, 0, 89, 90, 91, + 92, 301, 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, 303, 107, 108, 64, - 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, - 0, 0, 0, 0, 33, 0, 71, 72, 34, 0, + 103, 104, 0, 0, 0, 0, 0, 0, 0, 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, 610, 0, 0, 0, 105, 302, 107, 108, 610, + 610, 0, 610, 0, 0, 610, 610, 0, 0, 0, + 610, 610, 610, 184, 610, 0, 0, 0, 0, 0, + 610, 0, 0, 610, 0, 0, 0, 0, 0, 0, + 610, 0, 0, 0, 0, 610, 0, 610, 610, 610, 0, 0, 0, 0, 0, 0, 0, 0, 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, 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, 610, 0, 610, 610, 0, 0, 610, 0, 0, + 610, 0, 610, 0, 610, 610, 610, 610, 0, 610, + 0, 0, 0, 0, 0, 0, 610, 0, 0, 610, + 610, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 610, 610, 610, 610, 610, 0, + 0, 0, 0, 0, 0, 0, 610, 0, 0, 0, + 0, 0, 610, 610, 610, 610, 0, 0, 0, 610, + 0, 610, 0, 0, 0, 0, 0, 610, 610, 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, 500, 0, + 0, 0, 610, 610, 610, 610, 56, 24, 0, 25, + 0, 0, 26, 253, 0, 0, 0, 27, 61, 62, + 0, 28, 0, 0, 0, 0, 0, 64, 0, 0, + 30, 0, 0, 0, 27, 0, 0, 32, 0, 0, + 0, 337, 33, 0, 71, 72, 34, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 27, 36, 0, + 37, 74, 0, 0, 38, 0, 0, 76, 0, 78, + 27, 80, 39, 40, 254, 27, 41, 337, 0, 0, + 27, 0, 27, 27, 27, 27, 0, 0, 27, 0, + 27, 0, 0, 0, 27, 0, 0, 0, 0, 0, + 0, 89, 90, 91, 255, 0, 27, 0, 0, 27, + 0, 27, 0, 95, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 27, 0, 0, 0, 0, + 0, 27, 27, 0, 0, 0, 0, 0, 0, 0, + 337, 337, 337, 337, 745, 0, 0, 337, 337, 105, + 501, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 0, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, + 337, 337, 337, 0, 48, 0, 48, 0, 48, 337, + 48, 0, 337, 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, 48, 0, 47, + 0, 48, 0, 48, 0, 81, 48, 0, 48, 48, + 0, 48, 0, 48, 47, 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, 47, 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, 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, 0, 47, 0, 0, 47, + 0, 47, 47, 47, 47, 0, 0, 0, 47, 47, + 47, 0, 0, 47, 47, 47, 0, 0, 0, 0, + 0, 0, 47, 47, 48, 47, 47, 0, 47, 47, + 47, 0, 0, 0, 47, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 47, 0, 0, + 0, 47, 0, 47, 47, 0, 47, 0, 47, 47, + 214, 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, 337, + 47, 0, 0, 47, 0, 47, 47, 47, 47, 0, + 0, 0, 47, 47, 47, 0, 0, 47, 47, 47, + 47, 0, 337, 0, 0, 0, 47, 47, 0, 47, + 47, 452, 47, 47, 47, 337, 0, 0, 47, 0, + 337, 0, 0, 337, 0, 337, 0, 337, 337, 337, + 337, 0, 0, 0, 453, 337, 0, 0, 47, 337, + 0, 0, 0, 337, 215, 0, 0, 454, 0, 0, + 0, 337, 456, 0, 337, 0, 337, 457, 0, 458, + 459, 460, 461, 0, 0, 0, 0, 462, 0, 0, + 0, 463, 0, 0, 0, 337, 0, 0, 0, 0, + 337, 0, 0, 464, 0, 0, 465, 337, 466, 265, + 0, 337, 0, 0, 47, 56, 24, 0, 25, 0, + 0, 26, 253, 0, 337, 0, 27, 61, 62, 0, + 28, 0, 467, 0, 0, 0, 64, 0, 0, 30, + 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, + 0, 33, 0, 71, 72, 34, 337, 594, 0, 0, + 0, 0, 0, 0, 595, 0, 0, 36, 0, 37, + 74, 0, 0, 38, 0, 0, 76, 0, 78, 0, + 80, 39, 40, 254, 0, 41, 0, 0, 1340, 0, + 0, 0, 596, 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, 930, 0, 597, 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, 594, 0, 0, 0, 0, 0, 0, + 595, 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, 596, 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, 597, 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, + 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, 301, 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, 302, 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, 301, 0, 0, 0, 0, 889, 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, 302, 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, 301, 0, + 0, 0, 517, 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, 302, 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, - 641, 0, 0, 0, 0, 0, 0, 36, 0, 37, + 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, 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, + 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, - 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, - 47, 0, 0, 0, 47, 0, 47, 47, 47, 47, - 0, 0, 0, 0, 47, 0, 47, 0, 47, 0, - 47, 0, 35, 47, 0, 0, 0, 0, 0, 0, - 47, 0, 0, 47, 0, 47, 47, 0, 47, 47, - 0, 47, 0, 0, 0, 0, 47, 0, 47, 47, - 47, 47, 0, 0, 0, 0, 47, 0, 0, 47, - 47, 47, 0, 0, 0, 36, 0, 0, 0, 0, - 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, 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, 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, 453, 299, 0, 0, 47, 0, 47, 47, - 0, 47, 0, 47, 0, 0, 0, 0, 47, 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, + 89, 90, 91, 92, 301, 0, 0, 0, 511, 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, 302, + 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, + 301, 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, 302, 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, 1044, 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, 0, 0, 0, 0, 468, + 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, + 301, 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, 643, + 0, 643, 0, 643, 105, 256, 643, 108, 643, 643, + 0, 643, 0, 643, 0, 643, 0, 643, 643, 643, + 0, 0, 0, 643, 643, 0, 0, 0, 0, 643, + 0, 643, 643, 0, 0, 0, 643, 0, 0, 0, + 643, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 643, 643, 0, 643, 0, 0, 0, 643, 643, + 0, 0, 0, 0, 0, 0, 643, 643, 56, 24, + 643, 25, 0, 643, 26, 253, 0, 0, 643, 27, + 61, 62, 0, 28, 0, 0, 0, 0, 0, 64, + 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, + 643, 643, 0, 0, 33, 0, 71, 72, 34, 0, + 0, 0, 0, 643, 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, 643, 1235, 0, 0, 27, 0, + 0, 0, 28, 89, 90, 91, 255, 0, 0, 0, + 0, 30, 642, 0, 642, 95, 0, 642, 32, 642, + 642, 0, 642, 33, 642, 1236, 642, 34, 642, 642, + 642, 0, 0, 0, 642, 642, 0, 0, 0, 36, + 642, 37, 642, 642, 0, 38, 1237, 642, 0, 0, + 0, 642, 0, 39, 40, 0, 0, 41, 0, 0, + 322, 105, 256, 642, 0, 642, 0, 0, 0, 642, + 642, 0, 0, 0, 0, 0, 0, 642, 642, 0, + 642, 642, 642, 0, 642, 642, 0, 642, 642, 642, + 642, 0, 642, 0, 642, 0, 642, 642, 642, 0, + 0, 0, 642, 642, 0, 0, 0, 0, 642, 0, + 642, 642, 0, 0, 0, 642, 0, 0, 0, 642, + 0, 0, 0, 0, 642, 0, 0, 0, 0, 0, + 0, 642, 0, 642, 0, 0, 0, 642, 642, 0, + 0, 355, 0, 0, 0, 642, 642, 0, 0, 642, + 0, 0, 642, 0, 24, 0, 25, 642, 0, 26, + 0, 0, 1295, 0, 27, 642, 686, 0, 28, 0, + 687, 1296, 1297, 0, 0, 0, 1298, 30, 0, 0, + 0, 0, 1299, 0, 32, 0, 24, 0, 25, 33, + 0, 26, 0, 34, 1295, 0, 27, 0, 686, 0, + 28, 0, 687, 1296, 1297, 36, 0, 37, 1298, 30, + 0, 38, 0, 0, 1299, 0, 32, 0, 0, 39, + 40, 33, 0, 41, 0, 34, 1300, 0, 0, 0, + 47, 1301, 47, 642, 0, 47, 0, 36, 0, 37, + 47, 0, 0, 38, 47, 0, 0, 0, 0, 0, + 0, 39, 40, 47, 0, 41, 0, 0, 1300, 0, + 47, 0, 47, 1301, 47, 47, 1302, 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, 1303, 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, 1303, + 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, 33, 34, 35, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 0, 36, 0, + 37, 33, 0, 0, 38, 33, 0, 0, 33, 0, + 0, 47, 39, 40, 0, 0, 41, 0, 0, 0, + 33, 33, 0, 0, 0, 33, 33, 0, 0, 0, + 0, 33, 0, 33, 33, 33, 33, 0, 0, 0, + 0, 33, 0, 0, 0, 33, 0, 33, 0, 0, + 0, 0, 0, 0, 0, 574, 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, + 42, 31, 31, 0, 47, 0, 0, 31, 0, 31, + 31, 31, 31, 0, 0, 47, 0, 31, 0, 0, + 47, 31, 0, 31, 47, 0, 0, 47, 0, 0, + 0, 0, 0, 31, 0, 0, 31, 0, 31, 47, + 47, 0, 31, 0, 47, 47, 0, 47, 0, 0, + 47, 0, 47, 47, 47, 47, 0, 0, 47, 0, + 47, 0, 31, 47, 47, 0, 47, 47, 31, 31, + 47, 0, 0, 0, 0, 0, 47, 0, 0, 47, + 0, 47, 47, 47, 0, 47, 0, 47, 47, 47, + 0, 0, 0, 47, 0, 47, 47, 47, 47, 0, + 0, 0, 0, 47, 0, 47, 0, 47, 0, 47, + 0, 35, 47, 0, 0, 0, 0, 0, 0, 47, + 0, 0, 47, 0, 47, 47, 0, 47, 47, 0, + 47, 0, 0, 0, 0, 47, 0, 47, 47, 47, + 47, 0, 0, 0, 0, 47, 0, 0, 47, 47, + 47, 0, 0, 0, 36, 0, 0, 0, 0, 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, 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, 198, 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, 0, 0, + 0, 47, 299, 47, 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, + 300, 452, 47, 47, 0, 0, 47, 47, 47, 47, + 47, 47, 47, 0, 0, 47, 0, 47, 0, 0, + 0, 47, 0, 0, 453, 0, 0, 0, 0, 0, + 0, 452, 47, 47, 47, 47, 47, 454, 47, 0, + 0, 455, 456, 0, 0, 0, 0, 457, 0, 458, + 459, 460, 461, 0, 453, 0, 0, 462, 0, 0, + 0, 463, 47, 0, 0, 0, 0, 454, 0, 0, + 0, 0, 456, 464, 0, 0, 465, 457, 466, 458, + 459, 460, 461, 0, 0, 0, 0, 462, 0, 0, + 0, 463, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 467, 464, 0, 0, 465, 0, 466, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 467, }; protected static readonly short [] yyCheck = { 17, - 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, - 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, + 515, 18, 51, 17, 298, 4, 6, 51, 189, 234, + 469, 17, 299, 17, 288, 517, 232, 191, 354, 188, + 247, 68, 321, 20, 559, 339, 17, 84, 59, 491, + 157, 297, 354, 645, 646, 332, 370, 937, 295, 1113, + 87, 88, 87, 88, 58, 92, 721, 576, 723, 77, + 585, 59, 1148, 1149, 748, 73, 113, 0, 115, 77, + 277, 256, 328, 108, 256, 79, 781, 81, 59, 256, + 1242, 256, 63, 113, 256, 115, 256, 95, 942, 256, + 335, 256, 368, 256, 17, 268, 17, 1259, 256, 256, + 17, 256, 256, 768, 256, 268, 771, 282, 368, 256, + 368, 256, 1145, 1199, 256, 374, 256, 341, 376, 269, + 47, 391, 401, 414, 268, 17, 256, 891, 370, 1447, + 1448, 21, 374, 418, 413, 172, 286, 428, 902, 314, + 268, 1108, 418, 428, 414, 369, 665, 256, 276, 157, + 189, 17, 369, 157, 410, 189, 363, 416, 418, 323, + 256, 157, 52, 157, 199, 200, 343, 339, 17, 256, + 1203, 429, 344, 340, 346, 17, 157, 349, 350, 256, + 352, 353, 17, 17, 429, 256, 1504, 1198, 790, 17, + 372, 355, 374, 232, 339, 368, 360, 17, 232, 344, + 358, 346, 374, 256, 349, 350, 532, 352, 353, 1220, + 247, 418, 419, 256, 391, 1069, 363, 819, 256, 434, + 256, 258, 376, 375, 511, 256, 261, 433, 554, 374, + 514, 256, 724, 418, 157, 363, 157, 414, 228, 247, + 157, 381, 554, 418, 252, 375, 0, 429, 418, 422, + 576, 428, 287, 418, 0, 559, 1418, 429, 367, 422, + 369, 418, 371, 418, 285, 157, 424, 425, 426, 427, + 256, 418, 307, 320, 295, 439, 418, 324, 422, 375, + 288, 585, 329, 1445, 429, 293, 294, 285, 375, 326, + 418, 157, 369, 294, 331, 1457, 223, 1459, 1309, 329, + 308, 256, 1313, 374, 285, 306, 256, 315, 157, 317, + 474, 420, 316, 321, 423, 157, 351, 257, 256, 317, + 256, 1026, 157, 157, 257, 333, 334, 1338, 381, 157, + 372, 369, 369, 370, 999, 371, 317, 157, 381, 665, + 358, 372, 944, 339, 946, 339, 256, 949, 1412, 374, + 358, 870, 387, 388, 666, 262, 256, 256, 339, 1043, + 686, 369, 370, 256, 418, 373, 374, 375, 376, 377, + 378, 379, 380, 381, 382, 383, 418, 363, 415, 416, + 415, 416, 419, 1350, 370, 256, 372, 1092, 374, 371, + 368, 298, 1478, 256, 433, 256, 367, 405, 376, 433, + 256, 256, 256, 325, 443, 376, 266, 325, 1298, 256, + 574, 903, 1379, 1380, 374, 1382, 913, 418, 368, 374, + 709, 368, 1508, 587, 374, 589, 1393, 591, 266, 1396, + 882, 367, 418, 1035, 372, 1037, 1038, 61, 420, 358, + 376, 65, 66, 67, 1411, 69, 70, 662, 435, 483, + 74, 75, 335, 490, 314, 492, 416, 81, 1123, 83, + 370, 85, 449, 372, 374, 1130, 90, 91, 1435, 795, + 370, 378, 379, 372, 374, 368, 314, 694, 515, 726, + 484, 374, 429, 795, 277, 343, 701, 811, 281, 1154, + 114, 368, 656, 491, 341, 532, 418, 257, 369, 536, + 418, 993, 256, 343, 372, 513, 369, 515, 369, 517, + 491, 257, 676, 440, 441, 375, 372, 372, 372, 446, + 429, 1018, 369, 1020, 528, 529, 272, 372, 263, 368, + 256, 277, 1134, 391, 542, 281, 256, 375, 575, 547, + 363, 381, 368, 256, 870, 532, 1211, 363, 272, 342, + 296, 391, 429, 368, 368, 372, 414, 869, 305, 256, + 343, 429, 566, 559, 1166, 559, 339, 264, 363, 363, + 428, 363, 296, 373, 414, 369, 376, 323, 559, 305, + 315, 20, 256, 867, 429, 339, 594, 595, 428, 585, + 429, 585, 305, 369, 367, 418, 342, 256, 381, 323, + 817, 272, 418, 429, 585, 642, 277, 644, 391, 896, + 281, 1213, 429, 367, 429, 429, 653, 371, 735, 373, + 374, 375, 376, 418, 418, 296, 418, 381, 325, 1231, + 254, 414, 640, 257, 1159, 376, 306, 645, 646, 256, + 648, 305, 369, 313, 900, 428, 373, 367, 87, 88, + 263, 371, 323, 373, 374, 367, 376, 694, 363, 371, + 937, 381, 1226, 414, 369, 339, 1226, 398, 399, 108, + 344, 342, 346, 297, 711, 349, 350, 428, 352, 353, + 339, 994, 1226, 394, 395, 344, 694, 346, 429, 313, + 349, 350, 256, 352, 353, 415, 423, 687, 371, 357, + 373, 709, 315, 1155, 376, 726, 1270, 996, 420, 1022, + 1270, 369, 759, 418, 372, 373, 724, 339, 753, 392, + 393, 729, 339, 294, 1008, 762, 1270, 344, 386, 346, + 294, 391, 349, 350, 272, 352, 353, 256, 272, 412, + 721, 776, 723, 376, 961, 367, 1316, 420, 912, 256, + 423, 755, 1225, 1226, 414, 429, 791, 794, 296, 1329, + 199, 200, 296, 421, 1226, 773, 1226, 775, 428, 306, + 429, 308, 1245, 1226, 811, 779, 313, 781, 1348, 371, + 817, 256, 790, 418, 294, 323, 357, 768, 325, 323, + 771, 1226, 363, 428, 953, 357, 306, 1270, 369, 1272, + 1226, 372, 373, 811, 373, 844, 369, 376, 1270, 817, + 1270, 819, 429, 821, 386, 386, 1080, 1270, 381, 371, + 339, 373, 261, 1127, 386, 344, 339, 346, 381, 1113, + 349, 350, 339, 352, 353, 1270, 871, 344, 391, 346, + 874, 381, 349, 350, 1270, 352, 353, 418, 287, 256, + 421, 391, 1116, 1017, 367, 1159, 256, 865, 367, 867, + 299, 414, 486, 376, 418, 852, 306, 857, 307, 269, + 907, 357, 909, 313, 414, 428, 884, 374, 915, 376, + 1329, 371, 367, 891, 381, 325, 286, 373, 1152, 1106, + 1194, 376, 367, 901, 373, 903, 371, 376, 373, 374, + 386, 376, 367, 940, 528, 357, 381, 256, 1400, 367, + 429, 376, 351, 370, 368, 354, 384, 374, 376, 367, + 374, 373, 429, 371, 961, 373, 374, 381, 376, 354, + 355, 966, 339, 381, 386, 256, 944, 344, 946, 346, + 977, 949, 349, 350, 368, 352, 353, 367, 387, 388, + 382, 383, 376, 961, 1280, 371, 376, 373, 1173, 367, + 368, 1287, 6, 1169, 396, 397, 389, 415, 376, 1233, + 1462, 958, 1143, 17, 385, 370, 415, 416, 968, 374, + 970, 368, 972, 357, 371, 993, 373, 374, 996, 372, + 339, 374, 369, 376, 370, 344, 435, 346, 374, 373, + 349, 350, 400, 352, 353, 392, 393, 1499, 390, 370, + 449, 372, 386, 374, 418, 59, 1521, 1522, 999, 63, + 368, 1298, 1026, 415, 372, 412, 374, 1035, 376, 1037, + 1038, 368, 1040, 420, 368, 372, 423, 374, 372, 376, + 367, 368, 376, 87, 88, 371, 367, 368, 369, 376, + 371, 372, 368, 374, 369, 376, 418, 372, 374, 256, + 376, 1050, 370, 371, 108, 373, 374, 375, 418, 1106, + 368, 277, 1080, 371, 1108, 373, 374, 370, 371, 370, + 429, 374, 367, 374, 369, 372, 1094, 1095, 1092, 376, + 368, 369, 372, 532, 392, 393, 376, 418, 1106, 420, + 1107, 376, 423, 372, 1143, 1113, 1145, 376, 1116, 1143, + 372, 1145, 374, 157, 412, 554, 370, 372, 372, 376, + 374, 376, 420, 354, 355, 423, 1134, 372, 1412, 374, + 1169, 1127, 1140, 1127, 370, 1169, 372, 576, 370, 1303, + 372, 374, 1123, 376, 1152, 370, 1127, 372, 367, 1130, + 393, 394, 395, 396, 256, 199, 200, 294, 1166, 1167, + 367, 368, 1326, 1159, 1203, 1159, 368, 369, 357, 1203, + 386, 387, 388, 1154, 363, 370, 1340, 372, 1159, 372, + 369, 374, 373, 372, 373, 374, 1225, 1226, 372, 1224, + 374, 1225, 343, 370, 1358, 372, 1360, 386, 1194, 370, + 1194, 372, 374, 376, 376, 1213, 1245, 374, 374, 376, + 376, 1245, 374, 1194, 376, 376, 261, 261, 414, 415, + 364, 365, 294, 1231, 372, 1233, 665, 372, 373, 418, + 1211, 1270, 414, 1272, 364, 365, 1273, 418, 1272, 284, + 356, 285, 376, 287, 1279, 391, 392, 686, 418, 1111, + 1112, 369, 297, 389, 390, 299, 375, 302, 397, 398, + 1295, 1296, 307, 307, 309, 310, 311, 312, 418, 372, + 376, 372, 317, 317, 368, 374, 321, 372, 294, 1283, + 325, 372, 294, 1318, 374, 372, 1321, 372, 333, 372, + 374, 336, 93, 338, 256, 339, 97, 98, 99, 100, + 101, 102, 103, 104, 371, 376, 256, 351, 294, 294, + 354, 381, 372, 374, 753, 373, 1350, 362, 375, 374, + 373, 418, 381, 372, 374, 429, 374, 374, 374, 372, + 1334, 423, 374, 374, 367, 421, 372, 776, 373, 343, + 372, 294, 294, 387, 388, 1379, 1380, 374, 1382, 374, + 0, 1390, 791, 418, 371, 370, 795, 367, 256, 1393, + 256, 375, 1396, 374, 418, 256, 261, 256, 1407, 280, + 256, 415, 416, 418, 381, 367, 372, 1411, 368, 343, + 351, 1420, 1421, 370, 423, 376, 374, 371, 381, 284, + 372, 374, 1400, 370, 1398, 376, 372, 372, 347, 367, + 256, 1435, 297, 381, 1412, 256, 372, 302, 1447, 1448, + 305, 381, 307, 852, 309, 310, 311, 312, 372, 0, + 376, 1429, 317, 368, 347, 339, 321, 370, 374, 370, + 325, 870, 871, 375, 381, 370, 372, 368, 333, 348, + 374, 336, 372, 338, 418, 418, 348, 491, 376, 256, + 368, 367, 256, 368, 1462, 402, 403, 404, 405, 406, + 407, 408, 409, 410, 411, 1504, 367, 362, 367, 381, + 376, 356, 372, 337, 371, 368, 368, 305, 368, 418, + 374, 418, 369, 371, 1521, 1522, 418, 367, 532, 418, + 371, 1499, 418, 376, 371, 371, 371, 381, 937, 373, + 301, 1505, 1506, 371, 367, 371, 373, 369, 1512, 1513, + 554, 381, 372, 1521, 1522, 559, 374, 372, 256, 958, + 373, 367, 0, 418, 374, 374, 374, 966, 372, 376, + 372, 332, 576, 370, 368, 339, 418, 376, 376, 418, + 344, 585, 346, 347, 348, 349, 350, 351, 352, 353, + 354, 355, 356, 418, 372, 376, 372, 418, 381, 372, + 370, 381, 368, 372, 368, 315, 370, 263, 372, 371, + 374, 375, 376, 371, 368, 372, 372, 0, 0, 367, + 372, 376, 368, 384, 385, 386, 390, 376, 389, 390, + 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, + 401, 402, 403, 404, 0, 368, 372, 257, 372, 370, + 418, 261, 367, 372, 0, 368, 368, 373, 372, 370, + 367, 665, 272, 368, 372, 429, 368, 277, 418, 372, + 376, 281, 376, 418, 284, 376, 372, 376, 368, 367, + 372, 368, 686, 372, 368, 376, 296, 297, 367, 315, + 376, 301, 302, 376, 376, 376, 376, 307, 376, 309, + 310, 311, 312, 376, 376, 263, 50, 317, 12, 5, + 958, 321, 852, 323, 1272, 1106, 257, 721, 1106, 723, + 261, 1452, 1415, 333, 1245, 335, 336, 686, 338, 1468, + 1432, 272, 342, 1403, 1398, 1304, 277, 700, 874, 874, + 281, 869, 1316, 284, 1513, 874, 1335, 1146, 1258, 753, + 511, 1270, 362, 1421, 1420, 296, 297, 1507, 368, 369, + 301, 302, 1425, 1203, 768, 1506, 307, 771, 309, 310, + 311, 312, 776, 1360, 1304, 844, 317, 896, 1205, 265, + 321, 267, 323, 817, 270, 532, 369, 791, 1008, 275, + 729, 795, 333, 279, 335, 336, 694, 338, 71, 595, + 335, 342, 288, 726, 399, 401, 1205, 400, 402, 295, + 554, 403, 795, 404, 300, 1279, 1194, 1183, 304, 257, + 581, 362, 1127, 261, 157, 1224, 995, 1071, 369, 1095, + 316, 979, 318, 1022, 272, 1085, 322, 0, 1155, 277, + 1083, 1275, 917, 281, 330, 331, 284, 424, 334, 424, + 651, 337, 1167, 530, -1, -1, 850, -1, 296, 297, + 849, -1, -1, 301, 302, -1, 870, 871, -1, 307, + -1, 309, 310, 311, 312, -1, -1, 363, -1, 317, + 1279, 1280, -1, 321, -1, 323, -1, -1, 1287, -1, + -1, -1, -1, -1, -1, 333, 1295, 1296, 336, 1298, + 338, -1, -1, -1, 342, 1304, -1, -1, -1, -1, + 256, -1, -1, -1, -1, 261, 262, 1316, -1, 1318, + -1, -1, 1321, -1, 362, -1, -1, -1, -1, -1, + 1329, 369, 418, 937, -1, -1, -1, -1, 284, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 1348, + -1, 297, 298, -1, -1, -1, 302, -1, -1, 305, + -1, 307, 966, 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, 999, -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, -1, 370, 371, 372, 373, 374, 375, + 376, 0, 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, -1, 423, -1, -1, + -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 257, -1, -1, -1, 261, -1, + -1, 256, -1, -1, -1, -1, -1, 262, -1, 272, + -1, -1, -1, -1, 277, -1, -1, -1, 281, 1123, + -1, 284, -1, 1127, -1, -1, 1130, -1, -1, -1, + -1, -1, -1, 296, 297, 896, -1, -1, 301, 302, + -1, -1, 1146, 298, 307, -1, 309, 310, 311, 312, + 1154, -1, -1, -1, 317, 1159, -1, -1, 321, -1, + 323, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 333, -1, -1, 336, -1, 338, -1, -1, -1, 342, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 297, 298, -1, -1, -1, 302, 934, -1, - 305, -1, 307, -1, 309, 310, 311, 312, -1, -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, - 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, + 1194, -1, -1, -1, -1, -1, -1, -1, 0, 362, + -1, 1205, -1, -1, -1, 368, 369, 1211, 363, -1, + -1, -1, -1, 368, 369, -1, 371, 372, 373, 374, + 1224, 376, -1, 378, 379, -1, 381, 382, 383, 384, + 385, -1, 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, - -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, 418, -1, 420, -1, -1, 423, -1, + -1, -1, -1, -1, 429, 1279, 1280, -1, -1, -1, + -1, -1, -1, 1287, -1, -1, -1, 256, 257, -1, + -1, 1295, 1296, -1, 1298, 264, 265, 266, 267, 268, + -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, + 279, 280, -1, -1, 1318, -1, 285, 1321, 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, - -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, + 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, 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, + -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, 357, -1, -1, + 350, 351, 352, 353, 354, 355, 356, -1, -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, + 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, + -1, -1, 382, 383, 384, 385, -1, -1, -1, 389, 390, -1, -1, -1, 394, 395, 396, 397, 398, 399, - 400, 401, 256, -1, -1, 0, -1, -1, 262, -1, + 400, 401, 298, -1, -1, -1, -1, -1, 0, -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, 429, -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, - 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, -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, + -1, -1, -1, 339, -1, -1, -1, -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, + 356, 357, -1, -1, 256, -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, 0, -1, 389, 390, -1, -1, -1, 394, 395, + 396, 397, 398, 399, 400, 401, 256, -1, -1, -1, + -1, -1, 262, -1, -1, -1, -1, 413, -1, -1, + 416, -1, 418, -1, 420, -1, -1, 423, -1, -1, + -1, -1, -1, 429, 0, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 339, 298, -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, 0, 370, -1, + 372, -1, 374, 375, 376, -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, -1, -1, 367, 368, -1, + 370, 371, 372, -1, 374, 375, 376, -1, 378, 379, + -1, -1, 382, 383, 384, 385, -1, 429, -1, 389, + 390, -1, -1, -1, 394, 395, 396, 397, 398, 399, + 400, 401, -1, -1, -1, -1, -1, 0, -1, -1, + -1, -1, -1, 413, 256, 257, 416, -1, 418, 261, + -1, -1, -1, 265, -1, 267, -1, -1, 270, 429, + 272, 273, -1, 275, -1, 277, -1, 279, -1, 281, + 282, 283, 284, -1, -1, 287, 288, -1, -1, -1, + 0, 293, -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, -1, -1, -1, -1, -1, 330, 331, + -1, 333, 334, 0, 336, 337, 338, -1, 257, -1, + 342, -1, 261, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 272, -1, -1, -1, -1, 277, -1, + 362, -1, 281, -1, -1, 284, 368, 369, -1, -1, + -1, -1, -1, -1, -1, 377, 0, 296, 297, -1, + -1, 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, + -1, -1, -1, -1, 333, -1, 418, 336, -1, 338, + 296, 297, -1, 342, 257, 301, 302, -1, 261, -1, + -1, 307, -1, 309, 310, 311, 312, -1, -1, 272, + -1, 317, -1, 362, 277, 321, -1, 323, 281, 368, + 369, 284, -1, -1, -1, -1, -1, 333, -1, -1, + 336, -1, 338, 296, 297, -1, 342, -1, 301, 302, + -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, + -1, -1, -1, -1, 317, -1, 362, -1, 321, -1, + 323, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 333, -1, -1, 336, 257, 338, -1, -1, 261, 342, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, + -1, -1, -1, -1, 277, -1, -1, -1, 281, 362, + -1, 284, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 296, 297, -1, -1, 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, -1, -1, -1, -1, + 333, -1, -1, 336, -1, 338, 296, 297, -1, 342, + 257, 301, 302, -1, 261, -1, -1, 307, -1, 309, + 310, 311, 312, -1, -1, 272, -1, 317, -1, 362, + 277, 321, -1, 323, 281, -1, -1, 284, -1, -1, + -1, -1, -1, 333, -1, -1, 336, -1, 338, 296, + 297, -1, 342, 257, 301, 302, -1, 261, -1, -1, + 307, -1, 309, 310, 311, 312, -1, -1, 272, -1, + 317, -1, 362, 277, 321, -1, 323, 281, -1, -1, + 284, -1, -1, -1, -1, -1, 333, -1, -1, 336, + -1, 338, 296, 297, -1, 342, -1, 301, 302, -1, + -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, -1, -1, 317, -1, 362, -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, - 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, + -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, 429, 392, 393, 394, 395, 396, 397, + 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, + 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, 368, - -1, 370, 371, 372, 373, 374, 375, 376, -1, 378, - 379, -1, 381, 382, 383, 384, 385, 386, 387, 388, + -1, -1, -1, -1, -1, -1, -1, -1, 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, 256, -1, -1, - -1, 420, 262, -1, 423, -1, 265, -1, 267, -1, - 429, 270, -1, -1, -1, -1, 275, -1, -1, -1, - 279, -1, -1, -1, -1, -1, -1, -1, -1, 288, - -1, -1, -1, -1, -1, -1, 295, -1, 298, -1, - -1, 300, -1, -1, -1, 304, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 316, -1, 318, - -1, -1, -1, 322, -1, -1, -1, -1, -1, -1, - -1, 330, 331, -1, -1, 334, -1, -1, 337, 339, + 409, 410, 411, 412, 413, -1, 256, -1, -1, -1, + -1, 420, 262, -1, -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, -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, 363, -1, -1, -1, 368, -1, + -1, -1, -1, -1, -1, -1, -1, 367, 368, -1, 370, 371, 372, 373, 374, 375, 376, -1, 378, 379, -1, 381, 382, 383, 384, 385, 386, 387, 388, 389, - 390, -1, 392, 393, 394, 395, 396, 397, 398, 399, + 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, 418, + 410, 411, 412, 413, -1, 256, 256, -1, -1, -1, 420, 262, -1, 423, -1, 265, -1, 267, -1, 429, 270, -1, -1, -1, -1, 275, -1, -1, -1, 279, -1, -1, -1, -1, -1, -1, -1, -1, 288, -1, @@ -11842,284 +11872,258 @@ void case_978() 330, 331, -1, -1, 334, -1, -1, 337, 339, -1, -1, -1, -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, -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, 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, + 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, 362, -1, -1, - -1, 298, -1, -1, -1, -1, 368, -1, 370, 371, - 372, 373, 374, 375, 376, -1, 378, 314, -1, 381, + 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, 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, -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, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, 256, 429, -1, -1, - -1, -1, 262, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, 378, 379, -1, -1, 382, 383, - 384, 385, -1, -1, -1, 389, 390, -1, -1, -1, - 394, 395, 396, 397, 398, 399, 400, 401, 298, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 413, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 256, 429, -1, -1, -1, -1, - 262, -1, -1, -1, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, -1, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 298, -1, 368, -1, - 370, -1, 372, -1, 374, 375, 376, -1, 378, 379, - -1, -1, 382, 383, 384, 385, -1, -1, -1, 389, - 390, -1, -1, -1, 394, 395, 396, 397, 398, 399, - 400, 401, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 413, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, 256, 429, - -1, -1, -1, -1, 262, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, 378, 379, -1, -1, - 382, 383, 384, 385, -1, -1, -1, 389, 390, -1, - -1, -1, 394, 395, 396, 397, 398, 399, 400, 401, - 298, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 413, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 256, 429, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, -1, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, - 378, 379, -1, -1, 382, 383, 384, 385, -1, -1, - -1, 389, 390, -1, 256, -1, 394, 395, 396, 397, - 398, 399, 400, 401, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 413, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - -1, 429, -1, -1, -1, -1, -1, -1, 368, -1, - 370, -1, 372, -1, 374, 375, 376, -1, -1, -1, - -1, -1, 382, 383, 384, 385, -1, -1, -1, 389, - 390, -1, 256, -1, 394, 395, 396, 397, 398, 399, - 400, 401, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 413, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, 429, - -1, -1, -1, -1, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, -1, -1, -1, -1, - 382, 383, 384, 385, -1, -1, -1, 389, 390, -1, - 256, -1, 394, 395, 396, 397, 398, 399, 400, 401, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 429, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, -1, -1, -1, -1, 382, 383, - 384, 385, -1, -1, -1, 389, 390, -1, 256, -1, - 394, 395, 396, 397, 398, 399, 400, 401, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 413, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, -1, 429, -1, -1, -1, -1, - -1, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, -1, -1, -1, -1, 382, 383, 384, 385, - -1, -1, -1, 389, 390, -1, 256, -1, -1, -1, - 396, 397, 398, 399, 400, 401, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 413, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, - -1, -1, -1, -1, 382, 383, 384, 385, -1, -1, - -1, 389, 390, -1, 256, -1, -1, -1, 396, 397, - 398, 399, 400, 401, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 413, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - -1, 429, -1, -1, -1, -1, -1, -1, 368, -1, - 370, -1, 372, -1, 374, 375, 376, -1, -1, -1, - -1, -1, 382, 383, 384, 385, -1, -1, -1, 389, - 390, -1, 256, -1, -1, -1, 396, 397, 398, 399, - 400, 401, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 413, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, 429, - -1, -1, -1, -1, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, -1, -1, -1, -1, - 382, 383, 384, 385, -1, -1, -1, 389, 390, -1, - 256, -1, -1, -1, 396, 397, 398, 399, 400, 401, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 429, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, -1, -1, -1, -1, 382, 383, - 384, 385, -1, -1, -1, 389, 390, -1, 256, -1, - -1, -1, 396, 397, 398, 399, 400, 401, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 413, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, -1, 429, -1, -1, -1, -1, - -1, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, -1, -1, -1, -1, -1, -1, 384, 385, - -1, -1, -1, 389, 390, -1, 256, -1, -1, -1, - -1, -1, 398, 399, 400, 401, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 413, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, - -1, -1, -1, -1, -1, -1, 384, 385, -1, -1, - -1, 389, 390, -1, 256, -1, -1, -1, -1, -1, - 398, 399, 400, 401, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 413, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - -1, 429, -1, -1, -1, -1, -1, -1, 368, -1, - 370, -1, 372, -1, 374, 375, 376, -1, -1, -1, - -1, -1, -1, -1, 384, 385, -1, -1, -1, 389, - 390, -1, 256, -1, -1, -1, -1, -1, 398, 399, - 400, 401, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 413, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, 429, - -1, -1, -1, -1, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, -1, -1, -1, -1, - -1, -1, 384, 385, -1, -1, -1, 389, 390, -1, - 256, -1, -1, -1, -1, -1, -1, -1, 400, 401, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 429, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, -1, -1, -1, -1, -1, -1, - 384, 385, -1, -1, -1, 389, 390, -1, 256, -1, - -1, -1, -1, -1, -1, -1, 400, 401, -1, -1, - -1, -1, -1, 339, -1, -1, -1, -1, 344, 413, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, -1, -1, -1, -1, 429, -1, -1, -1, -1, - -1, -1, 368, -1, 370, -1, 372, -1, 374, 375, - 376, -1, -1, -1, -1, -1, -1, -1, -1, 385, - -1, -1, -1, 389, 390, -1, 256, -1, -1, -1, - -1, -1, -1, -1, 400, 401, -1, -1, -1, -1, - -1, 339, -1, -1, -1, -1, 344, 413, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, - -1, -1, -1, 429, -1, -1, -1, -1, -1, -1, - 368, -1, 370, -1, 372, -1, 374, 375, 376, -1, - -1, -1, -1, -1, -1, -1, -1, 385, -1, -1, - -1, 389, 390, -1, 256, -1, -1, -1, -1, -1, - -1, -1, 400, 401, -1, -1, -1, -1, -1, 339, - -1, -1, -1, -1, 344, 413, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, - -1, 429, -1, -1, -1, -1, -1, -1, 368, -1, - 370, -1, 372, -1, 374, 375, 376, -1, -1, -1, - -1, -1, -1, -1, -1, 385, -1, -1, -1, -1, - 390, -1, 256, -1, -1, -1, -1, -1, -1, -1, - 400, 401, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, 344, 413, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, -1, -1, -1, -1, 429, - -1, -1, -1, -1, -1, -1, 368, -1, 370, -1, - 372, -1, 374, 375, 376, -1, -1, -1, -1, -1, - -1, -1, -1, 385, -1, -1, -1, -1, 390, -1, - 256, -1, -1, -1, -1, -1, -1, -1, 400, 401, - -1, -1, -1, -1, -1, 339, -1, -1, -1, -1, - 344, 413, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, -1, -1, -1, -1, 429, -1, -1, - -1, -1, -1, -1, 368, -1, 370, -1, 372, -1, - 374, 375, 376, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 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, 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, -1, -1, -1, -1, - -1, -1, -1, -1, 400, 401, -1, -1, -1, -1, - -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, - -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, + 412, 413, -1, 256, 256, -1, -1, 418, 420, 262, + -1, 423, -1, 265, -1, 267, -1, 429, 270, -1, + -1, -1, -1, 275, -1, -1, -1, 279, -1, -1, + -1, -1, -1, -1, -1, -1, 288, -1, -1, -1, + -1, -1, -1, 295, -1, 298, -1, -1, 300, -1, + -1, -1, 304, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 316, -1, 318, -1, -1, -1, + 322, -1, -1, -1, -1, -1, -1, -1, 330, 331, + -1, -1, 334, -1, -1, 337, 339, -1, -1, -1, + -1, 344, -1, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 368, -1, 370, 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, 418, 420, 262, 256, + 423, -1, 266, -1, -1, -1, 429, -1, 265, -1, + 267, -1, -1, 270, -1, -1, -1, -1, 275, -1, + -1, -1, 279, -1, -1, -1, -1, -1, -1, -1, + -1, 288, -1, -1, 298, -1, -1, -1, 295, -1, + -1, -1, -1, 300, -1, -1, -1, 304, -1, -1, + 314, -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, -1, -1, -1, -1, 256, -1, -1, -1, -1, + -1, 262, -1, 357, -1, -1, -1, -1, -1, 363, + -1, -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, 298, 392, 393, + 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, + 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, + -1, -1, -1, -1, 418, -1, 420, -1, -1, 423, + -1, 418, -1, -1, -1, 429, -1, -1, 339, -1, + -1, -1, -1, 344, -1, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 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, -1, -1, + -1, -1, -1, -1, -1, -1, 297, -1, 429, -1, + -1, 302, -1, -1, 305, -1, 307, -1, 309, 310, + 311, 312, -1, -1, -1, -1, 317, -1, -1, -1, + 321, -1, -1, 298, 325, -1, -1, -1, -1, -1, + -1, -1, 333, -1, -1, 336, -1, 338, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, + -1, -1, -1, -1, -1, 262, -1, -1, -1, -1, + -1, 362, -1, -1, 339, -1, -1, -1, -1, 344, + -1, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 298, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, 378, 379, -1, -1, 382, 383, 384, + 385, 386, 387, 388, 389, 390, -1, 418, -1, 394, + 395, 396, 397, 398, 399, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, 256, 429, -1, -1, -1, -1, 262, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, 378, 379, -1, -1, 382, 383, 384, 385, -1, + -1, -1, 389, 390, -1, -1, -1, 394, 395, 396, + 397, 398, 399, 400, 401, 298, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 413, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -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, 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, 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, 378, 379, -1, -1, 382, 383, 384, + 385, -1, -1, -1, 389, 390, -1, 256, -1, 394, + 395, 396, 397, 398, 399, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, -1, -1, -1, -1, 382, 383, 384, 385, -1, + -1, -1, 389, 390, -1, 256, -1, 394, 395, 396, + 397, 398, 399, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, -1, 429, -1, -1, -1, -1, -1, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, + -1, -1, -1, 382, 383, 384, 385, -1, -1, -1, + 389, 390, -1, 256, -1, 394, 395, 396, 397, 398, + 399, 400, 401, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 413, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, + -1, 382, 383, 384, 385, -1, -1, -1, 389, 390, + -1, 256, -1, 394, 395, 396, 397, 398, 399, 400, + 401, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 413, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, 429, -1, + -1, -1, -1, -1, -1, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, -1, -1, -1, -1, 382, + 383, 384, 385, -1, -1, -1, 389, 390, -1, 256, + -1, -1, -1, 396, 397, 398, 399, 400, 401, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 413, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, 429, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, -1, -1, -1, -1, 382, 383, 384, + 385, -1, -1, -1, 389, 390, -1, 256, -1, -1, + -1, 396, 397, 398, 399, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, -1, -1, -1, -1, 382, 383, 384, 385, -1, + -1, -1, 389, 390, -1, 256, -1, -1, -1, 396, + 397, 398, 399, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, -1, 429, -1, -1, -1, -1, -1, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, + -1, -1, -1, 382, 383, 384, 385, -1, -1, -1, + 389, 390, -1, 256, -1, -1, -1, 396, 397, 398, + 399, 400, 401, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 413, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, + -1, 382, 383, 384, 385, -1, -1, -1, 389, 390, + -1, 256, -1, -1, -1, 396, 397, 398, 399, 400, + 401, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 413, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, 429, -1, + -1, -1, -1, -1, -1, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, -1, -1, -1, -1, -1, + -1, 384, 385, -1, -1, -1, 389, 390, -1, 256, + -1, -1, -1, -1, -1, 398, 399, 400, 401, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 413, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, 429, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, -1, -1, -1, -1, -1, -1, 384, + 385, -1, -1, -1, 389, 390, -1, 256, -1, -1, + -1, -1, -1, 398, 399, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, -1, -1, -1, -1, -1, -1, 384, 385, -1, + -1, -1, 389, 390, -1, 256, -1, -1, -1, -1, + -1, 398, 399, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, -1, 429, -1, -1, -1, -1, -1, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, + -1, -1, -1, -1, -1, 384, 385, -1, -1, -1, + 389, 390, -1, 256, -1, -1, -1, -1, -1, -1, + -1, 400, 401, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 413, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, + -1, -1, -1, 384, 385, -1, -1, -1, 389, 390, + -1, 256, -1, -1, -1, -1, -1, -1, -1, 400, + 401, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 413, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, 429, -1, + -1, -1, -1, -1, -1, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, -1, -1, -1, -1, -1, + -1, -1, 385, -1, -1, -1, 389, 390, -1, 256, + -1, -1, -1, -1, -1, -1, -1, 400, 401, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 413, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, 429, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, -1, -1, -1, -1, -1, -1, -1, + 385, -1, -1, -1, 389, 390, -1, 256, -1, -1, + -1, -1, -1, -1, -1, 400, 401, -1, -1, -1, + -1, -1, 339, -1, -1, -1, -1, 344, 413, 346, + 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, + -1, -1, -1, -1, 429, -1, -1, -1, -1, -1, + -1, 368, -1, 370, -1, 372, -1, 374, 375, 376, + -1, -1, -1, -1, -1, -1, -1, -1, 385, -1, + -1, -1, -1, 390, -1, 256, -1, -1, -1, -1, + -1, -1, -1, 400, 401, -1, -1, -1, -1, -1, + 339, -1, -1, -1, -1, 344, 413, 346, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, + -1, -1, 429, -1, -1, -1, -1, -1, -1, 368, + -1, 370, -1, 372, -1, 374, 375, 376, -1, -1, + -1, -1, -1, -1, -1, -1, 385, -1, -1, -1, + -1, 390, -1, 256, -1, -1, -1, -1, -1, -1, + -1, 400, 401, -1, -1, -1, -1, -1, 339, -1, + -1, -1, -1, 344, 413, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, + 429, -1, -1, -1, -1, -1, -1, 368, -1, 370, + -1, 372, -1, 374, 375, 376, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 390, + -1, 256, -1, -1, -1, -1, -1, -1, -1, 400, + 401, -1, -1, -1, -1, -1, 339, -1, -1, -1, + -1, 344, 413, 346, 347, 348, 349, 350, 351, 352, + 353, 354, 355, 356, -1, -1, -1, -1, 429, -1, + -1, -1, -1, -1, -1, 368, -1, 370, -1, 372, + -1, 374, 375, 376, -1, -1, -1, 256, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 390, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 400, 401, -1, + -1, -1, -1, -1, 339, -1, -1, -1, -1, 344, + 413, 346, 347, 348, 349, 350, 351, 352, 353, 354, + 355, 356, -1, -1, -1, -1, 429, -1, -1, -1, + -1, -1, -1, 368, -1, 370, -1, 372, -1, 374, + 375, 376, -1, -1, -1, -1, 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, - 256, -1, -1, -1, 417, 418, 419, 420, 264, 265, - 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, + -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, @@ -12150,114 +12154,55 @@ void case_978() -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, 417, 418, - 419, 420, 264, 265, -1, 267, -1, -1, 270, 271, - -1, 256, -1, 275, 276, 277, -1, 279, -1, -1, - 265, -1, 267, 285, -1, 270, 288, -1, -1, -1, - 275, -1, -1, 295, 279, -1, -1, -1, 300, -1, - 302, 303, 304, 288, -1, -1, -1, -1, -1, -1, - 295, -1, -1, -1, 316, 300, 318, 319, -1, 304, - 322, -1, -1, 325, -1, 327, -1, 329, 330, 331, - 332, 316, 334, 318, -1, -1, -1, 322, -1, 341, - -1, -1, 344, 345, -1, 330, 331, -1, -1, 334, - -1, -1, 337, -1, -1, -1, -1, 359, 360, 361, - 362, 363, -1, -1, -1, 367, 368, -1, -1, 371, - -1, -1, -1, -1, -1, 377, 378, 379, 380, -1, + 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, -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, 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, - 345, -1, 330, 331, -1, -1, 334, -1, -1, 337, + 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, -1, -1, -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, -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, 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, -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, - 318, 319, -1, 304, 322, -1, -1, 325, -1, 327, - -1, 329, 330, 331, 332, 316, 334, 318, -1, -1, - -1, 322, -1, 341, -1, -1, 344, 345, -1, 330, - 331, -1, -1, 334, -1, -1, 337, -1, -1, -1, -1, 359, 360, 361, 362, 363, -1, -1, -1, 367, - -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, + -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, -1, -1, 275, 276, 277, 418, 279, -1, + 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, @@ -12266,30 +12211,89 @@ void case_978() 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, + 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, 372, -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, 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, 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, 370, -1, -1, -1, -1, 392, 393, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, + -1, -1, -1, 417, 418, 419, 420, 264, 265, -1, + 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, + 277, 418, 279, -1, -1, 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, 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, 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, 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, -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, -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, -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, + -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, @@ -12298,7 +12302,7 @@ void case_978() -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, + 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, @@ -12336,386 +12340,437 @@ void case_978() -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, + 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, 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, -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, 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, - 362, -1, 364, 365, 261, -1, -1, -1, 265, -1, - 267, -1, -1, 270, -1, 272, 273, -1, 275, -1, + -1, 256, -1, -1, -1, 417, 418, 419, 420, 264, + 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, + 275, 276, 277, 418, 279, -1, -1, -1, -1, -1, + 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, + 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 316, -1, 318, 319, -1, -1, 322, -1, -1, + 325, -1, 327, -1, 329, 330, 331, 332, -1, 334, + -1, -1, -1, -1, -1, -1, 341, -1, -1, 344, + 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 359, 360, 361, 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, + -1, 279, -1, -1, -1, -1, -1, 285, -1, -1, + 288, -1, -1, -1, 261, -1, -1, 295, -1, -1, + -1, 262, 300, -1, 302, 303, 304, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 284, 316, -1, + 318, 319, -1, -1, 322, -1, -1, 325, -1, 327, + 297, 329, 330, 331, 332, 302, 334, 298, -1, -1, + 307, -1, 309, 310, 311, 312, -1, -1, 315, -1, + 317, -1, -1, -1, 321, -1, -1, -1, -1, -1, + -1, 359, 360, 361, 362, -1, 333, -1, -1, 336, + -1, 338, -1, 371, -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, 368, 369, -1, -1, -1, -1, -1, -1, -1, + 371, 372, 373, 374, 375, -1, -1, 378, 379, 417, + 418, 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, + 287, 288, -1, -1, -1, -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, -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, -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, 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, -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, + 318, -1, -1, 321, 322, 323, -1, -1, -1, -1, + -1, -1, 330, 331, 418, 333, 334, -1, 336, 337, 338, -1, -1, -1, 342, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 261, -1, -1, + -1, 265, -1, 267, 362, -1, 270, -1, 272, 273, + 368, 275, -1, 277, -1, 279, -1, 281, 282, 283, + 284, -1, -1, 287, 288, -1, -1, -1, -1, 293, + -1, 295, 296, 297, -1, -1, 300, -1, 302, 261, + 304, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, -1, 316, 317, 318, -1, -1, 321, 322, 323, + 418, -1, 284, -1, -1, -1, 330, 331, -1, 333, + 334, 261, 336, 337, 338, 297, -1, -1, 342, -1, + 302, -1, -1, 305, -1, 307, -1, 309, 310, 311, + 312, -1, -1, -1, 284, 317, -1, -1, 362, 321, + -1, -1, -1, 325, 368, -1, -1, 297, -1, -1, + -1, 333, 302, -1, 336, -1, 338, 307, -1, 309, + 310, 311, 312, -1, -1, -1, -1, 317, -1, -1, + -1, 321, -1, -1, -1, 357, -1, -1, -1, -1, + 362, -1, -1, 333, -1, -1, 336, 369, 338, 371, + -1, 373, -1, -1, 418, 264, 265, -1, 267, -1, + -1, 270, 271, -1, 386, -1, 275, 276, 277, -1, + 279, -1, 362, -1, -1, -1, 285, -1, -1, 288, + -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, + -1, 300, -1, 302, 303, 304, 418, 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, 418, -1, + -1, -1, 341, -1, -1, 344, 345, -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, -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, -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, - 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, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 316, -1, 318, 319, - -1, -1, 322, -1, -1, 325, -1, 327, -1, 329, - 330, 331, 332, -1, 334, -1, -1, 337, -1, -1, - -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 359, - 360, 361, 362, 363, -1, -1, -1, -1, -1, -1, - -1, 371, -1, -1, -1, -1, -1, 377, 378, 379, - 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, - -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, - 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, - -1, 275, 276, 277, -1, 279, -1, 417, 418, 419, - 420, 285, -1, -1, 288, -1, -1, -1, -1, -1, - -1, 295, -1, -1, -1, -1, 300, -1, 302, 303, - 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 316, -1, 318, 319, -1, -1, 322, -1, - -1, 325, -1, 327, -1, 329, 330, 331, 332, -1, - 334, -1, -1, -1, -1, -1, -1, 341, -1, -1, - 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 359, 360, 361, 362, 363, - -1, -1, -1, -1, 368, -1, -1, 371, -1, -1, - -1, -1, -1, 377, 378, 379, 380, -1, -1, -1, - 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, - -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, - -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, - -1, 279, -1, 417, 418, 419, 420, 285, -1, -1, - 288, -1, -1, -1, -1, -1, -1, 295, -1, -1, - -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 316, -1, - 318, 319, -1, -1, 322, -1, -1, 325, -1, 327, - -1, 329, 330, 331, 332, -1, 334, -1, -1, -1, - -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, + 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, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 316, + -1, 318, 319, -1, -1, 322, -1, -1, 325, -1, + 327, -1, 329, 330, 331, 332, -1, 334, -1, -1, + 337, -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 359, 360, 361, 362, 363, -1, -1, -1, 367, - -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, - 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, - -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, - -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, - -1, -1, -1, 275, 276, 277, -1, 279, -1, 417, - 418, 419, 420, 285, -1, -1, 288, -1, -1, -1, - -1, -1, -1, 295, -1, -1, -1, -1, 300, -1, - 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 316, -1, 318, 319, -1, -1, - 322, -1, -1, 325, -1, 327, -1, 329, 330, 331, - 332, -1, 334, -1, -1, -1, -1, -1, -1, 341, - -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 359, 360, 361, - 362, 363, -1, -1, -1, 367, -1, -1, -1, 371, - -1, -1, -1, -1, -1, 377, 378, 379, 380, -1, - -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, - 392, 393, -1, -1, -1, -1, -1, -1, 264, 265, - -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, - 276, 277, -1, 279, -1, 417, 418, 419, 420, 285, - -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, - -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, + -1, -1, 359, 360, 361, 362, 363, -1, -1, -1, + -1, -1, -1, -1, 371, -1, -1, -1, -1, -1, + 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, + -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 417, 418, 419, 420, 285, -1, -1, 288, -1, -1, + -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, + 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 359, 360, + 361, 362, 363, -1, -1, -1, -1, 368, -1, -1, + 371, -1, -1, -1, -1, -1, 377, 378, 379, 380, + -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, + -1, 392, 393, -1, -1, -1, -1, -1, -1, 264, + 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, + 275, 276, 277, -1, 279, -1, 417, 418, 419, 420, + 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, + 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 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, 316, -1, 318, 319, -1, -1, 322, -1, -1, + 325, -1, 327, -1, 329, 330, 331, 332, -1, 334, + -1, -1, -1, -1, -1, -1, 341, -1, -1, 344, + 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 359, 360, 361, 362, 363, -1, + -1, -1, 367, -1, -1, -1, 371, -1, -1, -1, + -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, + -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, + -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, + -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, + 279, -1, 417, 418, 419, 420, 285, -1, -1, 288, + -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, + -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 316, -1, 318, + 319, -1, -1, 322, -1, -1, 325, -1, 327, -1, + 329, 330, 331, 332, -1, 334, -1, -1, -1, -1, + -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 359, 360, 361, 362, 363, -1, -1, - -1, -1, -1, -1, -1, 371, -1, -1, -1, -1, - -1, 377, 378, 379, 380, -1, -1, -1, 384, -1, - 386, -1, -1, -1, -1, -1, 392, 393, -1, -1, - -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, - 270, 271, -1, -1, -1, 275, 276, 277, -1, 279, - -1, 417, 418, 419, 420, 285, -1, -1, 288, -1, - -1, -1, -1, -1, -1, 295, -1, -1, -1, -1, - 300, -1, 302, 303, 304, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 316, -1, 318, 319, - -1, -1, 322, -1, -1, 325, -1, 327, -1, 329, - 330, 331, 332, -1, 334, -1, -1, -1, -1, -1, - -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 359, - 360, 361, 362, 363, -1, -1, -1, -1, -1, -1, - -1, 371, -1, -1, -1, -1, -1, 377, 378, 379, - 380, -1, -1, -1, 384, -1, 386, -1, -1, -1, - -1, -1, 392, 393, -1, -1, -1, -1, -1, -1, - 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, - -1, 275, 276, 277, -1, 279, -1, 417, 418, 419, - 420, 285, -1, -1, 288, -1, -1, -1, -1, -1, - -1, 295, -1, -1, -1, -1, 300, -1, 302, 303, - 304, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 316, -1, 318, 319, -1, -1, 322, -1, - -1, 325, -1, 327, -1, 329, 330, 331, 332, -1, - 334, -1, -1, -1, -1, -1, -1, 341, -1, -1, - 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 359, 360, 361, 362, 363, - -1, -1, -1, -1, -1, -1, -1, 371, -1, -1, - -1, -1, -1, 377, 378, 379, 380, -1, -1, -1, - 384, -1, 386, -1, -1, -1, -1, -1, 392, 393, - -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, - -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, - -1, 279, -1, 417, 418, 419, 420, 285, -1, -1, - 288, -1, -1, -1, -1, -1, -1, 295, -1, -1, - -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 316, -1, - 318, 319, -1, -1, 322, -1, -1, 325, -1, 327, - -1, 329, 330, 331, 332, -1, 334, -1, -1, -1, - -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, + 359, 360, 361, 362, 363, -1, -1, -1, 367, -1, + -1, -1, 371, -1, -1, -1, -1, -1, 377, 378, + 379, 380, -1, -1, -1, 384, -1, 386, -1, -1, + -1, -1, -1, 392, 393, -1, -1, -1, -1, -1, + -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, + -1, -1, 275, 276, 277, -1, 279, -1, 417, 418, + 419, 420, 285, -1, -1, 288, -1, -1, -1, -1, + -1, -1, 295, -1, -1, -1, -1, 300, -1, 302, + 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 316, -1, 318, 319, -1, -1, 322, + -1, -1, 325, -1, 327, -1, 329, 330, 331, 332, + -1, 334, -1, -1, -1, -1, -1, -1, 341, -1, + -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 359, 360, 361, 362, + 363, -1, -1, -1, -1, -1, -1, -1, 371, -1, + -1, -1, -1, -1, 377, 378, 379, 380, -1, -1, + -1, 384, -1, 386, -1, -1, -1, -1, -1, 392, + 393, -1, -1, -1, -1, -1, -1, 264, 265, -1, + 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, + 277, -1, 279, -1, 417, 418, 419, 420, 285, -1, + -1, 288, -1, -1, -1, -1, -1, -1, 295, -1, + -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 316, + -1, 318, 319, -1, -1, 322, -1, -1, 325, -1, + 327, -1, 329, 330, 331, 332, -1, 334, -1, -1, + -1, -1, -1, -1, 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 359, 360, 361, 362, 363, -1, -1, -1, -1, - -1, -1, -1, 371, -1, -1, -1, -1, -1, 377, - 378, 379, 380, -1, -1, -1, 384, -1, 386, -1, - -1, -1, -1, -1, 392, 393, -1, -1, -1, -1, - -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, - -1, -1, -1, 275, 276, 277, -1, 279, -1, 417, - 418, 419, 420, 285, -1, -1, 288, -1, -1, -1, - -1, -1, -1, 295, -1, -1, -1, -1, 300, -1, - 302, 303, 304, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 316, -1, 318, 319, -1, -1, - 322, -1, -1, 325, -1, 327, -1, 329, 330, 331, - 332, -1, 334, -1, -1, -1, -1, -1, -1, 341, - -1, -1, 344, 345, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 359, 360, 361, - 362, 363, -1, -1, -1, -1, -1, -1, -1, 371, - -1, -1, -1, -1, -1, 377, 378, 379, 380, -1, - -1, -1, 384, -1, 386, -1, -1, -1, -1, -1, - 392, 393, -1, -1, -1, -1, -1, -1, 264, 265, - -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, - 276, 277, -1, 279, -1, 417, 418, 419, 420, 285, - -1, -1, 288, -1, -1, -1, -1, -1, -1, 295, - -1, 261, -1, -1, 300, -1, 302, 303, 304, -1, + -1, -1, 359, 360, 361, 362, 363, -1, -1, -1, + -1, -1, -1, -1, 371, -1, -1, -1, -1, -1, + 377, 378, 379, 380, -1, -1, -1, 384, -1, 386, + -1, -1, -1, -1, -1, 392, 393, -1, -1, -1, + -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, + 271, -1, -1, -1, 275, 276, 277, -1, 279, -1, + 417, 418, 419, 420, 285, -1, -1, 288, -1, -1, + -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, + -1, 302, 303, 304, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, + -1, 322, -1, -1, 325, -1, 327, -1, 329, 330, + 331, 332, -1, 334, -1, -1, -1, -1, -1, -1, + 341, -1, -1, 344, 345, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 359, 360, + 361, 362, 363, -1, -1, -1, -1, -1, -1, -1, + 371, -1, -1, -1, -1, -1, 377, 378, 379, 380, + -1, -1, -1, 384, -1, 386, -1, -1, -1, -1, + -1, 392, 393, -1, -1, -1, -1, -1, -1, 264, + 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, + 275, 276, 277, -1, 279, -1, 417, 418, 419, 420, + 285, -1, -1, 288, -1, -1, -1, -1, -1, -1, + 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, -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, 316, -1, 318, 319, -1, -1, 322, -1, -1, + 325, -1, 327, -1, 329, 330, 331, 332, -1, 334, + -1, -1, -1, -1, -1, -1, 341, -1, -1, 344, + 345, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 359, 360, 361, 362, 363, -1, + -1, -1, -1, -1, -1, -1, 371, -1, -1, -1, + -1, -1, 377, 378, 379, 380, -1, -1, -1, 384, + -1, 386, -1, -1, -1, -1, -1, 392, 393, -1, + -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, + -1, 270, 271, -1, -1, -1, 275, 276, 277, -1, + 279, -1, 417, 418, 419, 420, 285, -1, -1, 288, + -1, -1, -1, -1, -1, -1, 295, -1, -1, -1, -1, 300, -1, 302, 303, 304, -1, -1, -1, -1, - 377, -1, -1, -1, -1, -1, -1, 316, -1, 318, + -1, -1, -1, -1, -1, -1, -1, 316, -1, 318, 319, -1, -1, 322, -1, -1, 325, -1, 327, -1, - 329, 330, 331, 332, -1, 334, -1, -1, 337, -1, - -1, -1, -1, -1, -1, 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, 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, + 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, - 296, 297, -1, 362, -1, 301, 302, -1, 261, 368, - 369, 307, -1, 309, 310, 311, 312, -1, -1, 272, - -1, 317, -1, -1, 277, 321, -1, 323, 281, -1, - -1, 284, -1, -1, -1, -1, -1, 333, -1, -1, - 336, -1, 338, 296, 297, -1, 342, -1, 301, 302, - 261, -1, -1, -1, 307, -1, 309, 310, 311, 312, - -1, -1, -1, -1, 317, -1, 362, -1, 321, -1, - 323, -1, 368, 284, -1, -1, -1, -1, -1, -1, - 333, -1, -1, 336, -1, 338, 297, -1, 261, 342, - -1, 302, -1, -1, -1, -1, 307, -1, 309, 310, - 311, 312, -1, -1, -1, -1, 317, -1, -1, 362, - 321, 284, -1, -1, -1, 368, -1, -1, -1, -1, - -1, -1, 333, -1, 297, 336, 261, 338, -1, 302, - -1, -1, -1, -1, 307, -1, 309, 310, 311, 312, - -1, -1, -1, -1, 317, -1, -1, -1, 321, 284, - -1, 362, -1, 364, 365, -1, -1, 368, -1, -1, - 333, -1, 297, 336, 261, 338, 263, 302, -1, -1, - -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, 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, -1, -1, 333, -1, 297, 336, - -1, 338, -1, 302, -1, -1, -1, -1, 307, -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, - 297, -1, -1, 362, 333, 302, -1, 336, -1, 338, + 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, 263, 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, -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, + 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, 261, 304, 305, -1, -1, + -1, -1, -1, -1, -1, -1, 272, -1, 316, -1, + 318, 277, -1, -1, 322, 281, -1, -1, 284, -1, + -1, 418, 330, 331, -1, -1, 334, -1, -1, -1, + 296, 297, -1, -1, -1, 301, 302, -1, -1, -1, + -1, 307, -1, 309, 310, 311, 312, -1, -1, -1, + -1, 317, -1, -1, -1, 321, -1, 323, -1, -1, + -1, -1, -1, -1, -1, 418, -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, -1, 261, -1, -1, 307, -1, 309, + 310, 311, 312, -1, -1, 272, -1, 317, -1, -1, + 277, 321, -1, 323, 281, -1, -1, 284, -1, -1, + -1, -1, -1, 333, -1, -1, 336, -1, 338, 296, + 297, -1, 342, -1, 301, 302, -1, 261, -1, -1, + 307, -1, 309, 310, 311, 312, -1, -1, 272, -1, + 317, -1, 362, 277, 321, -1, 323, 281, 368, 369, + 284, -1, -1, -1, -1, -1, 333, -1, -1, 336, + -1, 338, 296, 297, -1, 342, -1, 301, 302, 261, + -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, -1, -1, 317, -1, 362, -1, 321, -1, 323, + -1, 368, 284, -1, -1, -1, -1, -1, -1, 333, + -1, -1, 336, -1, 338, 297, -1, 261, 342, -1, + 302, -1, -1, -1, -1, 307, -1, 309, 310, 311, + 312, -1, -1, -1, -1, 317, -1, -1, 362, 321, + 284, -1, -1, -1, 368, -1, -1, -1, -1, -1, + -1, 333, -1, 297, 336, 261, 338, -1, 302, -1, + -1, -1, -1, 307, -1, 309, 310, 311, 312, -1, + -1, -1, -1, 317, -1, -1, -1, 321, 284, -1, + 362, -1, 364, 365, -1, -1, 368, -1, -1, 333, + -1, 297, 336, 261, 338, 263, 302, -1, -1, -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, 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, + 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, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 362, + -1, -1, 362, }; -#line 6611 "cs-parser.jay" +#line 6654 "cs-parser.jay" // // A class used to hold info about an operator declarator @@ -12870,17 +12925,12 @@ public Tokenizer Lexer { } } -static CSharpParser () -{ - oob_stack = new Stack (); -} - -public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file) - : this (reader, file, file.Compiler.Report) +public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, ParserSession session) + : this (reader, file, file.Compiler.Report, session) { } -public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Report report) +public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Report report, ParserSession session) { this.file = file; current_container = current_namespace = file; @@ -12893,22 +12943,16 @@ public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Re lang_version = settings.Version; yacc_verbose_flag = settings.VerboseParserFlag; doc_support = settings.DocumentationFile != null; - oob_stack.Clear (); - lexer = new Tokenizer (reader, file); - -#if FULL_AST - lbag = new LocationsBag (); -#else - lbag = null; -#endif - - use_global_stacks = true; + lexer = new Tokenizer (reader, file, session); + oob_stack = new Stack (); + lbag = session.LocationsBag; + use_global_stacks = session.UseJayGlobalArrays; + parameters_bucket = session.ParametersStack; } public void parse () { eof_token = Token.EOF; - Tokenizer.LocatedToken.Initialize (); try { if (yacc_verbose_flag > 1) @@ -12975,12 +13019,6 @@ Location GetLocation (object obj) return lexer.Location; } -public LocationsBag LocationsBag { - get { - return lbag; - } -} - void start_block (Location loc) { if (current_block == null) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay index 6e2e26750..1299f6d93 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay @@ -10,12 +10,7 @@ // // (C) 2001 Ximian, Inc (http://www.ximian.com) // (C) 2004-2011 Novell, Inc -// Copyright 2011 Xamarin Inc. -// -// TODO: -// (1) Figure out why error productions dont work. `type-declaration' is a -// great spot to put an `error' because you can reproduce it with this input: -// "public X { }" +// Copyright 2011-2012 Xamarin Inc. // using System.Text; @@ -81,7 +76,7 @@ namespace Mono.CSharp /// /// An out-of-band stack. /// - static Stack oob_stack; + Stack oob_stack; /// /// Controls the verbosity of the errors produced by the parser @@ -137,7 +132,7 @@ namespace Mono.CSharp // share the bucket for very common constructs which can never // be recursive // - static List parameters_bucket = new List (6); + List parameters_bucket; // // Full AST support members @@ -2669,6 +2664,22 @@ enum_member_declaration $$ = em; } + | opt_attributes IDENTIFIER error + { + Error_SyntaxError (yyToken); + + var lt = (Tokenizer.LocatedToken) $2; + var em = new EnumMember ((Enum) current_type, new MemberName (lt.Value, lt.Location), (Attributes) $1); + ((Enum) current_type).AddEnumMember (em); + + if (doc_support) { + em.DocComment = Lexer.consume_doc_comment (); + Lexer.doc_state = XmlCommentState.Allowed; + } + + $$ = em; + } + | attributes_without_members ; delegate_declaration @@ -3196,6 +3207,14 @@ invocation_expression $$ = new Invocation ((Expression) $1, (Arguments) $3); lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4)); } + | primary_expression open_parens_any argument_list error + { + Error_SyntaxError (yyToken); + + $$ = new Invocation ((Expression) $1, (Arguments) $3); + lbag.AddLocation ($$, GetLocation ($2)); + } + ; opt_object_or_collection_initializer @@ -3207,8 +3226,8 @@ object_or_collection_initializer : OPEN_BRACE opt_member_initializer_list close_brace_or_complete_completion { if ($2 == null) { - $$ = CollectionOrObjectInitializers.Empty; - // TODO: lbag + $$ = new CollectionOrObjectInitializers (new List (), GetLocation ($1)); + lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3)); } else { $$ = new CollectionOrObjectInitializers ((List) $2, GetLocation ($1)); lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3)); @@ -3279,7 +3298,8 @@ member_initializer | OPEN_BRACE CLOSE_BRACE { report.Error (1920, GetLocation ($1), "An element initializer cannot be empty"); - $$ = null; + $$ = new CollectionElementInitializer (new List (), GetLocation ($1)); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3327,6 +3347,7 @@ argument_list } | argument_list COMMA error { + lexer.putback (')'); // TODO: Wrong but what can I do Error_SyntaxError (yyToken); $$ = $1; } @@ -3955,18 +3976,18 @@ multiplicative_expression : prefixed_unary_expression | multiplicative_expression STAR prefixed_unary_expression { - $$ = new Binary (Binary.Operator.Multiply, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Multiply, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | multiplicative_expression DIV prefixed_unary_expression { - $$ = new Binary (Binary.Operator.Division, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Division, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | multiplicative_expression PERCENT prefixed_unary_expression { - $$ = new Binary (Binary.Operator.Modulus, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Modulus, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -3974,18 +3995,14 @@ additive_expression : multiplicative_expression | additive_expression PLUS multiplicative_expression { - $$ = new Binary (Binary.Operator.Addition, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Addition, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | additive_expression MINUS multiplicative_expression { - $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } - | parenthesized_expression MINUS multiplicative_expression - { - // Shift/Reduce conflict - $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3, GetLocation ($2)); - } | additive_expression AS type { $$ = new As ((Expression) $1, (Expression) $3, GetLocation ($2)); @@ -4000,13 +4017,13 @@ shift_expression : additive_expression | shift_expression OP_SHIFT_LEFT additive_expression { - $$ = new Binary (Binary.Operator.LeftShift, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LeftShift, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | shift_expression OP_SHIFT_RIGHT additive_expression { - $$ = new Binary (Binary.Operator.RightShift, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.RightShift, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4014,23 +4031,23 @@ relational_expression : shift_expression | relational_expression OP_LT shift_expression { - $$ = new Binary (Binary.Operator.LessThan, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LessThan, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | relational_expression OP_GT shift_expression { - $$ = new Binary (Binary.Operator.GreaterThan, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.GreaterThan, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | relational_expression OP_LE shift_expression { - $$ = new Binary (Binary.Operator.LessThanOrEqual, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LessThanOrEqual, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | relational_expression OP_GE shift_expression { - $$ = new Binary (Binary.Operator.GreaterThanOrEqual, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.GreaterThanOrEqual, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4038,13 +4055,13 @@ equality_expression : relational_expression | equality_expression OP_EQ relational_expression { - $$ = new Binary (Binary.Operator.Equality, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Equality, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | equality_expression OP_NE relational_expression { - $$ = new Binary (Binary.Operator.Inequality, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.Inequality, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4052,8 +4069,8 @@ and_expression : equality_expression | and_expression BITWISE_AND equality_expression { - $$ = new Binary (Binary.Operator.BitwiseAnd, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.BitwiseAnd, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4061,8 +4078,8 @@ exclusive_or_expression : and_expression | exclusive_or_expression CARRET and_expression { - $$ = new Binary (Binary.Operator.ExclusiveOr, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4070,8 +4087,8 @@ inclusive_or_expression : exclusive_or_expression | inclusive_or_expression BITWISE_OR exclusive_or_expression { - $$ = new Binary (Binary.Operator.BitwiseOr, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.BitwiseOr, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4079,8 +4096,8 @@ conditional_and_expression : inclusive_or_expression | conditional_and_expression OP_AND inclusive_or_expression { - $$ = new Binary (Binary.Operator.LogicalAnd, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LogicalAnd, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4088,8 +4105,8 @@ conditional_or_expression : conditional_and_expression | conditional_or_expression OP_OR conditional_and_expression { - $$ = new Binary (Binary.Operator.LogicalOr, - (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Binary (Binary.Operator.LogicalOr, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4100,7 +4117,8 @@ null_coalescing_expression if (lang_version < LanguageVersion.ISO_2) FeatureIsNotAvailable (GetLocation ($2), "null coalescing operator"); - $$ = new Nullable.NullCoalescingOperator ((Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new Nullable.NullCoalescingOperator ((Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4121,57 +4139,58 @@ conditional_expression assignment_expression : prefixed_unary_expression ASSIGN expression { - $$ = new SimpleAssign ((Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new SimpleAssign ((Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_MULT_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.Multiply, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.Multiply, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_DIV_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.Division, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.Division, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_MOD_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.Modulus, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.Modulus, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_ADD_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.Addition, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.Addition, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_SUB_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.Subtraction, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_SHIFT_LEFT_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.LeftShift, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.LeftShift, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_SHIFT_RIGHT_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.RightShift, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.RightShift, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_AND_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.BitwiseAnd, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.BitwiseAnd, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_OR_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.BitwiseOr, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.BitwiseOr, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } | prefixed_unary_expression OP_XOR_ASSIGN expression { - $$ = new CompoundAssign ( - Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $3, GetLocation ($2)); + $$ = new CompoundAssign (Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $3); + lbag.AddLocation ($$, GetLocation ($2)); } ; @@ -4965,7 +4984,7 @@ identifier_inside_body { if (async_block) { report.Error (4003, GetLocation ($1), "`await' cannot be used as an identifier within an async method or lambda expression"); - $$ = Tokenizer.LocatedToken.Create ("await", GetLocation ($1)); + $$ = new Tokenizer.LocatedToken ("await", GetLocation ($1)); } } ; @@ -5347,19 +5366,19 @@ while_statement do_statement : DO embedded_statement WHILE open_parens_any boolean_expression CLOSE_PARENS SEMICOLON { - $$ = new Do ((Statement) $2, (BooleanExpression) $5, GetLocation ($1)); + $$ = new Do ((Statement) $2, (BooleanExpression) $5, GetLocation ($1), GetLocation ($3)); lbag.AddStatement ($$, GetLocation ($3), GetLocation ($4), GetLocation ($6), GetLocation ($7)); } | DO embedded_statement error { Error_SyntaxError (yyToken); - $$ = new Do ((Statement) $2, null, GetLocation ($1)); + $$ = new Do ((Statement) $2, null, GetLocation ($1), Location.Null); } | DO embedded_statement WHILE open_parens_any boolean_expression error { Error_SyntaxError (yyToken); - $$ = new Do ((Statement) $2, (BooleanExpression) $5, GetLocation ($1)); + $$ = new Do ((Statement) $2, (BooleanExpression) $5, GetLocation ($1), GetLocation ($3)); lbag.AddStatement ($$, GetLocation ($3), GetLocation ($4)); } ; @@ -5414,6 +5433,7 @@ for_statement_condition { $$ = $4; } + | boolean_expression CLOSE_PARENS { report.Error (1525, GetLocation ($2), "Unexpected symbol ')', expected ';'"); For f = (For) $0; @@ -5627,6 +5647,11 @@ return_statement $$ = new Return ((Expression) $2, GetLocation ($1)); lbag.AddStatement ($$, GetLocation ($3)); } + | RETURN expression error + { + Error_SyntaxError (yyToken); + $$ = new Return ((Expression) $2, GetLocation ($1)); + } | RETURN error { Error_SyntaxError (yyToken); @@ -5664,6 +5689,24 @@ yield_statement $$ = new Yield ((Expression) $3, lt.Location); lbag.AddStatement ($$, GetLocation ($2), GetLocation ($4)); } + | identifier_inside_body RETURN expression error + { + Error_SyntaxError (yyToken); + + var lt = (Tokenizer.LocatedToken) $1; + string s = lt.Value; + if (s != "yield"){ + report.Error (1003, lt.Location, "; expected"); + } else if ($3 == null) { + report.Error (1627, GetLocation ($4), "Expression expected after yield return"); + } else if (lang_version == LanguageVersion.ISO_1){ + FeatureIsNotAvailable (lt.Location, "iterators"); + } + + current_block.Explicit.RegisterIteratorYield (); + $$ = new Yield ((Expression) $3, lt.Location); + lbag.AddStatement ($$, GetLocation ($2)); + } | identifier_inside_body BREAK SEMICOLON { var lt = (Tokenizer.LocatedToken) $1; @@ -6762,17 +6805,12 @@ public Tokenizer Lexer { } } -static CSharpParser () -{ - oob_stack = new Stack (); -} - -public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file) - : this (reader, file, file.Compiler.Report) +public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, ParserSession session) + : this (reader, file, file.Compiler.Report, session) { } -public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Report report) +public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Report report, ParserSession session) { this.file = file; current_container = current_namespace = file; @@ -6785,22 +6823,16 @@ public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Re lang_version = settings.Version; yacc_verbose_flag = settings.VerboseParserFlag; doc_support = settings.DocumentationFile != null; - oob_stack.Clear (); - lexer = new Tokenizer (reader, file); - -#if FULL_AST - lbag = new LocationsBag (); -#else - lbag = null; -#endif - - use_global_stacks = true; + lexer = new Tokenizer (reader, file, session); + oob_stack = new Stack (); + lbag = session.LocationsBag; + use_global_stacks = session.UseJayGlobalArrays; + parameters_bucket = session.ParametersStack; } public void parse () { eof_token = Token.EOF; - Tokenizer.LocatedToken.Initialize (); try { if (yacc_verbose_flag > 1) @@ -6867,12 +6899,6 @@ Location GetLocation (object obj) return lexer.Location; } -public LocationsBag LocationsBag { - get { - return lbag; - } -} - void start_block (Location loc) { if (current_block == null) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs index 35705d56e..f8926924e 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs @@ -16,6 +16,7 @@ using System.Text; using System.Collections.Generic; using System.Globalization; using System.Diagnostics; +using System.Collections; namespace Mono.CSharp { @@ -66,32 +67,62 @@ namespace Mono.CSharp } // - // This class has to be used in the parser only, it reuses token - // details after each parse + // This class has to be used by parser only, it reuses token + // details after each file parse completion // public class LocatedToken { - int row, column; - string value; + public int row, column; + public string value; + public SourceFile file; - static LocatedToken[] buffer = new LocatedToken[0]; - static int pos; - - private LocatedToken () + public LocatedToken () { } - public static LocatedToken Create (int row, int column) + public LocatedToken (string value, Location loc) { - return Create (null, row, column); + this.value = value; + file = loc.SourceFile; + row = loc.Row; + column = loc.Column; } - public static LocatedToken Create (string value, Location loc) + public override string ToString () { - return Create (value, loc.Row, loc.Column); + return string.Format ("Token '{0}' at {1},{2}", Value, row, column); } - public static LocatedToken Create (string value, int row, int column) + public Location Location { + get { return new Location (file, row, column); } + } + + public string Value { + get { return value; } + } + } + + public class LocatedTokenBuffer + { + readonly LocatedToken[] buffer; + public int pos; + + public LocatedTokenBuffer () + { + buffer = new LocatedToken[0]; + } + + public LocatedTokenBuffer (LocatedToken[] buffer) + { + this.buffer = buffer ?? new LocatedToken[0]; + } + + public LocatedToken Create (SourceFile file, int row, int column) + { + return Create (null, file, row, column); + } + + public LocatedToken Create (string value, SourceFile file, int row, int column) { // // TODO: I am not very happy about the logic but it's the best @@ -105,15 +136,16 @@ namespace Mono.CSharp if (pos >= buffer.Length) { entry = new LocatedToken (); } else { - entry = buffer [pos]; + entry = buffer[pos]; if (entry == null) { entry = new LocatedToken (); - buffer [pos] = entry; + buffer[pos] = entry; } ++pos; } entry.value = value; + entry.file = file; entry.row = row; entry.column = column; return entry; @@ -123,31 +155,9 @@ namespace Mono.CSharp // Used for token not required by expression evaluator // [Conditional ("FULL_AST")] - public static void CreateOptional (int row, int col, ref object token) - { - token = Create (row, col); - } - - public static void Initialize () - { -#if !FULL_AST - if (buffer.Length == 0) - buffer = new LocatedToken [15000]; -#endif - pos = 0; - } - - public override string ToString () + public void CreateOptional (SourceFile file, int row, int col, ref object token) { - return string.Format ("Token '{0}' at {1},{2}", Value, row, column); - } - - public Location Location { - get { return new Location (row, column); } - } - - public string Value { - get { return value; } + token = Create (file, row, col); } } @@ -174,6 +184,7 @@ namespace Mono.CSharp readonly SeekableStreamReader reader; readonly CompilationSourceFile source_file; + public CompilationSourceFile SourceFile { get { return source_file; } } readonly CompilerContext context; SourceFile current_source; @@ -192,6 +203,7 @@ namespace Mono.CSharp List escaped_identifiers; int parsing_generic_less_than; readonly bool doc_processing; + readonly LocatedTokenBuffer ltb; // // Used mainly for parser optimizations. Some expressions for instance @@ -355,27 +367,15 @@ namespace Mono.CSharp // Stack ifstack; - const int max_id_size = 512; - const int max_number_size = 512; - -#if FULL_AST - readonly char [] id_builder = new char [max_id_size]; - - Dictionary[] identifiers = new Dictionary[max_id_size + 1]; + public const int MaxIdentifierLength = 512; + public const int MaxNumberLength = 512; - char [] number_builder = new char [max_number_size]; + readonly char[] id_builder; + readonly Dictionary[] identifiers; + readonly char[] number_builder; int number_pos; - char[] value_builder = new char[256]; -#else - static readonly char [] id_builder = new char [max_id_size]; - - static Dictionary[] identifiers = new Dictionary[max_id_size + 1]; - - static char [] number_builder = new char [max_number_size]; - static int number_pos; - static char[] value_builder = new char[256]; -#endif + char[] value_builder = new char[64]; public int Line { get { @@ -386,6 +386,15 @@ namespace Mono.CSharp } } + public int Column { + get { + return col; + } + set { + col = value; + } + } + // // This is used when the tokenizer needs to save // the current position as it needs to do some parsing @@ -430,11 +439,15 @@ namespace Mono.CSharp } } - public Tokenizer (SeekableStreamReader input, CompilationSourceFile file) + public Tokenizer (SeekableStreamReader input, CompilationSourceFile file, ParserSession session) { this.source_file = file; this.context = file.Compiler; this.current_source = file.SourceFile; + this.identifiers = session.Identifiers; + this.id_builder = session.IDBuilder; + this.number_builder = session.NumberBuilder; + this.ltb = new LocatedTokenBuffer (session.LocatedTokens); reader = input; @@ -444,8 +457,6 @@ namespace Mono.CSharp doc_processing = context.Settings.DocumentationFile != null; tab_size = context.Settings.TabSize; - - Mono.CSharp.Location.Push (current_source); } public void PushPosition () @@ -829,11 +840,13 @@ namespace Mono.CSharp PushPosition (); xtoken (); if (xtoken () != Token.ARROW) - res = -1; + goto default; PopPosition (); break; default: + // peek_token could overwrite id_buffer + id_builder [0] = 'a'; id_builder [1] = 's'; id_builder [2] = 'y'; id_builder [3] = 'n'; id_builder [4] = 'c'; res = -1; break; } @@ -891,7 +904,7 @@ namespace Mono.CSharp public Location Location { get { - return new Location (ref_line, col); + return new Location (current_source, ref_line, col); } } @@ -1104,9 +1117,14 @@ namespace Mono.CSharp start: int the_token = token (); if (the_token == Token.OPEN_BRACKET) { - do { + while (true) { the_token = token (); - } while (the_token != Token.CLOSE_BRACKET); + if (the_token == Token.EOF) + return true; + + if (the_token == Token.CLOSE_BRACKET) + break; + } the_token = token (); } else if (the_token == Token.IN || the_token == Token.OUT) { the_token = token (); @@ -1319,7 +1337,7 @@ namespace Mono.CSharp bool seen_digits = false; if (c != -1){ - if (number_pos == max_number_size) + if (number_pos == MaxNumberLength) Error_NumericConstantTooLong (); number_builder [number_pos++] = (char) c; } @@ -1330,7 +1348,7 @@ namespace Mono.CSharp // while ((d = peek_char2 ()) != -1){ if (d >= '0' && d <= '9'){ - if (number_pos == max_number_size) + if (number_pos == MaxNumberLength) Error_NumericConstantTooLong (); number_builder [number_pos++] = (char) d; get_char (); @@ -1595,23 +1613,23 @@ namespace Mono.CSharp if (c == 'e' || c == 'E'){ is_real = true; - if (number_pos == max_number_size) + if (number_pos == MaxNumberLength) Error_NumericConstantTooLong (); number_builder [number_pos++] = (char) c; c = get_char (); if (c == '+'){ - if (number_pos == max_number_size) + if (number_pos == MaxNumberLength) Error_NumericConstantTooLong (); number_builder [number_pos++] = '+'; c = -1; } else if (c == '-') { - if (number_pos == max_number_size) + if (number_pos == MaxNumberLength) Error_NumericConstantTooLong (); number_builder [number_pos++] = '-'; c = -1; } else { - if (number_pos == max_number_size) + if (number_pos == MaxNumberLength) Error_NumericConstantTooLong (); number_builder [number_pos++] = '+'; } @@ -1780,7 +1798,7 @@ namespace Mono.CSharp if (peek_char () == '\n') { putback_char = -1; } - + x = '\n'; advance_line (); } else if (x == '\n') { @@ -1791,6 +1809,26 @@ namespace Mono.CSharp return x; } + int get_char_withwithoutskippingwindowseol () + { + int x; + if (putback_char != -1) { + x = putback_char; + putback_char = -1; + } else { + x = reader.Read (); + } + + if (x == '\r') { + + } else if (x == '\n') { + advance_line (); + } else { + col++; + } + return x; + } + void advance_line () { line++; @@ -1816,13 +1854,10 @@ namespace Mono.CSharp public void putback (int c) { - if (putback_char != -1){ - Console.WriteLine ("Col: " + col); - Console.WriteLine ("Row: " + line); - Console.WriteLine ("Name: " + current_source.Name); - Console.WriteLine ("Current [{0}] putting back [{1}] ", putback_char, c); - throw new Exception ("This should not happen putback on putback"); + if (putback_char != -1) { + throw new InternalErrorException (string.Format ("Secondary putback [{0}] putting back [{1}] is not allowed", (char)putback_char, (char) c), Location); } + if (c == '\n' || col == 0) { // It won't happen though. line--; @@ -1963,7 +1998,7 @@ namespace Mono.CSharp } if (pos != 0) { - if (pos > max_id_size) + if (pos > MaxIdentifierLength) arg = new string (value_builder, 0, pos); else arg = InternIdentifier (value_builder, pos); @@ -1998,7 +2033,6 @@ namespace Mono.CSharp } //ref_line = line; - Location.Push (current_source); return true; } @@ -2085,7 +2119,6 @@ namespace Mono.CSharp if (new_file_name != null) { current_source = context.LookupFile (source_file, new_file_name); source_file.AddIncludeFile (current_source); - Location.Push (current_source); } if (!hidden_block_start.IsNull) { @@ -2183,6 +2216,8 @@ namespace Mono.CSharp // // The syntax is ` "foo.txt" "{guid}" "hash"' // + // guid is predefined hash algorithm guid {406ea660-64cf-4c82-b6f0-42d48172a799} for md5 + // int c = get_char (); if (c != '"') @@ -2245,6 +2280,7 @@ namespace Mono.CSharp // Any length of checksum List checksum_bytes = new List (16); + var checksum_location = Location; c = peek_char (); while (c != '"' && c != -1) { checksum_bytes.Add (read_hex (out error)); @@ -2260,14 +2296,23 @@ namespace Mono.CSharp return false; } - file.SetChecksum (guid_bytes, checksum_bytes.ToArray ()); - current_source.AutoGenerated = true; + if (context.Settings.GenerateDebugInfo) { + var chsum = checksum_bytes.ToArray (); + + if (file.HasChecksum) { + if (!ArrayComparer.IsEqual (file.Checksum, chsum)) { + // TODO: Report.SymbolRelatedToPreviousError + Report.Warning (1697, 1, checksum_location, "Different checksum values specified for file `{0}'", file.Name); + } + } + + file.SetChecksum (guid_bytes, chsum); + current_source.AutoGenerated = true; + } + return true; } -#if !FULL_AST - static -#endif bool IsTokenIdentifierEqual (char[] identifier) { for (int i = 0; i < identifier.Length; ++i) { @@ -2871,7 +2916,7 @@ namespace Mono.CSharp #endif while (true){ - c = get_char (); + c = get_char_withwithoutskippingwindowseol (); if (c == '"') { if (quoted && peek_char () == '"') { if (pos == value_builder.Length) @@ -3009,7 +3054,7 @@ namespace Mono.CSharp if (id_builder [0] >= '_' && !quoted) { int keyword = GetKeyword (id_builder, pos); if (keyword != -1) { - val = LocatedToken.Create (keyword == Token.AWAIT ? "await" : null, ref_line, column); + val = ltb.Create (keyword == Token.AWAIT ? "await" : null, current_source, ref_line, column); return keyword; } } @@ -3017,12 +3062,12 @@ namespace Mono.CSharp string s = InternIdentifier (id_builder, pos); #if FULL_AST if (quoted) { - val = LocatedToken.Create ("@" + s, ref_line, column - 1); + val = ltb.Create ("@" + s, current_source, ref_line, column - 1); } else { - val = LocatedToken.Create (s, ref_line, column); + val = ltb.Create (s, current_source, ref_line, column); } #else - val = LocatedToken.Create (s, ref_line, column); + val = ltb.Create (s, current_source, ref_line, column); #endif if (quoted && parsing_attribute_section) AddEscapedIdentifier (((LocatedToken) val).Location); @@ -3030,9 +3075,6 @@ namespace Mono.CSharp return Token.IDENTIFIER; } -#if !FULL_AST - static -#endif string InternIdentifier (char[] charBuffer, int length) { // @@ -3098,17 +3140,17 @@ namespace Mono.CSharp return consume_identifier (c); case '{': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); return Token.OPEN_BRACE; case '}': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); return Token.CLOSE_BRACE; case '[': // To block doccomment inside attribute declaration. if (doc_state == XmlCommentState.Allowed) doc_state = XmlCommentState.NotAllowed; - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); if (parsing_block == 0 || lambda_arguments_parsing) return Token.OPEN_BRACKET; @@ -3134,10 +3176,10 @@ namespace Mono.CSharp return Token.OPEN_BRACKET_EXPR; } case ']': - LocatedToken.CreateOptional (ref_line, col, ref val); + ltb.CreateOptional (current_source, ref_line, col, ref val); return Token.CLOSE_BRACKET; case '(': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); // // An expression versions of parens can appear in block context only // @@ -3182,29 +3224,29 @@ namespace Mono.CSharp return Token.OPEN_PARENS; case ')': - LocatedToken.CreateOptional (ref_line, col, ref val); + ltb.CreateOptional (current_source, ref_line, col, ref val); return Token.CLOSE_PARENS; case ',': - LocatedToken.CreateOptional (ref_line, col, ref val); + ltb.CreateOptional (current_source, ref_line, col, ref val); return Token.COMMA; case ';': - LocatedToken.CreateOptional (ref_line, col, ref val); + ltb.CreateOptional (current_source, ref_line, col, ref val); return Token.SEMICOLON; case '~': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); return Token.TILDE; case '?': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); return TokenizePossibleNullableType (); case '<': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); if (parsing_generic_less_than++ > 0) return Token.OP_GENERICS_LT; return TokenizeLessThan (); case '>': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); d = peek_char (); if (d == '=') { @@ -3231,7 +3273,7 @@ namespace Mono.CSharp return Token.OP_GT; case '+': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); d = peek_char (); if (d == '+') { d = Token.OP_INC; @@ -3244,7 +3286,7 @@ namespace Mono.CSharp return d; case '-': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); d = peek_char (); if (d == '-') { d = Token.OP_DEC; @@ -3259,15 +3301,15 @@ namespace Mono.CSharp return d; case '!': - val = LocatedToken.Create (ref_line, col); - if (peek_char () == '=') { + val = ltb.Create (current_source, ref_line, col); + if (peek_char () == '='){ get_char (); return Token.OP_NE; } return Token.BANG; case '=': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); d = peek_char (); if (d == '=') { get_char (); @@ -3281,7 +3323,7 @@ namespace Mono.CSharp return Token.ASSIGN; case '&': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); d = peek_char (); if (d == '&') { get_char (); @@ -3294,7 +3336,7 @@ namespace Mono.CSharp return Token.BITWISE_AND; case '|': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); d = peek_char (); if (d == '|') { get_char (); @@ -3307,8 +3349,8 @@ namespace Mono.CSharp return Token.BITWISE_OR; case '*': - val = LocatedToken.Create (ref_line, col); - if (peek_char () == '=') { + val = ltb.Create (current_source, ref_line, col); + if (peek_char () == '='){ get_char (); return Token.OP_MULT_ASSIGN; } @@ -3316,8 +3358,8 @@ namespace Mono.CSharp case '/': d = peek_char (); - if (d == '=') { - val = LocatedToken.Create (ref_line, col); + if (d == '='){ + val = ltb.Create (current_source, ref_line, col); get_char (); return Token.OP_DIV_ASSIGN; } @@ -3426,11 +3468,11 @@ namespace Mono.CSharp update_formatted_doc_comment (current_comment_start); continue; } - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); return Token.DIV; case '%': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); if (peek_char () == '='){ get_char (); return Token.OP_MOD_ASSIGN; @@ -3438,7 +3480,7 @@ namespace Mono.CSharp return Token.PERCENT; case '^': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); if (peek_char () == '='){ get_char (); return Token.OP_XOR_ASSIGN; @@ -3446,7 +3488,7 @@ namespace Mono.CSharp return Token.CARRET; case ':': - val = LocatedToken.Create (ref_line, col); + val = ltb.Create (current_source, ref_line, col); if (peek_char () == ':') { get_char (); return Token.DOUBLE_COLON; @@ -3470,7 +3512,7 @@ namespace Mono.CSharp if (d >= '0' && d <= '9') return is_number (c); - LocatedToken.CreateOptional (ref_line, col, ref val); + ltb.CreateOptional (current_source, ref_line, col, ref val); return Token.DOT; case '#': diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs index 2d2dcf8ff..11eca1e7e 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/decl.cs @@ -608,7 +608,7 @@ namespace Mono.CSharp { if (al == Modifiers.PRIVATE) { var decl = mc.Parent; do { - same_access_restrictions = decl.CurrentType == p_parent; + same_access_restrictions = decl.CurrentType.MemberDefinition == p_parent.MemberDefinition; } while (!same_access_restrictions && !decl.PartialContainer.IsTopLevel && (decl = decl.Parent) != null); } @@ -945,6 +945,15 @@ namespace Mono.CSharp { GenericTask = 1 << 22 } + // + // Some flags can be copied directly from other member + // + protected const StateFlags SharedStateFlags = + StateFlags.CLSCompliant | StateFlags.CLSCompliant_Undetected | + StateFlags.Obsolete | StateFlags.Obsolete_Undetected | + StateFlags.MissingDependency | StateFlags.MissingDependency_Undetected | + StateFlags.HasDynamicElement; + protected Modifiers modifiers; public StateFlags state; protected IMemberDefinition definition; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs index f0781401b..f2923aa5b 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/delegate.cs @@ -520,8 +520,11 @@ namespace Mono.CSharp { } TypeSpec rt = delegate_method.ReturnType; + if (rt.BuiltinType == BuiltinTypeSpec.Type.Dynamic) + rt = ec.BuiltinTypes.Object; + if (!Delegate.IsTypeCovariant (ec, rt, invoke_method.ReturnType)) { - Expression ret_expr = new TypeExpression (rt, loc); + Expression ret_expr = new TypeExpression (delegate_method.ReturnType, loc); Error_ConversionFailed (ec, delegate_method, ret_expr); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs index e988178c4..6cc53d505 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/doc.cs @@ -47,6 +47,8 @@ namespace Mono.CSharp // Dictionary StoredDocuments = new Dictionary (); + ParserSession session; + public DocumentationBuilder (ModuleContainer module) { doc_module = new ModuleContainer (module.Compiler); @@ -324,12 +326,18 @@ namespace Mono.CSharp var encoding = module.Compiler.Settings.Encoding; var s = new MemoryStream (encoding.GetBytes (cref)); - SeekableStreamReader seekable = new SeekableStreamReader (s, encoding); - var source_file = new CompilationSourceFile (doc_module); + var source_file = new CompilationSourceFile (doc_module, mc.Location.SourceFile); var report = new Report (doc_module.Compiler, new NullReportPrinter ()); - var parser = new CSharpParser (seekable, source_file, report); + if (session == null) + session = new ParserSession () { + UseJayGlobalArrays = true + }; + + SeekableStreamReader seekable = new SeekableStreamReader (s, encoding, session.StreamReaderBuffer); + + var parser = new CSharpParser (seekable, source_file, report, session); ParsedParameters = null; ParsedName = null; ParsedBuiltinType = null; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs index e86263da6..5f2ac1e74 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/driver.cs @@ -20,6 +20,7 @@ using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; +using System.Threading; namespace Mono.CSharp { @@ -41,7 +42,7 @@ namespace Mono.CSharp } } - void tokenize_file (SourceFile sourceFile, ModuleContainer module) + void tokenize_file (SourceFile sourceFile, ModuleContainer module, ParserSession session) { Stream input; @@ -56,7 +57,7 @@ namespace Mono.CSharp SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding); var file = new CompilationSourceFile (module, sourceFile); - Tokenizer lexer = new Tokenizer (reader, file); + Tokenizer lexer = new Tokenizer (reader, file, session); int token, tokens = 0, errors = 0; while ((token = lexer.token ()) != Token.EOF){ @@ -77,49 +78,97 @@ namespace Mono.CSharp Location.Initialize (sources); + var session = new ParserSession () { + UseJayGlobalArrays = true, + LocatedTokens = new Tokenizer.LocatedToken[15000] + }; + for (int i = 0; i < sources.Count; ++i) { if (tokenize_only) { - tokenize_file (sources[i], module); + tokenize_file (sources[i], module, session); } else { - Parse (sources[i], module); + Parse (sources[i], module, session, Report); } } } - public void Parse (SourceFile file, ModuleContainer module) +#if false + void ParseParallel (ModuleContainer module) + { + var sources = module.Compiler.SourceFiles; + + Location.Initialize (sources); + + var pcount = Environment.ProcessorCount; + var threads = new Thread[System.Math.Max (2, pcount - 1)]; + + for (int i = 0; i < threads.Length; ++i) { + var t = new Thread (l => { + var session = new ParserSession () { + //UseJayGlobalArrays = true, + }; + + var report = new Report (ctx, Report.Printer); // TODO: Implement flush at once printer + + for (int ii = (int) l; ii < sources.Count; ii += threads.Length) { + Parse (sources[ii], module, session, report); + } + + // TODO: Merge warning regions + }); + + t.Start (i); + threads[i] = t; + } + + for (int t = 0; t < threads.Length; ++t) { + threads[t].Join (); + } + } +#endif + + public void Parse (SourceFile file, ModuleContainer module, ParserSession session, Report report) { Stream input; try { input = File.OpenRead (file.Name); } catch { - Report.Error (2001, "Source file `{0}' could not be found", file.Name); + report.Error (2001, "Source file `{0}' could not be found", file.Name); return; } // Check 'MZ' header if (input.ReadByte () == 77 && input.ReadByte () == 90) { - Report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name); + report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name); input.Close (); return; } input.Position = 0; - SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding); + SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding, session.StreamReaderBuffer); + + Parse (reader, file, module, session, report); + + if (ctx.Settings.GenerateDebugInfo && report.Errors == 0 && !file.HasChecksum) { + input.Position = 0; + var checksum = session.GetChecksumAlgorithm (); + file.SetChecksum (checksum.ComputeHash (input)); + } - Parse (reader, file, module); reader.Dispose (); input.Close (); } - public static CSharpParser Parse(SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module, int lineModifier = 0) + public static CSharpParser Parse (SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module, ParserSession session, Report report, int lineModifier = 0, int colModifier = 0) { var file = new CompilationSourceFile (module, sourceFile); module.AddTypeContainer(file); - CSharpParser parser = new CSharpParser (reader, file); + CSharpParser parser = new CSharpParser (reader, file, report, session); parser.Lexer.Line += lineModifier; + parser.Lexer.Column += colModifier; parser.Lexer.sbag = new SpecialsBag (); parser.parse (); return parser; @@ -347,7 +396,8 @@ namespace Mono.CSharp tr.Stop (TimeReporter.TimerType.CloseTypes); tr.Start (TimeReporter.TimerType.Resouces); - assembly.EmbedResources (); + if (!settings.WriteMetadataOnly) + assembly.EmbedResources (); tr.Stop (TimeReporter.TimerType.Resouces); if (Report.Errors > 0) @@ -369,6 +419,7 @@ namespace Mono.CSharp public ModuleContainer ModuleCompiled { get; set; } public LocationsBag LocationsBag { get; set; } public SpecialsBag SpecialsBag { get; set; } + public IEnumerable Conditionals { get; set; } public object LastYYValue { get; set; } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs index c9cea6927..b9d6967dc 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/dynamic.cs @@ -502,7 +502,7 @@ namespace Mono.CSharp 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); + Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc); init.Emit (ec); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs index 4ccc3c3e9..cf1de9483 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/ecore.cs @@ -2277,9 +2277,11 @@ namespace Mono.CSharp { } } + var report = ctx.Module.Compiler.Report; + var retval = ctx.LookupNamespaceOrType (Name, Arity, LookupMode.IgnoreAccessibility, loc); if (retval != null) { - ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (retval.Type); + report.SymbolRelatedToPreviousError (retval.Type); ErrorIsInaccesible (ctx, retval.GetSignatureForError (), loc); return; } @@ -2290,7 +2292,17 @@ namespace Mono.CSharp { return; } - NamespaceContainer.Error_NamespaceNotFound (loc, Name, ctx.Module.Compiler.Report); + var ns_candidates = ctx.Module.GlobalRootNamespace.FindTypeNamespaces (ctx, Name, Arity); + if (ns_candidates != null) { + string usings = string.Join ("' or `", ns_candidates.ToArray ()); + report.Error (246, loc, + "The type or namespace name `{0}' could not be found. Are you missing `{1}' using directive?", + Name, usings); + } else { + report.Error (246, loc, + "The type or namespace name `{0}' could not be found. Are you missing an assembly reference?", + Name); + } } public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext ec) @@ -2401,7 +2413,7 @@ namespace Mono.CSharp { } else { break; } - } else if (me is MethodGroupExpr) { + } else if (me is MethodGroupExpr || me is PropertyExpr || me is IndexerExpr) { // Leave it to overload resolution to report correct error } else { // TODO: rc.Report.SymbolRelatedToPreviousError () @@ -2777,8 +2789,14 @@ namespace Mono.CSharp { } } - // TODO: For now we do it for any hoisted call even if it's needed for - // hoisted stories only but that requires a new expression wrapper + // + // When base access is used inside anonymous method/iterator/etc we need to + // get back to the context of original type. We do it by emiting proxy + // method in original class and rewriting base call to this compiler + // generated method call which does the actual base invocation. This may + // introduce redundant storey but with `this' only but it's tricky to avoid + // at this stage as we don't know what expressions follow base + // if (rc.CurrentAnonymousMethod != null) { if (targs == null && method.IsGeneric) { targs = method.TypeArguments; @@ -2792,8 +2810,9 @@ namespace Mono.CSharp { // Ideally this should apply to any proxy rewrite but in the case of unary mutators on // get/set member expressions second call would fail to proxy because left expression - // would be of 'this' and not 'base' - if (rc.CurrentType.IsStruct) + // would be of 'this' and not 'base' because we share InstanceExpression for get/set + // FIXME: The async check is another hack but will probably fail with mutators + if (rc.CurrentType.IsStruct || rc.CurrentAnonymousMethod.Storey is AsyncTaskStorey) InstanceExpression = new This (loc).Resolve (rc); } @@ -2967,7 +2986,7 @@ namespace Mono.CSharp { "An object reference is required to access non-static member `{0}'", GetSignatureForError ()); - InstanceExpression = new CompilerGeneratedThis (type, loc).Resolve (rc); + InstanceExpression = new CompilerGeneratedThis (rc.CurrentType, loc).Resolve (rc); return false; } @@ -2993,12 +3012,15 @@ namespace Mono.CSharp { if (me != null) { me.ResolveInstanceExpression (rc, rhs); - var fe = me as FieldExpr; - if (fe != null && fe.IsMarshalByRefAccess (rc)) { - rc.Report.SymbolRelatedToPreviousError (me.DeclaringType); - rc.Report.Warning (1690, 1, loc, - "Cannot call methods, properties, or indexers on `{0}' because it is a value type member of a marshal-by-reference class", - me.GetSignatureForError ()); + // Using this check to detect probing instance expression resolve + if (!rc.OmitStructFlowAnalysis) { + var fe = me as FieldExpr; + if (fe != null && fe.IsMarshalByRefAccess (rc)) { + rc.Report.SymbolRelatedToPreviousError (me.DeclaringType); + rc.Report.Warning (1690, 1, loc, + "Cannot call methods, properties, or indexers on `{0}' because it is a value type member of a marshal-by-reference class", + me.GetSignatureForError ()); + } } return true; @@ -3166,8 +3188,12 @@ namespace Mono.CSharp { } var me = ExtensionExpression as MemberExpr; - if (me != null) + if (me != null) { me.ResolveInstanceExpression (ec, null); + var fe = me as FieldExpr; + if (fe != null) + fe.Spec.MemberDefinition.SetIsUsed (); + } InstanceExpression = null; return this; @@ -3437,11 +3463,35 @@ namespace Mono.CSharp { best_candidate_return = best_candidate.ReturnType; } + if (best_candidate.IsGeneric && TypeParameterSpec.HasAnyTypeParameterConstrained (best_candidate.GenericDefinition)) { + ConstraintChecker cc = new ConstraintChecker (ec); + cc.CheckAll (best_candidate.GetGenericMethodDefinition (), best_candidate.TypeArguments, best_candidate.Constraints, loc); + } + + // + // Additional check for possible imported base override method which + // could not be done during IsOverrideMethodBaseTypeAccessible + // + if (best_candidate.IsVirtual && (best_candidate.DeclaringType.Modifiers & Modifiers.PROTECTED) != 0 && + best_candidate.MemberDefinition.IsImported && !best_candidate.DeclaringType.IsAccessible (ec)) { + ec.Report.SymbolRelatedToPreviousError (best_candidate); + ErrorIsInaccesible (ec, best_candidate.GetSignatureForError (), loc); + } + return this; } public override MemberExpr ResolveMemberAccess (ResolveContext ec, Expression left, SimpleName original) { + var fe = left as FieldExpr; + if (fe != null) { + // + // Using method-group on struct fields makes the struct assigned. I am not sure + // why but that's what .net does + // + fe.Spec.MemberDefinition.SetIsAssigned (); + } + simple_name = original; return base.ResolveMemberAccess (ec, left, original); } @@ -3587,7 +3637,6 @@ namespace Mono.CSharp { TypeSpec best_candidate_return_type; SessionReportPrinter lambda_conv_msgs; - ReportPrinter prev_recorder; public OverloadResolver (IList members, Restrictions restrictions, Location loc) : this (members, null, restrictions, loc) @@ -3720,7 +3769,9 @@ namespace Mono.CSharp { if (!TypeSpecComparer.Equals (p_m.Parameters.Types, q_m.Parameters.Types)) return 0; + var orig_p = p; p = p_m.ReturnType; + var orig_q = q; q = q_m.ReturnType; // @@ -3737,14 +3788,14 @@ namespace Mono.CSharp { return p.Kind != MemberKind.Void ? 1: 0; } + var am = (AnonymousMethodExpression) a.Expr; + // // When anonymous method is an asynchronous, and P has a return type Task, and Q has a return type Task // better conversion is performed between underlying types Y1 and Y2 // if (p.IsGenericTask || q.IsGenericTask) { - var async_am = a.Expr as AnonymousMethodExpression; - if (async_am != null && async_am.Block.IsAsync) { - + if (am.Block.IsAsync) { if (p.IsGenericTask != q.IsGenericTask) { return 0; } @@ -3752,6 +3803,19 @@ namespace Mono.CSharp { q = q.TypeArguments[0]; p = p.TypeArguments[0]; } + } else if (q != p) { + // + // LAMESPEC: Lambda expression returning dynamic type has identity (better) conversion to delegate returning object type + // + if (q.BuiltinType == BuiltinTypeSpec.Type.Object) { + var am_rt = am.InferReturnType (ec, null, orig_q); + if (am_rt != null && am_rt.BuiltinType == BuiltinTypeSpec.Type.Dynamic) + return 2; + } else if (p.BuiltinType == BuiltinTypeSpec.Type.Object) { + var am_rt = am.InferReturnType (ec, null, orig_p); + if (am_rt != null && am_rt.BuiltinType == BuiltinTypeSpec.Type.Dynamic) + return 1; + } } // @@ -4030,6 +4094,32 @@ namespace Mono.CSharp { return false; } + static bool CheckInflatedArguments (MethodSpec ms) + { + if (!TypeParameterSpec.HasAnyTypeParameterTypeConstrained (ms.GenericDefinition)) + return true; + + // Setup constraint checker for probing only + ConstraintChecker cc = new ConstraintChecker (null); + + var mp = ms.Parameters.Types; + for (int i = 0; i < mp.Length; ++i) { + var type = mp[i] as InflatedTypeSpec; + if (type == null) + continue; + + var targs = type.TypeArguments; + if (targs.Length == 0) + continue; + + // TODO: Checking inflated MVAR arguments should be enough + if (!cc.CheckAll (type.GetDefinition (), targs, type.Constraints, Location.Null)) + return false; + } + + return true; + } + public static void Error_ConstructorMismatch (ResolveContext rc, TypeSpec type, int argCount, Location loc) { rc.Report.Error (1729, loc, @@ -4045,6 +4135,7 @@ namespace Mono.CSharp { // // A return value rates candidate method compatibility, // 0 = the best, int.MaxValue = the worst + // -1 = fatal error // int IsApplicable (ResolveContext ec, ref Arguments arguments, int arg_count, ref MemberSpec candidate, IParametersMember pm, ref bool params_expanded_form, ref bool dynamicArgument, ref TypeSpec returnType) { @@ -4166,15 +4257,24 @@ namespace Mono.CSharp { arg_count = arguments.Count; } + // + // Don't do any expensive checks when the candidate cannot succeed + // + if (arg_count != param_count && !cpd.HasParams) + return (param_count - arg_count) * 2 + 1; + + var dep = candidate.GetMissingDependencies (); + if (dep != null) { + ImportedTypeDefinition.Error_MissingDependency (ec, dep, loc); + return -1; + } + // // 1. Handle generic method using type arguments when specified or type inference // TypeSpec[] ptypes; var ms = candidate as MethodSpec; if (ms != null && ms.IsGeneric) { - // Setup constraint checker for probing only - ConstraintChecker cc = new ConstraintChecker (null); - if (type_arguments != null) { var g_args_count = ms.Arity; if (g_args_count != type_arguments.Count) @@ -4182,31 +4282,50 @@ namespace Mono.CSharp { ms = ms.MakeGenericMethod (ec, type_arguments.Arguments); } else { - // TODO: It should not be here (we don't know yet whether any argument is lambda) but - // for now it simplifies things. I should probably add a callback to ResolveContext + // + // Deploy custom error reporting for infered anonymous expression or lambda methods. When + // probing lambda methods keep all errors reported in separate set and once we are done and no best + // candidate was found use the set to report more details about what was wrong with lambda body. + // The general idea is to distinguish between code errors and errors caused by + // trial-and-error type inference + // if (lambda_conv_msgs == null) { - lambda_conv_msgs = new SessionReportPrinter (); - prev_recorder = ec.Report.SetPrinter (lambda_conv_msgs); + for (int i = 0; i < arg_count; i++) { + Argument a = arguments[i]; + if (a == null) + continue; + + var am = a.Expr as AnonymousMethodExpression; + if (am != null) { + if (lambda_conv_msgs == null) + lambda_conv_msgs = new SessionReportPrinter (); + + am.TypeInferenceReportPrinter = lambda_conv_msgs; + } + } } var ti = new TypeInference (arguments); TypeSpec[] i_args = ti.InferMethodArguments (ec, ms); - lambda_conv_msgs.EndSession (); if (i_args == null) return ti.InferenceScore - 20000; + // + // Clear any error messages when the result was success + // + if (lambda_conv_msgs != null) + lambda_conv_msgs.ClearSession (); + if (i_args.Length != 0) { ms = ms.MakeGenericMethod (ec, i_args); } - - cc.IgnoreInferredDynamic = true; } // // Type arguments constraints have to match for the method to be applicable // - if (!cc.CheckAll (ms.GetGenericMethodDefinition (), ms.TypeArguments, ms.Constraints, loc)) { + if (!CheckInflatedArguments (ms)) { candidate = ms; return int.MaxValue - 25000; } @@ -4403,28 +4522,11 @@ namespace Mono.CSharp { if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (restrictions & Restrictions.CovariantDelegate) == 0) return -1; - // - // Deploy custom error reporting for lambda methods. When probing lambda methods - // keep all errors reported in separate set and once we are done and no best - // candidate was found, this set is used to report more details about what was wrong - // with lambda body - // - if (argument.Expr.Type == InternalType.AnonymousMethod) { - if (lambda_conv_msgs == null) { - lambda_conv_msgs = new SessionReportPrinter (); - prev_recorder = ec.Report.SetPrinter (lambda_conv_msgs); - } - } - // // Use implicit conversion in all modes to return same candidates when the expression // is used as argument or delegate conversion // if (!Convert.ImplicitConversionExists (ec, argument.Expr, parameter)) { - if (lambda_conv_msgs != null) { - lambda_conv_msgs.EndSession (); - } - return 2; } } @@ -4450,7 +4552,7 @@ namespace Mono.CSharp { return p; if (specific == ac_q.Element) return q; - } else if (TypeManager.IsGenericType (p)) { + } else if (p.IsGeneric && q.IsGeneric) { var pargs = TypeManager.GetTypeArguments (p); var qargs = TypeManager.GetTypeArguments (q); @@ -4494,147 +4596,148 @@ namespace Mono.CSharp { bool error_mode = false; MemberSpec invocable_member = null; - // Be careful, cannot return until error reporter is restored while (true) { best_candidate = null; best_candidate_rate = int.MaxValue; var type_members = members; - try { + do { + for (int i = 0; i < type_members.Count; ++i) { + var member = type_members[i]; - do { - for (int i = 0; i < type_members.Count; ++i) { - var member = type_members[i]; + // + // Methods in a base class are not candidates if any method in a derived + // class is applicable + // + if ((member.Modifiers & Modifiers.OVERRIDE) != 0) + continue; + + if (!error_mode) { + if (!member.IsAccessible (rc)) + continue; + if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (rc)) + continue; + + if ((member.Modifiers & (Modifiers.PROTECTED | Modifiers.STATIC)) == Modifiers.PROTECTED && + instance_qualifier != null && !instance_qualifier.CheckProtectedMemberAccess (rc, member)) { + continue; + } + } + + IParametersMember pm = member as IParametersMember; + if (pm == null) { // - // Methods in a base class are not candidates if any method in a derived - // class is applicable + // Will use it later to report ambiguity between best method and invocable member // - if ((member.Modifiers & Modifiers.OVERRIDE) != 0) - continue; + if (Invocation.IsMemberInvocable (member)) + invocable_member = member; - if (!error_mode) { - if (!member.IsAccessible (rc)) - continue; + continue; + } - if (rc.IsRuntimeBinder && !member.DeclaringType.IsAccessible (rc)) - continue; + // + // Overload resolution is looking for base member but using parameter names + // and default values from the closest member. That means to do expensive lookup + // for the closest override for virtual or abstract members + // + if ((member.Modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT)) != 0) { + var override_params = base_provider.GetOverrideMemberParameters (member); + if (override_params != null) + pm = override_params; + } - if ((member.Modifiers & (Modifiers.PROTECTED | Modifiers.STATIC)) == Modifiers.PROTECTED && - instance_qualifier != null && !instance_qualifier.CheckProtectedMemberAccess (rc, member)) { + // + // Check if the member candidate is applicable + // + bool params_expanded_form = false; + bool dynamic_argument = false; + TypeSpec rt = pm.MemberType; + int candidate_rate = IsApplicable (rc, ref candidate_args, args_count, ref member, pm, ref params_expanded_form, ref dynamic_argument, ref rt); + + if (lambda_conv_msgs != null) + lambda_conv_msgs.EndSession (); + + // + // How does it score compare to others + // + if (candidate_rate < best_candidate_rate) { + + // Fatal error (missing dependency), cannot continue + if (candidate_rate < 0) + return null; + + best_candidate_rate = candidate_rate; + best_candidate = member; + best_candidate_args = candidate_args; + best_candidate_params = params_expanded_form; + best_candidate_dynamic = dynamic_argument; + best_parameter_member = pm; + best_candidate_return_type = rt; + } else if (candidate_rate == 0) { + // + // The member look is done per type for most operations but sometimes + // it's not possible like for binary operators overload because they + // are unioned between 2 sides + // + if ((restrictions & Restrictions.BaseMembersIncluded) != 0) { + if (TypeSpec.IsBaseClass (best_candidate.DeclaringType, member.DeclaringType, true)) continue; - } } - IParametersMember pm = member as IParametersMember; - if (pm == null) { + bool is_better; + if (best_candidate.DeclaringType.IsInterface && member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) { // - // Will use it later to report ambiguity between best method and invocable member + // We pack all interface members into top level type which makes the overload resolution + // more complicated for interfaces. We compensate it by removing methods with same + // signature when building the cache hence this path should not really be hit often // - if (Invocation.IsMemberInvocable (member)) - invocable_member = member; + // Example: + // interface IA { void Foo (int arg); } + // interface IB : IA { void Foo (params int[] args); } + // + // IB::Foo is the best overload when calling IB.Foo (1) + // + is_better = true; + if (ambiguous_candidates != null) { + foreach (var amb_cand in ambiguous_candidates) { + if (member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) { + continue; + } - continue; - } + is_better = false; + break; + } - // - // Overload resolution is looking for base member but using parameter names - // and default values from the closest member. That means to do expensive lookup - // for the closest override for virtual or abstract members - // - if ((member.Modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT)) != 0) { - var override_params = base_provider.GetOverrideMemberParameters (member); - if (override_params != null) - pm = override_params; + if (is_better) + ambiguous_candidates = null; + } + } else { + // Is the new candidate better + is_better = BetterFunction (rc, candidate_args, member, pm.Parameters, params_expanded_form, best_candidate, best_parameter_member.Parameters, best_candidate_params); } - // - // Check if the member candidate is applicable - // - bool params_expanded_form = false; - bool dynamic_argument = false; - TypeSpec rt = pm.MemberType; - int candidate_rate = IsApplicable (rc, ref candidate_args, args_count, ref member, pm, ref params_expanded_form, ref dynamic_argument, ref rt); - - // - // How does it score compare to others - // - if (candidate_rate < best_candidate_rate) { - best_candidate_rate = candidate_rate; + if (is_better) { best_candidate = member; best_candidate_args = candidate_args; best_candidate_params = params_expanded_form; best_candidate_dynamic = dynamic_argument; best_parameter_member = pm; best_candidate_return_type = rt; - } else if (candidate_rate == 0) { - // - // The member look is done per type for most operations but sometimes - // it's not possible like for binary operators overload because they - // are unioned between 2 sides - // - if ((restrictions & Restrictions.BaseMembersIncluded) != 0) { - if (TypeSpec.IsBaseClass (best_candidate.DeclaringType, member.DeclaringType, true)) - continue; - } - - bool is_better; - if (best_candidate.DeclaringType.IsInterface && member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) { - // - // We pack all interface members into top level type which makes the overload resolution - // more complicated for interfaces. We compensate it by removing methods with same - // signature when building the cache hence this path should not really be hit often - // - // Example: - // interface IA { void Foo (int arg); } - // interface IB : IA { void Foo (params int[] args); } - // - // IB::Foo is the best overload when calling IB.Foo (1) - // - is_better = true; - if (ambiguous_candidates != null) { - foreach (var amb_cand in ambiguous_candidates) { - if (member.DeclaringType.ImplementsInterface (best_candidate.DeclaringType, false)) { - continue; - } - - is_better = false; - break; - } - - if (is_better) - ambiguous_candidates = null; - } - } else { - // Is the new candidate better - is_better = BetterFunction (rc, candidate_args, member, pm.Parameters, params_expanded_form, best_candidate, best_parameter_member.Parameters, best_candidate_params); - } + } else { + // It's not better but any other found later could be but we are not sure yet + if (ambiguous_candidates == null) + ambiguous_candidates = new List (); - if (is_better) { - best_candidate = member; - best_candidate_args = candidate_args; - best_candidate_params = params_expanded_form; - best_candidate_dynamic = dynamic_argument; - best_parameter_member = pm; - best_candidate_return_type = rt; - } else { - // It's not better but any other found later could be but we are not sure yet - if (ambiguous_candidates == null) - ambiguous_candidates = new List (); - - ambiguous_candidates.Add (new AmbiguousCandidate (member, pm.Parameters, params_expanded_form)); - } + ambiguous_candidates.Add (new AmbiguousCandidate (member, pm.Parameters, params_expanded_form)); } - - // Restore expanded arguments - if (candidate_args != args) - candidate_args = args; } - } while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null); - } finally { - if (prev_recorder != null) - rc.Report.SetPrinter (prev_recorder); - } + + // Restore expanded arguments + if (candidate_args != args) + candidate_args = args; + } + } while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null); // // We've found exact match @@ -4685,6 +4788,17 @@ namespace Mono.CSharp { args [0].Type.GetSignatureForError (), best_candidate.Name, best_candidate.GetSignatureForError ()); } + // + // Check type constraints only when explicit type arguments are used + // + if (best_candidate.IsGeneric && type_arguments != null) { + MethodSpec bc = best_candidate as MethodSpec; + if (bc != null && TypeParameterSpec.HasAnyTypeParameterConstrained (bc.GenericDefinition)) { + ConstraintChecker cc = new ConstraintChecker (rc); + cc.CheckAll (bc.GetGenericMethodDefinition (), bc.TypeArguments, bc.Constraints, loc); + } + } + BestCandidateIsDynamic = true; return null; } @@ -4744,11 +4858,6 @@ namespace Mono.CSharp { if (oa != null && !rc.IsObsolete) AttributeTester.Report_ObsoleteMessage (oa, best_candidate.GetSignatureForError (), loc, rc.Report); - var dep = best_candidate.GetMissingDependencies (); - if (dep != null) { - ImportedTypeDefinition.Error_MissingDependency (rc, dep, loc); - } - best_candidate.MemberDefinition.SetIsUsed (); args = best_candidate_args; @@ -4825,9 +4934,8 @@ namespace Mono.CSharp { return; } - if (lambda_conv_msgs != null) { - if (lambda_conv_msgs.Merge (rc.Report.Printer)) - return; + if (lambda_conv_msgs != null && lambda_conv_msgs.Merge (rc.Report.Printer)) { + return; } @@ -5217,14 +5325,25 @@ namespace Mono.CSharp { public override Expression CreateExpressionTree (ResolveContext ec) { + return CreateExpressionTree (ec, true); + } + + public Expression CreateExpressionTree (ResolveContext ec, bool convertInstance) + { + Arguments args; Expression instance; + if (InstanceExpression == null) { instance = new NullLiteral (loc); - } else { + } else if (convertInstance) { instance = InstanceExpression.CreateExpressionTree (ec); + } else { + args = new Arguments (1); + args.Add (new Argument (InstanceExpression)); + instance = CreateExpressionFactoryCall (ec, "Constant", args); } - Arguments args = Arguments.CreateForExpressionTree (ec, null, + args = Arguments.CreateForExpressionTree (ec, null, instance, CreateTypeOfExpression ()); @@ -5238,6 +5357,8 @@ namespace Mono.CSharp { protected override Expression DoResolve (ResolveContext ec) { + spec.MemberDefinition.SetIsUsed (); + return DoResolve (ec, null); } @@ -5279,7 +5400,7 @@ namespace Mono.CSharp { if (lvalue_instance && var != null && var.VariableInfo != null) { var.VariableInfo.SetStructFieldAssigned (ec, Name); } - + if (fb != null) { IFixedExpression fe = InstanceExpression as IFixedExpression; if (!ec.HasSet (ResolveContext.Options.FixedInitializerScope) && (fe == null || !fe.IsFixed)) { @@ -5457,8 +5578,6 @@ namespace Mono.CSharp { { bool is_volatile = (spec.Modifiers & Modifiers.VOLATILE) != 0; - spec.MemberDefinition.SetIsUsed (); - if (IsStatic){ if (is_volatile) ec.Emit (OpCodes.Volatile); @@ -6046,7 +6165,7 @@ namespace Mono.CSharp { GetSignatureForError ()); } else { rc.Report.SymbolRelatedToPreviousError (best_candidate.Set); - ErrorIsInaccesible (rc, best_candidate.Set.GetSignatureForError (), loc); + ErrorIsInaccesible (rc, best_candidate.GetSignatureForError (), loc); } } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs index 8b4a348a6..0d1264516 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/eval.cs @@ -79,7 +79,7 @@ namespace Mono.CSharp module = new ModuleContainer (ctx); module.Evaluator = this; - source_file = new CompilationSourceFile (module); + source_file = new CompilationSourceFile (module, null); module.AddTypeContainer (source_file); startup_files = ctx.SourceFiles.Count; @@ -115,9 +115,10 @@ namespace Mono.CSharp Location.Initialize (ctx.SourceFiles); + var parser_session = new ParserSession (); for (int i = 0; i < startup_files; ++i) { var sf = ctx.SourceFiles [i]; - d.Parse (sf, module); + d.Parse (sf, module, parser_session, ctx.Report); } } @@ -442,7 +443,7 @@ namespace Mono.CSharp // InputKind ToplevelOrStatement (SeekableStreamReader seekable) { - Tokenizer tokenizer = new Tokenizer (seekable, source_file); + Tokenizer tokenizer = new Tokenizer (seekable, source_file, new ParserSession ()); int t = tokenizer.token (); switch (t){ @@ -571,7 +572,7 @@ namespace Mono.CSharp seekable.Position = 0; source_file.DeclarationFound = false; - CSharpParser parser = new CSharpParser (seekable, source_file); + CSharpParser parser = new CSharpParser (seekable, source_file, new ParserSession ()); if (kind == InputKind.StatementOrExpression){ parser.Lexer.putback_char = Tokenizer.EvalStatementParserCharacter; @@ -976,7 +977,9 @@ namespace Mono.CSharp static public string help { get { return "Static methods:\n" + +#if !NET_2_1 " Describe (object); - Describes the object's type\n" + +#endif " LoadPackage (package); - Loads the given Package (like -pkg:FILE)\n" + " LoadAssembly (assembly); - Loads the given assembly (like -r:ASSEMBLY)\n" + " ShowVars (); - Shows defined local variables.\n" + diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs index 3091426b4..458df5c49 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/expression.cs @@ -1211,7 +1211,7 @@ namespace Mono.CSharp var one = new IntConstant (ec.BuiltinTypes, 1, loc); var op = IsDecrement ? Binary.Operator.Subtraction : Binary.Operator.Addition; - operation = new Binary (op, source, one, loc); + operation = new Binary (op, source, one); operation = operation.Resolve (ec); if (operation == null) throw new NotImplementedException ("should not be reached"); @@ -1527,7 +1527,7 @@ namespace Mono.CSharp // Turn is check into simple null check for implicitly convertible reference types // return ReducedExpression.Create ( - new Binary (Binary.Operator.Inequality, expr, new NullLiteral (loc), loc).Resolve (ec), + new Binary (Binary.Operator.Inequality, expr, new NullLiteral (loc)).Resolve (ec), this).Resolve (ec); } @@ -2014,7 +2014,7 @@ namespace Mono.CSharp // b = b.left >> b.right & (0x1f|0x3f) // b.right = new Binary (Operator.BitwiseAnd, - b.right, new IntConstant (ec.BuiltinTypes, right_mask, b.right.Location), b.loc).Resolve (ec); + b.right, new IntConstant (ec.BuiltinTypes, right_mask, b.right.Location)).Resolve (ec); // // Expression tree representation does not use & mask @@ -2202,19 +2202,19 @@ namespace Mono.CSharp protected State state; Expression enum_conversion; - public Binary (Operator oper, Expression left, Expression right, bool isCompound, Location loc) - : this (oper, left, right, loc) + public Binary (Operator oper, Expression left, Expression right, bool isCompound) + : this (oper, left, right) { if (isCompound) state |= State.Compound; } - public Binary (Operator oper, Expression left, Expression right, Location loc) + public Binary (Operator oper, Expression left, Expression right) { this.oper = oper; this.left = left; this.right = right; - this.loc = loc; + this.loc = left.Location; } #region Properties @@ -2319,7 +2319,7 @@ namespace Mono.CSharp public static void Error_OperatorCannotBeApplied (ResolveContext ec, Expression left, Expression right, Operator oper, Location loc) { - new Binary (oper, left, right, loc).Error_OperatorCannotBeApplied (ec, left, right); + new Binary (oper, left, right).Error_OperatorCannotBeApplied (ec, left, right); } public static void Error_OperatorCannotBeApplied (ResolveContext ec, Expression left, Expression right, string oper, Location loc) @@ -3031,7 +3031,7 @@ namespace Mono.CSharp (TypeSpec.IsValueType (left.Type) && right is NullLiteral) || (right.Type.IsNullableType && (left is NullLiteral || left.Type.IsNullableType || TypeSpec.IsValueType (left.Type))) || (TypeSpec.IsValueType (right.Type) && left is NullLiteral))) { - var lifted = new Nullable.LiftedBinaryOperator (oper, left, right, loc); + var lifted = new Nullable.LiftedBinaryOperator (oper, left, right); lifted.state = state; return lifted.Resolve (ec); } @@ -4409,7 +4409,7 @@ namespace Mono.CSharp // TODO: Should be the checks resolve context sensitive? ResolveContext rc = new ResolveContext (ec.MemberContext, ResolveContext.Options.UnsafeScope); - right = new Binary (Binary.Operator.Multiply, right, right_const, loc).Resolve (rc); + right = new Binary (Binary.Operator.Multiply, right, right_const).Resolve (rc); if (right == null) return; } @@ -5264,8 +5264,10 @@ namespace Mono.CSharp { this.expr = expr; this.arguments = arguments; - if (expr != null) - loc = expr.Location; + if (expr != null) { + var ma = expr as MemberAccess; + loc = ma != null ? ma.GetLeftExpressionLocation () : expr.Location; + } } #region Properties @@ -6154,7 +6156,7 @@ namespace Mono.CSharp { if (initializers != null && bounds == null) { // - // We use this to store all the date values in the order in which we + // We use this to store all the data values in the order in which we // will need to store them in the byte blob later // array_data = new List (); @@ -6212,7 +6214,16 @@ namespace Mono.CSharp ec.Report.Error (623, loc, "Array initializers can only be used in a variable or field initializer. Try using a new expression instead"); return false; } - + + // When we don't have explicitly specified dimensions, record whatever dimension we first encounter at each level + if (!bounds.ContainsKey(idx + 1)) + bounds[idx + 1] = sub_probe.Count; + + if (bounds[idx + 1] != sub_probe.Count) { + ec.Report.Error(847, sub_probe.Location, "An array initializer of length `{0}' was expected", bounds[idx + 1].ToString()); + return false; + } + bool ret = CheckIndices (ec, sub_probe, idx + 1, specified_dims, child_bounds - 1); if (!ret) return false; @@ -6987,7 +6998,7 @@ namespace Mono.CSharp if (variable_info == null) return; - if (rc.HasSet (ResolveContext.Options.OmitStructFlowAnalysis)) + if (rc.OmitStructFlowAnalysis) return; if (!variable_info.IsAssigned (rc)) { @@ -7932,6 +7943,18 @@ namespace Mono.CSharp expr.Error_OperatorCannotBeApplied (rc, loc, ".", type); } + public Location GetLeftExpressionLocation () + { + Expression expr = LeftExpression; + MemberAccess ma = expr as MemberAccess; + while (ma != null && ma.LeftExpression != null) { + expr = ma.LeftExpression; + ma = expr as MemberAccess; + } + + return expr == null ? Location : expr.Location; + } + public static bool IsValidDotExpression (TypeSpec type) { const MemberKind dot_kinds = MemberKind.Class | MemberKind.Struct | MemberKind.Delegate | MemberKind.Enum | @@ -8252,9 +8275,19 @@ namespace Mono.CSharp { if (ec.Module.Compiler.Settings.Version > LanguageVersion.ISO_2 && !ec.IsRuntimeBinder && MethodGroupExpr.IsExtensionMethodArgument (expr)) { ec.Report.SymbolRelatedToPreviousError (type); + + var cand = ec.Module.GlobalRootNamespace.FindExtensionMethodNamespaces (ec, type, name, Arity); + string missing; + // a using directive or an assembly reference + if (cand != null) { + missing = "`" + string.Join ("' or `", cand.ToArray ()) + "' using directive"; + } else { + missing = "an assembly reference"; + } + ec.Report.Error (1061, loc, - "Type `{0}' does not contain a definition for `{1}' and no extension method `{1}' of type `{0}' could be found (are you missing a using directive or an assembly reference?)", - type.GetSignatureForError (), name); + "Type `{0}' does not contain a definition for `{1}' and no extension method `{1}' of type `{0}' could be found. Are you missing {2}?", + type.GetSignatureForError (), name, missing); return; } @@ -9461,7 +9494,7 @@ namespace Mono.CSharp this.left = left; this.spec = spec; - this.loc = spec.Location; + this.loc = left.Location; } public override TypeSpec ResolveAsType (IMemberContext ec) @@ -9843,6 +9876,9 @@ namespace Mono.CSharp // class CollectionElementInitializer : Invocation { + public readonly bool IsSingle; + + public class ElementInitializerArgument : Argument { public ElementInitializerArgument (Expression e) @@ -9870,6 +9906,7 @@ namespace Mono.CSharp public CollectionElementInitializer (Expression argument) : base (null, new Arguments (1)) { + IsSingle = true; base.arguments.Add (new ElementInitializerArgument (argument)); this.loc = argument.Location; } @@ -9877,6 +9914,7 @@ namespace Mono.CSharp public CollectionElementInitializer (List arguments, Location loc) : base (null, new Arguments (arguments.Count)) { + IsSingle = false; foreach (Expression e in arguments) base.arguments.Add (new ElementInitializerArgument (e)); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs index d38ecc945..580b192a6 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/field.cs @@ -640,13 +640,12 @@ namespace Mono.CSharp } if (initializer != null) { - Parent.RegisterFieldForInitialization (this, - new FieldInitializer (spec, initializer, this)); + Parent.RegisterFieldForInitialization (this, new FieldInitializer (this, initializer, TypeExpression.Location)); } if (declarators != null) { - var t = new TypeExpression (MemberType, TypeExpression.Location); foreach (var d in declarators) { + var t = new TypeExpression (MemberType, d.Name.Location); var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes); if (d.Initializer != null) f.initializer = d.Initializer; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs index 6f1b92cbe..9bf70dc76 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/generic.cs @@ -737,6 +737,12 @@ namespace Mono.CSharp { } } + public bool HasAnyTypeConstraint { + get { + return (spec & (SpecialConstraint.Class | SpecialConstraint.Struct)) != 0 || ifaces != null || targs != null || HasTypeConstraint; + } + } + public bool HasTypeConstraint { get { var bt = BaseType.BuiltinType; @@ -1226,6 +1232,30 @@ namespace Mono.CSharp { return false; } + public static bool HasAnyTypeParameterTypeConstrained (IGenericMethodDefinition md) + { + var tps = md.TypeParameters; + for (int i = 0; i < md.TypeParametersCount; ++i) { + if (tps[i].HasAnyTypeConstraint) { + return true; + } + } + + return false; + } + + public static bool HasAnyTypeParameterConstrained (IGenericMethodDefinition md) + { + var tps = md.TypeParameters; + for (int i = 0; i < md.TypeParametersCount; ++i) { + if (tps[i].IsConstrained) { + return true; + } + } + + return false; + } + public override TypeSpec Mutate (TypeParameterMutator mutator) { return mutator.Mutate (this); @@ -1488,7 +1518,9 @@ namespace Mono.CSharp { if (targs == null) throw new ArgumentNullException ("targs"); -// this.state = openType.state; + this.state &= ~SharedStateFlags; + this.state |= (openType.state & SharedStateFlags); + this.context = context; this.open_type = openType; this.targs = targs; @@ -2222,29 +2254,14 @@ namespace Mono.CSharp { struct ConstraintChecker { IMemberContext mc; - bool ignore_inferred_dynamic; bool recursive_checks; public ConstraintChecker (IMemberContext ctx) { this.mc = ctx; - ignore_inferred_dynamic = false; recursive_checks = false; } - #region Properties - - public bool IgnoreInferredDynamic { - get { - return ignore_inferred_dynamic; - } - set { - ignore_inferred_dynamic = value; - } - } - - #endregion - // // Checks the constraints of open generic type against type // arguments. This version is used for types which could not be @@ -2289,14 +2306,11 @@ namespace Mono.CSharp { // // Checks all type arguments againts type parameters constraints - // NOTE: It can run in probing mode when `mc' is null + // NOTE: It can run in probing mode when `this.mc' is null // public bool CheckAll (MemberSpec context, TypeSpec[] targs, TypeParameterSpec[] tparams, Location loc) { for (int i = 0; i < tparams.Length; i++) { - if (ignore_inferred_dynamic && targs[i].BuiltinType == BuiltinTypeSpec.Type.Dynamic) - continue; - var targ = targs[i]; if (!CheckConstraint (context, targ, tparams [i], loc)) return false; @@ -2342,15 +2356,6 @@ namespace Mono.CSharp { // Check the class constraint // if (tparam.HasTypeConstraint) { - var dep = tparam.BaseType.GetMissingDependencies (); - if (dep != null) { - if (mc == null) - return false; - - ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc); - ok = false; - } - if (!CheckConversion (mc, context, atype, tparam, tparam.BaseType, loc)) { if (mc == null) return false; @@ -2364,19 +2369,6 @@ namespace Mono.CSharp { // if (tparam.Interfaces != null) { foreach (TypeSpec iface in tparam.Interfaces) { - var dep = iface.GetMissingDependencies (); - if (dep != null) { - if (mc == null) - return false; - - ImportedTypeDefinition.Error_MissingDependency (mc, dep, loc); - ok = false; - - // return immediately to avoid duplicate errors because we are scanning - // expanded interface list - return false; - } - if (!CheckConversion (mc, context, atype, tparam, iface, loc)) { if (mc == null) return false; @@ -2466,14 +2458,6 @@ namespace Mono.CSharp { return true; } - // - // When partial/full type inference finds a dynamic type argument delay - // the constraint check to runtime, it can succeed for real underlying - // dynamic type - // - if (ignore_inferred_dynamic && HasDynamicTypeArgument (ttype.TypeArguments)) - return true; - if (mc != null) { mc.Module.Compiler.Report.SymbolRelatedToPreviousError (tparam); if (atype.IsGenericParameter) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs index 541a407fa..605db44fb 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/import.cs @@ -90,7 +90,7 @@ namespace Mono.CSharp if (cad.Count > 0) { foreach (var ca in cad) { var dt = ca.Constructor.DeclaringType; - if (dt.Name != "DynamicAttribute" && dt.Namespace != CompilerServicesNamespace) + if (dt.Name != "DynamicAttribute" || dt.Namespace != CompilerServicesNamespace) continue; if (ca.ConstructorArguments.Count == 0) { @@ -390,18 +390,21 @@ namespace Mono.CSharp if ((mod & Modifiers.OVERRIDE) != 0) { bool is_real_override = false; if (kind == MemberKind.Method && declaringType.BaseType != null) { - var filter = MemberFilter.Method (name, tparams != null ? tparams.Length : 0, parameters, null); - var candidate = MemberCache.FindMember (declaringType.BaseType, filter, BindingRestriction.None); - - // - // For imported class method do additional validation to be sure that metadata - // override flag was correct - // - // Difference between protected internal and protected is ok - // - const Modifiers conflict_mask = Modifiers.AccessibilityMask & ~Modifiers.INTERNAL; - if (candidate != null && (candidate.Modifiers & conflict_mask) == (mod & conflict_mask) && !candidate.IsStatic) { - is_real_override = true; + var btype = declaringType.BaseType; + if (IsOverrideMethodBaseTypeAccessible (btype)) { + var filter = MemberFilter.Method (name, tparams != null ? tparams.Length : 0, parameters, null); + var candidate = MemberCache.FindMember (btype, filter, BindingRestriction.None); + + // + // For imported class method do additional validation to be sure that metadata + // override flag was correct + // + // Difference between protected internal and protected is ok + // + const Modifiers conflict_mask = Modifiers.AccessibilityMask & ~Modifiers.INTERNAL; + if (candidate != null && (candidate.Modifiers & conflict_mask) == (mod & conflict_mask) && !candidate.IsStatic) { + is_real_override = true; + } } } @@ -434,6 +437,30 @@ namespace Mono.CSharp return ms; } + bool IsOverrideMethodBaseTypeAccessible (TypeSpec baseType) + { + switch (baseType.Modifiers & Modifiers.AccessibilityMask) { + case Modifiers.PUBLIC: + return true; + case Modifiers.INTERNAL: + // + // Check whether imported method in base type is accessible from compiled + // context + // + return baseType.MemberDefinition.IsInternalAsPublic (module.DeclaringAssembly); + case Modifiers.PRIVATE: + return false; + default: + // protected + // protected internal + // + // Method accessibility checks will be done later based on context + // where the method is called (CS0122 error will be reported for inaccessible) + // + return true; + } + } + // // Imports System.Reflection parameters // @@ -835,6 +862,13 @@ namespace Mono.CSharp import_cache.Add (type, spec); + if (kind == MemberKind.TypeParameter) { + if (canImportBaseType) + ImportTypeParameterTypeConstraints ((TypeParameterSpec) spec, type); + + return spec; + } + // // Two stage setup as the base type can be inflated declaring type or // another nested type inside same declaring type which has not been @@ -992,7 +1026,6 @@ namespace Mono.CSharp ImportTypeParameterTypeConstraints (tp, tp.GetMetaInfo ()); } } - } protected void ImportTypes (MetaType[] types, Namespace targetNamespace, bool hasExtensionTypes) @@ -1796,7 +1829,15 @@ namespace Mono.CSharp // or referenced from the user core in which case compilation error has to // be reported because compiler cannot continue anyway // - foreach (var t in types) { + for (int i = 0; i < types.Count; ++i) { + var t = types [i]; + + // + // Report missing types only once per type + // + if (i > 0 && types.IndexOf (t) < i) + continue; + string name = t.GetSignatureForError (); if (t.MemberDefinition.DeclaringAssembly == ctx.Module.DeclaringAssembly) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs index 2586eada9..665981ca7 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/iterators.cs @@ -972,7 +972,9 @@ namespace Mono.CSharp method.Block.IsCompilerGenerated = true; method.Block.AddStatement (new TryFinallyBlockProxyStatement (this, block)); - storey.AddMember (method); + // Cannot it add to storey because it'd be emitted before nested + // anonoymous methods which could capture shared variable + return method; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs index 337c378e5..e3cbf6dd1 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs @@ -52,13 +52,15 @@ namespace Mono.CSharp } } + static readonly byte[] MD5Algorith = { 96, 166, 110, 64, 207, 100, 130, 76, 182, 240, 66, 212, 129, 114, 167, 153 }; + public readonly string Name; public readonly string FullPathName; public readonly int Index; public bool AutoGenerated; SourceFileEntry file; - byte[] guid, checksum; + byte[] algGuid, checksum; List hidden_lines; public SourceFile (string name, string path, int index) @@ -68,15 +70,32 @@ namespace Mono.CSharp this.FullPathName = path; } + public byte[] Checksum { + get { + return checksum; + } + } + + public bool HasChecksum { + get { + return checksum != null; + } + } + public SourceFileEntry SourceFileEntry { get { return file; } } - public void SetChecksum (byte[] guid, byte[] checksum) + public void SetChecksum (byte[] checksum) { - this.guid = guid; + SetChecksum (MD5Algorith, checksum); + } + + public void SetChecksum (byte[] algorithmGuid, byte[] checksum) + { + this.algGuid = algorithmGuid; this.checksum = checksum; } @@ -85,13 +104,9 @@ namespace Mono.CSharp if (hidden_lines != null) hidden_lines.Sort (); - if (guid != null) { - file = new SourceFileEntry (symwriter, FullPathName, guid, checksum); - } else { - file = new SourceFileEntry (symwriter, FullPathName); - if (AutoGenerated) - file.SetAutoGenerated (); - } + file = new SourceFileEntry (symwriter, FullPathName, algGuid, checksum); + if (AutoGenerated) + file.SetAutoGenerated (); return file; } @@ -177,7 +192,6 @@ namespace Mono.CSharp const int max_column = column_mask; static List source_list; - static int current_source; static Checkpoint [] checkpoints; static int checkpoint_index; @@ -192,7 +206,6 @@ namespace Mono.CSharp public static void Reset () { source_list = new List (); - current_source = 0; checkpoint_index = 0; } @@ -220,13 +233,7 @@ namespace Mono.CSharp checkpoints [0] = new Checkpoint (0, 0); } - static public void Push (SourceFile file) - { - current_source = file != null ? file.Index : -1; - // File is always pushed before being changed. - } - - public Location (int row, int column) + public Location (SourceFile file, int row, int column) { if (row <= 0) token = 0; @@ -237,6 +244,9 @@ namespace Mono.CSharp long target = -1; long delta = 0; + // TODO: For eval only, need better handling of empty + int file_index = file == null ? 0 : file.Index; + // FIXME: This value is certainly wrong but what was the intension int max = checkpoint_index < 10 ? checkpoint_index : 10; @@ -245,13 +255,13 @@ namespace Mono.CSharp delta = row - offset; if (delta >= 0 && delta < (1 << line_delta_bits) && - checkpoints [checkpoint_index - i].File == current_source) { + checkpoints[checkpoint_index - i].File == file_index) { target = checkpoint_index - i; break; } } if (target == -1) { - AddCheckpoint (current_source, row); + AddCheckpoint (file_index, row); target = checkpoint_index; delta = row % (1 << line_delta_bits); } @@ -269,7 +279,7 @@ namespace Mono.CSharp public static Location operator - (Location loc, int columns) { - return new Location (loc.Row, loc.Column - columns); + return new Location (loc.SourceFile, loc.Row, loc.Column - columns); } static void AddCheckpoint (int file, int row) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs index 5374da9db..9ff316886 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/membercache.cs @@ -435,12 +435,15 @@ namespace Mono.CSharp { // A special method to work with member lookup only. It returns a list of all members named @name // starting from @container. It's very performance sensitive // - public static IList FindMembers (TypeSpec container, string name, bool declaredOnly) + // declaredOnlyClass cannot be used interfaces. Manual filtering is required because names are + // compacted + // + public static IList FindMembers (TypeSpec container, string name, bool declaredOnlyClass) { IList applicable; do { - if (container.MemberCache.member_hash.TryGetValue (name, out applicable) || declaredOnly) + if (container.MemberCache.member_hash.TryGetValue (name, out applicable) || declaredOnlyClass) return applicable; container = container.BaseType; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs index 5f15beb0b..a1560a508 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/method.cs @@ -496,6 +496,20 @@ namespace Mono.CSharp { missing.AddRange (m); } + if (Arity > 0) { + foreach (var tp in GenericDefinition.TypeParameters) { + var m = tp.GetMissingDependencies (); + + if (m == null) + continue; + + if (missing == null) + missing = new List (); + + missing.AddRange (m); + } + } + return missing; } @@ -1199,6 +1213,9 @@ namespace Mono.CSharp { block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, Location); ModFlags |= Modifiers.DEBUGGER_HIDDEN; } + + if (Compiler.Settings.WriteMetadataOnly) + block = null; } if ((ModFlags & Modifiers.STATIC) == 0) @@ -1287,10 +1304,18 @@ namespace Mono.CSharp { } } - base.Emit (); - + if (block != null && block.StateMachine != null) { + var psm = block.StateMachine is IteratorStorey ? + Module.PredefinedAttributes.IteratorStateMachine : + Module.PredefinedAttributes.AsyncStateMachine; + + psm.EmitAttribute (MethodBuilder, block.StateMachine); + } + if ((ModFlags & Modifiers.METHOD_EXTENSION) != 0) Module.PredefinedAttributes.Extension.EmitAttribute (MethodBuilder); + + base.Emit (); } catch { Console.WriteLine ("Internal compiler error at {0}: exception caught while emitting {1}", Location, MethodBuilder); @@ -1418,8 +1443,7 @@ namespace Mono.CSharp { base_ctor = ConstructorLookup (ec, type, ref argument_list, loc); } - // TODO MemberCache: Does it work for inflated types ? - if (base_ctor == caller_builder.Spec){ + if (base_ctor != null && base_ctor.MemberDefinition == caller_builder.Spec.MemberDefinition) { ec.Report.Error (516, loc, "Constructor `{0}' cannot call itself", caller_builder.GetSignatureForError ()); } @@ -1604,10 +1628,15 @@ namespace Mono.CSharp { Parent.MemberCache.AddMember (spec); - // It's here only to report an error - if (block != null && block.IsIterator) { - member_type = Compiler.BuiltinTypes.Void; - Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); + if (block != null) { + // It's here only to report an error + if (block.IsIterator) { + member_type = Compiler.BuiltinTypes.Void; + Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); + } + + if (Compiler.Settings.WriteMetadataOnly) + block = null; } return true; @@ -1643,14 +1672,14 @@ namespace Mono.CSharp { BlockContext bc = new BlockContext (this, block, Compiler.BuiltinTypes.Void); bc.Set (ResolveContext.Options.ConstructorScope); - // - // If we use a "this (...)" constructor initializer, then - // do not emit field initializers, they are initialized in the other constructor - // - if (!(Initializer is ConstructorThisInitializer)) - Parent.PartialContainer.ResolveFieldInitializers (bc); - if (block != null) { + // + // If we use a "this (...)" constructor initializer, then + // do not emit field initializers, they are initialized in the other constructor + // + if (!(Initializer is ConstructorThisInitializer)) + Parent.PartialContainer.ResolveFieldInitializers (bc); + if (!IsStatic) { if (Initializer == null) { if (Parent.PartialContainer.Kind == MemberKind.Struct) { @@ -1951,7 +1980,7 @@ namespace Mono.CSharp { // if ((flags & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) { implementing = null; - } else if (optional && (container.Interfaces == null || Array.IndexOf (container.Interfaces, implementing.DeclaringType) < 0)) { + } else if (optional && (container.Interfaces == null || !container.Definition.Interfaces.Contains (implementing.DeclaringType))) { // // We are not implementing interface when base class already implemented it // @@ -2142,6 +2171,16 @@ namespace Mono.CSharp { return true; } + public override bool Define () + { + base.Define (); + + if (Compiler.Settings.WriteMetadataOnly) + block = null; + + return true; + } + public override void Emit() { var base_type = Parent.PartialContainer.BaseType; @@ -2505,13 +2544,18 @@ namespace Mono.CSharp { if (!base.Define ()) return false; - if (block != null && block.IsIterator) { - // - // Current method is turned into automatically generated - // wrapper which creates an instance of iterator - // - Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); - ModFlags |= Modifiers.DEBUGGER_HIDDEN; + if (block != null) { + if (block.IsIterator) { + // + // Current method is turned into automatically generated + // wrapper which creates an instance of iterator + // + Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); + ModFlags |= Modifiers.DEBUGGER_HIDDEN; + } + + if (Compiler.Settings.WriteMetadataOnly) + block = null; } // imlicit and explicit operator of same types are not allowed diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs index 3117053fc..bf36e8f20 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/module.cs @@ -429,7 +429,7 @@ namespace Mono.CSharp base.EmitContainer (); - if (Compiler.Report.Errors == 0) + if (Compiler.Report.Errors == 0 && !Compiler.Settings.WriteMetadataOnly) VerifyMembers (); if (anonymous_types != null) { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs index c2d4f3040..9f448842f 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/namespace.cs @@ -41,6 +41,46 @@ namespace Mono.CSharp { report.Error (1681, loc, "The global extern alias cannot be redefined"); } + // + // For better error reporting where we try to guess missing using directive + // + public List FindTypeNamespaces (IMemberContext ctx, string name, int arity) + { + List res = null; + + foreach (var ns in all_namespaces) { + var type = ns.Value.LookupType (ctx, name, arity, LookupMode.Normal, Location.Null); + if (type != null) { + if (res == null) + res = new List (); + + res.Add (ns.Key); + } + } + + return res; + } + + // + // For better error reporting where compiler tries to guess missing using directive + // + public List FindExtensionMethodNamespaces (IMemberContext ctx, TypeSpec extensionType, string name, int arity) + { + List res = null; + + foreach (var ns in all_namespaces) { + var methods = ns.Value.LookupExtensionMethod (ctx, extensionType, name, arity); + if (methods != null) { + if (res == null) + res = new List (); + + res.Add (ns.Key); + } + } + + return res; + } + public void RegisterNamespace (Namespace child) { if (child != this) @@ -181,14 +221,51 @@ namespace Mono.CSharp { return; } + string assembly = null; + string possible_name = fullname + "." + name; + + // Only assembly unique name should be added + switch (possible_name) { + case "System.Drawing": + case "System.Web.Services": + case "System.Web": + case "System.Data": + case "System.Configuration": + case "System.Data.Services": + case "System.DirectoryServices": + case "System.Json": + case "System.Net.Http": + case "System.Numerics": + case "System.Runtime.Caching": + case "System.ServiceModel": + case "System.Transactions": + case "System.Web.Routing": + case "System.Xml.Linq": + case "System.Xml": + assembly = possible_name; + break; + + case "System.Linq": + case "System.Linq.Expressions": + assembly = "System.Core"; + break; + + case "System.Windows.Forms": + case "System.Windows.Forms.Layout": + assembly = "System.Windows.Name"; + break; + } + + assembly = assembly == null ? "an" : "`" + assembly + "'"; + if (this is GlobalRootNamespace) { ctx.Module.Compiler.Report.Error (400, loc, - "The type or namespace name `{0}' could not be found in the global namespace (are you missing an assembly reference?)", - name); + "The type or namespace name `{0}' could not be found in the global namespace. Are you missing {1} assembly reference?", + name, assembly); } else { ctx.Module.Compiler.Report.Error (234, loc, - "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing an assembly reference?", - name, GetSignatureForError ()); + "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing {2} assembly reference?", + name, GetSignatureForError (), assembly); } } @@ -209,10 +286,16 @@ namespace Mono.CSharp { ns_parent = this; } + return ns_parent.TryAddNamespace (name.Basename); + } + + Namespace TryAddNamespace (string name) + { Namespace ns; - if (!ns_parent.namespaces.TryGetValue (name.Basename, out ns)) { - ns = new Namespace (ns_parent, name.Basename); - ns_parent.namespaces.Add (name.Basename, ns); + + if (!namespaces.TryGetValue (name, out ns)) { + ns = new Namespace (this, name); + namespaces.Add (name, ns); } return ns; @@ -591,6 +674,14 @@ namespace Mono.CSharp { } } + public IEnumerable Conditionals { + get { + if (conditionals == null) + return Enumerable.Empty (); + return conditionals.Where (kv => kv.Value).Select (kv => kv.Key); + } + } + public string FileName { get { return file.Name; @@ -801,8 +892,10 @@ namespace Mono.CSharp { name = mn.Name; } + var names_container = Parent == null ? Module : (TypeContainer) this; + MemberCore mc; - if (defined_names.TryGetValue (name, out mc)) { + if (names_container.DefinedNames.TryGetValue (name, out mc)) { if (tc is NamespaceContainer && mc is NamespaceContainer) { containers.Add (tc); return; @@ -816,7 +909,7 @@ namespace Mono.CSharp { GetSignatureForError (), mn.GetSignatureForError ()); } } else { - defined_names.Add (name, tc); + names_container.DefinedNames.Add (name, tc); } base.AddTypeContainer (tc); @@ -1100,44 +1193,6 @@ namespace Mono.CSharp { return match; } - static void MsgtryRef (string s) - { - Console.WriteLine (" Try using -r:" + s); - } - - static void MsgtryPkg (string s) - { - Console.WriteLine (" Try using -pkg:" + s); - } - - public static void Error_NamespaceNotFound (Location loc, string name, Report Report) - { - Report.Error (246, loc, "The type or namespace name `{0}' could not be found. Are you missing a using directive or an assembly reference?", - name); - - switch (name) { - case "Gtk": case "GtkSharp": - MsgtryPkg ("gtk-sharp-2.0"); - break; - - case "Gdk": case "GdkSharp": - MsgtryPkg ("gdk-sharp-2.0"); - break; - - case "Glade": case "GladeSharp": - MsgtryPkg ("glade-sharp-2.0"); - break; - - case "System.Drawing": - case "System.Web.Services": - case "System.Web": - case "System.Data": - case "System.Windows.Forms": - MsgtryRef (name); - break; - } - } - protected override void DefineNamespace () { if (namespace_using_table == null) @@ -1180,11 +1235,23 @@ namespace Mono.CSharp { entry.Define (this); + // + // It's needed for repl only, when using clause cannot be resolved don't hold it in + // global list which is resolved for each evaluation + // + if (entry.ResolvedExpression == null) { + clauses.RemoveAt (i--); + continue; + } + Namespace using_ns = entry.ResolvedExpression as Namespace; if (using_ns == null) continue; if (list.Contains (using_ns)) { + // Ensure we don't report the warning multiple times in repl + clauses.RemoveAt (i--); + Compiler.Report.Warning (105, 3, entry.Location, "The using directive for `{0}' appeared previously in this namespace", using_ns.GetSignatureForError ()); } else { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs index 1e46767cf..d7a6c1638 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/nullable.cs @@ -539,8 +539,8 @@ namespace Mono.CSharp.Nullable Expression user_operator; MethodSpec wrap_ctor; - public LiftedBinaryOperator (Binary.Operator op, Expression left, Expression right, Location loc) - : base (op, left, right, loc) + public LiftedBinaryOperator (Binary.Operator op, Expression left, Expression right) + : base (op, left, right) { } @@ -583,7 +583,7 @@ namespace Mono.CSharp.Nullable Constant c = new BoolConstant (ec.BuiltinTypes, Oper == Operator.Inequality, loc); if ((Oper & Operator.EqualityMask) != 0) { - ec.Report.Warning (472, 2, loc, "The result of comparing value type `{0}' with null is `{1}'", + ec.Report.Warning (472, 2, loc, "The result of comparing value type `{0}' with null is always `{1}'", TypeManager.CSharpName (expr.Type), c.GetValueAsLiteral ()); } else { ec.Report.Warning (464, 2, loc, "The result of comparing type `{0}' with null is always `{1}'", @@ -1000,12 +1000,12 @@ namespace Mono.CSharp.Nullable { Expression left, right; Unwrap unwrap; - - public NullCoalescingOperator (Expression left, Expression right, Location loc) + + public NullCoalescingOperator (Expression left, Expression right) { this.left = left; this.right = right; - this.loc = loc; + this.loc = left.Location; } public Expression LeftExpression { diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/outline.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/outline.cs index 784cece95..7f21b8c4d 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/outline.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/outline.cs @@ -29,6 +29,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !NET_2_1 + using System; using System.Reflection; using System.Collections; @@ -88,9 +90,7 @@ public class Outline { OutlineParams (method.GetParameters ()); o.Write (")"); -#if NET_2_0 WriteGenericConstraints (t.GetGenericArguments ()); -#endif o.WriteLine (";"); return; @@ -119,9 +119,9 @@ public class Outline { if (underlyingType != typeof (int)) o.Write (" : {0}", FormatType (underlyingType)); } -#if NET_2_0 + WriteGenericConstraints (t.GetGenericArguments ()); -#endif + o.WriteLine (" {"); o.Indent++; @@ -142,7 +142,6 @@ public class Outline { first = true; foreach (ConstructorInfo ci in t.GetConstructors (DefaultFlags)) { - if (! ShowMember (ci)) continue; @@ -150,6 +149,7 @@ public class Outline { o.WriteLine (); first = false; + OutlineMemberAttribute (ci); OutlineConstructor (ci); o.WriteLine (); @@ -169,7 +169,8 @@ public class Outline { if (first) o.WriteLine (); first = false; - + + OutlineMemberAttribute (m); OutlineMethod (m); o.WriteLine (); @@ -191,6 +192,7 @@ public class Outline { o.WriteLine (); first = false; + OutlineMemberAttribute (m); OutlineOperator (m); o.WriteLine (); @@ -208,6 +210,7 @@ public class Outline { o.WriteLine (); first = false; + OutlineMemberAttribute (pi); OutlineProperty (pi); o.WriteLine (); @@ -224,6 +227,7 @@ public class Outline { o.WriteLine (); first = false; + OutlineMemberAttribute (fi); OutlineField (fi); o.WriteLine (); @@ -240,6 +244,7 @@ public class Outline { o.WriteLine (); first = false; + OutlineMemberAttribute (ei); OutlineEvent (ei); o.WriteLine (); @@ -286,6 +291,15 @@ public class Outline { o.WriteLine ("[Obsolete]"); } + void OutlineMemberAttribute (MemberInfo mi) + { + if (!mi.IsDefined (typeof (System.ObsoleteAttribute), false)) + return; + var oa = mi.GetCustomAttributes (typeof (System.ObsoleteAttribute), false) [0] as ObsoleteAttribute; + var msg = oa.Message; + o.WriteLine ("[Obsolete{0}]", msg == null || msg == "" ? "" : string.Format ("(\"{0}\")", msg)); + } + void OutlineEvent (EventInfo ei) { MethodBase accessor = ei.GetAddMethod (true); @@ -382,15 +396,11 @@ public class Outline { } o.Write (mi.Name); -#if NET_2_0 o.Write (FormatGenericParams (mi.GetGenericArguments ())); -#endif o.Write (" ("); OutlineParams (mi.GetParameters ()); o.Write (")"); -#if NET_2_0 WriteGenericConstraints (mi.GetGenericArguments ()); -#endif o.Write (";"); } @@ -549,7 +559,6 @@ public class Outline { } } -#if NET_2_0 string FormatGenericParams (Type [] args) { StringBuilder sb = new StringBuilder (); @@ -565,7 +574,6 @@ public class Outline { sb.Append (">"); return sb.ToString (); } -#endif // TODO: fine tune this so that our output is less verbose. We need to figure // out a way to do this while not making things confusing. @@ -665,9 +673,7 @@ public class Outline { void GetTypeName (StringBuilder sb, Type t) { sb.Append (RemoveGenericArity (t.Name)); -#if NET_2_0 sb.Append (FormatGenericParams (t.GetGenericArguments ())); -#endif } string GetFullName (Type t) @@ -679,12 +685,10 @@ public class Outline { void GetFullName_recursed (StringBuilder sb, Type t, bool recursed) { -#if NET_2_0 if (t.IsGenericParameter) { sb.Append (t.Name); return; } -#endif if (t.DeclaringType != null) { GetFullName_recursed (sb, t.DeclaringType, true); @@ -702,7 +706,6 @@ public class Outline { GetTypeName (sb, t); } -#if NET_2_0 void WriteGenericConstraints (Type [] args) { @@ -758,7 +761,6 @@ public class Outline { } } } -#endif string OperatorFromName (string name) { @@ -1022,3 +1024,5 @@ public class Comparer : IComparer { } } } + +#endif \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs index c72840cce..067c0c5f2 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/property.cs @@ -362,8 +362,13 @@ namespace Mono.CSharp CheckAbstractAndExtern (block != null); CheckProtectedModifier (); - if (block != null && block.IsIterator) - Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); + if (block != null) { + if (block.IsIterator) + Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); + + if (Compiler.Settings.WriteMetadataOnly) + block = null; + } return null; } @@ -906,7 +911,7 @@ namespace Mono.CSharp public override void Emit (TypeDefinition parent) { - if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0) { + if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 && !Compiler.Settings.WriteMetadataOnly) { block = new ToplevelBlock (Compiler, ParameterInfo, Location) { IsCompilerGenerated = true }; @@ -938,11 +943,10 @@ namespace Mono.CSharp var cond = new BooleanExpression (new Binary (Binary.Operator.Inequality, new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj1, Location), Location), - new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj2, Location), Location), - Location)); + new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj2, Location), Location))); var body = new ExplicitBlock (block, Location, Location); - block.AddStatement (new Do (body, cond, Location)); + block.AddStatement (new Do (body, cond, Location, Location)); body.AddStatement (new StatementExpression ( new SimpleAssign (new LocalVariableReference (obj2, Location), new LocalVariableReference (obj1, Location)))); @@ -1194,6 +1198,9 @@ namespace Mono.CSharp if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName))) return null; + if (Compiler.Settings.WriteMetadataOnly) + block = null; + MethodBuilder mb = method_data.MethodBuilder; Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, mb, ParameterInfo, method.ModFlags); @@ -1440,7 +1447,14 @@ namespace Mono.CSharp public override MethodBuilder Define (TypeContainer parent) { - parameters.Resolve (this); + // Disable reporting, parameters are resolved twice + Report.DisableReporting (); + try { + parameters.Resolve (this); + } finally { + Report.EnableReporting (); + } + return base.Define (parent); } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs index 50d78f007..b27b9c8a0 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/report.cs @@ -49,7 +49,7 @@ namespace Mono.CSharp { 809, 824, 1030, 1058, 1060, 1066, 1522, 1570, 1571, 1572, 1573, 1574, 1580, 1581, 1584, 1587, 1589, 1590, 1591, 1592, - 1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1699, + 1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1697, 1699, 1700, 1701, 1702, 1709, 1711, 1717, 1718, 1720, 1735, 1901, 1956, 1981, 1998, 2002, 2023, 2029, @@ -170,12 +170,6 @@ namespace Mono.CSharp { extra_information.Add (msg); } - public bool CheckWarningCode (string code, Location loc) - { - Warning (1691, 1, loc, "`{0}' is not a valid warning number", code); - return false; - } - public bool CheckWarningCode (int code, Location loc) { if (AllWarningsHashSet == null) @@ -184,7 +178,8 @@ namespace Mono.CSharp { if (AllWarningsHashSet.Contains (code)) return true; - return CheckWarningCode (code.ToString (), loc); + Warning (1691, 1, loc, "`{0}' is not a valid warning number", code); + return false; } public void ExtraInformation (Location loc, string msg) @@ -644,6 +639,11 @@ namespace Mono.CSharp { bool showFullPaths; + public void ClearSession () + { + session_messages = null; + } + public override void Print (AbstractMessage msg, bool showFullPath) { // diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs index 679a3ab1f..1556b5ca5 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/settings.cs @@ -159,6 +159,8 @@ namespace Mono.CSharp { public RuntimeVersion StdLibRuntimeVersion; + public bool WriteMetadataOnly; + readonly List conditional_symbols; readonly List source_files; @@ -180,10 +182,8 @@ namespace Mono.CSharp { StdLibRuntimeVersion = RuntimeVersion.v4; WarningLevel = 4; - if (Environment.OSVersion.Platform == PlatformID.Win32NT) - TabSize = 4; - else - TabSize = 8; + // Default to 1 or mdb files would be platform speficic + TabSize = 1; AssemblyReferences = new List (); AssemblyReferencesAliases = new List> (); @@ -565,36 +565,22 @@ namespace Mono.CSharp { source_file_index.Add (path, unit.Index); } - void AddWarningAsError (string warningId, CompilerSettings settings) + public bool ProcessWarningsList (string text, Action action) { - int id; - try { - id = int.Parse (warningId); - } catch { - report.CheckWarningCode (warningId, Location.Null); - return; - } - - if (!report.CheckWarningCode (id, Location.Null)) - return; - - settings.AddWarningAsError (id); - } + bool valid = true; + foreach (string wid in text.Split (numeric_value_separator)) { + int id; + if (!int.TryParse (wid, NumberStyles.AllowLeadingWhite, CultureInfo.InvariantCulture, out id)) { + report.Error (1904, "`{0}' is not a valid warning number", wid); + valid = false; + continue; + } - void RemoveWarningAsError (string warningId, CompilerSettings settings) - { - int id; - try { - id = int.Parse (warningId); - } catch { - report.CheckWarningCode (warningId, Location.Null); - return; + if (report.CheckWarningCode (id, Location.Null)) + action (id); } - if (!report.CheckWarningCode (id, Location.Null)) - return; - - settings.AddWarningOnly (id); + return valid; } void Error_RequiresArgument (string option) @@ -684,8 +670,9 @@ namespace Mono.CSharp { { output.WriteLine ( "Other flags in the compiler\n" + - " --fatal[=COUNT] Makes errors after COUNT fatal\n" + + " --fatal[=COUNT] Makes error after COUNT fatal\n" + " --lint Enhanced warnings\n" + + " --metadata-only Produced assembly will contain metadata only\n" + " --parse Only parses the source file\n" + " --runtime:VERSION Sets mscorlib.dll metadata version: v1, v2, v4\n" + " --stacktrace Shows stack trace at error location\n" + @@ -947,7 +934,7 @@ namespace Mono.CSharp { return ParseResult.Success; case "/debug": - if (value == "full" || value == "pdbonly" || idx < 0) { + if (value.Equals ("full", StringComparison.OrdinalIgnoreCase) || value.Equals ("pdbonly", StringComparison.OrdinalIgnoreCase) || idx < 0) { settings.GenerateDebugInfo = true; return ParseResult.Success; } @@ -997,8 +984,8 @@ namespace Mono.CSharp { settings.WarningsAreErrors = true; parser_settings.WarningsAreErrors = true; } else { - foreach (string wid in value.Split (numeric_value_separator)) - AddWarningAsError (wid, settings); + if (!ProcessWarningsList (value, v => settings.AddWarningAsError (v))) + return ParseResult.Error; } return ParseResult.Success; @@ -1006,12 +993,13 @@ namespace Mono.CSharp { if (value.Length == 0) { settings.WarningsAreErrors = false; } else { - foreach (string wid in value.Split (numeric_value_separator)) - RemoveWarningAsError (wid, settings); + if (!ProcessWarningsList (value, v => settings.AddWarningOnly (v))) + return ParseResult.Error; } return ParseResult.Success; case "/warn": + case "/w": if (value.Length == 0) { Error_RequiresArgument (option); return ParseResult.Error; @@ -1021,28 +1009,15 @@ namespace Mono.CSharp { return ParseResult.Success; case "/nowarn": - if (value.Length == 0) { - Error_RequiresArgument (option); - return ParseResult.Error; - } + if (value.Length == 0) { + Error_RequiresArgument (option); + return ParseResult.Error; + } - var warns = value.Split (numeric_value_separator); - foreach (string wc in warns) { - try { - if (wc.Trim ().Length == 0) - continue; + if (!ProcessWarningsList (value, v => settings.SetIgnoreWarning (v))) + return ParseResult.Error; - int warn = Int32.Parse (wc); - if (warn < 1) { - throw new ArgumentOutOfRangeException ("warn"); - } - settings.SetIgnoreWarning (warn); - } catch { - report.Error (1904, "`{0}' is not a valid warning number", wc); - return ParseResult.Error; - } - } - return ParseResult.Success; + return ParseResult.Success; case "/noconfig": settings.LoadDefaultReferences = false; @@ -1451,6 +1426,10 @@ namespace Mono.CSharp { settings.LoadDefaultReferences = false; return ParseResult.Success; + case "--metadata-only": + settings.WriteMetadataOnly = true; + return ParseResult.Success; + default: if (arg.StartsWith ("--fatal", StringComparison.Ordinal)){ int fatal = 1; @@ -1565,7 +1544,7 @@ namespace Mono.CSharp { " -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" + " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" + " -sdk:VERSION Specifies SDK version of referenced assemblies\n" + - " VERSION can be one of: 2, 4 (default) or custom value\n" + + " VERSION can be one of: 2, 4, 4.5 (default) or a custom value\n" + " -target:KIND Specifies the format of the output assembly (short: -t)\n" + " KIND can be one of: exe, winexe, library, module\n" + " -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" + diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs index 4a71f027d..46aff2b96 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/statement.cs @@ -281,11 +281,16 @@ namespace Mono.CSharp { public Expression expr; public Statement EmbeddedStatement; - public Do (Statement statement, BooleanExpression bool_expr, Location l) + public Do (Statement statement, BooleanExpression bool_expr, Location doLocation, Location whileLocation) { expr = bool_expr; EmbeddedStatement = statement; - loc = l; + loc = doLocation; + WhileLocation = whileLocation; + } + + public Location WhileLocation { + get; private set; } public override bool Resolve (BlockContext ec) @@ -332,7 +337,7 @@ namespace Mono.CSharp { ec.MarkLabel (ec.LoopBegin); // Mark start of while condition - ec.Mark (expr.Location); + ec.Mark (WhileLocation); // // Dead code elimination @@ -461,7 +466,7 @@ namespace Mono.CSharp { ec.MarkLabel (ec.LoopBegin); - ec.Mark (expr.Location); + ec.Mark (loc); expr.EmitBranchable (ec, while_loop, true); ec.MarkLabel (ec.LoopEnd); @@ -784,12 +789,10 @@ namespace Mono.CSharp { public sealed override bool Resolve (BlockContext ec) { - if (!DoResolve (ec)) - return false; - + var res = DoResolve (ec); unwind_protect = ec.CurrentBranching.AddReturnOrigin (ec.CurrentBranching.CurrentUsageVector, this); ec.CurrentBranching.CurrentUsageVector.Goto (); - return true; + return res; } } @@ -880,7 +883,6 @@ 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", @@ -911,6 +913,15 @@ namespace Mono.CSharp { } } } else { + // Same error code as .NET but better error message + if (block_return_type.Kind == MemberKind.Void) { + ec.Report.Error (127, loc, + "`{0}': A return keyword must not be followed by any expression when delegate returns void", + am.GetSignatureForError ()); + + return false; + } + var l = am as AnonymousMethodBody; if (l != null && l.ReturnTypeInference != null && expr != null) { l.ReturnTypeInference.AddCommonTypeBound (expr.Type); @@ -952,10 +963,9 @@ namespace Mono.CSharp { async_return.EmitAssign (ec); ec.EmitEpilogue (); - - ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, async_body.BodyEnd); } + ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, async_body.BodyEnd); return; } @@ -1438,6 +1448,7 @@ namespace Mono.CSharp { protected FullNamedExpression type_expr; protected LocalVariable li; protected List declarators; + TypeSpec type; public BlockVariableDeclaration (FullNamedExpression type, LocalVariable li) { @@ -1514,8 +1525,7 @@ namespace Mono.CSharp { public bool Resolve (BlockContext bc, bool resolveDeclaratorInitializers) { - if (li.Type == null) { - TypeSpec type = null; + if (type == null && !li.IsCompilerGenerated) { var vexpr = type_expr as VarExpr; // @@ -1623,8 +1633,10 @@ namespace Mono.CSharp { if (declarators != null) { foreach (var d in declarators) { d.Variable.CreateBuilder (ec); - if (d.Initializer != null) + if (d.Initializer != null) { + ec.Mark (d.Variable.Location); ((ExpressionStatement) d.Initializer).EmitStatement (ec); + } } } } @@ -2464,15 +2476,6 @@ namespace Mono.CSharp { if (ec.CurrentAnonymousMethod is StateMachineInitializer && ParametersBlock.Original == ec.CurrentAnonymousMethod.Block.Original) return ec.CurrentAnonymousMethod.Storey; - // - // When referencing a variable inside iterator where all - // variables will be captured anyway we don't need to create - // another storey context - // - if (ParametersBlock.StateMachine is IteratorStorey) { - return ParametersBlock.StateMachine; - } - if (am_storey == null) { MemberBase mc = ec.MemberContext as MemberBase; @@ -4248,10 +4251,10 @@ namespace Mono.CSharp { Expression cond = null; for (int ci = 0; ci < s.Labels.Count; ++ci) { - var e = new Binary (Binary.Operator.Equality, value, s.Labels[ci].Converted, loc); + var e = new Binary (Binary.Operator.Equality, value, s.Labels[ci].Converted); if (ci > 0) { - cond = new Binary (Binary.Operator.LogicalOr, cond, e, loc); + cond = new Binary (Binary.Operator.LogicalOr, cond, e); } else { cond = e; } @@ -4541,6 +4544,12 @@ namespace Mono.CSharp { ec.MarkLabel (start_finally); if (finally_host != null) { + finally_host.Define (); + finally_host.Emit (); + + // Now it's safe to add, to close it properly and emit sequence points + finally_host.Parent.AddMember (finally_host); + var ce = new CallEmitter (); ce.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc); ce.EmitPredefined (ec, finally_host.Spec, new Arguments (0)); @@ -4755,21 +4764,9 @@ namespace Mono.CSharp { locked = false; } - using (ec.Set (ResolveContext.Options.LockScope)) { - ec.StartFlowBranching (this); - Statement.Resolve (ec); - ec.EndFlowBranching (); - } - - if (lv != null) { - lv.IsLockedByStatement = locked; - } - - base.Resolve (ec); - // // Have to keep original lock value around to unlock same location - // in the case the original has changed or is null + // in the case of original value has changed or is null // expr_copy = TemporaryVariableReference.Create (ec.BuiltinTypes.Object, ec.CurrentBlock, loc); expr_copy.Resolve (ec); @@ -4782,6 +4779,18 @@ namespace Mono.CSharp { lock_taken.Resolve (ec); } + using (ec.Set (ResolveContext.Options.LockScope)) { + ec.StartFlowBranching (this); + Statement.Resolve (ec); + ec.EndFlowBranching (); + } + + if (lv != null) { + lv.IsLockedByStatement = locked; + } + + base.Resolve (ec); + return true; } @@ -5136,8 +5145,8 @@ namespace Mono.CSharp { // fixed (T* e_ptr = (e == null || e.Length == 0) ? null : converted [0]) // converted = new Conditional (new BooleanExpression (new Binary (Binary.Operator.LogicalOr, - new Binary (Binary.Operator.Equality, initializer, new NullLiteral (loc), loc), - new Binary (Binary.Operator.Equality, new MemberAccess (initializer, "Length"), new IntConstant (bc.BuiltinTypes, 0, loc), loc), loc)), + new Binary (Binary.Operator.Equality, initializer, new NullLiteral (loc)), + new Binary (Binary.Operator.Equality, new MemberAccess (initializer, "Length"), new IntConstant (bc.BuiltinTypes, 0, loc)))), new NullLiteral (loc), converted, loc); @@ -5703,7 +5712,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, dispose.loc); + dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc)), dispose, dispose.loc); return dispose; } @@ -5717,7 +5726,7 @@ namespace Mono.CSharp { { for (int i = declarators.Count - 1; i >= 0; --i) { var d = declarators [i]; - var vd = new VariableDeclaration (d.Variable, type_expr.Location); + var vd = new VariableDeclaration (d.Variable, d.Variable.Location); vd.Initializer = d.Initializer; vd.IsNested = true; vd.dispose_call = CreateDisposeCall (bc, d.Variable); @@ -5953,7 +5962,7 @@ namespace Mono.CSharp { if (variable_ref == null) return false; - for_each.body.AddScopeStatement (new StatementExpression (new CompilerAssign (variable_ref, access, Location.Null), for_each.variable.Location)); + for_each.body.AddScopeStatement (new StatementExpression (new CompilerAssign (variable_ref, access, Location.Null), for_each.type.Location)); bool ok = true; @@ -6049,7 +6058,7 @@ namespace Mono.CSharp { var idisaposable_test = new Binary (Binary.Operator.Inequality, new CompilerAssign ( dispose_variable.CreateReferenceExpression (bc, loc), new As (lv.CreateReferenceExpression (bc, loc), new TypeExpression (dispose_variable.Type, loc), loc), - loc), new NullLiteral (loc), loc); + loc), new NullLiteral (loc)); var m = bc.Module.PredefinedMembers.IDisposableDispose.Resolve (loc); @@ -6264,7 +6273,7 @@ namespace Mono.CSharp { if (variable_ref == null) return false; - for_each.body.AddScopeStatement (new StatementExpression (new CompilerAssign (variable_ref, current_pe, Location.Null), variable.Location)); + for_each.body.AddScopeStatement (new StatementExpression (new CompilerAssign (variable_ref, current_pe, Location.Null), for_each.type.Location)); var init = new Invocation (get_enumerator_mg, null); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs index 35762dfea..b4ac0c32a 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs @@ -127,7 +127,7 @@ namespace Mono.CSharp { return true; } } - + #if !FULL_AST /// /// This is an arbitrarily seekable StreamReader wrapper. /// @@ -137,21 +137,23 @@ namespace Mono.CSharp { /// public class SeekableStreamReader : IDisposable { + public const int DefaultReadAheadSize = 2048; + StreamReader reader; Stream stream; - static char[] buffer; + char[] buffer; int read_ahead_length; // the length of read buffer int buffer_start; // in chars int char_count; // count of filled characters in buffer[] int pos; // index into buffer[] - public SeekableStreamReader (Stream stream, Encoding encoding) + public SeekableStreamReader (Stream stream, Encoding encoding, char[] sharedBuffer = null) { this.stream = stream; + this.buffer = sharedBuffer; - const int default_read_ahead = 2048; - InitializeStream (default_read_ahead); + InitializeStream (DefaultReadAheadSize); reader = new StreamReader (stream, encoding, true); } @@ -274,7 +276,7 @@ namespace Mono.CSharp { return buffer [pos++]; } } - +#endif public class UnixUtils { [System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty")] extern static int _isatty (int fd); diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs index 6eb3fc6e4..1a2b37eaf 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typemanager.cs @@ -144,7 +144,7 @@ namespace Mono.CSharp { var ctx = module.Compiler; foreach (var p in types) { - var found = PredefinedType.Resolve (module, p.Kind, p.Namespace, p.Name, p.Arity); + var found = PredefinedType.Resolve (module, p.Kind, p.Namespace, p.Name, p.Arity, true, true); if (found == null || found == p) continue; @@ -340,6 +340,7 @@ namespace Mono.CSharp public readonly PredefinedMember AsyncVoidMethodBuilderSetStateMachine; public readonly PredefinedMember AsyncVoidMethodBuilderOnCompleted; public readonly PredefinedMember AsyncVoidMethodBuilderOnCompletedUnsafe; + public readonly PredefinedMember AsyncStateMachineAttributeCtor; public readonly PredefinedMember DebuggerBrowsableAttributeCtor; public readonly PredefinedMember DecimalCtor; public readonly PredefinedMember DecimalCtorInt; @@ -357,6 +358,7 @@ namespace Mono.CSharp public readonly PredefinedMember IEnumerableGetEnumerator; public readonly PredefinedMember InterlockedCompareExchange; public readonly PredefinedMember InterlockedCompareExchange_T; + public readonly PredefinedMember IteratorStateMachineAttributeCtor; public readonly PredefinedMember FixedBufferAttributeCtor; public readonly PredefinedMember MethodInfoGetMethodFromHandle; public readonly PredefinedMember MethodInfoGetMethodFromHandle2; @@ -549,6 +551,10 @@ namespace Mono.CSharp }, false), btypes.Void)); + AsyncStateMachineAttributeCtor = new PredefinedMember (module, atypes.AsyncStateMachine, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved ( + btypes.Type))); + DebuggerBrowsableAttributeCtor = new PredefinedMember (module, atypes.DebuggerBrowsable, MemberFilter.Constructor (null)); @@ -625,6 +631,10 @@ namespace Mono.CSharp }, false), null)); + IteratorStateMachineAttributeCtor = new PredefinedMember (module, atypes.IteratorStateMachine, + MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved ( + btypes.Type))); + MethodInfoGetMethodFromHandle = new PredefinedMember (module, types.MethodBase, "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle); @@ -748,7 +758,7 @@ namespace Mono.CSharp if (type != null) return true; - type = Resolve (module, kind, ns, name, arity, false); + type = Resolve (module, kind, ns, name, arity, false, false); return type != null; } @@ -757,17 +767,21 @@ namespace Mono.CSharp return ns + "." + name; } - public static TypeSpec Resolve (ModuleContainer module, MemberKind kind, string ns, string name, int arity) + public static TypeSpec Resolve (ModuleContainer module, MemberKind kind, string ns, string name, int arity, bool required, bool reportErrors) { - return Resolve (module, kind, ns, name, arity, true); - } + // + // Cannot call it with true because it could create non-existent namespaces for + // predefined types. It's set to true only for build-in types which all must + // exist therefore it does not matter, for predefined types we don't want to create + // fake namespaces when type is optional and does not exist (e.g. System.Linq). + // + Namespace type_ns = module.GlobalRootNamespace.GetNamespace (ns, required); + IList found = null; + if (type_ns != null) + found = type_ns.GetAllTypes (name); - public static TypeSpec Resolve (ModuleContainer module, MemberKind kind, string ns, string name, int arity, bool reportErrors) - { - Namespace type_ns = module.GlobalRootNamespace.GetNamespace (ns, true); - var found = type_ns.GetAllTypes (name); if (found == null) { - if (reportErrors) + if (reportErrors ) module.Compiler.Report.Error (518, "The predefined type `{0}.{1}' is not defined or imported", ns, name); return null; @@ -837,13 +851,13 @@ namespace Mono.CSharp public TypeSpec Resolve () { if (type == null) - type = Resolve (module, kind, ns, name, arity); + type = Resolve (module, kind, ns, name, arity, false, true); return type; } } - class PredefinedMember where T : MemberSpec + public class PredefinedMember where T : MemberSpec { readonly ModuleContainer module; T member; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs index 7ad55a4be..8337ce59b 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/typespec.cs @@ -23,6 +23,9 @@ using System.Reflection; namespace Mono.CSharp { + // + // Inflated or non-inflated representation of any type. + // public class TypeSpec : MemberSpec { protected MetaType info; @@ -306,6 +309,9 @@ namespace Mono.CSharp } } + // + // A cache of all type members (including nested types) + // public MemberCache MemberCache { get { if (cache == null || (state & StateFlags.PendingMemberCacheMembers) != 0) @@ -435,6 +441,9 @@ namespace Mono.CSharp return aua; } + // + // Return metadata information used during emit to describe the type + // public virtual MetaType GetMetaInfo () { return info; @@ -445,6 +454,9 @@ namespace Mono.CSharp return this; } + // + // Text representation of type used by documentation writer + // public override string GetSignatureForDocumentation () { StringBuilder sb = new StringBuilder (); @@ -651,6 +663,9 @@ namespace Mono.CSharp return new InflatedTypeSpec (inflator.Context, this, inflator.TypeInstance, targs); } + // + // Inflates current type using specific type arguments + // public InflatedTypeSpec MakeGenericType (IModuleContext context, TypeSpec[] targs) { if (targs.Length == 0 && !IsNested) @@ -721,6 +736,18 @@ namespace Mono.CSharp } } + if (MemberDefinition.TypeParametersCount > 0) { + foreach (var tp in MemberDefinition.TypeParameters) { + var tp_missing = tp.GetMissingDependencies (); + if (tp_missing != null) { + if (missing == null) + missing = new List (); + + missing.AddRange (tp_missing); + } + } + } + if (missing != null || BaseType == null) return missing; @@ -741,6 +768,10 @@ namespace Mono.CSharp } } + // + // Special version used for types which must exist in corlib or + // the compiler cannot work + // public sealed class BuiltinTypeSpec : TypeSpec { public enum Type @@ -922,6 +953,9 @@ namespace Mono.CSharp } } + // + // Various type comparers used by compiler + // static class TypeSpecComparer { // @@ -1333,7 +1367,7 @@ namespace Mono.CSharp cache = MemberCache.Empty; // Make all internal types CLS-compliant, non-obsolete - state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected)) | StateFlags.CLSCompliant; + state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected | StateFlags.MissingDependency_Undetected)) | StateFlags.CLSCompliant; } #region Properties @@ -1447,6 +1481,9 @@ namespace Mono.CSharp #endregion } + // + // Common base class for composite types + // public abstract class ElementTypeSpec : TypeSpec, ITypeDefinition { protected ElementTypeSpec (MemberKind kind, TypeSpec element, MetaType info) @@ -1454,11 +1491,8 @@ namespace Mono.CSharp { this.Element = element; - // Some flags can be copied directly from the element - const StateFlags shared_flags = StateFlags.CLSCompliant | StateFlags.CLSCompliant_Undetected - | StateFlags.Obsolete | StateFlags.Obsolete_Undetected | StateFlags.HasDynamicElement; - state &= ~shared_flags; - state |= (element.state & shared_flags); + state &= ~SharedStateFlags; + state |= (element.state & SharedStateFlags); if (element.BuiltinType == BuiltinTypeSpec.Type.Dynamic) state |= StateFlags.HasDynamicElement; diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs index dbd5709aa..6cbc1610c 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/visit.cs @@ -11,6 +11,7 @@ // using System; +using System.Diagnostics; namespace Mono.CSharp { @@ -18,7 +19,7 @@ namespace Mono.CSharp { public virtual void Visit (MemberCore member) { - Console.WriteLine ("unknown member type: " + member.GetType ()); + Debug.Fail ("unknown member type: " + member.GetType ()); } public virtual void Visit (ModuleContainer mc) @@ -125,7 +126,7 @@ namespace Mono.CSharp public virtual object Visit (Statement stmt) { - Console.WriteLine ("unknown statement:" + stmt); + Debug.Fail ("unknown statement:" + stmt); return null; } @@ -309,7 +310,7 @@ namespace Mono.CSharp public virtual object Visit (Expression expression) { - Console.WriteLine ("Visit unknown expression:" + expression); + Debug.Fail ("Visit unknown expression:" + expression); return null; } diff --git a/ICSharpCode.NRefactory.CSharp/QueryExpressionExpander.cs b/ICSharpCode.NRefactory.CSharp/QueryExpressionExpander.cs new file mode 100644 index 000000000..35902a21a --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/QueryExpressionExpander.cs @@ -0,0 +1,357 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text; +using ICSharpCode.NRefactory.PatternMatching; + +namespace ICSharpCode.NRefactory.CSharp { + public class QueryExpressionExpansionResult { + public AstNode AstNode { get; private set; } + + /// + /// Maps original range variables to some node in the new tree that represents them. + /// + public IDictionary RangeVariables { get; private set; } + + /// + /// Maps clauses to method calls. The keys will always be either a or a + /// + public IDictionary Expressions { get; private set; } + + public QueryExpressionExpansionResult(AstNode astNode, IDictionary rangeVariables, IDictionary expressions) { + AstNode = astNode; + RangeVariables = rangeVariables; + Expressions = expressions; + } + } + + public class QueryExpressionExpander { + class Visitor : DepthFirstAstVisitor { + int currentTransparentParameter; + const string TransparentParameterNameTemplate = "<>x{0}"; + + protected override AstNode VisitChildren(AstNode node) { + List newChildren = null; + + int i = 0; + foreach (var child in node.Children) { + var newChild = child.AcceptVisitor(this); + if (newChild != null) { + newChildren = newChildren ?? Enumerable.Repeat((AstNode)null, i).ToList(); + newChildren.Add(newChild); + } + else if (newChildren != null) { + newChildren.Add(null); + } + i++; + } + + if (newChildren == null) + return null; + + var result = node.Clone(); + + i = 0; + foreach (var children in result.Children) { + if (newChildren[i] != null) + children.ReplaceWith(newChildren[i]); + i++; + } + + return result; + } + + Expression MakeNestedMemberAccess(Expression target, IEnumerable members) { + return members.Aggregate(target, (current, m) => current.Member(m)); + } + + Expression VisitNested(Expression node, ParameterDeclaration transparentParameter) { + var oldRangeVariableSubstitutions = activeRangeVariableSubstitutions; + try { + if (transparentParameter != null && currentTransparentType.Count > 1) { + activeRangeVariableSubstitutions = new Dictionary(activeRangeVariableSubstitutions); + foreach (var t in currentTransparentType) + activeRangeVariableSubstitutions[t.Item1.Name] = MakeNestedMemberAccess(new IdentifierExpression(transparentParameter.Name), t.Item2); + } + var result = node.AcceptVisitor(this); + return (Expression)(result ?? node.Clone()); + } + finally { + activeRangeVariableSubstitutions = oldRangeVariableSubstitutions; + } + } + + QueryClause GetNextQueryClause(QueryClause clause) { + for (AstNode node = clause.NextSibling; node != null; node = node.NextSibling) { + if (node.Role == QueryExpression.ClauseRole) + return (QueryClause)node; + } + return null; + } + + public IDictionary rangeVariables = new Dictionary(); + public IDictionary expressions = new Dictionary(); + + Dictionary activeRangeVariableSubstitutions = new Dictionary(); + List>> currentTransparentType = new List>>(); + Expression currentResult; + bool eatSelect; + + void MapExpression(AstNode orig, Expression newExpr) { + Debug.Assert(orig is QueryClause || orig is QueryOrdering); + expressions[orig] = newExpr; + } + + ParameterDeclaration CreateParameterForCurrentRangeVariable() { + var param = new ParameterDeclaration(); + + if (currentTransparentType.Count == 1) { + var clonedRangeVariable = (Identifier)currentTransparentType[0].Item1.Clone(); + if (!rangeVariables.ContainsKey(currentTransparentType[0].Item1)) + rangeVariables[currentTransparentType[0].Item1] = param; + param.AddChild(clonedRangeVariable, Roles.Identifier); + } + else { + param.AddChild(Identifier.Create(string.Format(CultureInfo.InvariantCulture, TransparentParameterNameTemplate, currentTransparentParameter++)), Roles.Identifier); + } + return param; + } + + LambdaExpression CreateLambda(IList parameters, Expression body) { + var result = new LambdaExpression(); + if (parameters.Count > 1) + result.AddChild(new CSharpTokenNode(TextLocation.Empty), Roles.LPar); + result.AddChild(parameters[0], Roles.Parameter); + for (int i = 1; i < parameters.Count; i++) { + result.AddChild(new CSharpTokenNode(TextLocation.Empty), Roles.Comma); + result.AddChild(parameters[i], Roles.Parameter); + } + if (parameters.Count > 1) + result.AddChild(new CSharpTokenNode(TextLocation.Empty), Roles.RPar); + result.AddChild(body, LambdaExpression.BodyRole); + + return result; + } + + ParameterDeclaration CreateParameter(Identifier identifier) { + var result = new ParameterDeclaration(); + result.AddChild(identifier, Roles.Identifier); + return result; + } + + Expression AddMemberToCurrentTransparentType(ParameterDeclaration param, Identifier name, Expression value, bool namedExpression) { + Expression newAssignment = VisitNested(value, param); + if (namedExpression) { + newAssignment = new NamedExpression(name.Name, VisitNested(value, param)); + if (!rangeVariables.ContainsKey(name) ) + rangeVariables[name] = ((NamedExpression)newAssignment).NameToken; + } + + foreach (var t in currentTransparentType) + t.Item2.Insert(0, param.Name); + + currentTransparentType.Add(Tuple.Create(name, new List { name.Name })); + return new AnonymousTypeCreateExpression(new[] { new IdentifierExpression(param.Name), newAssignment }); + } + + void AddFirstMemberToCurrentTransparentType(Identifier identifier) { + Debug.Assert(currentTransparentType.Count == 0); + currentTransparentType.Add(Tuple.Create(identifier, new List())); + } + + public override AstNode VisitQueryExpression(QueryExpression queryExpression) { + var oldTransparentType = currentTransparentType; + var oldResult = currentResult; + var oldEatSelect = eatSelect; + try { + currentTransparentType = new List>>(); + currentResult = null; + eatSelect = false; + + foreach (var clause in queryExpression.Clauses) { + var result = (Expression)clause.AcceptVisitor(this); + MapExpression(clause, result ?? currentResult); + currentResult = result; + } + + return currentResult; + } + finally { + currentTransparentType = oldTransparentType; + currentResult = oldResult; + eatSelect = oldEatSelect; + } + } + + public override AstNode VisitQueryContinuationClause(QueryContinuationClause queryContinuationClause) { + var prev = VisitNested(queryContinuationClause.PrecedingQuery, null); + AddFirstMemberToCurrentTransparentType(queryContinuationClause.IdentifierToken); + return prev; + } + + public override AstNode VisitQueryFromClause(QueryFromClause queryFromClause) { + if (currentResult == null) { + AddFirstMemberToCurrentTransparentType(queryFromClause.IdentifierToken); + if (queryFromClause.Type.IsNull) { + return VisitNested(queryFromClause.Expression, null); + } + else { + return VisitNested(queryFromClause.Expression, null).Invoke("Cast", new[] { queryFromClause.Type.Clone() }, new Expression[0]); + } + } + else { + var innerSelectorParam = CreateParameterForCurrentRangeVariable(); + var innerSelector = CreateLambda(new[] { innerSelectorParam }, VisitNested(queryFromClause.Expression, innerSelectorParam)); + + var clonedIdentifier = (Identifier)queryFromClause.IdentifierToken.Clone(); + + var resultParam = CreateParameterForCurrentRangeVariable(); + Expression body; + // Second from clause - SelectMany + var select = GetNextQueryClause(queryFromClause) as QuerySelectClause; + if (select != null) { + body = VisitNested(select.Expression, resultParam); + eatSelect = true; + } + else { + body = AddMemberToCurrentTransparentType(resultParam, queryFromClause.IdentifierToken, new IdentifierExpression(queryFromClause.Identifier), false); + } + + var resultSelectorParam2 = CreateParameter(clonedIdentifier); + var resultSelector = CreateLambda(new[] { resultParam, resultSelectorParam2 }, body); + rangeVariables[queryFromClause.IdentifierToken] = resultSelectorParam2; + + return currentResult.Invoke("SelectMany", innerSelector, resultSelector); + } + } + + public override AstNode VisitQueryLetClause(QueryLetClause queryLetClause) { + var param = CreateParameterForCurrentRangeVariable(); + var body = AddMemberToCurrentTransparentType(param, queryLetClause.IdentifierToken, queryLetClause.Expression, true); + var lambda = CreateLambda(new[] { param }, body); + + return currentResult.Invoke("Select", lambda); + } + + public override AstNode VisitQueryWhereClause(QueryWhereClause queryWhereClause) { + var param = CreateParameterForCurrentRangeVariable(); + return currentResult.Invoke("Where", CreateLambda(new[] { param }, VisitNested(queryWhereClause.Condition, param))); + } + + public override AstNode VisitQueryJoinClause(QueryJoinClause queryJoinClause) { + Expression resultSelectorBody = null; + var inExpression = VisitNested(queryJoinClause.InExpression, null); + var key1SelectorFirstParam = CreateParameterForCurrentRangeVariable(); + var key1Selector = CreateLambda(new[] { key1SelectorFirstParam }, VisitNested(queryJoinClause.OnExpression, key1SelectorFirstParam)); + var key2Param = CreateParameter(Identifier.Create(queryJoinClause.JoinIdentifier)); + var key2Selector = CreateLambda(new[] { key2Param }, VisitNested(queryJoinClause.EqualsExpression, null)); + + var resultSelectorFirstParam = CreateParameterForCurrentRangeVariable(); + + var select = GetNextQueryClause(queryJoinClause) as QuerySelectClause; + if (select != null) { + resultSelectorBody = VisitNested(select.Expression, resultSelectorFirstParam); + eatSelect = true; + } + + if (queryJoinClause.IntoKeyword.IsNull) { + // Normal join + if (resultSelectorBody == null) + resultSelectorBody = AddMemberToCurrentTransparentType(resultSelectorFirstParam, queryJoinClause.JoinIdentifierToken, new IdentifierExpression(queryJoinClause.JoinIdentifier), false); + + var resultSelector = CreateLambda(new[] { resultSelectorFirstParam, CreateParameter(Identifier.Create(queryJoinClause.JoinIdentifier)) }, resultSelectorBody); + rangeVariables[queryJoinClause.JoinIdentifierToken] = key2Param; + return currentResult.Invoke("Join", inExpression, key1Selector, key2Selector, resultSelector); + } + else { + // Group join + if (resultSelectorBody == null) + resultSelectorBody = AddMemberToCurrentTransparentType(resultSelectorFirstParam, queryJoinClause.IntoIdentifierToken, new IdentifierExpression(queryJoinClause.IntoIdentifier), false); + + var intoParam = CreateParameter(Identifier.Create(queryJoinClause.IntoIdentifier)); + var resultSelector = CreateLambda(new[] { resultSelectorFirstParam, intoParam }, resultSelectorBody); + rangeVariables[queryJoinClause.IntoIdentifierToken] = intoParam; + + return currentResult.Invoke("GroupJoin", inExpression, key1Selector, key2Selector, resultSelector); + } + } + + public override AstNode VisitQueryOrderClause(QueryOrderClause queryOrderClause) { + var current = currentResult; + bool first = true; + foreach (var o in queryOrderClause.Orderings) { + string methodName = first ? (o.Direction == QueryOrderingDirection.Descending ? "OrderByDescending" : "OrderBy") + : (o.Direction == QueryOrderingDirection.Descending ? "ThenByDescending" : "ThenBy"); + + var param = CreateParameterForCurrentRangeVariable(); + current = current.Invoke(methodName, CreateLambda(new[] { param }, VisitNested(o.Expression, param))); + MapExpression(o, current); + first = false; + } + return current; + } + + bool IsSingleRangeVariable(Expression expr) { + if (currentTransparentType.Count > 1) + return false; + var unpacked = ParenthesizedExpression.UnpackParenthesizedExpression(expr); + return unpacked is IdentifierExpression && ((IdentifierExpression)unpacked).Identifier == currentTransparentType[0].Item1.Name; + } + + public override AstNode VisitQuerySelectClause(QuerySelectClause querySelectClause) { + if (eatSelect) { + eatSelect = false; + return currentResult; + } + else if (((QueryExpression)querySelectClause.Parent).Clauses.Count > 2 && IsSingleRangeVariable(querySelectClause.Expression)) { + // A simple query that ends with a trivial select should be removed. + return currentResult; + } + + var param = CreateParameterForCurrentRangeVariable(); + var lambda = CreateLambda(new[] { param }, VisitNested(querySelectClause.Expression, param)); + return currentResult.Invoke("Select", lambda); + } + + public override AstNode VisitQueryGroupClause(QueryGroupClause queryGroupClause) { + var param = CreateParameterForCurrentRangeVariable(); + var keyLambda = CreateLambda(new[] { param }, VisitNested(queryGroupClause.Key, param)); + + if (IsSingleRangeVariable(queryGroupClause.Projection)) { + // We are grouping by the single active range variable, so we can use the single argument form of GroupBy + return currentResult.Invoke("GroupBy", keyLambda); + } + else { + var projectionParam = CreateParameterForCurrentRangeVariable(); + var projectionLambda = CreateLambda(new[] { projectionParam }, VisitNested(queryGroupClause.Projection, projectionParam)); + return currentResult.Invoke("GroupBy", keyLambda, projectionLambda); + } + } + + public override AstNode VisitIdentifierExpression(IdentifierExpression identifierExpression) { + Expression subst; + activeRangeVariableSubstitutions.TryGetValue(identifierExpression.Identifier, out subst); + return subst != null ? subst.Clone() : null; + } + } + + /// + /// Expands all occurances of query patterns in the specified node. Returns a clone of the node with all query patterns expanded, or null if there was no query pattern to expand. + /// + /// + /// + public QueryExpressionExpansionResult ExpandQueryExpressions(AstNode node) { + var visitor = new Visitor(); + var astNode = node.AcceptVisitor(visitor); + if (astNode != null) { + astNode.Freeze(); + return new QueryExpressionExpansionResult(astNode, visitor.rangeVariables, visitor.expressions); + } + else { + return null; + } + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/BaseRefactoringContext.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/BaseRefactoringContext.cs index 449be597d..32a84ba23 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/BaseRefactoringContext.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/BaseRefactoringContext.cs @@ -35,6 +35,7 @@ using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.NRefactory.Editor; using System.ComponentModel.Design; using ICSharpCode.NRefactory.CSharp.Analysis; +using ICSharpCode.NRefactory.Utils; namespace ICSharpCode.NRefactory.CSharp.Refactoring { @@ -72,9 +73,9 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring } } - public virtual CSharpParsedFile ParsedFile { + public virtual CSharpUnresolvedFile UnresolvedFile { get { - return resolver.ParsedFile; + return resolver.UnresolvedFile; } } @@ -135,6 +136,31 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring { return new DefiniteAssignmentAnalysis (root, resolver, CancellationToken); } + + /// + /// Creates a new reachability analysis object with a given statement. + /// + /// + /// The statement to start the analysis. + /// + /// + /// The reachability analysis object. + /// + public ReachabilityAnalysis CreateReachabilityAnalysis (Statement statement) + { + return ReachabilityAnalysis.Create (statement, resolver, CancellationToken); + } + + /// + /// Parses a composite format string. + /// + /// + /// The format string parsing result. + /// + public virtual FormatStringParseResult ParseFormatString(string source) + { + return new CompositeFormatStringParser().Parse(source); + } #endregion /// diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddAnotherAccessorAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddAnotherAccessorAction.cs index 1258ec709..fc57d1f95 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddAnotherAccessorAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddAnotherAccessorAction.cs @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring public IEnumerable GetActions(RefactoringContext context) { var pdecl = GetPropertyDeclaration(context); - if (pdecl == null) { + if (pdecl == null || !pdecl.Getter.IsNull && !pdecl.Setter.IsNull) { yield break; } @@ -45,7 +45,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (type != null && type.ClassType == ClassType.Interface) { yield break; } - yield return new CodeAction (pdecl.Setter.IsNull ? context.TranslateString("Add getter") : context.TranslateString("Add setter"), script => { + yield return new CodeAction (pdecl.Setter.IsNull ? context.TranslateString("Add setter") : context.TranslateString("Add getter"), script => { var accessorStatement = BuildAccessorStatement(context, pdecl); Accessor accessor = new Accessor () { diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddCatchTypeAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddCatchTypeAction.cs new file mode 100644 index 000000000..6a33592aa --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/AddCatchTypeAction.cs @@ -0,0 +1,59 @@ +// +// AddCatchTypeAction.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using ICSharpCode.NRefactory.CSharp; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Add type", + Description = "Adds an exception type specifier to catch clauses.")] + public class AddCatchTypeAction : ICodeActionProvider + { + #region ICodeActionProvider implementation + + public IEnumerable GetActions(RefactoringContext context) + { + var catchClause = context.GetNode(); + if (catchClause == null) + yield break; + if (!catchClause.Type.IsNull) + yield break; + yield return new CodeAction(context.TranslateString("Add type specifier"), script => { + var newIdentifier = Identifier.Create("e"); + var newType = context.CreateShortType("System", "Exception"); + script.Replace(catchClause, new CatchClause() { + Type = newType, + VariableNameToken = newIdentifier, + Body = catchClause.Body.Clone() as BlockStatement + }); + script.Link(newType); + script.Link(newIdentifier); + }); + } + + #endregion + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CheckIfParameterIsNullAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CheckIfParameterIsNullAction.cs index c5bb6c24c..8a5edc864 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CheckIfParameterIsNullAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CheckIfParameterIsNullAction.cs @@ -37,18 +37,24 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring { protected override CodeAction GetAction(RefactoringContext context, ParameterDeclaration parameter) { - var bodyStatement = parameter.Parent.GetChildByRole(Roles.Body); - if (bodyStatement == null) + BlockStatement bodyStatement; + if (parameter.Parent is LambdaExpression) { + bodyStatement = parameter.Parent.GetChildByRole (LambdaExpression.BodyRole) as BlockStatement; + } else { + bodyStatement = parameter.Parent.GetChildByRole (Roles.Body); + } + if (bodyStatement == null || bodyStatement.IsNull) return null; var type = context.ResolveType(parameter.Type); if (type.IsReferenceType == false || HasNullCheck(parameter)) return null; - return new CodeAction (context.TranslateString("Add null check for parameter"), script => { - var statement = new IfElseStatement () { + return new CodeAction(context.TranslateString("Add null check for parameter"), script => { + var statement = new IfElseStatement() { Condition = new BinaryOperatorExpression (new IdentifierExpression (parameter.Name), BinaryOperatorType.Equality, new NullReferenceExpression ()), TrueStatement = new ThrowStatement (new ObjectCreateExpression (context.CreateShortType("System", "ArgumentNullException"), new PrimitiveExpression (parameter.Name))) }; + System.Console.WriteLine(bodyStatement.StartLocation +"/" + bodyStatement.EndLocation); script.AddTo(bodyStatement, statement); }); } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertAnonymousDelegateToLambdaAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertAnonymousDelegateToLambdaAction.cs new file mode 100644 index 000000000..23abf7a50 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertAnonymousDelegateToLambdaAction.cs @@ -0,0 +1,61 @@ +// +// ConvertAnonymousDelegateToExpression.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Convert anonymous delegate to lambda block", + Description = "Converts an anonymous delegate into a lambda in block form.")] + public class ConvertAnonymousDelegateToLambdaAction : SpecializedCodeAction + { + #region implemented abstract members of SpecializedCodeAction + protected override CodeAction GetAction(RefactoringContext context, AnonymousMethodExpression node) + { + if (context.Location < node.DelegateToken.StartLocation || context.Location >= node.Body.StartLocation) + return null; + + if (!node.HasParameterList) + return null; + + return new CodeAction(context.TranslateString("Convert to lambda block"), script => { + var parent = node.Parent; + while (!(parent is Statement)) + parent = parent.Parent; + bool explicitLambda = parent is VariableDeclarationStatement && ((VariableDeclarationStatement)parent).Type.GetText() == "var"; + var lambda = new LambdaExpression { Body = node.Body.Clone() }; + foreach (var parameter in node.Parameters) { + if (explicitLambda) { + lambda.Parameters.Add(new ParameterDeclaration { Type = parameter.Type.Clone(), Name = parameter.Name }); + } else { + lambda.Parameters.Add(new ParameterDeclaration { Name = parameter.Name }); + } + } + script.Replace(node, lambda); + }); + } + #endregion + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertAsToCastAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertAsToCastAction.cs new file mode 100644 index 000000000..3d9e26296 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertAsToCastAction.cs @@ -0,0 +1,44 @@ +// +// ConvertAsToCastAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + /// + /// Converts an 'as' expression to a cast expression + /// + [ContextAction("Convert 'as' to cast.", Description = "Convert 'as' to cast.")] + public class ConvertAsToCastAction : SpecializedCodeAction + { + + protected override CodeAction GetAction (RefactoringContext context, AsExpression node) + { + if (!node.AsToken.Contains (context.Location)) + return null; + return new CodeAction (context.TranslateString ("Convert 'as' to cast"), + script => script.Replace (node, new CastExpression (node.Type.Clone (), node.Expression.Clone ()))); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertCastToAsAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertCastToAsAction.cs new file mode 100644 index 000000000..85c694bd7 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertCastToAsAction.cs @@ -0,0 +1,52 @@ +// +// ConvertCastToAsAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + /// + /// Converts a cast expression to an 'as' expression + /// + [ContextAction ("Convert cast to 'as'.", Description = "Convert cast to 'as'.")] + public class ConvertCastToAsAction : SpecializedCodeAction + { + + protected override CodeAction GetAction (RefactoringContext context, CastExpression node) + { + if (node.Expression.Contains (context.Location)) + return null; + // only works on reference and nullable types + var type = context.ResolveType (node.Type); + var typeDef = type.GetDefinition (); + if (type.IsReferenceType == true || (typeDef != null && typeDef.KnownTypeCode == KnownTypeCode.NullableOfT)) + return new CodeAction (context.TranslateString ("Convert cast to 'as'"), script => + script.Replace (node, new AsExpression (node.Expression.Clone (), node.Type.Clone ()))); + + return null; + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertConditionalToIfAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertConditionalToIfAction.cs new file mode 100644 index 000000000..f69f18b18 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertConditionalToIfAction.cs @@ -0,0 +1,146 @@ +// +// ConvertConditionalToIfAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring.CodeActions +{ + [ContextAction ("Convert '?:' to 'if'", Description = "Convert '?:' operator to 'if' statement.")] + public class ConvertConditionalToIfAction : ICodeActionProvider + { + public IEnumerable GetActions (RefactoringContext context) + { + // return + var returnStatement = context.GetNode (); + if (returnStatement != null) { + var action = GetAction (context, returnStatement, returnStatement.Expression, + expr => new Statement[] + { + new IfElseStatement (expr.Condition.Clone (), + new ReturnStatement (expr.TrueExpression.Clone ()), + new ReturnStatement (expr.FalseExpression.Clone ())) + }); + if (action != null) + yield return action; + yield break; + } + + // assignment + var assignment = context.GetNode (); + if (assignment != null) { + var statement = assignment.Parent as ExpressionStatement; + if (statement == null) + yield break; + + // statement is in for initializer/iterator + if (statement.Parent is ForStatement && + statement != ((ForStatement)statement.Parent).EmbeddedStatement) + yield break; + + // statement is in using resource-acquisition + if (statement.Parent is UsingStatement && + statement != ((UsingStatement)statement.Parent).EmbeddedStatement) + yield break; + + var action = GetAction (context, statement, assignment.Right, + expr => new Statement [] { ConvertAssignment (assignment.Left, assignment.Operator, expr) }); + if (action != null) + yield return action; + + yield break; + } + + // variable initializer + var initializer = context.GetNode (); + if (initializer != null && initializer.Parent is VariableDeclarationStatement && + initializer.Parent.Parent is BlockStatement) { + + var variableDecl = (VariableDeclarationStatement)initializer.Parent; + var newVariableDecl = (VariableDeclarationStatement)variableDecl.Clone (); + foreach (var variable in newVariableDecl.Variables) { + if (variable.Name == initializer.Name) + variable.Initializer = Expression.Null; + } + + var action = GetAction (context, variableDecl, initializer.Initializer, + expr => new Statement [] + { + newVariableDecl, + ConvertAssignment (new IdentifierExpression (initializer.Name), AssignmentOperatorType.Assign, + expr) + }); + if (action != null) + yield return action; + } + } + + CodeAction GetAction (RefactoringContext context, Statement originalStatement, Expression conditionalCandidate, + Func> getReplacement) + { + var conditionalExpr = GetConditionalExpression (conditionalCandidate); + if (conditionalExpr == null || + !(conditionalExpr.QuestionMarkToken.Contains(context.Location) || + conditionalExpr.ColonToken.Contains(context.Location))) + return null; + + return new CodeAction (context.TranslateString ("Convert '?:' to 'if'"), + script => + { + foreach (var node in getReplacement (conditionalExpr)) + script.InsertBefore (originalStatement, node); + script.Remove (originalStatement); + }); + } + + static ConditionalExpression GetConditionalExpression (Expression expr) + { + while (expr != null) { + if (expr is ConditionalExpression) + return (ConditionalExpression)expr; + + var parenthesizedExpr = expr as ParenthesizedExpression; + if (parenthesizedExpr == null) + break; + expr = parenthesizedExpr.Expression; + } + return null; + } + + static IfElseStatement ConvertAssignment (Expression target, AssignmentOperatorType op, + ConditionalExpression conditionalExpr) + { + var trueAssignment = new AssignmentExpression (target.Clone (), op, + conditionalExpr.TrueExpression.Clone ()); + var falseAssignment = new AssignmentExpression (target.Clone (), op, + conditionalExpr.FalseExpression.Clone ()); + return new IfElseStatement (conditionalExpr.Condition.Clone (), + new ExpressionStatement (trueAssignment), + new ExpressionStatement (falseAssignment)); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertExplicitToImplicitImplementationAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertExplicitToImplicitImplementationAction.cs new file mode 100644 index 000000000..d429d4f82 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertExplicitToImplicitImplementationAction.cs @@ -0,0 +1,69 @@ +// +// ConvertExplicitToImplicitImplementation.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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.Linq; +using ICSharpCode.NRefactory.Semantics; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Convert explicit to implict implementation", + Description = " Convert explicit implementation of an interface method to implicit implementation")] + public class ConvertExplicitToImplicitImplementationAction : SpecializedCodeAction + { + protected override CodeAction GetAction (RefactoringContext context, MethodDeclaration node) + { + if (node.PrivateImplementationType.IsNull) + return null; + + if (!node.NameToken.Contains (context.Location) && + !node.PrivateImplementationType.Contains(context.Location)) + return null; + + var method = (IMethod)((MemberResolveResult)context.Resolve (node)).Member; + var type = method.DeclaringType; + + // find existing method with the same signature + if (type.GetMethods (m => m.Name == node.Name && m.TypeParameters.Count == method.TypeParameters.Count + && !m.IsExplicitInterfaceImplementation) + .Any (m => ParameterListComparer.Instance.Equals (m.Parameters, method.Parameters))) + return null; + + return new CodeAction (context.TranslateString ("Convert explict to implicit implementation"), + script => + { + var implicitImpl = (MethodDeclaration)node.Clone (); + implicitImpl.PrivateImplementationType = AstType.Null; + + // remove visibility modifier, in case the code contains error + implicitImpl.Modifiers &= ~Modifiers.VisibilityMask; + + implicitImpl.Modifiers |= Modifiers.Public; + script.Replace (node, implicitImpl); + }); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertForeachToForAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertForeachToForAction.cs index aa24d024b..6444cdd5a 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertForeachToForAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertForeachToForAction.cs @@ -44,38 +44,46 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring yield break; } yield return new CodeAction(context.TranslateString("Convert 'foreach' loop to 'for'"), script => { - var result = context.Resolve (foreachStatement.InExpression); - var countProperty = GetCountProperty (result.Type); + var result = context.Resolve(foreachStatement.InExpression); + var countProperty = GetCountProperty(result.Type); // TODO: use another variable name if 'i' is already in use - var initializer = new VariableDeclarationStatement (new PrimitiveType ("int"), "i", new PrimitiveExpression (0)); - var id1 = new IdentifierExpression ("i"); - var id2 = id1.Clone (); - var id3 = id1.Clone (); + var initializer = new VariableDeclarationStatement(new PrimitiveType("int"), "i", new PrimitiveExpression(0)); + var id1 = new IdentifierExpression("i"); + var id2 = id1.Clone(); + var id3 = id1.Clone(); - var forStatement = new ForStatement () { + var variableDeclarationStatement = new VariableDeclarationStatement( + foreachStatement.VariableType.Clone(), + foreachStatement.VariableName, + new IndexerExpression(foreachStatement.InExpression.Clone(), id3) + ); + var forStatement = new ForStatement() { Initializers = { initializer }, Condition = new BinaryOperatorExpression (id1, BinaryOperatorType.LessThan, new MemberReferenceExpression (foreachStatement.InExpression.Clone (), countProperty)), Iterators = { new ExpressionStatement (new UnaryOperatorExpression (UnaryOperatorType.PostIncrement, id2)) }, EmbeddedStatement = new BlockStatement { - new VariableDeclarationStatement (foreachStatement.VariableType.Clone (), foreachStatement.VariableName, new IndexerExpression (foreachStatement.InExpression.Clone (), id3)) + variableDeclarationStatement } }; if (foreachStatement.EmbeddedStatement is BlockStatement) { - foreach (var child in ((BlockStatement)foreachStatement.EmbeddedStatement).Statements) { - forStatement.EmbeddedStatement.AddChild (child.Clone (), BlockStatement.StatementRole); + variableDeclarationStatement.Remove(); + var oldBlock = (BlockStatement)foreachStatement.EmbeddedStatement.Clone(); + if (oldBlock.Statements.Any()) { + oldBlock.Statements.InsertBefore(oldBlock.Statements.First(), variableDeclarationStatement); + } else { + oldBlock.Statements.Add(variableDeclarationStatement); } + forStatement.EmbeddedStatement = oldBlock; } else { forStatement.EmbeddedStatement.AddChild (foreachStatement.EmbeddedStatement.Clone (), BlockStatement.StatementRole); } - script.Replace (foreachStatement, forStatement); script.Link (initializer.Variables.First ().NameToken, id1, id2, id3); }); } - static string GetCountProperty(IType type) { if (type.Kind == TypeKind.Array) { diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertIfToConditionalAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertIfToConditionalAction.cs new file mode 100644 index 000000000..31633994b --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertIfToConditionalAction.cs @@ -0,0 +1,138 @@ +// +// ConvertIfToConditionalAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using ICSharpCode.NRefactory.PatternMatching; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring.CodeActions +{ + [ContextAction ("Convert 'if' to '?:'", Description = "Convert 'if' statement to '?:' operator.")] + public class ConvertIfToConditionalAction : SpecializedCodeAction + { + static readonly InsertParenthesesVisitor insertParenthesesVisitor = new InsertParenthesesVisitor (); + protected override CodeAction GetAction (RefactoringContext context, IfElseStatement ifElseStatement) + { + if (!ifElseStatement.IfToken.Contains (context.Location)) + return null; + + var convertAssignment = GetConvertAssignmentAction (context, ifElseStatement); + if (convertAssignment != null) + return convertAssignment; + + var convertReturn = GetConvertReturnAction (context, ifElseStatement); + return convertReturn; + } + + CodeAction GetConvertAssignmentAction (RefactoringContext context, IfElseStatement ifElseStatement) + { + Func extractAssignment = + node => + { + var exprStatement = node as ExpressionStatement; + if (exprStatement != null) + return exprStatement.Expression as AssignmentExpression; + return null; + }; + return GetAction (context, ifElseStatement, extractAssignment, + (assignment1, assignment2) => + { + if (assignment1.Operator != assignment2.Operator || !assignment1.Left.Match (assignment2.Left).Success) + return null; + var conditionalExpr = new ConditionalExpression (ifElseStatement.Condition.Clone (), + assignment1.Right.Clone (), + assignment2.Right.Clone ()); + conditionalExpr.AcceptVisitor (insertParenthesesVisitor); + + var assignment = new AssignmentExpression (assignment1.Left.Clone (), assignment1.Operator, + conditionalExpr); + return new ExpressionStatement (assignment); + }); + } + + CodeAction GetConvertReturnAction (RefactoringContext context, IfElseStatement ifElseStatement) + { + Func extractReturn = node => node as ReturnStatement; + return GetAction (context, ifElseStatement, extractReturn, + (return1, return2) => + { + var conditionalExpr = new ConditionalExpression (ifElseStatement.Condition.Clone (), + return1.Expression.Clone (), + return2.Expression.Clone ()); + conditionalExpr.AcceptVisitor (insertParenthesesVisitor); + return new ReturnStatement (conditionalExpr); + }, + true); + } + + CodeAction GetAction (RefactoringContext context, IfElseStatement ifElseStatement, + Func extractor, Func getReplaceStatement, + bool findImplicitFalseStatement = false) + where T : AstNode + { + + var node1 = GetNode (ifElseStatement.TrueStatement, extractor); + if (node1 == null) + return null; + + var falseStatement = ifElseStatement.FalseStatement; + // try next statement if there is no FalseStatement + if (falseStatement.IsNull && findImplicitFalseStatement) + falseStatement = ifElseStatement.NextSibling as Statement; + + var node2 = GetNode (falseStatement, extractor); + if (node2 == null) + return null; + + var replacement = getReplaceStatement (node1, node2); + if (replacement == null) + return null; + + return new CodeAction (context.TranslateString ("Convert 'if' to '?:'"), + script => + { + script.Replace (ifElseStatement, replacement); + // remove implicit false statement + if (falseStatement != ifElseStatement.FalseStatement) + script.Remove (falseStatement); + }); + } + + static T GetNode (Statement node, Func extract) + where T : AstNode + { + var result = extract (node); + if (result != null) + return result; + + var blockStatement = node as BlockStatement; + if (blockStatement != null && blockStatement.Statements.Count == 1) + return GetNode (blockStatement.Statements.First (), extract); + + return null; + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertIfToSwitchAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertIfToSwitchAction.cs new file mode 100644 index 000000000..257008298 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertIfToSwitchAction.cs @@ -0,0 +1,193 @@ +// +// ConvertIfToSwitchAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.PatternMatching; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Convert 'if' to 'switch'", Description = "Convert 'if' statement to 'switch' statement")] + public class ConvertIfToSwitchAction : SpecializedCodeAction + { + protected override CodeAction GetAction (RefactoringContext context, IfElseStatement node) + { + if (!node.IfToken.Contains (context.Location)) + return null; + + var switchExpr = GetSwitchExpression (context, node.Condition); + if (switchExpr == null) + return null; + + var switchSections = new List (); + if (!CollectSwitchSections (switchSections, context, node, switchExpr)) + return null; + + return new CodeAction (context.TranslateString ("Convert 'if' to 'switch'"), + script => + { + var switchStatement = new SwitchStatement { Expression = switchExpr.Clone () }; + switchStatement.SwitchSections.AddRange (switchSections); + script.Replace (node, switchStatement); + }); + } + + static Expression GetSwitchExpression (RefactoringContext context, Expression expr) + { + var binaryOp = expr as BinaryOperatorExpression; + if (binaryOp == null) + return null; + + if (binaryOp.Operator == BinaryOperatorType.ConditionalOr) + return GetSwitchExpression (context, binaryOp.Left); + + if (binaryOp.Operator == BinaryOperatorType.Equality) { + Expression switchExpr = null; + if (IsConstantExpression (context, binaryOp.Right)) + switchExpr = binaryOp.Left; + if (IsConstantExpression (context, binaryOp.Left)) + switchExpr = binaryOp.Right; + if (switchExpr != null && IsValidSwitchType (context.Resolve (switchExpr).Type)) + return switchExpr; + } + + return null; + } + + static bool IsConstantExpression (RefactoringContext context, Expression expr) + { + if (expr is PrimitiveExpression || expr is NullReferenceExpression) + return true; + return context.Resolve (expr).IsCompileTimeConstant; + } + + static readonly KnownTypeCode [] validTypes = + { + KnownTypeCode.String, KnownTypeCode.Boolean, KnownTypeCode.Char, + KnownTypeCode.Byte, KnownTypeCode.SByte, + KnownTypeCode.Int16, KnownTypeCode.Int32, KnownTypeCode.Int64, + KnownTypeCode.UInt16, KnownTypeCode.UInt32, KnownTypeCode.UInt64 + }; + + static bool IsValidSwitchType (IType type) + { + if (type.Kind == TypeKind.Enum) + return true; + var typeDefinition = type.GetDefinition (); + if (typeDefinition == null) + return false; + + if (typeDefinition.KnownTypeCode == KnownTypeCode.NullableOfT) { + var nullableType = (ParameterizedType)type; + typeDefinition = nullableType.TypeArguments [0].GetDefinition (); + if (typeDefinition == null) + return false; + } + return Array.IndexOf (validTypes, typeDefinition.KnownTypeCode) != -1; + } + + static bool CollectSwitchSections (ICollection result, RefactoringContext context, + IfElseStatement ifStatement, Expression switchExpr) + { + // if + var section = new SwitchSection (); + if (!CollectCaseLabels (section.CaseLabels, context, ifStatement.Condition, switchExpr)) + return false; + CollectSwitchSectionStatements (section.Statements, context, ifStatement.TrueStatement); + result.Add (section); + + if (ifStatement.FalseStatement.IsNull) + return true; + + // else if + var falseStatement = ifStatement.FalseStatement as IfElseStatement; + if (falseStatement != null) + return CollectSwitchSections (result, context, falseStatement, switchExpr); + + // else (default label) + var defaultSection = new SwitchSection (); + defaultSection.CaseLabels.Add (new CaseLabel ()); + CollectSwitchSectionStatements (defaultSection.Statements, context, ifStatement.FalseStatement); + result.Add (defaultSection); + + return true; + } + + static bool CollectCaseLabels (AstNodeCollection result, RefactoringContext context, + Expression condition, Expression switchExpr) + { + if (condition is ParenthesizedExpression) + return CollectCaseLabels (result, context, ((ParenthesizedExpression)condition).Expression, switchExpr); + + var binaryOp = condition as BinaryOperatorExpression; + if (binaryOp == null) + return false; + + if (binaryOp.Operator == BinaryOperatorType.ConditionalOr) + return CollectCaseLabels (result, context, binaryOp.Left, switchExpr) && + CollectCaseLabels (result, context, binaryOp.Right, switchExpr); + + if (binaryOp.Operator == BinaryOperatorType.Equality) { + if (switchExpr.Match (binaryOp.Left).Success) { + if (IsConstantExpression (context, binaryOp.Right)) { + result.Add (new CaseLabel (binaryOp.Right.Clone ())); + return true; + } + } else if (switchExpr.Match (binaryOp.Right).Success) { + if (IsConstantExpression (context, binaryOp.Left)) { + result.Add (new CaseLabel (binaryOp.Left.Clone ())); + return true; + } + } + } + + return false; + } + + static void CollectSwitchSectionStatements (AstNodeCollection result, RefactoringContext context, + Statement statement) + { + BlockStatement blockStatement; + if (statement is BlockStatement) + blockStatement = (BlockStatement)statement.Clone (); + else + blockStatement = new BlockStatement { statement.Clone () }; + + var breackStatement = new BreakStatement (); + blockStatement.Add (breackStatement); + // check if break is needed + var reachabilityAnalysis = context.CreateReachabilityAnalysis (blockStatement); + if (!reachabilityAnalysis.IsReachable (breackStatement)) + blockStatement.Statements.Remove (breackStatement); + + var statements = blockStatement.Statements.ToArray (); + blockStatement.Statements.Clear (); + result.AddRange (statements); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertImplicitToExplicitImplementationAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertImplicitToExplicitImplementationAction.cs new file mode 100644 index 000000000..88ab2ec0a --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertImplicitToExplicitImplementationAction.cs @@ -0,0 +1,60 @@ +// +// ConvertImplicitToExplicitImplementationAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using ICSharpCode.NRefactory.Semantics; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Convert implict to explicit implementation", + Description = " Convert implict implementation of an interface method to explicit implementation")] + public class ConvertImplicitToExplicitImplementationAction : SpecializedCodeAction + { + protected override CodeAction GetAction (RefactoringContext context, MethodDeclaration node) + { + if (!node.PrivateImplementationType.IsNull) + return null; + + if (!node.NameToken.Contains (context.Location)) + return null; + + var method = (IMethod)((MemberResolveResult)context.Resolve (node)).Member; + if (method.ImplementedInterfaceMembers.Count != 1 || method.DeclaringType.Kind == TypeKind.Interface) + return null; + + return new CodeAction (context.TranslateString ("Convert implict to explicit implementation"), + script => + { + var explicitImpl = (MethodDeclaration)node.Clone (); + // remove visibility modifier + explicitImpl.Modifiers &= ~Modifiers.VisibilityMask; + var implementedInterface = method.ImplementedInterfaceMembers [0].DeclaringType; + explicitImpl.PrivateImplementationType = context.CreateShortType (implementedInterface); + script.Replace (node, explicitImpl); + }); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaBodyExpressionToStatementAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaBodyExpressionToStatementAction.cs new file mode 100644 index 000000000..776127dfe --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaBodyExpressionToStatementAction.cs @@ -0,0 +1,61 @@ +// +// ConvertLambdaBodyExpressionToStatementAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Converts expression of lambda body to statement", + Description = "Converts expression of lambda body to statement")] + public class ConvertLambdaBodyExpressionToStatementAction : SpecializedCodeAction + { + + protected override CodeAction GetAction (RefactoringContext context, LambdaExpression node) + { + if (!node.ArrowToken.Contains (context.Location)) + return null; + + var bodyExpr = node.Body as Expression; + if (bodyExpr == null) + return null; + return new CodeAction (context.TranslateString ("Convert to lambda statement"), + script => + { + var body = new BlockStatement (); + if (RequireReturnStatement (context, node)) { + body.Add (new ReturnStatement (bodyExpr.Clone ())); + } else { + body.Add (new ExpressionStatement (bodyExpr.Clone ())); + } + script.Replace (bodyExpr, body); + }); + } + + static bool RequireReturnStatement (RefactoringContext context, LambdaExpression lambda) + { + var type = LambdaHelper.GetLambdaReturnType (context, lambda); + return type != null && type.ReflectionName != "System.Void"; + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaBodyStatementToExpressionAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaBodyStatementToExpressionAction.cs new file mode 100644 index 000000000..0126fea82 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaBodyStatementToExpressionAction.cs @@ -0,0 +1,57 @@ +// +// ConvertLambdaBodyStatementToExpressionAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Converts statement of lambda body to expression", + Description = "Converts statement of lambda body to expression")] + public class ConvertLambdaBodyStatementToExpressionAction : SpecializedCodeAction + { + protected override CodeAction GetAction (RefactoringContext context, LambdaExpression node) + { + if (!node.ArrowToken.Contains (context.Location)) + return null; + + var blockStatement = node.Body as BlockStatement; + if (blockStatement == null || blockStatement.Statements.Count > 1) + return null; + + Expression expr; + var returnStatement = blockStatement.Statements.FirstOrNullObject () as ReturnStatement; + if (returnStatement != null) { + expr = returnStatement.Expression; + } else { + var exprStatement = blockStatement.Statements.FirstOrNullObject () as ExpressionStatement; + if (exprStatement == null) + return null; + expr = exprStatement.Expression; + } + + return new CodeAction (context.TranslateString ("Convert to lambda expression"), + script => script.Replace (blockStatement, expr.Clone ())); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaToAnonymousDelegateAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaToAnonymousDelegateAction.cs new file mode 100644 index 000000000..cb6a555f1 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertLambdaToAnonymousDelegateAction.cs @@ -0,0 +1,80 @@ +// +// ConvertLambdaToDelegateAction.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using ICSharpCode.NRefactory.CSharp.Resolver; +using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Convert lambda to anonymous delegate", + Description = "Converts a lambda to an anonymous delegate.")] + public class ConvertLambdaToAnonymousDelegateAction : SpecializedCodeAction + { + #region implemented abstract members of SpecializedCodeAction + protected override CodeAction GetAction(RefactoringContext context, LambdaExpression node) + { + if (context.Location < node.StartLocation || context.Location >= node.Body.StartLocation) + return null; + + var lambdaResolveResult = context.Resolve(node) as LambdaResolveResult; + if (lambdaResolveResult == null) + return null; + + return new CodeAction(context.TranslateString("Convert to anonymous delegate"), script => { + BlockStatement newBody; + if (node.Body is BlockStatement) { + newBody = (BlockStatement)node.Body.Clone(); + } else { + newBody = new BlockStatement { + Statements = { + new ExpressionStatement((Expression)node.Body.Clone()) + } + }; + } + var method = new AnonymousMethodExpression (newBody, GetParameters(lambdaResolveResult.Parameters, context)); + method.HasParameterList = true; + script.Replace(node, method); + }); + } + #endregion + + IEnumerable GetParameters(IList parameters, RefactoringContext context) + { + foreach (var parameter in parameters) { + var type = context.CreateShortType(parameter.Type); + var name = parameter.Name; + ParameterModifier modifier = ParameterModifier.None; + if (parameter.IsRef) + modifier |= ParameterModifier.Ref; + if (parameter.IsOut) + modifier |= ParameterModifier.Out; + yield return new ParameterDeclaration(type, name, modifier); + } + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertSwitchToIfAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertSwitchToIfAction.cs new file mode 100644 index 000000000..f1a36b347 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertSwitchToIfAction.cs @@ -0,0 +1,147 @@ +// +// ConvertSwitchToIfAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Convert 'switch' to 'if'", Description = "Convert 'switch' statement to 'if' statement")] + public class ConvertSwitchToIfAction : SpecializedCodeAction + { + static readonly InsertParenthesesVisitor insertParenthesesVisitor = new InsertParenthesesVisitor (); + + protected override CodeAction GetAction (RefactoringContext context, SwitchStatement node) + { + if (!node.SwitchToken.Contains (context.Location)) + return null; + + // empty switch + if (node.SwitchSections.Count == 0) + return null; + + // switch with default only + if (node.SwitchSections.First ().CaseLabels.Any (label => label.Expression.IsNull)) + return null; + + // check non-trailing breaks + foreach (var switchSection in node.SwitchSections) { + var lastStatement = switchSection.Statements.LastOrDefault (); + var finder = new NonTrailingBreakFinder (lastStatement as BreakStatement); + if (switchSection.AcceptVisitor (finder)) + return null; + } + + return new CodeAction (context.TranslateString ("Convert 'switch' to 'if'"), + script => + { + IfElseStatement ifStatement = null; + IfElseStatement currentStatement = null; + foreach (var switchSection in node.SwitchSections) { + var condition = CollectCondition (node.Expression, switchSection.CaseLabels); + var bodyStatement = new BlockStatement (); + var lastStatement = switchSection.Statements.LastOrDefault (); + foreach (var statement in switchSection.Statements) { + // skip trailing break + if (statement == lastStatement && statement is BreakStatement) + continue; + bodyStatement.Add (statement.Clone ()); + } + + // default -> else + if (condition == null) { + currentStatement.FalseStatement = bodyStatement; + break; + } + var elseIfStatement = new IfElseStatement (condition, bodyStatement); + if (ifStatement == null) + ifStatement = elseIfStatement; + else + currentStatement.FalseStatement = elseIfStatement; + currentStatement = elseIfStatement; + } + script.Replace (node, ifStatement); + script.FormatText (ifStatement); + }); + } + + static Expression CollectCondition(Expression switchExpr, AstNodeCollection caseLabels) + { + // default + if (caseLabels.Count == 0 || caseLabels.Any (label => label.Expression.IsNull)) + return null; + + var conditionList = caseLabels.Select ( + label => new BinaryOperatorExpression (switchExpr.Clone (), BinaryOperatorType.Equality, label.Expression.Clone ())) + .ToArray (); + + // insert necessary parentheses + foreach (var expr in conditionList) + expr.AcceptVisitor (insertParenthesesVisitor); + + if (conditionList.Length == 1) + return conditionList [0]; + + // combine case labels into an conditional or expression + BinaryOperatorExpression condition = null; + BinaryOperatorExpression currentCondition = null; + for (int i = 0; i < conditionList.Length - 1; i++) { + var newCondition = new BinaryOperatorExpression + { + Operator = BinaryOperatorType.ConditionalOr, + Left = conditionList[i] + }; + if (currentCondition == null) + condition = newCondition; + else + currentCondition.Right = newCondition; + currentCondition = newCondition; + } + currentCondition.Right = conditionList [conditionList.Length - 1]; + + return condition; + } + + class NonTrailingBreakFinder : DepthFirstAstVisitor + { + BreakStatement trailingBreakStatement; + + public NonTrailingBreakFinder (BreakStatement trailingBreak) + { + trailingBreakStatement = trailingBreak; + } + + protected override bool VisitChildren (AstNode node) + { + return node.Children.Any (child => child.AcceptVisitor (this)); + } + + public override bool VisitBreakStatement (BreakStatement breakStatement) + { + return breakStatement != trailingBreakStatement; + } + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/ConvertInitializerToExplicitInitializationsAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/ConvertInitializerToExplicitInitializationsAction.cs new file mode 100644 index 000000000..1dbb82c9d --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/ConvertInitializerToExplicitInitializationsAction.cs @@ -0,0 +1,208 @@ +// +// ConvertInitializerToExplicitInitializationsAction.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// 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; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Convert to explicit initializers", + Description = "Converts an object or collection initializer to explicit initializations.")] + public class ConvertInitializerToExplicitInitializationsAction : ICodeActionProvider + { + #region ICodeActionProvider implementation + + public IEnumerable GetActions(RefactoringContext context) + { + var codeAction = GetActionForVariableInitializer(context); + if (codeAction != null) { + yield return codeAction; + yield break; + } + codeAction = GetActionForAssignmentExpression(context); + if (codeAction != null) { + yield return codeAction; + yield break; + } + } + + public CodeAction GetActionForVariableInitializer(RefactoringContext context) + { + var variableInitializer = context.GetNode(); + if (variableInitializer == null) + return null; + var declaration = variableInitializer.Parent as VariableDeclarationStatement; + if (declaration == null) + return null; + if (variableInitializer.Initializer.IsNull) + return null; + var objectCreateExpression = variableInitializer.Initializer as ObjectCreateExpression; + if (objectCreateExpression == null) + return null; + var converter = new InitializerConversionVisitor(context); + Expression finalExpression; + var statements = converter.ConvertInitializer(objectCreateExpression, out finalExpression); + if (statements.Count > 0) { + return new CodeAction(context.TranslateString("Convert to explicit initializers"), script => { + foreach (var statement in statements) { + script.InsertBefore(declaration, statement); + } + script.Replace(variableInitializer.Initializer, finalExpression); + }); + } + return null; + } + + public CodeAction GetActionForAssignmentExpression(RefactoringContext context) + { + var assignmentExpression = context.GetNode(); + if (assignmentExpression == null) + return null; + var expressionStatement = assignmentExpression.Parent as ExpressionStatement; + if (expressionStatement == null) + return null; + var objectCreateExpression = assignmentExpression.Right as ObjectCreateExpression; + if (objectCreateExpression == null) + return null; + var converter = new InitializerConversionVisitor(context); + Expression finalExpression; + var statements = converter.ConvertInitializer(objectCreateExpression, out finalExpression); + if (statements.Count > 0) { + return new CodeAction(context.TranslateString("Convert to explicit initializers"), script => { + foreach (var statement in statements) { + script.InsertBefore(expressionStatement, statement); + } + script.Replace(assignmentExpression.Right, finalExpression); + }); + } + return null; + } + #endregion + + class InitializerConversionVisitor : DepthFirstAstVisitor + { + RefactoringContext context; + IList statements; + NamingHelper namingHelper; + + public InitializerConversionVisitor(RefactoringContext context) + { + this.context = context; + namingHelper = new NamingHelper(context); + } + + AstType GetDeclarationType(AstType type) + { + AstType declarationType; + if (context.UseExplicitTypes) { + declarationType = type.Clone(); + } else { + declarationType = new SimpleType("var"); + } + return declarationType; + } + + public IList ConvertInitializer(ObjectCreateExpression initializer, out Expression finalExpression) + { + statements = new List(); + + finalExpression = initializer.AcceptVisitor(this, null); + + return statements; + } + + public override Expression VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, Expression data) + { + var creationType = objectCreateExpression.Type.Clone(); + + var parameters = objectCreateExpression.Arguments.Select(arg => arg.Clone()); + var newCreation = new ObjectCreateExpression(creationType, parameters); + if (objectCreateExpression.Initializer.IsNull) { + return newCreation; + } else { + AstType declarationType = GetDeclarationType(objectCreateExpression.Type); + var name = namingHelper.GenerateVariableName(objectCreateExpression.Type); + var variableInitializer = new VariableDeclarationStatement(declarationType, name, newCreation); + statements.Add(variableInitializer); + + var identifier = new IdentifierExpression(name); + base.VisitObjectCreateExpression(objectCreateExpression, identifier); + + return identifier; + } + } + + public override Expression VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, Expression data) + { + if (!(arrayInitializerExpression.Parent is ArrayInitializerExpression)) { + return base.VisitArrayInitializerExpression(arrayInitializerExpression, data); + } + // this a tuple in a collection initializer + var arguments = arrayInitializerExpression.Elements.Select(element => element.AcceptVisitor(this, null).Clone()); + var method = new MemberReferenceExpression { + Target = data.Clone(), + MemberName = "Add" + }; + var statement = new ExpressionStatement(new InvocationExpression(method, arguments)); + statements.Add(statement); + + return null; + } + + public override Expression VisitNamedExpression(NamedExpression namedExpression, Expression data) + { + var member = new MemberReferenceExpression { + Target = data.Clone(), + MemberName = namedExpression.Name + }; + var expression = namedExpression.Expression.AcceptVisitor(this, member); + if (expression != null) { + var statement = new ExpressionStatement { + Expression = new AssignmentExpression { + Left = member, + Right = expression.Clone() + } + }; + statements.Add(statement); + } + + return null; + } + + protected override Expression VisitChildren(AstNode node, Expression data) + { + // Most expressions should just be used as-is, and + // a) need not be visited + // b) only return themselves + if (node is Expression && !(node is ObjectCreateExpression || node is ArrayInitializerExpression || node is NamedExpression)){ + return (Expression)node; + } + return base.VisitChildren(node, data); + } + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/ConvertToInitializerAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/ConvertToInitializerAction.cs new file mode 100644 index 000000000..bfb248541 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/ConvertToInitializerAction.cs @@ -0,0 +1,109 @@ +// +// ConvertToInitializerAction.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// 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; +using ICSharpCode.NRefactory.Semantics; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Convert to initializer", + Description = "Converts a set of assignments and .Add() calls to an initializer.")] + public class ConvertToInitializerAction : ICodeActionProvider + { + #region ICodeActionProvider implementation + public IEnumerable GetActions(RefactoringContext context) + { + var initializer = context.GetNode(); + if (initializer != null) { + var action = HandleInitializer(context, initializer); + if (action != null) + yield return action; + } + var expressionStatement = context.GetNode(); + if (expressionStatement != null) { + var action = HandleExpressionStatement(context, expressionStatement); + if (action != null) + yield return action; + } + } + + CodeAction HandleInitializer(RefactoringContext context, VariableInitializer initializer) + { + var objectCreateExpression = initializer.Initializer as ObjectCreateExpression; + if (objectCreateExpression == null) + return null; + var initializerRR = context.Resolve(initializer) as LocalResolveResult; + if (initializerRR == null) + return null; + IList statements = GetNodes(context.GetNode()); + var converter = new StatementsToInitializerConverter(context); + var newInitializer = converter.ConvertToInitializer(initializer, ref statements); + if (statements.Count == 0) + return null; + return MakeAction(context, initializer, newInitializer, statements); + } + + CodeAction HandleExpressionStatement(RefactoringContext context, ExpressionStatement expressionStatement) + { + var expression = expressionStatement.Expression as AssignmentExpression; + if (expression == null) + return null; + if (!(expression.Right is ObjectCreateExpression)) + return null; + var expressionResolveResult = context.Resolve(expression.Left); + if (!(expressionResolveResult is LocalResolveResult) && !(expressionResolveResult is MemberResolveResult)) + return null; + IList statements = GetNodes(context.GetNode()); + var converter = new StatementsToInitializerConverter(context); + var newExpression = converter.ConvertToInitializer(expression, ref statements); + if (statements.Count == 0) + return null; + return MakeAction(context, expression, newExpression, statements); + } + + List GetNodes(Statement startStatement) + { + var statements = new List(); + AstNode currentNode = startStatement.NextSibling; + while (currentNode != null) { + if (currentNode is Statement || currentNode is Comment) + statements.Add(currentNode); + currentNode = currentNode.NextSibling; + } + return statements; + } + + CodeAction MakeAction(RefactoringContext context, AstNode oldNode, AstNode replacementNode, IEnumerable toRemove) + { + return new CodeAction(context.TranslateString("Convert to initializer"), script => { + foreach (var statement in toRemove) + script.Remove(statement); + script.Replace(oldNode, replacementNode); + }); + } + #endregion + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/InitializerPath.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/InitializerPath.cs new file mode 100644 index 000000000..ba3573bf3 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/InitializerPath.cs @@ -0,0 +1,180 @@ +// +// InitializerPath.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using ICSharpCode.NRefactory.CSharp.Refactoring; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Semantics; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + class InitializerPath + { + InitializerPath(object anchor) + { + this.anchor = anchor; + MemberPath = new List(); + } + + public InitializerPath(IVariable target) : this((object)target) + { + } + + public InitializerPath(IMember target) : this((object)target) + { + } + + public static InitializerPath FromResolveResult(ResolveResult resolveResult) + { + InitializerPath initializerPath = null; + var memberPath = new List(); + var currentResolveResult = resolveResult; + do { + if (currentResolveResult is MemberResolveResult) { + var memberResolveResult = (MemberResolveResult)currentResolveResult; + memberPath.Add(memberResolveResult.Member); + currentResolveResult = memberResolveResult.TargetResult; + } else if (currentResolveResult is LocalResolveResult) { + var localResolveResult = (LocalResolveResult)currentResolveResult; + memberPath.Reverse(); + initializerPath = new InitializerPath(localResolveResult.Variable) { + MemberPath = memberPath + }; + break; + } else if (currentResolveResult is ThisResolveResult) { + break; + } else { + return null; + } + + } while (currentResolveResult != null); + + if (initializerPath == null) { + // This path is rooted at a member + memberPath.Reverse(); + initializerPath = new InitializerPath(memberPath [0]) { + MemberPath = memberPath.Skip(1).ToList() + }; + } + return initializerPath; + } + + public InitializerPath GetParentPath() + { + if (MemberPath.Count < 1) + throw new InvalidOperationException("Cannot get the parent path of a path that does not contain any members."); + return new InitializerPath(anchor) { + MemberPath = MemberPath.Take(MemberPath.Count - 1).ToList() + }; + } + + public bool IsSubPath(InitializerPath other) + { + if (!other.anchor.Equals(anchor)) + return false; + if (MemberPath.Count <= other.MemberPath.Count) + return false; + for (int i = 0; i < other.MemberPath.Count; i++) { + if (MemberPath [i] != other.MemberPath [i]) + return false; + } + return true; + } + + public int Level { get { return MemberPath.Count + 1; } } + + object anchor; + + public IVariable VariableRoot { + get { return anchor as IVariable; } + } + + public IMember MemberRoot { + get { return anchor as IMember; } + } + + public string RootName { + get { + if (anchor is IMember) + return (anchor as IMember).Name; + else + return (anchor as IVariable).Name; + } + } + + public IList MemberPath { get; private set; } + + public override bool Equals(object obj) + { + if (obj.GetType() != typeof(InitializerPath)) + return false; + + var other = (InitializerPath)obj; + + if (!object.Equals(anchor, other.anchor)) + return false; + + if (MemberPath.Count != other.MemberPath.Count) + return false; + + for (int i = 0; i < MemberPath.Count; i++) { + if (!object.Equals(MemberPath [i], other.MemberPath [i])) + return false; + } + return true; + } + + public override int GetHashCode() + { + int hash = anchor.GetHashCode(); + foreach (var member in MemberPath) + hash ^= member.GetHashCode(); + return hash; + } + + public static bool operator==(InitializerPath left, InitializerPath right) + { + return object.Equals(left, right); + } + + public static bool operator!=(InitializerPath left, InitializerPath right) + { + return !object.Equals(left, right); + } + + public override string ToString() + { + if (MemberPath.Count > 0) + return string.Format("[InitializerPath: {0}.{1}]", RootName, + string.Join(".", MemberPath.Select(member => member.Name))); + else + return string.Format("[InitializerPath: {0}]", RootName); + } + } + +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/StatementsToInitializerConverter.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/StatementsToInitializerConverter.cs new file mode 100644 index 000000000..fe3c1a6c8 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ConvertToInitializer/StatementsToInitializerConverter.cs @@ -0,0 +1,428 @@ +// +// StatementsToInitializerConverter.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using ICSharpCode.NRefactory.CSharp.Refactoring; +using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.Semantics; +using System.Linq; +using ICSharpCode.NRefactory.CSharp.Resolver; +using System.Threading; +using System.Diagnostics; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public class StatementsToInitializerConverter + { + IDictionary initializers = new Dictionary(); + IList comments = new List(); + InitializerPath mainInitializerPath; + RefactoringContext context; + + public StatementsToInitializerConverter(RefactoringContext context) + { + this.context = context; + } + + void Initialize(AstNode targetNode) + { + var target = context.Resolve(targetNode); + if (target is LocalResolveResult) { + mainInitializerPath = new InitializerPath(((LocalResolveResult)target).Variable); + } else if (target is MemberResolveResult) { + mainInitializerPath = new InitializerPath(((MemberResolveResult)target).Member); + } else { + throw new ArgumentException("variableInitializer must target a variable or a member."); + } + } + + public VariableInitializer ConvertToInitializer(VariableInitializer variableInitializer, ref IList statements) + { + if (variableInitializer == null) + throw new ArgumentNullException("variableInitializer"); + if (statements == null) + throw new ArgumentNullException("statements"); + + Initialize(variableInitializer); + initializers [mainInitializerPath] = variableInitializer.Initializer.Clone(); + + Convert(statements); + statements = ReplacementNodeHelper.GetReplacedNodes(initializers [mainInitializerPath]); + return new VariableInitializer(mainInitializerPath.RootName, initializers [mainInitializerPath]); + } + + public AssignmentExpression ConvertToInitializer(AssignmentExpression assignmentExpression, ref IList statements) + { + if (assignmentExpression == null) + throw new ArgumentNullException("assignmentExpression"); + if (statements == null) + throw new ArgumentNullException("statements"); + if (!(assignmentExpression.Right is ObjectCreateExpression)) + throw new ArgumentException("assignmentExpression.Right must be an ObjectCreateExpression", "assignmentExpression"); + + Initialize(assignmentExpression.Left); + initializers [mainInitializerPath] = assignmentExpression.Right.Clone(); + + Convert(statements); + statements = ReplacementNodeHelper.GetReplacedNodes(initializers [mainInitializerPath]); + return new AssignmentExpression(new IdentifierExpression(mainInitializerPath.RootName), initializers [mainInitializerPath]); + } + + void Convert(IList originalStatements) + { + foreach (var node in originalStatements) { + var comment = node as Comment; + if (comment != null) { + comments.Add((Comment)ReplacementNodeHelper.CloneWithReplacementAnnotation(comment, node)); + continue; + } + var success = TryHandleInitializer(node); + if (success) { + continue; + } + var expressionStatement = node as ExpressionStatement; + if (expressionStatement == null) + break; + success = TryHandleAssignmentExpression(expressionStatement); + if (success) { + continue; + } + success = TryHandleAddCall(expressionStatement); + if (success) { + continue; + } + break; + } + } + + bool TryHandleInitializer(AstNode node) + { + VariableInitializer variableInitializer; + var variableDeclarationStatement = node as VariableDeclarationStatement; + if (variableDeclarationStatement == null) { + variableInitializer = VariableInitializer.Null; + return false; + } + variableInitializer = variableDeclarationStatement.Variables.FirstOrNullObject(); + if (variableInitializer.IsNull) + return false; + var sourceResolveResult = context.Resolve(variableInitializer.Initializer) as LocalResolveResult; + if (HasDependency(variableInitializer.Initializer) && !CanReplaceDependent(sourceResolveResult)) + return false; + var targetResolveResult = context.Resolve(variableInitializer) as LocalResolveResult; + AddNewVariable(targetResolveResult.Variable, variableInitializer.Initializer, node); + return true; + } + + bool TryHandleAddCall(ExpressionStatement expressionStatement) + { + var invocationExpression = expressionStatement.Expression as InvocationExpression; + if (invocationExpression == null) + return false; + var target = invocationExpression.Target; + var invocationResolveResult = context.Resolve(invocationExpression) as InvocationResolveResult; + if (invocationResolveResult == null) + return false; + if (invocationResolveResult.Member.Name != "Add") + return false; + var targetResult = invocationResolveResult.TargetResult; + if (targetResult is MemberResolveResult) + return false; + + ArrayInitializerExpression tuple = new ArrayInitializerExpression(); + foreach (var argument in invocationExpression.Arguments) { + var argumentLocalResolveResult = context.Resolve(argument) as LocalResolveResult; + if (argumentLocalResolveResult != null) { + var initializerPath = InitializerPath.FromResolveResult(argumentLocalResolveResult); + if (initializerPath == null || !initializers.ContainsKey(initializerPath)) + return false; + // Add a clone, since we do not yet know if this is where the initializer will be used + var initializerClone = initializers[initializerPath].Clone(); + tuple.Elements.Add(initializerClone); + } else { + tuple.Elements.Add(argument.Clone()); + } + } + ReplacementNodeHelper.AddReplacementAnnotation(tuple, expressionStatement); + + var targetPath = InitializerPath.FromResolveResult(targetResult); + if (targetPath == null || !initializers.ContainsKey(targetPath)) + return false; + InsertImplicitInitializersForPath(targetPath); + var targetInitializer = initializers [targetPath]; + AddToInitializer(targetInitializer, tuple); + return true; + } + + bool TryHandleAssignmentExpression(ExpressionStatement expressionStatement) + { + var assignmentExpression = expressionStatement.Expression as AssignmentExpression; + if (assignmentExpression == null) + return false; + var resolveResult = context.Resolve(assignmentExpression.Right); + if (HasDependency(assignmentExpression.Right) && !CanReplaceDependent(resolveResult)) + return false; + var success = PushAssignment(assignmentExpression.Left, assignmentExpression.Right, expressionStatement); + return success; + } + + bool CanReplaceDependent(ResolveResult resolveResult) + { + return resolveResult is LocalResolveResult; + } + + void AddNewVariable(IVariable variable, Expression initializer, AstNode node) + { + var variablePath = new InitializerPath(variable); + var rightResolveResult = context.Resolve(initializer) as LocalResolveResult; + if (rightResolveResult != null) { + var rightPath = InitializerPath.FromResolveResult(rightResolveResult); + if (rightPath != null && initializers.ContainsKey(rightPath)) { + var rightInitializer = initializers [rightPath]; + ReplacementNodeHelper.AddReplacementAnnotation(rightInitializer, node); + initializers.Remove(rightPath); + initializers [variablePath] = rightInitializer; + if (rightPath == mainInitializerPath) { + mainInitializerPath = variablePath; + } + } + } else { + initializers [variablePath] = ReplacementNodeHelper.CloneWithReplacementAnnotation(initializer, node); + } + } + + void AddOldAnnotationsToInitializer(InitializerPath targetPath, Expression initializer) + { + if (targetPath != null) { + if (initializers.ContainsKey(targetPath)) { + foreach (var astNode in ReplacementNodeHelper.GetAllReplacementAnnotations(initializers[targetPath])) { + initializer.AddAnnotation(astNode); + } + } + } + } + + bool PushAssignment(Expression left, Expression right, AstNode node) + { + var rightResolveResult = context.Resolve(right) as LocalResolveResult; + var leftResolveResult = context.Resolve(left); + Expression initializer; + if (rightResolveResult != null) { + var rightPath = InitializerPath.FromResolveResult(rightResolveResult); + if (initializers.ContainsKey(rightPath)) { + initializer = initializers [rightPath]; + } else { + initializer = right.Clone(); + } + } else { + initializer = right.Clone(); + } + var leftPath = InitializerPath.FromResolveResult(leftResolveResult); + if (leftPath == null) { + return false; + } + // Move replacement annotations over, in case this is the second assignment + // to the same variable. + AddOldAnnotationsToInitializer(leftPath, initializer); + + if (leftResolveResult is LocalResolveResult) { + ReplacementNodeHelper.AddReplacementAnnotation(initializer, node); + initializers [leftPath] = initializer; + return true; + } + if (!(leftResolveResult is MemberResolveResult)) + return false; + + Debug.Assert(leftPath.Level > 1, "No top level assignment should get here."); + + var parentKey = leftPath.GetParentPath(); + var member = leftPath.MemberPath.Last(); + + var success = InsertImplicitInitializersForPath(parentKey); + if (!success) + return false; + + var parentInitializer = initializers [parentKey]; + AddToInitializer(parentInitializer, comments.ToArray()); + comments.Clear(); + + AddToInitializer(parentInitializer, new NamedExpression(member.Name, initializer)); + ReplacementNodeHelper.AddReplacementAnnotation(initializer, node); + initializers [leftPath] = initializer; + return true; + } + + static void AddNodesToInitializer(Expression initializer, params AstNode[] nodes) + { + foreach (var node in nodes) { + if (node is Expression) { + initializer.AddChild((Expression)node, Roles.Expression); + } else if (node is Comment) { + initializer.AddChild((Comment)node, Roles.Comment); + } + } + } + + void AddToInitializer(Expression initializer, params AstNode[] nodes) + { + if (initializer is ArrayInitializerExpression) { + var arrayInitializerExpression = (ArrayInitializerExpression)initializer; + AddNodesToInitializer(arrayInitializerExpression, nodes); + } else if (initializer is ObjectCreateExpression) { + var objectCreateExpression = (ObjectCreateExpression)initializer; + + if (objectCreateExpression.Initializer.IsNull) + objectCreateExpression.Initializer = new ArrayInitializerExpression(); + + AddNodesToInitializer(objectCreateExpression.Initializer, nodes); + } + } + + bool HasDependency(Expression expression) + { + var referenceFinder = new FindReferences(); + return HasDependency(referenceFinder, expression); + } + + bool HasDependency(FindReferences referenceFinder, Expression expression) + { + if (HasDependencyCheck(referenceFinder, expression)) + return true; + var queue = new Queue(); + queue.Enqueue(context.Resolve(expression)); + do { + var result = queue.Dequeue(); + if (result is LocalResolveResult && HasDependencyCheck(referenceFinder, (LocalResolveResult)result)) { + return true; + } + foreach (var childResult in result.GetChildResults()) { + queue.Enqueue(childResult); + } + } while (queue.Count > 0); + return false; + } + + bool HasDependencyCheck(FindReferences referenceFinder, LocalResolveResult localResolveResult) + { + bool result = false; + referenceFinder.FindLocalReferences(localResolveResult.Variable, context.UnresolvedFile, + (SyntaxTree)context.RootNode, context.Compilation, + (node, resolveResult) => { + result |= VariableHasBeenConverted(localResolveResult.Variable); + }, CancellationToken.None); + return result; + } + + bool HasDependencyCheck(FindReferences referenceFinder, Expression expression) + { + var memberReferences = from exp in expression.DescendantsAndSelf + let memberReference = exp as MemberReferenceExpression + where memberReference != null + select memberReference; + foreach (var memberReference in memberReferences) { + var resolveResult = context.Resolve(memberReference) as MemberResolveResult; + if (resolveResult == null) + continue; + var initializerPath = InitializerPath.FromResolveResult(resolveResult); + if (initializerPath != null && initializers.ContainsKey(initializerPath)) + return true; + } + return false; + } + + bool VariableHasBeenConverted(IVariable variable) + { + return initializers.Any(item => item.Key.VariableRoot.Equals(variable)); + } + + bool InsertImplicitInitializersForPath(InitializerPath path) + { + if (initializers.ContainsKey(path)) + return true; + + if (path.MemberPath.Count == 0) + return false; + var parentPath = path.GetParentPath(); + var success = InsertImplicitInitializersForPath(parentPath); + if (!success) + return false; + + var parentInitializer = initializers [parentPath]; + var initializer = new ArrayInitializerExpression(); + var namedExpression = new NamedExpression(path.MemberPath [path.MemberPath.Count - 1].Name, initializer); + AddToInitializer(parentInitializer, namedExpression); + initializers [path] = initializer; + return true; + } + + } + + class ReplacementNodeAnnotation + { + public AstNode ReplacedNode { get; set; } + } + + class ReplacementNodeHelper + { + public static void AddReplacementAnnotation(AstNode node, AstNode replacedNode) + { + node.AddAnnotation(new ReplacementNodeAnnotation() { + ReplacedNode = replacedNode + }); + } + + public static AstNode CloneWithReplacementAnnotation(AstNode node, AstNode replacedNode) + { + var newNode = node.Clone(); + AddReplacementAnnotation(newNode, replacedNode); + return newNode; + } + + public static Expression CloneWithReplacementAnnotation(Expression expression, AstNode replacedNode) + { + var newExpression = expression.Clone(); + AddReplacementAnnotation(newExpression, replacedNode); + return newExpression; + } + + public static IEnumerable GetAllReplacementAnnotations(AstNode node) + { + return + from n in node.DescendantsAndSelf + from annotation in n.Annotations + let replacementAnnotation = annotation as ReplacementNodeAnnotation + where replacementAnnotation != null + select replacementAnnotation; + } + + public static IList GetReplacedNodes(AstNode expression) + { + return GetAllReplacementAnnotations(expression) + .Select(a => a.ReplacedNode) + .ToList(); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateBackingStoreAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateBackingStoreAction.cs index 9d90ba338..1c83f0958 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateBackingStoreAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateBackingStoreAction.cs @@ -46,6 +46,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring // create field var backingStore = new FieldDeclaration (); + if (property.Modifiers.HasFlag (Modifiers.Static)) + backingStore.Modifiers |= Modifiers.Static; backingStore.ReturnType = property.ReturnType.Clone (); var initializer = new VariableInitializer (backingStoreName); diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateClassDeclarationAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateClassDeclarationAction.cs index 73e06f15e..81295afc0 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateClassDeclarationAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateClassDeclarationAction.cs @@ -63,7 +63,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring }); yield return new CodeAction(context.TranslateString("Create nested class"), script => { - script.InsertWithCursor(context.TranslateString("Create nested class"), CreateType(context, service, node), Script.InsertPosition.Before); + script.InsertWithCursor( + context.TranslateString("Create nested class"), + Script.InsertPosition.Before, + CreateType(context, service, node) + ); }); } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateConstructorDeclarationAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateConstructorDeclarationAction.cs index 0b4161dc2..b4629051f 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateConstructorDeclarationAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateConstructorDeclarationAction.cs @@ -50,9 +50,13 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring new ThrowStatement(new ObjectCreateExpression(context.CreateShortType("System", "NotImplementedException"))) } }; - decl.Parameters.AddRange(CreateMethodDeclarationAction.GenerateParameters (context, createExpression.Arguments)); + decl.Parameters.AddRange(CreateMethodDeclarationAction.GenerateParameters(context, createExpression.Arguments)); - script.InsertWithCursor(context.TranslateString("Create constructor"), decl, resolveResult.Member.DeclaringTypeDefinition); + script.InsertWithCursor( + context.TranslateString("Create constructor"), + resolveResult.Member.DeclaringTypeDefinition, + decl + ); }); } } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateCustomEventImplementationAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateCustomEventImplementationAction.cs new file mode 100644 index 000000000..3becd9398 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateCustomEventImplementationAction.cs @@ -0,0 +1,66 @@ +// +// CreateCustomEventImplementationAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Create custom event implementation", Description = "Create custom event implementation.")] + public class CreateCustomEventImplementationAction : SpecializedCodeAction + { + protected override CodeAction GetAction (RefactoringContext context, VariableInitializer node) + { + var eventDecl = node.Parent as EventDeclaration; + if (eventDecl == null) + return null; + return new CodeAction (context.TranslateString ("Create custom event implementation"), + script => + { + var accessor = new Accessor + { + Body = new BlockStatement + { + new ThrowStatement( + new ObjectCreateExpression(context.CreateShortType("System", "NotImplementedException"))) + } + }; + var e = new CustomEventDeclaration + { + Name = node.Name, + Modifiers = eventDecl.Modifiers, + ReturnType = eventDecl.ReturnType.Clone (), + AddAccessor = accessor, + RemoveAccessor = (Accessor)accessor.Clone(), + }; + if (eventDecl.Variables.Count > 1) { + var newEventDecl = (EventDeclaration)eventDecl.Clone (); + newEventDecl.Variables.Remove ( + newEventDecl.Variables.FirstOrNullObject (v => v.Name == node.Name)); + script.InsertBefore (eventDecl, newEventDecl); + } + script.Replace (eventDecl, e); + }); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateEventInvocatorAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateEventInvocatorAction.cs index f8df32298..4e62c80dc 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateEventInvocatorAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateEventInvocatorAction.cs @@ -53,25 +53,25 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (invokeMethod == null) { yield break; } - yield return new CodeAction (context.TranslateString("Create event invocator"), script => { + yield return new CodeAction(context.TranslateString("Create event invocator"), script => { bool hasSenderParam = false; IEnumerable pars = invokeMethod.Parameters; - if (invokeMethod.Parameters.Any ()) { + if (invokeMethod.Parameters.Any()) { var first = invokeMethod.Parameters [0]; if (first.Name == "sender" /*&& first.Type == "System.Object"*/) { hasSenderParam = true; - pars = invokeMethod.Parameters.Skip (1); + pars = invokeMethod.Parameters.Skip(1); } } const string handlerName = "handler"; - var arguments = new List (); + var arguments = new List(); if (hasSenderParam) - arguments.Add (new ThisReferenceExpression ()); + arguments.Add(new ThisReferenceExpression()); foreach (var par in pars) - arguments.Add (new IdentifierExpression (par.Name)); + arguments.Add(new IdentifierExpression(par.Name)); - var methodDeclaration = new MethodDeclaration () { + var methodDeclaration = new MethodDeclaration() { Name = "On" + initializer.Name, ReturnType = new PrimitiveType ("void"), Modifiers = ICSharpCode.NRefactory.CSharp.Modifiers.Protected | ICSharpCode.NRefactory.CSharp.Modifiers.Virtual, @@ -85,12 +85,16 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring }; foreach (var par in pars) { - var typeName = context.CreateShortType (par.Type); - var decl = new ParameterDeclaration (typeName, par.Name); - methodDeclaration.Parameters.Add (decl); + var typeName = context.CreateShortType(par.Type); + var decl = new ParameterDeclaration(typeName, par.Name); + methodDeclaration.Parameters.Add(decl); } - script.InsertWithCursor (context.TranslateString("Create event invocator"), methodDeclaration, Script.InsertPosition.After); + script.InsertWithCursor( + context.TranslateString("Create event invocator"), + Script.InsertPosition.After, + methodDeclaration + ); }); } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateFieldAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateFieldAction.cs index 117d6ed11..e93a827d9 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateFieldAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateFieldAction.cs @@ -46,20 +46,28 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring public IEnumerable GetActions(RefactoringContext context) { - var identifier = context.GetNode(); - if (identifier == null) + var expr = context.GetNode(n => n is IdentifierExpression || n is MemberReferenceExpression) as Expression; + if (expr == null) yield break; - if (IsInvocationTarget(identifier)) + + if (expr is MemberReferenceExpression && !(((MemberReferenceExpression)expr).Target is ThisReferenceExpression)) + yield break; + + var propertyName = CreatePropertyAction.GetPropertyName(expr); + if (propertyName == null) + yield break; + + if (IsInvocationTarget(expr)) yield break; - var statement = identifier.GetParent(); + var statement = expr.GetParent(); if (statement == null) yield break; - if (!(context.Resolve(identifier).IsError)) + if (!(context.Resolve(expr).IsError)) yield break; - var guessedType = CreateFieldAction.GuessAstType(context, identifier); + var guessedType = CreateFieldAction.GuessAstType(context, expr); if (guessedType == null) yield break; - var state = context.GetResolverStateBefore(identifier); + var state = context.GetResolverStateBefore(expr); if (state.CurrentMember == null || state.CurrentTypeDefinition == null) yield break; @@ -73,11 +81,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring yield return new CodeAction(context.TranslateString("Create field"), script => { var decl = new FieldDeclaration() { ReturnType = guessedType, - Variables = { new VariableInitializer(identifier.Identifier) } + Variables = { new VariableInitializer(propertyName) } }; if (isStatic) decl.Modifiers |= Modifiers.Static; - script.InsertWithCursor(context.TranslateString("Create field"), decl, Script.InsertPosition.Before); + script.InsertWithCursor(context.TranslateString("Create field"), Script.InsertPosition.Before, decl); }); } @@ -131,6 +139,24 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring } } + static IType GetElementType(CSharpAstResolver resolver, IType type) + { + // TODO: A better get element type method. + if (type.Kind == TypeKind.Array || type.Kind == TypeKind.Dynamic) { + if (type.Kind == TypeKind.Array) + return ((ArrayType)type).ElementType; + return resolver.Compilation.FindType(KnownTypeCode.Object); + } + + foreach (var method in type.GetMethods (m => m.Name == "GetEnumerator")) { + var pr = method.ReturnType.GetProperties(p => p.Name == "Current").FirstOrDefault(); + if (pr != null) + return pr.ReturnType; + } + + return resolver.Compilation.FindType(KnownTypeCode.Object); + } + internal static IEnumerable GetValidTypes(CSharpAstResolver resolver, Expression expr) { if (expr.Parent is DirectionExpression) { @@ -141,11 +167,24 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring } } + if (expr.Parent is ArrayInitializerExpression) { + var aex = expr.Parent as ArrayInitializerExpression; + if (aex.IsSingleElement) + aex = aex.Parent as ArrayInitializerExpression; + var type = GetElementType(resolver, resolver.Resolve(aex.Parent).Type); + if (type.Kind != TypeKind.Unknown) + return new [] { type }; + } + if (expr.Parent is ObjectCreateExpression) { - var parent = expr.Parent; - if (parent is ObjectCreateExpression) { - var invoke = (ObjectCreateExpression)parent; - return GetAllValidTypesFromObjectCreation(resolver, invoke, expr); + var invoke = (ObjectCreateExpression)expr.Parent; + return GetAllValidTypesFromObjectCreation(resolver, invoke, expr); + } + + if (expr.Parent is ArrayCreateExpression) { + var ace = (ArrayCreateExpression)expr.Parent; + if (!ace.Type.IsNull) { + return new [] { resolver.Resolve(ace.Type).Type }; } } @@ -159,6 +198,9 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (expr.Parent is VariableInitializer) { var initializer = (VariableInitializer)expr.Parent; + var field = initializer.GetParent(); + if (field != null) + return new [] { resolver.Resolve(field.ReturnType).Type }; return new [] { resolver.Resolve(initializer).Type }; } @@ -185,8 +227,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring } if (expr.Parent is ReturnStatement) { - var state = resolver.GetResolverStateBefore(expr); - if (state != null) + var state = resolver.GetResolverStateBefore(expr.Parent); + if (state != null && state.CurrentMember != null) return new [] { state.CurrentMember.ReturnType }; } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateIndexerAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateIndexerAction.cs index 70ae20a81..c65058d2b 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateIndexerAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateIndexerAction.cs @@ -57,7 +57,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (targetResolveResult.Type.GetDefinition() == null || targetResolveResult.Type.GetDefinition().Region.IsEmpty) yield break; isStatic = targetResolveResult is TypeResolveResult; - if (isStatic && targetResolveResult.Type.Kind == TypeKind.Interface) + if (isStatic && targetResolveResult.Type.Kind == TypeKind.Interface || targetResolveResult.Type.Kind == TypeKind.Enum) yield break; } else { isStatic = indexer.Target is IdentifierExpression && state.CurrentMember.IsStatic; @@ -77,7 +77,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring } }, }; - decl.Parameters.AddRange(CreateMethodDeclarationAction.GenerateParameters (context, indexer.Arguments)); + decl.Parameters.AddRange(CreateMethodDeclarationAction.GenerateParameters(context, indexer.Arguments)); if (isStatic) decl.Modifiers |= Modifiers.Static; @@ -90,11 +90,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring decl.Modifiers |= Modifiers.Public; } - script.InsertWithCursor(context.TranslateString("Create indexer"), decl, targetResolveResult.Type.GetDefinition()); + script.InsertWithCursor(context.TranslateString("Create indexer"), targetResolveResult.Type.GetDefinition(), decl); return; } - script.InsertWithCursor(context.TranslateString("Create indexer"), decl, Script.InsertPosition.Before); + script.InsertWithCursor(context.TranslateString("Create indexer"), Script.InsertPosition.Before, decl); }); } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateMethodDeclarationAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateMethodDeclarationAction.cs index bfe3bfd67..57e8c2834 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateMethodDeclarationAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateMethodDeclarationAction.cs @@ -54,14 +54,13 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring IEnumerable GetActionsFromMemberReferenceExpression(RefactoringContext context, MemberReferenceExpression invocation) { if (!(context.Resolve(invocation).IsError)) - yield break; + yield break; var methodName = invocation.MemberName; var guessedType = CreateFieldAction.GuessType(context, invocation); if (guessedType.Kind != TypeKind.Delegate) - yield break; + yield break; var invocationMethod = guessedType.GetDelegateInvokeMethod(); - var state = context.GetResolverStateBefore(invocation); if (state.CurrentTypeDefinition == null) yield break; @@ -73,7 +72,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (targetResolveResult.Type.GetDefinition() == null || targetResolveResult.Type.GetDefinition().Region.IsEmpty) yield break; isStatic = targetResolveResult is TypeResolveResult; - if (isStatic && targetResolveResult.Type.Kind == TypeKind.Interface) + if (isStatic && targetResolveResult.Type.Kind == TypeKind.Interface || targetResolveResult.Type.Kind == TypeKind.Enum) yield break; } else { if (state.CurrentMember == null) @@ -107,6 +106,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (guessedType.Kind != TypeKind.Delegate) yield break; var invocationMethod = guessedType.GetDelegateInvokeMethod(); + if (invocationMethod == null) + yield break; var state = context.GetResolverStateBefore(identifier); if (state.CurrentMember == null || state.CurrentTypeDefinition == null) yield break; @@ -153,7 +154,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (targetResolveResult.Type.GetDefinition() == null || targetResolveResult.Type.GetDefinition().Region.IsEmpty) yield break; isStatic = targetResolveResult is TypeResolveResult; - if (isStatic && targetResolveResult.Type.Kind == TypeKind.Interface) + if (isStatic && targetResolveResult.Type.Kind == TypeKind.Interface || targetResolveResult.Type.Kind == TypeKind.Enum) yield break; } else { isStatic = state.CurrentMember.IsStatic || state.CurrentTypeDefinition.IsStatic; @@ -209,11 +210,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring decl.Modifiers |= Modifiers.Public; } - script.InsertWithCursor(context.TranslateString("Create method"), decl, targetResolveResult.Type.GetDefinition()); + script.InsertWithCursor(context.TranslateString("Create method"), targetResolveResult.Type.GetDefinition(), decl); return; } - script.InsertWithCursor(context.TranslateString("Create method"), decl, Script.InsertPosition.Before); + script.InsertWithCursor(context.TranslateString("Create method"), Script.InsertPosition.Before, decl); }); } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateOverloadWithoutParameterAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateOverloadWithoutParameterAction.cs new file mode 100644 index 000000000..9dbd124ca --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateOverloadWithoutParameterAction.cs @@ -0,0 +1,140 @@ +// +// CreateOverloadWithoutParameterAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Linq; +using ICSharpCode.NRefactory.Semantics; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Create overload without parameter", Description = "Create overload without the selected parameter.")] + public class CreateOverloadWithoutParameterAction : SpecializedCodeAction + { + protected override CodeAction GetAction (RefactoringContext context, ParameterDeclaration node) + { + if (!node.DefaultExpression.IsNull) + return null; + if (node.ParameterModifier == ParameterModifier.This || node.ParameterModifier == ParameterModifier.Params) + return null; + + var methodDecl = node.Parent as MethodDeclaration; + if (methodDecl == null) + return null; + + // explicit implementation + if (!methodDecl.PrivateImplementationType.IsNull) + return null; + + // find existing method + var method = (IMethod)((MemberResolveResult)context.Resolve (methodDecl)).Member; + var parameters = new List (method.Parameters.Where (param => param.Name != node.Name)); + if (method.DeclaringType.GetMethods ( + m => m.Name == method.Name && m.TypeParameters.Count == method.TypeParameters.Count) + .Any (m => ParameterListComparer.Instance.Equals (m.Parameters, parameters))) + return null; + + return new CodeAction (context.TranslateString ("Create overload without parameter"), + script => + { + var defaultExpr = GetDefaultValueExpression (context, node.Type); + + var body = new BlockStatement (); + Expression argExpr; + if (node.ParameterModifier == ParameterModifier.Ref) { + body.Add (new VariableDeclarationStatement (node.Type.Clone (), node.Name, defaultExpr)); + argExpr = new DirectionExpression (FieldDirection.Ref, new IdentifierExpression (node.Name)); + } else if (node.ParameterModifier == ParameterModifier.Out) { + body.Add (new VariableDeclarationStatement (node.Type.Clone (), node.Name)); + argExpr = new DirectionExpression (FieldDirection.Out, new IdentifierExpression (node.Name)); + } else { + argExpr = defaultExpr; + } + body.Add (new InvocationExpression (new IdentifierExpression (methodDecl.Name), + methodDecl.Parameters.Select (param => param == node ? argExpr : new IdentifierExpression (param.Name)))); + + var decl = (MethodDeclaration)methodDecl.Clone (); + decl.Parameters.Remove (decl.Parameters.First (param => param.Name == node.Name)); + decl.Body = body; + + script.InsertWithCursor ("Create overload without parameter", Script.InsertPosition.Before, decl); + + //if (node.ParameterModifier != ParameterModifier.Out) + // script.Link (defaultExpr); + }); + } + + static Expression GetDefaultValueExpression (RefactoringContext context, AstType astType) + { + var type = context.ResolveType (astType); + + // array + if (type.Kind == TypeKind.Array) + return new ObjectCreateExpression (astType.Clone ()); + + // enum + if (type.Kind == TypeKind.Enum) { + var members = type.GetMembers ().ToArray(); + if (members.Length == 0) + return new DefaultValueExpression (astType.Clone ()); + return astType.Member(members[0].Name); + } + + if ((type.IsReferenceType ?? false) || type.Kind == TypeKind.Dynamic) + return new NullReferenceExpression (); + + var typeDefinition = type.GetDefinition (); + if (typeDefinition != null) { + switch (typeDefinition.KnownTypeCode) { + case KnownTypeCode.Boolean: + return new PrimitiveExpression (false); + + case KnownTypeCode.Char: + return new PrimitiveExpression ('\0'); + + case KnownTypeCode.SByte: + case KnownTypeCode.Byte: + case KnownTypeCode.Int16: + case KnownTypeCode.UInt16: + case KnownTypeCode.Int32: + case KnownTypeCode.UInt32: + case KnownTypeCode.Int64: + case KnownTypeCode.UInt64: + case KnownTypeCode.Single: + case KnownTypeCode.Double: + case KnownTypeCode.Decimal: + return new PrimitiveExpression (0); + + case KnownTypeCode.NullableOfT: + return new NullReferenceExpression (); + } + if (type.Kind == TypeKind.Struct) + return new ObjectCreateExpression (astType.Clone ()); + } + return new DefaultValueExpression (astType.Clone ()); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs index 89f82a1f6..c9c750cad 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreatePropertyAction.cs @@ -63,12 +63,14 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring ResolveResult targetResolveResult = null; if (identifier is MemberReferenceExpression) { targetResolveResult = context.Resolve(((MemberReferenceExpression)identifier).Target); + if (targetResolveResult.Type.GetDefinition() == null || targetResolveResult.Type.GetDefinition().Region.IsEmpty) + yield break; createInOtherType = !state.CurrentTypeDefinition.Equals(targetResolveResult.Type.GetDefinition()); } bool isStatic = targetResolveResult is TypeResolveResult; if (createInOtherType) { - if (isStatic && targetResolveResult.Type.Kind == TypeKind.Interface) + if (isStatic && targetResolveResult.Type.Kind == TypeKind.Interface || targetResolveResult.Type.Kind == TypeKind.Enum) yield break; } else { if (state.CurrentMember == null) @@ -76,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring isStatic |= state.CurrentMember.IsStatic || state.CurrentTypeDefinition.IsStatic; } -// var service = (NamingConventionService)context.GetService(typeof(NamingConventionService)); + // var service = (NamingConventionService)context.GetService(typeof(NamingConventionService)); // if (service != null && !service.IsValidName(propertyName, AffectedEntity.Property, Modifiers.Private, isStatic)) { // yield break; // } @@ -97,15 +99,20 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring } else { decl.Modifiers |= Modifiers.Public; } - script.InsertWithCursor(context.TranslateString("Create property"), decl, targetResolveResult.Type.GetDefinition()); + script.InsertWithCursor( + context.TranslateString("Create property"), + targetResolveResult.Type.GetDefinition(), + decl); + return; } - script.InsertWithCursor(context.TranslateString("Create property"), decl, Script.InsertPosition.Before); + script.InsertWithCursor(context.TranslateString("Create property"), Script.InsertPosition.Before, decl); + }); } - static string GetPropertyName(Expression expr) + internal static string GetPropertyName(Expression expr) { if (expr is IdentifierExpression) return ((IdentifierExpression)expr).Identifier; diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtensionMethodInvocationToStaticMethodInvocationAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtensionMethodInvocationToStaticMethodInvocationAction.cs new file mode 100644 index 000000000..fd42c88ea --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtensionMethodInvocationToStaticMethodInvocationAction.cs @@ -0,0 +1,69 @@ +// +// ExtensionMethodInvocationToStaticMethodInvocationAction.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// 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; +using ICSharpCode.NRefactory.CSharp.Resolver; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Invoke using static method syntax", + Description = "Converts the call into static method call syntax.")] + public class ExtensionMethodInvocationToStaticMethodInvocationAction : ICodeActionProvider + { + #region ICodeActionProvider implementation + + public IEnumerable GetActions (RefactoringContext context) + { + var invocation = context.GetNode(); + if (invocation == null) + yield break; + var memberReference = invocation.Target as MemberReferenceExpression; + if (memberReference == null) + yield break; + var invocationRR = context.Resolve(invocation) as CSharpInvocationResolveResult; + if (invocationRR == null) + yield break; + if (invocationRR.IsExtensionMethodInvocation) + yield return new CodeAction(context.TranslateString("Convert to call to static method"), script => { + script.Replace(invocation, ToStaticMethodInvocation(invocation, memberReference, invocationRR)); + }); + } + + #endregion + + AstNode ToStaticMethodInvocation(InvocationExpression invocation, MemberReferenceExpression memberReference, + CSharpInvocationResolveResult invocationRR) + { + var newArgumentList = invocation.Arguments.Select(arg => arg.Clone()).ToList(); + newArgumentList.Insert(0, memberReference.Target.Clone()); + var newTarget = memberReference.Clone() as MemberReferenceExpression; + newTarget.Target = new IdentifierExpression(invocationRR.Member.DeclaringType.Name); + return new InvocationExpression(newTarget, newArgumentList); + } + + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractAnonymousMethodAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractAnonymousMethodAction.cs new file mode 100644 index 000000000..d1d05cce2 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractAnonymousMethodAction.cs @@ -0,0 +1,117 @@ +// +// ExtractAnonymousMethodAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Linq; +using ICSharpCode.NRefactory.CSharp.Resolver; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Extract anonymous method", + Description = "Extract anonymous method to method of the containing type")] + public class ExtractAnonymousMethodAction : ICodeActionProvider + { + public IEnumerable GetActions (RefactoringContext context) + { + // lambda + var lambda = context.GetNode (); + if (lambda != null && lambda.ArrowToken.Contains(context.Location)) { + if (ContainsLocalReferences (context, lambda, lambda.Body)) + yield break; + + bool noReturn = false; + BlockStatement body; + if (lambda.Body is BlockStatement) { + body = (BlockStatement)lambda.Body.Clone (); + } else { + body = new BlockStatement (); + + var type = LambdaHelper.GetLambdaReturnType (context, lambda); + if (type == null || type.ReflectionName == "System.Void") { + noReturn = true; + body.Add (new ExpressionStatement ((Expression)lambda.Body.Clone ())); + } else { + body.Add (new ReturnStatement ((Expression)lambda.Body.Clone ())); + } + } + var method = GetMethod (context, (LambdaResolveResult)context.Resolve (lambda), body, noReturn); + yield return GetAction (context, lambda, method); + } + + // anonymous method + var anonymousMethod = context.GetNode (); + if (anonymousMethod != null && anonymousMethod.DelegateToken.Contains(context.Location)) { + if (ContainsLocalReferences (context, anonymousMethod, anonymousMethod.Body)) + yield break; + + var method = GetMethod (context, (LambdaResolveResult)context.Resolve (anonymousMethod), + (BlockStatement)anonymousMethod.Body.Clone ()); + yield return GetAction (context, anonymousMethod, method); + } + } + + CodeAction GetAction (RefactoringContext context, AstNode node, MethodDeclaration method) + { + return new CodeAction (context.TranslateString ("Extract anonymous method"), + script => + { + var identifier = new IdentifierExpression ("Method"); + script.Replace (node, identifier); + script.InsertBefore (node.GetParent (), method); + script.Link (method.NameToken, identifier); + }); + } + + static MethodDeclaration GetMethod (RefactoringContext context, LambdaResolveResult lambda, BlockStatement body, + bool noReturnValue = false) + { + var method = new MethodDeclaration { Name = "Method" }; + + if (noReturnValue) { + method.ReturnType = new PrimitiveType ("void"); + } else { + var type = lambda.GetInferredReturnType (lambda.Parameters.Select (p => p.Type).ToArray ()); + method.ReturnType = type.Name == "?" ? new PrimitiveType ("void") : context.CreateShortType (type); + } + + foreach (var param in lambda.Parameters) + method.Parameters.Add (new ParameterDeclaration (context.CreateShortType (param.Type), param.Name)); + + method.Body = body; + if (lambda.IsAsync) + method.Modifiers |= Modifiers.Async; + + return method; + } + + static bool ContainsLocalReferences (RefactoringContext context, AstNode expr, AstNode body) + { + var visitor = new ExtractMethod.VariableLookupVisitor (context); + body.AcceptVisitor (visitor); + return visitor.UsedVariables.Any (variable => !expr.Contains (variable.Region.Begin)); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractFieldAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractFieldAction.cs new file mode 100755 index 000000000..7585386f0 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractFieldAction.cs @@ -0,0 +1,93 @@ +// +// ExtractFieldAction.cs +// +// Author: +// Nieve <> +// +// Copyright (c) 2012 Nieve +// +// 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; +using System.Linq; +using ICSharpCode.NRefactory.PatternMatching; +using Mono.CSharp; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Extract field", Description = "Extracts a field from a local variable declaration.")] + public class ExtractFieldAction : ICodeActionProvider + { + public IEnumerable GetActions(RefactoringContext context) + { + //TODO: implement variable assignment & ctor param + var varInit = context.GetNode(); + if (varInit != null) { + AstType type = varInit.GetPrevNode() as AstType; + if (type == null) yield break; + if (varInit.Parent is FieldDeclaration) yield break; + if (CannotExtractField(varInit)) yield break; + + yield return new CodeAction("Extract field", s=>{ + var name = varInit.Name; + FieldDeclaration field = new FieldDeclaration(){ + ReturnType = type.Clone(), + Variables = { new VariableInitializer(name) } + }; + AstNode nodeToRemove = RemoveDeclaration(varInit) ? varInit.Parent : type; + s.Remove(nodeToRemove, true); + s.InsertWithCursor(context.TranslateString("Extract field"),Script.InsertPosition.Before,field); + s.FormatText(varInit.Parent); + }); + } + + var idntf = context.GetNode(); + if (idntf == null) yield break; + var paramDec = idntf.Parent as ParameterDeclaration; + if (paramDec != null) { + var ctor = paramDec.Parent as ConstructorDeclaration; + if (ctor == null) yield break; + MemberReferenceExpression thisField = new MemberReferenceExpression(new ThisReferenceExpression(), idntf.Name, new AstType[]{}); + var assign = new AssignmentExpression(thisField, AssignmentOperatorType.Assign, new IdentifierExpression(idntf.Name)); + var statement = new ExpressionStatement(assign); + var type = (idntf.GetPrevNode() as AstType).Clone(); + FieldDeclaration field = new FieldDeclaration(){ + ReturnType = type.Clone(), + Variables = { new VariableInitializer(idntf.Name) } + }; + yield return new CodeAction("Extract field", s=>{ + s.InsertWithCursor(context.TranslateString("Extract field"),Script.InsertPosition.Before,field); + s.AddTo(ctor.Body, statement); + }); + } + } + + static bool RemoveDeclaration (VariableInitializer varInit){ + var result = varInit.Parent as VariableDeclarationStatement; + return result.Variables.First ().Initializer.IsNull; + } + + static bool CannotExtractField (VariableInitializer varInit) + { + var result = varInit.Parent as VariableDeclarationStatement; + return result == null || result.Variables.Count != 1; + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/ExtractMethodAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/ExtractMethodAction.cs index 77105d0b4..4d3d15c2d 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/ExtractMethodAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/ExtractMethodAction.cs @@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.CSharp.Resolver; using ICSharpCode.NRefactory.CSharp.Analysis; using System.Threading; using ICSharpCode.NRefactory.TypeSystem; +using System.Threading.Tasks; namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod { @@ -44,14 +45,14 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod var selected = new List(context.GetSelectedNodes()); if (selected.Count == 0) yield break; - + if (selected.Count == 1 && selected [0] is Expression) { var codeAction = CreateFromExpression(context, (Expression)selected [0]); if (codeAction == null) yield break; yield return codeAction; } - + foreach (var node in selected) { if (!(node is Statement)) yield break; @@ -60,13 +61,13 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod if (action != null) yield return action; } - + CodeAction CreateFromExpression(RefactoringContext context, Expression expression) { var resolveResult = context.Resolve(expression); if (resolveResult.IsError) return null; - + return new CodeAction(context.TranslateString("Extract method"), script => { string methodName = "NewMethod"; var method = new MethodDeclaration() { @@ -78,18 +79,27 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod }; if (!StaticVisitor.UsesNotStaticMember(context, expression)) method.Modifiers |= Modifiers.Static; - script.InsertWithCursor(context.TranslateString("Extract method"), method, Script.InsertPosition.Before); - var target = new IdentifierExpression(methodName); - script.Replace(expression, new InvocationExpression(target)); -// script.Link(target, method.NameToken); + var task = script.InsertWithCursor(context.TranslateString("Extract method"), Script.InsertPosition.Before, method); + + Action replaceStatements = delegate { + var target = new IdentifierExpression(methodName); + script.Replace(expression, new InvocationExpression(target)); + script.Link(target, method.NameToken); + }; + + if (task.IsCompleted) { + replaceStatements (null); + } else { + task.ContinueWith (replaceStatements, TaskScheduler.FromCurrentSynchronizationContext ()); + } }); } - + CodeAction CreateFromStatements(RefactoringContext context, List statements) { if (!(statements [0].Parent is Statement)) return null; - + return new CodeAction(context.TranslateString("Extract method"), script => { string methodName = "NewMethod"; var method = new MethodDeclaration() { @@ -107,79 +117,90 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod var target = new IdentifierExpression(methodName); var invocation = new InvocationExpression(target); - + var usedVariables = VariableLookupVisitor.Analyze(context, statements); - - var extractedCodeAnalysis = new DefiniteAssignmentAnalysis((Statement)statements [0].Parent, context.Resolver, context.CancellationToken); + + var inExtractedRegion = new VariableUsageAnalyzation (context, usedVariables); var lastStatement = statements [statements.Count - 1]; - extractedCodeAnalysis.SetAnalyzedRange(statements [0], lastStatement); - var statusAfterMethod = new List>(); - foreach (var variable in usedVariables) { - extractedCodeAnalysis.Analyze(variable.Name, DefiniteAssignmentStatus.PotentiallyAssigned, context.CancellationToken); - statusAfterMethod.Add(Tuple.Create(variable, extractedCodeAnalysis.GetStatusAfter(lastStatement))); - } var stmt = statements [0].GetParent(); while (stmt.GetParent () != null) { stmt = stmt.GetParent(); } - var wholeCodeAnalysis = new DefiniteAssignmentAnalysis(stmt, context.Resolver, context.CancellationToken); - var statusBeforeMethod = new Dictionary(); - foreach (var variable in usedVariables) { - wholeCodeAnalysis.Analyze(variable.Name, DefiniteAssignmentStatus.PotentiallyAssigned, context.CancellationToken); - statusBeforeMethod [variable] = extractedCodeAnalysis.GetStatusBefore(statements [0]); - } - - var afterCodeAnalysis = new DefiniteAssignmentAnalysis(stmt, context.Resolver, context.CancellationToken); - var statusAtEnd = new Dictionary(); - afterCodeAnalysis.SetAnalyzedRange(lastStatement, stmt.Statements.Last(), false, true); + inExtractedRegion.SetAnalyzedRange(statements [0], lastStatement); + stmt.AcceptVisitor (inExtractedRegion); + + var beforeExtractedRegion = new VariableUsageAnalyzation (context, usedVariables); + beforeExtractedRegion.SetAnalyzedRange(statements [0].Parent, statements [0], true, false); + stmt.AcceptVisitor (beforeExtractedRegion); + + var afterExtractedRegion = new VariableUsageAnalyzation (context, usedVariables); + afterExtractedRegion.SetAnalyzedRange(lastStatement, stmt.Statements.Last(), false, true); + stmt.AcceptVisitor (afterExtractedRegion); + usedVariables.Sort ((l, r) => l.Region.Begin.CompareTo (r.Region.Begin)); + IVariable generatedReturnVariable = null; foreach (var variable in usedVariables) { - afterCodeAnalysis.Analyze(variable.Name, DefiniteAssignmentStatus.PotentiallyAssigned, context.CancellationToken); - statusBeforeMethod [variable] = extractedCodeAnalysis.GetStatusBefore(statements [0]); + if ((variable is IParameter) || beforeExtractedRegion.Has (variable) || !afterExtractedRegion.Has (variable)) + continue; + generatedReturnVariable = variable; + method.ReturnType = context.CreateShortType (variable.Type); + method.Body.Add (new ReturnStatement (new IdentifierExpression (variable.Name))); + break; } - var beforeVisitor = new VariableLookupVisitor(context); - beforeVisitor.SetAnalyzedRange(stmt, statements [0], true, false); - stmt.AcceptVisitor(beforeVisitor); - var afterVisitor = new VariableLookupVisitor(context); - afterVisitor.SetAnalyzedRange(lastStatement, stmt, false, true); - stmt.AcceptVisitor(afterVisitor); - foreach (var status in statusAfterMethod) { - if (!beforeVisitor.UsedVariables.Contains(status.Item1) && !afterVisitor.UsedVariables.Contains(status.Item1)) + foreach (var variable in usedVariables) { + if (!(variable is IParameter) && !beforeExtractedRegion.Has (variable) && !afterExtractedRegion.Has (variable)) continue; - Expression argumentExpression = new IdentifierExpression(status.Item1.Name); + if (variable == generatedReturnVariable) + continue; + Expression argumentExpression = new IdentifierExpression(variable.Name); - ParameterModifier mod; - switch (status.Item2) { - case DefiniteAssignmentStatus.AssignedAfterTrueExpression: - case DefiniteAssignmentStatus.AssignedAfterFalseExpression: - case DefiniteAssignmentStatus.PotentiallyAssigned: - mod = ParameterModifier.Ref; - argumentExpression = new DirectionExpression(FieldDirection.Ref, argumentExpression); - break; - case DefiniteAssignmentStatus.DefinitelyAssigned: - if (statusBeforeMethod [status.Item1] != DefiniteAssignmentStatus.PotentiallyAssigned) - goto case DefiniteAssignmentStatus.PotentiallyAssigned; + ParameterModifier mod = ParameterModifier.None; + if (inExtractedRegion.GetStatus (variable) == VariableState.Changed) { + if (beforeExtractedRegion.GetStatus (variable) == VariableState.None) { mod = ParameterModifier.Out; argumentExpression = new DirectionExpression(FieldDirection.Out, argumentExpression); - break; -// case DefiniteAssignmentStatus.Unassigned: - default: - mod = ParameterModifier.None; - break; + } else { + mod = ParameterModifier.Ref; + argumentExpression = new DirectionExpression(FieldDirection.Ref, argumentExpression); + } } - method.Parameters.Add(new ParameterDeclaration(context.CreateShortType(status.Item1.Type), status.Item1.Name, mod)); + + method.Parameters.Add(new ParameterDeclaration(context.CreateShortType(variable.Type), variable.Name, mod)); invocation.Arguments.Add(argumentExpression); } + var task = script.InsertWithCursor(context.TranslateString("Extract method"), Script.InsertPosition.Before, method); + Action replaceStatements = delegate { + foreach (var node in statements.Skip (1)) { + script.Remove(node); + } + foreach (var variable in usedVariables) { + if ((variable is IParameter) || beforeExtractedRegion.Has (variable) || !afterExtractedRegion.Has (variable)) + continue; + if (variable == generatedReturnVariable) + continue; + script.InsertBefore (statements [0], new VariableDeclarationStatement (context.CreateShortType(variable.Type), variable.Name)); + } + AstNode invocationStatement; + + if (generatedReturnVariable != null) { + invocationStatement = new VariableDeclarationStatement (new SimpleType ("var"), generatedReturnVariable.Name, invocation); + } else { + invocationStatement = new ExpressionStatement(invocation); + } + script.Replace(statements [0], invocationStatement); + + + script.Link(target, method.NameToken); + }; - foreach (var node in statements.Skip (1)) { - script.Remove(node); + if (task.IsCompleted) { + replaceStatements (null); + } else { + task.ContinueWith (replaceStatements, TaskScheduler.FromCurrentSynchronizationContext ()); } - script.Replace(statements [0], new ExpressionStatement(invocation)); - script.InsertWithCursor(context.TranslateString("Extract method"), method, Script.InsertPosition.Before); - //script.Link(target, method.NameToken); }); } } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableLookupVisitor.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableLookupVisitor.cs index 3613ebb2a..0a8240bb7 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableLookupVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableLookupVisitor.cs @@ -33,18 +33,22 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod class VariableLookupVisitor : DepthFirstAstVisitor { readonly RefactoringContext context; - + public List UsedVariables = new List (); - + TextLocation startLocation = TextLocation.Empty; TextLocation endLocation = TextLocation.Empty; - - + public VariableLookupVisitor (RefactoringContext context) { this.context = context; } + public bool Has (IVariable item1) + { + return UsedVariables.Contains (item1); + } + public void SetAnalyzedRange(AstNode start, AstNode end, bool startInclusive = true, bool endInclusive = true) { if (start == null) @@ -54,17 +58,18 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod startLocation = startInclusive ? start.StartLocation : start.EndLocation; endLocation = endInclusive ? end.EndLocation : end.StartLocation; } - + public override void VisitIdentifierExpression(IdentifierExpression identifierExpression) { if (startLocation.IsEmpty || startLocation <= identifierExpression.StartLocation && identifierExpression.EndLocation <= endLocation) { var result = context.Resolve(identifierExpression); var local = result as LocalResolveResult; - if (local != null && !UsedVariables.Contains(local.Variable)) + if (local != null && !UsedVariables.Contains(local.Variable)) { UsedVariables.Add(local.Variable); + } } } - + public override void VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement) { base.VisitVariableDeclarationStatement(variableDeclarationStatement); @@ -78,14 +83,14 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod } } - + public static List Analyze(RefactoringContext context, Expression expression) { var visitor = new VariableLookupVisitor(context); expression.AcceptVisitor(visitor); return visitor.UsedVariables; } - + public static List Analyze(RefactoringContext context, List statements) { var visitor = new VariableLookupVisitor(context); diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableUsageAnalyzation.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableUsageAnalyzation.cs new file mode 100644 index 000000000..b75924544 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ExtractMethod/VariableUsageAnalyzation.cs @@ -0,0 +1,146 @@ +// +// VariableUsageAnalyzation.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; +using ICSharpCode.NRefactory.TypeSystem; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring.ExtractMethod +{ + + public enum VariableState { + None, + Used, + Changed + } + + + public class VariableUsageAnalyzation : DepthFirstAstVisitor + { + readonly RefactoringContext context; + readonly List usedVariables; + + Dictionary states = new Dictionary (); + + TextLocation startLocation = TextLocation.Empty; + TextLocation endLocation = TextLocation.Empty; + + public VariableUsageAnalyzation (RefactoringContext context, List usedVariables) + { + this.context = context; + this.usedVariables = usedVariables; + } + + public bool Has(IVariable variable) + { + return states.ContainsKey (variable); + } + + public void SetAnalyzedRange(AstNode start, AstNode end, bool startInclusive = true, bool endInclusive = true) + { + if (start == null) + throw new ArgumentNullException("start"); + if (end == null) + throw new ArgumentNullException("end"); + startLocation = startInclusive ? start.StartLocation : start.EndLocation; + endLocation = endInclusive ? end.EndLocation : end.StartLocation; + states.Clear (); + } + + public VariableState GetStatus (IVariable variable) + { + VariableState state; + if (!states.TryGetValue (variable, out state)) + return VariableState.None; + return state; + } + + void SetState (string identifier, VariableState state) + { + var variable = usedVariables.FirstOrDefault (v => v.Name == identifier); + if (variable == null) + return; + VariableState oldState; + if (states.TryGetValue (variable, out oldState)) { + if (oldState < state) + states [variable] = state; + } else { + states [variable] = state; + } + } + + public override void VisitIdentifierExpression(IdentifierExpression identifierExpression) + { + if (startLocation.IsEmpty || startLocation <= identifierExpression.StartLocation && identifierExpression.EndLocation <= endLocation) { + SetState (identifierExpression.Identifier, VariableState.Used); + } + } + + public override void VisitAssignmentExpression(AssignmentExpression assignmentExpression) + { + if (startLocation.IsEmpty || startLocation <= assignmentExpression.StartLocation && assignmentExpression.EndLocation <= endLocation) { + var left = assignmentExpression.Left as IdentifierExpression; + if (left != null) + SetState(left.Identifier, VariableState.Changed); + } + base.VisitAssignmentExpression (assignmentExpression); + } + + public override void VisitDirectionExpression(DirectionExpression directionExpression) + { + if (startLocation.IsEmpty || startLocation <= directionExpression.StartLocation && directionExpression.EndLocation <= endLocation) { + var expr = directionExpression.Expression as IdentifierExpression; + if (expr != null) + SetState(expr.Identifier, VariableState.Changed); + } + base.VisitDirectionExpression (directionExpression); + } + + public override void VisitVariableInitializer(VariableInitializer variableInitializer) + { + if (startLocation.IsEmpty || startLocation <= variableInitializer.StartLocation && variableInitializer.EndLocation <= endLocation) { + SetState(variableInitializer.Name, variableInitializer.Initializer.IsNull ? VariableState.None : VariableState.Changed); + } + + base.VisitVariableInitializer(variableInitializer); + } + + public override void VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression) + { + if (startLocation.IsEmpty || startLocation <= unaryOperatorExpression.StartLocation && unaryOperatorExpression.EndLocation <= endLocation) { + if (unaryOperatorExpression.Operator == UnaryOperatorType.Increment || unaryOperatorExpression.Operator == UnaryOperatorType.Decrement || + unaryOperatorExpression.Operator == UnaryOperatorType.PostIncrement || unaryOperatorExpression.Operator == UnaryOperatorType.PostDecrement) { + var expr = unaryOperatorExpression.Expression as IdentifierExpression; + if (expr != null) + SetState(expr.Identifier, VariableState.Changed); + } + } + base.VisitUnaryOperatorExpression (unaryOperatorExpression); + } + + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GenerateGetterAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GenerateGetterAction.cs index dfa83b7ff..6bc0852df 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GenerateGetterAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GenerateGetterAction.cs @@ -55,8 +55,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring yield break; } - yield return new CodeAction (context.TranslateString("Create getter"), script => { - script.InsertWithCursor(context.TranslateString("Create getter"), GeneratePropertyDeclaration(context, field, initializer), Script.InsertPosition.After); + yield return new CodeAction(context.TranslateString("Create getter"), script => { + script.InsertWithCursor( + context.TranslateString("Create getter"), + Script.InsertPosition.After, + GeneratePropertyDeclaration(context, field, initializer)); }); } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GeneratePropertyAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GeneratePropertyAction.cs index 1f5c6381f..291b507f7 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GeneratePropertyAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/GeneratePropertyAction.cs @@ -28,6 +28,7 @@ using ICSharpCode.NRefactory.PatternMatching; using System.Linq; using System.Threading; using System.Collections.Generic; +using ICSharpCode.NRefactory.Semantics; namespace ICSharpCode.NRefactory.CSharp.Refactoring { @@ -50,15 +51,24 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring } } var field = initializer.Parent as FieldDeclaration; - if (field == null) { + if (field == null || field.HasModifier(Modifiers.Readonly) || field.HasModifier(Modifiers.Const)) { yield break; } - yield return new CodeAction (context.TranslateString("Create property"), script => { - script.InsertWithCursor(context.TranslateString("Create property"), GeneratePropertyDeclaration(context, field, initializer), Script.InsertPosition.After); + var resolveResult = context.Resolve(initializer) as MemberResolveResult; + if (resolveResult == null) + yield break; + yield return new CodeAction(context.TranslateString("Create property"), script => { + var fieldName = context.GetNameProposal(initializer.Name, true); + if (initializer.Name == context.GetNameProposal(initializer.Name, false)) { + script.Rename(resolveResult.Member, fieldName); + } + script.InsertWithCursor( + context.TranslateString("Create property"), + Script.InsertPosition.After, GeneratePropertyDeclaration(context, field, fieldName)); }); } - static PropertyDeclaration GeneratePropertyDeclaration (RefactoringContext context, FieldDeclaration field, VariableInitializer initializer) + static PropertyDeclaration GeneratePropertyDeclaration (RefactoringContext context, FieldDeclaration field, string fieldName) { var mod = ICSharpCode.NRefactory.CSharp.Modifiers.Public; if (field.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Static)) @@ -66,16 +76,16 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring return new PropertyDeclaration () { Modifiers = mod, - Name = context.GetNameProposal (initializer.Name, false), + Name = context.GetNameProposal (fieldName, false), ReturnType = field.ReturnType.Clone (), Getter = new Accessor () { Body = new BlockStatement () { - new ReturnStatement (new IdentifierExpression (initializer.Name)) + new ReturnStatement (new IdentifierExpression (fieldName)) } }, Setter = new Accessor () { Body = new BlockStatement () { - new ExpressionStatement (new AssignmentExpression (new IdentifierExpression (initializer.Name), new IdentifierExpression ("value"))) + new ExpressionStatement (new AssignmentExpression (new IdentifierExpression (fieldName), new IdentifierExpression ("value"))) } } }; diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementAbstractMembersAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementAbstractMembersAction.cs new file mode 100644 index 000000000..97a4b9b00 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementAbstractMembersAction.cs @@ -0,0 +1,116 @@ +// +// ImplementAbstractMembersAction.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 ICSharpCode.NRefactory.TypeSystem; +using System.Threading; +using System.Collections.Generic; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Implement abstract members", Description = "Implements abstract members from an abstract class.")] + public class ImplementAbstractMembersAction : ICodeActionProvider + { + public IEnumerable GetActions(RefactoringContext context) + { + var type = context.GetNode(); + if (type == null || type.Role != Roles.BaseType) + yield break; + var state = context.GetResolverStateBefore(type); + if (state.CurrentTypeDefinition == null) + yield break; + + var resolveResult = context.Resolve(type); + if (resolveResult.Type.Kind != TypeKind.Class || resolveResult.Type.GetDefinition() == null || !resolveResult.Type.GetDefinition().IsAbstract) + yield break; + + var toImplement = CollectMembersToImplement(state.CurrentTypeDefinition, resolveResult.Type); + if (toImplement.Count == 0) + yield break; + + yield return new CodeAction(context.TranslateString("Implement abstract members"), script => { + script.InsertWithCursor( + context.TranslateString("Implement abstract members"), + state.CurrentTypeDefinition, + ImplementInterfaceAction.GenerateImplementation (context, toImplement.Select (m => Tuple.Create (m, false))).Select (entity => { + var decl = entity as EntityDeclaration; + if (decl != null) + decl.Modifiers |= Modifiers.Override; + return entity; + }) + ); + }); + } + + public static List CollectMembersToImplement(ITypeDefinition implementingType, IType abstractType) + { + var def = abstractType.GetDefinition(); + var toImplement = new List(); + bool alreadyImplemented; + + // Stub out non-implemented events defined by @iface + foreach (var ev in abstractType.GetEvents (e => !e.IsSynthetic && e.IsAbstract)) { + alreadyImplemented = implementingType.GetAllBaseTypeDefinitions().Any( + x => x.Kind != TypeKind.Interface && x.Events.Any (y => y.Name == ev.Name) + ); + + if (!alreadyImplemented) + toImplement.Add(ev); + } + + // Stub out non-implemented methods defined by @iface + foreach (var method in abstractType.GetMethods (d => !d.IsSynthetic && d.IsAbstract)) { + alreadyImplemented = false; + + foreach (var cmet in implementingType.GetMethods ()) { + if (!cmet.IsAbstract && ImplementInterfaceAction.CompareMethods(method, cmet)) { + alreadyImplemented = true; + } + } + if (!alreadyImplemented) + toImplement.Add(method); + } + + // Stub out non-implemented properties defined by @iface + foreach (var prop in abstractType.GetProperties (p => !p.IsSynthetic && p.IsAbstract)) { + alreadyImplemented = false; + foreach (var t in implementingType.GetAllBaseTypeDefinitions ()) { + if (t.Kind == TypeKind.Interface) + continue; + foreach (IProperty cprop in t.Properties) { + if (!cprop.IsAbstract && cprop.Name == prop.Name) { + alreadyImplemented = true; + } + } + } + if (!alreadyImplemented) + toImplement.Add(prop); + } + return toImplement; + } + + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceAction.cs new file mode 100644 index 000000000..915715cb5 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceAction.cs @@ -0,0 +1,179 @@ +// +// ImplementInterfaceAction.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 ICSharpCode.NRefactory.TypeSystem; +using System.Threading; +using System.Collections.Generic; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Implement interface", Description = "Creates an interface implementation.")] + public class ImplementInterfaceAction : ICodeActionProvider + { + public IEnumerable GetActions(RefactoringContext context) + { + var type = context.GetNode(); + if (type == null || type.Role != Roles.BaseType) + yield break; + + var state = context.GetResolverStateBefore(type); + if (state.CurrentTypeDefinition == null) + yield break; + + var resolveResult = context.Resolve(type); + if (resolveResult.Type.Kind != TypeKind.Interface) + yield break; + + var toImplement = CollectMembersToImplement(state.CurrentTypeDefinition, resolveResult.Type, false); + if (toImplement.Count == 0) + yield break; + + yield return new CodeAction(context.TranslateString("Implement interface"), script => { + script.InsertWithCursor( + context.TranslateString("Implement Interface"), + state.CurrentTypeDefinition, + GenerateImplementation(context, toImplement) + ); + }); + } + + public static IEnumerable GenerateImplementation(RefactoringContext context, IEnumerable> toImplement) + { + var nodes = new Dictionary>(); + + foreach (var member in toImplement) { + if (!nodes.ContainsKey(member.Item1.DeclaringType)) + nodes [member.Item1.DeclaringType] = new List(); + nodes [member.Item1.DeclaringType].Add(GenerateMemberImplementation(context, member.Item1, member.Item2)); + } + + foreach (var kv in nodes) { + if (kv.Key.Kind == TypeKind.Interface) { + yield return new PreProcessorDirective( + PreProcessorDirectiveType.Region, + string.Format("{0} implementation", kv.Key.Name)); + } else { + yield return new PreProcessorDirective( + PreProcessorDirectiveType.Region, + string.Format("implemented abstract members of {0}", kv.Key.Name)); + } + foreach (var member in kv.Value) + yield return member; + yield return new PreProcessorDirective( + PreProcessorDirectiveType.Endregion + ); + } + } + + static EntityDeclaration GenerateMemberImplementation(RefactoringContext context, IMember member, bool explicitImplementation) + { + var builder = context.CreateTypeSytemAstBuilder(); + builder.GenerateBody = true; + builder.ShowConstantValues = !explicitImplementation; + builder.ShowTypeParameterConstraints = !explicitImplementation; + builder.UseCustomEvents = explicitImplementation; + var decl = builder.ConvertEntity(member); + if (explicitImplementation) { + decl.Modifiers = Modifiers.None; + decl.AddChild(builder.ConvertType(member.DeclaringType), EntityDeclaration.PrivateImplementationTypeRole); + } else { + decl.Modifiers = Modifiers.Public; + } + return decl; + } + + public static List> CollectMembersToImplement(ITypeDefinition implementingType, IType interfaceType, bool explicitly) + { + var def = interfaceType.GetDefinition(); + List> toImplement = new List>(); + bool alreadyImplemented; + + // Stub out non-implemented events defined by @iface + foreach (var evGroup in interfaceType.GetEvents (e => !e.IsSynthetic && e.DeclaringTypeDefinition.ReflectionName == def.ReflectionName).GroupBy (m => m.DeclaringType).Reverse ()) + foreach (var ev in evGroup) { + bool needsExplicitly = explicitly; + alreadyImplemented = implementingType.GetAllBaseTypeDefinitions().Any( + x => x.Kind != TypeKind.Interface && x.Events.Any(y => y.Name == ev.Name) + ); + + if (!alreadyImplemented) + toImplement.Add(new Tuple(ev, needsExplicitly)); + } + + // Stub out non-implemented methods defined by @iface + foreach (var methodGroup in interfaceType.GetMethods (d => !d.IsSynthetic).GroupBy (m => m.DeclaringType).Reverse ()) + foreach (var method in methodGroup) { + + bool needsExplicitly = explicitly; + alreadyImplemented = false; + + foreach (var cmet in implementingType.GetMethods ()) { + if (CompareMethods(method, cmet)) { + if (!needsExplicitly && !cmet.ReturnType.Equals(method.ReturnType)) + needsExplicitly = true; + else + alreadyImplemented |= !needsExplicitly /*|| cmet.InterfaceImplementations.Any (impl => impl.InterfaceType.Equals (interfaceType))*/; + } + } + if (toImplement.Where(t => t.Item1 is IMethod).Any(t => CompareMethods(method, (IMethod)t.Item1))) + needsExplicitly = true; + if (!alreadyImplemented) + toImplement.Add(new Tuple(method, needsExplicitly)); + } + + // Stub out non-implemented properties defined by @iface + foreach (var propGroup in interfaceType.GetProperties (p => !p.IsSynthetic && p.DeclaringTypeDefinition.ReflectionName == def.ReflectionName).GroupBy (m => m.DeclaringType).Reverse ()) + foreach (var prop in propGroup) { + bool needsExplicitly = explicitly; + alreadyImplemented = false; + foreach (var t in implementingType.GetAllBaseTypeDefinitions ()) { + if (t.Kind == TypeKind.Interface) + continue; + foreach (IProperty cprop in t.Properties) { + if (cprop.Name == prop.Name) { + if (!needsExplicitly && !cprop.ReturnType.Equals(prop.ReturnType)) + needsExplicitly = true; + else + alreadyImplemented |= !needsExplicitly/* || cprop.InterfaceImplementations.Any (impl => impl.InterfaceType.Resolve (ctx).Equals (interfaceType))*/; + } + } + } + if (!alreadyImplemented) + toImplement.Add(new Tuple(prop, needsExplicitly)); + } + return toImplement; + } + + internal static bool CompareMethods(IMethod interfaceMethod, IMethod typeMethod) + { + if (typeMethod.IsExplicitInterfaceImplementation) + return typeMethod.ImplementedInterfaceMembers.Any(m => m.Equals(interfaceMethod)); + return SignatureComparer.Ordinal.Equals(interfaceMethod, typeMethod); + } + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceExplicitAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceExplicitAction.cs new file mode 100644 index 000000000..d5206d5ed --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/ImplementInterfaceExplicitAction.cs @@ -0,0 +1,68 @@ +// +// ImplementInterfaceExplicitAction.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 ICSharpCode.NRefactory.TypeSystem; +using System.Threading; +using System.Collections.Generic; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Implement interface explicit", Description = "Creates an interface implementation.")] + public class ImplementInterfaceExplicitAction : ICodeActionProvider + { + public IEnumerable GetActions(RefactoringContext context) + { + var type = context.GetNode(); + if (type == null || type.Role != Roles.BaseType) + yield break; + var state = context.GetResolverStateBefore(type); + if (state.CurrentTypeDefinition == null) + yield break; + + var resolveResult = context.Resolve(type); + if (resolveResult.Type.Kind != TypeKind.Interface) + yield break; + + var toImplement = ImplementInterfaceAction.CollectMembersToImplement( + state.CurrentTypeDefinition, + resolveResult.Type, + false + ); + if (toImplement.Count == 0) + yield break; + + yield return new CodeAction(context.TranslateString("Implement interface explicit"), script => { + script.InsertWithCursor( + context.TranslateString("Implement Interface"), + state.CurrentTypeDefinition, + ImplementInterfaceAction.GenerateImplementation (context, toImplement.Select (t => Tuple.Create (t.Item1, true))) + ); + }); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/InlineLocalVariableAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/InlineLocalVariableAction.cs index d24adf378..a8bec696c 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/InlineLocalVariableAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/InlineLocalVariableAction.cs @@ -1,4 +1,4 @@ -// +// // InlineLocalVariableAction.cs // // Author: @@ -53,12 +53,12 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (resolveResult == null || resolveResult.IsError) { yield break; } - var unit = context.RootNode as CompilationUnit; + var unit = context.RootNode as SyntaxTree; if (unit == null) { yield break; } yield return new CodeAction(context.TranslateString("Inline local variable"), script => { - refFinder.FindLocalReferences(resolveResult.Variable, context.ParsedFile, unit, context.Compilation, (n, r) => script.Replace(n, initializer.Initializer.Clone()), default(CancellationToken)); + refFinder.FindLocalReferences(resolveResult.Variable, context.UnresolvedFile, unit, context.Compilation, (n, r) => script.Replace(n, initializer.Initializer.Clone()), default(CancellationToken)); script.Remove(node); }); } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IntroduceConstantAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IntroduceConstantAction.cs index 81ceacb3b..37235016c 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IntroduceConstantAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IntroduceConstantAction.cs @@ -1,4 +1,4 @@ -// +// // IntroduceConstantAction.cs // // Author: @@ -59,7 +59,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring }; script.InsertBefore(statement, decl); - var variableUsage = new IdentifierExpression(name); + var variableUsage = new IdentifierExpression(name); script.Replace(pexpr, variableUsage); script.Link(initializer.NameToken, variableUsage); }); @@ -81,7 +81,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring var variableUsage = new IdentifierExpression(name); script.Replace(pexpr, variableUsage); // script.Link(initializer.NameToken, variableUsage); - script.InsertWithCursor(context.TranslateString("Create constant"), decl, Script.InsertPosition.Before); + script.InsertWithCursor(context.TranslateString("Create constant"), Script.InsertPosition.Before, decl); }); } } diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IterateViaForeachAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IterateViaForeachAction.cs new file mode 100644 index 000000000..1638f25d2 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IterateViaForeachAction.cs @@ -0,0 +1,168 @@ +// +// IterateViaForeachTests.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using ICSharpCode.NRefactory.CSharp.Refactoring; +using ICSharpCode.NRefactory.TypeSystem; +using System.Collections.Generic; +using ICSharpCode.NRefactory.Semantics; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Iterate via foreach", Description = "Iterates an IEnumerable with a foreach loop.")] + public class IterateViaForeachAction : ICodeActionProvider + { + #region ICodeActionProvider implementation + + public IEnumerable GetActions(RefactoringContext context) + { + CodeAction action; + action = ActionFromUsingStatement(context); + if (action != null) + yield return action; + action = ActionFromVariableInitializer(context); + if (action != null) + yield return action; + action = ActionFromExpressionStatement(context); + if (action != null) + yield return action; + } + + CodeAction ActionFromUsingStatement(RefactoringContext context) + { + var initializer = context.GetNode(); + if (initializer == null) + return null; + var initializerRR = context.Resolve(initializer) as LocalResolveResult; + if (initializerRR == null) + return null; + var elementType = GetElementType(initializerRR, context); + if (elementType == null) + return null; + var usingStatement = initializer.Parent.Parent as UsingStatement; + if (usingStatement == null) + return null; + return new CodeAction(context.TranslateString("Iterate via foreach"), script => { + var iterator = MakeForeach(new IdentifierExpression(initializer.Name), elementType, context); + if (usingStatement.EmbeddedStatement is EmptyStatement) { + var blockStatement = new BlockStatement(); + blockStatement.Statements.Add(iterator); + script.Replace(usingStatement.EmbeddedStatement, blockStatement); + script.FormatText(blockStatement); + } else if (usingStatement.EmbeddedStatement is BlockStatement) { + var anchorNode = usingStatement.EmbeddedStatement.FirstChild; + script.InsertAfter(anchorNode, iterator); + script.FormatText(usingStatement.EmbeddedStatement); + } + }); + } + + CodeAction ActionFromVariableInitializer(RefactoringContext context) + { + var initializer = context.GetNode(); + if (initializer == null || initializer.Parent.Parent is ForStatement) + return null; + var initializerRR = context.Resolve(initializer) as LocalResolveResult; + if (initializerRR == null) + return null; + var elementType = GetElementType(initializerRR, context); + if (elementType == null) + return null; + + return new CodeAction(context.TranslateString("Iterate via foreach"), script => { + var iterator = MakeForeach(new IdentifierExpression(initializer.Name), elementType, context); + script.InsertAfter(context.GetNode(), iterator); + }); + } + + CodeAction ActionFromExpressionStatement(RefactoringContext context) + { + var expressionStatement = context.GetNode(); + if (expressionStatement == null) + return null; + var expression = expressionStatement.Expression; + if (expression is AssignmentExpression) + expression = ((AssignmentExpression)expression).Left; + var expressionRR = context.Resolve(expression); + if (expressionRR == null) + return null; + var elementType = GetElementType(expressionRR, context); + if (elementType == null) + return null; + return new CodeAction(context.TranslateString("Iterate via foreach"), script => { + var iterator = MakeForeach(expression, elementType, context); + if (expression == expressionStatement.Expression) + script.Replace(expressionStatement, iterator); + else + script.InsertAfter(expressionStatement, iterator); + }); + } + + static ForeachStatement MakeForeach(Expression node, IType type, RefactoringContext context) + { + var namingHelper = new NamingHelper(context); + return new ForeachStatement() { + VariableType = new SimpleType("var"), + VariableName = namingHelper.GenerateVariableName(type), + InExpression = node.Clone(), + EmbeddedStatement = new BlockStatement() + }; + } + + static IType GetElementType(ResolveResult rr, RefactoringContext context) + { + IType type = GetInterfaceType(rr.Type, "System.Collections.Generic.IEnumerable") ?? + GetInterfaceType(rr.Type, "System.Collections.IEnumerable"); + if (type == null) + return null; + + var parameterizedType = type as ParameterizedType; + if (parameterizedType != null) + return parameterizedType.TypeArguments.First(); + else + return context.Compilation.FindType(KnownTypeCode.Object); + } + + static IType GetInterfaceType(IType type, string typeName) + { + string fullName = null; + if (type.TypeParameterCount > 0) + fullName = type.FullName.Split('`').First(); + else + fullName = type.FullName; + + if (fullName == typeName) + return type; + foreach (var baseType in type.DirectBaseTypes) { + IType retType = GetInterfaceType(baseType, typeName); + if (retType != null) + return retType; + } + return null; + } + + #endregion + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinDeclarationAndAssignmentAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinDeclarationAndAssignmentAction.cs new file mode 100644 index 000000000..7b1e83c5c --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinDeclarationAndAssignmentAction.cs @@ -0,0 +1,63 @@ +// +// JoinDeclarationAndAssignmentAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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.Linq; +using ICSharpCode.NRefactory.PatternMatching; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Join local variable declaration and assignment", + Description = "Join local variable declaration and assignment.")] + public class JoinDeclarationAndAssignmentAction : SpecializedCodeAction + { + protected override CodeAction GetAction (RefactoringContext context, VariableInitializer node) + { + var variableDecl = node.Parent as VariableDeclarationStatement; + if (variableDecl == null || !node.Initializer.IsNull) + return null; + + var assignmentPattern = new ExpressionStatement( + new AssignmentExpression (new IdentifierExpression (node.Name), new AnyNode ("value"))); + var match = assignmentPattern.Match (variableDecl.NextSibling); + if (!match.Success) + return null; + + return new CodeAction (context.TranslateString ("Join local variable declaration and assignment"), script => { + var jointVariableDecl = new VariableDeclarationStatement (variableDecl.Type.Clone (), + node.Name, match.Get ("value").First ().Clone ()); + script.Replace (variableDecl.NextSibling, jointVariableDecl); + if (variableDecl.Variables.Count == 1) { + script.Remove (variableDecl); + } else { + var newVariableDecl = new VariableDeclarationStatement { Type = variableDecl.Type.Clone () }; + foreach (var variable in variableDecl.Variables.Where (variable => variable != node)) + newVariableDecl.Variables.Add ((VariableInitializer) variable.Clone ()); + script.Replace (variableDecl, newVariableDecl); + } + }); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinStringAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinStringAction.cs new file mode 100644 index 000000000..835ae1637 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinStringAction.cs @@ -0,0 +1,62 @@ +// +// JoinStringAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Join string literal", Description = "Join string literals.")] + public class JoinStringAction : SpecializedCodeAction + { + protected override CodeAction GetAction (RefactoringContext context, BinaryOperatorExpression node) + { + if (node.Operator != BinaryOperatorType.Add) + return null; + + PrimitiveExpression left; + var leftBinaryOperatorExpr = node.Left as BinaryOperatorExpression; + if (leftBinaryOperatorExpr != null && leftBinaryOperatorExpr.Operator == BinaryOperatorType.Add) { + left = leftBinaryOperatorExpr.Right as PrimitiveExpression; + } else { + left = node.Left as PrimitiveExpression; + } + var right = node.Right as PrimitiveExpression; + + if (left == null || right == null || + !(left.Value is string) || !(right.Value is string) || !node.OperatorToken.Contains(context.Location)) + return null; + + var isLeftVerbatim = left.LiteralValue.StartsWith ("@"); + var isRightVerbatime = right.LiteralValue.StartsWith ("@"); + if (isLeftVerbatim != isRightVerbatime) + return null; + + return new CodeAction (context.TranslateString ("Join strings"), script => { + var start = context.GetOffset (left.EndLocation) - 1; + var end = context.GetOffset (right.StartLocation) + (isLeftVerbatim ? 2 : 1); + script.RemoveText (start, end - start); + }); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/MergeNestedIfAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/MergeNestedIfAction.cs new file mode 100644 index 000000000..a72cce7eb --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/MergeNestedIfAction.cs @@ -0,0 +1,106 @@ +// +// MergeNestedIfAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Merge nested 'if'", Description = "Merge two nested 'if' statements.")] + public class MergeNestedIfAction : SpecializedCodeAction + { + static readonly InsertParenthesesVisitor insertParenthesesVisitor = new InsertParenthesesVisitor (); + + protected override CodeAction GetAction (RefactoringContext context, IfElseStatement node) + { + if (!node.IfToken.Contains (context.Location)) + return null; + + IfElseStatement outerIfStatement; + IfElseStatement innerIfStatement = GetInnerIfStatement (node); + if (innerIfStatement != null) { + if (!innerIfStatement.FalseStatement.IsNull) + return null; + outerIfStatement = node; + } else { + outerIfStatement = GetOuterIfStatement (node); + if (outerIfStatement == null || !outerIfStatement.FalseStatement.IsNull) + return null; + innerIfStatement = node; + } + + return new CodeAction (context.TranslateString ("Merge nested 'if's"), + script => + { + var mergedIfStatement = new IfElseStatement + { + Condition = new BinaryOperatorExpression (outerIfStatement.Condition.Clone (), + BinaryOperatorType.ConditionalAnd, + innerIfStatement.Condition.Clone ()), + TrueStatement = innerIfStatement.TrueStatement.Clone () + }; + mergedIfStatement.Condition.AcceptVisitor (insertParenthesesVisitor); + script.Replace (outerIfStatement, mergedIfStatement); + }); + } + + static IfElseStatement GetOuterIfStatement (IfElseStatement node) + { + var outerIf = node.Parent as IfElseStatement; + if (outerIf != null) + return outerIf; + + var blockStatement = node.Parent as BlockStatement; + while (blockStatement != null && blockStatement.Statements.Count == 1) { + outerIf = blockStatement.Parent as IfElseStatement; + if (outerIf != null) + return outerIf; + blockStatement = blockStatement.Parent as BlockStatement; + } + + return null; + } + + static IfElseStatement GetInnerIfStatement (IfElseStatement node) + { + if (!node.FalseStatement.IsNull) + return null; + + var innerIf = node.TrueStatement as IfElseStatement; + if (innerIf != null) + return innerIf; + + var blockStatement = node.TrueStatement as BlockStatement; + while (blockStatement != null && blockStatement.Statements.Count == 1) { + innerIf = blockStatement.Statements.First () as IfElseStatement; + if (innerIf != null) + return innerIf; + blockStatement = blockStatement.Statements.First () as BlockStatement; + } + + return null; + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/MoveToOuterScopeAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/MoveToOuterScopeAction.cs new file mode 100644 index 000000000..f04be0471 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/MoveToOuterScopeAction.cs @@ -0,0 +1,154 @@ +// +// MoveToOuterScopeAction.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// 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; +using System; +using ICSharpCode.NRefactory.CSharp.Resolver; +using System.Linq; +using ICSharpCode.NRefactory.Semantics; +using System.Threading; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + + [ContextAction("Move to outer scope", Description = "Moves a declaration to the parent scope.")] + public class MoveToOuterScopeAction : ICodeActionProvider + { + #region ICodeActionProvider implementation + public IEnumerable GetActions(RefactoringContext context) + { + var variableDeclaration = context.GetNode(); + if (variableDeclaration == null) + yield break; + var entryNode = FindCurrentScopeEntryNode(variableDeclaration); + if (entryNode == null) + yield break; + var selectedInitializer = context.GetNode(); + if (selectedInitializer != null) { + if (HasDependency(context, entryNode, selectedInitializer)) { + yield return MoveDeclarationAction(context, entryNode, variableDeclaration, selectedInitializer); + } else { + yield return MoveInitializerAction(context, entryNode, variableDeclaration, selectedInitializer); + } + } else { + yield return new CodeAction(context.TranslateString("Move declaration to outer scope"), script => { + script.Remove(variableDeclaration); + script.InsertBefore(entryNode, variableDeclaration.Clone()); + }); + } + } + + static CodeAction MoveInitializerAction(RefactoringContext context, AstNode insertAnchor, + VariableDeclarationStatement declaration, VariableInitializer initializer) + { + var type = declaration.Type.Clone(); + var name = initializer.Name; + return new CodeAction(context.TranslateString("Move initializer to outer scope"), script => { + if (declaration.Variables.Count != 1) { + var innerDeclaration = RemoveInitializer(declaration, initializer); + script.InsertBefore(declaration, innerDeclaration); + } + script.Remove(declaration); + var outerDeclaration = new VariableDeclarationStatement(type, name, initializer.Initializer.Clone()); + script.InsertBefore(insertAnchor, outerDeclaration); + }); + } + + static CodeAction MoveDeclarationAction(RefactoringContext context, AstNode insertAnchor, + VariableDeclarationStatement declarationStatement, VariableInitializer initializer) + { + var type = declarationStatement.Type.Clone(); + var name = initializer.Name; + + return new CodeAction(context.TranslateString("Move declaration to outer scope"), script => { + script.InsertBefore(declarationStatement, new ExpressionStatement() { + Expression = new AssignmentExpression(new IdentifierExpression(name), initializer.Initializer.Clone()) + }); + script.Remove(declarationStatement); + script.InsertBefore(insertAnchor, new VariableDeclarationStatement(type, name, Expression.Null)); + }); + } + + bool HasDependency(RefactoringContext context, AstNode firstSearchNode, AstNode targetNode) + { + var referenceFinder = new FindReferences(); + var identifiers = targetNode.Descendants + .Where(n => n is IdentifierExpression) + .Select(node => (IdentifierExpression)node); + foreach (var identifier in identifiers) { + var resolveResult = context.Resolve(identifier); + var localResolveResult = resolveResult as LocalResolveResult; + if (localResolveResult == null) + continue; + bool referenceFound = false; + var variable = localResolveResult.Variable; + var syntaxTree = context.RootNode as SyntaxTree; + referenceFinder.FindLocalReferences(localResolveResult.Variable, context.UnresolvedFile, syntaxTree, + context.Compilation, (node, nodeResolveResult) => { + if (node.StartLocation > firstSearchNode.StartLocation && node.EndLocation < targetNode.StartLocation) + referenceFound = true; + }, CancellationToken.None); + if (referenceFound) + return true; + } + return false; + } + + static VariableDeclarationStatement RemoveInitializer(VariableDeclarationStatement variableDeclarationStatement, VariableInitializer selectedVariableInitializer) + { + var newVariableDeclarationStatement = new VariableDeclarationStatement() { + Type = variableDeclarationStatement.Type.Clone() + }; + foreach (var variableInitializer in variableDeclarationStatement.Variables) { + if (variableInitializer != selectedVariableInitializer) { + newVariableDeclarationStatement.AddChild((VariableInitializer)variableInitializer.Clone(), Roles.Variable); + } + } + return newVariableDeclarationStatement; + } + + List scopeContainers = new List() { + typeof (MethodDeclaration), + typeof (Accessor) + }; + + AstNode FindCurrentScopeEntryNode(Statement startNode) + { + // Start one node up in the tree, otherwise we may stop at the BlockStatement + // of the current scope instead of moving up to the enclosing scope + var currentNode = startNode.Parent; + AstNode lastNode; + do { + lastNode = currentNode; + currentNode = currentNode.Parent; + if (scopeContainers.Contains(currentNode.GetType())) + return null; + } while (currentNode.GetType() != typeof(BlockStatement)); + return lastNode; + } + #endregion + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/NegateRelationalExpressionAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/NegateRelationalExpressionAction.cs new file mode 100644 index 000000000..425748542 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/NegateRelationalExpressionAction.cs @@ -0,0 +1,48 @@ +// +// NegateRelationalExpressionAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Negate an relational expression", Description = "Negate an relational expression.")] + public class NegateRelationalExpressionAction : SpecializedCodeAction + { + + protected override CodeAction GetAction (RefactoringContext context, BinaryOperatorExpression node) + { + var newOp = CSharpUtil.NegateRelationalOperator (node.Operator); + if (newOp != BinaryOperatorType.Any && node.OperatorToken.Contains (context.Location)) { + var operatorToken = BinaryOperatorExpression.GetOperatorRole (node.Operator).Token; + return new CodeAction (string.Format (context.TranslateString ("Negate '{0}'"), operatorToken), + script => { + var expr = new BinaryOperatorExpression (node.Left.Clone (), newOp, node.Right.Clone ()); + script.Replace (node, expr); + }); + } + return null; + } + + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/PutInsideUsingAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/PutInsideUsingAction.cs new file mode 100644 index 000000000..88dd4bdcb --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/PutInsideUsingAction.cs @@ -0,0 +1,147 @@ +// +// PutInsideUsingAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Linq; +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.NRefactory.Semantics; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("put inside 'using'", Description = "put IDisposable inside 'using' construct")] + public class PutInsideUsingAction : SpecializedCodeAction + { + static readonly FindReferences refFinder = new FindReferences (); + protected override CodeAction GetAction (RefactoringContext context, VariableInitializer node) + { + if (node.Initializer.IsNull) + return null; + + var variableDecl = node.Parent as VariableDeclarationStatement; + if (variableDecl == null || !(variableDecl.Parent is BlockStatement)) + return null; + + var type = context.ResolveType (variableDecl.Type); + if (!IsIDisposable (type)) + return null; + + var unit = context.RootNode as SyntaxTree; + if (unit == null) + return null; + + var resolveResult = (LocalResolveResult)context.Resolve (node); + + return new CodeAction (context.TranslateString ("put inside 'using'"), + script => + { + var lastReference = GetLastReference (resolveResult.Variable, context, unit); + + var body = new BlockStatement (); + var variableToMoveOutside = new List (); + + if (lastReference != node) { + var statements = CollectStatements (variableDecl.NextSibling as Statement, + lastReference.EndLocation).ToArray(); + + // collect statements to put inside 'using' and variable declaration to move outside 'using' + foreach (var statement in statements) { + script.Remove (statement); + + var decl = statement as VariableDeclarationStatement; + if (decl == null) { + body.Statements.Add (statement.Clone ()); + continue; + } + + var outsideDecl = (VariableDeclarationStatement)decl.Clone (); + outsideDecl.Variables.Clear (); + var insideDecl = (VariableDeclarationStatement)outsideDecl.Clone (); + + foreach (var variable in decl.Variables) { + var reference = GetLastReference ( + ((LocalResolveResult)context.Resolve (variable)).Variable, context, unit); + if (reference.StartLocation > lastReference.EndLocation) + outsideDecl.Variables.Add ((VariableInitializer)variable.Clone ()); + else + insideDecl.Variables.Add ((VariableInitializer)variable.Clone ()); + } + if (outsideDecl.Variables.Count > 0) + variableToMoveOutside.Add (outsideDecl); + if (insideDecl.Variables.Count > 0) + body.Statements.Add (insideDecl); + } + } + + foreach (var decl in variableToMoveOutside) + script.InsertBefore (variableDecl, decl); + + var usingStatement = new UsingStatement + { + ResourceAcquisition = new VariableDeclarationStatement (variableDecl.Type.Clone (), node.Name, + node.Initializer.Clone ()), + EmbeddedStatement = body + }; + script.Replace (variableDecl, usingStatement); + + if (variableDecl.Variables.Count == 1) + return; + // other variables in the same declaration statement + var remainingVariables = (VariableDeclarationStatement)variableDecl.Clone (); + remainingVariables.Variables.Remove ( + remainingVariables.Variables.FirstOrDefault (v => v.Name == node.Name)); + script.InsertBefore (usingStatement, remainingVariables); + }); + } + + static bool IsIDisposable (IType type) + { + return type.GetAllBaseTypeDefinitions ().Any (t => t.KnownTypeCode == KnownTypeCode.IDisposable); + } + + static IEnumerable CollectStatements (Statement statement, TextLocation end) + { + while (statement != null) { + yield return statement; + if (statement.Contains (end)) + break; + statement = statement.NextSibling as Statement; + } + } + + static AstNode GetLastReference (IVariable variable, RefactoringContext context, SyntaxTree unit) + { + AstNode lastReference = null; + refFinder.FindLocalReferences (variable, context.UnresolvedFile, unit, context.Compilation, + (v, r) => + { + if (lastReference == null || v.EndLocation > lastReference.EndLocation) + lastReference = v; + }, context.CancellationToken); + return lastReference; + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveBracesAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveBracesAction.cs index 21e82fa43..3d7a6fc52 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveBracesAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveBracesAction.cs @@ -41,6 +41,11 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring } yield return new CodeAction (context.TranslateString("Remove braces"), script => { + var start = script.GetCurrentOffset (block.LBraceToken.GetPrevNode ().EndLocation); + var end = script.GetCurrentOffset (block.LBraceToken.EndLocation); + if (end <= start) + return; + script.RemoveText (start, end - start); script.Remove(block.LBraceToken); script.Remove(block.RBraceToken); script.FormatText(block.Parent); diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveRedundantCatchTypeAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveRedundantCatchTypeAction.cs new file mode 100644 index 000000000..fd6817c95 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/RemoveRedundantCatchTypeAction.cs @@ -0,0 +1,80 @@ +// +// RemoveRedundantCatchTypeAction.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using ICSharpCode.NRefactory.CSharp.Refactoring; +using ICSharpCode.NRefactory.TypeSystem; +using System; +using ICSharpCode.NRefactory.Semantics; +using System.Threading; +using ICSharpCode.NRefactory.CSharp.Resolver; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction("Remove redundant type", + Description = "Removes a redundant exception type specifier from catch clauses.")] + public class RemoveRedundantCatchTypeAction : ICodeActionProvider + { + #region ICodeActionProvider implementation + public System.Collections.Generic.IEnumerable GetActions(RefactoringContext context) + { + var catchClause = context.GetNode(); + if (catchClause == null) + yield break; + if (catchClause.Type.IsNull) + yield break; + var exceptionType = context.ResolveType(catchClause.Type); + if (exceptionType != context.Compilation.FindType(typeof(Exception))) + yield break; + var syntaxTree = context.RootNode as SyntaxTree; + if (syntaxTree == null) + yield break; + var exceptionIdentifierRR = context.Resolve(catchClause.VariableNameToken) as LocalResolveResult; + if (exceptionIdentifierRR != null && + IsReferenced(exceptionIdentifierRR.Variable, catchClause.Body, syntaxTree, context)) + yield break; + yield return new CodeAction(context.TranslateString("Remove type specifier"), script => { + script.Replace(catchClause, new CatchClause() { + Body = catchClause.Body.Clone() as BlockStatement + }); + }); + } + + bool IsReferenced(IVariable variable, AstNode node, SyntaxTree syntaxTree, RefactoringContext context) + { + int referencesFound = 0; + var findRef = new FindReferences(); + findRef.FindLocalReferences(variable, context.UnresolvedFile, syntaxTree, context.Compilation, (n, entity) => { + referencesFound++; + }, CancellationToken.None); + + // One reference is the declaration, and that does not count + return referencesFound > 1; + } + + #endregion + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/SplitDeclarationListAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/SplitDeclarationListAction.cs new file mode 100644 index 000000000..c6cdb6298 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/SplitDeclarationListAction.cs @@ -0,0 +1,93 @@ +// +// SplitDeclarationListAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Split declaration list", + Description = "Split variable declaration with multiple variables into declarations with a single variable")] + public class SplitDeclarationListAction : ICodeActionProvider + { + public IEnumerable GetActions (RefactoringContext context) + { + // field, local var, event, fixed var, fixed field + + // local variable + var variableDecl = context.GetNode (); + if (variableDecl != null && variableDecl.Parent is BlockStatement) { + return GetAction (context, variableDecl, v => v.Variables); + } + + // field + var fieldDecl = context.GetNode (); + if (fieldDecl != null) + return GetAction (context, fieldDecl, f => f.Variables); + + // event + var eventDecl = context.GetNode (); + if (eventDecl != null) + return GetAction (context, eventDecl, e => e.Variables); + + // fixed field + var fixedFieldDecl = context.GetNode (); + if (fixedFieldDecl != null) + return GetAction (context, fixedFieldDecl, f => f.Variables); + + return Enumerable.Empty (); + } + + IEnumerable GetAction (RefactoringContext context, T decl, + Func> getInitializers) + where T : AstNode + where S : AstNode + { + var initializers = getInitializers(decl); + if (initializers.Count < 2) + yield break; + + yield return new CodeAction (context.TranslateString ("Split declaration list"), + script => + { + var emptyDecl = (T)decl.Clone (); + getInitializers (emptyDecl).Clear (); + + var declList = initializers.Select (v => + { + var singleDecl = (T)emptyDecl.Clone (); + getInitializers(singleDecl).Add ((S)v.Clone ()); + return singleDecl; + }); + + foreach (var singleDecl in declList) + script.InsertBefore (decl, singleDecl); + script.Remove (decl); + }); + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/StaticMethodInvocationToExtensionMethodInvocationAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/StaticMethodInvocationToExtensionMethodInvocationAction.cs new file mode 100644 index 000000000..5f06c577f --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/StaticMethodInvocationToExtensionMethodInvocationAction.cs @@ -0,0 +1,68 @@ +// +// StaticMethodInvocationToExtensionMethodInvocationAction.cs +// +// Author: +// Simon Lindgren +// +// Copyright (c) 2012 Simon Lindgren +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using ICSharpCode.NRefactory.CSharp.Resolver; +using System.Linq; +using System.Collections.Generic; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + + [ContextAction("Invoke using extension method syntax", + Description = "Converts the call into extension method call syntax.")] + public class StaticMethodInvocationToExtensionMethodInvocationAction : ICodeActionProvider + { + #region ICodeActionProvider implementation + + public IEnumerable GetActions (RefactoringContext context) + { + var invocation = context.GetNode(); + if (invocation == null) + yield break; + var memberReference = invocation.Target as MemberReferenceExpression; + if (memberReference == null) + yield break; + var firstArgument = invocation.Arguments.FirstOrDefault(); + if (firstArgument is NullReferenceExpression) + yield break; + var invocationRR = context.Resolve(invocation) as CSharpInvocationResolveResult; + if (invocationRR == null) + yield break; + var method = invocationRR.Member as IMethod; + if (method == null || !method.IsExtensionMethod || invocationRR.IsExtensionMethodInvocation) + yield break; + yield return new CodeAction(context.TranslateString("Convert to extension method call"), script => { + var newArgumentList = invocation.Arguments.Skip(1).Select(arg => arg.Clone()).ToList(); + var newTarget = memberReference.Clone() as MemberReferenceExpression; + newTarget.Target = firstArgument.Clone(); + script.Replace(invocation, new InvocationExpression(newTarget, newArgumentList)); + }); + } + + #endregion + } +} + diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/UseExplicitTypeAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/UseExplicitTypeAction.cs index 96cd3a10c..c1b0aecb5 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/UseExplicitTypeAction.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/UseExplicitTypeAction.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring if (!(!type.Equals(SpecialType.NullType) && !type.Equals(SpecialType.UnknownType))) { yield break; } - yield return new CodeAction (context.TranslateString("Use expcicit type"), script => { + yield return new CodeAction (context.TranslateString("Use explicit type"), script => { if (varDecl != null) { script.Replace (varDecl.Type, context.CreateShortType (type)); } else { diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/UseStringFormatAction.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/UseStringFormatAction.cs new file mode 100644 index 000000000..56f7404fe --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/UseStringFormatAction.cs @@ -0,0 +1,144 @@ +// +// UseStringFormatAction.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Text; +using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.PatternMatching; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [ContextAction ("Use string.Format()", + Description = "Convert concatenation of strings and objects to string.Format()")] + public class UseStringFormatAction : ICodeActionProvider + { + + public IEnumerable GetActions (RefactoringContext context) + { + // NOTE: @, multiple occurance + + var node = context.GetNode (); + while (node != null && !IsStringConcatenation(context, node as BinaryOperatorExpression)) + node = node.Parent; + + if (node == null) + yield break; + + var expr = (BinaryOperatorExpression)node; + var parent = expr.Parent as BinaryOperatorExpression; + while (parent != null && parent.Operator == BinaryOperatorType.Add) { + expr = parent; + parent = expr.Parent as BinaryOperatorExpression; + } + + yield return new CodeAction (context.TranslateString ("Use string.Format()"), + script => + { + var format = new StringBuilder (); + var stringType = new PrimitiveType ("string"); + var formatInvocation = new InvocationExpression ( + new MemberReferenceExpression (new TypeReferenceExpression (stringType), "Format")); + var formatLiteral = new PrimitiveExpression (""); + var counter = 0; + var verbatim = false; + var arguments = new List (); + + format.Append ('"'); + formatInvocation.Arguments.Add (formatLiteral); + foreach (var item in GetConcatItems (context, expr)) { + if (IsStringLiteral (item)) { + var stringLiteral = (PrimitiveExpression)item; + + if (stringLiteral.LiteralValue [0] == '@') { + verbatim = true; + format.Append (stringLiteral.LiteralValue, 2, stringLiteral.LiteralValue.Length - 3); + } else { + format.Append (stringLiteral.LiteralValue, 1, stringLiteral.LiteralValue.Length - 2); + } + } else { + var index = IndexOf (arguments, item); + if (index == -1) { + // new item + formatInvocation.Arguments.Add (item.Clone ()); + arguments.Add (item); + format.Append ("{" + counter++ + "}"); + } else { + // existing item + format.Append ("{" + index + "}"); + } + } + } + format.Append ('"'); + if (verbatim) + format.Insert (0, '@'); + formatLiteral.LiteralValue = format.ToString (); + script.Replace (expr, formatInvocation); + }); + } + + static int IndexOf (IList arguments, Expression item) + { + for (int i = 0; i < arguments.Count; i++) { + if (item.Match (arguments [i]).Success) + return i; + } + return -1; + } + + static IEnumerable GetConcatItems (RefactoringContext context, BinaryOperatorExpression expr) + { + var leftExpr = expr.Left as BinaryOperatorExpression; + if (IsStringConcatenation(context, leftExpr)) { + foreach (var item in GetConcatItems (context, leftExpr)) + yield return item; + } else { + yield return expr.Left; + } + + var rightExpr = expr.Right as BinaryOperatorExpression; + if (IsStringConcatenation(context, rightExpr)) { + foreach (var item in GetConcatItems (context, rightExpr)) + yield return item; + } else { + yield return expr.Right; + } + } + + static bool IsStringConcatenation (RefactoringContext context, BinaryOperatorExpression expr) + { + if (expr == null || expr.Operator != BinaryOperatorType.Add) + return false; + var typeDef = context.Resolve (expr).Type.GetDefinition(); + return typeDef != null && typeDef.KnownTypeCode == KnownTypeCode.String; + } + + static bool IsStringLiteral (AstNode node) + { + var expr = node as PrimitiveExpression; + return expr != null && expr.Value is string; + } + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssue.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssue.cs index df75077a6..2ae89cb6e 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssue.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssue.cs @@ -1,4 +1,4 @@ -// +// // InspectionIssue.cs // // Author: @@ -35,9 +35,9 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring public class CodeIssue { /// - /// Gets the desription of the issue. + /// Gets the description of the issue. /// - public string Desription { + public string Description { get; private set; } @@ -83,7 +83,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring /// public CodeIssue(string description, TextLocation start, TextLocation end, IEnumerable actions = null) { - Desription = description; + Description = description; Start = start; End = end; if (actions != null) diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToClosureIssue.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToClosureIssue.cs new file mode 100644 index 000000000..c54af7885 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToClosureIssue.cs @@ -0,0 +1,327 @@ +// +// AccessToClosureIssue.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Linq; +using ICSharpCode.NRefactory.CSharp.Analysis; +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.NRefactory.Semantics; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + public abstract class AccessToClosureIssue : ICodeIssueProvider + { + static FindReferences refFinder = new FindReferences (); + static ControlFlowGraphBuilder cfgBuilder = new ControlFlowGraphBuilder (); + + public string Title + { get; private set; } + + protected AccessToClosureIssue (string title) + { + Title = title; + } + + public IEnumerable GetIssues (BaseRefactoringContext context) + { + var unit = context.RootNode as SyntaxTree; + if (unit == null) + return Enumerable.Empty (); + return new GatherVisitor (context, unit, this).GetIssues (); + } + + protected virtual bool IsTargetVariable (IVariable variable) + { + return true; + } + + protected abstract NodeKind GetNodeKind (AstNode node); + + protected virtual bool CanReachModification (ControlFlowNode node, Statement start, + IDictionary> modifications) + { + return node.NextStatement != null && node.NextStatement != start && + modifications.ContainsKey (node.NextStatement); + } + + protected abstract IEnumerable GetFixes (BaseRefactoringContext context, Node env, + string variableName); + + #region GatherVisitor + + class GatherVisitor : GatherVisitorBase + { + SyntaxTree unit; + string title; + AccessToClosureIssue issueProvider; + + public GatherVisitor (BaseRefactoringContext context, SyntaxTree unit, + AccessToClosureIssue issueProvider) + : base (context) + { + this.title = context.TranslateString (issueProvider.Title); + this.unit = unit; + this.issueProvider = issueProvider; + } + + public override void VisitVariableInitializer (VariableInitializer variableInitializer) + { + var variableDecl = variableInitializer.Parent as VariableDeclarationStatement; + if (variableDecl != null) + CheckVariable (((LocalResolveResult)ctx.Resolve (variableInitializer)).Variable, + variableDecl.GetParent ()); + base.VisitVariableInitializer (variableInitializer); + } + + public override void VisitForeachStatement (ForeachStatement foreachStatement) + { + CheckVariable (((LocalResolveResult)ctx.Resolve (foreachStatement.VariableNameToken)).Variable, + foreachStatement); + base.VisitForeachStatement (foreachStatement); + } + + public override void VisitParameterDeclaration (ParameterDeclaration parameterDeclaration) + { + var parent = parameterDeclaration.Parent; + Statement body = null; + if (parent is MethodDeclaration) { + body = ((MethodDeclaration)parent).Body; + } else if (parent is AnonymousMethodExpression) { + body = ((AnonymousMethodExpression)parent).Body; + } else if (parent is LambdaExpression) { + body = ((LambdaExpression)parent).Body as Statement; + } else if (parent is ConstructorDeclaration) { + body = ((ConstructorDeclaration)parent).Body; + } else if (parent is OperatorDeclaration) { + body = ((OperatorDeclaration)parent).Body; + } + if (body != null) + CheckVariable (((LocalResolveResult)ctx.Resolve (parameterDeclaration)).Variable, body); + base.VisitParameterDeclaration (parameterDeclaration); + } + + void FindLocalReferences (IVariable variable, FoundReferenceCallback callback) + { + refFinder.FindLocalReferences (variable, ctx.UnresolvedFile, unit, ctx.Compilation, callback, + ctx.CancellationToken); + } + + void CheckVariable (IVariable variable, Statement env) + { + if (!issueProvider.IsTargetVariable (variable)) + return; + + var root = new Environment (env, env); + var envLookup = new Dictionary (); + envLookup [env] = root; + + FindLocalReferences (variable, (astNode, resolveResult) => + AddNode (envLookup, new Node (astNode, issueProvider.GetNodeKind (astNode)))); + + root.SortChildren (); + CollectIssues (root, variable.Name); + } + + void CollectIssues (Environment env, string variableName) + { + IList cfg = null; + IDictionary> modifications = null; + + if (env.Body != null) { + cfg = cfgBuilder.BuildControlFlowGraph (env.Body); + modifications = new Dictionary> (); + foreach (var node in env.Children) { + if (node.Kind == NodeKind.Modification || node.Kind == NodeKind.ReferenceAndModification) { + IList nodes; + if (!modifications.TryGetValue (node.ContainingStatement, out nodes)) + modifications [node.ContainingStatement] = nodes = new List (); + nodes.Add (node); + } + } + } + + foreach (var child in env.GetChildEnvironments ()) { + if (!child.IssueCollected && cfg != null && + CanReachModification (cfg, child, modifications)) + CollectAllIssues (child, variableName); + + CollectIssues (child, variableName); + } + } + + void CollectAllIssues (Environment env, string variableName) + { + var fixes = issueProvider.GetFixes (ctx, env, variableName).ToArray (); + env.IssueCollected = true; + + foreach (var child in env.Children) { + if (child is Environment) { + CollectAllIssues ((Environment)child, variableName); + } else { + if (child.Kind != NodeKind.Modification) + AddIssue (child.AstNode, title, fixes); + // stop marking references after the variable is modified in current environment + if (child.Kind != NodeKind.Reference) + break; + } + } + } + + void AddNode (IDictionary envLookup, Node node) + { + var astParent = node.AstNode.Parent; + var path = new List (); + while (astParent != null) { + Environment parent; + if (envLookup.TryGetValue (astParent, out parent)) { + parent.Children.Add (node); + return; + } + + if (astParent is LambdaExpression) { + parent = new Environment (astParent, ((LambdaExpression)astParent).Body as Statement); + } else if (astParent is AnonymousMethodExpression) { + parent = new Environment (astParent, ((AnonymousMethodExpression)astParent).Body); + } + + path.Add (astParent); + if (parent != null) { + foreach (var astNode in path) + envLookup [astNode] = parent; + path.Clear (); + + parent.Children.Add (node); + node = parent; + } + astParent = astParent.Parent; + } + } + + bool CanReachModification (IEnumerable cfg, Environment env, + IDictionary> modifications) + { + if (modifications.Count == 0) + return false; + + var start = env.ContainingStatement; + if (modifications.ContainsKey (start) && + modifications [start].Any (v => v.AstNode.StartLocation > env.AstNode.EndLocation)) + return true; + + var stack = new Stack (cfg.Where (node => node.NextStatement == start)); + var visitedNodes = new HashSet (stack); + while (stack.Count > 0) { + var node = stack.Pop (); + if (issueProvider.CanReachModification (node, start, modifications)) + return true; + foreach (var edge in node.Outgoing) { + if (visitedNodes.Add (edge.To)) + stack.Push (edge.To); + } + } + return false; + } + + } + + #endregion + + #region Node + + protected enum NodeKind + { + Reference, + Modification, + ReferenceAndModification, + Environment, + } + + protected class Node + { + public AstNode AstNode + { get; private set; } + + public NodeKind Kind + { get; private set; } + + public Statement ContainingStatement + { get; private set; } + + public Node (AstNode astNode, NodeKind kind) + { + AstNode = astNode; + Kind = kind; + ContainingStatement = astNode.GetParent (); + } + + public virtual IEnumerable GetAllReferences () + { + yield return this; + } + } + + protected class Environment : Node + { + public Statement Body + { get; private set; } + + public bool IssueCollected + { get; set; } + + public List Children + { get; private set; } + + public Environment (AstNode astNode, Statement body) + : base (astNode, NodeKind.Environment) + { + Body = body; + Children = new List (); + } + + public override IEnumerable GetAllReferences () + { + return Children.SelectMany (child => child.GetAllReferences ()); + } + + public IEnumerable GetChildEnvironments () + { + return from child in Children + where child is Environment + select (Environment)child; + } + + public void SortChildren () + { + Children.Sort ((x, y) => x.AstNode.StartLocation.CompareTo(y.AstNode.StartLocation)); + foreach (var env in GetChildEnvironments ()) + env.SortChildren (); + } + } + + #endregion + } +} diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToDisposedClosureIssue.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToDisposedClosureIssue.cs new file mode 100644 index 000000000..738dc7b51 --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToDisposedClosureIssue.cs @@ -0,0 +1,93 @@ +// +// AccessToDisposedClosureIssue.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Linq; +using ICSharpCode.NRefactory.CSharp.Analysis; +using ICSharpCode.NRefactory.TypeSystem; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + + [IssueDescription ("Access to disposed closure variable", + Description = "Access to closure variable from anonymous method when the variable is" + + " disposed externally", + Category = IssueCategories.CodeQualityIssues, + Severity = Severity.Warning, + IssueMarker = IssueMarker.Underline)] + public class AccessToDisposedClosureIssue : AccessToClosureIssue + { + public AccessToDisposedClosureIssue () + : base ("Access to disposed closure") + { + } + + protected override bool IsTargetVariable (IVariable variable) + { + return variable.Type.GetAllBaseTypeDefinitions ().Any (t => t.KnownTypeCode == KnownTypeCode.IDisposable); + } + + protected override NodeKind GetNodeKind (AstNode node) + { + if (node.Parent is UsingStatement) + return NodeKind.ReferenceAndModification; + + if (node.Parent is VariableDeclarationStatement && node.Parent.Parent is UsingStatement) + return NodeKind.Modification; + + var memberRef = node.Parent as MemberReferenceExpression; + if (memberRef != null && memberRef.Parent is InvocationExpression && memberRef.MemberName == "Dispose") + return NodeKind.ReferenceAndModification; + + return NodeKind.Reference; + } + + protected override bool CanReachModification (ControlFlowNode node, Statement start, + IDictionary> modifications) + { + if (base.CanReachModification (node, start, modifications)) + return true; + + if (node.NextStatement != start) { + var usingStatement = node.PreviousStatement as UsingStatement; + if (usingStatement != null) { + if (modifications.ContainsKey(usingStatement)) + return true; + if (usingStatement.ResourceAcquisition is Statement && + modifications.ContainsKey ((Statement)usingStatement.ResourceAcquisition)) + return true; + } + } + return false; + } + + protected override IEnumerable GetFixes (BaseRefactoringContext context, Node env, + string variableName) + { + yield break; + } + } +} \ No newline at end of file diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToModifiedClosureIssue.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToModifiedClosureIssue.cs new file mode 100644 index 000000000..253629f4b --- /dev/null +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/AccessToClosureIssues/AccessToModifiedClosureIssue.cs @@ -0,0 +1,115 @@ +// +// AccessToModifiedClosureIssue.cs +// +// Author: +// Mansheng Yang +// +// Copyright (c) 2012 Mansheng Yang +// +// 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; +using System.Linq; + +namespace ICSharpCode.NRefactory.CSharp.Refactoring +{ + [IssueDescription ("Access to modified closure variable", + Description = "Access to closure variable from anonymous method when the variable is modified " + + "externally", + Category = IssueCategories.CodeQualityIssues, + Severity = Severity.Warning, + IssueMarker = IssueMarker.Underline)] + public class AccessToModifiedClosureIssue : AccessToClosureIssue + { + public AccessToModifiedClosureIssue () + : base ("Access to modified closure") + { + } + + protected override NodeKind GetNodeKind (AstNode node) + { + var assignment = node.GetParent (); + if (assignment != null && assignment.Left == node) { + if (assignment.Operator == AssignmentOperatorType.Assign) + return NodeKind.Modification; + return NodeKind.ReferenceAndModification; + } + var unaryExpr = node.GetParent (); + if (unaryExpr != null && unaryExpr.Expression == node && + (unaryExpr.Operator == UnaryOperatorType.Increment || + unaryExpr.Operator == UnaryOperatorType.PostIncrement || + unaryExpr.Operator == UnaryOperatorType.Decrement || + unaryExpr.Operator == UnaryOperatorType.PostDecrement)) { + return NodeKind.ReferenceAndModification; + } + if (node.Parent is ForeachStatement) + return NodeKind.Modification; + + return NodeKind.Reference; + } + + protected override IEnumerable GetFixes (BaseRefactoringContext context, Node env, + string variableName) + { + var containingStatement = env.ContainingStatement; + + // we don't give a fix for these cases since the general fix may not work + // lambda in while/do-while/for condition + if (containingStatement is WhileStatement || containingStatement is DoWhileStatement || + containingStatement is ForStatement) + yield break; + // lambda in for initializer/iterator + if (containingStatement.Parent is ForStatement && + ((ForStatement)containingStatement.Parent).EmbeddedStatement != containingStatement) + yield break; + + Action