diff --git a/Decompiler.csproj b/Decompiler.csproj
index b62aa1fa6..3c1ce0799 100644
--- a/Decompiler.csproj
+++ b/Decompiler.csproj
@@ -25,9 +25,6 @@
-
- lib\NRefactory\ICSharpCode.NRefactory.dll
-
@@ -76,5 +73,9 @@
{D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}
Mono.Cecil
+
+ {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}
+ NRefactory
+
\ No newline at end of file
diff --git a/Decompiler.sln b/Decompiler.sln
index d0132cdfb..5657d292b 100644
--- a/Decompiler.sln
+++ b/Decompiler.sln
@@ -1,10 +1,14 @@

-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
# SharpDevelop 3.0.0.2914
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decompiler", "Decompiler.csproj", "{EE3A3C1A-F9C3-4C75-853D-A9476E518C3A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "lib\cecil-0.6\src\Mono.Cecil\Mono.Cecil.csproj", "{D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "lib\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "lib\NRefactory\NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "lib\cecil-0.6\src\Mono.Cecil\Mono.Cecil.csproj", "{C58CA4B3-20ED-4D22-A55B-AD5DE9DEB125}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -20,5 +24,21 @@ Global
{D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}.Release|Any CPU.Build.0 = Release|Any CPU
{D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B22522AA-B5BF-4A58-AC6D-D4B45805521F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B22522AA-B5BF-4A58-AC6D-D4B45805521F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B22522AA-B5BF-4A58-AC6D-D4B45805521F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B22522AA-B5BF-4A58-AC6D-D4B45805521F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E6075AD9-053B-4B6B-ABAF-92DC5EDC877B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E6075AD9-053B-4B6B-ABAF-92DC5EDC877B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E6075AD9-053B-4B6B-ABAF-92DC5EDC877B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E6075AD9-053B-4B6B-ABAF-92DC5EDC877B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C58CA4B3-20ED-4D22-A55B-AD5DE9DEB125}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C58CA4B3-20ED-4D22-A55B-AD5DE9DEB125}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C58CA4B3-20ED-4D22-A55B-AD5DE9DEB125}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C58CA4B3-20ED-4D22-A55B-AD5DE9DEB125}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/lib/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs b/lib/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs
new file mode 100644
index 000000000..f9e02ccff
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs
@@ -0,0 +1,314 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace NRefactoryASTGenerator.Ast
+{
+ [CustomImplementation]
+ abstract class Expression : AbstractNode, INullable {}
+
+ [CustomImplementation]
+ class PrimitiveExpression : Expression {}
+
+ enum ParameterModifiers { In }
+
+ class ParameterDeclarationExpression : Expression {
+ List attributes;
+ [QuestionMarkDefault]
+ string parameterName;
+ TypeReference typeReference;
+ ParameterModifiers paramModifier;
+ Expression defaultValue;
+
+ public ParameterDeclarationExpression(TypeReference typeReference, string parameterName) {}
+ public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier) {}
+ public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier, Expression defaultValue) {}
+ }
+
+ class NamedArgumentExpression : Expression {
+ string name;
+ Expression expression;
+
+ public NamedArgumentExpression(string name, Expression expression) {}
+ }
+
+ [IncludeBoolProperty("IsAnonymousType", "return createType.IsNull || string.IsNullOrEmpty(createType.Type);")]
+ class ObjectCreateExpression : Expression {
+ TypeReference createType;
+ List parameters;
+ CollectionInitializerExpression objectInitializer;
+
+ public ObjectCreateExpression(TypeReference createType, List parameters) {}
+ }
+
+ [IncludeBoolProperty("IsImplicitlyTyped", "return createType.IsNull || string.IsNullOrEmpty(createType.Type);")]
+ class ArrayCreateExpression : Expression {
+ TypeReference createType;
+ List arguments;
+ CollectionInitializerExpression arrayInitializer;
+
+ public ArrayCreateExpression(TypeReference createType) {}
+ public ArrayCreateExpression(TypeReference createType, List arguments) {}
+ public ArrayCreateExpression(TypeReference createType, CollectionInitializerExpression arrayInitializer) {}
+ }
+
+ [ImplementNullable(NullableImplementation.Shadow)]
+ class CollectionInitializerExpression : Expression {
+ List createExpressions;
+
+ public CollectionInitializerExpression() {}
+ public CollectionInitializerExpression(List createExpressions) {}
+ }
+
+ enum AssignmentOperatorType {}
+
+ class AssignmentExpression : Expression {
+ Expression left;
+ AssignmentOperatorType op;
+ Expression right;
+
+ public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right) {}
+ }
+
+ class BaseReferenceExpression : Expression {}
+
+ enum BinaryOperatorType {}
+
+ class BinaryOperatorExpression : Expression
+ {
+ Expression left;
+ BinaryOperatorType op;
+ Expression right;
+
+ public BinaryOperatorExpression(Expression left, BinaryOperatorType op, Expression right) {}
+ }
+
+ enum CastType {}
+
+ class CastExpression : Expression
+ {
+ TypeReference castTo;
+ Expression expression;
+ CastType castType;
+
+ public CastExpression(TypeReference castTo) {}
+ public CastExpression(TypeReference castTo, Expression expression, CastType castType) {}
+ }
+
+ [IncludeMember("[Obsolete] public string FieldName { get { return MemberName; } set { MemberName = value; } }")]
+ class MemberReferenceExpression : Expression
+ {
+ Expression targetObject;
+ string memberName;
+ List typeArguments;
+
+ public MemberReferenceExpression(Expression targetObject, string memberName) {}
+ }
+
+ class PointerReferenceExpression : Expression {
+ Expression targetObject;
+ string identifier;
+ List typeArguments;
+
+ public PointerReferenceExpression(Expression targetObject, string identifier) {}
+ }
+
+ class IdentifierExpression : Expression {
+ string identifier;
+ List typeArguments;
+
+ public IdentifierExpression(string identifier) {}
+ }
+
+ class InvocationExpression : Expression {
+ Expression targetObject;
+ List arguments;
+
+ public InvocationExpression(Expression targetObject) {}
+ public InvocationExpression(Expression targetObject, List arguments) {}
+ }
+
+ class ParenthesizedExpression : Expression {
+ Expression expression;
+
+ public ParenthesizedExpression(Expression expression) {}
+ }
+
+ class ThisReferenceExpression : Expression {}
+
+ class TypeOfExpression : Expression {
+ TypeReference typeReference;
+
+ public TypeOfExpression(TypeReference typeReference) {}
+ }
+
+ [IncludeMember("public TypeReferenceExpression(string typeName) : this(new TypeReference(typeName)) {}")]
+ class TypeReferenceExpression : Expression {
+ TypeReference typeReference;
+
+ public TypeReferenceExpression(TypeReference typeReference) {}
+ }
+
+ enum UnaryOperatorType {}
+
+ class UnaryOperatorExpression : Expression {
+ UnaryOperatorType op;
+ Expression expression;
+
+ public UnaryOperatorExpression(UnaryOperatorType op) {}
+ public UnaryOperatorExpression(Expression expression, UnaryOperatorType op) {}
+ }
+
+ class AnonymousMethodExpression : Expression {
+ List parameters;
+ BlockStatement body;
+ bool hasParameterList;
+ }
+
+ class LambdaExpression : Expression {
+ List parameters;
+ BlockStatement statementBody;
+ Expression expressionBody;
+ }
+
+ class CheckedExpression : Expression {
+ Expression expression;
+
+ public CheckedExpression(Expression expression) {}
+ }
+
+ class ConditionalExpression : Expression {
+ Expression condition;
+ Expression trueExpression;
+ Expression falseExpression;
+
+ public ConditionalExpression(Expression condition, Expression trueExpression, Expression falseExpression) {}
+ }
+
+ class DefaultValueExpression : Expression {
+ TypeReference typeReference;
+
+ public DefaultValueExpression(TypeReference typeReference) {}
+ }
+
+ enum FieldDirection {}
+
+ class DirectionExpression : Expression {
+ FieldDirection fieldDirection;
+ Expression expression;
+
+ public DirectionExpression(FieldDirection fieldDirection, Expression expression) {}
+ }
+
+ class IndexerExpression : Expression {
+ Expression targetObject;
+ List indexes;
+
+ public IndexerExpression(Expression targetObject, List indexes) {}
+ }
+
+ class SizeOfExpression : Expression {
+ TypeReference typeReference;
+
+ public SizeOfExpression(TypeReference typeReference) {}
+ }
+
+ class StackAllocExpression : Expression {
+ TypeReference typeReference;
+ Expression expression;
+
+ public StackAllocExpression(TypeReference typeReference, Expression expression) {}
+ }
+
+ class UncheckedExpression : Expression {
+ Expression expression;
+
+ public UncheckedExpression(Expression expression) {}
+ }
+
+ class AddressOfExpression : Expression {
+ Expression expression;
+
+ public AddressOfExpression(Expression expression) {}
+ }
+
+ class ClassReferenceExpression : Expression {}
+
+ class TypeOfIsExpression : Expression {
+ Expression expression;
+ TypeReference typeReference;
+
+ public TypeOfIsExpression(Expression expression, TypeReference typeReference) {}
+ }
+
+ [ImplementNullable(NullableImplementation.Shadow)]
+ class QueryExpression : Expression {
+ QueryExpressionFromClause fromClause;
+ List fromLetWhereClauses;
+ List orderings;
+ QueryExpressionClause selectOrGroupClause;
+ QueryExpressionIntoClause intoClause;
+ }
+
+ [ImplementNullable]
+ abstract class QueryExpressionClause : AbstractNode, INullable { }
+
+ class QueryExpressionWhereClause : QueryExpressionClause {
+ Expression condition;
+ }
+
+ class QueryExpressionLetClause : QueryExpressionClause {
+ [QuestionMarkDefault]
+ string identifier;
+ Expression expression;
+ }
+
+ abstract class QueryExpressionFromOrJoinClause : QueryExpressionClause {
+ TypeReference type;
+ [QuestionMarkDefault]
+ string identifier;
+ Expression inExpression;
+ }
+
+ [ImplementNullable(NullableImplementation.Shadow)]
+ class QueryExpressionFromClause : QueryExpressionFromOrJoinClause { }
+
+ class QueryExpressionJoinClause : QueryExpressionFromOrJoinClause {
+ Expression onExpression;
+ Expression equalsExpression;
+
+ string intoIdentifier;
+ }
+
+ class QueryExpressionOrdering : AbstractNode {
+ Expression criteria;
+ QueryExpressionOrderingDirection direction;
+ }
+
+ enum QueryExpressionOrderingDirection {
+ None, Ascending, Descending
+ }
+
+ class QueryExpressionSelectClause : QueryExpressionClause {
+ Expression projection;
+ }
+
+ class QueryExpressionGroupClause : QueryExpressionClause {
+ Expression projection;
+ Expression groupBy;
+ }
+
+ [ImplementNullable(NullableImplementation.Shadow)]
+ class QueryExpressionIntoClause : QueryExpressionClause {
+ [QuestionMarkDefault]
+ string intoIdentifier;
+
+ QueryExpression continuedQuery;
+ }
+}
diff --git a/lib/NRefactory/NRefactoryASTGenerator/AST/GlobalLevel.cs b/lib/NRefactory/NRefactoryASTGenerator/AST/GlobalLevel.cs
new file mode 100644
index 000000000..bdcf2566e
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/AST/GlobalLevel.cs
@@ -0,0 +1,95 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace NRefactoryASTGenerator.Ast
+{
+ [CustomImplementation, HasChildren]
+ class CompilationUnit : AbstractNode {}
+
+ [HasChildren]
+ class NamespaceDeclaration : AbstractNode
+ {
+ string name;
+
+ public NamespaceDeclaration(string name) {}
+ }
+
+ class TemplateDefinition : AttributedNode
+ {
+ [QuestionMarkDefault]
+ string name;
+ List bases;
+
+ public TemplateDefinition(string name, List attributes) : base(attributes) {}
+ }
+
+ class DelegateDeclaration : AttributedNode
+ {
+ [QuestionMarkDefault]
+ string name;
+ TypeReference returnType;
+ List parameters;
+ List templates;
+
+ public DelegateDeclaration(Modifiers modifier, List attributes) : base(modifier, attributes) {}
+ }
+
+ enum ClassType { Class }
+
+ [HasChildren]
+ class TypeDeclaration : AttributedNode
+ {
+ // Children of Struct: FieldDeclaration, MethodDeclaration, EventDeclaration, ConstructorDeclaration,
+ // OperatorDeclaration, TypeDeclaration, IndexerDeclaration, PropertyDeclaration, in VB: DeclareDeclaration
+ // Childrean of class: children of struct, DestructorDeclaration
+ // Children of Interface: MethodDeclaration, PropertyDeclaration, IndexerDeclaration, EventDeclaration, in VB: TypeDeclaration(Enum) too
+ // Children of Enum: FieldDeclaration
+ string name;
+ ClassType type;
+ List baseTypes;
+ List templates;
+ Location bodyStartLocation;
+
+ public TypeDeclaration(Modifiers modifier, List attributes) : base(modifier, attributes) {}
+ }
+
+ [IncludeBoolProperty("IsAlias", "return !alias.IsNull;")]
+ class Using : AbstractNode
+ {
+ [QuestionMarkDefault]
+ string name;
+ TypeReference alias;
+
+ public Using(string name) {}
+ public Using(string name, TypeReference alias) {}
+ }
+
+ [IncludeMember("public UsingDeclaration(string @namespace) : this(@namespace, null) {}")]
+ [IncludeMember("public UsingDeclaration(string @namespace, TypeReference alias) {" +
+ " usings = new List(1);" +
+ " usings.Add(new Using(@namespace, alias)); " +
+ "}")]
+ class UsingDeclaration : AbstractNode
+ {
+ List usings;
+
+ public UsingDeclaration(List usings) {}
+ }
+
+ enum OptionType { None }
+
+ class OptionDeclaration : AbstractNode
+ {
+ OptionType optionType;
+ bool optionValue;
+
+ public OptionDeclaration(OptionType optionType, bool optionValue) {}
+ }
+}
diff --git a/lib/NRefactory/NRefactoryASTGenerator/AST/Node.cs b/lib/NRefactory/NRefactoryASTGenerator/AST/Node.cs
new file mode 100644
index 000000000..8c6ea7ff2
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/AST/Node.cs
@@ -0,0 +1,72 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace NRefactoryASTGenerator.Ast
+{
+ interface INode {}
+ interface INullable {}
+ struct Location {}
+
+ enum Modifiers { None }
+
+ [CustomImplementation]
+ abstract class AbstractNode : INode {}
+
+ abstract class AttributedNode : AbstractNode
+ {
+ List attributes;
+ Modifiers modifier;
+
+ public AttributedNode() {}
+ public AttributedNode(List attributes) {}
+ public AttributedNode(Modifiers modifier, List attributes) {}
+ }
+
+ abstract class ParametrizedNode : AttributedNode
+ {
+ string name;
+ List parameters;
+
+ public ParametrizedNode() {}
+
+ public ParametrizedNode(Modifiers modifier, List attributes,
+ string name, List parameters)
+ : base(modifier, attributes)
+ {}
+ }
+
+ [CustomImplementation]
+ class TypeReference : AbstractNode
+ {
+ List genericTypes;
+ }
+
+ [CustomImplementation]
+ class InnerClassTypeReference : TypeReference
+ {
+ TypeReference baseType;
+ }
+
+ class AttributeSection : AbstractNode, INullable
+ {
+ string attributeTarget;
+ List attributes;
+ }
+
+ class Attribute : AbstractNode
+ {
+ string name;
+ List positionalArguments;
+ List namedArguments;
+
+ public Attribute() {}
+ public Attribute(string name, List positionalArguments, List namedArguments) {}
+ }
+}
diff --git a/lib/NRefactory/NRefactoryASTGenerator/AST/Statements.cs b/lib/NRefactory/NRefactoryASTGenerator/AST/Statements.cs
new file mode 100644
index 000000000..b9ecef4e7
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/AST/Statements.cs
@@ -0,0 +1,314 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace NRefactoryASTGenerator.Ast
+{
+ [CustomImplementation]
+ abstract class Statement : AbstractNode, INullable {}
+
+ [CustomImplementation]
+ abstract class StatementWithEmbeddedStatement : Statement {
+ Statement embeddedStatement;
+ }
+
+ [CustomImplementation, HasChildren]
+ class BlockStatement : Statement {}
+
+ class BreakStatement : Statement {}
+
+ enum ContinueType {}
+
+ class ContinueStatement : Statement {
+ ContinueType continueType;
+
+ public ContinueStatement() {}
+ public ContinueStatement(ContinueType continueType) {}
+ }
+
+ enum ConditionType {}
+ enum ConditionPosition {}
+
+ class DoLoopStatement : StatementWithEmbeddedStatement {
+ Expression condition;
+ ConditionType conditionType;
+ ConditionPosition conditionPosition;
+
+ public DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition) {}
+ }
+
+ class ForeachStatement : StatementWithEmbeddedStatement {
+ TypeReference typeReference;
+ string variableName;
+ Expression expression;
+ Expression nextExpression;
+
+ public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement) {}
+ public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement, Expression nextExpression) {}
+ }
+
+ class ForStatement : StatementWithEmbeddedStatement {
+ List initializers;
+ Expression condition;
+ List iterator;
+
+ public ForStatement(List initializers, Expression condition, List iterator, Statement embeddedStatement) {}
+ }
+
+ class GotoStatement : Statement {
+ string label;
+
+ public GotoStatement(string label) {}
+ }
+
+ [IncludeMember(@"
+ public IfElseStatement(Expression condition, Statement trueStatement)
+ : this(condition) {
+ this.trueStatement.Add(Statement.CheckNull(trueStatement));
+ }")]
+ [IncludeMember(@"
+ public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement)
+ : this(condition) {
+ this.trueStatement.Add(Statement.CheckNull(trueStatement));
+ this.falseStatement.Add(Statement.CheckNull(falseStatement));
+ }")]
+ [IncludeBoolProperty("HasElseStatements", "return falseStatement.Count > 0;")]
+ [IncludeBoolProperty("HasElseIfSections", "return elseIfSections.Count > 0;")]
+ class IfElseStatement : Statement {
+ Expression condition;
+ List trueStatement; // List for stmt : stmt : stmt ... in VB.NET
+ List falseStatement;
+ List elseIfSections;
+
+ public IfElseStatement(Expression condition) {}
+ }
+
+ class ElseIfSection : StatementWithEmbeddedStatement {
+ Expression condition;
+
+ public ElseIfSection(Expression condition, Statement embeddedStatement) {}
+ }
+
+ class LabelStatement : Statement {
+ string label;
+
+ public LabelStatement(string label) {}
+ }
+
+ [CustomImplementation]
+ class LocalVariableDeclaration : Statement {
+ TypeReference typeReference;
+ Modifiers modifier;
+ List variables;
+ }
+
+ class LockStatement : StatementWithEmbeddedStatement
+ {
+ Expression lockExpression;
+
+ public LockStatement(Expression lockExpression, Statement embeddedStatement) {}
+ }
+
+ class ReturnStatement : Statement
+ {
+ Expression expression;
+
+ public ReturnStatement(Expression expression) { }
+ }
+
+ class ExpressionStatement : Statement {
+ Expression expression;
+
+ public ExpressionStatement(Expression expression) {}
+ }
+
+ class SwitchStatement : Statement {
+ Expression switchExpression;
+ List switchSections;
+
+ public SwitchStatement(Expression switchExpression, List switchSections) {}
+ }
+
+ class SwitchSection : BlockStatement {
+ List switchLabels;
+
+ public SwitchSection() { }
+ public SwitchSection(List switchLabels) { }
+ }
+
+ [IncludeBoolProperty("IsDefault", "return label.IsNull;")]
+ class CaseLabel : AbstractNode {
+ Expression label;
+ BinaryOperatorType binaryOperatorType;
+ Expression toExpression;
+
+ public CaseLabel() {}
+ public CaseLabel(Expression label) {}
+ public CaseLabel(Expression label, Expression toExpression) {}
+ public CaseLabel(BinaryOperatorType binaryOperatorType, Expression label) {}
+ }
+
+ class ThrowStatement : Statement {
+ Expression expression;
+
+ public ThrowStatement(Expression expression) {}
+ }
+
+ class TryCatchStatement : Statement {
+ Statement statementBlock;
+ List catchClauses;
+ Statement finallyBlock;
+
+ public TryCatchStatement(Statement statementBlock, List catchClauses, Statement finallyBlock) {}
+ }
+
+ class CatchClause : AbstractNode {
+ TypeReference typeReference;
+ string variableName;
+ Statement statementBlock;
+ Expression condition;
+
+ public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock) {}
+ public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock, Expression condition) {}
+ public CatchClause(Statement statementBlock) {}
+ }
+
+ class CheckedStatement : Statement {
+ Statement block;
+
+ public CheckedStatement(Statement block) {}
+ }
+
+ class EmptyStatement : Statement {}
+
+ class FixedStatement : StatementWithEmbeddedStatement {
+ TypeReference typeReference;
+ List pointerDeclarators;
+
+ public FixedStatement(TypeReference typeReference, List pointerDeclarators, Statement embeddedStatement) {}
+ }
+
+ [IncludeBoolProperty("IsDefaultCase", "return expression.IsNull;")]
+ class GotoCaseStatement : Statement {
+ Expression expression;
+
+ public GotoCaseStatement(Expression expression) {}
+ }
+
+ class UncheckedStatement : Statement {
+ Statement block;
+
+ public UncheckedStatement(Statement block) {}
+ }
+
+ class UnsafeStatement : Statement {
+ Statement block;
+
+ public UnsafeStatement(Statement block) {}
+ }
+
+ class UsingStatement : StatementWithEmbeddedStatement {
+ Statement resourceAcquisition;
+
+ public UsingStatement(Statement resourceAcquisition, Statement embeddedStatement) {}
+ }
+
+ [IncludeBoolProperty("IsYieldReturn", "return statement is ReturnStatement;")]
+ [IncludeBoolProperty("IsYieldBreak", "return statement is BreakStatement;")]
+ class YieldStatement : Statement {
+ Statement statement;
+
+ public YieldStatement(Statement statement) {}
+ }
+
+ class AddHandlerStatement : Statement {
+ Expression eventExpression;
+ Expression handlerExpression;
+
+ public AddHandlerStatement(Expression eventExpression, Expression handlerExpression) {}
+ }
+
+ class EndStatement : Statement {}
+
+ class EraseStatement : Statement {
+ List expressions;
+
+ public EraseStatement() {}
+ public EraseStatement(List expressions) {}
+ }
+
+ class ErrorStatement : Statement {
+ Expression expression;
+
+ public ErrorStatement(Expression expression) {}
+ }
+
+ enum ExitType {}
+
+ class ExitStatement : Statement {
+ ExitType exitType;
+
+ public ExitStatement(ExitType exitType) {}
+ }
+
+ class ForNextStatement : StatementWithEmbeddedStatement {
+ Expression start;
+ Expression end;
+ Expression step;
+
+ List nextExpressions;
+ TypeReference typeReference;
+ string variableName;
+
+ public ForNextStatement(TypeReference typeReference, string variableName, Expression start, Expression end, Expression step, Statement embeddedStatement, List nextExpressions) {}
+ }
+
+ class OnErrorStatement : StatementWithEmbeddedStatement {
+ public OnErrorStatement(Statement embeddedStatement) {}
+ }
+
+ class RaiseEventStatement : Statement {
+ string eventName;
+ List arguments;
+
+ public RaiseEventStatement(string eventName, List arguments) {}
+ }
+
+ class ReDimStatement : Statement {
+ List reDimClauses;
+ bool isPreserve;
+
+ public ReDimStatement(bool isPreserve) {}
+ }
+
+ class RemoveHandlerStatement : Statement {
+ Expression eventExpression;
+ Expression handlerExpression;
+
+ public RemoveHandlerStatement(Expression eventExpression, Expression handlerExpression) {}
+ }
+
+ class ResumeStatement : Statement {
+ string labelName;
+ bool isResumeNext;
+
+ public ResumeStatement(bool isResumeNext) {}
+
+ public ResumeStatement(string labelName) {}
+ }
+
+ class StopStatement : Statement {}
+
+ class WithStatement : Statement {
+ Expression expression;
+ BlockStatement body;
+
+ public WithStatement(Expression expression) {}
+ }
+}
diff --git a/lib/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs b/lib/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs
new file mode 100644
index 000000000..767666b8a
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs
@@ -0,0 +1,261 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace NRefactoryASTGenerator.Ast
+{
+ class VariableDeclaration : AbstractNode
+ {
+ string name;
+ Expression initializer;
+ TypeReference typeReference;
+ Expression fixedArrayInitialization;
+
+ public VariableDeclaration(string name) {}
+ public VariableDeclaration(string name, Expression initializer) {}
+ public VariableDeclaration(string name, Expression initializer, TypeReference typeReference) {}
+ }
+
+ class ConstructorDeclaration : ParametrizedNode
+ {
+ ConstructorInitializer constructorInitializer;
+ BlockStatement body;
+
+ public ConstructorDeclaration(string name, Modifiers modifier,
+ List parameters,
+ List attributes)
+ : base(modifier, attributes, name, parameters)
+ {}
+
+ public ConstructorDeclaration(string name, Modifiers modifier,
+ List parameters,
+ ConstructorInitializer constructorInitializer,
+ List attributes)
+ : base(modifier, attributes, name, parameters)
+ {}
+ }
+
+ enum ConstructorInitializerType { None }
+
+ [ImplementNullable]
+ class ConstructorInitializer : AbstractNode, INullable
+ {
+ ConstructorInitializerType constructorInitializerType;
+ List arguments;
+ }
+
+ [ImplementNullable(NullableImplementation.Abstract)]
+ abstract class EventAddRemoveRegion : AttributedNode
+ {
+ BlockStatement block;
+ List parameters;
+
+ public EventAddRemoveRegion(List attributes) : base(attributes) {}
+ }
+
+ [ImplementNullable(NullableImplementation.CompleteAbstract)]
+ class EventAddRegion : EventAddRemoveRegion
+ {
+ public EventAddRegion(List attributes) : base(attributes) {}
+ }
+
+ [ImplementNullable(NullableImplementation.CompleteAbstract)]
+ class EventRemoveRegion : EventAddRemoveRegion
+ {
+ public EventRemoveRegion(List attributes) : base(attributes) {}
+ }
+
+ [ImplementNullable(NullableImplementation.CompleteAbstract)]
+ class EventRaiseRegion : EventAddRemoveRegion
+ {
+ public EventRaiseRegion(List attributes) : base(attributes) {}
+ }
+
+ class InterfaceImplementation : AbstractNode
+ {
+ TypeReference interfaceType;
+ [QuestionMarkDefault]
+ string memberName;
+
+ public InterfaceImplementation(TypeReference interfaceType, string memberName) {}
+ }
+
+ [IncludeBoolProperty("HasAddRegion", "return !addRegion.IsNull;")]
+ [IncludeBoolProperty("HasRemoveRegion", "return !removeRegion.IsNull;")]
+ [IncludeBoolProperty("HasRaiseRegion", "return !raiseRegion.IsNull;")]
+ class EventDeclaration : MemberNode
+ {
+ EventAddRegion addRegion;
+ EventRemoveRegion removeRegion;
+ EventRaiseRegion raiseRegion;
+ Location bodyStart;
+ Location bodyEnd;
+ Expression initializer;
+ }
+
+ [IncludeMember(@"
+ public TypeReference GetTypeForField(int fieldIndex)
+ {
+ if (!typeReference.IsNull) {
+ return typeReference;
+ }
+ return ((VariableDeclaration)Fields[fieldIndex]).TypeReference;
+ }")]
+ [IncludeMember(@"
+ public VariableDeclaration GetVariableDeclaration(string variableName)
+ {
+ foreach (VariableDeclaration variableDeclaration in Fields) {
+ if (variableDeclaration.Name == variableName) {
+ return variableDeclaration;
+ }
+ }
+ return null;
+ }")]
+ class FieldDeclaration : AttributedNode
+ {
+ TypeReference typeReference;
+ List fields;
+
+ // for enum members
+ public FieldDeclaration(List attributes) : base(attributes) {}
+
+ // for all other cases
+ public FieldDeclaration(List attributes, TypeReference typeReference, Modifiers modifier)
+ : base(modifier, attributes)
+ {}
+ }
+
+ abstract class MemberNode : ParametrizedNode
+ {
+ List interfaceImplementations;
+ TypeReference typeReference;
+
+ public MemberNode() {}
+
+ public MemberNode(Modifiers modifier, List attributes,
+ string name, List parameters)
+ : base(modifier, attributes, name, parameters)
+ {}
+ }
+
+ class MethodDeclaration : MemberNode
+ {
+ BlockStatement body;
+ List handlesClause;
+ List templates;
+ bool isExtensionMethod;
+ }
+
+ enum ConversionType { None }
+ enum OverloadableOperatorType { None }
+
+ [IncludeBoolProperty("IsConversionOperator", "return conversionType != ConversionType.None;")]
+ class OperatorDeclaration : MethodDeclaration
+ {
+ ConversionType conversionType;
+ List returnTypeAttributes;
+ OverloadableOperatorType overloadableOperator;
+ }
+
+ [IncludeBoolProperty("HasGetRegion", "return !getRegion.IsNull;")]
+ [IncludeBoolProperty("HasSetRegion", "return !setRegion.IsNull;")]
+ [IncludeBoolProperty("IsReadOnly", "return HasGetRegion && !HasSetRegion;")]
+ [IncludeBoolProperty("IsWriteOnly", "return !HasGetRegion && HasSetRegion;")]
+ [IncludeMember(@"
+ internal PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List attributes) : this(modifier, attributes, name, null)
+ {
+ this.TypeReference = typeReference;
+ if ((modifier & Modifiers.ReadOnly) != Modifiers.ReadOnly) {
+ this.SetRegion = new PropertySetRegion(null, null);
+ }
+ if ((modifier & Modifiers.WriteOnly) != Modifiers.WriteOnly) {
+ this.GetRegion = new PropertyGetRegion(null, null);
+ }
+ }")]
+ class PropertyDeclaration : MemberNode
+ {
+ Location bodyStart;
+ Location bodyEnd;
+ PropertyGetRegion getRegion;
+ PropertySetRegion setRegion;
+
+ public PropertyDeclaration(Modifiers modifier, List attributes,
+ string name, List parameters)
+ : base(modifier, attributes, name, parameters)
+ {}
+ }
+
+ [ImplementNullable(NullableImplementation.Abstract)]
+ abstract class PropertyGetSetRegion : AttributedNode
+ {
+ // can be null if only the definition is there (interface declaration)
+ BlockStatement block;
+
+ public PropertyGetSetRegion(BlockStatement block, List attributes) : base(attributes) {}
+ }
+
+ [ImplementNullable(NullableImplementation.CompleteAbstract)]
+ class PropertyGetRegion : PropertyGetSetRegion
+ {
+ public PropertyGetRegion(BlockStatement block, List attributes) : base(block, attributes) {}
+ }
+
+ [ImplementNullable(NullableImplementation.CompleteAbstract)]
+ class PropertySetRegion : PropertyGetSetRegion
+ {
+ List parameters;
+
+ public PropertySetRegion(BlockStatement block, List attributes) : base(block, attributes) {}
+ }
+
+ class DestructorDeclaration : AttributedNode
+ {
+ string name;
+ BlockStatement body;
+
+ public DestructorDeclaration(string name, Modifiers modifier, List attributes) : base(modifier, attributes) {}
+ }
+
+ [IncludeBoolProperty("HasGetRegion", "return !getRegion.IsNull;")]
+ [IncludeBoolProperty("HasSetRegion", "return !setRegion.IsNull;")]
+ [IncludeBoolProperty("IsReadOnly", "return HasGetRegion && !HasSetRegion;")]
+ [IncludeBoolProperty("IsWriteOnly", "return !HasGetRegion && HasSetRegion;")]
+ class IndexerDeclaration : AttributedNode
+ {
+ List parameters;
+ List interfaceImplementations;
+ TypeReference typeReference;
+ Location bodyStart;
+ Location bodyEnd;
+ PropertyGetRegion getRegion;
+ PropertySetRegion setRegion;
+
+ public IndexerDeclaration(Modifiers modifier, List parameters, List attributes)
+ : base(modifier, attributes)
+ {}
+
+ public IndexerDeclaration(TypeReference typeReference, List parameters, Modifiers modifier, List attributes)
+ : base(modifier, attributes)
+ {}
+ }
+
+ enum CharsetModifier { None }
+
+ class DeclareDeclaration : ParametrizedNode
+ {
+ string alias;
+ string library;
+ CharsetModifier charset;
+ TypeReference typeReference;
+
+ public DeclareDeclaration(string name, Modifiers modifier, TypeReference typeReference, List parameters, List attributes, string library, string alias, CharsetModifier charset)
+ : base(modifier, attributes, name, parameters)
+ {}
+ }
+}
diff --git a/lib/NRefactory/NRefactoryASTGenerator/AssemblyInfo.cs b/lib/NRefactory/NRefactoryASTGenerator/AssemblyInfo.cs
new file mode 100644
index 000000000..d36cc378f
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("NRefactory AST Generator")]
+[assembly: AssemblyDescription("Parser and refactoring library for C# and VB.NET")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("ic#code")]
+[assembly: AssemblyProduct("SharpDevelop")]
+[assembly: AssemblyCopyright("2006 AlphaSierraPapa")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("2.0.0.1")]
diff --git a/lib/NRefactory/NRefactoryASTGenerator/Attributes.cs b/lib/NRefactory/NRefactoryASTGenerator/Attributes.cs
new file mode 100644
index 000000000..2647e2742
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/Attributes.cs
@@ -0,0 +1,180 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.CodeDom;
+using System.Reflection;
+using ICSharpCode.EasyCodeDom;
+
+namespace NRefactoryASTGenerator
+{
+ public enum NullableImplementation
+ {
+ ///
+ /// Implement INullable with a virtual bool IsNull, create Null class and static instance
+ /// of it.
+ ///
+ Default,
+ ///
+ /// Create Null class and a static instance using the "new" modifier.
+ ///
+ Shadow,
+ ///
+ /// Implement INullable with a virtual bool IsNull.
+ ///
+ Abstract,
+ ///
+ /// Complete an abstract nullable implementation by creating the Null class
+ /// and the static instance.
+ ///
+ CompleteAbstract
+ }
+
+ public abstract class TypeImplementationModifierAttribute : Attribute
+ {
+ public abstract void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type);
+ }
+
+ [AttributeUsage(AttributeTargets.Class)]
+ public class CustomImplementationAttribute : Attribute
+ {
+ }
+
+ [AttributeUsage(AttributeTargets.Class)]
+ public class HasChildrenAttribute : Attribute
+ {
+ }
+
+ [AttributeUsage(AttributeTargets.Field)]
+ public class QuestionMarkDefaultAttribute : Attribute
+ {
+ }
+
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
+ public class IncludeMemberAttribute : TypeImplementationModifierAttribute
+ {
+ string code;
+
+ public IncludeMemberAttribute(string code)
+ {
+ this.code = code;
+ }
+
+ public override void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type)
+ {
+ ctd.Members.Add(new CodeSnippetTypeMember(code));
+ }
+ }
+
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
+ public class IncludeBoolPropertyAttribute : TypeImplementationModifierAttribute
+ {
+ string name;
+ string code;
+
+ public IncludeBoolPropertyAttribute(string name, string code)
+ {
+ this.name = name;
+ this.code = code;
+ }
+
+ public override void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type)
+ {
+ CodeMemberProperty prop = new CodeMemberProperty();
+ prop.Name = name;
+ prop.Type = new CodeTypeReference(typeof(bool));
+ prop.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+ prop.GetStatements.Add(new CodeSnippetStatement("\t\t\t\t" + code));
+ ctd.Members.Add(prop);
+ }
+ }
+
+ [AttributeUsage(AttributeTargets.Class)]
+ public class ImplementNullableAttribute : TypeImplementationModifierAttribute
+ {
+ NullableImplementation implementation;
+
+ public ImplementNullableAttribute()
+ {
+ this.implementation = NullableImplementation.Default;
+ }
+
+ public ImplementNullableAttribute(NullableImplementation implementation)
+ {
+ this.implementation = implementation;
+ }
+
+ public override void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type)
+ {
+ if (implementation == NullableImplementation.Default || implementation == NullableImplementation.Abstract) {
+ ctd.BaseTypes.Add(new CodeTypeReference("INullable"));
+ CodeMemberProperty prop = new CodeMemberProperty();
+ prop.Name = "IsNull";
+ prop.Type = new CodeTypeReference(typeof(bool));
+ prop.Attributes = MemberAttributes.Public;
+ prop.GetStatements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(false)));
+ ctd.Members.Add(prop);
+ }
+ if (implementation != NullableImplementation.Abstract) {
+ EasyTypeDeclaration newType = new EasyTypeDeclaration("Null" + ctd.Name);
+ newType.TypeAttributes = TypeAttributes.Class | TypeAttributes.NotPublic | TypeAttributes.Sealed;
+ newType.BaseTypes.Add(new CodeTypeReference(ctd.Name));
+ cns.Types.Add(newType);
+
+ System.Reflection.ConstructorInfo baseCtor = MainClass.GetBaseCtor(type);
+ if (baseCtor != null) {
+ CodeConstructor ctor = new CodeConstructor();
+ ctor.Attributes = MemberAttributes.Private;
+ foreach (object o in baseCtor.GetParameters()) {
+ ctor.BaseConstructorArgs.Add(new CodePrimitiveExpression(null));
+ }
+ newType.Members.Add(ctor);
+ }
+
+ CodeMemberField field = new CodeMemberField(newType.Name, "Instance");
+ field.Attributes = MemberAttributes.Static | MemberAttributes.Assembly;
+ field.InitExpression = new CodeObjectCreateExpression(new CodeTypeReference(newType.Name));
+ newType.Members.Add(field);
+
+ CodeMemberProperty prop = new CodeMemberProperty();
+ prop.Name = "IsNull";
+ prop.Type = new CodeTypeReference(typeof(bool));
+ prop.Attributes = MemberAttributes.Public | MemberAttributes.Override;
+ prop.GetStatements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(true)));
+ newType.Members.Add(prop);
+
+ CodeMemberMethod method = new CodeMemberMethod();
+ method.Name = "AcceptVisitor";
+ method.Attributes = MemberAttributes.Public | MemberAttributes.Override;
+ method.Parameters.Add(new CodeParameterDeclarationExpression("IAstVisitor", "visitor"));
+ method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "data"));
+ method.ReturnType = new CodeTypeReference(typeof(object));
+ method.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null)));
+ newType.Members.Add(method);
+
+ method = new CodeMemberMethod();
+ method.Name = "ToString";
+ method.Attributes = MemberAttributes.Public | MemberAttributes.Override;
+ method.ReturnType = new CodeTypeReference(typeof(string));
+ method.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression("[" + newType.Name + "]")));
+ newType.Members.Add(method);
+
+ prop = new CodeMemberProperty();
+ prop.Name = "Null";
+ prop.Type = new CodeTypeReference(ctd.Name);
+ prop.Attributes = MemberAttributes.Public | MemberAttributes.Static;
+ if (implementation == NullableImplementation.Shadow) {
+ prop.Attributes |= MemberAttributes.New;
+ }
+ CodeExpression ex = new CodeTypeReferenceExpression(newType.Name);
+ ex = new CodePropertyReferenceExpression(ex, "Instance");
+ prop.GetStatements.Add(new CodeMethodReturnStatement(ex));
+ ctd.Members.Add(prop);
+ }
+ }
+ }
+}
diff --git a/lib/NRefactory/NRefactoryASTGenerator/EasyCodeDom.cs b/lib/NRefactory/NRefactoryASTGenerator/EasyCodeDom.cs
new file mode 100644
index 000000000..54fb44cc1
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/EasyCodeDom.cs
@@ -0,0 +1,439 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.CodeDom;
+
+namespace ICSharpCode.EasyCodeDom
+{
+ public static class Easy
+ {
+ public static CodeTypeReference TypeRef(Type type)
+ {
+ return new CodeTypeReference(type, CodeTypeReferenceOptions.GlobalReference);
+ }
+ public static CodeTypeReference TypeRef(CodeTypeDeclaration type)
+ {
+ return new CodeTypeReference(type.Name);
+ }
+ public static CodeTypeReference TypeRef(string typeName, params string[] typeArguments)
+ {
+ CodeTypeReference tr = new CodeTypeReference(typeName);
+ foreach (string ta in typeArguments) {
+ tr.TypeArguments.Add(ta);
+ }
+ return tr;
+ }
+
+ ///
+ /// Gets the EasyExpression for any primitive value that can be expressed as literal.
+ /// Also works for enumeration values.
+ ///
+ public static EasyExpression Prim(object literalValue)
+ {
+ if (literalValue is Enum) {
+ return Type(literalValue.GetType()).Field(literalValue.ToString());
+ } else {
+ return new EasyExpression(new CodePrimitiveExpression(literalValue));
+ }
+ }
+
+ public static EasyExpression Type(Type type)
+ {
+ return Type(TypeRef(type));
+ }
+ public static EasyExpression Type(CodeTypeReference type)
+ {
+ return new EasyExpression(new CodeTypeReferenceExpression(type));
+ }
+ public static EasyExpression Type(string type)
+ {
+ return Type(new CodeTypeReference(type));
+ }
+
+ public static EasyExpression TypeOf(Type type)
+ {
+ return TypeOf(TypeRef(type));
+ }
+ public static EasyExpression TypeOf(CodeTypeReference type)
+ {
+ return new EasyExpression(new CodeTypeOfExpression(type));
+ }
+
+ public static EasyExpression New(Type type, params CodeExpression[] arguments)
+ {
+ return New(TypeRef(type), arguments);
+ }
+ public static EasyExpression New(CodeTypeReference type, params CodeExpression[] arguments)
+ {
+ return new EasyExpression(new CodeObjectCreateExpression(type, arguments));
+ }
+
+ public static EasyExpression Var(string name)
+ {
+ return new EasyExpression(new CodeVariableReferenceExpression(name));
+ }
+
+ public static EasyExpression Binary(CodeExpression left,
+ CodeBinaryOperatorType op,
+ CodeExpression right)
+ {
+ return new EasyExpression(new CodeBinaryOperatorExpression(left, op, right));
+ }
+
+ public static EasyExpression This {
+ get {
+ return new EasyExpression(new CodeThisReferenceExpression());
+ }
+ }
+
+ public static EasyExpression Base {
+ get {
+ return new EasyExpression(new CodeBaseReferenceExpression());
+ }
+ }
+
+ public static EasyExpression Value {
+ get {
+ return new EasyExpression(new CodePropertySetValueReferenceExpression());
+ }
+ }
+
+ public static EasyExpression Null {
+ get {
+ return new EasyExpression(new CodePrimitiveExpression(null));
+ }
+ }
+
+ public static void AddSummary(CodeTypeMember member, string summary)
+ {
+ member.Comments.Add(new CodeCommentStatement("", true));
+ member.Comments.Add(new CodeCommentStatement(summary, true));
+ member.Comments.Add(new CodeCommentStatement("", true));
+ }
+
+ internal static CodeAttributeDeclaration AddAttribute(CodeAttributeDeclarationCollection col,
+ CodeTypeReference type,
+ CodeExpression[] arguments)
+ {
+ CodeAttributeArgument[] attributeArguments = new CodeAttributeArgument[arguments.Length];
+ for (int i = 0; i < arguments.Length; i++) {
+ attributeArguments[i] = new CodeAttributeArgument(arguments[i]);
+ }
+ CodeAttributeDeclaration cad = new CodeAttributeDeclaration(type, attributeArguments);
+ col.Add(cad);
+ return cad;
+ }
+ }
+
+ public sealed class EasyExpression
+ {
+ readonly CodeExpression expr;
+
+ public EasyExpression(CodeExpression expr)
+ {
+ this.expr = expr;
+ }
+
+ public static implicit operator CodeExpression(EasyExpression expr)
+ {
+ return expr.expr;
+ }
+
+ public EasyExpression InvokeMethod(string name, params CodeExpression[] arguments)
+ {
+ return new EasyExpression(new CodeMethodInvokeExpression(expr, name, arguments));
+ }
+
+ public EasyExpression CastTo(Type type)
+ {
+ return CastTo(Easy.TypeRef(type));
+ }
+ public EasyExpression CastTo(CodeTypeReference type)
+ {
+ return new EasyExpression(new CodeCastExpression(type, expr));
+ }
+
+ public EasyExpression Index(params CodeExpression[] indices)
+ {
+ return new EasyExpression(new CodeIndexerExpression(expr, indices));
+ }
+
+ public EasyExpression Field(string name)
+ {
+ return new EasyExpression(new CodeFieldReferenceExpression(expr, name));
+ }
+
+ public EasyExpression Property(string name)
+ {
+ return new EasyExpression(new CodePropertyReferenceExpression(expr, name));
+ }
+ }
+
+ public class EasyCompileUnit : CodeCompileUnit
+ {
+ public EasyNamespace AddNamespace(string name)
+ {
+ EasyNamespace n = new EasyNamespace(name);
+ this.Namespaces.Add(n);
+ return n;
+ }
+ }
+
+ public class EasyNamespace : CodeNamespace
+ {
+ public EasyNamespace() : base() {}
+ public EasyNamespace(string name) : base(name) {}
+
+ public EasyTypeDeclaration AddType(string name)
+ {
+ EasyTypeDeclaration n = new EasyTypeDeclaration(name);
+ this.Types.Add(n);
+ return n;
+ }
+
+ public CodeNamespaceImport AddImport(string nameSpace)
+ {
+ CodeNamespaceImport cni = new CodeNamespaceImport(nameSpace);
+ this.Imports.Add(cni);
+ return cni;
+ }
+ }
+
+ public class EasyTypeDeclaration : CodeTypeDeclaration
+ {
+ public EasyTypeDeclaration() : base() {}
+ public EasyTypeDeclaration(string name) : base(name) {}
+
+ public CodeAttributeDeclaration AddAttribute(Type type, params CodeExpression[] arguments)
+ {
+ return Easy.AddAttribute(this.CustomAttributes, Easy.TypeRef(type), arguments);
+ }
+ public CodeAttributeDeclaration AddAttribute(CodeTypeReference type, params CodeExpression[] arguments)
+ {
+ return Easy.AddAttribute(this.CustomAttributes, type, arguments);
+ }
+
+ public EasyField AddField(Type type, string name)
+ {
+ return AddField(Easy.TypeRef(type), name);
+ }
+ public EasyField AddField(CodeTypeReference type, string name)
+ {
+ EasyField f = new EasyField(type, name);
+ this.Members.Add(f);
+ return f;
+ }
+
+ public EasyProperty AddProperty(Type type, string name)
+ {
+ return AddProperty(Easy.TypeRef(type), name);
+ }
+ public EasyProperty AddProperty(CodeTypeReference type, string name)
+ {
+ EasyProperty p = new EasyProperty(type, name);
+ this.Members.Add(p);
+ if (this.IsInterface == false) {
+ p.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+ }
+ return p;
+ }
+
+ public EasyProperty AddProperty(CodeMemberField field, string name)
+ {
+ EasyProperty p = AddProperty(field.Type, name);
+ p.Getter.Return(new CodeVariableReferenceExpression(field.Name));
+ p.Attributes |= field.Attributes & MemberAttributes.Static; // copy static flag
+ return p;
+ }
+
+ ///
+ /// Adds a method with return type void and attributes=Public|Final to this type.
+ ///
+ public EasyMethod AddMethod(string name)
+ {
+ return AddMethod(Easy.TypeRef(typeof(void)), name);
+ }
+ ///
+ /// Adds a method with return type and attributes=Public|Final to this type.
+ ///
+ public EasyMethod AddMethod(Type type, string name)
+ {
+ return AddMethod(Easy.TypeRef(type), name);
+ }
+ ///
+ /// Adds a method with return type and attributes=Public|Final to this type.
+ ///
+ public EasyMethod AddMethod(CodeTypeReference type, string name)
+ {
+ EasyMethod p = new EasyMethod(type, name);
+ this.Members.Add(p);
+ if (this.IsInterface == false) {
+ p.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+ }
+ return p;
+ }
+ }
+
+ public class EasyField : CodeMemberField
+ {
+ public EasyField() : base() {}
+ public EasyField(CodeTypeReference type, string name) : base(type, name) {}
+
+ public CodeAttributeDeclaration AddAttribute(Type type, params CodeExpression[] arguments)
+ {
+ return Easy.AddAttribute(this.CustomAttributes, Easy.TypeRef(type), arguments);
+ }
+ public CodeAttributeDeclaration AddAttribute(CodeTypeReference type, params CodeExpression[] arguments)
+ {
+ return Easy.AddAttribute(this.CustomAttributes, type, arguments);
+ }
+ }
+
+ public class EasyProperty : CodeMemberProperty
+ {
+ EasyBlock getter, setter;
+
+ public EasyProperty()
+ {
+ getter = new EasyBlock(this.GetStatements);
+ setter = new EasyBlock(this.SetStatements);
+ }
+
+ public EasyProperty(CodeTypeReference type, string name) : this()
+ {
+ this.Type = type;
+ this.Name = name;
+ }
+
+ public CodeAttributeDeclaration AddAttribute(Type type, params CodeExpression[] arguments)
+ {
+ return Easy.AddAttribute(this.CustomAttributes, Easy.TypeRef(type), arguments);
+ }
+ public CodeAttributeDeclaration AddAttribute(CodeTypeReference type, params CodeExpression[] arguments)
+ {
+ return Easy.AddAttribute(this.CustomAttributes, type, arguments);
+ }
+
+ public EasyBlock Getter {
+ get { return getter; }
+ }
+
+ public EasyBlock Setter {
+ get { return setter; }
+ }
+ }
+
+ public class EasyMethod : CodeMemberMethod
+ {
+ EasyBlock body;
+
+ public EasyMethod()
+ {
+ body = new EasyBlock(this.Statements);
+ }
+
+ public EasyMethod(CodeTypeReference type, string name) : this()
+ {
+ this.ReturnType = type;
+ this.Name = name;
+ }
+
+ public CodeAttributeDeclaration AddAttribute(Type type, params CodeExpression[] arguments)
+ {
+ return Easy.AddAttribute(this.CustomAttributes, Easy.TypeRef(type), arguments);
+ }
+ public CodeAttributeDeclaration AddAttribute(CodeTypeReference type, params CodeExpression[] arguments)
+ {
+ return Easy.AddAttribute(this.CustomAttributes, type, arguments);
+ }
+
+ public CodeParameterDeclarationExpression AddParameter(Type type, string name)
+ {
+ return AddParameter(Easy.TypeRef(type), name);
+ }
+ public CodeParameterDeclarationExpression AddParameter(CodeTypeReference type, string name)
+ {
+ CodeParameterDeclarationExpression cpde;
+ cpde = new CodeParameterDeclarationExpression(type, name);
+ this.Parameters.Add(cpde);
+ return cpde;
+ }
+
+ public EasyBlock Body {
+ get { return body; }
+ }
+ }
+
+ public sealed class EasyBlock
+ {
+ readonly CodeStatementCollection csc;
+
+ public EasyBlock(CodeStatementCollection csc)
+ {
+ this.csc = csc;
+ }
+
+ public CodeMethodReturnStatement Return(CodeExpression expr)
+ {
+ CodeMethodReturnStatement st = new CodeMethodReturnStatement(expr);
+ csc.Add(st);
+ return st;
+ }
+
+ public CodeAssignStatement Assign(CodeExpression lhs, CodeExpression rhs)
+ {
+ CodeAssignStatement st = new CodeAssignStatement(lhs, rhs);
+ csc.Add(st);
+ return st;
+ }
+
+ ///
+ /// Execute one expression as statement.
+ ///
+ public CodeExpressionStatement Add(CodeExpression expr)
+ {
+ CodeExpressionStatement st = new CodeExpressionStatement(expr);
+ csc.Add(st);
+ return st;
+ }
+
+ ///
+ /// Adds the statement.
+ ///
+ public CodeStatement Add(CodeStatement st)
+ {
+ csc.Add(st);
+ return st;
+ }
+
+ ///
+ /// Invoke a method on target as statement.
+ ///
+ public CodeExpressionStatement InvokeMethod(CodeExpression target, string name, params CodeExpression[] arguments)
+ {
+ return Add(new CodeMethodInvokeExpression(target, name, arguments));
+ }
+
+ ///
+ /// Declares a local variable.
+ ///
+ public CodeVariableDeclarationStatement DeclareVariable(Type type, string name)
+ {
+ return DeclareVariable(Easy.TypeRef(type), name);
+ }
+ ///
+ /// Declares a local variable.
+ ///
+ public CodeVariableDeclarationStatement DeclareVariable(CodeTypeReference type, string name)
+ {
+ CodeVariableDeclarationStatement st = new CodeVariableDeclarationStatement(type, name);
+ csc.Add(st);
+ return st;
+ }
+ }
+}
diff --git a/lib/NRefactory/NRefactoryASTGenerator/Main.cs b/lib/NRefactory/NRefactoryASTGenerator/Main.cs
new file mode 100644
index 000000000..359b64418
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/Main.cs
@@ -0,0 +1,542 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using System.CodeDom;
+using System.Diagnostics;
+using System.Reflection;
+using System.IO;
+using NRefactoryASTGenerator.Ast;
+using ICSharpCode.EasyCodeDom;
+
+namespace NRefactoryASTGenerator
+{
+ class MainClass
+ {
+ public const string VisitPrefix = "Visit";
+
+ public static void Main(string[] args)
+ {
+ string directory = "../../../Project/Src/Ast/";
+ string visitorsDir = "../../../Project/Src/Visitors/";
+ Debug.WriteLine("AST Generator running...");
+ if (!File.Exists(directory + "INode.cs")) {
+ Debug.WriteLine("did not find output directory");
+ return;
+ }
+ if (!File.Exists(visitorsDir + "AbstractAstTransformer.cs")) {
+ Debug.WriteLine("did not find visitor output directory");
+ return;
+ }
+
+ List nodeTypes = new List();
+ foreach (Type type in typeof(MainClass).Assembly.GetTypes()) {
+ if (type.IsClass && typeof(INode).IsAssignableFrom(type)) {
+ nodeTypes.Add(type);
+ }
+ }
+ nodeTypes.Sort(delegate(Type a, Type b) { return a.Name.CompareTo(b.Name); });
+
+ EasyCompileUnit ccu = new EasyCompileUnit();
+ EasyNamespace cns = ccu.AddNamespace("ICSharpCode.NRefactory.Ast");
+ cns.AddImport("System");
+ cns.AddImport("System.Collections.Generic");
+ foreach (Type type in nodeTypes) {
+ if (type.GetCustomAttributes(typeof(CustomImplementationAttribute), false).Length == 0) {
+ EasyTypeDeclaration ctd = cns.AddType(type.Name);
+ if (type.IsAbstract) {
+ ctd.TypeAttributes |= TypeAttributes.Abstract;
+ }
+ ctd.BaseTypes.Add(new CodeTypeReference(type.BaseType.Name));
+
+ ProcessType(type, ctd);
+
+ foreach (object o in type.GetCustomAttributes(false)) {
+ if (o is TypeImplementationModifierAttribute) {
+ (o as TypeImplementationModifierAttribute).ModifyImplementation(cns, ctd, type);
+ }
+ }
+
+ if (!type.IsAbstract) {
+ CodeMemberMethod method = new CodeMemberMethod();
+ method.Name = "AcceptVisitor";
+ method.Attributes = MemberAttributes.Public | MemberAttributes.Override;
+ method.Parameters.Add(new CodeParameterDeclarationExpression("IAstVisitor", "visitor"));
+ method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "data"));
+ method.ReturnType = new CodeTypeReference(typeof(object));
+ CodeExpression ex = new CodeVariableReferenceExpression("visitor");
+ ex = new CodeMethodInvokeExpression(ex, VisitPrefix + ctd.Name,
+ new CodeThisReferenceExpression(),
+ new CodeVariableReferenceExpression("data"));
+ method.Statements.Add(new CodeMethodReturnStatement(ex));
+ ctd.Members.Add(method);
+
+ method = new CodeMemberMethod();
+ method.Name = "ToString";
+ method.Attributes = MemberAttributes.Public | MemberAttributes.Override;
+ method.ReturnType = new CodeTypeReference(typeof(string));
+ method.Statements.Add(new CodeMethodReturnStatement(CreateToString(type)));
+ ctd.Members.Add(method);
+ }
+ }
+ }
+
+ System.CodeDom.Compiler.CodeGeneratorOptions settings = new System.CodeDom.Compiler.CodeGeneratorOptions();
+ settings.IndentString = "\t";
+ settings.VerbatimOrder = true;
+
+ using (StringWriter writer = new StringWriter()) {
+ new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings);
+ File.WriteAllText(directory + "Generated.cs", writer.ToString());
+ }
+
+ ccu = new EasyCompileUnit();
+ cns = ccu.AddNamespace("ICSharpCode.NRefactory");
+ cns.AddImport("System");
+ cns.AddImport("ICSharpCode.NRefactory.Ast");
+ cns.Types.Add(CreateAstVisitorInterface(nodeTypes));
+
+ using (StringWriter writer = new StringWriter()) {
+ new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings);
+ File.WriteAllText(visitorsDir + "../IAstVisitor.cs", writer.ToString());
+ }
+
+ ccu = new EasyCompileUnit();
+ cns = ccu.AddNamespace("ICSharpCode.NRefactory.Visitors");
+ cns.AddImport("System");
+ cns.AddImport("System.Collections.Generic");
+ cns.AddImport("System.Diagnostics");
+ cns.AddImport("ICSharpCode.NRefactory.Ast");
+ cns.Types.Add(CreateAstVisitorClass(nodeTypes, false));
+
+ using (StringWriter writer = new StringWriter()) {
+ new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings);
+ File.WriteAllText(visitorsDir + "AbstractAstVisitor.cs", writer.ToString());
+ }
+
+ ccu = new EasyCompileUnit();
+ cns = ccu.AddNamespace("ICSharpCode.NRefactory.Visitors");
+ cns.AddImport("System");
+ cns.AddImport("System.Collections.Generic");
+ cns.AddImport("System.Diagnostics");
+ cns.AddImport("ICSharpCode.NRefactory.Ast");
+ cns.Types.Add(CreateAstVisitorClass(nodeTypes, true));
+
+ using (StringWriter writer = new StringWriter()) {
+ new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings);
+ File.WriteAllText(visitorsDir + "AbstractAstTransformer.cs", writer.ToString());
+ }
+
+ ccu = new EasyCompileUnit();
+ cns = ccu.AddNamespace("ICSharpCode.NRefactory.Visitors");
+ cns.AddImport("System");
+ cns.AddImport("ICSharpCode.NRefactory.Ast");
+ cns.Types.Add(CreateNodeTrackingAstVisitorClass(nodeTypes));
+
+ using (StringWriter writer = new StringWriter()) {
+ new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, settings);
+ // CodeDom cannot output "sealed", so we need to use this hack:
+ File.WriteAllText(visitorsDir + "NodeTrackingAstVisitor.cs",
+ writer.ToString().Replace("public override object", "public sealed override object"));
+ }
+ }
+
+ static CodeTypeDeclaration CreateAstVisitorInterface(List nodeTypes)
+ {
+ EasyTypeDeclaration td = new EasyTypeDeclaration("IAstVisitor");
+ td.IsInterface = true;
+
+ foreach (Type t in nodeTypes) {
+ if (!t.IsAbstract) {
+ EasyMethod m = td.AddMethod(typeof(object), VisitPrefix + t.Name);
+ m.AddParameter(ConvertType(t), GetFieldName(t.Name));
+ m.AddParameter(typeof(object), "data");
+ }
+ }
+ return td;
+ }
+
+ static CodeTypeDeclaration CreateAstVisitorClass(List nodeTypes, bool transformer)
+ {
+ EasyTypeDeclaration td = new EasyTypeDeclaration(transformer ? "AbstractAstTransformer" : "AbstractAstVisitor");
+ td.TypeAttributes = TypeAttributes.Public | TypeAttributes.Abstract;
+ td.BaseTypes.Add(new CodeTypeReference("IAstVisitor"));
+
+ if (transformer) {
+ string comment =
+ "The AbstractAstTransformer will iterate through the whole AST,\n " +
+ "just like the AbstractAstVisitor. However, the AbstractAstTransformer allows\n " +
+ "you to modify the AST at the same time: It does not use 'foreach' internally,\n " +
+ "so you can add members to collections of parents of the current node (but\n " +
+ "you cannot insert or delete items as that will make the index used invalid).\n " +
+ "You can use the methods ReplaceCurrentNode and RemoveCurrentNode to replace\n " +
+ "or remove the current node, totally independent from the type of the parent node.";
+ Easy.AddSummary(td, comment);
+
+ EasyField field = td.AddField(Easy.TypeRef("Stack", "INode"), "nodeStack");
+ field.InitExpression = Easy.New(field.Type);
+
+ /*
+ CodeExpression nodeStack = Easy.Var("nodeStack");
+ CodeMemberProperty p = new CodeMemberProperty();
+ p.Name = "CurrentNode";
+ p.Type = new CodeTypeReference("INode");
+ p.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+ p.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression("currentNode")));
+ p.SetStatements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression("currentNode"),
+ new CodePropertySetValueReferenceExpression()));
+ td.Members.Add(p);
+ */
+
+ EasyMethod m = td.AddMethod("ReplaceCurrentNode");
+ m.AddParameter(Easy.TypeRef("INode"), "newNode");
+ m.Statements.Add(Easy.Var("nodeStack").InvokeMethod("Pop"));
+ m.Statements.Add(Easy.Var("nodeStack").InvokeMethod("Push", Easy.Var("newNode")));
+
+ m = td.AddMethod("RemoveCurrentNode");
+ m.Statements.Add(Easy.Var("nodeStack").InvokeMethod("Pop"));
+ m.Statements.Add(Easy.Var("nodeStack").InvokeMethod("Push", Easy.Null));
+ }
+
+ foreach (Type type in nodeTypes) {
+ if (!type.IsAbstract) {
+ EasyMethod m = td.AddMethod(typeof(object), VisitPrefix + type.Name);
+ m.Attributes = MemberAttributes.Public;
+ m.AddParameter(ConvertType(type), GetFieldName(type.Name));
+ m.AddParameter(typeof(object), "data");
+
+ List assertions = new List();
+ string varVariableName = GetFieldName(type.Name);
+ EasyExpression var = Easy.Var(varVariableName);
+ assertions.Add(AssertIsNotNull(var));
+
+ AddFieldVisitCode(m, type, var, assertions, transformer);
+
+ if (type.GetCustomAttributes(typeof(HasChildrenAttribute), true).Length > 0) {
+ if (transformer) {
+ m.Statements.Add(new CodeSnippetStatement(CreateTransformerLoop(varVariableName + ".Children", "INode")));
+ m.Body.Return(Easy.Null);
+ } else {
+ m.Body.Return(var.InvokeMethod("AcceptChildren", Easy.This, Easy.Var("data")));
+ }
+ } else {
+ CodeExpressionStatement lastStatement = null;
+ if (m.Statements.Count > 0) {
+ lastStatement = m.Statements[m.Statements.Count - 1] as CodeExpressionStatement;
+ }
+ if (lastStatement != null) {
+ m.Statements.RemoveAt(m.Statements.Count - 1);
+ m.Body.Return(lastStatement.Expression);
+ } else {
+ m.Body.Return(Easy.Null);
+ }
+ }
+
+ for (int i = 0; i < assertions.Count; i++) {
+ m.Statements.Insert(i, assertions[i]);
+ }
+ }
+ }
+ return td;
+ }
+
+ static void AddFieldVisitCode(EasyMethod m, Type type, EasyExpression var, List assertions, bool transformer)
+ {
+ if (type != null) {
+ if (type.BaseType != typeof(StatementWithEmbeddedStatement)) {
+ AddFieldVisitCode(m, type.BaseType, var, assertions, transformer);
+ }
+ foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) {
+ AddVisitCode(m, field, var, assertions, transformer);
+ }
+ if (type.BaseType == typeof(StatementWithEmbeddedStatement)) {
+ AddFieldVisitCode(m, type.BaseType, var, assertions, transformer);
+ }
+ }
+ }
+
+ static CodeStatement AssertIsNotNull(CodeExpression expr)
+ {
+ return new CodeExpressionStatement(
+ Easy.Type("Debug").InvokeMethod("Assert",
+ Easy.Binary(expr,
+ CodeBinaryOperatorType.IdentityInequality,
+ Easy.Null))
+ );
+ }
+
+ static string GetCode(CodeExpression ex)
+ {
+ using (StringWriter writer = new StringWriter()) {
+ new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromExpression(ex, writer, null);
+ return writer.ToString();
+ }
+ }
+
+ static string CreateTransformerLoop(string collection, string typeName)
+ {
+ return
+ "\t\t\tfor (int i = 0; i < " + collection + ".Count; i++) {\n" +
+ "\t\t\t\t" + typeName + " o = " + collection + "[i];\n" +
+ "\t\t\t\tDebug.Assert(o != null);\n" +
+ "\t\t\t\tnodeStack.Push(o);\n" +
+ "\t\t\t\to.AcceptVisitor(this, data);\n" +
+ (typeName == "INode"
+ ? "\t\t\t\to = nodeStack.Pop();\n"
+ : "\t\t\t\to = (" + typeName + ")nodeStack.Pop();\n") +
+ "\t\t\t\tif (o == null)\n" +
+ "\t\t\t\t\t" + collection + ".RemoveAt(i--);\n" +
+ "\t\t\t\telse\n" +
+ "\t\t\t\t\t" + collection + "[i] = o;\n" +
+ "\t\t\t}";
+ }
+
+ static bool AddVisitCode(EasyMethod m, FieldInfo field, EasyExpression var, List assertions, bool transformer)
+ {
+ EasyExpression prop = var.Property(GetPropertyName(field.Name));
+ EasyExpression nodeStack = Easy.Var("nodeStack");
+ if (field.FieldType.FullName.StartsWith("System.Collections.Generic.List")) {
+ Type elType = field.FieldType.GetGenericArguments()[0];
+ if (!typeof(INode).IsAssignableFrom(elType))
+ return false;
+ assertions.Add(AssertIsNotNull(prop));
+ string code;
+ if (transformer) {
+ code = CreateTransformerLoop(GetCode(prop), ConvertType(elType).BaseType);
+ } else {
+ code =
+ "\t\t\tforeach (" + ConvertType(elType).BaseType + " o in " + GetCode(prop) + ") {\n" +
+ "\t\t\t\tDebug.Assert(o != null);\n" +
+ "\t\t\t\to.AcceptVisitor(this, data);\n" +
+ "\t\t\t}";
+ }
+ m.Statements.Add(new CodeSnippetStatement(code));
+ return true;
+ }
+ if (!typeof(INode).IsAssignableFrom(field.FieldType))
+ return false;
+ assertions.Add(AssertIsNotNull(prop));
+ if (transformer) {
+ m.Statements.Add(nodeStack.InvokeMethod("Push", prop));
+ }
+ m.Statements.Add(prop.InvokeMethod("AcceptVisitor",
+ Easy.This,
+ Easy.Var("data")));
+ if (transformer) {
+ m.Body.Assign(prop, nodeStack.InvokeMethod("Pop").CastTo(ConvertType(field.FieldType)));
+ }
+ return true;
+ }
+
+ static CodeExpression CreateToString(Type type)
+ {
+ CodeMethodInvokeExpression ie = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(string)),
+ "Format");
+ CodePrimitiveExpression prim = new CodePrimitiveExpression();
+ ie.Parameters.Add(prim);
+ string text = "[" + type.Name;
+ int index = 0;
+ do {
+ foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) {
+ text += " " + GetPropertyName(field.Name) + "={" + index.ToString() + "}";
+ index++;
+ if (typeof(System.Collections.ICollection).IsAssignableFrom(field.FieldType)) {
+ ie.Parameters.Add(new CodeSnippetExpression("GetCollectionString(" + GetPropertyName(field.Name) + ")"));
+ } else {
+ ie.Parameters.Add(new CodeVariableReferenceExpression(GetPropertyName(field.Name)));
+ }
+ }
+ type = type.BaseType;
+ } while (type != null);
+ prim.Value = text + "]";
+ if (ie.Parameters.Count == 1)
+ return prim;
+ else
+ return ie;
+ // return String.Format("[AnonymousMethodExpression: Parameters={0} Body={1}]",
+ // GetCollectionString(Parameters),
+ // Body);
+ }
+
+ static void ProcessType(Type type, EasyTypeDeclaration ctd)
+ {
+ foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) {
+ ctd.AddField(ConvertType(field.FieldType), field.Name).Attributes = 0;
+ }
+ foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) {
+ EasyProperty p = ctd.AddProperty(ConvertType(field.FieldType), GetPropertyName(field.Name));
+ p.Getter.Return(Easy.Var(field.Name));
+ CodeExpression ex;
+ if (field.FieldType.IsValueType)
+ ex = new CodePropertySetValueReferenceExpression();
+ else
+ ex = GetDefaultValue("value", field);
+ p.Setter.Assign(Easy.Var(field.Name), ex);
+ if (typeof(INode).IsAssignableFrom(field.FieldType) && typeof(INullable).IsAssignableFrom(field.FieldType)) {
+ p.SetStatements.Add(new CodeSnippetStatement("\t\t\t\tif (!" +field.Name+".IsNull) "+field.Name+".Parent = this;"));
+ }
+ }
+ foreach (ConstructorInfo ctor in type.GetConstructors()) {
+ CodeConstructor c = new CodeConstructor();
+ if (type.IsAbstract)
+ c.Attributes = MemberAttributes.Family;
+ else
+ c.Attributes = MemberAttributes.Public;
+ ctd.Members.Add(c);
+ ConstructorInfo baseCtor = GetBaseCtor(type);
+ foreach(ParameterInfo param in ctor.GetParameters()) {
+ c.Parameters.Add(new CodeParameterDeclarationExpression(ConvertType(param.ParameterType),
+ param.Name));
+ if (baseCtor != null && Array.Exists(baseCtor.GetParameters(), delegate(ParameterInfo p) { return param.Name == p.Name; }))
+ continue;
+ c.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(GetPropertyName(param.Name)),
+ new CodeVariableReferenceExpression(param.Name)));
+ }
+ if (baseCtor != null) {
+ foreach(ParameterInfo param in baseCtor.GetParameters()) {
+ c.BaseConstructorArgs.Add(new CodeVariableReferenceExpression(param.Name));
+ }
+ }
+ // initialize fields that were not initialized by parameter
+ foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) {
+ if (field.FieldType.IsValueType && field.FieldType != typeof(Location))
+ continue;
+ if (Array.Exists(ctor.GetParameters(), delegate(ParameterInfo p) { return field.Name == p.Name; }))
+ continue;
+ c.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(field.Name),
+ GetDefaultValue(null, field)));
+ }
+ }
+ }
+
+ internal static ConstructorInfo GetBaseCtor(Type type)
+ {
+ ConstructorInfo[] list = type.BaseType.GetConstructors();
+ if (list.Length == 0)
+ return null;
+ else
+ return list[0];
+ }
+
+ internal static CodeExpression GetDefaultValue(string inputVariable, FieldInfo field)
+ {
+ string code;
+ // get default value:
+ if (field.FieldType == typeof(string)) {
+ code = "\"\"";
+ if (field.GetCustomAttributes(typeof(QuestionMarkDefaultAttribute), false).Length > 0) {
+ if (inputVariable == null)
+ return new CodePrimitiveExpression("?");
+ else
+ return new CodeSnippetExpression("string.IsNullOrEmpty(" + inputVariable + ") ? \"?\" : " + inputVariable);
+ }
+ } else if (field.FieldType.FullName.StartsWith("System.Collections.Generic.List")) {
+ code = "new List<" + field.FieldType.GetGenericArguments()[0].Name + ">()";
+ } else if (field.FieldType == typeof(Location)) {
+ code = "Location.Empty";
+ } else {
+ code = field.FieldType.Name + ".Null";
+ }
+ if (inputVariable != null) {
+ code = inputVariable + " ?? " + code;
+ }
+ return new CodeSnippetExpression(code);
+ }
+
+ internal static string GetFieldName(string typeName)
+ {
+ return char.ToLower(typeName[0]) + typeName.Substring(1);
+ }
+
+ internal static string GetPropertyName(string fieldName)
+ {
+ return char.ToUpper(fieldName[0]) + fieldName.Substring(1);
+ }
+
+ internal static CodeTypeReference ConvertType(Type type)
+ {
+ if (type.IsGenericType && !type.IsGenericTypeDefinition) {
+ CodeTypeReference tr = ConvertType(type.GetGenericTypeDefinition());
+ foreach (Type subType in type.GetGenericArguments()) {
+ tr.TypeArguments.Add(ConvertType(subType));
+ }
+ return tr;
+ } else if (type.FullName.StartsWith("NRefactory") || type.FullName.StartsWith("System.Collections")) {
+ if (type.Name == "Attribute")
+ return new CodeTypeReference("ICSharpCode.NRefactory.Ast.Attribute");
+ return new CodeTypeReference(type.Name);
+ } else {
+ return new CodeTypeReference(type);
+ }
+ }
+
+ static CodeTypeDeclaration CreateNodeTrackingAstVisitorClass(List nodeTypes)
+ {
+ EasyTypeDeclaration td = new EasyTypeDeclaration("NodeTrackingAstVisitor");
+ td.TypeAttributes = TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Abstract;
+ td.BaseTypes.Add(new CodeTypeReference("AbstractAstVisitor"));
+
+ string comment = "\n " +
+ "The NodeTrackingAstVisitor will iterate through the whole AST,\n " +
+ "just like the AbstractAstVisitor, and calls the virtual methods\n " +
+ "BeginVisit and EndVisit for each node being visited.\n " +
+ "";
+ td.Comments.Add(new CodeCommentStatement(comment, true));
+ comment = "\n " +
+ "base.Visit(node, data) calls this.TrackedVisit(node, data), so if\n " +
+ "you want to visit child nodes using the default visiting behaviour,\n " +
+ "use base.TrackedVisit(parentNode, data).\n " +
+ "";
+ td.Comments.Add(new CodeCommentStatement(comment, true));
+
+ EasyMethod m = td.AddMethod("BeginVisit");
+ m.Attributes = MemberAttributes.Family;
+ m.AddParameter(Easy.TypeRef("INode"), "node");
+
+ m = td.AddMethod("EndVisit");
+ m.Attributes = MemberAttributes.Family;
+ m.AddParameter(Easy.TypeRef("INode"), "node");
+
+ foreach (Type type in nodeTypes) {
+ if (!type.IsAbstract) {
+
+ m = td.AddMethod(typeof(object), VisitPrefix + type.Name);
+ m.Attributes = MemberAttributes.Public | MemberAttributes.Override;
+ m.AddParameter(ConvertType(type), GetFieldName(type.Name));
+ m.AddParameter(new CodeTypeReference(typeof(object)), "data");
+
+ CodeExpression var = Easy.Var(GetFieldName(type.Name));
+
+// m.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "BeginVisit"), new CodeExpression[] { var }));
+// m.Statements.Add(new CodeVariableDeclarationStatement(new CodeTypeReference(typeof(object)), "result", new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "TrackedVisit"), new CodeExpression[] { var, new CodeVariableReferenceExpression("data") })));
+// m.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "EndVisit"), new CodeExpression[] { var }));
+// m.Statements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression("result")));
+ m.Body.InvokeMethod(Easy.This, "BeginVisit", var);
+ m.Body.DeclareVariable(typeof(object), "result").InitExpression
+ = Easy.This.InvokeMethod("TrackedVisit" + type.Name, var, Easy.Var("data"));
+ m.Body.InvokeMethod(Easy.This, "EndVisit", var);
+ m.Body.Return(Easy.Var("result"));
+ }
+ }
+
+ foreach (Type type in nodeTypes) {
+ if (!type.IsAbstract) {
+
+ m = td.AddMethod(typeof(object), "TrackedVisit" + type.Name);
+ m.Attributes = MemberAttributes.Public;
+ m.AddParameter(ConvertType(type), GetFieldName(type.Name));
+ m.AddParameter(new CodeTypeReference(typeof(object)), "data");
+
+ m.Body.Return(Easy.Base.InvokeMethod(VisitPrefix + type.Name, Easy.Var(GetFieldName(type.Name)), Easy.Var("data")));
+ }
+ }
+
+ return td;
+ }
+ }
+}
diff --git a/lib/NRefactory/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj b/lib/NRefactory/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj
new file mode 100644
index 000000000..ef7f609fe
--- /dev/null
+++ b/lib/NRefactory/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj
@@ -0,0 +1,56 @@
+
+
+ Exe
+ NRefactoryASTGenerator
+ NRefactoryASTGenerator
+ Debug
+ AnyCPU
+ {B22522AA-B5BF-4A58-AC6D-D4B45805521F}
+ False
+ False
+ False
+ Auto
+ 4194304
+ AnyCPU
+ 4096
+ 4
+ 0169
+ false
+
+
+ bin\Debug\
+ False
+ DEBUG;TRACE
+ true
+ Full
+ True
+
+
+ bin\Release\
+ True
+ TRACE
+ False
+ None
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/NRefactory/Project/Configuration/AssemblyInfo.cs b/lib/NRefactory/Project/Configuration/AssemblyInfo.cs
new file mode 100644
index 000000000..6f0cf97dc
--- /dev/null
+++ b/lib/NRefactory/Project/Configuration/AssemblyInfo.cs
@@ -0,0 +1,25 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: CLSCompliant(true)]
+[assembly: StringFreezing()]
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("NRefactory")]
+[assembly: AssemblyDescription("Parser and refactoring library for C# and VB.NET")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
diff --git a/lib/NRefactory/Project/NRefactory.csproj b/lib/NRefactory/Project/NRefactory.csproj
new file mode 100644
index 000000000..9657323c4
--- /dev/null
+++ b/lib/NRefactory/Project/NRefactory.csproj
@@ -0,0 +1,152 @@
+
+
+ Debug
+ AnyCPU
+ 8.0.41115
+ 2.0
+ {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}
+ ICSharpCode.NRefactory
+ ICSharpCode.NRefactory
+ Library
+ 4
+ False
+ False
+ OnSuccessfulBuild
+ Library
+ true
+ Resources\ICSharpCode.NRefactory.snk
+ False
+ False
+ Auto
+ 94896128
+ AnyCPU
+ 4096
+ False
+ -Microsoft.Design#CA1002;-Microsoft.Design#CA1020;-Microsoft.Design#CA1051;-Microsoft.Design#CA1062;-Microsoft.Globalization#CA1303;-Microsoft.Globalization#CA1305;-Microsoft.Naming#CA1704;-Microsoft.Performance#CA1800;-Microsoft.Performance#CA1805;-Microsoft.Usage#CA2211;-Microsoft.Usage#CA2227
+ v2.0
+
+
+ False
+ True
+ TEST; DEBUG
+ false
+
+
+ True
+ False
+ TEST
+ false
+
+
+ Full
+ true
+ bin\Debug
+
+
+ false
+ None
+ bin\Release
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/NRefactory/Project/NRefactory.csproj.user b/lib/NRefactory/Project/NRefactory.csproj.user
new file mode 100644
index 000000000..3b61c2cc0
--- /dev/null
+++ b/lib/NRefactory/Project/NRefactory.csproj.user
@@ -0,0 +1,13 @@
+
+
+ 8.0.41115
+ ShowAllFiles
+ 0
+
+
+ ..\..\..\..\bin\SharpDevelop.exe
+
+
+ ..\..\..\..\bin\SharpDevelop.exe
+
+
\ No newline at end of file
diff --git a/lib/NRefactory/Project/Resources/ICSharpCode.NRefactory.snk b/lib/NRefactory/Project/Resources/ICSharpCode.NRefactory.snk
new file mode 100644
index 000000000..b273cdc5a
Binary files /dev/null and b/lib/NRefactory/Project/Resources/ICSharpCode.NRefactory.snk differ
diff --git a/lib/NRefactory/Project/Src/Ast/AbstractNode.cs b/lib/NRefactory/Project/Src/Ast/AbstractNode.cs
new file mode 100644
index 000000000..a4ff1b5e0
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/AbstractNode.cs
@@ -0,0 +1,76 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+
+namespace ICSharpCode.NRefactory.Ast
+{
+ public abstract class AbstractNode : INode
+ {
+ List children = new List();
+
+ public INode Parent { get; set; }
+ public Location StartLocation { get; set; }
+ public Location EndLocation { get; set; }
+ public object UserData { get; set; }
+
+ public List Children {
+ get {
+ return children;
+ }
+ set {
+ Debug.Assert(value != null);
+ children = value;
+ }
+ }
+
+ public virtual void AddChild(INode childNode)
+ {
+ Debug.Assert(childNode != null);
+ children.Add(childNode);
+ }
+
+ public abstract object AcceptVisitor(IAstVisitor visitor, object data);
+
+ public virtual object AcceptChildren(IAstVisitor visitor, object data)
+ {
+ foreach (INode child in children) {
+ Debug.Assert(child != null);
+ child.AcceptVisitor(visitor, data);
+ }
+ return data;
+ }
+
+ public static string GetCollectionString(ICollection collection)
+ {
+ StringBuilder output = new StringBuilder();
+ output.Append('{');
+
+ if (collection != null) {
+ IEnumerator en = collection.GetEnumerator();
+ bool isFirst = true;
+ while (en.MoveNext()) {
+ if (!isFirst) {
+ output.Append(", ");
+ } else {
+ isFirst = false;
+ }
+ output.Append(en.Current == null ? "" : en.Current.ToString());
+ }
+ } else {
+ return "null";
+ }
+
+ output.Append('}');
+ return output.ToString();
+ }
+ }
+}
diff --git a/lib/NRefactory/Project/Src/Ast/Enums.cs b/lib/NRefactory/Project/Src/Ast/Enums.cs
new file mode 100644
index 000000000..b90245f87
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/Enums.cs
@@ -0,0 +1,369 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+
+namespace ICSharpCode.NRefactory.Ast
+{
+ [Flags]
+ public enum Modifiers
+ {
+ None = 0x0000,
+
+ // Access
+ Private = 0x0001,
+ /// C# 'internal', VB 'Friend'
+ Internal = 0x0002,
+ Protected = 0x0004,
+ Public = 0x0008,
+ Dim = 0x0010, // VB.NET SPECIFIC, for fields/local variables only
+
+ // Scope
+ Abstract = 0x0010, // == MustOverride/MustInherit
+ Virtual = 0x0020,
+ Sealed = 0x0040,
+ /// C# 'static', VB 'Shared'
+ Static = 0x0080,
+ Override = 0x0100,
+ /// For fields: readonly (c# and vb), for properties: get-only (vb)
+ ReadOnly = 0x0200,
+ Const = 0x0400,
+ /// C# 'new', VB 'Shadows'
+ New = 0x0800,
+ Partial = 0x1000,
+
+ // Special
+ Extern = 0x2000,
+ Volatile = 0x4000,
+ Unsafe = 0x8000,
+ Overloads = 0x10000, // VB specific
+ WithEvents = 0x20000, // VB specific
+ Default = 0x40000, // VB specific
+ Fixed = 0x80000, // C# specific (fixed size arrays in unsafe structs)
+
+ /// Generated code, not part of parsed code
+ Synthetic = 0x200000,
+ /// Only for VB properties.
+ WriteOnly = 0x400000, // VB specific
+
+ Visibility = Private | Public | Protected | Internal,
+ Classes = New | Visibility | Abstract | Sealed | Partial | Static,
+ VBModules = Visibility,
+ VBStructures = Visibility | New,
+ VBEnums = Visibility | New,
+ VBInterfacs = Visibility | New,
+ VBDelegates = Visibility | New,
+ VBMethods = Visibility | New | Static | Virtual | Sealed | Abstract | Override | Overloads,
+ VBExternalMethods = Visibility | New | Overloads,
+ VBEvents = Visibility | New | Overloads,
+ VBProperties = VBMethods | Default | ReadOnly | WriteOnly,
+ VBCustomEvents = Visibility | New | Overloads,
+ VBOperators = Public | Static | Overloads | New,
+
+
+ // this is not documented in the spec
+ VBInterfaceEvents = New,
+ VBInterfaceMethods = New | Overloads,
+ VBInterfaceProperties = New | Overloads | ReadOnly | WriteOnly | Default,
+ VBInterfaceEnums = New,
+
+ Fields = New | Visibility | Static | ReadOnly | Volatile | Fixed,
+ PropertysEventsMethods = New | Visibility | Static | Virtual | Sealed | Override | Abstract | Extern,
+ Indexers = New | Visibility | Virtual | Sealed | Override | Abstract | Extern,
+ Operators = Public | Static | Extern,
+ Constants = New | Visibility,
+ StructsInterfacesEnumsDelegates = New | Visibility | Partial,
+ StaticConstructors = Extern | Static | Unsafe,
+ Destructors = Extern | Unsafe,
+ Constructors = Visibility | Extern,
+ }
+
+ public enum ClassType
+ {
+ Class,
+ Module,
+ Interface,
+ Struct,
+ Enum
+ }
+
+ public enum ParentType
+ {
+ ClassOrStruct,
+ InterfaceOrEnum,
+ Namespace,
+ Unknown
+ }
+
+ public enum FieldDirection
+ {
+ None,
+ In,
+ Out,
+ Ref
+ }
+
+ [Flags]
+ public enum ParameterModifiers
+ {
+ // Values must be the same as in SharpDevelop's ParameterModifiers
+ None = 0,
+ In = 1,
+ Out = 2,
+ Ref = 4,
+ Params = 8,
+ Optional = 16
+ }
+
+ public enum AssignmentOperatorType
+ {
+ None,
+ Assign,
+
+ Add,
+ Subtract,
+ Multiply,
+ Divide,
+ Modulus,
+
+ Power, // (VB only)
+ DivideInteger, // (VB only)
+ ConcatString, // (VB only)
+
+ ShiftLeft,
+ ShiftRight,
+
+ BitwiseAnd,
+ BitwiseOr,
+ ExclusiveOr,
+ }
+
+ public enum BinaryOperatorType
+ {
+ None,
+
+ /// '&' in C#, 'And' in VB.
+ BitwiseAnd,
+ /// '|' in C#, 'Or' in VB.
+ BitwiseOr,
+ /// '&&' in C#, 'AndAlso' in VB.
+ LogicalAnd,
+ /// '||' in C#, 'OrElse' in VB.
+ LogicalOr,
+ /// '^' in C#, 'Xor' in VB.
+ ExclusiveOr,
+
+ /// >
+ GreaterThan,
+ /// >=
+ GreaterThanOrEqual,
+ /// '==' in C#, '=' in VB.
+ Equality,
+ /// '!=' in C#, '<>' in VB.
+ InEquality,
+ /// <
+ LessThan,
+ /// <=
+ LessThanOrEqual,
+
+ /// +
+ Add,
+ /// -
+ Subtract,
+ /// *
+ Multiply,
+ /// /
+ Divide,
+ /// '%' in C#, 'Mod' in VB.
+ Modulus,
+ /// VB-only: \
+ DivideInteger,
+ /// VB-only: ^
+ Power,
+ /// VB-only: &
+ Concat,
+
+ /// C#: <<
+ ShiftLeft,
+ /// C#: >>
+ ShiftRight,
+ /// VB-only: Is
+ ReferenceEquality,
+ /// VB-only: IsNot
+ ReferenceInequality,
+
+ /// VB-only: Like
+ Like,
+ /// C#: ??
+ NullCoalescing,
+ }
+
+ public enum CastType
+ {
+ ///
+ /// direct cast (C#, VB "DirectCast")
+ ///
+ Cast,
+ ///
+ /// try cast (C# "as", VB "TryCast")
+ ///
+ TryCast,
+ ///
+ /// converting cast (VB "CType")
+ ///
+ Conversion,
+ ///
+ /// primitive converting cast (VB "CString" etc.)
+ ///
+ PrimitiveConversion
+ }
+
+ public enum UnaryOperatorType
+ {
+ None,
+ Not,
+ BitNot,
+
+ Minus,
+ Plus,
+
+ Increment,
+ Decrement,
+
+ PostIncrement,
+ PostDecrement,
+
+ /// Dereferencing pointer
+ Star,
+ /// Get address of
+ BitWiseAnd
+ }
+
+ public enum ContinueType
+ {
+ None,
+ Do,
+ For,
+ While
+ }
+
+ public enum ConditionType
+ {
+ None,
+ Until,
+ While,
+ DoWhile
+ }
+
+ public enum ConditionPosition
+ {
+ None,
+ Start,
+ End
+ }
+
+ public enum ExitType
+ {
+ None,
+ Sub,
+ Function,
+ Property,
+ Do,
+ For,
+ While,
+ Select,
+ Try
+ }
+
+ public enum ConstructorInitializerType
+ {
+ None,
+ Base,
+ This
+ }
+
+ public enum ConversionType
+ {
+ None,
+ Implicit,
+ Explicit
+ }
+
+ public enum OverloadableOperatorType
+ {
+ None,
+
+ Add,
+ Subtract,
+ Multiply,
+ Divide,
+ Modulus,
+ Concat,
+
+ Not,
+ BitNot,
+
+ BitwiseAnd,
+ BitwiseOr,
+ ExclusiveOr,
+
+ ShiftLeft,
+ ShiftRight,
+
+ GreaterThan,
+ GreaterThanOrEqual,
+ Equality,
+ InEquality,
+ LessThan,
+ LessThanOrEqual,
+
+ Increment,
+ Decrement,
+
+ IsTrue,
+ IsFalse,
+
+ // VB specific
+ Like,
+ Power,
+ CType,
+ DivideInteger
+ }
+
+ ///
+ /// Charset types, used in external methods
+ /// declarations (VB only).
+ ///
+ public enum CharsetModifier
+ {
+ None,
+ Auto,
+ Unicode,
+ Ansi
+ }
+
+ ///
+ /// Compare type, used in the Option Compare
+ /// pragma (VB only).
+ ///
+ public enum OptionType
+ {
+ None,
+ Explicit,
+ Strict,
+ CompareBinary,
+ CompareText
+ }
+
+ ///
+ /// Specifies the ordering direction of a QueryExpressionOrdering node.
+ ///
+ public enum QueryExpressionOrderingDirection
+ {
+ None, Ascending, Descending
+ }
+}
diff --git a/lib/NRefactory/Project/Src/Ast/General/BlockStatement.cs b/lib/NRefactory/Project/Src/Ast/General/BlockStatement.cs
new file mode 100644
index 000000000..838bcdaae
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/General/BlockStatement.cs
@@ -0,0 +1,63 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+
+namespace ICSharpCode.NRefactory.Ast
+{
+ public class BlockStatement : Statement
+ {
+ // Children in C#: LabelStatement, LocalVariableDeclaration, Statement
+ // Children in VB: LabelStatement, EndStatement, Statement
+
+ public static new BlockStatement Null {
+ get {
+ return NullBlockStatement.Instance;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data)
+ {
+ return visitor.VisitBlockStatement(this, data);
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[BlockStatement: Children={0}]",
+ GetCollectionString(base.Children));
+ }
+ }
+
+ internal sealed class NullBlockStatement : BlockStatement
+ {
+ public static readonly NullBlockStatement Instance = new NullBlockStatement();
+
+ public override bool IsNull {
+ get {
+ return true;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data)
+ {
+ return data;
+ }
+ public override object AcceptChildren(IAstVisitor visitor, object data)
+ {
+ return data;
+ }
+ public override void AddChild(INode childNode)
+ {
+ throw new InvalidOperationException();
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[NullBlockStatement]");
+ }
+ }
+}
diff --git a/lib/NRefactory/Project/Src/Ast/General/CompilationUnit.cs b/lib/NRefactory/Project/Src/Ast/General/CompilationUnit.cs
new file mode 100644
index 000000000..9afb7ba43
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/General/CompilationUnit.cs
@@ -0,0 +1,60 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.NRefactory.Ast
+{
+ public class CompilationUnit : AbstractNode
+ {
+ // Children in C#: UsingAliasDeclaration, UsingDeclaration, AttributeSection, NamespaceDeclaration
+ // Children in VB: OptionStatements, ImportsStatement, AttributeSection, NamespaceDeclaration
+
+ Stack blockStack = new Stack();
+
+ public CompilationUnit()
+ {
+ blockStack.Push(this);
+ }
+
+ public void BlockStart(INode block)
+ {
+ blockStack.Push(block);
+ }
+
+ public void BlockEnd()
+ {
+ blockStack.Pop();
+ }
+
+ public INode CurrentBock {
+ get {
+ return blockStack.Count > 0 ? (INode)blockStack.Peek() : null;
+ }
+ }
+
+ public override void AddChild(INode childNode)
+ {
+ if (childNode != null) {
+ INode parent = (INode)blockStack.Peek();
+ parent.Children.Add(childNode);
+ childNode.Parent = parent;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data)
+ {
+ return visitor.VisitCompilationUnit(this, data);
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[CompilationUnit]");
+ }
+ }
+}
diff --git a/lib/NRefactory/Project/Src/Ast/General/Expression.cs b/lib/NRefactory/Project/Src/Ast/General/Expression.cs
new file mode 100644
index 000000000..8e2646a69
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/General/Expression.cs
@@ -0,0 +1,107 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+
+namespace ICSharpCode.NRefactory.Ast
+{
+ public abstract class Expression : AbstractNode, INullable
+ {
+ public static Expression Null {
+ get {
+ return NullExpression.Instance;
+ }
+ }
+
+ public virtual bool IsNull {
+ get {
+ return false;
+ }
+ }
+
+ public static Expression CheckNull(Expression expression)
+ {
+ return expression == null ? NullExpression.Instance : expression;
+ }
+
+ ///
+ /// Returns the existing expression plus the specified integer value.
+ /// The old object is not modified, but might be a subobject on the new expression
+ /// (and thus its parent property is modified).
+ ///
+ public static Expression AddInteger(Expression expr, int value)
+ {
+ PrimitiveExpression pe = expr as PrimitiveExpression;
+ if (pe != null && pe.Value is int) {
+ int newVal = (int)pe.Value + value;
+ return new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
+ }
+ BinaryOperatorExpression boe = expr as BinaryOperatorExpression;
+ if (boe != null && boe.Op == BinaryOperatorType.Add) {
+ // clone boe:
+ boe = new BinaryOperatorExpression(boe.Left, boe.Op, boe.Right);
+
+ boe.Right = AddInteger(boe.Right, value);
+ if (boe.Right is PrimitiveExpression && ((PrimitiveExpression)boe.Right).Value is int) {
+ int newVal = (int)((PrimitiveExpression)boe.Right).Value;
+ if (newVal == 0) {
+ return boe.Left;
+ } else if (newVal < 0) {
+ ((PrimitiveExpression)boe.Right).Value = -newVal;
+ boe.Op = BinaryOperatorType.Subtract;
+ }
+ }
+ return boe;
+ }
+ if (boe != null && boe.Op == BinaryOperatorType.Subtract) {
+ pe = boe.Right as PrimitiveExpression;
+ if (pe != null && pe.Value is int) {
+ int newVal = (int)pe.Value - value;
+ if (newVal == 0)
+ return boe.Left;
+
+ // clone boe:
+ boe = new BinaryOperatorExpression(boe.Left, boe.Op, boe.Right);
+
+ if (newVal < 0) {
+ newVal = -newVal;
+ boe.Op = BinaryOperatorType.Add;
+ }
+ boe.Right = new PrimitiveExpression(newVal, newVal.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
+ return boe;
+ }
+ }
+ BinaryOperatorType opType = BinaryOperatorType.Add;
+ if (value < 0) {
+ value = -value;
+ opType = BinaryOperatorType.Subtract;
+ }
+ return new BinaryOperatorExpression(expr, opType, new PrimitiveExpression(value, value.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
+ }
+ }
+
+ internal sealed class NullExpression : Expression
+ {
+ internal static readonly NullExpression Instance = new NullExpression();
+
+ public override bool IsNull {
+ get {
+ return true;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data)
+ {
+ return null;
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[NullExpression]");
+ }
+ }
+}
diff --git a/lib/NRefactory/Project/Src/Ast/General/LocalVariableDeclaration.cs b/lib/NRefactory/Project/Src/Ast/General/LocalVariableDeclaration.cs
new file mode 100644
index 000000000..79c00ce91
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/General/LocalVariableDeclaration.cs
@@ -0,0 +1,102 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace ICSharpCode.NRefactory.Ast
+{
+ public class LocalVariableDeclaration : Statement
+ {
+ TypeReference typeReference;
+ Modifiers modifier = Modifiers.None;
+ List variables = new List(1);
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = TypeReference.CheckNull(value);
+ }
+ }
+
+ public Modifiers Modifier {
+ get {
+ return modifier;
+ }
+ set {
+ modifier = value;
+ }
+ }
+
+ public List Variables {
+ get {
+ return variables;
+ }
+ }
+
+ public TypeReference GetTypeForVariable(int variableIndex)
+ {
+ if (!typeReference.IsNull) {
+ return typeReference;
+ }
+
+ for (int i = variableIndex; i < Variables.Count;++i) {
+ if (!((VariableDeclaration)Variables[i]).TypeReference.IsNull) {
+ return ((VariableDeclaration)Variables[i]).TypeReference;
+ }
+ }
+ return null;
+ }
+
+ public LocalVariableDeclaration(VariableDeclaration declaration) : this(TypeReference.Null)
+ {
+ Variables.Add(declaration);
+ }
+
+ public LocalVariableDeclaration(TypeReference typeReference)
+ {
+ this.TypeReference = typeReference;
+ }
+
+ public LocalVariableDeclaration(TypeReference typeReference, Modifiers modifier)
+ {
+ this.TypeReference = typeReference;
+ this.modifier = modifier;
+ }
+
+ public LocalVariableDeclaration(Modifiers modifier)
+ {
+ this.typeReference = TypeReference.Null;
+ this.modifier = modifier;
+ }
+
+ public VariableDeclaration GetVariableDeclaration(string variableName)
+ {
+ foreach (VariableDeclaration variableDeclaration in variables) {
+ if (variableDeclaration.Name == variableName) {
+ return variableDeclaration;
+ }
+ }
+ return null;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data)
+ {
+ return visitor.VisitLocalVariableDeclaration(this, data);
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[LocalVariableDeclaration: Type={0}, Modifier ={1} Variables={2}]",
+ typeReference,
+ modifier,
+ GetCollectionString(variables));
+ }
+ }
+}
diff --git a/lib/NRefactory/Project/Src/Ast/General/PrimitiveExpression.cs b/lib/NRefactory/Project/Src/Ast/General/PrimitiveExpression.cs
new file mode 100644
index 000000000..2922db553
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/General/PrimitiveExpression.cs
@@ -0,0 +1,55 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+
+namespace ICSharpCode.NRefactory.Ast
+{
+ public class PrimitiveExpression : Expression
+ {
+ object val;
+ string stringValue;
+
+ public object Value {
+ get {
+ return val;
+ }
+ set {
+ val = value;
+ }
+ }
+
+ public string StringValue {
+ get {
+ return stringValue;
+ }
+ set {
+ stringValue = value == null ? String.Empty : value;
+ }
+ }
+
+ public PrimitiveExpression(object val, string stringValue)
+ {
+ this.Value = val;
+ this.StringValue = stringValue;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data)
+ {
+ return visitor.VisitPrimitiveExpression(this, data);
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[PrimitiveExpression: Value={1}, ValueType={2}, StringValue={0}]",
+ stringValue,
+ Value,
+ Value == null ? "null" : Value.GetType().FullName
+ );
+ }
+ }
+}
diff --git a/lib/NRefactory/Project/Src/Ast/General/Statement.cs b/lib/NRefactory/Project/Src/Ast/General/Statement.cs
new file mode 100644
index 000000000..93aa718bb
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/General/Statement.cs
@@ -0,0 +1,66 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+
+namespace ICSharpCode.NRefactory.Ast
+{
+ public abstract class Statement : AbstractNode, INullable
+ {
+ public static Statement Null {
+ get {
+ return NullStatement.Instance;
+ }
+ }
+
+ public virtual bool IsNull {
+ get {
+ return false;
+ }
+ }
+
+ public static Statement CheckNull(Statement statement)
+ {
+ return statement ?? NullStatement.Instance;
+ }
+ }
+
+ public abstract class StatementWithEmbeddedStatement : Statement
+ {
+ Statement embeddedStatement;
+
+ public Statement EmbeddedStatement {
+ get {
+ return embeddedStatement;
+ }
+ set {
+ embeddedStatement = Statement.CheckNull(value);
+ if (value != null)
+ value.Parent = this;
+ }
+ }
+ }
+
+ internal sealed class NullStatement : Statement
+ {
+ public static readonly NullStatement Instance = new NullStatement();
+
+ public override bool IsNull {
+ get { return true; }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data)
+ {
+ return data;
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[NullStatement]");
+ }
+ }
+}
diff --git a/lib/NRefactory/Project/Src/Ast/Generated.cs b/lib/NRefactory/Project/Src/Ast/Generated.cs
new file mode 100644
index 000000000..e491c1f41
--- /dev/null
+++ b/lib/NRefactory/Project/Src/Ast/Generated.cs
@@ -0,0 +1,4956 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace ICSharpCode.NRefactory.Ast {
+ using System;
+ using System.Collections.Generic;
+
+
+ public class AddHandlerStatement : Statement {
+
+ Expression eventExpression;
+
+ Expression handlerExpression;
+
+ public Expression EventExpression {
+ get {
+ return eventExpression;
+ }
+ set {
+ eventExpression = value ?? Expression.Null;
+ if (!eventExpression.IsNull) eventExpression.Parent = this;
+ }
+ }
+
+ public Expression HandlerExpression {
+ get {
+ return handlerExpression;
+ }
+ set {
+ handlerExpression = value ?? Expression.Null;
+ if (!handlerExpression.IsNull) handlerExpression.Parent = this;
+ }
+ }
+
+ public AddHandlerStatement(Expression eventExpression, Expression handlerExpression) {
+ EventExpression = eventExpression;
+ HandlerExpression = handlerExpression;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitAddHandlerStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[AddHandlerStatement EventExpression={0} HandlerExpression={1}]", EventExpression, HandlerExpression);
+ }
+ }
+
+ public class AddressOfExpression : Expression {
+
+ Expression expression;
+
+ public Expression Expression {
+ get {
+ return expression;
+ }
+ set {
+ expression = value ?? Expression.Null;
+ if (!expression.IsNull) expression.Parent = this;
+ }
+ }
+
+ public AddressOfExpression(Expression expression) {
+ Expression = expression;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitAddressOfExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[AddressOfExpression Expression={0}]", Expression);
+ }
+ }
+
+ public class AnonymousMethodExpression : Expression {
+
+ List parameters;
+
+ BlockStatement body;
+
+ bool hasParameterList;
+
+ public List Parameters {
+ get {
+ return parameters;
+ }
+ set {
+ parameters = value ?? new List();
+ }
+ }
+
+ public BlockStatement Body {
+ get {
+ return body;
+ }
+ set {
+ body = value ?? BlockStatement.Null;
+ if (!body.IsNull) body.Parent = this;
+ }
+ }
+
+ public bool HasParameterList {
+ get {
+ return hasParameterList;
+ }
+ set {
+ hasParameterList = value;
+ }
+ }
+
+ public AnonymousMethodExpression() {
+ parameters = new List();
+ body = BlockStatement.Null;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitAnonymousMethodExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[AnonymousMethodExpression Parameters={0} Body={1} HasParameterList={2}]", GetCollectionString(Parameters), Body, HasParameterList);
+ }
+ }
+
+ public class ArrayCreateExpression : Expression {
+
+ TypeReference createType;
+
+ List arguments;
+
+ CollectionInitializerExpression arrayInitializer;
+
+ public TypeReference CreateType {
+ get {
+ return createType;
+ }
+ set {
+ createType = value ?? TypeReference.Null;
+ }
+ }
+
+ public List Arguments {
+ get {
+ return arguments;
+ }
+ set {
+ arguments = value ?? new List();
+ }
+ }
+
+ public CollectionInitializerExpression ArrayInitializer {
+ get {
+ return arrayInitializer;
+ }
+ set {
+ arrayInitializer = value ?? CollectionInitializerExpression.Null;
+ if (!arrayInitializer.IsNull) arrayInitializer.Parent = this;
+ }
+ }
+
+ public ArrayCreateExpression(TypeReference createType) {
+ CreateType = createType;
+ arguments = new List();
+ arrayInitializer = CollectionInitializerExpression.Null;
+ }
+
+ public ArrayCreateExpression(TypeReference createType, List arguments) {
+ CreateType = createType;
+ Arguments = arguments;
+ arrayInitializer = CollectionInitializerExpression.Null;
+ }
+
+ public ArrayCreateExpression(TypeReference createType, CollectionInitializerExpression arrayInitializer) {
+ CreateType = createType;
+ ArrayInitializer = arrayInitializer;
+ arguments = new List();
+ }
+
+ public bool IsImplicitlyTyped {
+ get {
+ return createType.IsNull || string.IsNullOrEmpty(createType.Type);
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitArrayCreateExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ArrayCreateExpression CreateType={0} Arguments={1} ArrayInitializer={2}]", CreateType, GetCollectionString(Arguments), ArrayInitializer);
+ }
+ }
+
+ public class AssignmentExpression : Expression {
+
+ Expression left;
+
+ AssignmentOperatorType op;
+
+ Expression right;
+
+ public Expression Left {
+ get {
+ return left;
+ }
+ set {
+ left = value ?? Expression.Null;
+ if (!left.IsNull) left.Parent = this;
+ }
+ }
+
+ public AssignmentOperatorType Op {
+ get {
+ return op;
+ }
+ set {
+ op = value;
+ }
+ }
+
+ public Expression Right {
+ get {
+ return right;
+ }
+ set {
+ right = value ?? Expression.Null;
+ if (!right.IsNull) right.Parent = this;
+ }
+ }
+
+ public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right) {
+ Left = left;
+ Op = op;
+ Right = right;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitAssignmentExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[AssignmentExpression Left={0} Op={1} Right={2}]", Left, Op, Right);
+ }
+ }
+
+ public class Attribute : AbstractNode {
+
+ string name;
+
+ List positionalArguments;
+
+ List namedArguments;
+
+ public string Name {
+ get {
+ return name;
+ }
+ set {
+ name = value ?? "";
+ }
+ }
+
+ public List PositionalArguments {
+ get {
+ return positionalArguments;
+ }
+ set {
+ positionalArguments = value ?? new List();
+ }
+ }
+
+ public List NamedArguments {
+ get {
+ return namedArguments;
+ }
+ set {
+ namedArguments = value ?? new List();
+ }
+ }
+
+ public Attribute() {
+ name = "";
+ positionalArguments = new List();
+ namedArguments = new List();
+ }
+
+ public Attribute(string name, List positionalArguments, List namedArguments) {
+ Name = name;
+ PositionalArguments = positionalArguments;
+ NamedArguments = namedArguments;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitAttribute(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[Attribute Name={0} PositionalArguments={1} NamedArguments={2}]", Name, GetCollectionString(PositionalArguments), GetCollectionString(NamedArguments));
+ }
+ }
+
+ public abstract class AttributedNode : AbstractNode {
+
+ List attributes;
+
+ Modifiers modifier;
+
+ public List Attributes {
+ get {
+ return attributes;
+ }
+ set {
+ attributes = value ?? new List();
+ }
+ }
+
+ public Modifiers Modifier {
+ get {
+ return modifier;
+ }
+ set {
+ modifier = value;
+ }
+ }
+
+ protected AttributedNode() {
+ attributes = new List();
+ }
+
+ protected AttributedNode(List attributes) {
+ Attributes = attributes;
+ }
+
+ protected AttributedNode(Modifiers modifier, List attributes) {
+ Modifier = modifier;
+ Attributes = attributes;
+ }
+ }
+
+ public class AttributeSection : AbstractNode {
+
+ string attributeTarget;
+
+ List attributes;
+
+ public string AttributeTarget {
+ get {
+ return attributeTarget;
+ }
+ set {
+ attributeTarget = value ?? "";
+ }
+ }
+
+ public List Attributes {
+ get {
+ return attributes;
+ }
+ set {
+ attributes = value ?? new List();
+ }
+ }
+
+ public AttributeSection() {
+ attributeTarget = "";
+ attributes = new List();
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitAttributeSection(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[AttributeSection AttributeTarget={0} Attributes={1}]", AttributeTarget, GetCollectionString(Attributes));
+ }
+ }
+
+ public class BaseReferenceExpression : Expression {
+
+ public BaseReferenceExpression() {
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitBaseReferenceExpression(this, data);
+ }
+
+ public override string ToString() {
+ return "[BaseReferenceExpression]";
+ }
+ }
+
+ public class BinaryOperatorExpression : Expression {
+
+ Expression left;
+
+ BinaryOperatorType op;
+
+ Expression right;
+
+ public Expression Left {
+ get {
+ return left;
+ }
+ set {
+ left = value ?? Expression.Null;
+ if (!left.IsNull) left.Parent = this;
+ }
+ }
+
+ public BinaryOperatorType Op {
+ get {
+ return op;
+ }
+ set {
+ op = value;
+ }
+ }
+
+ public Expression Right {
+ get {
+ return right;
+ }
+ set {
+ right = value ?? Expression.Null;
+ if (!right.IsNull) right.Parent = this;
+ }
+ }
+
+ public BinaryOperatorExpression(Expression left, BinaryOperatorType op, Expression right) {
+ Left = left;
+ Op = op;
+ Right = right;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitBinaryOperatorExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[BinaryOperatorExpression Left={0} Op={1} Right={2}]", Left, Op, Right);
+ }
+ }
+
+ public class BreakStatement : Statement {
+
+ public BreakStatement() {
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitBreakStatement(this, data);
+ }
+
+ public override string ToString() {
+ return "[BreakStatement]";
+ }
+ }
+
+ public class CaseLabel : AbstractNode {
+
+ Expression label;
+
+ BinaryOperatorType binaryOperatorType;
+
+ Expression toExpression;
+
+ public Expression Label {
+ get {
+ return label;
+ }
+ set {
+ label = value ?? Expression.Null;
+ if (!label.IsNull) label.Parent = this;
+ }
+ }
+
+ public BinaryOperatorType BinaryOperatorType {
+ get {
+ return binaryOperatorType;
+ }
+ set {
+ binaryOperatorType = value;
+ }
+ }
+
+ public Expression ToExpression {
+ get {
+ return toExpression;
+ }
+ set {
+ toExpression = value ?? Expression.Null;
+ if (!toExpression.IsNull) toExpression.Parent = this;
+ }
+ }
+
+ public CaseLabel() {
+ label = Expression.Null;
+ toExpression = Expression.Null;
+ }
+
+ public CaseLabel(Expression label) {
+ Label = label;
+ toExpression = Expression.Null;
+ }
+
+ public CaseLabel(Expression label, Expression toExpression) {
+ Label = label;
+ ToExpression = toExpression;
+ }
+
+ public CaseLabel(BinaryOperatorType binaryOperatorType, Expression label) {
+ BinaryOperatorType = binaryOperatorType;
+ Label = label;
+ toExpression = Expression.Null;
+ }
+
+ public bool IsDefault {
+ get {
+ return label.IsNull;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitCaseLabel(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[CaseLabel Label={0} BinaryOperatorType={1} ToExpression={2}]", Label, BinaryOperatorType, ToExpression);
+ }
+ }
+
+ public class CastExpression : Expression {
+
+ TypeReference castTo;
+
+ Expression expression;
+
+ CastType castType;
+
+ public TypeReference CastTo {
+ get {
+ return castTo;
+ }
+ set {
+ castTo = value ?? TypeReference.Null;
+ }
+ }
+
+ public Expression Expression {
+ get {
+ return expression;
+ }
+ set {
+ expression = value ?? Expression.Null;
+ if (!expression.IsNull) expression.Parent = this;
+ }
+ }
+
+ public CastType CastType {
+ get {
+ return castType;
+ }
+ set {
+ castType = value;
+ }
+ }
+
+ public CastExpression(TypeReference castTo) {
+ CastTo = castTo;
+ expression = Expression.Null;
+ }
+
+ public CastExpression(TypeReference castTo, Expression expression, CastType castType) {
+ CastTo = castTo;
+ Expression = expression;
+ CastType = castType;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitCastExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[CastExpression CastTo={0} Expression={1} CastType={2}]", CastTo, Expression, CastType);
+ }
+ }
+
+ public class CatchClause : AbstractNode {
+
+ TypeReference typeReference;
+
+ string variableName;
+
+ Statement statementBlock;
+
+ Expression condition;
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ public string VariableName {
+ get {
+ return variableName;
+ }
+ set {
+ variableName = value ?? "";
+ }
+ }
+
+ public Statement StatementBlock {
+ get {
+ return statementBlock;
+ }
+ set {
+ statementBlock = value ?? Statement.Null;
+ if (!statementBlock.IsNull) statementBlock.Parent = this;
+ }
+ }
+
+ public Expression Condition {
+ get {
+ return condition;
+ }
+ set {
+ condition = value ?? Expression.Null;
+ if (!condition.IsNull) condition.Parent = this;
+ }
+ }
+
+ public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock) {
+ TypeReference = typeReference;
+ VariableName = variableName;
+ StatementBlock = statementBlock;
+ condition = Expression.Null;
+ }
+
+ public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock, Expression condition) {
+ TypeReference = typeReference;
+ VariableName = variableName;
+ StatementBlock = statementBlock;
+ Condition = condition;
+ }
+
+ public CatchClause(Statement statementBlock) {
+ StatementBlock = statementBlock;
+ typeReference = TypeReference.Null;
+ variableName = "";
+ condition = Expression.Null;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitCatchClause(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[CatchClause TypeReference={0} VariableName={1} StatementBlock={2} Condition={3}]" +
+ "", TypeReference, VariableName, StatementBlock, Condition);
+ }
+ }
+
+ public class CheckedExpression : Expression {
+
+ Expression expression;
+
+ public Expression Expression {
+ get {
+ return expression;
+ }
+ set {
+ expression = value ?? Expression.Null;
+ if (!expression.IsNull) expression.Parent = this;
+ }
+ }
+
+ public CheckedExpression(Expression expression) {
+ Expression = expression;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitCheckedExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[CheckedExpression Expression={0}]", Expression);
+ }
+ }
+
+ public class CheckedStatement : Statement {
+
+ Statement block;
+
+ public Statement Block {
+ get {
+ return block;
+ }
+ set {
+ block = value ?? Statement.Null;
+ if (!block.IsNull) block.Parent = this;
+ }
+ }
+
+ public CheckedStatement(Statement block) {
+ Block = block;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitCheckedStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[CheckedStatement Block={0}]", Block);
+ }
+ }
+
+ public class ClassReferenceExpression : Expression {
+
+ public ClassReferenceExpression() {
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitClassReferenceExpression(this, data);
+ }
+
+ public override string ToString() {
+ return "[ClassReferenceExpression]";
+ }
+ }
+
+ public class CollectionInitializerExpression : Expression {
+
+ List createExpressions;
+
+ public List CreateExpressions {
+ get {
+ return createExpressions;
+ }
+ set {
+ createExpressions = value ?? new List();
+ }
+ }
+
+ public CollectionInitializerExpression() {
+ createExpressions = new List();
+ }
+
+ public CollectionInitializerExpression(List createExpressions) {
+ CreateExpressions = createExpressions;
+ }
+
+ public new static CollectionInitializerExpression Null {
+ get {
+ return NullCollectionInitializerExpression.Instance;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitCollectionInitializerExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[CollectionInitializerExpression CreateExpressions={0}]", GetCollectionString(CreateExpressions));
+ }
+ }
+
+ internal sealed class NullCollectionInitializerExpression : CollectionInitializerExpression {
+
+ internal static NullCollectionInitializerExpression Instance = new NullCollectionInitializerExpression();
+
+ public override bool IsNull {
+ get {
+ return true;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return null;
+ }
+
+ public override string ToString() {
+ return "[NullCollectionInitializerExpression]";
+ }
+ }
+
+ public class ConditionalExpression : Expression {
+
+ Expression condition;
+
+ Expression trueExpression;
+
+ Expression falseExpression;
+
+ public Expression Condition {
+ get {
+ return condition;
+ }
+ set {
+ condition = value ?? Expression.Null;
+ if (!condition.IsNull) condition.Parent = this;
+ }
+ }
+
+ public Expression TrueExpression {
+ get {
+ return trueExpression;
+ }
+ set {
+ trueExpression = value ?? Expression.Null;
+ if (!trueExpression.IsNull) trueExpression.Parent = this;
+ }
+ }
+
+ public Expression FalseExpression {
+ get {
+ return falseExpression;
+ }
+ set {
+ falseExpression = value ?? Expression.Null;
+ if (!falseExpression.IsNull) falseExpression.Parent = this;
+ }
+ }
+
+ public ConditionalExpression(Expression condition, Expression trueExpression, Expression falseExpression) {
+ Condition = condition;
+ TrueExpression = trueExpression;
+ FalseExpression = falseExpression;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitConditionalExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ConditionalExpression Condition={0} TrueExpression={1} FalseExpression={2}]", Condition, TrueExpression, FalseExpression);
+ }
+ }
+
+ public class ConstructorDeclaration : ParametrizedNode {
+
+ ConstructorInitializer constructorInitializer;
+
+ BlockStatement body;
+
+ public ConstructorInitializer ConstructorInitializer {
+ get {
+ return constructorInitializer;
+ }
+ set {
+ constructorInitializer = value ?? ConstructorInitializer.Null;
+ if (!constructorInitializer.IsNull) constructorInitializer.Parent = this;
+ }
+ }
+
+ public BlockStatement Body {
+ get {
+ return body;
+ }
+ set {
+ body = value ?? BlockStatement.Null;
+ if (!body.IsNull) body.Parent = this;
+ }
+ }
+
+ public ConstructorDeclaration(string name, Modifiers modifier, List parameters, List attributes) {
+ Name = name;
+ Modifier = modifier;
+ Parameters = parameters;
+ Attributes = attributes;
+ constructorInitializer = ConstructorInitializer.Null;
+ body = BlockStatement.Null;
+ }
+
+ public ConstructorDeclaration(string name, Modifiers modifier, List parameters, ConstructorInitializer constructorInitializer, List attributes) {
+ Name = name;
+ Modifier = modifier;
+ Parameters = parameters;
+ ConstructorInitializer = constructorInitializer;
+ Attributes = attributes;
+ body = BlockStatement.Null;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitConstructorDeclaration(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ConstructorDeclaration ConstructorInitializer={0} Body={1} Name={2} Parameters={" +
+ "3} Attributes={4} Modifier={5}]", ConstructorInitializer, Body, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ public class ConstructorInitializer : AbstractNode, INullable {
+
+ ConstructorInitializerType constructorInitializerType;
+
+ List arguments;
+
+ public ConstructorInitializerType ConstructorInitializerType {
+ get {
+ return constructorInitializerType;
+ }
+ set {
+ constructorInitializerType = value;
+ }
+ }
+
+ public List Arguments {
+ get {
+ return arguments;
+ }
+ set {
+ arguments = value ?? new List();
+ }
+ }
+
+ public ConstructorInitializer() {
+ arguments = new List();
+ }
+
+ public virtual bool IsNull {
+ get {
+ return false;
+ }
+ }
+
+ public static ConstructorInitializer Null {
+ get {
+ return NullConstructorInitializer.Instance;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitConstructorInitializer(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ConstructorInitializer ConstructorInitializerType={0} Arguments={1}]", ConstructorInitializerType, GetCollectionString(Arguments));
+ }
+ }
+
+ internal sealed class NullConstructorInitializer : ConstructorInitializer {
+
+ internal static NullConstructorInitializer Instance = new NullConstructorInitializer();
+
+ public override bool IsNull {
+ get {
+ return true;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return null;
+ }
+
+ public override string ToString() {
+ return "[NullConstructorInitializer]";
+ }
+ }
+
+ public class ContinueStatement : Statement {
+
+ ContinueType continueType;
+
+ public ContinueType ContinueType {
+ get {
+ return continueType;
+ }
+ set {
+ continueType = value;
+ }
+ }
+
+ public ContinueStatement() {
+ }
+
+ public ContinueStatement(ContinueType continueType) {
+ ContinueType = continueType;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitContinueStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ContinueStatement ContinueType={0}]", ContinueType);
+ }
+ }
+
+ public class DeclareDeclaration : ParametrizedNode {
+
+ string alias;
+
+ string library;
+
+ CharsetModifier charset;
+
+ TypeReference typeReference;
+
+ public string Alias {
+ get {
+ return alias;
+ }
+ set {
+ alias = value ?? "";
+ }
+ }
+
+ public string Library {
+ get {
+ return library;
+ }
+ set {
+ library = value ?? "";
+ }
+ }
+
+ public CharsetModifier Charset {
+ get {
+ return charset;
+ }
+ set {
+ charset = value;
+ }
+ }
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ public DeclareDeclaration(string name, Modifiers modifier, TypeReference typeReference, List parameters, List attributes, string library, string alias, CharsetModifier charset) {
+ Name = name;
+ Modifier = modifier;
+ TypeReference = typeReference;
+ Parameters = parameters;
+ Attributes = attributes;
+ Library = library;
+ Alias = alias;
+ Charset = charset;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitDeclareDeclaration(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[DeclareDeclaration Alias={0} Library={1} Charset={2} TypeReference={3} Name={4} " +
+ "Parameters={5} Attributes={6} Modifier={7}]", Alias, Library, Charset, TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ public class DefaultValueExpression : Expression {
+
+ TypeReference typeReference;
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ public DefaultValueExpression(TypeReference typeReference) {
+ TypeReference = typeReference;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitDefaultValueExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[DefaultValueExpression TypeReference={0}]", TypeReference);
+ }
+ }
+
+ public class DelegateDeclaration : AttributedNode {
+
+ string name;
+
+ TypeReference returnType;
+
+ List parameters;
+
+ List templates;
+
+ public string Name {
+ get {
+ return name;
+ }
+ set {
+ name = string.IsNullOrEmpty(value) ? "?" : value;
+ }
+ }
+
+ public TypeReference ReturnType {
+ get {
+ return returnType;
+ }
+ set {
+ returnType = value ?? TypeReference.Null;
+ }
+ }
+
+ public List Parameters {
+ get {
+ return parameters;
+ }
+ set {
+ parameters = value ?? new List();
+ }
+ }
+
+ public List Templates {
+ get {
+ return templates;
+ }
+ set {
+ templates = value ?? new List();
+ }
+ }
+
+ public DelegateDeclaration(Modifiers modifier, List attributes) {
+ Modifier = modifier;
+ Attributes = attributes;
+ name = "?";
+ returnType = TypeReference.Null;
+ parameters = new List();
+ templates = new List();
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitDelegateDeclaration(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[DelegateDeclaration Name={0} ReturnType={1} Parameters={2} Templates={3} Attribu" +
+ "tes={4} Modifier={5}]", Name, ReturnType, GetCollectionString(Parameters), GetCollectionString(Templates), GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ public class DestructorDeclaration : AttributedNode {
+
+ string name;
+
+ BlockStatement body;
+
+ public string Name {
+ get {
+ return name;
+ }
+ set {
+ name = value ?? "";
+ }
+ }
+
+ public BlockStatement Body {
+ get {
+ return body;
+ }
+ set {
+ body = value ?? BlockStatement.Null;
+ if (!body.IsNull) body.Parent = this;
+ }
+ }
+
+ public DestructorDeclaration(string name, Modifiers modifier, List attributes) {
+ Name = name;
+ Modifier = modifier;
+ Attributes = attributes;
+ body = BlockStatement.Null;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitDestructorDeclaration(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[DestructorDeclaration Name={0} Body={1} Attributes={2} Modifier={3}]", Name, Body, GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ public class DirectionExpression : Expression {
+
+ FieldDirection fieldDirection;
+
+ Expression expression;
+
+ public FieldDirection FieldDirection {
+ get {
+ return fieldDirection;
+ }
+ set {
+ fieldDirection = value;
+ }
+ }
+
+ public Expression Expression {
+ get {
+ return expression;
+ }
+ set {
+ expression = value ?? Expression.Null;
+ if (!expression.IsNull) expression.Parent = this;
+ }
+ }
+
+ public DirectionExpression(FieldDirection fieldDirection, Expression expression) {
+ FieldDirection = fieldDirection;
+ Expression = expression;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitDirectionExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[DirectionExpression FieldDirection={0} Expression={1}]", FieldDirection, Expression);
+ }
+ }
+
+ public class DoLoopStatement : StatementWithEmbeddedStatement {
+
+ Expression condition;
+
+ ConditionType conditionType;
+
+ ConditionPosition conditionPosition;
+
+ public Expression Condition {
+ get {
+ return condition;
+ }
+ set {
+ condition = value ?? Expression.Null;
+ if (!condition.IsNull) condition.Parent = this;
+ }
+ }
+
+ public ConditionType ConditionType {
+ get {
+ return conditionType;
+ }
+ set {
+ conditionType = value;
+ }
+ }
+
+ public ConditionPosition ConditionPosition {
+ get {
+ return conditionPosition;
+ }
+ set {
+ conditionPosition = value;
+ }
+ }
+
+ public DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition) {
+ Condition = condition;
+ EmbeddedStatement = embeddedStatement;
+ ConditionType = conditionType;
+ ConditionPosition = conditionPosition;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitDoLoopStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[DoLoopStatement Condition={0} ConditionType={1} ConditionPosition={2} EmbeddedSt" +
+ "atement={3}]", Condition, ConditionType, ConditionPosition, EmbeddedStatement);
+ }
+ }
+
+ public class ElseIfSection : StatementWithEmbeddedStatement {
+
+ Expression condition;
+
+ public Expression Condition {
+ get {
+ return condition;
+ }
+ set {
+ condition = value ?? Expression.Null;
+ if (!condition.IsNull) condition.Parent = this;
+ }
+ }
+
+ public ElseIfSection(Expression condition, Statement embeddedStatement) {
+ Condition = condition;
+ EmbeddedStatement = embeddedStatement;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitElseIfSection(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ElseIfSection Condition={0} EmbeddedStatement={1}]", Condition, EmbeddedStatement);
+ }
+ }
+
+ public class EmptyStatement : Statement {
+
+ public EmptyStatement() {
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitEmptyStatement(this, data);
+ }
+
+ public override string ToString() {
+ return "[EmptyStatement]";
+ }
+ }
+
+ public class EndStatement : Statement {
+
+ public EndStatement() {
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitEndStatement(this, data);
+ }
+
+ public override string ToString() {
+ return "[EndStatement]";
+ }
+ }
+
+ public class EraseStatement : Statement {
+
+ List expressions;
+
+ public List Expressions {
+ get {
+ return expressions;
+ }
+ set {
+ expressions = value ?? new List();
+ }
+ }
+
+ public EraseStatement() {
+ expressions = new List();
+ }
+
+ public EraseStatement(List expressions) {
+ Expressions = expressions;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitEraseStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[EraseStatement Expressions={0}]", GetCollectionString(Expressions));
+ }
+ }
+
+ public class ErrorStatement : Statement {
+
+ Expression expression;
+
+ public Expression Expression {
+ get {
+ return expression;
+ }
+ set {
+ expression = value ?? Expression.Null;
+ if (!expression.IsNull) expression.Parent = this;
+ }
+ }
+
+ public ErrorStatement(Expression expression) {
+ Expression = expression;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitErrorStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ErrorStatement Expression={0}]", Expression);
+ }
+ }
+
+ public class EventAddRegion : EventAddRemoveRegion {
+
+ public EventAddRegion(List attributes) :
+ base(attributes) {
+ }
+
+ public static EventAddRegion Null {
+ get {
+ return NullEventAddRegion.Instance;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitEventAddRegion(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[EventAddRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ internal sealed class NullEventAddRegion : EventAddRegion {
+
+ private NullEventAddRegion() :
+ base(null) {
+ }
+
+ internal static NullEventAddRegion Instance = new NullEventAddRegion();
+
+ public override bool IsNull {
+ get {
+ return true;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return null;
+ }
+
+ public override string ToString() {
+ return "[NullEventAddRegion]";
+ }
+ }
+
+ public abstract class EventAddRemoveRegion : AttributedNode, INullable {
+
+ BlockStatement block;
+
+ List parameters;
+
+ public BlockStatement Block {
+ get {
+ return block;
+ }
+ set {
+ block = value ?? BlockStatement.Null;
+ if (!block.IsNull) block.Parent = this;
+ }
+ }
+
+ public List Parameters {
+ get {
+ return parameters;
+ }
+ set {
+ parameters = value ?? new List();
+ }
+ }
+
+ protected EventAddRemoveRegion(List attributes) {
+ Attributes = attributes;
+ block = BlockStatement.Null;
+ parameters = new List();
+ }
+
+ public virtual bool IsNull {
+ get {
+ return false;
+ }
+ }
+ }
+
+ public class EventDeclaration : MemberNode {
+
+ EventAddRegion addRegion;
+
+ EventRemoveRegion removeRegion;
+
+ EventRaiseRegion raiseRegion;
+
+ Location bodyStart;
+
+ Location bodyEnd;
+
+ Expression initializer;
+
+ public EventAddRegion AddRegion {
+ get {
+ return addRegion;
+ }
+ set {
+ addRegion = value ?? EventAddRegion.Null;
+ }
+ }
+
+ public EventRemoveRegion RemoveRegion {
+ get {
+ return removeRegion;
+ }
+ set {
+ removeRegion = value ?? EventRemoveRegion.Null;
+ }
+ }
+
+ public EventRaiseRegion RaiseRegion {
+ get {
+ return raiseRegion;
+ }
+ set {
+ raiseRegion = value ?? EventRaiseRegion.Null;
+ }
+ }
+
+ public Location BodyStart {
+ get {
+ return bodyStart;
+ }
+ set {
+ bodyStart = value;
+ }
+ }
+
+ public Location BodyEnd {
+ get {
+ return bodyEnd;
+ }
+ set {
+ bodyEnd = value;
+ }
+ }
+
+ public Expression Initializer {
+ get {
+ return initializer;
+ }
+ set {
+ initializer = value ?? Expression.Null;
+ if (!initializer.IsNull) initializer.Parent = this;
+ }
+ }
+
+ public EventDeclaration() {
+ addRegion = EventAddRegion.Null;
+ removeRegion = EventRemoveRegion.Null;
+ raiseRegion = EventRaiseRegion.Null;
+ bodyStart = Location.Empty;
+ bodyEnd = Location.Empty;
+ initializer = Expression.Null;
+ }
+
+ public bool HasRaiseRegion {
+ get {
+ return !raiseRegion.IsNull;
+ }
+ }
+
+ public bool HasRemoveRegion {
+ get {
+ return !removeRegion.IsNull;
+ }
+ }
+
+ public bool HasAddRegion {
+ get {
+ return !addRegion.IsNull;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitEventDeclaration(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[EventDeclaration AddRegion={0} RemoveRegion={1} RaiseRegion={2} BodyStart={3} Bo" +
+ "dyEnd={4} Initializer={5} InterfaceImplementations={6} TypeReference={7} Name={8" +
+ "} Parameters={9} Attributes={10} Modifier={11}]", AddRegion, RemoveRegion, RaiseRegion, BodyStart, BodyEnd, Initializer, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ public class EventRaiseRegion : EventAddRemoveRegion {
+
+ public EventRaiseRegion(List attributes) :
+ base(attributes) {
+ }
+
+ public static EventRaiseRegion Null {
+ get {
+ return NullEventRaiseRegion.Instance;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitEventRaiseRegion(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[EventRaiseRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ internal sealed class NullEventRaiseRegion : EventRaiseRegion {
+
+ private NullEventRaiseRegion() :
+ base(null) {
+ }
+
+ internal static NullEventRaiseRegion Instance = new NullEventRaiseRegion();
+
+ public override bool IsNull {
+ get {
+ return true;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return null;
+ }
+
+ public override string ToString() {
+ return "[NullEventRaiseRegion]";
+ }
+ }
+
+ public class EventRemoveRegion : EventAddRemoveRegion {
+
+ public EventRemoveRegion(List attributes) :
+ base(attributes) {
+ }
+
+ public static EventRemoveRegion Null {
+ get {
+ return NullEventRemoveRegion.Instance;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitEventRemoveRegion(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[EventRemoveRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ internal sealed class NullEventRemoveRegion : EventRemoveRegion {
+
+ private NullEventRemoveRegion() :
+ base(null) {
+ }
+
+ internal static NullEventRemoveRegion Instance = new NullEventRemoveRegion();
+
+ public override bool IsNull {
+ get {
+ return true;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return null;
+ }
+
+ public override string ToString() {
+ return "[NullEventRemoveRegion]";
+ }
+ }
+
+ public class ExitStatement : Statement {
+
+ ExitType exitType;
+
+ public ExitType ExitType {
+ get {
+ return exitType;
+ }
+ set {
+ exitType = value;
+ }
+ }
+
+ public ExitStatement(ExitType exitType) {
+ ExitType = exitType;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitExitStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ExitStatement ExitType={0}]", ExitType);
+ }
+ }
+
+ public class ExpressionStatement : Statement {
+
+ Expression expression;
+
+ public Expression Expression {
+ get {
+ return expression;
+ }
+ set {
+ expression = value ?? Expression.Null;
+ if (!expression.IsNull) expression.Parent = this;
+ }
+ }
+
+ public ExpressionStatement(Expression expression) {
+ Expression = expression;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitExpressionStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ExpressionStatement Expression={0}]", Expression);
+ }
+ }
+
+ public class FieldDeclaration : AttributedNode {
+
+ TypeReference typeReference;
+
+ List fields;
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ public List Fields {
+ get {
+ return fields;
+ }
+ set {
+ fields = value ?? new List();
+ }
+ }
+
+ public FieldDeclaration(List attributes) {
+ Attributes = attributes;
+ typeReference = TypeReference.Null;
+ fields = new List();
+ }
+
+ public FieldDeclaration(List attributes, TypeReference typeReference, Modifiers modifier) {
+ Attributes = attributes;
+ TypeReference = typeReference;
+ Modifier = modifier;
+ fields = new List();
+ }
+
+
+ public TypeReference GetTypeForField(int fieldIndex)
+ {
+ if (!typeReference.IsNull) {
+ return typeReference;
+ }
+ return ((VariableDeclaration)Fields[fieldIndex]).TypeReference;
+ }
+
+
+ public VariableDeclaration GetVariableDeclaration(string variableName)
+ {
+ foreach (VariableDeclaration variableDeclaration in Fields) {
+ if (variableDeclaration.Name == variableName) {
+ return variableDeclaration;
+ }
+ }
+ return null;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitFieldDeclaration(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[FieldDeclaration TypeReference={0} Fields={1} Attributes={2} Modifier={3}]", TypeReference, GetCollectionString(Fields), GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ public class FixedStatement : StatementWithEmbeddedStatement {
+
+ TypeReference typeReference;
+
+ List pointerDeclarators;
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ public List PointerDeclarators {
+ get {
+ return pointerDeclarators;
+ }
+ set {
+ pointerDeclarators = value ?? new List();
+ }
+ }
+
+ public FixedStatement(TypeReference typeReference, List pointerDeclarators, Statement embeddedStatement) {
+ TypeReference = typeReference;
+ PointerDeclarators = pointerDeclarators;
+ EmbeddedStatement = embeddedStatement;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitFixedStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[FixedStatement TypeReference={0} PointerDeclarators={1} EmbeddedStatement={2}]", TypeReference, GetCollectionString(PointerDeclarators), EmbeddedStatement);
+ }
+ }
+
+ public class ForeachStatement : StatementWithEmbeddedStatement {
+
+ TypeReference typeReference;
+
+ string variableName;
+
+ Expression expression;
+
+ Expression nextExpression;
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ public string VariableName {
+ get {
+ return variableName;
+ }
+ set {
+ variableName = value ?? "";
+ }
+ }
+
+ public Expression Expression {
+ get {
+ return expression;
+ }
+ set {
+ expression = value ?? Expression.Null;
+ if (!expression.IsNull) expression.Parent = this;
+ }
+ }
+
+ public Expression NextExpression {
+ get {
+ return nextExpression;
+ }
+ set {
+ nextExpression = value ?? Expression.Null;
+ if (!nextExpression.IsNull) nextExpression.Parent = this;
+ }
+ }
+
+ public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement) {
+ TypeReference = typeReference;
+ VariableName = variableName;
+ Expression = expression;
+ EmbeddedStatement = embeddedStatement;
+ nextExpression = Expression.Null;
+ }
+
+ public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement, Expression nextExpression) {
+ TypeReference = typeReference;
+ VariableName = variableName;
+ Expression = expression;
+ EmbeddedStatement = embeddedStatement;
+ NextExpression = nextExpression;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitForeachStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ForeachStatement TypeReference={0} VariableName={1} Expression={2} NextExpressio" +
+ "n={3} EmbeddedStatement={4}]", TypeReference, VariableName, Expression, NextExpression, EmbeddedStatement);
+ }
+ }
+
+ public class ForNextStatement : StatementWithEmbeddedStatement {
+
+ Expression start;
+
+ Expression end;
+
+ Expression step;
+
+ List nextExpressions;
+
+ TypeReference typeReference;
+
+ string variableName;
+
+ public Expression Start {
+ get {
+ return start;
+ }
+ set {
+ start = value ?? Expression.Null;
+ if (!start.IsNull) start.Parent = this;
+ }
+ }
+
+ public Expression End {
+ get {
+ return end;
+ }
+ set {
+ end = value ?? Expression.Null;
+ if (!end.IsNull) end.Parent = this;
+ }
+ }
+
+ public Expression Step {
+ get {
+ return step;
+ }
+ set {
+ step = value ?? Expression.Null;
+ if (!step.IsNull) step.Parent = this;
+ }
+ }
+
+ public List NextExpressions {
+ get {
+ return nextExpressions;
+ }
+ set {
+ nextExpressions = value ?? new List();
+ }
+ }
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ public string VariableName {
+ get {
+ return variableName;
+ }
+ set {
+ variableName = value ?? "";
+ }
+ }
+
+ public ForNextStatement(TypeReference typeReference, string variableName, Expression start, Expression end, Expression step, Statement embeddedStatement, List nextExpressions) {
+ TypeReference = typeReference;
+ VariableName = variableName;
+ Start = start;
+ End = end;
+ Step = step;
+ EmbeddedStatement = embeddedStatement;
+ NextExpressions = nextExpressions;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitForNextStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ForNextStatement Start={0} End={1} Step={2} NextExpressions={3} TypeReference={4" +
+ "} VariableName={5} EmbeddedStatement={6}]", Start, End, Step, GetCollectionString(NextExpressions), TypeReference, VariableName, EmbeddedStatement);
+ }
+ }
+
+ public class ForStatement : StatementWithEmbeddedStatement {
+
+ List initializers;
+
+ Expression condition;
+
+ List iterator;
+
+ public List Initializers {
+ get {
+ return initializers;
+ }
+ set {
+ initializers = value ?? new List();
+ }
+ }
+
+ public Expression Condition {
+ get {
+ return condition;
+ }
+ set {
+ condition = value ?? Expression.Null;
+ if (!condition.IsNull) condition.Parent = this;
+ }
+ }
+
+ public List Iterator {
+ get {
+ return iterator;
+ }
+ set {
+ iterator = value ?? new List();
+ }
+ }
+
+ public ForStatement(List initializers, Expression condition, List iterator, Statement embeddedStatement) {
+ Initializers = initializers;
+ Condition = condition;
+ Iterator = iterator;
+ EmbeddedStatement = embeddedStatement;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitForStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[ForStatement Initializers={0} Condition={1} Iterator={2} EmbeddedStatement={3}]", GetCollectionString(Initializers), Condition, GetCollectionString(Iterator), EmbeddedStatement);
+ }
+ }
+
+ public class GotoCaseStatement : Statement {
+
+ Expression expression;
+
+ public Expression Expression {
+ get {
+ return expression;
+ }
+ set {
+ expression = value ?? Expression.Null;
+ if (!expression.IsNull) expression.Parent = this;
+ }
+ }
+
+ public GotoCaseStatement(Expression expression) {
+ Expression = expression;
+ }
+
+ public bool IsDefaultCase {
+ get {
+ return expression.IsNull;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitGotoCaseStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[GotoCaseStatement Expression={0}]", Expression);
+ }
+ }
+
+ public class GotoStatement : Statement {
+
+ string label;
+
+ public string Label {
+ get {
+ return label;
+ }
+ set {
+ label = value ?? "";
+ }
+ }
+
+ public GotoStatement(string label) {
+ Label = label;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitGotoStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[GotoStatement Label={0}]", Label);
+ }
+ }
+
+ public class IdentifierExpression : Expression {
+
+ string identifier;
+
+ List typeArguments;
+
+ public string Identifier {
+ get {
+ return identifier;
+ }
+ set {
+ identifier = value ?? "";
+ }
+ }
+
+ public List TypeArguments {
+ get {
+ return typeArguments;
+ }
+ set {
+ typeArguments = value ?? new List();
+ }
+ }
+
+ public IdentifierExpression(string identifier) {
+ Identifier = identifier;
+ typeArguments = new List();
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitIdentifierExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[IdentifierExpression Identifier={0} TypeArguments={1}]", Identifier, GetCollectionString(TypeArguments));
+ }
+ }
+
+ public class IfElseStatement : Statement {
+
+ Expression condition;
+
+ List trueStatement;
+
+ List falseStatement;
+
+ List elseIfSections;
+
+ public Expression Condition {
+ get {
+ return condition;
+ }
+ set {
+ condition = value ?? Expression.Null;
+ if (!condition.IsNull) condition.Parent = this;
+ }
+ }
+
+ public List TrueStatement {
+ get {
+ return trueStatement;
+ }
+ set {
+ trueStatement = value ?? new List();
+ }
+ }
+
+ public List FalseStatement {
+ get {
+ return falseStatement;
+ }
+ set {
+ falseStatement = value ?? new List();
+ }
+ }
+
+ public List ElseIfSections {
+ get {
+ return elseIfSections;
+ }
+ set {
+ elseIfSections = value ?? new List();
+ }
+ }
+
+ public IfElseStatement(Expression condition) {
+ Condition = condition;
+ trueStatement = new List();
+ falseStatement = new List();
+ elseIfSections = new List();
+ }
+
+ public bool HasElseIfSections {
+ get {
+ return elseIfSections.Count > 0;
+ }
+ }
+
+
+ public IfElseStatement(Expression condition, Statement trueStatement)
+ : this(condition) {
+ this.trueStatement.Add(Statement.CheckNull(trueStatement));
+ }
+
+
+ public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement)
+ : this(condition) {
+ this.trueStatement.Add(Statement.CheckNull(trueStatement));
+ this.falseStatement.Add(Statement.CheckNull(falseStatement));
+ }
+
+ public bool HasElseStatements {
+ get {
+ return falseStatement.Count > 0;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitIfElseStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[IfElseStatement Condition={0} TrueStatement={1} FalseStatement={2} ElseIfSection" +
+ "s={3}]", Condition, GetCollectionString(TrueStatement), GetCollectionString(FalseStatement), GetCollectionString(ElseIfSections));
+ }
+ }
+
+ public class IndexerDeclaration : AttributedNode {
+
+ List parameters;
+
+ List interfaceImplementations;
+
+ TypeReference typeReference;
+
+ Location bodyStart;
+
+ Location bodyEnd;
+
+ PropertyGetRegion getRegion;
+
+ PropertySetRegion setRegion;
+
+ public List Parameters {
+ get {
+ return parameters;
+ }
+ set {
+ parameters = value ?? new List();
+ }
+ }
+
+ public List InterfaceImplementations {
+ get {
+ return interfaceImplementations;
+ }
+ set {
+ interfaceImplementations = value ?? new List();
+ }
+ }
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ public Location BodyStart {
+ get {
+ return bodyStart;
+ }
+ set {
+ bodyStart = value;
+ }
+ }
+
+ public Location BodyEnd {
+ get {
+ return bodyEnd;
+ }
+ set {
+ bodyEnd = value;
+ }
+ }
+
+ public PropertyGetRegion GetRegion {
+ get {
+ return getRegion;
+ }
+ set {
+ getRegion = value ?? PropertyGetRegion.Null;
+ }
+ }
+
+ public PropertySetRegion SetRegion {
+ get {
+ return setRegion;
+ }
+ set {
+ setRegion = value ?? PropertySetRegion.Null;
+ }
+ }
+
+ public IndexerDeclaration(Modifiers modifier, List parameters, List attributes) {
+ Modifier = modifier;
+ Parameters = parameters;
+ Attributes = attributes;
+ interfaceImplementations = new List();
+ typeReference = TypeReference.Null;
+ bodyStart = Location.Empty;
+ bodyEnd = Location.Empty;
+ getRegion = PropertyGetRegion.Null;
+ setRegion = PropertySetRegion.Null;
+ }
+
+ public IndexerDeclaration(TypeReference typeReference, List parameters, Modifiers modifier, List attributes) {
+ TypeReference = typeReference;
+ Parameters = parameters;
+ Modifier = modifier;
+ Attributes = attributes;
+ interfaceImplementations = new List();
+ bodyStart = Location.Empty;
+ bodyEnd = Location.Empty;
+ getRegion = PropertyGetRegion.Null;
+ setRegion = PropertySetRegion.Null;
+ }
+
+ public bool HasSetRegion {
+ get {
+ return !setRegion.IsNull;
+ }
+ }
+
+ public bool HasGetRegion {
+ get {
+ return !getRegion.IsNull;
+ }
+ }
+
+ public bool IsReadOnly {
+ get {
+ return HasGetRegion && !HasSetRegion;
+ }
+ }
+
+ public bool IsWriteOnly {
+ get {
+ return !HasGetRegion && HasSetRegion;
+ }
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitIndexerDeclaration(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[IndexerDeclaration Parameters={0} InterfaceImplementations={1} TypeReference={2}" +
+ " BodyStart={3} BodyEnd={4} GetRegion={5} SetRegion={6} Attributes={7} Modifier={" +
+ "8}]", GetCollectionString(Parameters), GetCollectionString(InterfaceImplementations), TypeReference, BodyStart, BodyEnd, GetRegion, SetRegion, GetCollectionString(Attributes), Modifier);
+ }
+ }
+
+ public class IndexerExpression : Expression {
+
+ Expression targetObject;
+
+ List indexes;
+
+ public Expression TargetObject {
+ get {
+ return targetObject;
+ }
+ set {
+ targetObject = value ?? Expression.Null;
+ if (!targetObject.IsNull) targetObject.Parent = this;
+ }
+ }
+
+ public List Indexes {
+ get {
+ return indexes;
+ }
+ set {
+ indexes = value ?? new List();
+ }
+ }
+
+ public IndexerExpression(Expression targetObject, List indexes) {
+ TargetObject = targetObject;
+ Indexes = indexes;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitIndexerExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[IndexerExpression TargetObject={0} Indexes={1}]", TargetObject, GetCollectionString(Indexes));
+ }
+ }
+
+ public class InterfaceImplementation : AbstractNode {
+
+ TypeReference interfaceType;
+
+ string memberName;
+
+ public TypeReference InterfaceType {
+ get {
+ return interfaceType;
+ }
+ set {
+ interfaceType = value ?? TypeReference.Null;
+ }
+ }
+
+ public string MemberName {
+ get {
+ return memberName;
+ }
+ set {
+ memberName = string.IsNullOrEmpty(value) ? "?" : value;
+ }
+ }
+
+ public InterfaceImplementation(TypeReference interfaceType, string memberName) {
+ InterfaceType = interfaceType;
+ MemberName = memberName;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitInterfaceImplementation(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[InterfaceImplementation InterfaceType={0} MemberName={1}]", InterfaceType, MemberName);
+ }
+ }
+
+ public class InvocationExpression : Expression {
+
+ Expression targetObject;
+
+ List arguments;
+
+ public Expression TargetObject {
+ get {
+ return targetObject;
+ }
+ set {
+ targetObject = value ?? Expression.Null;
+ if (!targetObject.IsNull) targetObject.Parent = this;
+ }
+ }
+
+ public List Arguments {
+ get {
+ return arguments;
+ }
+ set {
+ arguments = value ?? new List();
+ }
+ }
+
+ public InvocationExpression(Expression targetObject) {
+ TargetObject = targetObject;
+ arguments = new List();
+ }
+
+ public InvocationExpression(Expression targetObject, List arguments) {
+ TargetObject = targetObject;
+ Arguments = arguments;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitInvocationExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[InvocationExpression TargetObject={0} Arguments={1}]", TargetObject, GetCollectionString(Arguments));
+ }
+ }
+
+ public class LabelStatement : Statement {
+
+ string label;
+
+ public string Label {
+ get {
+ return label;
+ }
+ set {
+ label = value ?? "";
+ }
+ }
+
+ public LabelStatement(string label) {
+ Label = label;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitLabelStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[LabelStatement Label={0}]", Label);
+ }
+ }
+
+ public class LambdaExpression : Expression {
+
+ List parameters;
+
+ BlockStatement statementBody;
+
+ Expression expressionBody;
+
+ public List Parameters {
+ get {
+ return parameters;
+ }
+ set {
+ parameters = value ?? new List();
+ }
+ }
+
+ public BlockStatement StatementBody {
+ get {
+ return statementBody;
+ }
+ set {
+ statementBody = value ?? BlockStatement.Null;
+ if (!statementBody.IsNull) statementBody.Parent = this;
+ }
+ }
+
+ public Expression ExpressionBody {
+ get {
+ return expressionBody;
+ }
+ set {
+ expressionBody = value ?? Expression.Null;
+ if (!expressionBody.IsNull) expressionBody.Parent = this;
+ }
+ }
+
+ public LambdaExpression() {
+ parameters = new List();
+ statementBody = BlockStatement.Null;
+ expressionBody = Expression.Null;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitLambdaExpression(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[LambdaExpression Parameters={0} StatementBody={1} ExpressionBody={2}]", GetCollectionString(Parameters), StatementBody, ExpressionBody);
+ }
+ }
+
+ public class LockStatement : StatementWithEmbeddedStatement {
+
+ Expression lockExpression;
+
+ public Expression LockExpression {
+ get {
+ return lockExpression;
+ }
+ set {
+ lockExpression = value ?? Expression.Null;
+ if (!lockExpression.IsNull) lockExpression.Parent = this;
+ }
+ }
+
+ public LockStatement(Expression lockExpression, Statement embeddedStatement) {
+ LockExpression = lockExpression;
+ EmbeddedStatement = embeddedStatement;
+ }
+
+ public override object AcceptVisitor(IAstVisitor visitor, object data) {
+ return visitor.VisitLockStatement(this, data);
+ }
+
+ public override string ToString() {
+ return string.Format("[LockStatement LockExpression={0} EmbeddedStatement={1}]", LockExpression, EmbeddedStatement);
+ }
+ }
+
+ public abstract class MemberNode : ParametrizedNode {
+
+ List interfaceImplementations;
+
+ TypeReference typeReference;
+
+ public List InterfaceImplementations {
+ get {
+ return interfaceImplementations;
+ }
+ set {
+ interfaceImplementations = value ?? new List();
+ }
+ }
+
+ public TypeReference TypeReference {
+ get {
+ return typeReference;
+ }
+ set {
+ typeReference = value ?? TypeReference.Null;
+ }
+ }
+
+ protected MemberNode() {
+ interfaceImplementations = new List();
+ typeReference = TypeReference.Null;
+ }
+
+ protected MemberNode(Modifiers modifier, List attributes, string name, List parameters) {
+ Modifier = modifier;
+ Attributes = attributes;
+ Name = name;
+ Parameters = parameters;
+ interfaceImplementations = new List();
+ typeReference = TypeReference.Null;
+ }
+ }
+
+ public class MemberReferenceExpression : Expression {
+
+ Expression targetObject;
+
+ string memberName;
+
+ List