mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
b8330be Remove parent pointer from ITypeParameter and enable sharing type parameters. ca6b0e1 fixed primitve types. 094cac4 Added some creation constructors. b7cd75a Fixed unit test. 9fedc31 Handled undocumented expressions. 7d4ef1a Added support for quoted identifiers. f30490c Add some parser unit tests. 307559c Remove NextStatement/PrevStatement properties - too many properties can be confusing (e.g. a loop's EmbeddedStatement would show up next to those two properties) 90542d2 Fix parsing of query continuations for queries with multiple from clauses. ccd06a4 Fixed query expression tests. Had to add a new node type: AnonymousTypeCreateExpression. d4eaffb Make pattern matching AST independent from C# AST. e8d472b Rename FixedVariableInitializer.Initializer to CountExpression (this makes it consistent with StackAllocExpression). 16715bb Renamed CSharpFormattingPolicy to CSharpFormattingOptions. 92df3e5 Fixed some TypeReferenceExpression tests. f4450d1 Fixed some invocation expression tests. 42463a4 Fixed unit test TestIdentifierContainingEscapeSequence. 021a9fb Fixed typeofexpression tests. bd51bee Fixed GlobalFullNamespaceGenericFieldReferenceExpressionTest. 040e164 Fixed lambdaexpression tests. 0722289 Updated mcs, fixed failing unit test. c35eb4d Enabled typ declaration tests. 94c18d6 Fixed delegate declaration tests. a45fa11 Fixed event declaration tests. 9083bee Fixed constructor declaration tests. 2e82144 * TypeDeclarationTests.cs: * PropertyDeclarationTests.cs: enabled property declaration tests. 873c185 Added attribute section parsing / fixed indexer declaration tests. 2353804 Fixed field declaration tests. 4e60911 Fixed method declaration tests. 58caab2 Fixed statement unit tests. cad9d18 Fixed fixed statement. a4ce5aa Updated mcs/fixed pointer reference expression bug. ca77589 Fixed partial modifier. 8c7e017 Fixed UsingDeclarationTests. 293dba5 Worked on pointer reference expression. cc209b4 Fixed ArrayObjectCreateExpression tests. 58856b1 Activated cast expression tests. c0e20a6 Fixed qualified alias member tests. 44388b2 Fixed anonymous method tests. git-subtree-dir: NRefactory git-subtree-split: b8330bebd6a1cb3a2895fc924f472292bc1cf85epull/129/head
157 changed files with 9423 additions and 7642 deletions
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// AnonymousTypeCreateExpression.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Krüger <mkrueger@novell.com>
|
||||
//
|
||||
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp |
||||
{ |
||||
/// <summary>
|
||||
/// new { [ExpressionList] }
|
||||
/// </summary>
|
||||
public class AnonymousTypeCreateExpression : Expression |
||||
{ |
||||
public CSharpTokenNode NewToken { |
||||
get { return GetChildByRole (Roles.Keyword); } |
||||
} |
||||
|
||||
public CSharpTokenNode LParToken { |
||||
get { return GetChildByRole (Roles.LPar); } |
||||
} |
||||
|
||||
public AstNodeCollection<Expression> Initializer { |
||||
get { return GetChildrenByRole (Roles.Expression); } |
||||
} |
||||
|
||||
public CSharpTokenNode RParToken { |
||||
get { return GetChildByRole (Roles.RPar); } |
||||
} |
||||
|
||||
public AnonymousTypeCreateExpression () |
||||
{ |
||||
} |
||||
|
||||
public AnonymousTypeCreateExpression (IEnumerable<Expression> initializer) |
||||
{ |
||||
foreach (var ini in initializer) { |
||||
AddChild (ini, Roles.Expression); |
||||
} |
||||
} |
||||
|
||||
public AnonymousTypeCreateExpression (params Expression[] initializer) : this ((IEnumerable<Expression>)initializer) |
||||
{ |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitAnonymousTypeCreateExpression (this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
var o = other as AnonymousTypeCreateExpression; |
||||
return o != null && this.Initializer.DoMatch(o.Initializer, match); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.PatternMatching |
||||
{ |
||||
/// <summary>
|
||||
/// Matches one of several alternatives.
|
||||
/// </summary>
|
||||
public class Choice : Pattern, IEnumerable<AstNode> |
||||
{ |
||||
public static readonly Role<AstNode> AlternativeRole = new Role<AstNode>("Alternative", AstNode.Null); |
||||
|
||||
public void Add(string name, AstNode alternative) |
||||
{ |
||||
AddChild(new NamedNode(name, alternative), AlternativeRole); |
||||
} |
||||
|
||||
public void Add(AstNode alternative) |
||||
{ |
||||
AddChild(alternative, AlternativeRole); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
var checkPoint = match.CheckPoint(); |
||||
foreach (AstNode alt in GetChildrenByRole(AlternativeRole)) { |
||||
if (alt.DoMatch(other, match)) |
||||
return true; |
||||
else |
||||
match.RestoreCheckPoint(checkPoint); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
IEnumerator<AstNode> IEnumerable<AstNode>.GetEnumerator() |
||||
{ |
||||
return GetChildrenByRole(AlternativeRole).GetEnumerator(); |
||||
} |
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() |
||||
{ |
||||
return GetChildrenByRole(AlternativeRole).GetEnumerator(); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitChoice(this, data); |
||||
} |
||||
} |
||||
} |
||||
@ -1,42 +0,0 @@
@@ -1,42 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.PatternMatching |
||||
{ |
||||
public class OptionalNode : Pattern |
||||
{ |
||||
public static readonly Role<AstNode> ElementRole = new Role<AstNode>("Element", AstNode.Null); |
||||
|
||||
public OptionalNode(AstNode childNode) |
||||
{ |
||||
AddChild(childNode, ElementRole); |
||||
} |
||||
|
||||
public OptionalNode(string groupName, AstNode childNode) : this(new NamedNode(groupName, childNode)) |
||||
{ |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
backtrackingStack.Push(new PossibleMatch(pos, match.CheckPoint())); |
||||
return GetChildByRole(ElementRole).DoMatch(pos, match); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
if (other == null || other.IsNull) |
||||
return true; |
||||
else |
||||
return GetChildByRole(ElementRole).DoMatch(other, match); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitOptionalNode(this, data); |
||||
} |
||||
} |
||||
} |
||||
@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.PatternMatching |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for all patterns.
|
||||
/// </summary>
|
||||
public abstract class Pattern : AstNode |
||||
{ |
||||
public override NodeType NodeType { |
||||
get { return NodeType.Pattern; } |
||||
} |
||||
|
||||
internal struct PossibleMatch |
||||
{ |
||||
public readonly AstNode NextOther; // next node after the last matched node
|
||||
public readonly int Checkpoint; // checkpoint
|
||||
|
||||
public PossibleMatch(AstNode nextOther, int checkpoint) |
||||
{ |
||||
this.NextOther = nextOther; |
||||
this.Checkpoint = checkpoint; |
||||
} |
||||
} |
||||
|
||||
public static implicit operator AstType(Pattern p) |
||||
{ |
||||
return p != null ? new TypePlaceholder(p) : null; |
||||
} |
||||
|
||||
public AstType ToType() |
||||
{ |
||||
return new TypePlaceholder(this); |
||||
} |
||||
|
||||
public static implicit operator Expression(Pattern p) |
||||
{ |
||||
return p != null ? new ExpressionPlaceholder(p) : null; |
||||
} |
||||
|
||||
public Expression ToExpression() |
||||
{ |
||||
return new ExpressionPlaceholder(this); |
||||
} |
||||
|
||||
public static implicit operator Statement(Pattern p) |
||||
{ |
||||
return p != null ? new StatementPlaceholder(p) : null; |
||||
} |
||||
|
||||
public Statement ToStatement() |
||||
{ |
||||
return new StatementPlaceholder(this); |
||||
} |
||||
|
||||
public static implicit operator BlockStatement(Pattern p) |
||||
{ |
||||
return p != null ? new BlockStatementPlaceholder(p) : null; |
||||
} |
||||
|
||||
public static implicit operator VariableInitializer(Pattern p) |
||||
{ |
||||
return p != null ? new VariablePlaceholder(p) : null; |
||||
} |
||||
|
||||
public static implicit operator AttributeSection(Pattern p) |
||||
{ |
||||
return p != null ? new AttributeSectionPlaceholder(p) : null; |
||||
} |
||||
|
||||
public static implicit operator SwitchSection(Pattern p) |
||||
{ |
||||
return p != null ? new SwitchSectionPlaceholder(p) : null; |
||||
} |
||||
|
||||
public static implicit operator CatchClause(Pattern p) |
||||
{ |
||||
return p != null ? new CatchClausePlaceholder(p) : null; |
||||
} |
||||
|
||||
// Make debugging easier by giving Patterns a ToString() implementation
|
||||
public override string ToString() |
||||
{ |
||||
StringWriter w = new StringWriter(); |
||||
AcceptVisitor(new OutputVisitor(w, new CSharpFormattingPolicy()), null); |
||||
return w.ToString(); |
||||
} |
||||
} |
||||
} |
||||
@ -1,242 +0,0 @@
@@ -1,242 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.PatternMatching |
||||
{ |
||||
// Placeholders do not store their child in the AST tree; but keep it as a separate child.
|
||||
// This allows reusing the child in multiple placeholders; thus enabling the sharing of AST subtrees.
|
||||
sealed class TypePlaceholder : AstType |
||||
{ |
||||
readonly AstNode child; |
||||
|
||||
public TypePlaceholder(AstNode child) |
||||
{ |
||||
this.child = child; |
||||
} |
||||
|
||||
public override NodeType NodeType { |
||||
get { return NodeType.Placeholder; } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
return child.DoMatch(other, match); |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
return child.DoMatchCollection(role, pos, match, backtrackingStack); |
||||
} |
||||
} |
||||
|
||||
sealed class ExpressionPlaceholder : Expression |
||||
{ |
||||
readonly AstNode child; |
||||
|
||||
public ExpressionPlaceholder(AstNode child) |
||||
{ |
||||
this.child = child; |
||||
} |
||||
|
||||
public override NodeType NodeType { |
||||
get { return NodeType.Placeholder; } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
return child.DoMatch(other, match); |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
return child.DoMatchCollection(role, pos, match, backtrackingStack); |
||||
} |
||||
} |
||||
|
||||
sealed class StatementPlaceholder : Statement |
||||
{ |
||||
readonly AstNode child; |
||||
|
||||
public StatementPlaceholder(AstNode child) |
||||
{ |
||||
this.child = child; |
||||
} |
||||
|
||||
public override NodeType NodeType { |
||||
get { return NodeType.Placeholder; } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
return child.DoMatch(other, match); |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
return child.DoMatchCollection(role, pos, match, backtrackingStack); |
||||
} |
||||
} |
||||
|
||||
sealed class BlockStatementPlaceholder : BlockStatement |
||||
{ |
||||
readonly AstNode child; |
||||
|
||||
public BlockStatementPlaceholder(AstNode child) |
||||
{ |
||||
this.child = child; |
||||
} |
||||
|
||||
public override NodeType NodeType { |
||||
get { return NodeType.Placeholder; } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
return child.DoMatch(other, match); |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
return child.DoMatchCollection(role, pos, match, backtrackingStack); |
||||
} |
||||
} |
||||
|
||||
sealed class VariablePlaceholder : VariableInitializer |
||||
{ |
||||
readonly AstNode child; |
||||
|
||||
public VariablePlaceholder(AstNode child) |
||||
{ |
||||
this.child = child; |
||||
} |
||||
|
||||
public override NodeType NodeType { |
||||
get { return NodeType.Placeholder; } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
return child.DoMatch(other, match); |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
return child.DoMatchCollection(role, pos, match, backtrackingStack); |
||||
} |
||||
} |
||||
|
||||
sealed class AttributeSectionPlaceholder : AttributeSection |
||||
{ |
||||
readonly AstNode child; |
||||
|
||||
public AttributeSectionPlaceholder(AstNode child) |
||||
{ |
||||
this.child = child; |
||||
} |
||||
|
||||
public override NodeType NodeType { |
||||
get { return NodeType.Placeholder; } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
return child.DoMatch(other, match); |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
return child.DoMatchCollection(role, pos, match, backtrackingStack); |
||||
} |
||||
} |
||||
|
||||
sealed class SwitchSectionPlaceholder : SwitchSection |
||||
{ |
||||
readonly AstNode child; |
||||
|
||||
public SwitchSectionPlaceholder(AstNode child) |
||||
{ |
||||
this.child = child; |
||||
} |
||||
|
||||
public override NodeType NodeType { |
||||
get { return NodeType.Placeholder; } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
return child.DoMatch(other, match); |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
return child.DoMatchCollection(role, pos, match, backtrackingStack); |
||||
} |
||||
} |
||||
|
||||
sealed class CatchClausePlaceholder : CatchClause |
||||
{ |
||||
readonly AstNode child; |
||||
|
||||
public CatchClausePlaceholder(AstNode child) |
||||
{ |
||||
this.child = child; |
||||
} |
||||
|
||||
public override NodeType NodeType { |
||||
get { return NodeType.Placeholder; } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, Match match) |
||||
{ |
||||
return child.DoMatch(other, match); |
||||
} |
||||
|
||||
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack) |
||||
{ |
||||
return child.DoMatchCollection(role, pos, match, backtrackingStack); |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue