diff --git a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs index 7b7a80ca9f..faf55af3e5 100644 --- a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs +++ b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs @@ -15,7 +15,7 @@ using B = Boo.Lang.Compiler.Ast; namespace NRefactoryToBooConverter { - public partial class ConvertVisitor : IASTVisitor + public partial class ConvertVisitor : IAstVisitor { string fileName; CompilerErrorCollection errors; diff --git a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorGlobal.cs b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorGlobal.cs index 4a06ca995b..42d513dd79 100644 --- a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorGlobal.cs +++ b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorGlobal.cs @@ -200,6 +200,11 @@ namespace NRefactoryToBooConverter throw new ApplicationException("Visited NamedArgumentExpression."); } + public object Visit(InterfaceImplementation interfaceImplementation, object data) + { + throw new ApplicationException("Visited InterfaceImplementation."); + } + public object Visit(OptionDeclaration optionDeclaration, object data) { AddError(optionDeclaration, "Option statement is not supported."); diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/CustomComponentsSideTab.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/CustomComponentsSideTab.cs index 39529a0164..7db39f2ebe 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/CustomComponentsSideTab.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/CustomComponentsSideTab.cs @@ -81,7 +81,7 @@ namespace ICSharpCode.FormsDesigner.Gui { string className; IProjectContent assemblyLocation; - bool initialized; + Assembly usedAssembly = null; public CustomComponentToolBoxItem(IClass c) { @@ -93,14 +93,12 @@ namespace ICSharpCode.FormsDesigner.Gui void Init() { - if (initialized) - return; - initialized = true; LoggingService.Debug("Initializing MyToolBoxItem: " + className); if (assemblyLocation != null) { Assembly asm = TypeResolutionService.LoadAssembly(assemblyLocation); - if (asm != null) { + if (asm != null && usedAssembly != asm) { Initialize(asm.GetType(className)); + usedAssembly = asm; } } } diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs index 87c26edcbb..b6ce61ea41 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs @@ -26,7 +26,9 @@ namespace ICSharpCode.FormsDesigner.Services public class TypeResolutionService : ITypeResolutionService { readonly static List designerAssemblies = new List(); - // hash of file content -> Assembly + /// + /// string "filename:size" -> Assembly + /// readonly static Dictionary assemblyDict = new Dictionary(); /// @@ -137,7 +139,8 @@ namespace ICSharpCode.FormsDesigner.Services if (!File.Exists(fileName)) return null; byte[] data = File.ReadAllBytes(fileName); - string hash; + + string hash = fileName + ":" + File.GetLastWriteTimeUtc(fileName); using (HashFunction hashFunction = new HashFunction()) { hash = Convert.ToBase64String(hashFunction.ComputeHash(data)); } @@ -262,18 +265,11 @@ namespace ICSharpCode.FormsDesigner.Services return null; } try { - lock (designerAssemblies) { - foreach (Assembly asm in DesignerAssemblies) { - Type t = asm.GetType(name, false); - if (t != null) { - return t; - } - } - } - Type type = Type.GetType(name, false, ignoreCase); + Type type = null; + int idx = name.IndexOf(","); - if (type == null) { + if (idx < 0) { IProjectContent pc = this.CallingProject; if (pc != null) { IClass foundClass = pc.GetClass(name); @@ -287,26 +283,34 @@ namespace ICSharpCode.FormsDesigner.Services } // type lookup for typename, assembly, xyz style lookups - if (type == null) { - int idx = name.IndexOf(","); - if (idx > 0) { - string[] splitName = name.Split(','); - string typeName = splitName[0]; - string assemblyName = splitName[1].Substring(1); - Assembly assembly = null; - try { - assembly = Assembly.Load(assemblyName); - } catch (Exception e) { - LoggingService.Error(e); + if (type == null && idx > 0) { + string[] splitName = name.Split(','); + string typeName = splitName[0]; + string assemblyName = splitName[1].Substring(1); + Assembly assembly = null; + try { + assembly = Assembly.Load(assemblyName); + } catch (Exception e) { + LoggingService.Error(e); + } + if (assembly != null) { + lock (designerAssemblies) { + if (!designerAssemblies.Contains(assembly)) + designerAssemblies.Add(assembly); } - if (assembly != null) { - lock (designerAssemblies) { - if (!designerAssemblies.Contains(assembly)) - designerAssemblies.Add(assembly); + type = assembly.GetType(typeName, false, ignoreCase); + } else { + type = Type.GetType(typeName, false, ignoreCase); + } + } + + if (type == null) { + lock (designerAssemblies) { + foreach (Assembly asm in DesignerAssemblies) { + Type t = asm.GetType(name, false); + if (t != null) { + return t; } - type = assembly.GetType(typeName, false, ignoreCase); - } else { - type = Type.GetType(typeName, false, ignoreCase); } } } diff --git a/src/AddIns/Misc/PInvokeAddIn/Project/Src/PInvokeRepository.cs b/src/AddIns/Misc/PInvokeAddIn/Project/Src/PInvokeRepository.cs index 57c8121f73..6f1cfcef2a 100644 --- a/src/AddIns/Misc/PInvokeAddIn/Project/Src/PInvokeRepository.cs +++ b/src/AddIns/Misc/PInvokeAddIn/Project/Src/PInvokeRepository.cs @@ -5,7 +5,6 @@ // $Revision$ // - using System; using System.Collections; using System.IO; diff --git a/src/Libraries/NRefactory/NRefactory.sln b/src/Libraries/NRefactory/NRefactory.sln index 8ff1042c9e..ba29e40f01 100644 --- a/src/Libraries/NRefactory/NRefactory.sln +++ b/src/Libraries/NRefactory/NRefactory.sln @@ -1,11 +1,13 @@ Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.0.0.825 +# SharpDevelop 2.0.0.973 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryTests", "Test\NRefactoryTests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.framework.dll", "..\NUnit.Framework\nunit.framework.dll.csproj", "{83DD7E12-A705-4DBA-9D71-09C8973D9382}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -24,6 +26,10 @@ Global {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Release|Any CPU.Build.0 = Release|Any CPU {83DD7E12-A705-4DBA-9D71-09C8973D9382}.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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs new file mode 100644 index 0000000000..d70f6a766a --- /dev/null +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs @@ -0,0 +1,237 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.AST +{ + [CustomImplementation] + abstract class Expression : AbstractNode {} + + [CustomImplementation] + class PrimitiveExpression : Expression {} + + enum ParamModifier { In } + + class ParameterDeclarationExpression : Expression { + List attributes; + [QuestionMarkDefault] + string parameterName; + TypeReference typeReference; + ParamModifier paramModifier; + Expression defaultValue; + + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName) {} + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParamModifier paramModifier) {} + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParamModifier paramModifier, Expression defaultValue) {} + } + + class NamedArgumentExpression : Expression { + string name; + Expression expression; + + public NamedArgumentExpression(string name, Expression expression) {} + } + + class ArrayCreateExpression : Expression { + TypeReference createType; + List arguments; + ArrayInitializerExpression arrayInitializer; + + public ArrayCreateExpression(TypeReference createType) {} + public ArrayCreateExpression(TypeReference createType, List arguments) {} + public ArrayCreateExpression(TypeReference createType, ArrayInitializerExpression arrayInitializer) {} + } + + [ImplementNullable(NullableImplementation.Shadow)] + class ArrayInitializerExpression : Expression { + List createExpressions; + + public ArrayInitializerExpression() {} + public ArrayInitializerExpression(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) {} + } + + class FieldReferenceExpression : Expression + { + Expression targetObject; + string fieldName; + + public FieldReferenceExpression(Expression targetObject, string fieldName) {} + } + + class IdentifierExpression : Expression { + string identifier; + + public IdentifierExpression(string identifier) {} + } + + class InvocationExpression : Expression { + Expression targetObject; + List arguments; + List typeArguments; + + public InvocationExpression(Expression targetObject) {} + public InvocationExpression(Expression targetObject, List arguments) {} + public InvocationExpression(Expression targetObject, List arguments, List typeArguments) {} + } + + class ObjectCreateExpression : Expression { + TypeReference createType; + List parameters; + + public ObjectCreateExpression(TypeReference createType, List parameters) {} + } + + 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; + } + + 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 indices; + + public IndexerExpression(Expression targetObject, List indices) {} + } + + class PointerReferenceExpression : Expression { + Expression targetObject; + string identifier; + + public PointerReferenceExpression(Expression targetObject, string identifier) {} + } + + 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) {} + } +} diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/GlobalLevel.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/GlobalLevel.cs new file mode 100644 index 0000000000..1386a08155 --- /dev/null +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/GlobalLevel.cs @@ -0,0 +1,94 @@ +// +// +// +// +// $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(Modifier 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; + + public TypeDeclaration(Modifier 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/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs new file mode 100644 index 0000000000..be42378556 --- /dev/null +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs @@ -0,0 +1,67 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.AST +{ + interface INode {} + interface INullable {} + struct Point {} + + enum Modifier { None } + + [CustomImplementation] + abstract class AbstractNode : INode {} + + abstract class AttributedNode : AbstractNode + { + List attributes; + Modifier modifier; + + public AttributedNode(List attributes) {} + public AttributedNode(Modifier modifier, List attributes) {} + } + + abstract class ParametrizedNode : AttributedNode + { + string name; + List parameters; + + public ParametrizedNode(Modifier modifier, List attributes, + string name, List parameters) + : base(modifier, attributes) + {} + + public ParametrizedNode(Modifier modifier, List attributes) + : base(modifier, attributes) + {} + } + + [CustomImplementation] + class TypeReference : AbstractNode {} + [CustomImplementation] + class InnerClassTypeReference : TypeReference {} + + class AttributeSection : AbstractNode, INullable + { + string attributeTarget; + List attributes; + + public AttributeSection(string attributeTarget, List attributes) {} + } + + class Attribute : AbstractNode + { + string name; + List positionalArguments; + List namedArguments; + + public Attribute(string name, List positionalArguments, List namedArguments) {} + } +} diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Statements.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Statements.cs new file mode 100644 index 0000000000..895e33b401 --- /dev/null +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Statements.cs @@ -0,0 +1,314 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.AST +{ + [CustomImplementation] + abstract class Statement : AbstractNode {} + + [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; + Modifier modifier; + List variables; + } + + class LockStatement : StatementWithEmbeddedStatement + { + Expression lockExpression; + + public LockStatement(Expression lockExpression, Statement embeddedStatement) {} + } + + class ReturnStatement : Statement + { + Expression expression; + + public ReturnStatement(Expression expression) { } + } + + class StatementExpression : Statement { + Expression expression; + + public StatementExpression(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/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs new file mode 100644 index 0000000000..ed643f9c98 --- /dev/null +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs @@ -0,0 +1,284 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace NRefactoryASTGenerator.AST +{ + class VariableDeclaration : AbstractNode + { + string name; + Expression initializer; + TypeReference typeReference; + + 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, Modifier modifier, + List parameters, + List attributes) + : base(modifier, attributes, name, parameters) + {} + + public ConstructorDeclaration(string name, Modifier modifier, + List parameters, + ConstructorInitializer constructorInitializer, + List attributes) + : base(modifier, attributes, name, parameters) + {} + } + + enum ConstructorInitializerType { None } + + [ImplementNullable] + class ConstructorInitializer : AbstractNode + { + 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 : ParametrizedNode + { + TypeReference typeReference; + List interfaceImplementations; + EventAddRegion addRegion; + EventRemoveRegion removeRegion; + EventRaiseRegion raiseRegion; + Point bodyStart; + Point bodyEnd; + + public EventDeclaration(TypeReference typeReference, string name, Modifier modifier, List attributes, List parameters) + : base(modifier, attributes, name, parameters) + { } + + // for VB: + public EventDeclaration(TypeReference typeReference, Modifier modifier, List parameters, List attributes, string name, List interfaceImplementations) + : base(modifier, attributes, name, parameters) + { } + } + + [IncludeMember(@" + public TypeReference GetTypeForField(int fieldIndex) + { + if (!typeReference.IsNull) { + return typeReference; + } + + for (int i = fieldIndex; i < Fields.Count;++i) { + if (!((VariableDeclaration)Fields[i]).TypeReference.IsNull) { + return ((VariableDeclaration)Fields[i]).TypeReference; + } + } + return TypeReference.Null; + }")] + [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, Modifier modifier) + : base(modifier, attributes) + {} + } + + class MethodDeclaration : ParametrizedNode + { + TypeReference typeReference; + BlockStatement body; + List handlesClause; + List interfaceImplementations; + List templates; + + public MethodDeclaration(string name, Modifier modifier, TypeReference typeReference, List parameters, List attributes) : base(modifier, attributes, name, parameters) {} + } + + enum ConversionType { None } + enum OverloadableOperatorType { None } + + [IncludeBoolProperty("IsConversionOperator", "return conversionType != ConversionType.None;")] + [FixOperatorDeclarationAttribute] + class OperatorDeclaration : MethodDeclaration + { + ConversionType conversionType; + List returnTypeAttributes; + OverloadableOperatorType overloadableOperator; + + public OperatorDeclaration(Modifier modifier, + List attributes, + List parameters, + TypeReference typeReference, + ConversionType conversionType) + : base(null, modifier, typeReference, parameters, attributes) + {} + + public OperatorDeclaration(Modifier modifier, + List attributes, + List parameters, + TypeReference typeReference, + OverloadableOperatorType overloadableOperator) + : base(null, modifier, typeReference, parameters, attributes) + {} + } + + [IncludeBoolProperty("HasGetRegion", "return !getRegion.IsNull;")] + [IncludeBoolProperty("HasSetRegion", "return !setRegion.IsNull;")] + [IncludeBoolProperty("IsReadOnly", "return HasGetRegion && !HasSetRegion;")] + [IncludeBoolProperty("IsWriteOnly", "return !HasGetRegion && HasSetRegion;")] + [IncludeMember(@" + public PropertyDeclaration(string name, TypeReference typeReference, Modifier modifier, List attributes) : this(modifier, attributes, name, null) + { + this.TypeReference = typeReference; + if ((modifier & Modifier.ReadOnly) == Modifier.ReadOnly) { + this.GetRegion = new PropertyGetRegion(null, null); + } else if ((modifier & Modifier.WriteOnly) == Modifier.WriteOnly) { + this.SetRegion = new PropertySetRegion(null, null); + } + }")] + class PropertyDeclaration : ParametrizedNode + { + List interfaceImplementations; + TypeReference typeReference; + Point bodyStart; + Point bodyEnd; + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + + public PropertyDeclaration(Modifier 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, Modifier 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; + Point bodyStart; + Point bodyEnd; + PropertyGetRegion getRegion; + PropertySetRegion setRegion; + + public IndexerDeclaration(Modifier modifier, List parameters, List attributes) + : base(modifier, attributes) + {} + + public IndexerDeclaration(TypeReference typeReference, List parameters, Modifier modifier, List attributes) + : base(modifier, attributes) + {} + } + + enum CharsetModifier { None } + + class DeclareDeclaration : ParametrizedNode + { + string alias; + string library; + CharsetModifier charset; + TypeReference typeReference; + + public DeclareDeclaration(string name, Modifier modifier, TypeReference typeReference, List parameters, List attributes, string library, string alias, CharsetModifier charset) + : base(modifier, attributes, name, parameters) + {} + } +} diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AssemblyInfo.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AssemblyInfo.cs new file mode 100644 index 0000000000..3114526822 --- /dev/null +++ b/src/Libraries/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/src/Libraries/NRefactory/NRefactoryASTGenerator/Attributes.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/Attributes.cs new file mode 100644 index 0000000000..19cac1a2fc --- /dev/null +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/Attributes.cs @@ -0,0 +1,198 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.CodeDom; + +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)] + public class FixOperatorDeclarationAttribute : TypeImplementationModifierAttribute + { + public override void ModifyImplementation(CodeNamespace cns, CodeTypeDeclaration ctd, Type type) + { + foreach (object o in ctd.Members) { + CodeConstructor cc = o as CodeConstructor; + if (cc != null) { + cc.BaseConstructorArgs[0] = new CodePrimitiveExpression(null); + } + } + } + } + + [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(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) { + CodeTypeDeclaration newType = new CodeTypeDeclaration("Null" + ctd.Name); + newType.BaseTypes.Add(new CodeTypeReference(ctd.Name)); + cns.Types.Add(newType); + + System.Reflection.ConstructorInfo baseCtor = MainClass.GetBaseCtor(type); + CodeConstructor ctor = new CodeConstructor(); + ctor.Attributes = MemberAttributes.Private; + if (baseCtor != null) { + 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; + field.InitExpression = new CodeObjectCreateExpression(new CodeTypeReference(newType.Name)); + newType.Members.Add(field); + + CodeMemberProperty prop = new CodeMemberProperty(); + prop.Name = "Instance"; + prop.Type = new CodeTypeReference(newType.Name); + prop.Attributes = MemberAttributes.Public | MemberAttributes.Static; + prop.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression("instance"))); + newType.Members.Add(prop); + + 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/src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs new file mode 100644 index 0000000000..77af3c9e03 --- /dev/null +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs @@ -0,0 +1,231 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.CodeDom; +using System.Diagnostics; +using System.Reflection; +using System.IO; +using NRefactoryASTGenerator.AST; + +namespace NRefactoryASTGenerator +{ + class MainClass + { + public static void Main(string[] args) + { + string directory = "../../../Project/Src/Parser/AST/"; + string visitorsDir = "../../../Project/Src/Parser/Visitors/"; + Debug.WriteLine("AST Generator running..."); + if (!File.Exists(directory + "INode.cs")) { + Debug.WriteLine("did not find output directory"); + return; + } + if (!File.Exists(visitorsDir + "IASTVisitor.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); }); + + CodeCompileUnit ccu = new CodeCompileUnit(); + CodeNamespace cns = new CodeNamespace("ICSharpCode.NRefactory.Parser.AST"); + ccu.Namespaces.Add(cns); + cns.Imports.Add(new CodeNamespaceImport("System")); + cns.Imports.Add(new CodeNamespaceImport("System.Collections.Generic")); + cns.Imports.Add(new CodeNamespaceImport("System.Diagnostics")); + cns.Imports.Add(new CodeNamespaceImport("System.Drawing")); + foreach (Type type in nodeTypes) { + if (type.GetCustomAttributes(typeof(CustomImplementationAttribute), false).Length == 0) { + CodeTypeDeclaration ctd = new CodeTypeDeclaration(type.Name); + if (type.IsAbstract) { + ctd.TypeAttributes |= TypeAttributes.Abstract; + } + ctd.BaseTypes.Add(new CodeTypeReference(type.BaseType.Name)); + cns.Types.Add(ctd); + + 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, "Visit", + 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); + } + } + } + + using (StringWriter writer = new StringWriter()) { + new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromCompileUnit(ccu, writer, null); + File.WriteAllText(directory + "Generated.cs", writer.ToString()); + } + } + + 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, CodeTypeDeclaration ctd) + { + foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) { + CodeMemberField f = new CodeMemberField(ConvertType(field.FieldType), field.Name); + f.Attributes = 0; + ctd.Members.Add(f); + } + foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) { + CodeMemberProperty p = new CodeMemberProperty(); + p.Name = GetPropertyName(field.Name); + p.Attributes = MemberAttributes.Public | MemberAttributes.Final; + p.Type = ConvertType(field.FieldType); + p.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression(field.Name))); + CodeExpression ex; + if (field.FieldType.IsValueType) + ex = new CodePropertySetValueReferenceExpression(); + else + ex = GetDefaultValue("value", field); + p.SetStatements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(field.Name), ex)); + ctd.Members.Add(p); + } + foreach (ConstructorInfo ctor in type.GetConstructors()) { + CodeConstructor c = new CodeConstructor(); + 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(Point)) + 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(Point)) { + code = "new Point(-1, -1)"; + } else { + code = field.FieldType.Name + ".Null"; + } + if (inputVariable != null) { + code = inputVariable + " ?? " + code; + } + return new CodeSnippetExpression(code); + } + + 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")) { + return new CodeTypeReference(type.Name); + } else { + return new CodeTypeReference(type); + } + } + } +} diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj b/src/Libraries/NRefactory/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj new file mode 100644 index 0000000000..21769a6855 --- /dev/null +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/NRefactoryASTGenerator.csproj @@ -0,0 +1,55 @@ + + + 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/src/Libraries/NRefactory/Project/Configuration/AssemblyInfo.cs b/src/Libraries/NRefactory/Project/Configuration/AssemblyInfo.cs index 0c12695ca5..a888544cfb 100644 --- a/src/Libraries/NRefactory/Project/Configuration/AssemblyInfo.cs +++ b/src/Libraries/NRefactory/Project/Configuration/AssemblyInfo.cs @@ -19,7 +19,7 @@ using System.Runtime.CompilerServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("ic#code")] [assembly: AssemblyProduct("SharpDevelop")] -[assembly: AssemblyCopyright("2004-2005 AlphaSierraPapa")] +[assembly: AssemblyCopyright("2004-2006 AlphaSierraPapa")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/Libraries/NRefactory/Project/NRefactory.csproj b/src/Libraries/NRefactory/Project/NRefactory.csproj index a3820a3983..2ba511e9fc 100644 --- a/src/Libraries/NRefactory/Project/NRefactory.csproj +++ b/src/Libraries/NRefactory/Project/NRefactory.csproj @@ -88,98 +88,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -190,21 +99,27 @@ - - - - + + + + + + + + + + @@ -213,10 +128,6 @@ - - - - \ No newline at end of file diff --git a/src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs index 588fef5861..fedea813ed 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs @@ -639,6 +639,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter return null; } + public object Visit(InterfaceImplementation interfaceImplementation, object data) + { + throw new InvalidOperationException(); + } + public object Visit(ConstructorDeclaration constructorDeclaration, object data) { VisitAttributes(constructorDeclaration.Attributes, data); diff --git a/src/Libraries/NRefactory/Project/Src/Output/IOutputASTVisitor.cs b/src/Libraries/NRefactory/Project/Src/Output/IOutputASTVisitor.cs index 3c2bb42f0a..2c333957e3 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/IOutputASTVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/IOutputASTVisitor.cs @@ -19,7 +19,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter /// /// Description of IOutputASTVisitor. /// - public interface IOutputASTVisitor : IASTVisitor + public interface IOutputASTVisitor : IAstVisitor { string Text { get; diff --git a/src/Libraries/NRefactory/Project/Src/Output/NodeInformVisitor.cs b/src/Libraries/NRefactory/Project/Src/Output/NodeInformVisitor.cs index be72d94af2..4234af03e9 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/NodeInformVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/NodeInformVisitor.cs @@ -20,15 +20,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter public class NodeTracker { - IASTVisitor callVisitor; + IAstVisitor callVisitor; - public IASTVisitor CallVisitor { + public IAstVisitor CallVisitor { get { return callVisitor; } } - public NodeTracker(IASTVisitor callVisitor) + public NodeTracker(IAstVisitor callVisitor) { this.callVisitor = callVisitor; } diff --git a/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs index 94716e47b2..5f55ee0dfa 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs @@ -837,6 +837,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter return null; } + public object Visit(InterfaceImplementation interfaceImplementation, object data) + { + throw new InvalidOperationException(); + } + bool IsAbstract(AttributedNode node) { if ((node.Modifier & Modifier.Abstract) == Modifier.Abstract) diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/AbstractNode.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/AbstractNode.cs index cae4081761..d58174209f 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/AbstractNode.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/AbstractNode.cs @@ -65,9 +65,9 @@ namespace ICSharpCode.NRefactory.Parser.AST children.Add(childNode); } - public abstract object AcceptVisitor(IASTVisitor visitor, object data); + public abstract object AcceptVisitor(IAstVisitor visitor, object data); - public virtual object AcceptChildren(IASTVisitor visitor, object data) + public virtual object AcceptChildren(IAstVisitor visitor, object data) { foreach (INode child in children) { Debug.Assert(child != null); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/AttributedNode.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/AttributedNode.cs deleted file mode 100644 index 69af8866f0..0000000000 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/AttributedNode.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Diagnostics; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.Parser.AST -{ - public abstract class AttributedNode : AbstractNode - { - protected List attributes; - protected Modifier modifier; - - public List Attributes { - get { - return attributes; - } - set { - attributes = value == null ? new List(1) : value; - } - } - - public Modifier Modifier { - get { - return modifier; - } - set { - modifier = value; - } - } - - public AttributedNode(List attributes) : this(Modifier.None, attributes) - { - } - - public AttributedNode(Modifier modifier, List attributes) - { - this.modifier = modifier; - - // use property because of the null check. - this.Attributes = attributes; - } - - } -} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Enums.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/Enums.cs similarity index 52% rename from src/Libraries/NRefactory/Project/Src/Parser/AST/General/Enums.cs rename to src/Libraries/NRefactory/Project/Src/Parser/AST/Enums.cs index f0703f3136..ccea23e27f 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Enums.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/Enums.cs @@ -116,4 +116,244 @@ namespace ICSharpCode.NRefactory.Parser.AST 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, + + Star, + 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, + + True, + False, + + // VB specific + IsTrue, + IsFalse, + 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 + } } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/AttributeSection.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/AttributeSection.cs deleted file mode 100644 index f74131a930..0000000000 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/AttributeSection.cs +++ /dev/null @@ -1,180 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Diagnostics; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.Parser.AST -{ - public class NamedArgumentExpression : Expression - { - string name; - Expression expression; - - public string Name { - get { - return name; - } - set { - name = value == null ? String.Empty : value; - } - } - - public Expression Expression { - get { - return expression; - } - set { - expression = Expression.CheckNull(value); - } - } - - public NamedArgumentExpression(string name, Expression expression) - { - this.Name = name; - this.Expression = expression; - } - - public override object AcceptVisitor(IASTVisitor visitor, object data) - { - return visitor.Visit(this, data); - } - - public override string ToString() - { - return String.Format("[NamedArgumentExpression: Name = {0}, Expression = {1}]", - Name, - Expression); - } - } - - public class Attribute : AbstractNode - { - string name = ""; - List positionalArguments; - List namedArguments; - - public Attribute(string name, List positionalArguments, List namedArguments) - { - Debug.Assert(name != null); - Debug.Assert(positionalArguments != null); - Debug.Assert(namedArguments != null); - - this.name = name; - this.positionalArguments = positionalArguments; - this.namedArguments = namedArguments; - } - - public string Name { - get { - return name; - } - } - - public List PositionalArguments { - get { - return positionalArguments; - } - } - - public List NamedArguments { - get { - return namedArguments; - } - } - - public override object AcceptVisitor(IASTVisitor visitor, object data) - { - return visitor.Visit(this, data); - } - - public override string ToString() - { - return String.Format("[Attribute: Name = {0}, PositionalArguments = {1}, NamedArguments = {2}]", - Name, - PositionalArguments, - NamedArguments); - } - } - - public class AttributeSection : AbstractNode, INullable - { - string attributeTarget = ""; - List attributes; - static AttributeSection nullSection = new NullAttributeSection(); - - public virtual bool IsNull { - get { - return false; - } - } - - public static AttributeSection Null { - get { - return nullSection; - } - } - - public static AttributeSection CheckNull(AttributeSection attributeSection) - { - return attributeSection == null ? AttributeSection.Null : attributeSection; - } - - public string AttributeTarget { - get { - return attributeTarget; - } - set { - attributeTarget = value == null ? String.Empty : value; - } - } - - public List Attributes { - get { - return attributes; - } - set { - attributes = value == null ? new List(1) : value; - } - } - - public AttributeSection() : this(null, null) - { - } - - public AttributeSection(string attributeTarget, List attributes) - { - this.AttributeTarget = attributeTarget; - this.Attributes = attributes; - } - - public override object AcceptVisitor(IASTVisitor visitor, object data) - { - return visitor.Visit(this, data); - } - public override string ToString() - { - return String.Format("[AttributeSection: AttributeTarget={0}, Attributes={1}]", - AttributeTarget, - Attributes); - } - } - - public class NullAttributeSection : AttributeSection - { - public override bool IsNull { - get { - return true; - } - } - public override string ToString() - { - return String.Format("[NullAttributeSection]"); - } - } -} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/BlockStatement.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/BlockStatement.cs new file mode 100644 index 0000000000..f5ecf2bb2e --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/BlockStatement.cs @@ -0,0 +1,79 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections; + +namespace ICSharpCode.NRefactory.Parser.AST +{ + public class BlockStatement : Statement + { + // Children in C#: LabelStatement, LocalVariableDeclaration, Statement + // Children in VB: LabelStatement, EndStatement, Statement + + public static new NullBlockStatement Null { + get { + return NullBlockStatement.Instance; + } + } + + public static BlockStatement CheckNull(BlockStatement blockStatement) + { + return blockStatement == null ? NullBlockStatement.Instance : blockStatement; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return visitor.Visit(this, data); + } + + public override string ToString() + { + return String.Format("[BlockStatement: Children={0}]", + GetCollectionString(base.Children)); + } + } + + public class NullBlockStatement : BlockStatement + { + static NullBlockStatement nullBlockStatement = new NullBlockStatement(); + + public override bool IsNull { + get { + return true; + } + } + + public static NullBlockStatement Instance { + get { + return nullBlockStatement; + } + } + + NullBlockStatement() + { + } + + 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/src/Libraries/NRefactory/Project/Src/Parser/AST/General/CompilationUnit.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/CompilationUnit.cs new file mode 100644 index 0000000000..b8c98a30ac --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/CompilationUnit.cs @@ -0,0 +1,56 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Threading; +using System.Diagnostics; +using System.Collections; + +namespace ICSharpCode.NRefactory.Parser.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 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.Visit(this, data); + } + + public override string ToString() + { + return String.Format("[CompilationUnit]"); + } + } +} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Expression.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Expression.cs new file mode 100644 index 0000000000..84bb81e489 --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Expression.cs @@ -0,0 +1,111 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections; + +namespace ICSharpCode.NRefactory.Parser.AST +{ + public abstract class Expression : AbstractNode, INullable + { + public static NullExpression 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. + /// WARNING: This method modifies and possibly returns + /// again, but it might also create a new expression around . + /// + 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) { + 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; + 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))); + } + } + + public class NullExpression : Expression + { + static NullExpression nullExpression = new NullExpression(); + + public override bool IsNull { + get { + return true; + } + } + + public static NullExpression Instance { + get { + return nullExpression; + } + } + + NullExpression() + { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return null; + } + + public override string ToString() + { + return String.Format("[NullExpression]"); + } + } +} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/LocalVariableDeclaration.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/LocalVariableDeclaration.cs new file mode 100644 index 0000000000..1d7a13c9bc --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/LocalVariableDeclaration.cs @@ -0,0 +1,104 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.Collections; +using System.Collections.Generic; + +namespace ICSharpCode.NRefactory.Parser.AST +{ + public class LocalVariableDeclaration : Statement + { + TypeReference typeReference; + Modifier modifier = Modifier.None; + List variables = new List(1); + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = TypeReference.CheckNull(value); + } + } + + public Modifier 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, Modifier modifier) + { + this.TypeReference = typeReference; + this.modifier = modifier; + } + + public LocalVariableDeclaration(Modifier 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.Visit(this, data); + } + + public override string ToString() + { + return String.Format("[LocalVariableDeclaration: Type={0}, Modifier ={1} Variables={2}]", + typeReference, + modifier, + GetCollectionString(variables)); + } + } +} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/PrimitiveExpression.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/PrimitiveExpression.cs new file mode 100644 index 0000000000..7fbb1a6ea3 --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/PrimitiveExpression.cs @@ -0,0 +1,58 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.Collections; +using System.Globalization; + +namespace ICSharpCode.NRefactory.Parser.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.Visit(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/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statement.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statement.cs new file mode 100644 index 0000000000..b4190eb797 --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statement.cs @@ -0,0 +1,92 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections; + +namespace ICSharpCode.NRefactory.Parser.AST +{ + public abstract class Statement : AbstractNode, INullable + { + public static NullStatement Null { + get { + return NullStatement.Instance; + } + } + + public virtual bool IsNull { + get { + return false; + } + } + + public static Statement CheckNull(Statement statement) + { + return statement == null ? NullStatement.Instance : statement; + } + + public static void Replace(Statement oldStatement, Statement newStatement) + { + INode parent = oldStatement.Parent; + StatementWithEmbeddedStatement parentStmt = parent as StatementWithEmbeddedStatement; + if (parentStmt != null && parentStmt.EmbeddedStatement == oldStatement) + parentStmt.EmbeddedStatement = newStatement; + int index = parent.Children.IndexOf(oldStatement); + if (index >= 0) { + parent.Children[index] = newStatement; + newStatement.Parent = parent; + } + } + } + + public abstract class StatementWithEmbeddedStatement : Statement + { + Statement embeddedStatement; + + public Statement EmbeddedStatement { + get { + return embeddedStatement; + } + set { + embeddedStatement = Statement.CheckNull(value); + if (value != null) + value.Parent = this; + } + } + } + + public class NullStatement : Statement + { + static NullStatement nullStatement = new NullStatement(); + + public override bool IsNull { + get { + return true; + } + } + + public static NullStatement Instance { + get { + return nullStatement; + } + } + + NullStatement() + { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) + { + return data; + } + + public override string ToString() + { + return String.Format("[NullStatement]"); + } + } +} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/Generated.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/Generated.cs new file mode 100644 index 0000000000..f7551467c5 --- /dev/null +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/Generated.cs @@ -0,0 +1,4316 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ICSharpCode.NRefactory.Parser.AST { + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.Drawing; + + + public class AddHandlerStatement : Statement { + + Expression eventExpression; + + Expression handlerExpression; + + public AddHandlerStatement(Expression eventExpression, Expression handlerExpression) { + EventExpression = eventExpression; + HandlerExpression = handlerExpression; + } + + public Expression EventExpression { + get { + return eventExpression; + } + set { + eventExpression = value ?? Expression.Null; + } + } + + public Expression HandlerExpression { + get { + return handlerExpression; + } + set { + handlerExpression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[AddHandlerStatement EventExpression={0} HandlerExpression={1}]", EventExpression, HandlerExpression); + } + } + + public class AddressOfExpression : Expression { + + Expression expression; + + public AddressOfExpression(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[AddressOfExpression Expression={0}]", Expression); + } + } + + public class AnonymousMethodExpression : Expression { + + List parameters; + + BlockStatement body; + + public AnonymousMethodExpression() { + parameters = new List(); + body = BlockStatement.Null; + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[AnonymousMethodExpression Parameters={0} Body={1}]", GetCollectionString(Parameters), Body); + } + } + + public class ArrayCreateExpression : Expression { + + TypeReference createType; + + List arguments; + + ArrayInitializerExpression arrayInitializer; + + public ArrayCreateExpression(TypeReference createType) { + CreateType = createType; + arguments = new List(); + arrayInitializer = ArrayInitializerExpression.Null; + } + + public ArrayCreateExpression(TypeReference createType, List arguments) { + CreateType = createType; + Arguments = arguments; + arrayInitializer = ArrayInitializerExpression.Null; + } + + public ArrayCreateExpression(TypeReference createType, ArrayInitializerExpression arrayInitializer) { + CreateType = createType; + ArrayInitializer = arrayInitializer; + arguments = new List(); + } + + public TypeReference CreateType { + get { + return createType; + } + set { + createType = value ?? TypeReference.Null; + } + } + + public List Arguments { + get { + return arguments; + } + set { + arguments = value ?? new List(); + } + } + + public ArrayInitializerExpression ArrayInitializer { + get { + return arrayInitializer; + } + set { + arrayInitializer = value ?? ArrayInitializerExpression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ArrayCreateExpression CreateType={0} Arguments={1} ArrayInitializer={2}]", CreateType, GetCollectionString(Arguments), ArrayInitializer); + } + } + + public class ArrayInitializerExpression : Expression { + + List createExpressions; + + public ArrayInitializerExpression() { + createExpressions = new List(); + } + + public ArrayInitializerExpression(List createExpressions) { + CreateExpressions = createExpressions; + } + + public List CreateExpressions { + get { + return createExpressions; + } + set { + createExpressions = value ?? new List(); + } + } + + public new static ArrayInitializerExpression Null { + get { + return NullArrayInitializerExpression.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ArrayInitializerExpression CreateExpressions={0}]", GetCollectionString(CreateExpressions)); + } + } + + public class NullArrayInitializerExpression : ArrayInitializerExpression { + + static NullArrayInitializerExpression instance = new NullArrayInitializerExpression(); + + private NullArrayInitializerExpression() { + } + + public static NullArrayInitializerExpression Instance { + get { + return instance; + } + } + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullArrayInitializerExpression]"; + } + } + + public class AssignmentExpression : Expression { + + Expression left; + + AssignmentOperatorType op; + + Expression right; + + public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right) { + Left = left; + Op = op; + Right = right; + } + + public Expression Left { + get { + return left; + } + set { + left = value ?? Expression.Null; + } + } + + public AssignmentOperatorType Op { + get { + return op; + } + set { + op = value; + } + } + + public Expression Right { + get { + return right; + } + set { + right = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 Attribute(string name, List positionalArguments, List namedArguments) { + Name = name; + PositionalArguments = positionalArguments; + NamedArguments = 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 override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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; + + Modifier modifier; + + public AttributedNode(List attributes) { + Attributes = attributes; + } + + public AttributedNode(Modifier modifier, List attributes) { + Modifier = modifier; + Attributes = attributes; + } + + public List Attributes { + get { + return attributes; + } + set { + attributes = value ?? new List(); + } + } + + public Modifier Modifier { + get { + return modifier; + } + set { + modifier = value; + } + } + } + + public class AttributeSection : AbstractNode { + + string attributeTarget; + + List attributes; + + public AttributeSection(string attributeTarget, List attributes) { + AttributeTarget = attributeTarget; + Attributes = attributes; + } + + public string AttributeTarget { + get { + return attributeTarget; + } + set { + attributeTarget = value ?? ""; + } + } + + public List Attributes { + get { + return attributes; + } + set { + attributes = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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.Visit(this, data); + } + + public override string ToString() { + return "[BaseReferenceExpression]"; + } + } + + public class BinaryOperatorExpression : Expression { + + Expression left; + + BinaryOperatorType op; + + Expression right; + + public BinaryOperatorExpression(Expression left, BinaryOperatorType op, Expression right) { + Left = left; + Op = op; + Right = right; + } + + public Expression Left { + get { + return left; + } + set { + left = value ?? Expression.Null; + } + } + + public BinaryOperatorType Op { + get { + return op; + } + set { + op = value; + } + } + + public Expression Right { + get { + return right; + } + set { + right = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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.Visit(this, data); + } + + public override string ToString() { + return "[BreakStatement]"; + } + } + + public class CaseLabel : AbstractNode { + + Expression label; + + BinaryOperatorType binaryOperatorType; + + Expression toExpression; + + 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 Expression Label { + get { + return label; + } + set { + label = value ?? Expression.Null; + } + } + + public BinaryOperatorType BinaryOperatorType { + get { + return binaryOperatorType; + } + set { + binaryOperatorType = value; + } + } + + public Expression ToExpression { + get { + return toExpression; + } + set { + toExpression = value ?? Expression.Null; + } + } + + public bool IsDefault { + get { +return label.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 CastExpression(TypeReference castTo) { + CastTo = castTo; + expression = Expression.Null; + } + + public CastExpression(TypeReference castTo, Expression expression, CastType castType) { + CastTo = 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; + } + } + + public CastType CastType { + get { + return castType; + } + set { + castType = value; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 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 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; + } + } + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 CheckedExpression(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[CheckedExpression Expression={0}]", Expression); + } + } + + public class CheckedStatement : Statement { + + Statement block; + + public CheckedStatement(Statement block) { + Block = block; + } + + public Statement Block { + get { + return block; + } + set { + block = value ?? Statement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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.Visit(this, data); + } + + public override string ToString() { + return "[ClassReferenceExpression]"; + } + } + + public class ConditionalExpression : Expression { + + Expression condition; + + Expression trueExpression; + + Expression falseExpression; + + public ConditionalExpression(Expression condition, Expression trueExpression, Expression falseExpression) { + Condition = condition; + TrueExpression = trueExpression; + FalseExpression = falseExpression; + } + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + } + } + + public Expression TrueExpression { + get { + return trueExpression; + } + set { + trueExpression = value ?? Expression.Null; + } + } + + public Expression FalseExpression { + get { + return falseExpression; + } + set { + falseExpression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 ConstructorDeclaration(string name, Modifier modifier, List parameters, List attributes) : + base(modifier, attributes, name, parameters) { + constructorInitializer = ConstructorInitializer.Null; + body = BlockStatement.Null; + } + + public ConstructorDeclaration(string name, Modifier modifier, List parameters, ConstructorInitializer constructorInitializer, List attributes) : + base(modifier, attributes, name, parameters) { + ConstructorInitializer = constructorInitializer; + body = BlockStatement.Null; + } + + public ConstructorInitializer ConstructorInitializer { + get { + return constructorInitializer; + } + set { + constructorInitializer = value ?? ConstructorInitializer.Null; + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 ConstructorInitializer() { + arguments = new List(); + } + + public ConstructorInitializerType ConstructorInitializerType { + get { + return constructorInitializerType; + } + set { + constructorInitializerType = value; + } + } + + public List Arguments { + get { + return arguments; + } + set { + arguments = value ?? 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.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ConstructorInitializer ConstructorInitializerType={0} Arguments={1}]", ConstructorInitializerType, GetCollectionString(Arguments)); + } + } + + public class NullConstructorInitializer : ConstructorInitializer { + + static NullConstructorInitializer instance = new NullConstructorInitializer(); + + private NullConstructorInitializer() { + } + + public static NullConstructorInitializer Instance { + get { + return instance; + } + } + + 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 ContinueStatement() { + } + + public ContinueStatement(ContinueType continueType) { + ContinueType = continueType; + } + + public ContinueType ContinueType { + get { + return continueType; + } + set { + continueType = value; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 DeclareDeclaration(string name, Modifier modifier, TypeReference typeReference, List parameters, List attributes, string library, string alias, CharsetModifier charset) : + base(modifier, attributes, name, parameters) { + TypeReference = typeReference; + Library = library; + Alias = alias; + Charset = charset; + } + + 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 override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 DefaultValueExpression(TypeReference typeReference) { + TypeReference = typeReference; + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 DelegateDeclaration(Modifier modifier, List attributes) : + base(attributes) { + Modifier = modifier; + name = "?"; + returnType = TypeReference.Null; + parameters = new List(); + templates = new List(); + } + + 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 override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 DestructorDeclaration(string name, Modifier modifier, List attributes) : + base(attributes) { + Name = name; + Modifier = modifier; + body = BlockStatement.Null; + } + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 DirectionExpression(FieldDirection fieldDirection, Expression 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; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition) { + Condition = condition; + EmbeddedStatement = embeddedStatement; + ConditionType = conditionType; + ConditionPosition = conditionPosition; + } + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + } + } + + public ConditionType ConditionType { + get { + return conditionType; + } + set { + conditionType = value; + } + } + + public ConditionPosition ConditionPosition { + get { + return conditionPosition; + } + set { + conditionPosition = value; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 ElseIfSection(Expression condition, Statement embeddedStatement) { + Condition = condition; + EmbeddedStatement = embeddedStatement; + } + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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.Visit(this, data); + } + + public override string ToString() { + return "[EmptyStatement]"; + } + } + + public class EndStatement : Statement { + + public EndStatement() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return "[EndStatement]"; + } + } + + public class EraseStatement : Statement { + + List expressions; + + public EraseStatement() { + expressions = new List(); + } + + public EraseStatement(List expressions) { + Expressions = expressions; + } + + public List Expressions { + get { + return expressions; + } + set { + expressions = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[EraseStatement Expressions={0}]", GetCollectionString(Expressions)); + } + } + + public class ErrorStatement : Statement { + + Expression expression; + + public ErrorStatement(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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.Visit(this, data); + } + + public override string ToString() { + return string.Format("[EventAddRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class NullEventAddRegion : EventAddRegion { + + static NullEventAddRegion instance = new NullEventAddRegion(); + + private NullEventAddRegion() : + base(null) { + } + + public static NullEventAddRegion Instance { + get { + return instance; + } + } + + 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 EventAddRemoveRegion(List attributes) : + base(attributes) { + block = BlockStatement.Null; + parameters = new List(); + } + + public BlockStatement Block { + get { + return block; + } + set { + block = value ?? BlockStatement.Null; + } + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public virtual bool IsNull { + get { + return false; + } + } + } + + public class EventDeclaration : ParametrizedNode { + + TypeReference typeReference; + + List interfaceImplementations; + + EventAddRegion addRegion; + + EventRemoveRegion removeRegion; + + EventRaiseRegion raiseRegion; + + Point bodyStart; + + Point bodyEnd; + + public EventDeclaration(TypeReference typeReference, string name, Modifier modifier, List attributes, List parameters) : + base(modifier, attributes, name, parameters) { + TypeReference = typeReference; + interfaceImplementations = new List(); + addRegion = EventAddRegion.Null; + removeRegion = EventRemoveRegion.Null; + raiseRegion = EventRaiseRegion.Null; + bodyStart = new Point(-1, -1); + bodyEnd = new Point(-1, -1); + } + + public EventDeclaration(TypeReference typeReference, Modifier modifier, List parameters, List attributes, string name, List interfaceImplementations) : + base(modifier, attributes, name, parameters) { + TypeReference = typeReference; + InterfaceImplementations = interfaceImplementations; + addRegion = EventAddRegion.Null; + removeRegion = EventRemoveRegion.Null; + raiseRegion = EventRaiseRegion.Null; + bodyStart = new Point(-1, -1); + bodyEnd = new Point(-1, -1); + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public List InterfaceImplementations { + get { + return interfaceImplementations; + } + set { + interfaceImplementations = value ?? new List(); + } + } + + 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 Point BodyStart { + get { + return bodyStart; + } + set { + bodyStart = value; + } + } + + public Point BodyEnd { + get { + return bodyEnd; + } + set { + bodyEnd = value; + } + } + + public bool HasAddRegion { + get { +return !addRegion.IsNull; + } + } + + public bool HasRaiseRegion { + get { +return !raiseRegion.IsNull; + } + } + + public bool HasRemoveRegion { + get { +return !removeRegion.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[EventDeclaration TypeReference={0} InterfaceImplementations={1} AddRegion={2} Re" + + "moveRegion={3} RaiseRegion={4} BodyStart={5} BodyEnd={6} Name={7} Parameters={8}" + + " Attributes={9} Modifier={10}]", TypeReference, GetCollectionString(InterfaceImplementations), AddRegion, RemoveRegion, RaiseRegion, BodyStart, BodyEnd, 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.Visit(this, data); + } + + public override string ToString() { + return string.Format("[EventRaiseRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class NullEventRaiseRegion : EventRaiseRegion { + + static NullEventRaiseRegion instance = new NullEventRaiseRegion(); + + private NullEventRaiseRegion() : + base(null) { + } + + public static NullEventRaiseRegion Instance { + get { + return instance; + } + } + + 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.Visit(this, data); + } + + public override string ToString() { + return string.Format("[EventRemoveRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class NullEventRemoveRegion : EventRemoveRegion { + + static NullEventRemoveRegion instance = new NullEventRemoveRegion(); + + private NullEventRemoveRegion() : + base(null) { + } + + public static NullEventRemoveRegion Instance { + get { + return instance; + } + } + + 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 ExitStatement(ExitType exitType) { + ExitType = exitType; + } + + public ExitType ExitType { + get { + return exitType; + } + set { + exitType = value; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ExitStatement ExitType={0}]", ExitType); + } + } + + public class FieldDeclaration : AttributedNode { + + TypeReference typeReference; + + List fields; + + + public TypeReference GetTypeForField(int fieldIndex) + { + if (!typeReference.IsNull) { + return typeReference; + } + + for (int i = fieldIndex; i < Fields.Count;++i) { + if (!((VariableDeclaration)Fields[i]).TypeReference.IsNull) { + return ((VariableDeclaration)Fields[i]).TypeReference; + } + } + return TypeReference.Null; + } + + public VariableDeclaration GetVariableDeclaration(string variableName) + { + foreach (VariableDeclaration variableDeclaration in Fields) { + if (variableDeclaration.Name == variableName) { + return variableDeclaration; + } + } + return null; + } + + public FieldDeclaration(List attributes) : + base(attributes) { + typeReference = TypeReference.Null; + fields = new List(); + } + + public FieldDeclaration(List attributes, TypeReference typeReference, Modifier modifier) : + base(attributes) { + TypeReference = typeReference; + Modifier = modifier; + fields = new List(); + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public List Fields { + get { + return fields; + } + set { + fields = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 FieldReferenceExpression : Expression { + + Expression targetObject; + + string fieldName; + + public FieldReferenceExpression(Expression targetObject, string fieldName) { + TargetObject = targetObject; + FieldName = fieldName; + } + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + } + } + + public string FieldName { + get { + return fieldName; + } + set { + fieldName = value ?? ""; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[FieldReferenceExpression TargetObject={0} FieldName={1}]", TargetObject, FieldName); + } + } + + public class FixedStatement : StatementWithEmbeddedStatement { + + TypeReference typeReference; + + List pointerDeclarators; + + public FixedStatement(TypeReference typeReference, List pointerDeclarators, Statement embeddedStatement) { + TypeReference = typeReference; + PointerDeclarators = pointerDeclarators; + EmbeddedStatement = embeddedStatement; + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public List PointerDeclarators { + get { + return pointerDeclarators; + } + set { + pointerDeclarators = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 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 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; + } + } + + public Expression NextExpression { + get { + return nextExpression; + } + set { + nextExpression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 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 Expression Start { + get { + return start; + } + set { + start = value ?? Expression.Null; + } + } + + public Expression End { + get { + return end; + } + set { + end = value ?? Expression.Null; + } + } + + public Expression Step { + get { + return step; + } + set { + step = value ?? Expression.Null; + } + } + + 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 override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 ForStatement(List initializers, Expression condition, List iterator, Statement embeddedStatement) { + Initializers = initializers; + Condition = condition; + Iterator = iterator; + EmbeddedStatement = embeddedStatement; + } + + public List Initializers { + get { + return initializers; + } + set { + initializers = value ?? new List(); + } + } + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + } + } + + public List Iterator { + get { + return iterator; + } + set { + iterator = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 GotoCaseStatement(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public bool IsDefaultCase { + get { +return expression.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[GotoCaseStatement Expression={0}]", Expression); + } + } + + public class GotoStatement : Statement { + + string label; + + public GotoStatement(string label) { + Label = label; + } + + public string Label { + get { + return label; + } + set { + label = value ?? ""; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[GotoStatement Label={0}]", Label); + } + } + + public class IdentifierExpression : Expression { + + string identifier; + + public IdentifierExpression(string identifier) { + Identifier = identifier; + } + + public string Identifier { + get { + return identifier; + } + set { + identifier = value ?? ""; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[IdentifierExpression Identifier={0}]", Identifier); + } + } + + public class IfElseStatement : Statement { + + Expression condition; + + List trueStatement; + + List falseStatement; + + List elseIfSections; + + + public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement) + : this(condition) { + this.trueStatement.Add(Statement.CheckNull(trueStatement)); + this.falseStatement.Add(Statement.CheckNull(falseStatement)); + } + + public IfElseStatement(Expression condition, Statement trueStatement) + : this(condition) { + this.trueStatement.Add(Statement.CheckNull(trueStatement)); + } + + public IfElseStatement(Expression condition) { + Condition = condition; + trueStatement = new List(); + falseStatement = new List(); + elseIfSections = new List(); + } + + public Expression Condition { + get { + return condition; + } + set { + condition = value ?? Expression.Null; + } + } + + 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 bool HasElseIfSections { + get { +return elseIfSections.Count > 0; + } + } + + public bool HasElseStatements { + get { +return falseStatement.Count > 0; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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; + + Point bodyStart; + + Point bodyEnd; + + PropertyGetRegion getRegion; + + PropertySetRegion setRegion; + + public IndexerDeclaration(Modifier modifier, List parameters, List attributes) : + base(attributes) { + Modifier = modifier; + Parameters = parameters; + interfaceImplementations = new List(); + typeReference = TypeReference.Null; + bodyStart = new Point(-1, -1); + bodyEnd = new Point(-1, -1); + getRegion = PropertyGetRegion.Null; + setRegion = PropertySetRegion.Null; + } + + public IndexerDeclaration(TypeReference typeReference, List parameters, Modifier modifier, List attributes) : + base(attributes) { + TypeReference = typeReference; + Parameters = parameters; + Modifier = modifier; + interfaceImplementations = new List(); + bodyStart = new Point(-1, -1); + bodyEnd = new Point(-1, -1); + getRegion = PropertyGetRegion.Null; + setRegion = PropertySetRegion.Null; + } + + 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 Point BodyStart { + get { + return bodyStart; + } + set { + bodyStart = value; + } + } + + public Point 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 bool IsReadOnly { + get { +return HasGetRegion && !HasSetRegion; + } + } + + public bool HasGetRegion { + get { +return !getRegion.IsNull; + } + } + + public bool IsWriteOnly { + get { +return !HasGetRegion && HasSetRegion; + } + } + + public bool HasSetRegion { + get { +return !setRegion.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(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 indices; + + public IndexerExpression(Expression targetObject, List indices) { + TargetObject = targetObject; + Indices = indices; + } + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + } + } + + public List Indices { + get { + return indices; + } + set { + indices = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[IndexerExpression TargetObject={0} Indices={1}]", TargetObject, GetCollectionString(Indices)); + } + } + + public class InterfaceImplementation : AbstractNode { + + TypeReference interfaceType; + + string memberName; + + public InterfaceImplementation(TypeReference interfaceType, string memberName) { + InterfaceType = interfaceType; + MemberName = 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 override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[InterfaceImplementation InterfaceType={0} MemberName={1}]", InterfaceType, MemberName); + } + } + + public class InvocationExpression : Expression { + + Expression targetObject; + + List arguments; + + List typeArguments; + + public InvocationExpression(Expression targetObject) { + TargetObject = targetObject; + arguments = new List(); + typeArguments = new List(); + } + + public InvocationExpression(Expression targetObject, List arguments) { + TargetObject = targetObject; + Arguments = arguments; + typeArguments = new List(); + } + + public InvocationExpression(Expression targetObject, List arguments, List typeArguments) { + TargetObject = targetObject; + Arguments = arguments; + TypeArguments = typeArguments; + } + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + } + } + + public List Arguments { + get { + return arguments; + } + set { + arguments = value ?? new List(); + } + } + + public List TypeArguments { + get { + return typeArguments; + } + set { + typeArguments = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[InvocationExpression TargetObject={0} Arguments={1} TypeArguments={2}]", TargetObject, GetCollectionString(Arguments), GetCollectionString(TypeArguments)); + } + } + + public class LabelStatement : Statement { + + string label; + + public LabelStatement(string label) { + Label = label; + } + + public string Label { + get { + return label; + } + set { + label = value ?? ""; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[LabelStatement Label={0}]", Label); + } + } + + public class LockStatement : StatementWithEmbeddedStatement { + + Expression lockExpression; + + public LockStatement(Expression lockExpression, Statement embeddedStatement) { + LockExpression = lockExpression; + EmbeddedStatement = embeddedStatement; + } + + public Expression LockExpression { + get { + return lockExpression; + } + set { + lockExpression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[LockStatement LockExpression={0} EmbeddedStatement={1}]", LockExpression, EmbeddedStatement); + } + } + + public class MethodDeclaration : ParametrizedNode { + + TypeReference typeReference; + + BlockStatement body; + + List handlesClause; + + List interfaceImplementations; + + List templates; + + public MethodDeclaration(string name, Modifier modifier, TypeReference typeReference, List parameters, List attributes) : + base(modifier, attributes, name, parameters) { + TypeReference = typeReference; + body = BlockStatement.Null; + handlesClause = new List(); + interfaceImplementations = new List(); + templates = new List(); + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + } + } + + public List HandlesClause { + get { + return handlesClause; + } + set { + handlesClause = value ?? new List(); + } + } + + public List InterfaceImplementations { + get { + return interfaceImplementations; + } + set { + interfaceImplementations = value ?? new List(); + } + } + + public List Templates { + get { + return templates; + } + set { + templates = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[MethodDeclaration TypeReference={0} Body={1} HandlesClause={2} InterfaceImplemen" + + "tations={3} Templates={4} Name={5} Parameters={6} Attributes={7} Modifier={8}]", TypeReference, Body, GetCollectionString(HandlesClause), GetCollectionString(InterfaceImplementations), GetCollectionString(Templates), Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class NamedArgumentExpression : Expression { + + string name; + + Expression expression; + + public NamedArgumentExpression(string name, Expression expression) { + Name = name; + Expression = expression; + } + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[NamedArgumentExpression Name={0} Expression={1}]", Name, Expression); + } + } + + public class NamespaceDeclaration : AbstractNode { + + string name; + + public NamespaceDeclaration(string name) { + Name = name; + } + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[NamespaceDeclaration Name={0}]", Name); + } + } + + public class ObjectCreateExpression : Expression { + + TypeReference createType; + + List parameters; + + public ObjectCreateExpression(TypeReference createType, List parameters) { + CreateType = createType; + Parameters = parameters; + } + + public TypeReference CreateType { + get { + return createType; + } + set { + createType = value ?? TypeReference.Null; + } + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ObjectCreateExpression CreateType={0} Parameters={1}]", CreateType, GetCollectionString(Parameters)); + } + } + + public class OnErrorStatement : StatementWithEmbeddedStatement { + + public OnErrorStatement(Statement embeddedStatement) { + EmbeddedStatement = embeddedStatement; + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[OnErrorStatement EmbeddedStatement={0}]", EmbeddedStatement); + } + } + + public class OperatorDeclaration : MethodDeclaration { + + ConversionType conversionType; + + List returnTypeAttributes; + + OverloadableOperatorType overloadableOperator; + + public OperatorDeclaration(Modifier modifier, List attributes, List parameters, TypeReference typeReference, ConversionType conversionType) : + base(null, modifier, typeReference, parameters, attributes) { + ConversionType = conversionType; + returnTypeAttributes = new List(); + } + + public OperatorDeclaration(Modifier modifier, List attributes, List parameters, TypeReference typeReference, OverloadableOperatorType overloadableOperator) : + base(null, modifier, typeReference, parameters, attributes) { + OverloadableOperator = overloadableOperator; + returnTypeAttributes = new List(); + } + + public ConversionType ConversionType { + get { + return conversionType; + } + set { + conversionType = value; + } + } + + public List ReturnTypeAttributes { + get { + return returnTypeAttributes; + } + set { + returnTypeAttributes = value ?? new List(); + } + } + + public OverloadableOperatorType OverloadableOperator { + get { + return overloadableOperator; + } + set { + overloadableOperator = value; + } + } + + public bool IsConversionOperator { + get { +return conversionType != ConversionType.None; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[OperatorDeclaration ConversionType={0} ReturnTypeAttributes={1} OverloadableOper" + + "ator={2} TypeReference={3} Body={4} HandlesClause={5} InterfaceImplementations={" + + "6} Templates={7} Name={8} Parameters={9} Attributes={10} Modifier={11}]", ConversionType, GetCollectionString(ReturnTypeAttributes), OverloadableOperator, TypeReference, Body, GetCollectionString(HandlesClause), GetCollectionString(InterfaceImplementations), GetCollectionString(Templates), Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class OptionDeclaration : AbstractNode { + + OptionType optionType; + + bool optionValue; + + public OptionDeclaration(OptionType optionType, bool optionValue) { + OptionType = optionType; + OptionValue = optionValue; + } + + public OptionType OptionType { + get { + return optionType; + } + set { + optionType = value; + } + } + + public bool OptionValue { + get { + return optionValue; + } + set { + optionValue = value; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[OptionDeclaration OptionType={0} OptionValue={1}]", OptionType, OptionValue); + } + } + + public class ParameterDeclarationExpression : Expression { + + List attributes; + + string parameterName; + + TypeReference typeReference; + + ParamModifier paramModifier; + + Expression defaultValue; + + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName) { + TypeReference = typeReference; + ParameterName = parameterName; + attributes = new List(); + defaultValue = Expression.Null; + } + + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParamModifier paramModifier) { + TypeReference = typeReference; + ParameterName = parameterName; + ParamModifier = paramModifier; + attributes = new List(); + defaultValue = Expression.Null; + } + + public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParamModifier paramModifier, Expression defaultValue) { + TypeReference = typeReference; + ParameterName = parameterName; + ParamModifier = paramModifier; + DefaultValue = defaultValue; + attributes = new List(); + } + + public List Attributes { + get { + return attributes; + } + set { + attributes = value ?? new List(); + } + } + + public string ParameterName { + get { + return parameterName; + } + set { + parameterName = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public ParamModifier ParamModifier { + get { + return paramModifier; + } + set { + paramModifier = value; + } + } + + public Expression DefaultValue { + get { + return defaultValue; + } + set { + defaultValue = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ParameterDeclarationExpression Attributes={0} ParameterName={1} TypeReference={2" + + "} ParamModifier={3} DefaultValue={4}]", GetCollectionString(Attributes), ParameterName, TypeReference, ParamModifier, DefaultValue); + } + } + + public abstract class ParametrizedNode : AttributedNode { + + string name; + + List parameters; + + public ParametrizedNode(Modifier modifier, List attributes, string name, List parameters) : + base(attributes) { + Modifier = modifier; + Name = name; + Parameters = parameters; + } + + public ParametrizedNode(Modifier modifier, List attributes) : + base(attributes) { + Modifier = modifier; + name = ""; + parameters = new List(); + } + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + } + + public class ParenthesizedExpression : Expression { + + Expression expression; + + public ParenthesizedExpression(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ParenthesizedExpression Expression={0}]", Expression); + } + } + + public class PointerReferenceExpression : Expression { + + Expression targetObject; + + string identifier; + + public PointerReferenceExpression(Expression targetObject, string identifier) { + TargetObject = targetObject; + Identifier = identifier; + } + + public Expression TargetObject { + get { + return targetObject; + } + set { + targetObject = value ?? Expression.Null; + } + } + + public string Identifier { + get { + return identifier; + } + set { + identifier = value ?? ""; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[PointerReferenceExpression TargetObject={0} Identifier={1}]", TargetObject, Identifier); + } + } + + public class PropertyDeclaration : ParametrizedNode { + + List interfaceImplementations; + + TypeReference typeReference; + + Point bodyStart; + + Point bodyEnd; + + PropertyGetRegion getRegion; + + PropertySetRegion setRegion; + + + public PropertyDeclaration(string name, TypeReference typeReference, Modifier modifier, List attributes) : this(modifier, attributes, name, null) + { + this.TypeReference = typeReference; + if ((modifier & Modifier.ReadOnly) == Modifier.ReadOnly) { + this.GetRegion = new PropertyGetRegion(null, null); + } else if ((modifier & Modifier.WriteOnly) == Modifier.WriteOnly) { + this.SetRegion = new PropertySetRegion(null, null); + } + } + + public PropertyDeclaration(Modifier modifier, List attributes, string name, List parameters) : + base(modifier, attributes, name, parameters) { + interfaceImplementations = new List(); + typeReference = TypeReference.Null; + bodyStart = new Point(-1, -1); + bodyEnd = new Point(-1, -1); + getRegion = PropertyGetRegion.Null; + setRegion = PropertySetRegion.Null; + } + + public List InterfaceImplementations { + get { + return interfaceImplementations; + } + set { + interfaceImplementations = value ?? new List(); + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public Point BodyStart { + get { + return bodyStart; + } + set { + bodyStart = value; + } + } + + public Point 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 bool HasGetRegion { + get { +return !getRegion.IsNull; + } + } + + public bool IsWriteOnly { + get { +return !HasGetRegion && HasSetRegion; + } + } + + public bool HasSetRegion { + get { +return !setRegion.IsNull; + } + } + + public bool IsReadOnly { + get { +return HasGetRegion && !HasSetRegion; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[PropertyDeclaration InterfaceImplementations={0} TypeReference={1} BodyStart={2}" + + " BodyEnd={3} GetRegion={4} SetRegion={5} Name={6} Parameters={7} Attributes={8} " + + "Modifier={9}]", GetCollectionString(InterfaceImplementations), TypeReference, BodyStart, BodyEnd, GetRegion, SetRegion, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); + } + } + + public class PropertyGetRegion : PropertyGetSetRegion { + + public PropertyGetRegion(BlockStatement block, List attributes) : + base(block, attributes) { + } + + public static PropertyGetRegion Null { + get { + return NullPropertyGetRegion.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[PropertyGetRegion Block={0} Attributes={1} Modifier={2}]", Block, GetCollectionString(Attributes), Modifier); + } + } + + public class NullPropertyGetRegion : PropertyGetRegion { + + static NullPropertyGetRegion instance = new NullPropertyGetRegion(); + + private NullPropertyGetRegion() : + base(null, null) { + } + + public static NullPropertyGetRegion Instance { + get { + return instance; + } + } + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullPropertyGetRegion]"; + } + } + + public abstract class PropertyGetSetRegion : AttributedNode, INullable { + + BlockStatement block; + + public PropertyGetSetRegion(BlockStatement block, List attributes) : + base(attributes) { + Block = block; + } + + public BlockStatement Block { + get { + return block; + } + set { + block = value ?? BlockStatement.Null; + } + } + + public virtual bool IsNull { + get { + return false; + } + } + } + + public class PropertySetRegion : PropertyGetSetRegion { + + List parameters; + + public PropertySetRegion(BlockStatement block, List attributes) : + base(block, attributes) { + parameters = new List(); + } + + public List Parameters { + get { + return parameters; + } + set { + parameters = value ?? new List(); + } + } + + public static PropertySetRegion Null { + get { + return NullPropertySetRegion.Instance; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[PropertySetRegion Parameters={0} Block={1} Attributes={2} Modifier={3}]", GetCollectionString(Parameters), Block, GetCollectionString(Attributes), Modifier); + } + } + + public class NullPropertySetRegion : PropertySetRegion { + + static NullPropertySetRegion instance = new NullPropertySetRegion(); + + private NullPropertySetRegion() : + base(null, null) { + } + + public static NullPropertySetRegion Instance { + get { + return instance; + } + } + + public override bool IsNull { + get { + return true; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return null; + } + + public override string ToString() { + return "[NullPropertySetRegion]"; + } + } + + public class RaiseEventStatement : Statement { + + string eventName; + + List arguments; + + public RaiseEventStatement(string eventName, List arguments) { + EventName = eventName; + Arguments = arguments; + } + + public string EventName { + get { + return eventName; + } + set { + eventName = value ?? ""; + } + } + + public List Arguments { + get { + return arguments; + } + set { + arguments = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[RaiseEventStatement EventName={0} Arguments={1}]", EventName, GetCollectionString(Arguments)); + } + } + + public class ReDimStatement : Statement { + + List reDimClauses; + + bool isPreserve; + + public ReDimStatement(bool isPreserve) { + IsPreserve = isPreserve; + reDimClauses = new List(); + } + + public List ReDimClauses { + get { + return reDimClauses; + } + set { + reDimClauses = value ?? new List(); + } + } + + public bool IsPreserve { + get { + return isPreserve; + } + set { + isPreserve = value; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ReDimStatement ReDimClauses={0} IsPreserve={1}]", GetCollectionString(ReDimClauses), IsPreserve); + } + } + + public class RemoveHandlerStatement : Statement { + + Expression eventExpression; + + Expression handlerExpression; + + public RemoveHandlerStatement(Expression eventExpression, Expression handlerExpression) { + EventExpression = eventExpression; + HandlerExpression = handlerExpression; + } + + public Expression EventExpression { + get { + return eventExpression; + } + set { + eventExpression = value ?? Expression.Null; + } + } + + public Expression HandlerExpression { + get { + return handlerExpression; + } + set { + handlerExpression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[RemoveHandlerStatement EventExpression={0} HandlerExpression={1}]", EventExpression, HandlerExpression); + } + } + + public class ResumeStatement : Statement { + + string labelName; + + bool isResumeNext; + + public ResumeStatement(bool isResumeNext) { + IsResumeNext = isResumeNext; + labelName = ""; + } + + public ResumeStatement(string labelName) { + LabelName = labelName; + } + + public string LabelName { + get { + return labelName; + } + set { + labelName = value ?? ""; + } + } + + public bool IsResumeNext { + get { + return isResumeNext; + } + set { + isResumeNext = value; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ResumeStatement LabelName={0} IsResumeNext={1}]", LabelName, IsResumeNext); + } + } + + public class ReturnStatement : Statement { + + Expression expression; + + public ReturnStatement(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ReturnStatement Expression={0}]", Expression); + } + } + + public class SizeOfExpression : Expression { + + TypeReference typeReference; + + public SizeOfExpression(TypeReference typeReference) { + TypeReference = typeReference; + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[SizeOfExpression TypeReference={0}]", TypeReference); + } + } + + public class StackAllocExpression : Expression { + + TypeReference typeReference; + + Expression expression; + + public StackAllocExpression(TypeReference typeReference, Expression expression) { + TypeReference = typeReference; + Expression = expression; + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[StackAllocExpression TypeReference={0} Expression={1}]", TypeReference, Expression); + } + } + + public class StatementExpression : Statement { + + Expression expression; + + public StatementExpression(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[StatementExpression Expression={0}]", Expression); + } + } + + public class StopStatement : Statement { + + public StopStatement() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return "[StopStatement]"; + } + } + + public class SwitchSection : BlockStatement { + + List switchLabels; + + public SwitchSection() { + switchLabels = new List(); + } + + public SwitchSection(List switchLabels) { + SwitchLabels = switchLabels; + } + + public List SwitchLabels { + get { + return switchLabels; + } + set { + switchLabels = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[SwitchSection SwitchLabels={0}]", GetCollectionString(SwitchLabels)); + } + } + + public class SwitchStatement : Statement { + + Expression switchExpression; + + List switchSections; + + public SwitchStatement(Expression switchExpression, List switchSections) { + SwitchExpression = switchExpression; + SwitchSections = switchSections; + } + + public Expression SwitchExpression { + get { + return switchExpression; + } + set { + switchExpression = value ?? Expression.Null; + } + } + + public List SwitchSections { + get { + return switchSections; + } + set { + switchSections = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[SwitchStatement SwitchExpression={0} SwitchSections={1}]", SwitchExpression, GetCollectionString(SwitchSections)); + } + } + + public class TemplateDefinition : AttributedNode { + + string name; + + List bases; + + public TemplateDefinition(string name, List attributes) : + base(attributes) { + Name = name; + bases = new List(); + } + + public string Name { + get { + return name; + } + set { + name = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public List Bases { + get { + return bases; + } + set { + bases = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[TemplateDefinition Name={0} Bases={1} Attributes={2} Modifier={3}]", Name, GetCollectionString(Bases), GetCollectionString(Attributes), Modifier); + } + } + + public class ThisReferenceExpression : Expression { + + public ThisReferenceExpression() { + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return "[ThisReferenceExpression]"; + } + } + + public class ThrowStatement : Statement { + + Expression expression; + + public ThrowStatement(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[ThrowStatement Expression={0}]", Expression); + } + } + + public class TryCatchStatement : Statement { + + Statement statementBlock; + + List catchClauses; + + Statement finallyBlock; + + public TryCatchStatement(Statement statementBlock, List catchClauses, Statement finallyBlock) { + StatementBlock = statementBlock; + CatchClauses = catchClauses; + FinallyBlock = finallyBlock; + } + + public Statement StatementBlock { + get { + return statementBlock; + } + set { + statementBlock = value ?? Statement.Null; + } + } + + public List CatchClauses { + get { + return catchClauses; + } + set { + catchClauses = value ?? new List(); + } + } + + public Statement FinallyBlock { + get { + return finallyBlock; + } + set { + finallyBlock = value ?? Statement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[TryCatchStatement StatementBlock={0} CatchClauses={1} FinallyBlock={2}]", StatementBlock, GetCollectionString(CatchClauses), FinallyBlock); + } + } + + public class TypeDeclaration : AttributedNode { + + string name; + + ClassType type; + + List baseTypes; + + List templates; + + public TypeDeclaration(Modifier modifier, List attributes) : + base(attributes) { + Modifier = modifier; + name = ""; + baseTypes = new List(); + templates = new List(); + } + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public ClassType Type { + get { + return type; + } + set { + type = value; + } + } + + public List BaseTypes { + get { + return baseTypes; + } + set { + baseTypes = value ?? new List(); + } + } + + public List Templates { + get { + return templates; + } + set { + templates = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[TypeDeclaration Name={0} Type={1} BaseTypes={2} Templates={3} Attributes={4} Mod" + + "ifier={5}]", Name, Type, GetCollectionString(BaseTypes), GetCollectionString(Templates), GetCollectionString(Attributes), Modifier); + } + } + + public class TypeOfExpression : Expression { + + TypeReference typeReference; + + public TypeOfExpression(TypeReference typeReference) { + TypeReference = typeReference; + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[TypeOfExpression TypeReference={0}]", TypeReference); + } + } + + public class TypeOfIsExpression : Expression { + + Expression expression; + + TypeReference typeReference; + + public TypeOfIsExpression(Expression expression, TypeReference typeReference) { + Expression = expression; + TypeReference = typeReference; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[TypeOfIsExpression Expression={0} TypeReference={1}]", Expression, TypeReference); + } + } + + public class TypeReferenceExpression : Expression { + + TypeReference typeReference; + +public TypeReferenceExpression(string typeName) : this(new TypeReference(typeName)) {} + + public TypeReferenceExpression(TypeReference typeReference) { + TypeReference = typeReference; + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[TypeReferenceExpression TypeReference={0}]", TypeReference); + } + } + + public class UnaryOperatorExpression : Expression { + + UnaryOperatorType op; + + Expression expression; + + public UnaryOperatorExpression(UnaryOperatorType op) { + Op = op; + expression = Expression.Null; + } + + public UnaryOperatorExpression(Expression expression, UnaryOperatorType op) { + Expression = expression; + Op = op; + } + + public UnaryOperatorType Op { + get { + return op; + } + set { + op = value; + } + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[UnaryOperatorExpression Op={0} Expression={1}]", Op, Expression); + } + } + + public class UncheckedExpression : Expression { + + Expression expression; + + public UncheckedExpression(Expression expression) { + Expression = expression; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[UncheckedExpression Expression={0}]", Expression); + } + } + + public class UncheckedStatement : Statement { + + Statement block; + + public UncheckedStatement(Statement block) { + Block = block; + } + + public Statement Block { + get { + return block; + } + set { + block = value ?? Statement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[UncheckedStatement Block={0}]", Block); + } + } + + public class UnsafeStatement : Statement { + + Statement block; + + public UnsafeStatement(Statement block) { + Block = block; + } + + public Statement Block { + get { + return block; + } + set { + block = value ?? Statement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[UnsafeStatement Block={0}]", Block); + } + } + + public class Using : AbstractNode { + + string name; + + TypeReference alias; + + public Using(string name) { + Name = name; + alias = TypeReference.Null; + } + + public Using(string name, TypeReference alias) { + Name = name; + Alias = alias; + } + + public string Name { + get { + return name; + } + set { + name = string.IsNullOrEmpty(value) ? "?" : value; + } + } + + public TypeReference Alias { + get { + return alias; + } + set { + alias = value ?? TypeReference.Null; + } + } + + public bool IsAlias { + get { +return !alias.IsNull; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[Using Name={0} Alias={1}]", Name, Alias); + } + } + + public class UsingDeclaration : AbstractNode { + + List usings; + +public UsingDeclaration(string nameSpace) : this(nameSpace, null) {} +public UsingDeclaration(string nameSpace, TypeReference alias) { usings = new List(1); usings.Add(new Using(nameSpace, alias)); } + + public UsingDeclaration(List usings) { + Usings = usings; + } + + public List Usings { + get { + return usings; + } + set { + usings = value ?? new List(); + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[UsingDeclaration Usings={0}]", GetCollectionString(Usings)); + } + } + + public class UsingStatement : StatementWithEmbeddedStatement { + + Statement resourceAcquisition; + + public UsingStatement(Statement resourceAcquisition, Statement embeddedStatement) { + ResourceAcquisition = resourceAcquisition; + EmbeddedStatement = embeddedStatement; + } + + public Statement ResourceAcquisition { + get { + return resourceAcquisition; + } + set { + resourceAcquisition = value ?? Statement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[UsingStatement ResourceAcquisition={0} EmbeddedStatement={1}]", ResourceAcquisition, EmbeddedStatement); + } + } + + public class VariableDeclaration : AbstractNode { + + string name; + + Expression initializer; + + TypeReference typeReference; + + public VariableDeclaration(string name) { + Name = name; + initializer = Expression.Null; + typeReference = TypeReference.Null; + } + + public VariableDeclaration(string name, Expression initializer) { + Name = name; + Initializer = initializer; + typeReference = TypeReference.Null; + } + + public VariableDeclaration(string name, Expression initializer, TypeReference typeReference) { + Name = name; + Initializer = initializer; + TypeReference = typeReference; + } + + public string Name { + get { + return name; + } + set { + name = value ?? ""; + } + } + + public Expression Initializer { + get { + return initializer; + } + set { + initializer = value ?? Expression.Null; + } + } + + public TypeReference TypeReference { + get { + return typeReference; + } + set { + typeReference = value ?? TypeReference.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[VariableDeclaration Name={0} Initializer={1} TypeReference={2}]", Name, Initializer, TypeReference); + } + } + + public class WithStatement : Statement { + + Expression expression; + + BlockStatement body; + + public WithStatement(Expression expression) { + Expression = expression; + body = BlockStatement.Null; + } + + public Expression Expression { + get { + return expression; + } + set { + expression = value ?? Expression.Null; + } + } + + public BlockStatement Body { + get { + return body; + } + set { + body = value ?? BlockStatement.Null; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[WithStatement Expression={0} Body={1}]", Expression, Body); + } + } + + public class YieldStatement : Statement { + + Statement statement; + + public YieldStatement(Statement statement) { + Statement = statement; + } + + public Statement Statement { + get { + return statement; + } + set { + statement = value ?? Statement.Null; + } + } + + public bool IsYieldReturn { + get { +return statement is ReturnStatement; + } + } + + public bool IsYieldBreak { + get { +return statement is BreakStatement; + } + } + + public override object AcceptVisitor(IAstVisitor visitor, object data) { + return visitor.Visit(this, data); + } + + public override string ToString() { + return string.Format("[YieldStatement Statement={0}]", Statement); + } + } +} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/INode.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/INode.cs index bade577980..164209e515 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/INode.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/INode.cs @@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.Parser.AST /// The visitor to accept /// Additional data for the visitor /// The paremeter - object AcceptChildren(IASTVisitor visitor, object data); + object AcceptChildren(IAstVisitor visitor, object data); /// /// Accept the visitor @@ -46,6 +46,6 @@ namespace ICSharpCode.NRefactory.Parser.AST /// The visitor to accept /// Additional data for the visitor /// The value the visitor returns after the visit - object AcceptVisitor(IASTVisitor visitor, object data); + object AcceptVisitor(IAstVisitor visitor, object data); } } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/INullable.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/INullable.cs similarity index 100% rename from src/Libraries/NRefactory/Project/Src/Parser/AST/General/INullable.cs rename to src/Libraries/NRefactory/Project/Src/Parser/AST/INullable.cs diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/ParametrizedNode.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/ParametrizedNode.cs deleted file mode 100644 index c3af50fea8..0000000000 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/ParametrizedNode.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Diagnostics; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.Parser.AST -{ - public abstract class ParametrizedNode : AttributedNode - { - protected string name = String.Empty; - protected List parameters; - - public string Name { - get { - return name; - } - set { - name = value == null ? String.Empty : value; - } - } - - public List Parameters { - get { - return parameters; - } - set { - parameters = value == null ? new List(1) : value; - } - } - - public ParametrizedNode(Modifier modifier, List attributes) : this(modifier, attributes, null) - { - } - - public ParametrizedNode(Modifier modifier, List attributes, string name) : this(modifier, attributes, name, null) - { - } - - public ParametrizedNode(Modifier modifier, List attributes, string name, List parameters) : base(modifier, attributes) - { - // use properties because of the null check. - this.Name = name; - this.Parameters = parameters; - } - } -} diff --git a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeReference.cs b/src/Libraries/NRefactory/Project/Src/Parser/AST/TypeReference.cs similarity index 98% rename from src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeReference.cs rename to src/Libraries/NRefactory/Project/Src/Parser/AST/TypeReference.cs index c4440d995f..3841c1d3e0 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/AST/General/TypeReference.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/AST/TypeReference.cs @@ -263,7 +263,7 @@ namespace ICSharpCode.NRefactory.Parser.AST protected TypeReference() {} - public override object AcceptVisitor(IASTVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.Visit(this, data); } @@ -304,7 +304,7 @@ namespace ICSharpCode.NRefactory.Parser.AST return true; } } - public override object AcceptVisitor(IASTVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return data; } @@ -349,7 +349,7 @@ namespace ICSharpCode.NRefactory.Parser.AST this.baseType = outerClass; } - public override object AcceptVisitor(IASTVisitor visitor, object data) + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.Visit(this, data); } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index cdca88b1aa..226e176373 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -2091,7 +2091,7 @@ out stmt); lexer.NextToken(); #line 1239 "cs.ATG" - EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes); + EventDeclaration eventDecl = new EventDeclaration(null, null, m.Modifier, attributes, null); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); compilationUnit.BlockStart(eventDecl); @@ -2685,7 +2685,7 @@ out type); Expect(1); #line 1514 "cs.ATG" - EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes); + EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null); compilationUnit.AddChild(ed); Expect(11); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index fff9ef15a4..cb93493ef3 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -1236,7 +1236,7 @@ StructMemberDecl attributes> .) | /*--- event declaration: */ (. m.Check(Modifier.PropertysEventsMethods); .) - "event" (. EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes); + "event" (. EventDeclaration eventDecl = new EventDeclaration(null, null, m.Modifier, attributes, null); eventDecl.StartLocation = t.Location; compilationUnit.AddChild(eventDecl); compilationUnit.BlockStart(eventDecl); @@ -1511,7 +1511,7 @@ InterfaceMemberDecl "{" (. Point bodyStart = t.Location;.) InterfaceAccessors "}" (. id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;.) ) /*--- interface event declaration: */ - | "event" (. if (startLocation.X == -1) startLocation = t.Location; .) Type ident (. EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes); + | "event" (. if (startLocation.X == -1) startLocation = t.Location; .) Type ident (. EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes, null); compilationUnit.AddChild(ed); .) ";" (. ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; .) diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs index 313ae0b3cb..9d570e3eb3 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs @@ -401,7 +401,7 @@ out u); void GlobalAttributeSection() { -#line 2162 "VBNET.ATG" +#line 2170 "VBNET.ATG" Point startPos = t.Location; Expect(27); if (la.kind == 49) { @@ -410,20 +410,20 @@ out u); lexer.NextToken(); } else SynErr(208); -#line 2164 "VBNET.ATG" +#line 2172 "VBNET.ATG" string attributeTarget = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture); List attributes = new List(); ASTAttribute attribute; Expect(13); Attribute( -#line 2168 "VBNET.ATG" +#line 2176 "VBNET.ATG" out attribute); -#line 2168 "VBNET.ATG" +#line 2176 "VBNET.ATG" attributes.Add(attribute); while ( -#line 2169 "VBNET.ATG" +#line 2177 "VBNET.ATG" NotFinalComma()) { if (la.kind == 12) { lexer.NextToken(); @@ -435,10 +435,10 @@ NotFinalComma()) { Expect(13); } Attribute( -#line 2169 "VBNET.ATG" +#line 2177 "VBNET.ATG" out attribute); -#line 2169 "VBNET.ATG" +#line 2177 "VBNET.ATG" attributes.Add(attribute); } if (la.kind == 12) { @@ -447,7 +447,7 @@ out attribute); Expect(26); EndOfStmt(); -#line 2174 "VBNET.ATG" +#line 2182 "VBNET.ATG" AttributeSection section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -564,47 +564,47 @@ out aliasedType); } void Qualident( -#line 2890 "VBNET.ATG" +#line 2898 "VBNET.ATG" out string qualident) { -#line 2892 "VBNET.ATG" +#line 2900 "VBNET.ATG" string name; qualidentBuilder.Length = 0; Identifier(); -#line 2896 "VBNET.ATG" +#line 2904 "VBNET.ATG" qualidentBuilder.Append(t.val); while ( -#line 2897 "VBNET.ATG" +#line 2905 "VBNET.ATG" DotAndIdentOrKw()) { Expect(10); IdentifierOrKeyword( -#line 2897 "VBNET.ATG" +#line 2905 "VBNET.ATG" out name); -#line 2897 "VBNET.ATG" +#line 2905 "VBNET.ATG" qualidentBuilder.Append('.'); qualidentBuilder.Append(name); } -#line 2899 "VBNET.ATG" +#line 2907 "VBNET.ATG" qualident = qualidentBuilder.ToString(); } void TypeName( -#line 2055 "VBNET.ATG" +#line 2063 "VBNET.ATG" out TypeReference typeref) { -#line 2056 "VBNET.ATG" +#line 2064 "VBNET.ATG" ArrayList rank = null; NonArrayTypeName( -#line 2058 "VBNET.ATG" +#line 2066 "VBNET.ATG" out typeref, false); ArrayTypeModifiers( -#line 2059 "VBNET.ATG" +#line 2067 "VBNET.ATG" out rank); -#line 2060 "VBNET.ATG" +#line 2068 "VBNET.ATG" if (rank != null && typeref != null) { typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); } @@ -621,35 +621,35 @@ out rank); } void AttributeSection( -#line 2231 "VBNET.ATG" +#line 2239 "VBNET.ATG" out AttributeSection section) { -#line 2233 "VBNET.ATG" +#line 2241 "VBNET.ATG" string attributeTarget = "";List attributes = new List(); ASTAttribute attribute; Expect(27); -#line 2237 "VBNET.ATG" +#line 2245 "VBNET.ATG" Point startPos = t.Location; if ( -#line 2238 "VBNET.ATG" +#line 2246 "VBNET.ATG" IsLocalAttrTarget()) { if (la.kind == 93) { lexer.NextToken(); -#line 2239 "VBNET.ATG" +#line 2247 "VBNET.ATG" attributeTarget = "event"; } else if (la.kind == 154) { lexer.NextToken(); -#line 2240 "VBNET.ATG" +#line 2248 "VBNET.ATG" attributeTarget = "return"; } else { Identifier(); -#line 2243 "VBNET.ATG" +#line 2251 "VBNET.ATG" string val = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture); if (val != "field" || val != "method" || val != "module" || val != "param" || @@ -662,20 +662,20 @@ IsLocalAttrTarget()) { Expect(13); } Attribute( -#line 2253 "VBNET.ATG" +#line 2261 "VBNET.ATG" out attribute); -#line 2253 "VBNET.ATG" +#line 2261 "VBNET.ATG" attributes.Add(attribute); while ( -#line 2254 "VBNET.ATG" +#line 2262 "VBNET.ATG" NotFinalComma()) { Expect(12); Attribute( -#line 2254 "VBNET.ATG" +#line 2262 "VBNET.ATG" out attribute); -#line 2254 "VBNET.ATG" +#line 2262 "VBNET.ATG" attributes.Add(attribute); } if (la.kind == 12) { @@ -683,7 +683,7 @@ out attribute); } Expect(26); -#line 2258 "VBNET.ATG" +#line 2266 "VBNET.ATG" section = new AttributeSection(attributeTarget, attributes); section.StartLocation = startPos; section.EndLocation = t.EndLocation; @@ -691,69 +691,69 @@ out attribute); } void TypeModifier( -#line 2951 "VBNET.ATG" +#line 2959 "VBNET.ATG" Modifiers m) { switch (la.kind) { case 148: { lexer.NextToken(); -#line 2952 "VBNET.ATG" +#line 2960 "VBNET.ATG" m.Add(Modifier.Public, t.Location); break; } case 147: { lexer.NextToken(); -#line 2953 "VBNET.ATG" +#line 2961 "VBNET.ATG" m.Add(Modifier.Protected, t.Location); break; } case 99: { lexer.NextToken(); -#line 2954 "VBNET.ATG" +#line 2962 "VBNET.ATG" m.Add(Modifier.Internal, t.Location); break; } case 145: { lexer.NextToken(); -#line 2955 "VBNET.ATG" +#line 2963 "VBNET.ATG" m.Add(Modifier.Private, t.Location); break; } case 158: { lexer.NextToken(); -#line 2956 "VBNET.ATG" +#line 2964 "VBNET.ATG" m.Add(Modifier.Static, t.Location); break; } case 157: { lexer.NextToken(); -#line 2957 "VBNET.ATG" +#line 2965 "VBNET.ATG" m.Add(Modifier.New, t.Location); break; } case 122: { lexer.NextToken(); -#line 2958 "VBNET.ATG" +#line 2966 "VBNET.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 131: { lexer.NextToken(); -#line 2959 "VBNET.ATG" +#line 2967 "VBNET.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 203: { lexer.NextToken(); -#line 2960 "VBNET.ATG" +#line 2968 "VBNET.ATG" m.Add(Modifier.Partial, t.Location); break; } @@ -1158,42 +1158,42 @@ out constraint); } void ClassBaseType( -#line 933 "VBNET.ATG" +#line 936 "VBNET.ATG" out TypeReference typeRef) { -#line 935 "VBNET.ATG" +#line 938 "VBNET.ATG" typeRef = null; Expect(110); TypeName( -#line 938 "VBNET.ATG" +#line 941 "VBNET.ATG" out typeRef); EndOfStmt(); } void TypeImplementsClause( -#line 1665 "VBNET.ATG" +#line 1673 "VBNET.ATG" out List baseInterfaces) { -#line 1667 "VBNET.ATG" +#line 1675 "VBNET.ATG" baseInterfaces = new List(); TypeReference type = null; Expect(107); TypeName( -#line 1670 "VBNET.ATG" +#line 1678 "VBNET.ATG" out type); -#line 1672 "VBNET.ATG" +#line 1680 "VBNET.ATG" baseInterfaces.Add(type); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 1675 "VBNET.ATG" +#line 1683 "VBNET.ATG" out type); -#line 1676 "VBNET.ATG" +#line 1684 "VBNET.ATG" baseInterfaces.Add(type); } EndOfStmt(); @@ -1311,10 +1311,10 @@ m, attributes); } void NonArrayTypeName( -#line 2078 "VBNET.ATG" +#line 2086 "VBNET.ATG" out TypeReference typeref, bool canBeUnbound) { -#line 2080 "VBNET.ATG" +#line 2088 "VBNET.ATG" string name; typeref = null; bool isGlobal = false; @@ -1324,38 +1324,38 @@ out TypeReference typeref, bool canBeUnbound) { lexer.NextToken(); Expect(10); -#line 2085 "VBNET.ATG" +#line 2093 "VBNET.ATG" isGlobal = true; } QualIdentAndTypeArguments( -#line 2086 "VBNET.ATG" +#line 2094 "VBNET.ATG" out typeref, canBeUnbound); -#line 2087 "VBNET.ATG" +#line 2095 "VBNET.ATG" typeref.IsGlobal = isGlobal; while (la.kind == 10) { lexer.NextToken(); -#line 2088 "VBNET.ATG" +#line 2096 "VBNET.ATG" TypeReference nestedTypeRef; QualIdentAndTypeArguments( -#line 2089 "VBNET.ATG" +#line 2097 "VBNET.ATG" out nestedTypeRef, canBeUnbound); -#line 2090 "VBNET.ATG" +#line 2098 "VBNET.ATG" typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); } } else if (la.kind == 133) { lexer.NextToken(); -#line 2093 "VBNET.ATG" +#line 2101 "VBNET.ATG" typeref = new TypeReference("System.Object"); } else if (StartOf(9)) { PrimitiveTypeName( -#line 2094 "VBNET.ATG" +#line 2102 "VBNET.ATG" out name); -#line 2094 "VBNET.ATG" +#line 2102 "VBNET.ATG" typeref = new TypeReference(name); } else SynErr(218); } @@ -1383,27 +1383,27 @@ out f); } void InterfaceBase( -#line 1650 "VBNET.ATG" +#line 1658 "VBNET.ATG" out List bases) { -#line 1652 "VBNET.ATG" +#line 1660 "VBNET.ATG" TypeReference type; bases = new List(); Expect(110); TypeName( -#line 1656 "VBNET.ATG" +#line 1664 "VBNET.ATG" out type); -#line 1656 "VBNET.ATG" +#line 1664 "VBNET.ATG" bases.Add(type); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 1659 "VBNET.ATG" +#line 1667 "VBNET.ATG" out type); -#line 1659 "VBNET.ATG" +#line 1667 "VBNET.ATG" bases.Add(type); } Expect(1); @@ -1424,27 +1424,27 @@ TypeDeclaration newType) { } void FormalParameterList( -#line 2265 "VBNET.ATG" +#line 2273 "VBNET.ATG" List parameter) { -#line 2267 "VBNET.ATG" +#line 2275 "VBNET.ATG" ParameterDeclarationExpression p; AttributeSection section; List attributes = new List(); while (la.kind == 27) { AttributeSection( -#line 2271 "VBNET.ATG" +#line 2279 "VBNET.ATG" out section); -#line 2271 "VBNET.ATG" +#line 2279 "VBNET.ATG" attributes.Add(section); } FormalParameter( -#line 2273 "VBNET.ATG" +#line 2281 "VBNET.ATG" out p); -#line 2275 "VBNET.ATG" +#line 2283 "VBNET.ATG" bool paramsFound = false; p.Attributes = attributes; parameter.Add(p); @@ -1452,166 +1452,166 @@ out p); while (la.kind == 12) { lexer.NextToken(); -#line 2280 "VBNET.ATG" +#line 2288 "VBNET.ATG" if (paramsFound) Error("params array must be at end of parameter list"); while (la.kind == 27) { AttributeSection( -#line 2281 "VBNET.ATG" +#line 2289 "VBNET.ATG" out section); -#line 2281 "VBNET.ATG" +#line 2289 "VBNET.ATG" attributes.Add(section); } FormalParameter( -#line 2283 "VBNET.ATG" +#line 2291 "VBNET.ATG" out p); -#line 2283 "VBNET.ATG" +#line 2291 "VBNET.ATG" p.Attributes = attributes; parameter.Add(p); } } void MemberModifier( -#line 2963 "VBNET.ATG" +#line 2971 "VBNET.ATG" Modifiers m) { switch (la.kind) { case 122: { lexer.NextToken(); -#line 2964 "VBNET.ATG" +#line 2972 "VBNET.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 79: { lexer.NextToken(); -#line 2965 "VBNET.ATG" +#line 2973 "VBNET.ATG" m.Add(Modifier.Default, t.Location); break; } case 99: { lexer.NextToken(); -#line 2966 "VBNET.ATG" +#line 2974 "VBNET.ATG" m.Add(Modifier.Internal, t.Location); break; } case 157: { lexer.NextToken(); -#line 2967 "VBNET.ATG" +#line 2975 "VBNET.ATG" m.Add(Modifier.New, t.Location); break; } case 142: { lexer.NextToken(); -#line 2968 "VBNET.ATG" +#line 2976 "VBNET.ATG" m.Add(Modifier.Override, t.Location); break; } case 123: { lexer.NextToken(); -#line 2969 "VBNET.ATG" +#line 2977 "VBNET.ATG" m.Add(Modifier.Abstract, t.Location); break; } case 145: { lexer.NextToken(); -#line 2970 "VBNET.ATG" +#line 2978 "VBNET.ATG" m.Add(Modifier.Private, t.Location); break; } case 147: { lexer.NextToken(); -#line 2971 "VBNET.ATG" +#line 2979 "VBNET.ATG" m.Add(Modifier.Protected, t.Location); break; } case 148: { lexer.NextToken(); -#line 2972 "VBNET.ATG" +#line 2980 "VBNET.ATG" m.Add(Modifier.Public, t.Location); break; } case 131: { lexer.NextToken(); -#line 2973 "VBNET.ATG" +#line 2981 "VBNET.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 132: { lexer.NextToken(); -#line 2974 "VBNET.ATG" +#line 2982 "VBNET.ATG" m.Add(Modifier.Sealed, t.Location); break; } case 158: { lexer.NextToken(); -#line 2975 "VBNET.ATG" +#line 2983 "VBNET.ATG" m.Add(Modifier.Static, t.Location); break; } case 141: { lexer.NextToken(); -#line 2976 "VBNET.ATG" +#line 2984 "VBNET.ATG" m.Add(Modifier.Virtual, t.Location); break; } case 140: { lexer.NextToken(); -#line 2977 "VBNET.ATG" +#line 2985 "VBNET.ATG" m.Add(Modifier.Overloads, t.Location); break; } case 150: { lexer.NextToken(); -#line 2978 "VBNET.ATG" +#line 2986 "VBNET.ATG" m.Add(Modifier.ReadOnly, t.Location); break; } case 184: { lexer.NextToken(); -#line 2979 "VBNET.ATG" +#line 2987 "VBNET.ATG" m.Add(Modifier.WriteOnly, t.Location); break; } case 183: { lexer.NextToken(); -#line 2980 "VBNET.ATG" +#line 2988 "VBNET.ATG" m.Add(Modifier.WithEvents, t.Location); break; } case 81: { lexer.NextToken(); -#line 2981 "VBNET.ATG" +#line 2989 "VBNET.ATG" m.Add(Modifier.Dim, t.Location); break; } case 202: { lexer.NextToken(); -#line 2982 "VBNET.ATG" +#line 2990 "VBNET.ATG" m.Add(Modifier.Widening, t.Location); break; } case 201: { lexer.NextToken(); -#line 2983 "VBNET.ATG" +#line 2991 "VBNET.ATG" m.Add(Modifier.Narrowing, t.Location); break; } @@ -1620,18 +1620,18 @@ Modifiers m) { } void ClassMemberDecl( -#line 929 "VBNET.ATG" +#line 932 "VBNET.ATG" Modifiers m, List attributes) { StructureMemberDecl( -#line 930 "VBNET.ATG" +#line 933 "VBNET.ATG" m, attributes); } void StructureMemberDecl( -#line 943 "VBNET.ATG" +#line 946 "VBNET.ATG" Modifiers m, List attributes) { -#line 945 "VBNET.ATG" +#line 948 "VBNET.ATG" TypeReference type = null; List p = new List(); Statement stmt = null; @@ -1641,37 +1641,37 @@ Modifiers m, List attributes) { switch (la.kind) { case 67: case 80: case 90: case 112: case 121: case 166: { NonModuleDeclaration( -#line 951 "VBNET.ATG" +#line 954 "VBNET.ATG" m, attributes); break; } case 167: { lexer.NextToken(); -#line 955 "VBNET.ATG" +#line 958 "VBNET.ATG" Point startPos = t.Location; if (StartOf(12)) { -#line 959 "VBNET.ATG" +#line 962 "VBNET.ATG" string name = String.Empty; - MethodDeclaration methodDeclaration; ArrayList handlesClause = null; + MethodDeclaration methodDeclaration; List handlesClause = null; List implementsClause = null; Identifier(); -#line 965 "VBNET.ATG" +#line 968 "VBNET.ATG" name = t.val; m.Check(Modifier.VBMethods); TypeParameterList( -#line 968 "VBNET.ATG" +#line 971 "VBNET.ATG" templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 969 "VBNET.ATG" +#line 972 "VBNET.ATG" p); } Expect(25); @@ -1679,23 +1679,23 @@ p); if (la.kind == 105 || la.kind == 107) { if (la.kind == 107) { ImplementsClause( -#line 972 "VBNET.ATG" +#line 975 "VBNET.ATG" out implementsClause); } else { HandlesClause( -#line 974 "VBNET.ATG" +#line 977 "VBNET.ATG" out handlesClause); } } -#line 977 "VBNET.ATG" +#line 980 "VBNET.ATG" Point endLocation = t.EndLocation; Expect(1); if ( -#line 981 "VBNET.ATG" +#line 984 "VBNET.ATG" IsMustOverride(m)) { -#line 983 "VBNET.ATG" +#line 986 "VBNET.ATG" methodDeclaration = new MethodDeclaration(name, m.Modifier, null, p, attributes); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = endLocation; @@ -1709,7 +1709,7 @@ IsMustOverride(m)) { } else if (StartOf(13)) { -#line 996 "VBNET.ATG" +#line 999 "VBNET.ATG" methodDeclaration = new MethodDeclaration(name, m.Modifier, null, p, attributes); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = endLocation; @@ -1723,17 +1723,17 @@ IsMustOverride(m)) { compilationUnit.BlockStart(methodDeclaration); Block( -#line 1008 "VBNET.ATG" +#line 1011 "VBNET.ATG" out stmt); -#line 1010 "VBNET.ATG" +#line 1013 "VBNET.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; Expect(88); Expect(167); -#line 1013 "VBNET.ATG" +#line 1016 "VBNET.ATG" methodDeclaration.Body.EndLocation = t.EndLocation; Expect(1); } else SynErr(220); @@ -1743,29 +1743,29 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1016 "VBNET.ATG" +#line 1019 "VBNET.ATG" p); } Expect(25); } -#line 1017 "VBNET.ATG" +#line 1020 "VBNET.ATG" m.Check(Modifier.Constructors); -#line 1018 "VBNET.ATG" +#line 1021 "VBNET.ATG" Point constructorEndLocation = t.EndLocation; Expect(1); Block( -#line 1020 "VBNET.ATG" +#line 1023 "VBNET.ATG" out stmt); Expect(88); Expect(167); -#line 1021 "VBNET.ATG" +#line 1024 "VBNET.ATG" Point endLocation = t.EndLocation; Expect(1); -#line 1023 "VBNET.ATG" +#line 1026 "VBNET.ATG" ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes); cd.StartLocation = m.GetDeclarationLocation(startPos); cd.EndLocation = constructorEndLocation; @@ -1779,26 +1779,26 @@ out stmt); case 100: { lexer.NextToken(); -#line 1035 "VBNET.ATG" +#line 1038 "VBNET.ATG" m.Check(Modifier.VBMethods); string name = String.Empty; Point startPos = t.Location; - MethodDeclaration methodDeclaration;ArrayList handlesClause = null; + MethodDeclaration methodDeclaration;List handlesClause = null; List implementsClause = null; AttributeSection returnTypeAttributeSection = null; Identifier(); -#line 1042 "VBNET.ATG" +#line 1045 "VBNET.ATG" name = t.val; TypeParameterList( -#line 1043 "VBNET.ATG" +#line 1046 "VBNET.ATG" templates); if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1044 "VBNET.ATG" +#line 1047 "VBNET.ATG" p); } Expect(25); @@ -1807,15 +1807,15 @@ p); lexer.NextToken(); while (la.kind == 27) { AttributeSection( -#line 1045 "VBNET.ATG" +#line 1048 "VBNET.ATG" out returnTypeAttributeSection); } TypeName( -#line 1045 "VBNET.ATG" +#line 1048 "VBNET.ATG" out type); } -#line 1047 "VBNET.ATG" +#line 1050 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object"); } @@ -1823,20 +1823,20 @@ out type); if (la.kind == 105 || la.kind == 107) { if (la.kind == 107) { ImplementsClause( -#line 1053 "VBNET.ATG" +#line 1056 "VBNET.ATG" out implementsClause); } else { HandlesClause( -#line 1055 "VBNET.ATG" +#line 1058 "VBNET.ATG" out handlesClause); } } Expect(1); if ( -#line 1061 "VBNET.ATG" +#line 1064 "VBNET.ATG" IsMustOverride(m)) { -#line 1063 "VBNET.ATG" +#line 1066 "VBNET.ATG" methodDeclaration = new MethodDeclaration(name, m.Modifier, type, p, attributes); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; @@ -1844,12 +1844,15 @@ IsMustOverride(m)) { methodDeclaration.HandlesClause = handlesClause; methodDeclaration.Templates = templates; methodDeclaration.InterfaceImplementations = implementsClause; - methodDeclaration.ReturnTypeAttributeSection = returnTypeAttributeSection; + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + methodDeclaration.Attributes.Add(returnTypeAttributeSection); + } compilationUnit.AddChild(methodDeclaration); } else if (StartOf(13)) { -#line 1075 "VBNET.ATG" +#line 1081 "VBNET.ATG" methodDeclaration = new MethodDeclaration(name, m.Modifier, type, p, attributes); methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos); methodDeclaration.EndLocation = t.EndLocation; @@ -1857,23 +1860,26 @@ IsMustOverride(m)) { methodDeclaration.Templates = templates; methodDeclaration.HandlesClause = handlesClause; methodDeclaration.InterfaceImplementations = implementsClause; - methodDeclaration.ReturnTypeAttributeSection = returnTypeAttributeSection; + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + methodDeclaration.Attributes.Add(returnTypeAttributeSection); + } compilationUnit.AddChild(methodDeclaration); compilationUnit.BlockStart(methodDeclaration); Block( -#line 1087 "VBNET.ATG" +#line 1096 "VBNET.ATG" out stmt); -#line 1089 "VBNET.ATG" +#line 1098 "VBNET.ATG" compilationUnit.BlockEnd(); methodDeclaration.Body = (BlockStatement)stmt; Expect(88); Expect(100); -#line 1094 "VBNET.ATG" +#line 1103 "VBNET.ATG" methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation; methodDeclaration.Body.EndLocation = t.EndLocation; @@ -1884,7 +1890,7 @@ out stmt); case 78: { lexer.NextToken(); -#line 1103 "VBNET.ATG" +#line 1112 "VBNET.ATG" m.Check(Modifier.VBExternalMethods); Point startPos = t.Location; CharsetModifier charsetModifer = CharsetModifier.None; @@ -1894,39 +1900,39 @@ out stmt); if (StartOf(14)) { Charset( -#line 1110 "VBNET.ATG" +#line 1119 "VBNET.ATG" out charsetModifer); } if (la.kind == 167) { lexer.NextToken(); Identifier(); -#line 1113 "VBNET.ATG" +#line 1122 "VBNET.ATG" name = t.val; Expect(115); Expect(3); -#line 1114 "VBNET.ATG" +#line 1123 "VBNET.ATG" library = t.val.ToString(); if (la.kind == 44) { lexer.NextToken(); Expect(3); -#line 1115 "VBNET.ATG" +#line 1124 "VBNET.ATG" alias = t.val.ToString(); } if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1116 "VBNET.ATG" +#line 1125 "VBNET.ATG" p); } Expect(25); } Expect(1); -#line 1119 "VBNET.ATG" +#line 1128 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; @@ -1936,25 +1942,25 @@ p); lexer.NextToken(); Identifier(); -#line 1126 "VBNET.ATG" +#line 1135 "VBNET.ATG" name = t.val; Expect(115); Expect(3); -#line 1127 "VBNET.ATG" +#line 1136 "VBNET.ATG" library = t.val; if (la.kind == 44) { lexer.NextToken(); Expect(3); -#line 1128 "VBNET.ATG" +#line 1137 "VBNET.ATG" alias = t.val; } if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1129 "VBNET.ATG" +#line 1138 "VBNET.ATG" p); } Expect(25); @@ -1962,12 +1968,12 @@ p); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1130 "VBNET.ATG" +#line 1139 "VBNET.ATG" out type); } Expect(1); -#line 1133 "VBNET.ATG" +#line 1142 "VBNET.ATG" DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer); declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos); declareDeclaration.EndLocation = t.EndLocation; @@ -1979,7 +1985,7 @@ out type); case 93: { lexer.NextToken(); -#line 1143 "VBNET.ATG" +#line 1152 "VBNET.ATG" m.Check(Modifier.VBEvents); Point startPos = t.Location; EventDeclaration eventDeclaration; @@ -1988,19 +1994,19 @@ out type); Identifier(); -#line 1149 "VBNET.ATG" +#line 1158 "VBNET.ATG" name= t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1151 "VBNET.ATG" +#line 1160 "VBNET.ATG" out type); } else if (la.kind == 1 || la.kind == 24 || la.kind == 107) { if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1153 "VBNET.ATG" +#line 1162 "VBNET.ATG" p); } Expect(25); @@ -2008,11 +2014,11 @@ p); } else SynErr(224); if (la.kind == 107) { ImplementsClause( -#line 1155 "VBNET.ATG" +#line 1164 "VBNET.ATG" out implementsClause); } -#line 1157 "VBNET.ATG" +#line 1166 "VBNET.ATG" eventDeclaration = new EventDeclaration(type, m.Modifier, p, attributes, name, implementsClause); eventDeclaration.StartLocation = m.GetDeclarationLocation(startPos); eventDeclaration.EndLocation = t.EndLocation; @@ -2023,26 +2029,26 @@ out implementsClause); } case 2: case 47: case 49: case 50: case 51: case 70: case 144: case 169: case 176: case 177: { -#line 1164 "VBNET.ATG" +#line 1173 "VBNET.ATG" Point startPos = t.Location; -#line 1166 "VBNET.ATG" +#line 1175 "VBNET.ATG" m.Check(Modifier.Fields); FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(startPos); VariableDeclarator( -#line 1170 "VBNET.ATG" +#line 1179 "VBNET.ATG" variableDeclarators); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( -#line 1171 "VBNET.ATG" +#line 1180 "VBNET.ATG" variableDeclarators); } Expect(1); -#line 1174 "VBNET.ATG" +#line 1183 "VBNET.ATG" fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); @@ -2051,35 +2057,35 @@ variableDeclarators); } case 71: { -#line 1179 "VBNET.ATG" +#line 1188 "VBNET.ATG" m.Check(Modifier.Fields); lexer.NextToken(); -#line 1180 "VBNET.ATG" +#line 1189 "VBNET.ATG" m.Add(Modifier.Const, t.Location); -#line 1182 "VBNET.ATG" +#line 1191 "VBNET.ATG" FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier); fd.StartLocation = m.GetDeclarationLocation(t.Location); List constantDeclarators = new List(); ConstantDeclarator( -#line 1186 "VBNET.ATG" +#line 1195 "VBNET.ATG" constantDeclarators); while (la.kind == 12) { lexer.NextToken(); ConstantDeclarator( -#line 1187 "VBNET.ATG" +#line 1196 "VBNET.ATG" constantDeclarators); } -#line 1189 "VBNET.ATG" +#line 1198 "VBNET.ATG" fd.Fields = constantDeclarators; fd.EndLocation = t.Location; Expect(1); -#line 1194 "VBNET.ATG" +#line 1203 "VBNET.ATG" fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); @@ -2088,20 +2094,20 @@ constantDeclarators); case 146: { lexer.NextToken(); -#line 1200 "VBNET.ATG" +#line 1209 "VBNET.ATG" m.Check(Modifier.VBProperties); Point startPos = t.Location; List implementsClause = null; Identifier(); -#line 1204 "VBNET.ATG" +#line 1213 "VBNET.ATG" string propertyName = t.val; if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1205 "VBNET.ATG" +#line 1214 "VBNET.ATG" p); } Expect(25); @@ -2109,26 +2115,26 @@ p); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1206 "VBNET.ATG" +#line 1215 "VBNET.ATG" out type); } -#line 1208 "VBNET.ATG" +#line 1217 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object"); } if (la.kind == 107) { ImplementsClause( -#line 1212 "VBNET.ATG" +#line 1221 "VBNET.ATG" out implementsClause); } Expect(1); if ( -#line 1216 "VBNET.ATG" +#line 1225 "VBNET.ATG" IsMustOverride(m)) { -#line 1218 "VBNET.ATG" +#line 1227 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; @@ -2139,7 +2145,7 @@ IsMustOverride(m)) { } else if (la.kind == 27 || la.kind == 101 || la.kind == 156) { -#line 1228 "VBNET.ATG" +#line 1237 "VBNET.ATG" PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes); pDecl.StartLocation = m.GetDeclarationLocation(startPos); pDecl.EndLocation = t.Location; @@ -2151,13 +2157,13 @@ IsMustOverride(m)) { PropertySetRegion setRegion; AccessorDecls( -#line 1238 "VBNET.ATG" +#line 1247 "VBNET.ATG" out getRegion, out setRegion); Expect(88); Expect(146); Expect(1); -#line 1242 "VBNET.ATG" +#line 1251 "VBNET.ATG" pDecl.GetRegion = getRegion; pDecl.SetRegion = setRegion; pDecl.BodyEnd = t.EndLocation; @@ -2169,11 +2175,11 @@ out getRegion, out setRegion); case 204: { lexer.NextToken(); -#line 1249 "VBNET.ATG" +#line 1258 "VBNET.ATG" Point startPos = t.Location; Expect(93); -#line 1251 "VBNET.ATG" +#line 1260 "VBNET.ATG" m.Check(Modifier.VBCustomEvents); EventAddRemoveRegion eventAccessorDeclaration; EventAddRegion addHandlerAccessorDeclaration = null; @@ -2183,24 +2189,24 @@ out getRegion, out setRegion); Identifier(); -#line 1258 "VBNET.ATG" +#line 1267 "VBNET.ATG" string customEventName = t.val; Expect(48); TypeName( -#line 1259 "VBNET.ATG" +#line 1268 "VBNET.ATG" out type); if (la.kind == 107) { ImplementsClause( -#line 1260 "VBNET.ATG" +#line 1269 "VBNET.ATG" out implementsClause); } Expect(1); while (StartOf(15)) { EventAccessorDeclaration( -#line 1263 "VBNET.ATG" +#line 1272 "VBNET.ATG" out eventAccessorDeclaration); -#line 1265 "VBNET.ATG" +#line 1274 "VBNET.ATG" if(eventAccessorDeclaration is EventAddRegion) { addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration; @@ -2219,7 +2225,7 @@ out eventAccessorDeclaration); Expect(93); Expect(1); -#line 1281 "VBNET.ATG" +#line 1290 "VBNET.ATG" if(addHandlerAccessorDeclaration == null) { Error("Need to provide AddHandler accessor."); @@ -2235,7 +2241,7 @@ out eventAccessorDeclaration); Error("Need to provide RaiseEvent accessor."); } - EventDeclaration decl = new EventDeclaration(type, customEventName, m.Modifier, attributes); + EventDeclaration decl = new EventDeclaration(type, customEventName, m.Modifier, attributes, null); decl.StartLocation = m.GetDeclarationLocation(startPos); decl.EndLocation = t.EndLocation; decl.AddRegion = addHandlerAccessorDeclaration; @@ -2248,7 +2254,7 @@ out eventAccessorDeclaration); case 187: { lexer.NextToken(); -#line 1307 "VBNET.ATG" +#line 1316 "VBNET.ATG" m.Check(Modifier.VBOperators); Point startPos = t.Location; TypeReference returnType = NullTypeReference.Instance; @@ -2260,7 +2266,7 @@ out eventAccessorDeclaration); List returnTypeAttributes = new List(); OverloadableOperator( -#line 1317 "VBNET.ATG" +#line 1326 "VBNET.ATG" out operatorType); Expect(24); if (la.kind == 55) { @@ -2268,16 +2274,16 @@ out operatorType); } Identifier(); -#line 1318 "VBNET.ATG" +#line 1327 "VBNET.ATG" operandName = t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1319 "VBNET.ATG" +#line 1328 "VBNET.ATG" out operandType); } -#line 1320 "VBNET.ATG" +#line 1329 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParamModifier.In)); while (la.kind == 12) { lexer.NextToken(); @@ -2286,55 +2292,54 @@ out operandType); } Identifier(); -#line 1324 "VBNET.ATG" +#line 1333 "VBNET.ATG" operandName = t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1325 "VBNET.ATG" +#line 1334 "VBNET.ATG" out operandType); } -#line 1326 "VBNET.ATG" +#line 1335 "VBNET.ATG" parameters.Add(new ParameterDeclarationExpression(operandType, operandName, ParamModifier.In)); } Expect(25); -#line 1329 "VBNET.ATG" +#line 1338 "VBNET.ATG" Point endPos = t.EndLocation; if (la.kind == 48) { lexer.NextToken(); while (la.kind == 27) { AttributeSection( -#line 1330 "VBNET.ATG" +#line 1339 "VBNET.ATG" out section); -#line 1330 "VBNET.ATG" +#line 1339 "VBNET.ATG" returnTypeAttributes.Add(section); } TypeName( -#line 1330 "VBNET.ATG" +#line 1339 "VBNET.ATG" out returnType); -#line 1330 "VBNET.ATG" +#line 1339 "VBNET.ATG" endPos = t.EndLocation; Expect(1); } Block( -#line 1331 "VBNET.ATG" +#line 1340 "VBNET.ATG" out stmt); Expect(88); Expect(187); Expect(1); -#line 1333 "VBNET.ATG" +#line 1342 "VBNET.ATG" OperatorDeclaration operatorDeclaration = new OperatorDeclaration(m.Modifier, attributes, parameters, returnType, operatorType ); - operatorDeclaration.ConvertToType = returnType; operatorDeclaration.ReturnTypeAttributes = returnTypeAttributes; operatorDeclaration.Body = (BlockStatement)stmt; operatorDeclaration.StartLocation = m.GetDeclarationLocation(startPos); @@ -2350,25 +2355,25 @@ out stmt); } void EnumMemberDecl( -#line 911 "VBNET.ATG" +#line 914 "VBNET.ATG" out FieldDeclaration f) { -#line 913 "VBNET.ATG" +#line 916 "VBNET.ATG" Expression expr = null;List attributes = new List(); AttributeSection section = null; VariableDeclaration varDecl = null; while (la.kind == 27) { AttributeSection( -#line 917 "VBNET.ATG" +#line 920 "VBNET.ATG" out section); -#line 917 "VBNET.ATG" +#line 920 "VBNET.ATG" attributes.Add(section); } Identifier(); -#line 920 "VBNET.ATG" +#line 923 "VBNET.ATG" f = new FieldDeclaration(attributes); varDecl = new VariableDeclaration(t.val); f.Fields.Add(varDecl); @@ -2377,10 +2382,10 @@ out section); if (la.kind == 11) { lexer.NextToken(); Expr( -#line 925 "VBNET.ATG" +#line 928 "VBNET.ATG" out expr); -#line 925 "VBNET.ATG" +#line 928 "VBNET.ATG" varDecl.Initializer = expr; } Expect(1); @@ -2510,7 +2515,10 @@ out type); type = new TypeReference("System.Object"); } MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, type, p, attributes); - md.ReturnTypeAttributeSection = returnTypeAttributeSection; + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + md.Attributes.Add(returnTypeAttributeSection); + } md.EndLocation = t.EndLocation; md.Templates = templates; compilationUnit.AddChild(md); @@ -2519,17 +2527,17 @@ out type); } else if (la.kind == 146) { lexer.NextToken(); -#line 889 "VBNET.ATG" +#line 892 "VBNET.ATG" mod.Check(Modifier.VBInterfaceProperties); Identifier(); -#line 890 "VBNET.ATG" +#line 893 "VBNET.ATG" name = t.val; if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 891 "VBNET.ATG" +#line 894 "VBNET.ATG" p); } Expect(25); @@ -2537,18 +2545,18 @@ p); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 892 "VBNET.ATG" +#line 895 "VBNET.ATG" out type); } -#line 894 "VBNET.ATG" +#line 897 "VBNET.ATG" if(type == null) { type = new TypeReference("System.Object"); } Expect(1); -#line 900 "VBNET.ATG" +#line 903 "VBNET.ATG" PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes); pd.Parameters = p; pd.EndLocation = t.EndLocation; @@ -2557,97 +2565,97 @@ out type); } else SynErr(227); } else if (StartOf(17)) { NonModuleDeclaration( -#line 907 "VBNET.ATG" +#line 910 "VBNET.ATG" mod, attributes); } else SynErr(228); } void Expr( -#line 1711 "VBNET.ATG" +#line 1719 "VBNET.ATG" out Expression expr) { DisjunctionExpr( -#line 1713 "VBNET.ATG" +#line 1721 "VBNET.ATG" out expr); } void ImplementsClause( -#line 1682 "VBNET.ATG" +#line 1690 "VBNET.ATG" out List baseInterfaces) { -#line 1684 "VBNET.ATG" +#line 1692 "VBNET.ATG" baseInterfaces = new List(); TypeReference type = null; string memberName = null; Expect(107); NonArrayTypeName( -#line 1689 "VBNET.ATG" +#line 1697 "VBNET.ATG" out type, false); -#line 1690 "VBNET.ATG" +#line 1698 "VBNET.ATG" if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); -#line 1691 "VBNET.ATG" +#line 1699 "VBNET.ATG" baseInterfaces.Add(new InterfaceImplementation(type, memberName)); while (la.kind == 12) { lexer.NextToken(); NonArrayTypeName( -#line 1693 "VBNET.ATG" +#line 1701 "VBNET.ATG" out type, false); -#line 1694 "VBNET.ATG" +#line 1702 "VBNET.ATG" if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); -#line 1695 "VBNET.ATG" +#line 1703 "VBNET.ATG" baseInterfaces.Add(new InterfaceImplementation(type, memberName)); } } void HandlesClause( -#line 1640 "VBNET.ATG" -out ArrayList handlesClause) { +#line 1648 "VBNET.ATG" +out List handlesClause) { -#line 1642 "VBNET.ATG" - handlesClause = new ArrayList(); +#line 1650 "VBNET.ATG" + handlesClause = new List(); string name; Expect(105); EventMemberSpecifier( -#line 1645 "VBNET.ATG" +#line 1653 "VBNET.ATG" out name); -#line 1645 "VBNET.ATG" +#line 1653 "VBNET.ATG" handlesClause.Add(name); while (la.kind == 12) { lexer.NextToken(); EventMemberSpecifier( -#line 1646 "VBNET.ATG" +#line 1654 "VBNET.ATG" out name); -#line 1646 "VBNET.ATG" +#line 1654 "VBNET.ATG" handlesClause.Add(name); } } void Block( -#line 2321 "VBNET.ATG" +#line 2329 "VBNET.ATG" out Statement stmt) { -#line 2324 "VBNET.ATG" +#line 2332 "VBNET.ATG" BlockStatement blockStmt = new BlockStatement(); blockStmt.StartLocation = t.Location; compilationUnit.BlockStart(blockStmt); while (StartOf(18) || -#line 2329 "VBNET.ATG" +#line 2337 "VBNET.ATG" IsEndStmtAhead()) { if ( -#line 2329 "VBNET.ATG" +#line 2337 "VBNET.ATG" IsEndStmtAhead()) { Expect(88); EndOfStmt(); -#line 2329 "VBNET.ATG" +#line 2337 "VBNET.ATG" compilationUnit.AddChild(new EndStatement()); } else { Statement(); @@ -2655,7 +2663,7 @@ IsEndStmtAhead()) { } } -#line 2334 "VBNET.ATG" +#line 2342 "VBNET.ATG" stmt = blockStmt; blockStmt.EndLocation = t.EndLocation; compilationUnit.BlockEnd(); @@ -2663,35 +2671,35 @@ IsEndStmtAhead()) { } void Charset( -#line 1632 "VBNET.ATG" +#line 1640 "VBNET.ATG" out CharsetModifier charsetModifier) { -#line 1633 "VBNET.ATG" +#line 1641 "VBNET.ATG" charsetModifier = CharsetModifier.None; if (la.kind == 100 || la.kind == 167) { } else if (la.kind == 47) { lexer.NextToken(); -#line 1634 "VBNET.ATG" +#line 1642 "VBNET.ATG" charsetModifier = CharsetModifier.ANSI; } else if (la.kind == 50) { lexer.NextToken(); -#line 1635 "VBNET.ATG" +#line 1643 "VBNET.ATG" charsetModifier = CharsetModifier.Auto; } else if (la.kind == 176) { lexer.NextToken(); -#line 1636 "VBNET.ATG" +#line 1644 "VBNET.ATG" charsetModifier = CharsetModifier.Unicode; } else SynErr(229); } void VariableDeclarator( -#line 1520 "VBNET.ATG" +#line 1528 "VBNET.ATG" List fieldDeclaration) { -#line 1522 "VBNET.ATG" +#line 1530 "VBNET.ATG" Expression expr = null; TypeReference type = null; ArrayList rank = null; @@ -2699,31 +2707,31 @@ List fieldDeclaration) { Identifier(); -#line 1527 "VBNET.ATG" +#line 1535 "VBNET.ATG" string name = t.val; if ( -#line 1528 "VBNET.ATG" +#line 1536 "VBNET.ATG" IsSize() && !IsDims()) { ArrayInitializationModifier( -#line 1528 "VBNET.ATG" +#line 1536 "VBNET.ATG" out dimension); } if ( -#line 1529 "VBNET.ATG" +#line 1537 "VBNET.ATG" IsDims()) { ArrayNameModifier( -#line 1529 "VBNET.ATG" +#line 1537 "VBNET.ATG" out rank); } if ( -#line 1531 "VBNET.ATG" +#line 1539 "VBNET.ATG" IsObjectCreation()) { Expect(48); ObjectCreateExpression( -#line 1531 "VBNET.ATG" +#line 1539 "VBNET.ATG" out expr); -#line 1533 "VBNET.ATG" +#line 1541 "VBNET.ATG" if (expr is ObjectCreateExpression) { type = ((ObjectCreateExpression)expr).CreateType; } else { @@ -2734,11 +2742,11 @@ out expr); if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1540 "VBNET.ATG" +#line 1548 "VBNET.ATG" out type); } -#line 1542 "VBNET.ATG" +#line 1550 "VBNET.ATG" if (type != null && dimension != null) { if(type.RankSpecifier != null) { Error("array rank only allowed one time"); @@ -2764,40 +2772,40 @@ out type); if (la.kind == 11) { lexer.NextToken(); VariableInitializer( -#line 1564 "VBNET.ATG" +#line 1572 "VBNET.ATG" out expr); } } else SynErr(230); -#line 1566 "VBNET.ATG" +#line 1574 "VBNET.ATG" fieldDeclaration.Add(new VariableDeclaration(name, expr, type)); } void ConstantDeclarator( -#line 1503 "VBNET.ATG" +#line 1511 "VBNET.ATG" List constantDeclaration) { -#line 1505 "VBNET.ATG" +#line 1513 "VBNET.ATG" Expression expr = null; TypeReference type = null; string name = String.Empty; Identifier(); -#line 1509 "VBNET.ATG" +#line 1517 "VBNET.ATG" name = t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 1510 "VBNET.ATG" +#line 1518 "VBNET.ATG" out type); } Expect(11); Expr( -#line 1511 "VBNET.ATG" +#line 1519 "VBNET.ATG" out expr); -#line 1513 "VBNET.ATG" +#line 1521 "VBNET.ATG" VariableDeclaration f = new VariableDeclaration(name, expr); f.TypeReference = type; constantDeclaration.Add(f); @@ -2805,10 +2813,10 @@ out expr); } void AccessorDecls( -#line 1445 "VBNET.ATG" +#line 1453 "VBNET.ATG" out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { -#line 1447 "VBNET.ATG" +#line 1455 "VBNET.ATG" List attributes = new List(); AttributeSection section; getBlock = null; @@ -2816,60 +2824,60 @@ out PropertyGetRegion getBlock, out PropertySetRegion setBlock) { while (la.kind == 27) { AttributeSection( -#line 1452 "VBNET.ATG" +#line 1460 "VBNET.ATG" out section); -#line 1452 "VBNET.ATG" +#line 1460 "VBNET.ATG" attributes.Add(section); } if (la.kind == 101) { GetAccessorDecl( -#line 1454 "VBNET.ATG" +#line 1462 "VBNET.ATG" out getBlock, attributes); if (la.kind == 27 || la.kind == 156) { -#line 1456 "VBNET.ATG" +#line 1464 "VBNET.ATG" attributes = new List(); while (la.kind == 27) { AttributeSection( -#line 1457 "VBNET.ATG" +#line 1465 "VBNET.ATG" out section); -#line 1457 "VBNET.ATG" +#line 1465 "VBNET.ATG" attributes.Add(section); } SetAccessorDecl( -#line 1458 "VBNET.ATG" +#line 1466 "VBNET.ATG" out setBlock, attributes); } } else if (la.kind == 156) { SetAccessorDecl( -#line 1461 "VBNET.ATG" +#line 1469 "VBNET.ATG" out setBlock, attributes); if (la.kind == 27 || la.kind == 101) { -#line 1463 "VBNET.ATG" +#line 1471 "VBNET.ATG" attributes = new List(); while (la.kind == 27) { AttributeSection( -#line 1464 "VBNET.ATG" +#line 1472 "VBNET.ATG" out section); -#line 1464 "VBNET.ATG" +#line 1472 "VBNET.ATG" attributes.Add(section); } GetAccessorDecl( -#line 1465 "VBNET.ATG" +#line 1473 "VBNET.ATG" out getBlock, attributes); } } else SynErr(231); } void EventAccessorDeclaration( -#line 1408 "VBNET.ATG" +#line 1416 "VBNET.ATG" out EventAddRemoveRegion eventAccessorDeclaration) { -#line 1410 "VBNET.ATG" +#line 1418 "VBNET.ATG" Statement stmt = null; List p = new List(); AttributeSection section; @@ -2878,10 +2886,10 @@ out EventAddRemoveRegion eventAccessorDeclaration) { while (la.kind == 27) { AttributeSection( -#line 1416 "VBNET.ATG" +#line 1424 "VBNET.ATG" out section); -#line 1416 "VBNET.ATG" +#line 1424 "VBNET.ATG" attributes.Add(section); } if (la.kind == 42) { @@ -2890,20 +2898,20 @@ out section); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1418 "VBNET.ATG" +#line 1426 "VBNET.ATG" p); } Expect(25); } Expect(1); Block( -#line 1419 "VBNET.ATG" +#line 1427 "VBNET.ATG" out stmt); Expect(88); Expect(42); Expect(1); -#line 1421 "VBNET.ATG" +#line 1429 "VBNET.ATG" eventAccessorDeclaration = new EventAddRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -2914,20 +2922,20 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1426 "VBNET.ATG" +#line 1434 "VBNET.ATG" p); } Expect(25); } Expect(1); Block( -#line 1427 "VBNET.ATG" +#line 1435 "VBNET.ATG" out stmt); Expect(88); Expect(152); Expect(1); -#line 1429 "VBNET.ATG" +#line 1437 "VBNET.ATG" eventAccessorDeclaration = new EventRemoveRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -2938,20 +2946,20 @@ out stmt); lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1434 "VBNET.ATG" +#line 1442 "VBNET.ATG" p); } Expect(25); } Expect(1); Block( -#line 1435 "VBNET.ATG" +#line 1443 "VBNET.ATG" out stmt); Expect(88); Expect(149); Expect(1); -#line 1437 "VBNET.ATG" +#line 1445 "VBNET.ATG" eventAccessorDeclaration = new EventRaiseRegion(attributes); eventAccessorDeclaration.Block = (BlockStatement)stmt; eventAccessorDeclaration.Parameters = p; @@ -2960,163 +2968,163 @@ out stmt); } void OverloadableOperator( -#line 1350 "VBNET.ATG" +#line 1358 "VBNET.ATG" out OverloadableOperatorType operatorType) { -#line 1351 "VBNET.ATG" +#line 1359 "VBNET.ATG" operatorType = OverloadableOperatorType.None; switch (la.kind) { case 14: { lexer.NextToken(); -#line 1353 "VBNET.ATG" +#line 1361 "VBNET.ATG" operatorType = OverloadableOperatorType.Add; break; } case 15: { lexer.NextToken(); -#line 1355 "VBNET.ATG" +#line 1363 "VBNET.ATG" operatorType = OverloadableOperatorType.Subtract; break; } case 16: { lexer.NextToken(); -#line 1357 "VBNET.ATG" +#line 1365 "VBNET.ATG" operatorType = OverloadableOperatorType.Multiply; break; } case 17: { lexer.NextToken(); -#line 1359 "VBNET.ATG" +#line 1367 "VBNET.ATG" operatorType = OverloadableOperatorType.Divide; break; } case 18: { lexer.NextToken(); -#line 1361 "VBNET.ATG" +#line 1369 "VBNET.ATG" operatorType = OverloadableOperatorType.DivideInteger; break; } case 19: { lexer.NextToken(); -#line 1363 "VBNET.ATG" +#line 1371 "VBNET.ATG" operatorType = OverloadableOperatorType.Concat; break; } case 116: { lexer.NextToken(); -#line 1365 "VBNET.ATG" +#line 1373 "VBNET.ATG" operatorType = OverloadableOperatorType.Like; break; } case 120: { lexer.NextToken(); -#line 1367 "VBNET.ATG" +#line 1375 "VBNET.ATG" operatorType = OverloadableOperatorType.Modulus; break; } case 45: { lexer.NextToken(); -#line 1369 "VBNET.ATG" +#line 1377 "VBNET.ATG" operatorType = OverloadableOperatorType.BitwiseAnd; break; } case 138: { lexer.NextToken(); -#line 1371 "VBNET.ATG" +#line 1379 "VBNET.ATG" operatorType = OverloadableOperatorType.BitwiseOr; break; } case 185: { lexer.NextToken(); -#line 1373 "VBNET.ATG" +#line 1381 "VBNET.ATG" operatorType = OverloadableOperatorType.ExclusiveOr; break; } case 20: { lexer.NextToken(); -#line 1375 "VBNET.ATG" +#line 1383 "VBNET.ATG" operatorType = OverloadableOperatorType.Power; break; } case 31: { lexer.NextToken(); -#line 1377 "VBNET.ATG" +#line 1385 "VBNET.ATG" operatorType = OverloadableOperatorType.ShiftLeft; break; } case 32: { lexer.NextToken(); -#line 1379 "VBNET.ATG" +#line 1387 "VBNET.ATG" operatorType = OverloadableOperatorType.ShiftRight; break; } case 11: { lexer.NextToken(); -#line 1381 "VBNET.ATG" +#line 1389 "VBNET.ATG" operatorType = OverloadableOperatorType.Equality; break; } case 28: { lexer.NextToken(); -#line 1383 "VBNET.ATG" +#line 1391 "VBNET.ATG" operatorType = OverloadableOperatorType.InEquality; break; } case 27: { lexer.NextToken(); -#line 1385 "VBNET.ATG" +#line 1393 "VBNET.ATG" operatorType = OverloadableOperatorType.LessThan; break; } case 30: { lexer.NextToken(); -#line 1387 "VBNET.ATG" +#line 1395 "VBNET.ATG" operatorType = OverloadableOperatorType.LessThanOrEqual; break; } case 26: { lexer.NextToken(); -#line 1389 "VBNET.ATG" +#line 1397 "VBNET.ATG" operatorType = OverloadableOperatorType.GreaterThan; break; } case 29: { lexer.NextToken(); -#line 1391 "VBNET.ATG" +#line 1399 "VBNET.ATG" operatorType = OverloadableOperatorType.GreaterThanOrEqual; break; } case 75: { lexer.NextToken(); -#line 1393 "VBNET.ATG" +#line 1401 "VBNET.ATG" operatorType = OverloadableOperatorType.CType; break; } case 2: case 47: case 49: case 50: case 51: case 70: case 144: case 169: case 176: case 177: { Identifier(); -#line 1397 "VBNET.ATG" +#line 1405 "VBNET.ATG" string opName = t.val; if (string.Equals(opName, "istrue", StringComparison.InvariantCultureIgnoreCase)) { operatorType = OverloadableOperatorType.IsTrue; @@ -3133,98 +3141,98 @@ out OverloadableOperatorType operatorType) { } void GetAccessorDecl( -#line 1471 "VBNET.ATG" +#line 1479 "VBNET.ATG" out PropertyGetRegion getBlock, List attributes) { -#line 1472 "VBNET.ATG" +#line 1480 "VBNET.ATG" Statement stmt = null; Expect(101); -#line 1474 "VBNET.ATG" +#line 1482 "VBNET.ATG" Point startLocation = t.Location; Expect(1); Block( -#line 1476 "VBNET.ATG" +#line 1484 "VBNET.ATG" out stmt); -#line 1477 "VBNET.ATG" +#line 1485 "VBNET.ATG" getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); Expect(88); Expect(101); -#line 1479 "VBNET.ATG" +#line 1487 "VBNET.ATG" getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; Expect(1); } void SetAccessorDecl( -#line 1484 "VBNET.ATG" +#line 1492 "VBNET.ATG" out PropertySetRegion setBlock, List attributes) { -#line 1486 "VBNET.ATG" +#line 1494 "VBNET.ATG" Statement stmt = null; List p = new List(); Expect(156); -#line 1489 "VBNET.ATG" +#line 1497 "VBNET.ATG" Point startLocation = t.Location; if (la.kind == 24) { lexer.NextToken(); if (StartOf(4)) { FormalParameterList( -#line 1490 "VBNET.ATG" +#line 1498 "VBNET.ATG" p); } Expect(25); } Expect(1); Block( -#line 1492 "VBNET.ATG" +#line 1500 "VBNET.ATG" out stmt); -#line 1494 "VBNET.ATG" +#line 1502 "VBNET.ATG" setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); setBlock.Parameters = p; Expect(88); Expect(156); -#line 1498 "VBNET.ATG" +#line 1506 "VBNET.ATG" setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; Expect(1); } void ArrayInitializationModifier( -#line 1570 "VBNET.ATG" +#line 1578 "VBNET.ATG" out List arrayModifiers) { -#line 1572 "VBNET.ATG" +#line 1580 "VBNET.ATG" arrayModifiers = null; Expect(24); InitializationRankList( -#line 1574 "VBNET.ATG" +#line 1582 "VBNET.ATG" out arrayModifiers); Expect(25); } void ArrayNameModifier( -#line 2114 "VBNET.ATG" +#line 2122 "VBNET.ATG" out ArrayList arrayModifiers) { -#line 2116 "VBNET.ATG" +#line 2124 "VBNET.ATG" arrayModifiers = null; ArrayTypeModifiers( -#line 2118 "VBNET.ATG" +#line 2126 "VBNET.ATG" out arrayModifiers); } void ObjectCreateExpression( -#line 1996 "VBNET.ATG" +#line 2004 "VBNET.ATG" out Expression oce) { -#line 1998 "VBNET.ATG" +#line 2006 "VBNET.ATG" TypeReference type = null; Expression initializer = null; List arguments = null; @@ -3233,37 +3241,37 @@ out Expression oce) { Expect(127); NonArrayTypeName( -#line 2004 "VBNET.ATG" +#line 2012 "VBNET.ATG" out type, false); if (la.kind == 24) { lexer.NextToken(); if (StartOf(20)) { ArgumentList( -#line 2005 "VBNET.ATG" +#line 2013 "VBNET.ATG" out arguments); } Expect(25); } if (la.kind == 22 || -#line 2006 "VBNET.ATG" +#line 2014 "VBNET.ATG" la.kind == Tokens.OpenParenthesis) { if ( -#line 2006 "VBNET.ATG" +#line 2014 "VBNET.ATG" la.kind == Tokens.OpenParenthesis) { ArrayTypeModifiers( -#line 2007 "VBNET.ATG" +#line 2015 "VBNET.ATG" out dimensions); ArrayInitializer( -#line 2008 "VBNET.ATG" +#line 2016 "VBNET.ATG" out initializer); } else { ArrayInitializer( -#line 2009 "VBNET.ATG" +#line 2017 "VBNET.ATG" out initializer); } } -#line 2011 "VBNET.ATG" +#line 2019 "VBNET.ATG" if (initializer == null) { oce = new ObjectCreateExpression(type, arguments); } else { @@ -3278,120 +3286,120 @@ out initializer); } void VariableInitializer( -#line 1604 "VBNET.ATG" +#line 1612 "VBNET.ATG" out Expression initializerExpression) { -#line 1606 "VBNET.ATG" +#line 1614 "VBNET.ATG" initializerExpression = null; if (StartOf(21)) { Expr( -#line 1608 "VBNET.ATG" +#line 1616 "VBNET.ATG" out initializerExpression); } else if (la.kind == 22) { ArrayInitializer( -#line 1609 "VBNET.ATG" +#line 1617 "VBNET.ATG" out initializerExpression); } else SynErr(234); } void InitializationRankList( -#line 1578 "VBNET.ATG" +#line 1586 "VBNET.ATG" out List rank) { -#line 1580 "VBNET.ATG" +#line 1588 "VBNET.ATG" rank = new List(); Expression expr = null; Expr( -#line 1583 "VBNET.ATG" +#line 1591 "VBNET.ATG" out expr); if (la.kind == 172) { lexer.NextToken(); -#line 1585 "VBNET.ATG" +#line 1593 "VBNET.ATG" if (!(expr is PrimitiveExpression) || (expr as PrimitiveExpression).StringValue != "0") Error("lower bound of array must be zero"); Expr( -#line 1588 "VBNET.ATG" +#line 1596 "VBNET.ATG" out expr); } -#line 1590 "VBNET.ATG" +#line 1598 "VBNET.ATG" if (expr != null) { rank.Add(expr); } while (la.kind == 12) { lexer.NextToken(); Expr( -#line 1592 "VBNET.ATG" +#line 1600 "VBNET.ATG" out expr); if (la.kind == 172) { lexer.NextToken(); -#line 1594 "VBNET.ATG" +#line 1602 "VBNET.ATG" if (!(expr is PrimitiveExpression) || (expr as PrimitiveExpression).StringValue != "0") Error("lower bound of array must be zero"); Expr( -#line 1597 "VBNET.ATG" +#line 1605 "VBNET.ATG" out expr); } -#line 1599 "VBNET.ATG" +#line 1607 "VBNET.ATG" if (expr != null) { rank.Add(expr); } } } void ArrayInitializer( -#line 1613 "VBNET.ATG" +#line 1621 "VBNET.ATG" out Expression outExpr) { -#line 1615 "VBNET.ATG" +#line 1623 "VBNET.ATG" Expression expr = null; ArrayInitializerExpression initializer = new ArrayInitializerExpression(); Expect(22); if (StartOf(22)) { VariableInitializer( -#line 1620 "VBNET.ATG" +#line 1628 "VBNET.ATG" out expr); -#line 1622 "VBNET.ATG" +#line 1630 "VBNET.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } while ( -#line 1625 "VBNET.ATG" +#line 1633 "VBNET.ATG" NotFinalComma()) { Expect(12); VariableInitializer( -#line 1625 "VBNET.ATG" +#line 1633 "VBNET.ATG" out expr); -#line 1626 "VBNET.ATG" +#line 1634 "VBNET.ATG" if (expr != null) { initializer.CreateExpressions.Add(expr); } } } Expect(23); -#line 1629 "VBNET.ATG" +#line 1637 "VBNET.ATG" outExpr = initializer; } void EventMemberSpecifier( -#line 1699 "VBNET.ATG" +#line 1707 "VBNET.ATG" out string name) { -#line 1700 "VBNET.ATG" +#line 1708 "VBNET.ATG" string type; name = String.Empty; if (StartOf(12)) { Identifier(); -#line 1701 "VBNET.ATG" +#line 1709 "VBNET.ATG" type = t.val; Expect(10); Identifier(); -#line 1703 "VBNET.ATG" +#line 1711 "VBNET.ATG" name = type + "." + t.val; } else if (la.kind == 124) { lexer.NextToken(); @@ -3399,128 +3407,128 @@ out string name) { if (StartOf(12)) { Identifier(); -#line 1706 "VBNET.ATG" +#line 1714 "VBNET.ATG" name = "MyBase." + t.val; } else if (la.kind == 92) { lexer.NextToken(); -#line 1707 "VBNET.ATG" +#line 1715 "VBNET.ATG" name = "MyBase.Error"; } else SynErr(235); } else SynErr(236); } void DisjunctionExpr( -#line 1845 "VBNET.ATG" +#line 1853 "VBNET.ATG" out Expression outExpr) { -#line 1847 "VBNET.ATG" +#line 1855 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ConjunctionExpr( -#line 1850 "VBNET.ATG" +#line 1858 "VBNET.ATG" out outExpr); while (la.kind == 138 || la.kind == 139 || la.kind == 185) { if (la.kind == 138) { lexer.NextToken(); -#line 1853 "VBNET.ATG" +#line 1861 "VBNET.ATG" op = BinaryOperatorType.BitwiseOr; } else if (la.kind == 139) { lexer.NextToken(); -#line 1854 "VBNET.ATG" +#line 1862 "VBNET.ATG" op = BinaryOperatorType.LogicalOr; } else { lexer.NextToken(); -#line 1855 "VBNET.ATG" +#line 1863 "VBNET.ATG" op = BinaryOperatorType.ExclusiveOr; } ConjunctionExpr( -#line 1857 "VBNET.ATG" +#line 1865 "VBNET.ATG" out expr); -#line 1857 "VBNET.ATG" +#line 1865 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AssignmentOperator( -#line 1716 "VBNET.ATG" +#line 1724 "VBNET.ATG" out AssignmentOperatorType op) { -#line 1717 "VBNET.ATG" +#line 1725 "VBNET.ATG" op = AssignmentOperatorType.None; switch (la.kind) { case 11: { lexer.NextToken(); -#line 1718 "VBNET.ATG" +#line 1726 "VBNET.ATG" op = AssignmentOperatorType.Assign; break; } case 41: { lexer.NextToken(); -#line 1719 "VBNET.ATG" +#line 1727 "VBNET.ATG" op = AssignmentOperatorType.ConcatString; break; } case 33: { lexer.NextToken(); -#line 1720 "VBNET.ATG" +#line 1728 "VBNET.ATG" op = AssignmentOperatorType.Add; break; } case 35: { lexer.NextToken(); -#line 1721 "VBNET.ATG" +#line 1729 "VBNET.ATG" op = AssignmentOperatorType.Subtract; break; } case 36: { lexer.NextToken(); -#line 1722 "VBNET.ATG" +#line 1730 "VBNET.ATG" op = AssignmentOperatorType.Multiply; break; } case 37: { lexer.NextToken(); -#line 1723 "VBNET.ATG" +#line 1731 "VBNET.ATG" op = AssignmentOperatorType.Divide; break; } case 38: { lexer.NextToken(); -#line 1724 "VBNET.ATG" +#line 1732 "VBNET.ATG" op = AssignmentOperatorType.DivideInteger; break; } case 34: { lexer.NextToken(); -#line 1725 "VBNET.ATG" +#line 1733 "VBNET.ATG" op = AssignmentOperatorType.Power; break; } case 39: { lexer.NextToken(); -#line 1726 "VBNET.ATG" +#line 1734 "VBNET.ATG" op = AssignmentOperatorType.ShiftLeft; break; } case 40: { lexer.NextToken(); -#line 1727 "VBNET.ATG" +#line 1735 "VBNET.ATG" op = AssignmentOperatorType.ShiftRight; break; } @@ -3529,10 +3537,10 @@ out AssignmentOperatorType op) { } void SimpleExpr( -#line 1731 "VBNET.ATG" +#line 1739 "VBNET.ATG" out Expression pexpr) { -#line 1733 "VBNET.ATG" +#line 1741 "VBNET.ATG" Expression expr; TypeReference type = null; string name = String.Empty; @@ -3543,136 +3551,136 @@ out Expression pexpr) { case 3: { lexer.NextToken(); -#line 1741 "VBNET.ATG" +#line 1749 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 4: { lexer.NextToken(); -#line 1742 "VBNET.ATG" +#line 1750 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 7: { lexer.NextToken(); -#line 1743 "VBNET.ATG" +#line 1751 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 6: { lexer.NextToken(); -#line 1744 "VBNET.ATG" +#line 1752 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 5: { lexer.NextToken(); -#line 1745 "VBNET.ATG" +#line 1753 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 9: { lexer.NextToken(); -#line 1746 "VBNET.ATG" +#line 1754 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 8: { lexer.NextToken(); -#line 1747 "VBNET.ATG" +#line 1755 "VBNET.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); break; } case 173: { lexer.NextToken(); -#line 1749 "VBNET.ATG" +#line 1757 "VBNET.ATG" pexpr = new PrimitiveExpression(true, "true"); break; } case 96: { lexer.NextToken(); -#line 1750 "VBNET.ATG" +#line 1758 "VBNET.ATG" pexpr = new PrimitiveExpression(false, "false"); break; } case 130: { lexer.NextToken(); -#line 1751 "VBNET.ATG" +#line 1759 "VBNET.ATG" pexpr = new PrimitiveExpression(null, "null"); break; } case 24: { lexer.NextToken(); Expr( -#line 1752 "VBNET.ATG" +#line 1760 "VBNET.ATG" out expr); Expect(25); -#line 1752 "VBNET.ATG" +#line 1760 "VBNET.ATG" pexpr = new ParenthesizedExpression(expr); break; } case 2: case 47: case 49: case 50: case 51: case 70: case 144: case 169: case 176: case 177: { Identifier(); -#line 1753 "VBNET.ATG" +#line 1761 "VBNET.ATG" pexpr = new IdentifierExpression(t.val); break; } case 52: case 54: case 65: case 76: case 77: case 84: case 111: case 117: case 159: case 160: case 165: case 190: case 191: case 192: case 193: { -#line 1754 "VBNET.ATG" +#line 1762 "VBNET.ATG" string val = String.Empty; PrimitiveTypeName( -#line 1755 "VBNET.ATG" +#line 1763 "VBNET.ATG" out val); Expect(10); -#line 1756 "VBNET.ATG" +#line 1764 "VBNET.ATG" t.val = ""; Identifier(); -#line 1756 "VBNET.ATG" +#line 1764 "VBNET.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); break; } case 119: { lexer.NextToken(); -#line 1757 "VBNET.ATG" +#line 1765 "VBNET.ATG" pexpr = new ThisReferenceExpression(); break; } case 124: case 125: { -#line 1758 "VBNET.ATG" +#line 1766 "VBNET.ATG" Expression retExpr = null; if (la.kind == 124) { lexer.NextToken(); -#line 1759 "VBNET.ATG" +#line 1767 "VBNET.ATG" retExpr = new BaseReferenceExpression(); } else if (la.kind == 125) { lexer.NextToken(); -#line 1760 "VBNET.ATG" +#line 1768 "VBNET.ATG" retExpr = new ClassReferenceExpression(); } else SynErr(238); Expect(10); IdentifierOrKeyword( -#line 1762 "VBNET.ATG" +#line 1770 "VBNET.ATG" out name); -#line 1762 "VBNET.ATG" +#line 1770 "VBNET.ATG" pexpr = new FieldReferenceExpression(retExpr, name); break; } @@ -3681,77 +3689,77 @@ out name); Expect(10); Identifier(); -#line 1764 "VBNET.ATG" +#line 1772 "VBNET.ATG" type = new TypeReference(t.val ?? ""); -#line 1766 "VBNET.ATG" +#line 1774 "VBNET.ATG" type.IsGlobal = true; -#line 1767 "VBNET.ATG" +#line 1775 "VBNET.ATG" pexpr = new TypeReferenceExpression(type); break; } case 127: { ObjectCreateExpression( -#line 1768 "VBNET.ATG" +#line 1776 "VBNET.ATG" out expr); -#line 1768 "VBNET.ATG" +#line 1776 "VBNET.ATG" pexpr = expr; break; } case 75: case 82: case 199: { -#line 1770 "VBNET.ATG" +#line 1778 "VBNET.ATG" CastType castType = CastType.Cast; if (la.kind == 82) { lexer.NextToken(); } else if (la.kind == 75) { lexer.NextToken(); -#line 1772 "VBNET.ATG" +#line 1780 "VBNET.ATG" castType = CastType.Conversion; } else if (la.kind == 199) { lexer.NextToken(); -#line 1773 "VBNET.ATG" +#line 1781 "VBNET.ATG" castType = CastType.TryCast; } else SynErr(239); Expect(24); Expr( -#line 1775 "VBNET.ATG" +#line 1783 "VBNET.ATG" out expr); Expect(12); TypeName( -#line 1775 "VBNET.ATG" +#line 1783 "VBNET.ATG" out type); Expect(25); -#line 1776 "VBNET.ATG" +#line 1784 "VBNET.ATG" pexpr = new CastExpression(type, expr, castType); break; } case 59: case 60: case 61: case 62: case 63: case 64: case 66: case 68: case 69: case 72: case 73: case 74: case 194: case 195: case 196: case 197: { CastTarget( -#line 1777 "VBNET.ATG" +#line 1785 "VBNET.ATG" out type); Expect(24); Expr( -#line 1777 "VBNET.ATG" +#line 1785 "VBNET.ATG" out expr); Expect(25); -#line 1777 "VBNET.ATG" +#line 1785 "VBNET.ATG" pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion); break; } case 43: { lexer.NextToken(); Expr( -#line 1778 "VBNET.ATG" +#line 1786 "VBNET.ATG" out expr); -#line 1778 "VBNET.ATG" +#line 1786 "VBNET.ATG" pexpr = new AddressOfExpression(expr); break; } @@ -3759,159 +3767,159 @@ out expr); lexer.NextToken(); Expect(24); GetTypeTypeName( -#line 1779 "VBNET.ATG" +#line 1787 "VBNET.ATG" out type); Expect(25); -#line 1779 "VBNET.ATG" +#line 1787 "VBNET.ATG" pexpr = new TypeOfExpression(type); break; } case 175: { lexer.NextToken(); SimpleExpr( -#line 1780 "VBNET.ATG" +#line 1788 "VBNET.ATG" out expr); Expect(113); TypeName( -#line 1780 "VBNET.ATG" +#line 1788 "VBNET.ATG" out type); -#line 1780 "VBNET.ATG" +#line 1788 "VBNET.ATG" pexpr = new TypeOfIsExpression(expr, type); break; } } while (la.kind == 10 || la.kind == 24) { InvocationOrMemberReferenceExpression( -#line 1782 "VBNET.ATG" +#line 1790 "VBNET.ATG" ref pexpr); } } else if (la.kind == 10) { lexer.NextToken(); IdentifierOrKeyword( -#line 1785 "VBNET.ATG" +#line 1793 "VBNET.ATG" out name); -#line 1785 "VBNET.ATG" +#line 1793 "VBNET.ATG" pexpr = new FieldReferenceExpression(pexpr, name); while (la.kind == 10 || la.kind == 24) { InvocationOrMemberReferenceExpression( -#line 1786 "VBNET.ATG" +#line 1794 "VBNET.ATG" ref pexpr); } } else SynErr(240); } void PrimitiveTypeName( -#line 2925 "VBNET.ATG" +#line 2933 "VBNET.ATG" out string type) { -#line 2926 "VBNET.ATG" +#line 2934 "VBNET.ATG" type = String.Empty; switch (la.kind) { case 52: { lexer.NextToken(); -#line 2927 "VBNET.ATG" +#line 2935 "VBNET.ATG" type = "Boolean"; break; } case 76: { lexer.NextToken(); -#line 2928 "VBNET.ATG" +#line 2936 "VBNET.ATG" type = "Date"; break; } case 65: { lexer.NextToken(); -#line 2929 "VBNET.ATG" +#line 2937 "VBNET.ATG" type = "Char"; break; } case 165: { lexer.NextToken(); -#line 2930 "VBNET.ATG" +#line 2938 "VBNET.ATG" type = "String"; break; } case 77: { lexer.NextToken(); -#line 2931 "VBNET.ATG" +#line 2939 "VBNET.ATG" type = "Decimal"; break; } case 54: { lexer.NextToken(); -#line 2932 "VBNET.ATG" +#line 2940 "VBNET.ATG" type = "Byte"; break; } case 159: { lexer.NextToken(); -#line 2933 "VBNET.ATG" +#line 2941 "VBNET.ATG" type = "Short"; break; } case 111: { lexer.NextToken(); -#line 2934 "VBNET.ATG" +#line 2942 "VBNET.ATG" type = "Integer"; break; } case 117: { lexer.NextToken(); -#line 2935 "VBNET.ATG" +#line 2943 "VBNET.ATG" type = "Long"; break; } case 160: { lexer.NextToken(); -#line 2936 "VBNET.ATG" +#line 2944 "VBNET.ATG" type = "Single"; break; } case 84: { lexer.NextToken(); -#line 2937 "VBNET.ATG" +#line 2945 "VBNET.ATG" type = "Double"; break; } case 191: { lexer.NextToken(); -#line 2938 "VBNET.ATG" +#line 2946 "VBNET.ATG" type = "UInteger"; break; } case 192: { lexer.NextToken(); -#line 2939 "VBNET.ATG" +#line 2947 "VBNET.ATG" type = "ULong"; break; } case 193: { lexer.NextToken(); -#line 2940 "VBNET.ATG" +#line 2948 "VBNET.ATG" type = "UShort"; break; } case 190: { lexer.NextToken(); -#line 2941 "VBNET.ATG" +#line 2949 "VBNET.ATG" type = "SByte"; break; } @@ -3920,130 +3928,130 @@ out string type) { } void IdentifierOrKeyword( -#line 2918 "VBNET.ATG" +#line 2926 "VBNET.ATG" out string name) { -#line 2920 "VBNET.ATG" +#line 2928 "VBNET.ATG" lexer.NextToken(); name = t.val; } void CastTarget( -#line 1823 "VBNET.ATG" +#line 1831 "VBNET.ATG" out TypeReference type) { -#line 1825 "VBNET.ATG" +#line 1833 "VBNET.ATG" type = null; switch (la.kind) { case 59: { lexer.NextToken(); -#line 1827 "VBNET.ATG" +#line 1835 "VBNET.ATG" type = new TypeReference("System.Boolean"); break; } case 60: { lexer.NextToken(); -#line 1828 "VBNET.ATG" +#line 1836 "VBNET.ATG" type = new TypeReference("System.Byte"); break; } case 194: { lexer.NextToken(); -#line 1829 "VBNET.ATG" +#line 1837 "VBNET.ATG" type = new TypeReference("System.SByte"); break; } case 61: { lexer.NextToken(); -#line 1830 "VBNET.ATG" +#line 1838 "VBNET.ATG" type = new TypeReference("System.Char"); break; } case 62: { lexer.NextToken(); -#line 1831 "VBNET.ATG" +#line 1839 "VBNET.ATG" type = new TypeReference("System.DateTime"); break; } case 64: { lexer.NextToken(); -#line 1832 "VBNET.ATG" +#line 1840 "VBNET.ATG" type = new TypeReference("System.Decimal"); break; } case 63: { lexer.NextToken(); -#line 1833 "VBNET.ATG" +#line 1841 "VBNET.ATG" type = new TypeReference("System.Double"); break; } case 72: { lexer.NextToken(); -#line 1834 "VBNET.ATG" +#line 1842 "VBNET.ATG" type = new TypeReference("System.Int16"); break; } case 66: { lexer.NextToken(); -#line 1835 "VBNET.ATG" +#line 1843 "VBNET.ATG" type = new TypeReference("System.Int32"); break; } case 68: { lexer.NextToken(); -#line 1836 "VBNET.ATG" +#line 1844 "VBNET.ATG" type = new TypeReference("System.Int64"); break; } case 195: { lexer.NextToken(); -#line 1837 "VBNET.ATG" +#line 1845 "VBNET.ATG" type = new TypeReference("System.UInt16"); break; } case 196: { lexer.NextToken(); -#line 1838 "VBNET.ATG" +#line 1846 "VBNET.ATG" type = new TypeReference("System.UInt32"); break; } case 197: { lexer.NextToken(); -#line 1839 "VBNET.ATG" +#line 1847 "VBNET.ATG" type = new TypeReference("System.UInt64"); break; } case 69: { lexer.NextToken(); -#line 1840 "VBNET.ATG" +#line 1848 "VBNET.ATG" type = new TypeReference("System.Object"); break; } case 73: { lexer.NextToken(); -#line 1841 "VBNET.ATG" +#line 1849 "VBNET.ATG" type = new TypeReference("System.Single"); break; } case 74: { lexer.NextToken(); -#line 1842 "VBNET.ATG" +#line 1850 "VBNET.ATG" type = new TypeReference("System.String"); break; } @@ -4052,19 +4060,19 @@ out TypeReference type) { } void GetTypeTypeName( -#line 2066 "VBNET.ATG" +#line 2074 "VBNET.ATG" out TypeReference typeref) { -#line 2067 "VBNET.ATG" +#line 2075 "VBNET.ATG" ArrayList rank = null; NonArrayTypeName( -#line 2069 "VBNET.ATG" +#line 2077 "VBNET.ATG" out typeref, true); ArrayTypeModifiers( -#line 2070 "VBNET.ATG" +#line 2078 "VBNET.ATG" out rank); -#line 2071 "VBNET.ATG" +#line 2079 "VBNET.ATG" if (rank != null && typeref != null) { typeref.RankSpecifier = (int[])rank.ToArray(typeof(int)); } @@ -4072,405 +4080,405 @@ out rank); } void InvocationOrMemberReferenceExpression( -#line 1790 "VBNET.ATG" +#line 1798 "VBNET.ATG" ref Expression pexpr) { -#line 1791 "VBNET.ATG" +#line 1799 "VBNET.ATG" string name; if (la.kind == 10) { lexer.NextToken(); IdentifierOrKeyword( -#line 1793 "VBNET.ATG" +#line 1801 "VBNET.ATG" out name); -#line 1793 "VBNET.ATG" +#line 1801 "VBNET.ATG" pexpr = new FieldReferenceExpression(pexpr, name); } else if (la.kind == 24) { InvocationExpression( -#line 1794 "VBNET.ATG" +#line 1802 "VBNET.ATG" ref pexpr); } else SynErr(243); } void InvocationExpression( -#line 1797 "VBNET.ATG" +#line 1805 "VBNET.ATG" ref Expression pexpr) { -#line 1798 "VBNET.ATG" +#line 1806 "VBNET.ATG" List typeParameters = new List(); List parameters = null; TypeReference type; Expect(24); -#line 1802 "VBNET.ATG" +#line 1810 "VBNET.ATG" Point start = t.Location; if (la.kind == 200) { lexer.NextToken(); TypeName( -#line 1804 "VBNET.ATG" +#line 1812 "VBNET.ATG" out type); -#line 1804 "VBNET.ATG" +#line 1812 "VBNET.ATG" if (type != null) typeParameters.Add(type); Expect(25); if (la.kind == 10) { lexer.NextToken(); Identifier(); -#line 1808 "VBNET.ATG" +#line 1816 "VBNET.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeParameters), t.val); } else if (la.kind == 24) { lexer.NextToken(); ArgumentList( -#line 1810 "VBNET.ATG" +#line 1818 "VBNET.ATG" out parameters); Expect(25); -#line 1812 "VBNET.ATG" +#line 1820 "VBNET.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeParameters); } else SynErr(244); } else if (StartOf(20)) { ArgumentList( -#line 1814 "VBNET.ATG" +#line 1822 "VBNET.ATG" out parameters); Expect(25); -#line 1816 "VBNET.ATG" +#line 1824 "VBNET.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeParameters); } else SynErr(245); -#line 1818 "VBNET.ATG" +#line 1826 "VBNET.ATG" pexpr.StartLocation = start; pexpr.EndLocation = t.Location; } void ArgumentList( -#line 2025 "VBNET.ATG" +#line 2033 "VBNET.ATG" out List arguments) { -#line 2027 "VBNET.ATG" +#line 2035 "VBNET.ATG" arguments = new List(); Expression expr = null; if (StartOf(21)) { Argument( -#line 2031 "VBNET.ATG" +#line 2039 "VBNET.ATG" out expr); -#line 2031 "VBNET.ATG" +#line 2039 "VBNET.ATG" if (expr != null) { arguments.Add(expr); } while (la.kind == 12) { lexer.NextToken(); Argument( -#line 2034 "VBNET.ATG" +#line 2042 "VBNET.ATG" out expr); -#line 2034 "VBNET.ATG" +#line 2042 "VBNET.ATG" if (expr != null) { arguments.Add(expr); } } } } void ConjunctionExpr( -#line 1861 "VBNET.ATG" +#line 1869 "VBNET.ATG" out Expression outExpr) { -#line 1863 "VBNET.ATG" +#line 1871 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; NotExpr( -#line 1866 "VBNET.ATG" +#line 1874 "VBNET.ATG" out outExpr); while (la.kind == 45 || la.kind == 46) { if (la.kind == 45) { lexer.NextToken(); -#line 1869 "VBNET.ATG" +#line 1877 "VBNET.ATG" op = BinaryOperatorType.BitwiseAnd; } else { lexer.NextToken(); -#line 1870 "VBNET.ATG" +#line 1878 "VBNET.ATG" op = BinaryOperatorType.LogicalAnd; } NotExpr( -#line 1872 "VBNET.ATG" +#line 1880 "VBNET.ATG" out expr); -#line 1872 "VBNET.ATG" +#line 1880 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void NotExpr( -#line 1876 "VBNET.ATG" +#line 1884 "VBNET.ATG" out Expression outExpr) { -#line 1877 "VBNET.ATG" +#line 1885 "VBNET.ATG" UnaryOperatorType uop = UnaryOperatorType.None; while (la.kind == 129) { lexer.NextToken(); -#line 1878 "VBNET.ATG" +#line 1886 "VBNET.ATG" uop = UnaryOperatorType.Not; } ComparisonExpr( -#line 1879 "VBNET.ATG" +#line 1887 "VBNET.ATG" out outExpr); -#line 1880 "VBNET.ATG" +#line 1888 "VBNET.ATG" if (uop != UnaryOperatorType.None) outExpr = new UnaryOperatorExpression(outExpr, uop); } void ComparisonExpr( -#line 1885 "VBNET.ATG" +#line 1893 "VBNET.ATG" out Expression outExpr) { -#line 1887 "VBNET.ATG" +#line 1895 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 1890 "VBNET.ATG" +#line 1898 "VBNET.ATG" out outExpr); while (StartOf(24)) { switch (la.kind) { case 27: { lexer.NextToken(); -#line 1893 "VBNET.ATG" +#line 1901 "VBNET.ATG" op = BinaryOperatorType.LessThan; break; } case 26: { lexer.NextToken(); -#line 1894 "VBNET.ATG" +#line 1902 "VBNET.ATG" op = BinaryOperatorType.GreaterThan; break; } case 30: { lexer.NextToken(); -#line 1895 "VBNET.ATG" +#line 1903 "VBNET.ATG" op = BinaryOperatorType.LessThanOrEqual; break; } case 29: { lexer.NextToken(); -#line 1896 "VBNET.ATG" +#line 1904 "VBNET.ATG" op = BinaryOperatorType.GreaterThanOrEqual; break; } case 28: { lexer.NextToken(); -#line 1897 "VBNET.ATG" +#line 1905 "VBNET.ATG" op = BinaryOperatorType.InEquality; break; } case 11: { lexer.NextToken(); -#line 1898 "VBNET.ATG" +#line 1906 "VBNET.ATG" op = BinaryOperatorType.Equality; break; } case 116: { lexer.NextToken(); -#line 1899 "VBNET.ATG" +#line 1907 "VBNET.ATG" op = BinaryOperatorType.Like; break; } case 113: { lexer.NextToken(); -#line 1900 "VBNET.ATG" +#line 1908 "VBNET.ATG" op = BinaryOperatorType.ReferenceEquality; break; } case 189: { lexer.NextToken(); -#line 1901 "VBNET.ATG" +#line 1909 "VBNET.ATG" op = BinaryOperatorType.ReferenceInequality; break; } } ShiftExpr( -#line 1903 "VBNET.ATG" +#line 1911 "VBNET.ATG" out expr); -#line 1903 "VBNET.ATG" +#line 1911 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void ShiftExpr( -#line 1907 "VBNET.ATG" +#line 1915 "VBNET.ATG" out Expression outExpr) { -#line 1909 "VBNET.ATG" +#line 1917 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ConcatenationExpr( -#line 1912 "VBNET.ATG" +#line 1920 "VBNET.ATG" out outExpr); while (la.kind == 31 || la.kind == 32) { if (la.kind == 31) { lexer.NextToken(); -#line 1915 "VBNET.ATG" +#line 1923 "VBNET.ATG" op = BinaryOperatorType.ShiftLeft; } else { lexer.NextToken(); -#line 1916 "VBNET.ATG" +#line 1924 "VBNET.ATG" op = BinaryOperatorType.ShiftRight; } ConcatenationExpr( -#line 1918 "VBNET.ATG" +#line 1926 "VBNET.ATG" out expr); -#line 1918 "VBNET.ATG" +#line 1926 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void ConcatenationExpr( -#line 1922 "VBNET.ATG" +#line 1930 "VBNET.ATG" out Expression outExpr) { -#line 1923 "VBNET.ATG" +#line 1931 "VBNET.ATG" Expression expr; AdditiveExpr( -#line 1925 "VBNET.ATG" +#line 1933 "VBNET.ATG" out outExpr); while (la.kind == 19) { lexer.NextToken(); AdditiveExpr( -#line 1925 "VBNET.ATG" +#line 1933 "VBNET.ATG" out expr); -#line 1925 "VBNET.ATG" +#line 1933 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr); } } void AdditiveExpr( -#line 1928 "VBNET.ATG" +#line 1936 "VBNET.ATG" out Expression outExpr) { -#line 1930 "VBNET.ATG" +#line 1938 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ModuloExpr( -#line 1933 "VBNET.ATG" +#line 1941 "VBNET.ATG" out outExpr); while (la.kind == 14 || la.kind == 15) { if (la.kind == 14) { lexer.NextToken(); -#line 1936 "VBNET.ATG" +#line 1944 "VBNET.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 1937 "VBNET.ATG" +#line 1945 "VBNET.ATG" op = BinaryOperatorType.Subtract; } ModuloExpr( -#line 1939 "VBNET.ATG" +#line 1947 "VBNET.ATG" out expr); -#line 1939 "VBNET.ATG" +#line 1947 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void ModuloExpr( -#line 1943 "VBNET.ATG" +#line 1951 "VBNET.ATG" out Expression outExpr) { -#line 1944 "VBNET.ATG" +#line 1952 "VBNET.ATG" Expression expr; IntegerDivisionExpr( -#line 1946 "VBNET.ATG" +#line 1954 "VBNET.ATG" out outExpr); while (la.kind == 120) { lexer.NextToken(); IntegerDivisionExpr( -#line 1946 "VBNET.ATG" +#line 1954 "VBNET.ATG" out expr); -#line 1946 "VBNET.ATG" +#line 1954 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr); } } void IntegerDivisionExpr( -#line 1949 "VBNET.ATG" +#line 1957 "VBNET.ATG" out Expression outExpr) { -#line 1950 "VBNET.ATG" +#line 1958 "VBNET.ATG" Expression expr; MultiplicativeExpr( -#line 1952 "VBNET.ATG" +#line 1960 "VBNET.ATG" out outExpr); while (la.kind == 18) { lexer.NextToken(); MultiplicativeExpr( -#line 1952 "VBNET.ATG" +#line 1960 "VBNET.ATG" out expr); -#line 1952 "VBNET.ATG" +#line 1960 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr); } } void MultiplicativeExpr( -#line 1955 "VBNET.ATG" +#line 1963 "VBNET.ATG" out Expression outExpr) { -#line 1957 "VBNET.ATG" +#line 1965 "VBNET.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; UnaryExpr( -#line 1960 "VBNET.ATG" +#line 1968 "VBNET.ATG" out outExpr); while (la.kind == 16 || la.kind == 17) { if (la.kind == 16) { lexer.NextToken(); -#line 1963 "VBNET.ATG" +#line 1971 "VBNET.ATG" op = BinaryOperatorType.Multiply; } else { lexer.NextToken(); -#line 1964 "VBNET.ATG" +#line 1972 "VBNET.ATG" op = BinaryOperatorType.Divide; } UnaryExpr( -#line 1966 "VBNET.ATG" +#line 1974 "VBNET.ATG" out expr); -#line 1966 "VBNET.ATG" +#line 1974 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void UnaryExpr( -#line 1970 "VBNET.ATG" +#line 1978 "VBNET.ATG" out Expression uExpr) { -#line 1972 "VBNET.ATG" +#line 1980 "VBNET.ATG" Expression expr; UnaryOperatorType uop = UnaryOperatorType.None; bool isUOp = false; @@ -4479,25 +4487,25 @@ out Expression uExpr) { if (la.kind == 14) { lexer.NextToken(); -#line 1976 "VBNET.ATG" +#line 1984 "VBNET.ATG" uop = UnaryOperatorType.Plus; isUOp = true; } else if (la.kind == 15) { lexer.NextToken(); -#line 1977 "VBNET.ATG" +#line 1985 "VBNET.ATG" uop = UnaryOperatorType.Minus; isUOp = true; } else { lexer.NextToken(); -#line 1978 "VBNET.ATG" +#line 1986 "VBNET.ATG" uop = UnaryOperatorType.Star; isUOp = true; } } ExponentiationExpr( -#line 1980 "VBNET.ATG" +#line 1988 "VBNET.ATG" out expr); -#line 1982 "VBNET.ATG" +#line 1990 "VBNET.ATG" if (isUOp) { uExpr = new UnaryOperatorExpression(expr, uop); } else { @@ -4507,50 +4515,50 @@ out expr); } void ExponentiationExpr( -#line 1990 "VBNET.ATG" +#line 1998 "VBNET.ATG" out Expression outExpr) { -#line 1991 "VBNET.ATG" +#line 1999 "VBNET.ATG" Expression expr; SimpleExpr( -#line 1993 "VBNET.ATG" +#line 2001 "VBNET.ATG" out outExpr); while (la.kind == 20) { lexer.NextToken(); SimpleExpr( -#line 1993 "VBNET.ATG" +#line 2001 "VBNET.ATG" out expr); -#line 1993 "VBNET.ATG" +#line 2001 "VBNET.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr); } } void ArrayTypeModifiers( -#line 2123 "VBNET.ATG" +#line 2131 "VBNET.ATG" out ArrayList arrayModifiers) { -#line 2125 "VBNET.ATG" +#line 2133 "VBNET.ATG" arrayModifiers = new ArrayList(); int i = 0; while ( -#line 2128 "VBNET.ATG" +#line 2136 "VBNET.ATG" IsDims()) { Expect(24); if (la.kind == 12 || la.kind == 25) { RankList( -#line 2130 "VBNET.ATG" +#line 2138 "VBNET.ATG" out i); } -#line 2132 "VBNET.ATG" +#line 2140 "VBNET.ATG" arrayModifiers.Add(i); Expect(25); } -#line 2137 "VBNET.ATG" +#line 2145 "VBNET.ATG" if(arrayModifiers.Count == 0) { arrayModifiers = null; } @@ -4558,69 +4566,69 @@ out i); } void Argument( -#line 2040 "VBNET.ATG" +#line 2048 "VBNET.ATG" out Expression argumentexpr) { -#line 2042 "VBNET.ATG" +#line 2050 "VBNET.ATG" Expression expr; argumentexpr = null; string name; if ( -#line 2046 "VBNET.ATG" +#line 2054 "VBNET.ATG" IsNamedAssign()) { Identifier(); -#line 2046 "VBNET.ATG" +#line 2054 "VBNET.ATG" name = t.val; Expect(13); Expect(11); Expr( -#line 2046 "VBNET.ATG" +#line 2054 "VBNET.ATG" out expr); -#line 2048 "VBNET.ATG" +#line 2056 "VBNET.ATG" argumentexpr = new NamedArgumentExpression(name, expr); } else if (StartOf(21)) { Expr( -#line 2051 "VBNET.ATG" +#line 2059 "VBNET.ATG" out argumentexpr); } else SynErr(246); } void QualIdentAndTypeArguments( -#line 2097 "VBNET.ATG" +#line 2105 "VBNET.ATG" out TypeReference typeref, bool canBeUnbound) { -#line 2098 "VBNET.ATG" +#line 2106 "VBNET.ATG" string name; typeref = null; Qualident( -#line 2100 "VBNET.ATG" +#line 2108 "VBNET.ATG" out name); -#line 2101 "VBNET.ATG" +#line 2109 "VBNET.ATG" typeref = new TypeReference(name); if ( -#line 2102 "VBNET.ATG" +#line 2110 "VBNET.ATG" la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) { lexer.NextToken(); Expect(200); if ( -#line 2104 "VBNET.ATG" +#line 2112 "VBNET.ATG" canBeUnbound && (la.kind == Tokens.CloseParenthesis || la.kind == Tokens.Comma)) { -#line 2105 "VBNET.ATG" +#line 2113 "VBNET.ATG" typeref.GenericTypes.Add(NullTypeReference.Instance); while (la.kind == 12) { lexer.NextToken(); -#line 2106 "VBNET.ATG" +#line 2114 "VBNET.ATG" typeref.GenericTypes.Add(NullTypeReference.Instance); } } else if (StartOf(5)) { TypeArgumentList( -#line 2107 "VBNET.ATG" +#line 2115 "VBNET.ATG" typeref.GenericTypes); } else SynErr(247); Expect(25); @@ -4628,48 +4636,48 @@ typeref.GenericTypes); } void TypeArgumentList( -#line 2150 "VBNET.ATG" +#line 2158 "VBNET.ATG" List typeArguments) { -#line 2152 "VBNET.ATG" +#line 2160 "VBNET.ATG" TypeReference typeref; TypeName( -#line 2154 "VBNET.ATG" +#line 2162 "VBNET.ATG" out typeref); -#line 2154 "VBNET.ATG" +#line 2162 "VBNET.ATG" if (typeref != null) typeArguments.Add(typeref); while (la.kind == 12) { lexer.NextToken(); TypeName( -#line 2157 "VBNET.ATG" +#line 2165 "VBNET.ATG" out typeref); -#line 2157 "VBNET.ATG" +#line 2165 "VBNET.ATG" if (typeref != null) typeArguments.Add(typeref); } } void RankList( -#line 2144 "VBNET.ATG" +#line 2152 "VBNET.ATG" out int i) { -#line 2145 "VBNET.ATG" +#line 2153 "VBNET.ATG" i = 0; while (la.kind == 12) { lexer.NextToken(); -#line 2146 "VBNET.ATG" +#line 2154 "VBNET.ATG" ++i; } } void Attribute( -#line 2182 "VBNET.ATG" +#line 2190 "VBNET.ATG" out ICSharpCode.NRefactory.Parser.AST.Attribute attribute) { -#line 2183 "VBNET.ATG" +#line 2191 "VBNET.ATG" string name; List positional = new List(); List named = new List(); @@ -4679,39 +4687,39 @@ out ICSharpCode.NRefactory.Parser.AST.Attribute attribute) { Expect(10); } Qualident( -#line 2188 "VBNET.ATG" +#line 2196 "VBNET.ATG" out name); if (la.kind == 24) { AttributeArguments( -#line 2189 "VBNET.ATG" +#line 2197 "VBNET.ATG" positional, named); } -#line 2190 "VBNET.ATG" +#line 2198 "VBNET.ATG" attribute = new ICSharpCode.NRefactory.Parser.AST.Attribute(name, positional, named); } void AttributeArguments( -#line 2194 "VBNET.ATG" +#line 2202 "VBNET.ATG" List positional, List named) { -#line 2196 "VBNET.ATG" +#line 2204 "VBNET.ATG" bool nameFound = false; string name = ""; Expression expr; Expect(24); if ( -#line 2202 "VBNET.ATG" +#line 2210 "VBNET.ATG" IsNotClosingParenthesis()) { if ( -#line 2204 "VBNET.ATG" +#line 2212 "VBNET.ATG" IsNamedAssign()) { -#line 2204 "VBNET.ATG" +#line 2212 "VBNET.ATG" nameFound = true; IdentifierOrKeyword( -#line 2205 "VBNET.ATG" +#line 2213 "VBNET.ATG" out name); if (la.kind == 13) { lexer.NextToken(); @@ -4719,10 +4727,10 @@ out name); Expect(11); } Expr( -#line 2207 "VBNET.ATG" +#line 2215 "VBNET.ATG" out expr); -#line 2209 "VBNET.ATG" +#line 2217 "VBNET.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -4730,13 +4738,13 @@ out expr); while (la.kind == 12) { lexer.NextToken(); if ( -#line 2216 "VBNET.ATG" +#line 2224 "VBNET.ATG" IsNamedAssign()) { -#line 2216 "VBNET.ATG" +#line 2224 "VBNET.ATG" nameFound = true; IdentifierOrKeyword( -#line 2217 "VBNET.ATG" +#line 2225 "VBNET.ATG" out name); if (la.kind == 13) { lexer.NextToken(); @@ -4744,14 +4752,14 @@ out name); Expect(11); } else if (StartOf(21)) { -#line 2219 "VBNET.ATG" +#line 2227 "VBNET.ATG" if (nameFound) Error("no positional argument after named argument"); } else SynErr(248); Expr( -#line 2220 "VBNET.ATG" +#line 2228 "VBNET.ATG" out expr); -#line 2220 "VBNET.ATG" +#line 2228 "VBNET.ATG" if (expr != null) { if(name == "") positional.Add(expr); else { named.Add(new NamedArgumentExpression(name, expr)); name = ""; } } @@ -4762,10 +4770,10 @@ out expr); } void FormalParameter( -#line 2289 "VBNET.ATG" +#line 2297 "VBNET.ATG" out ParameterDeclarationExpression p) { -#line 2291 "VBNET.ATG" +#line 2299 "VBNET.ATG" TypeReference type = null; ParamModifiers mod = new ParamModifiers(this); Expression expr = null; @@ -4773,28 +4781,28 @@ out ParameterDeclarationExpression p) { while (StartOf(25)) { ParameterModifier( -#line 2296 "VBNET.ATG" +#line 2304 "VBNET.ATG" mod); } Identifier(); -#line 2297 "VBNET.ATG" +#line 2305 "VBNET.ATG" string parameterName = t.val; if ( -#line 2298 "VBNET.ATG" +#line 2306 "VBNET.ATG" IsDims()) { ArrayTypeModifiers( -#line 2298 "VBNET.ATG" +#line 2306 "VBNET.ATG" out arrayModifiers); } if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 2299 "VBNET.ATG" +#line 2307 "VBNET.ATG" out type); } -#line 2301 "VBNET.ATG" +#line 2309 "VBNET.ATG" if(type != null) { if (arrayModifiers != null) { if (type.RankSpecifier != null) { @@ -4810,45 +4818,45 @@ out type); if (la.kind == 11) { lexer.NextToken(); Expr( -#line 2313 "VBNET.ATG" +#line 2321 "VBNET.ATG" out expr); } -#line 2315 "VBNET.ATG" +#line 2323 "VBNET.ATG" mod.Check(); p = new ParameterDeclarationExpression(type, parameterName, mod.Modifier, expr); } void ParameterModifier( -#line 2944 "VBNET.ATG" +#line 2952 "VBNET.ATG" ParamModifiers m) { if (la.kind == 55) { lexer.NextToken(); -#line 2945 "VBNET.ATG" +#line 2953 "VBNET.ATG" m.Add(ParamModifier.In); } else if (la.kind == 53) { lexer.NextToken(); -#line 2946 "VBNET.ATG" +#line 2954 "VBNET.ATG" m.Add(ParamModifier.Ref); } else if (la.kind == 137) { lexer.NextToken(); -#line 2947 "VBNET.ATG" +#line 2955 "VBNET.ATG" m.Add(ParamModifier.Optional); } else if (la.kind == 143) { lexer.NextToken(); -#line 2948 "VBNET.ATG" +#line 2956 "VBNET.ATG" m.Add(ParamModifier.Params); } else SynErr(249); } void Statement() { -#line 2342 "VBNET.ATG" +#line 2350 "VBNET.ATG" Statement stmt = null; Point startPos = la.Location; string label = String.Empty; @@ -4856,34 +4864,34 @@ ParamModifiers m) { if (la.kind == 1 || la.kind == 13) { } else if ( -#line 2348 "VBNET.ATG" +#line 2356 "VBNET.ATG" IsLabel()) { LabelName( -#line 2348 "VBNET.ATG" +#line 2356 "VBNET.ATG" out label); -#line 2350 "VBNET.ATG" +#line 2358 "VBNET.ATG" compilationUnit.AddChild(new LabelStatement(t.val)); Expect(13); Statement(); } else if (StartOf(26)) { EmbeddedStatement( -#line 2353 "VBNET.ATG" +#line 2361 "VBNET.ATG" out stmt); -#line 2353 "VBNET.ATG" +#line 2361 "VBNET.ATG" compilationUnit.AddChild(stmt); } else if (StartOf(27)) { LocalDeclarationStatement( -#line 2354 "VBNET.ATG" +#line 2362 "VBNET.ATG" out stmt); -#line 2354 "VBNET.ATG" +#line 2362 "VBNET.ATG" compilationUnit.AddChild(stmt); } else SynErr(250); -#line 2357 "VBNET.ATG" +#line 2365 "VBNET.ATG" if (stmt != null) { stmt.StartLocation = startPos; stmt.EndLocation = t.Location; @@ -4892,30 +4900,30 @@ out stmt); } void LabelName( -#line 2744 "VBNET.ATG" +#line 2752 "VBNET.ATG" out string name) { -#line 2746 "VBNET.ATG" +#line 2754 "VBNET.ATG" name = String.Empty; if (StartOf(12)) { Identifier(); -#line 2748 "VBNET.ATG" +#line 2756 "VBNET.ATG" name = t.val; } else if (la.kind == 5) { lexer.NextToken(); -#line 2749 "VBNET.ATG" +#line 2757 "VBNET.ATG" name = t.val; } else SynErr(251); } void EmbeddedStatement( -#line 2396 "VBNET.ATG" +#line 2404 "VBNET.ATG" out Statement statement) { -#line 2398 "VBNET.ATG" +#line 2406 "VBNET.ATG" Statement embeddedStatement = null; statement = null; Expression expr = null; @@ -4926,103 +4934,103 @@ out Statement statement) { case 94: { lexer.NextToken(); -#line 2404 "VBNET.ATG" +#line 2412 "VBNET.ATG" ExitType exitType = ExitType.None; switch (la.kind) { case 167: { lexer.NextToken(); -#line 2406 "VBNET.ATG" +#line 2414 "VBNET.ATG" exitType = ExitType.Sub; break; } case 100: { lexer.NextToken(); -#line 2408 "VBNET.ATG" +#line 2416 "VBNET.ATG" exitType = ExitType.Function; break; } case 146: { lexer.NextToken(); -#line 2410 "VBNET.ATG" +#line 2418 "VBNET.ATG" exitType = ExitType.Property; break; } case 83: { lexer.NextToken(); -#line 2412 "VBNET.ATG" +#line 2420 "VBNET.ATG" exitType = ExitType.Do; break; } case 98: { lexer.NextToken(); -#line 2414 "VBNET.ATG" +#line 2422 "VBNET.ATG" exitType = ExitType.For; break; } case 174: { lexer.NextToken(); -#line 2416 "VBNET.ATG" +#line 2424 "VBNET.ATG" exitType = ExitType.Try; break; } case 181: { lexer.NextToken(); -#line 2418 "VBNET.ATG" +#line 2426 "VBNET.ATG" exitType = ExitType.While; break; } case 155: { lexer.NextToken(); -#line 2420 "VBNET.ATG" +#line 2428 "VBNET.ATG" exitType = ExitType.Select; break; } default: SynErr(252); break; } -#line 2422 "VBNET.ATG" +#line 2430 "VBNET.ATG" statement = new ExitStatement(exitType); break; } case 174: { TryStatement( -#line 2423 "VBNET.ATG" +#line 2431 "VBNET.ATG" out statement); break; } case 186: { lexer.NextToken(); -#line 2424 "VBNET.ATG" +#line 2432 "VBNET.ATG" ContinueType continueType = ContinueType.None; if (la.kind == 83 || la.kind == 98 || la.kind == 181) { if (la.kind == 83) { lexer.NextToken(); -#line 2424 "VBNET.ATG" +#line 2432 "VBNET.ATG" continueType = ContinueType.Do; } else if (la.kind == 98) { lexer.NextToken(); -#line 2424 "VBNET.ATG" +#line 2432 "VBNET.ATG" continueType = ContinueType.For; } else { lexer.NextToken(); -#line 2424 "VBNET.ATG" +#line 2432 "VBNET.ATG" continueType = ContinueType.While; } } -#line 2424 "VBNET.ATG" +#line 2432 "VBNET.ATG" statement = new ContinueStatement(continueType); break; } @@ -5030,11 +5038,11 @@ out statement); lexer.NextToken(); if (StartOf(21)) { Expr( -#line 2426 "VBNET.ATG" +#line 2434 "VBNET.ATG" out expr); } -#line 2426 "VBNET.ATG" +#line 2434 "VBNET.ATG" statement = new ThrowStatement(expr); break; } @@ -5042,27 +5050,27 @@ out expr); lexer.NextToken(); if (StartOf(21)) { Expr( -#line 2428 "VBNET.ATG" +#line 2436 "VBNET.ATG" out expr); } -#line 2428 "VBNET.ATG" +#line 2436 "VBNET.ATG" statement = new ReturnStatement(expr); break; } case 168: { lexer.NextToken(); Expr( -#line 2430 "VBNET.ATG" +#line 2438 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2430 "VBNET.ATG" +#line 2438 "VBNET.ATG" out embeddedStatement); Expect(88); Expect(168); -#line 2431 "VBNET.ATG" +#line 2439 "VBNET.ATG" statement = new LockStatement(expr, embeddedStatement); break; } @@ -5070,42 +5078,42 @@ out embeddedStatement); lexer.NextToken(); Identifier(); -#line 2433 "VBNET.ATG" +#line 2441 "VBNET.ATG" name = t.val; if (la.kind == 24) { lexer.NextToken(); if (StartOf(20)) { ArgumentList( -#line 2434 "VBNET.ATG" +#line 2442 "VBNET.ATG" out p); } Expect(25); } -#line 2435 "VBNET.ATG" +#line 2443 "VBNET.ATG" statement = new RaiseEventStatement(name, p); break; } case 182: { WithStatement( -#line 2437 "VBNET.ATG" +#line 2445 "VBNET.ATG" out statement); break; } case 42: { lexer.NextToken(); -#line 2439 "VBNET.ATG" +#line 2447 "VBNET.ATG" Expression handlerExpr = null; Expr( -#line 2440 "VBNET.ATG" +#line 2448 "VBNET.ATG" out expr); Expect(12); Expr( -#line 2440 "VBNET.ATG" +#line 2448 "VBNET.ATG" out handlerExpr); -#line 2442 "VBNET.ATG" +#line 2450 "VBNET.ATG" statement = new AddHandlerStatement(expr, handlerExpr); break; @@ -5113,17 +5121,17 @@ out handlerExpr); case 152: { lexer.NextToken(); -#line 2445 "VBNET.ATG" +#line 2453 "VBNET.ATG" Expression handlerExpr = null; Expr( -#line 2446 "VBNET.ATG" +#line 2454 "VBNET.ATG" out expr); Expect(12); Expr( -#line 2446 "VBNET.ATG" +#line 2454 "VBNET.ATG" out handlerExpr); -#line 2448 "VBNET.ATG" +#line 2456 "VBNET.ATG" statement = new RemoveHandlerStatement(expr, handlerExpr); break; @@ -5131,16 +5139,16 @@ out handlerExpr); case 181: { lexer.NextToken(); Expr( -#line 2451 "VBNET.ATG" +#line 2459 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2452 "VBNET.ATG" +#line 2460 "VBNET.ATG" out embeddedStatement); Expect(88); Expect(181); -#line 2454 "VBNET.ATG" +#line 2462 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start); break; @@ -5148,23 +5156,23 @@ out embeddedStatement); case 83: { lexer.NextToken(); -#line 2459 "VBNET.ATG" +#line 2467 "VBNET.ATG" ConditionType conditionType = ConditionType.None; if (la.kind == 177 || la.kind == 181) { WhileOrUntil( -#line 2462 "VBNET.ATG" +#line 2470 "VBNET.ATG" out conditionType); Expr( -#line 2462 "VBNET.ATG" +#line 2470 "VBNET.ATG" out expr); EndOfStmt(); Block( -#line 2463 "VBNET.ATG" +#line 2471 "VBNET.ATG" out embeddedStatement); Expect(118); -#line 2466 "VBNET.ATG" +#line 2474 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType, @@ -5173,19 +5181,19 @@ out embeddedStatement); } else if (la.kind == 1 || la.kind == 13) { EndOfStmt(); Block( -#line 2473 "VBNET.ATG" +#line 2481 "VBNET.ATG" out embeddedStatement); Expect(118); if (la.kind == 177 || la.kind == 181) { WhileOrUntil( -#line 2474 "VBNET.ATG" +#line 2482 "VBNET.ATG" out conditionType); Expr( -#line 2474 "VBNET.ATG" +#line 2482 "VBNET.ATG" out expr); } -#line 2476 "VBNET.ATG" +#line 2484 "VBNET.ATG" statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End); } else SynErr(253); @@ -5194,7 +5202,7 @@ out expr); case 98: { lexer.NextToken(); -#line 2481 "VBNET.ATG" +#line 2489 "VBNET.ATG" Expression group = null; TypeReference typeReference; string typeName; @@ -5203,24 +5211,24 @@ out expr); if (la.kind == 85) { lexer.NextToken(); LoopControlVariable( -#line 2488 "VBNET.ATG" +#line 2496 "VBNET.ATG" out typeReference, out typeName); Expect(109); Expr( -#line 2489 "VBNET.ATG" +#line 2497 "VBNET.ATG" out group); EndOfStmt(); Block( -#line 2490 "VBNET.ATG" +#line 2498 "VBNET.ATG" out embeddedStatement); Expect(128); if (StartOf(21)) { Expr( -#line 2491 "VBNET.ATG" +#line 2499 "VBNET.ATG" out expr); } -#line 2493 "VBNET.ATG" +#line 2501 "VBNET.ATG" statement = new ForeachStatement(typeReference, typeName, group, @@ -5232,53 +5240,53 @@ out expr); } else if (StartOf(12)) { -#line 2504 "VBNET.ATG" +#line 2512 "VBNET.ATG" Expression start = null; Expression end = null; Expression step = null; Expression nextExpr = null;List nextExpressions = null; LoopControlVariable( -#line 2509 "VBNET.ATG" +#line 2517 "VBNET.ATG" out typeReference, out typeName); Expect(11); Expr( -#line 2510 "VBNET.ATG" +#line 2518 "VBNET.ATG" out start); Expect(172); Expr( -#line 2510 "VBNET.ATG" +#line 2518 "VBNET.ATG" out end); if (la.kind == 162) { lexer.NextToken(); Expr( -#line 2510 "VBNET.ATG" +#line 2518 "VBNET.ATG" out step); } EndOfStmt(); Block( -#line 2511 "VBNET.ATG" +#line 2519 "VBNET.ATG" out embeddedStatement); Expect(128); if (StartOf(21)) { Expr( -#line 2514 "VBNET.ATG" +#line 2522 "VBNET.ATG" out nextExpr); -#line 2514 "VBNET.ATG" +#line 2522 "VBNET.ATG" nextExpressions = new List(); nextExpressions.Add(nextExpr); while (la.kind == 12) { lexer.NextToken(); Expr( -#line 2515 "VBNET.ATG" +#line 2523 "VBNET.ATG" out nextExpr); -#line 2515 "VBNET.ATG" +#line 2523 "VBNET.ATG" nextExpressions.Add(nextExpr); } } -#line 2518 "VBNET.ATG" +#line 2526 "VBNET.ATG" statement = new ForNextStatement(typeReference, typeName, start, end, step, embeddedStatement, nextExpressions); } else SynErr(254); @@ -5287,29 +5295,29 @@ out nextExpr); case 92: { lexer.NextToken(); Expr( -#line 2522 "VBNET.ATG" +#line 2530 "VBNET.ATG" out expr); -#line 2522 "VBNET.ATG" +#line 2530 "VBNET.ATG" statement = new ErrorStatement(expr); break; } case 151: { lexer.NextToken(); -#line 2524 "VBNET.ATG" +#line 2532 "VBNET.ATG" bool isPreserve = false; if (la.kind == 144) { lexer.NextToken(); -#line 2524 "VBNET.ATG" +#line 2532 "VBNET.ATG" isPreserve = true; } Expr( -#line 2525 "VBNET.ATG" +#line 2533 "VBNET.ATG" out expr); -#line 2527 "VBNET.ATG" +#line 2535 "VBNET.ATG" ReDimStatement reDimStatement = new ReDimStatement(isPreserve); statement = reDimStatement; InvocationExpression redimClause = expr as InvocationExpression; @@ -5318,13 +5326,13 @@ out expr); while (la.kind == 12) { lexer.NextToken(); Expr( -#line 2532 "VBNET.ATG" +#line 2540 "VBNET.ATG" out expr); -#line 2533 "VBNET.ATG" +#line 2541 "VBNET.ATG" redimClause = expr as InvocationExpression; -#line 2534 "VBNET.ATG" +#line 2542 "VBNET.ATG" if (redimClause != null) { reDimStatement.ReDimClauses.Add(redimClause); } } break; @@ -5332,11 +5340,11 @@ out expr); case 91: { lexer.NextToken(); Expr( -#line 2538 "VBNET.ATG" +#line 2546 "VBNET.ATG" out expr); -#line 2539 "VBNET.ATG" - ArrayList arrays = new ArrayList(); +#line 2547 "VBNET.ATG" + List arrays = new List(); if (expr != null) { arrays.Add(expr);} EraseStatement eraseStatement = new EraseStatement(arrays); @@ -5344,53 +5352,53 @@ out expr); while (la.kind == 12) { lexer.NextToken(); Expr( -#line 2544 "VBNET.ATG" +#line 2552 "VBNET.ATG" out expr); -#line 2544 "VBNET.ATG" +#line 2552 "VBNET.ATG" if (expr != null) { arrays.Add(expr); } } -#line 2545 "VBNET.ATG" +#line 2553 "VBNET.ATG" statement = eraseStatement; break; } case 163: { lexer.NextToken(); -#line 2547 "VBNET.ATG" +#line 2555 "VBNET.ATG" statement = new StopStatement(); break; } case 106: { lexer.NextToken(); Expr( -#line 2549 "VBNET.ATG" +#line 2557 "VBNET.ATG" out expr); if (la.kind == 170) { lexer.NextToken(); } if ( -#line 2551 "VBNET.ATG" +#line 2559 "VBNET.ATG" IsEndStmtAhead()) { Expect(88); -#line 2551 "VBNET.ATG" +#line 2559 "VBNET.ATG" statement = new IfElseStatement(expr, new EndStatement()); } else if (la.kind == 1 || la.kind == 13) { EndOfStmt(); Block( -#line 2554 "VBNET.ATG" +#line 2562 "VBNET.ATG" out embeddedStatement); -#line 2556 "VBNET.ATG" +#line 2564 "VBNET.ATG" IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement); while (la.kind == 87 || -#line 2560 "VBNET.ATG" +#line 2568 "VBNET.ATG" IsElseIf()) { if ( -#line 2560 "VBNET.ATG" +#line 2568 "VBNET.ATG" IsElseIf()) { Expect(86); Expect(106); @@ -5398,20 +5406,20 @@ IsElseIf()) { lexer.NextToken(); } -#line 2563 "VBNET.ATG" +#line 2571 "VBNET.ATG" Expression condition = null; Statement block = null; Expr( -#line 2564 "VBNET.ATG" +#line 2572 "VBNET.ATG" out condition); if (la.kind == 170) { lexer.NextToken(); } EndOfStmt(); Block( -#line 2565 "VBNET.ATG" +#line 2573 "VBNET.ATG" out block); -#line 2567 "VBNET.ATG" +#line 2575 "VBNET.ATG" ifStatement.ElseIfSections.Add(new ElseIfSection(condition, block)); } @@ -5419,59 +5427,59 @@ out block); lexer.NextToken(); EndOfStmt(); Block( -#line 2572 "VBNET.ATG" +#line 2580 "VBNET.ATG" out embeddedStatement); -#line 2574 "VBNET.ATG" +#line 2582 "VBNET.ATG" ifStatement.FalseStatement.Add(embeddedStatement); } Expect(88); Expect(106); -#line 2578 "VBNET.ATG" +#line 2586 "VBNET.ATG" statement = ifStatement; } else if (StartOf(26)) { EmbeddedStatement( -#line 2581 "VBNET.ATG" +#line 2589 "VBNET.ATG" out embeddedStatement); -#line 2583 "VBNET.ATG" +#line 2591 "VBNET.ATG" IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement); while (la.kind == 13) { lexer.NextToken(); EmbeddedStatement( -#line 2585 "VBNET.ATG" +#line 2593 "VBNET.ATG" out embeddedStatement); -#line 2585 "VBNET.ATG" +#line 2593 "VBNET.ATG" ifStatement.TrueStatement.Add(embeddedStatement); } if (la.kind == 86) { lexer.NextToken(); if (StartOf(26)) { EmbeddedStatement( -#line 2587 "VBNET.ATG" +#line 2595 "VBNET.ATG" out embeddedStatement); } -#line 2589 "VBNET.ATG" +#line 2597 "VBNET.ATG" ifStatement.FalseStatement.Add(embeddedStatement); while (la.kind == 13) { lexer.NextToken(); EmbeddedStatement( -#line 2592 "VBNET.ATG" +#line 2600 "VBNET.ATG" out embeddedStatement); -#line 2593 "VBNET.ATG" +#line 2601 "VBNET.ATG" ifStatement.FalseStatement.Add(embeddedStatement); } } -#line 2596 "VBNET.ATG" +#line 2604 "VBNET.ATG" statement = ifStatement; } else SynErr(255); break; @@ -5482,43 +5490,43 @@ out embeddedStatement); lexer.NextToken(); } Expr( -#line 2599 "VBNET.ATG" +#line 2607 "VBNET.ATG" out expr); EndOfStmt(); -#line 2600 "VBNET.ATG" +#line 2608 "VBNET.ATG" List selectSections = new List(); Statement block = null; while (la.kind == 57) { -#line 2604 "VBNET.ATG" +#line 2612 "VBNET.ATG" List caseClauses = null; lexer.NextToken(); CaseClauses( -#line 2605 "VBNET.ATG" +#line 2613 "VBNET.ATG" out caseClauses); if ( -#line 2605 "VBNET.ATG" +#line 2613 "VBNET.ATG" IsNotStatementSeparator()) { lexer.NextToken(); } EndOfStmt(); -#line 2607 "VBNET.ATG" +#line 2615 "VBNET.ATG" SwitchSection selectSection = new SwitchSection(caseClauses); Block( -#line 2609 "VBNET.ATG" +#line 2617 "VBNET.ATG" out block); -#line 2611 "VBNET.ATG" +#line 2619 "VBNET.ATG" selectSection.Children = block.Children; selectSections.Add(selectSection); } -#line 2615 "VBNET.ATG" +#line 2623 "VBNET.ATG" statement = new SwitchStatement(expr, selectSections); Expect(88); Expect(155); @@ -5526,43 +5534,43 @@ out block); } case 135: { -#line 2617 "VBNET.ATG" +#line 2625 "VBNET.ATG" OnErrorStatement onErrorStatement = null; OnErrorStatement( -#line 2618 "VBNET.ATG" +#line 2626 "VBNET.ATG" out onErrorStatement); -#line 2618 "VBNET.ATG" +#line 2626 "VBNET.ATG" statement = onErrorStatement; break; } case 104: { -#line 2619 "VBNET.ATG" +#line 2627 "VBNET.ATG" GotoStatement goToStatement = null; GotoStatement( -#line 2620 "VBNET.ATG" +#line 2628 "VBNET.ATG" out goToStatement); -#line 2620 "VBNET.ATG" +#line 2628 "VBNET.ATG" statement = goToStatement; break; } case 153: { -#line 2621 "VBNET.ATG" +#line 2629 "VBNET.ATG" ResumeStatement resumeStatement = null; ResumeStatement( -#line 2622 "VBNET.ATG" +#line 2630 "VBNET.ATG" out resumeStatement); -#line 2622 "VBNET.ATG" +#line 2630 "VBNET.ATG" statement = resumeStatement; break; } case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 24: case 43: case 47: case 49: case 50: case 51: case 52: case 54: case 59: case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 68: case 69: case 70: case 72: case 73: case 74: case 75: case 76: case 77: case 82: case 84: case 96: case 102: case 111: case 117: case 119: case 124: case 125: case 127: case 130: case 144: case 159: case 160: case 165: case 169: case 173: case 175: case 176: case 177: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199: { -#line 2625 "VBNET.ATG" +#line 2633 "VBNET.ATG" Expression val = null; AssignmentOperatorType op; @@ -5570,25 +5578,25 @@ out resumeStatement); la.kind == Tokens.Not || la.kind == Tokens.Times; SimpleExpr( -#line 2631 "VBNET.ATG" +#line 2639 "VBNET.ATG" out expr); if (StartOf(28)) { AssignmentOperator( -#line 2633 "VBNET.ATG" +#line 2641 "VBNET.ATG" out op); Expr( -#line 2633 "VBNET.ATG" +#line 2641 "VBNET.ATG" out val); -#line 2633 "VBNET.ATG" +#line 2641 "VBNET.ATG" expr = new AssignmentExpression(expr, op, val); } else if (la.kind == 1 || la.kind == 13 || la.kind == 86) { -#line 2634 "VBNET.ATG" +#line 2642 "VBNET.ATG" if (mustBeAssignment) Error("error in assignment."); } else SynErr(256); -#line 2637 "VBNET.ATG" +#line 2645 "VBNET.ATG" // a field reference expression that stands alone is a // invocation expression without parantheses and arguments if(expr is FieldReferenceExpression || expr is IdentifierExpression) { @@ -5601,10 +5609,10 @@ out val); case 56: { lexer.NextToken(); SimpleExpr( -#line 2644 "VBNET.ATG" +#line 2652 "VBNET.ATG" out expr); -#line 2644 "VBNET.ATG" +#line 2652 "VBNET.ATG" statement = new StatementExpression(expr); break; } @@ -5612,7 +5620,7 @@ out expr); lexer.NextToken(); Identifier(); -#line 2646 "VBNET.ATG" +#line 2654 "VBNET.ATG" string resourcename = t.val, typeName; Statement resourceAquisition = null, block = null; @@ -5620,45 +5628,45 @@ out expr); if (la.kind == 127) { lexer.NextToken(); Qualident( -#line 2649 "VBNET.ATG" +#line 2657 "VBNET.ATG" out typeName); -#line 2650 "VBNET.ATG" +#line 2658 "VBNET.ATG" List initializer = null; if (la.kind == 24) { lexer.NextToken(); if (StartOf(20)) { ArgumentList( -#line 2651 "VBNET.ATG" +#line 2659 "VBNET.ATG" out initializer); } Expect(25); } -#line 2653 "VBNET.ATG" +#line 2661 "VBNET.ATG" resourceAquisition = new LocalVariableDeclaration(new VariableDeclaration(resourcename, new ArrayInitializerExpression(initializer), new TypeReference(typeName))); } else if (StartOf(12)) { Qualident( -#line 2656 "VBNET.ATG" +#line 2664 "VBNET.ATG" out typeName); Expect(11); Expr( -#line 2656 "VBNET.ATG" +#line 2664 "VBNET.ATG" out expr); -#line 2658 "VBNET.ATG" +#line 2666 "VBNET.ATG" resourceAquisition = new LocalVariableDeclaration(new VariableDeclaration(resourcename, expr, new TypeReference(typeName))); } else SynErr(257); Block( -#line 2661 "VBNET.ATG" +#line 2669 "VBNET.ATG" out block); Expect(88); Expect(188); -#line 2663 "VBNET.ATG" +#line 2671 "VBNET.ATG" statement = new UsingStatement(resourceAquisition, block); break; } @@ -5667,10 +5675,10 @@ out block); } void LocalDeclarationStatement( -#line 2365 "VBNET.ATG" +#line 2373 "VBNET.ATG" out Statement statement) { -#line 2367 "VBNET.ATG" +#line 2375 "VBNET.ATG" Modifiers m = new Modifiers(); LocalVariableDeclaration localVariableDeclaration; bool dimfound = false; @@ -5679,22 +5687,22 @@ out Statement statement) { if (la.kind == 71) { lexer.NextToken(); -#line 2373 "VBNET.ATG" +#line 2381 "VBNET.ATG" m.Add(Modifier.Const, t.Location); } else if (la.kind == 161) { lexer.NextToken(); -#line 2374 "VBNET.ATG" +#line 2382 "VBNET.ATG" m.Add(Modifier.Static, t.Location); } else { lexer.NextToken(); -#line 2375 "VBNET.ATG" +#line 2383 "VBNET.ATG" dimfound = true; } } -#line 2378 "VBNET.ATG" +#line 2386 "VBNET.ATG" if(dimfound && (m.Modifier & Modifier.Const) != 0) { Error("Dim is not allowed on constants."); } @@ -5707,137 +5715,137 @@ out Statement statement) { localVariableDeclaration.StartLocation = t.Location; VariableDeclarator( -#line 2389 "VBNET.ATG" +#line 2397 "VBNET.ATG" localVariableDeclaration.Variables); while (la.kind == 12) { lexer.NextToken(); VariableDeclarator( -#line 2390 "VBNET.ATG" +#line 2398 "VBNET.ATG" localVariableDeclaration.Variables); } -#line 2392 "VBNET.ATG" +#line 2400 "VBNET.ATG" statement = localVariableDeclaration; } void TryStatement( -#line 2856 "VBNET.ATG" +#line 2864 "VBNET.ATG" out Statement tryStatement) { -#line 2858 "VBNET.ATG" +#line 2866 "VBNET.ATG" Statement blockStmt = null, finallyStmt = null;List catchClauses = null; Expect(174); EndOfStmt(); Block( -#line 2861 "VBNET.ATG" +#line 2869 "VBNET.ATG" out blockStmt); if (la.kind == 58 || la.kind == 88 || la.kind == 97) { CatchClauses( -#line 2862 "VBNET.ATG" +#line 2870 "VBNET.ATG" out catchClauses); } if (la.kind == 97) { lexer.NextToken(); EndOfStmt(); Block( -#line 2863 "VBNET.ATG" +#line 2871 "VBNET.ATG" out finallyStmt); } Expect(88); Expect(174); -#line 2866 "VBNET.ATG" +#line 2874 "VBNET.ATG" tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt); } void WithStatement( -#line 2834 "VBNET.ATG" +#line 2842 "VBNET.ATG" out Statement withStatement) { -#line 2836 "VBNET.ATG" +#line 2844 "VBNET.ATG" Statement blockStmt = null; Expression expr = null; Expect(182); -#line 2839 "VBNET.ATG" +#line 2847 "VBNET.ATG" Point start = t.Location; Expr( -#line 2840 "VBNET.ATG" +#line 2848 "VBNET.ATG" out expr); EndOfStmt(); -#line 2842 "VBNET.ATG" +#line 2850 "VBNET.ATG" withStatement = new WithStatement(expr); withStatement.StartLocation = start; withStatements.Push(withStatement); Block( -#line 2846 "VBNET.ATG" +#line 2854 "VBNET.ATG" out blockStmt); -#line 2848 "VBNET.ATG" +#line 2856 "VBNET.ATG" ((WithStatement)withStatement).Body = (BlockStatement)blockStmt; withStatements.Pop(); Expect(88); Expect(182); -#line 2852 "VBNET.ATG" +#line 2860 "VBNET.ATG" withStatement.EndLocation = t.Location; } void WhileOrUntil( -#line 2827 "VBNET.ATG" +#line 2835 "VBNET.ATG" out ConditionType conditionType) { -#line 2828 "VBNET.ATG" +#line 2836 "VBNET.ATG" conditionType = ConditionType.None; if (la.kind == 181) { lexer.NextToken(); -#line 2829 "VBNET.ATG" +#line 2837 "VBNET.ATG" conditionType = ConditionType.While; } else if (la.kind == 177) { lexer.NextToken(); -#line 2830 "VBNET.ATG" +#line 2838 "VBNET.ATG" conditionType = ConditionType.Until; } else SynErr(259); } void LoopControlVariable( -#line 2668 "VBNET.ATG" +#line 2676 "VBNET.ATG" out TypeReference type, out string name) { -#line 2669 "VBNET.ATG" +#line 2677 "VBNET.ATG" ArrayList arrayModifiers = null; type = null; Qualident( -#line 2673 "VBNET.ATG" +#line 2681 "VBNET.ATG" out name); if ( -#line 2674 "VBNET.ATG" +#line 2682 "VBNET.ATG" IsDims()) { ArrayTypeModifiers( -#line 2674 "VBNET.ATG" +#line 2682 "VBNET.ATG" out arrayModifiers); } if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 2675 "VBNET.ATG" +#line 2683 "VBNET.ATG" out type); -#line 2675 "VBNET.ATG" +#line 2683 "VBNET.ATG" if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); } } -#line 2677 "VBNET.ATG" +#line 2685 "VBNET.ATG" if (type != null) { if(type.RankSpecifier != null && arrayModifiers != null) { Error("array rank only allowed one time"); @@ -5855,48 +5863,48 @@ out type); } void CaseClauses( -#line 2787 "VBNET.ATG" +#line 2795 "VBNET.ATG" out List caseClauses) { -#line 2789 "VBNET.ATG" +#line 2797 "VBNET.ATG" caseClauses = new List(); CaseLabel caseClause = null; CaseClause( -#line 2792 "VBNET.ATG" +#line 2800 "VBNET.ATG" out caseClause); -#line 2792 "VBNET.ATG" +#line 2800 "VBNET.ATG" caseClauses.Add(caseClause); while (la.kind == 12) { lexer.NextToken(); CaseClause( -#line 2793 "VBNET.ATG" +#line 2801 "VBNET.ATG" out caseClause); -#line 2793 "VBNET.ATG" +#line 2801 "VBNET.ATG" caseClauses.Add(caseClause); } } void OnErrorStatement( -#line 2694 "VBNET.ATG" +#line 2702 "VBNET.ATG" out OnErrorStatement stmt) { -#line 2696 "VBNET.ATG" +#line 2704 "VBNET.ATG" stmt = null; GotoStatement goToStatement = null; Expect(135); Expect(92); if ( -#line 2702 "VBNET.ATG" +#line 2710 "VBNET.ATG" IsNegativeLabelName()) { Expect(104); Expect(15); Expect(5); -#line 2704 "VBNET.ATG" +#line 2712 "VBNET.ATG" long intLabel = Int64.Parse(t.val); if(intLabel != 1) { Error("invalid label in on error statement."); @@ -5905,10 +5913,10 @@ IsNegativeLabelName()) { } else if (la.kind == 104) { GotoStatement( -#line 2710 "VBNET.ATG" +#line 2718 "VBNET.ATG" out goToStatement); -#line 2712 "VBNET.ATG" +#line 2720 "VBNET.ATG" string val = goToStatement.Label; // if value is numeric, make sure that is 0 @@ -5925,63 +5933,63 @@ out goToStatement); lexer.NextToken(); Expect(128); -#line 2726 "VBNET.ATG" +#line 2734 "VBNET.ATG" stmt = new OnErrorStatement(new ResumeStatement(true)); } else SynErr(260); } void GotoStatement( -#line 2732 "VBNET.ATG" +#line 2740 "VBNET.ATG" out ICSharpCode.NRefactory.Parser.AST.GotoStatement goToStatement) { -#line 2734 "VBNET.ATG" +#line 2742 "VBNET.ATG" string label = String.Empty; Expect(104); LabelName( -#line 2737 "VBNET.ATG" +#line 2745 "VBNET.ATG" out label); -#line 2739 "VBNET.ATG" +#line 2747 "VBNET.ATG" goToStatement = new ICSharpCode.NRefactory.Parser.AST.GotoStatement(label); } void ResumeStatement( -#line 2776 "VBNET.ATG" +#line 2784 "VBNET.ATG" out ResumeStatement resumeStatement) { -#line 2778 "VBNET.ATG" +#line 2786 "VBNET.ATG" resumeStatement = null; string label = String.Empty; if ( -#line 2781 "VBNET.ATG" +#line 2789 "VBNET.ATG" IsResumeNext()) { Expect(153); Expect(128); -#line 2782 "VBNET.ATG" +#line 2790 "VBNET.ATG" resumeStatement = new ResumeStatement(true); } else if (la.kind == 153) { lexer.NextToken(); if (StartOf(29)) { LabelName( -#line 2783 "VBNET.ATG" +#line 2791 "VBNET.ATG" out label); } -#line 2783 "VBNET.ATG" +#line 2791 "VBNET.ATG" resumeStatement = new ResumeStatement(label); } else SynErr(261); } void CaseClause( -#line 2797 "VBNET.ATG" +#line 2805 "VBNET.ATG" out CaseLabel caseClause) { -#line 2799 "VBNET.ATG" +#line 2807 "VBNET.ATG" Expression expr = null; Expression sexpr = null; BinaryOperatorType op = BinaryOperatorType.None; @@ -5990,7 +5998,7 @@ out CaseLabel caseClause) { if (la.kind == 86) { lexer.NextToken(); -#line 2805 "VBNET.ATG" +#line 2813 "VBNET.ATG" caseClause = new CaseLabel(); } else if (StartOf(30)) { if (la.kind == 113) { @@ -6000,76 +6008,76 @@ out CaseLabel caseClause) { case 27: { lexer.NextToken(); -#line 2809 "VBNET.ATG" +#line 2817 "VBNET.ATG" op = BinaryOperatorType.LessThan; break; } case 26: { lexer.NextToken(); -#line 2810 "VBNET.ATG" +#line 2818 "VBNET.ATG" op = BinaryOperatorType.GreaterThan; break; } case 30: { lexer.NextToken(); -#line 2811 "VBNET.ATG" +#line 2819 "VBNET.ATG" op = BinaryOperatorType.LessThanOrEqual; break; } case 29: { lexer.NextToken(); -#line 2812 "VBNET.ATG" +#line 2820 "VBNET.ATG" op = BinaryOperatorType.GreaterThanOrEqual; break; } case 11: { lexer.NextToken(); -#line 2813 "VBNET.ATG" +#line 2821 "VBNET.ATG" op = BinaryOperatorType.Equality; break; } case 28: { lexer.NextToken(); -#line 2814 "VBNET.ATG" +#line 2822 "VBNET.ATG" op = BinaryOperatorType.InEquality; break; } default: SynErr(262); break; } Expr( -#line 2816 "VBNET.ATG" +#line 2824 "VBNET.ATG" out expr); -#line 2818 "VBNET.ATG" +#line 2826 "VBNET.ATG" caseClause = new CaseLabel(op, expr); } else if (StartOf(21)) { Expr( -#line 2820 "VBNET.ATG" +#line 2828 "VBNET.ATG" out expr); if (la.kind == 172) { lexer.NextToken(); Expr( -#line 2820 "VBNET.ATG" +#line 2828 "VBNET.ATG" out sexpr); } -#line 2822 "VBNET.ATG" +#line 2830 "VBNET.ATG" caseClause = new CaseLabel(expr, sexpr); } else SynErr(263); } void CatchClauses( -#line 2871 "VBNET.ATG" +#line 2879 "VBNET.ATG" out List catchClauses) { -#line 2873 "VBNET.ATG" +#line 2881 "VBNET.ATG" catchClauses = new List(); TypeReference type = null; Statement blockStmt = null; @@ -6081,27 +6089,27 @@ out List catchClauses) { if (StartOf(12)) { Identifier(); -#line 2881 "VBNET.ATG" +#line 2889 "VBNET.ATG" name = t.val; if (la.kind == 48) { lexer.NextToken(); TypeName( -#line 2881 "VBNET.ATG" +#line 2889 "VBNET.ATG" out type); } } if (la.kind == 180) { lexer.NextToken(); Expr( -#line 2882 "VBNET.ATG" +#line 2890 "VBNET.ATG" out expr); } EndOfStmt(); Block( -#line 2884 "VBNET.ATG" +#line 2892 "VBNET.ATG" out blockStmt); -#line 2885 "VBNET.ATG" +#line 2893 "VBNET.ATG" catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); } } diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG index c531157bf8..be6e1985e3 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG @@ -878,7 +878,10 @@ InterfaceMemberDecl type = new TypeReference("System.Object"); } MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, type, p, attributes); - md.ReturnTypeAttributeSection = returnTypeAttributeSection; + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + md.Attributes.Add(returnTypeAttributeSection); + } md.EndLocation = t.EndLocation; md.Templates = templates; compilationUnit.AddChild(md); @@ -957,7 +960,7 @@ StructureMemberDecl attributes> ( (. string name = String.Empty; - MethodDeclaration methodDeclaration; ArrayList handlesClause = null; + MethodDeclaration methodDeclaration; List handlesClause = null; List implementsClause = null; .) Identifier @@ -1035,7 +1038,7 @@ StructureMemberDecl attributes> m.Check(Modifier.VBMethods); string name = String.Empty; Point startPos = t.Location; - MethodDeclaration methodDeclaration;ArrayList handlesClause = null; + MethodDeclaration methodDeclaration;List handlesClause = null; List implementsClause = null; AttributeSection returnTypeAttributeSection = null; .) @@ -1067,7 +1070,10 @@ StructureMemberDecl attributes> methodDeclaration.HandlesClause = handlesClause; methodDeclaration.Templates = templates; methodDeclaration.InterfaceImplementations = implementsClause; - methodDeclaration.ReturnTypeAttributeSection = returnTypeAttributeSection; + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + methodDeclaration.Attributes.Add(returnTypeAttributeSection); + } compilationUnit.AddChild(methodDeclaration); .) | @@ -1079,7 +1085,10 @@ StructureMemberDecl attributes> methodDeclaration.Templates = templates; methodDeclaration.HandlesClause = handlesClause; methodDeclaration.InterfaceImplementations = implementsClause; - methodDeclaration.ReturnTypeAttributeSection = returnTypeAttributeSection; + if (returnTypeAttributeSection != null) { + returnTypeAttributeSection.AttributeTarget = "return"; + methodDeclaration.Attributes.Add(returnTypeAttributeSection); + } compilationUnit.AddChild(methodDeclaration); compilationUnit.BlockStart(methodDeclaration); @@ -1293,7 +1302,7 @@ StructureMemberDecl attributes> Error("Need to provide RaiseEvent accessor."); } - EventDeclaration decl = new EventDeclaration(type, customEventName, m.Modifier, attributes); + EventDeclaration decl = new EventDeclaration(type, customEventName, m.Modifier, attributes, null); decl.StartLocation = m.GetDeclarationLocation(startPos); decl.EndLocation = t.EndLocation; decl.AddRegion = addHandlerAccessorDeclaration; @@ -1336,7 +1345,6 @@ StructureMemberDecl attributes> returnType, operatorType ); - operatorDeclaration.ConvertToType = returnType; operatorDeclaration.ReturnTypeAttributes = returnTypeAttributes; operatorDeclaration.Body = (BlockStatement)stmt; operatorDeclaration.StartLocation = m.GetDeclarationLocation(startPos); @@ -1637,9 +1645,9 @@ Charset . /* 9.2.6 */ -HandlesClause +HandlesClause handlesClause> (. - handlesClause = new ArrayList(); + handlesClause = new List(); string name; .) = "Handles" EventMemberSpecifier (. handlesClause.Add(name); .) @@ -2536,7 +2544,7 @@ EmbeddedStatement | /* 10.12.2 */ "Erase" Expr - (.ArrayList arrays = new ArrayList(); + (.List arrays = new List(); if (expr != null) { arrays.Add(expr);} EraseStatement eraseStatement = new EraseStatement(arrays); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/Visitors/AbstractASTVisitor.cs b/src/Libraries/NRefactory/Project/Src/Parser/Visitors/AbstractASTVisitor.cs index f7b511a178..271477021e 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/Visitors/AbstractASTVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/Visitors/AbstractASTVisitor.cs @@ -12,7 +12,7 @@ using ICSharpCode.NRefactory.Parser.AST; namespace ICSharpCode.NRefactory.Parser { - public abstract class AbstractASTVisitor : IASTVisitor + public abstract class AbstractASTVisitor : IAstVisitor { protected Stack blockStack = new Stack(); @@ -25,6 +25,11 @@ namespace ICSharpCode.NRefactory.Parser } } + public virtual object Visit(InterfaceImplementation interfaceImplementation, object data) + { + return interfaceImplementation.InterfaceType.AcceptChildren(this, data); + } + public virtual object Visit(INode node, object data) { Console.WriteLine("Warning, INode visited!"); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/Visitors/IASTVisitor.cs b/src/Libraries/NRefactory/Project/Src/Parser/Visitors/IASTVisitor.cs index 21fdc2495b..db3b10b92f 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/Visitors/IASTVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/Visitors/IASTVisitor.cs @@ -10,11 +10,13 @@ using ICSharpCode.NRefactory.Parser.AST; namespace ICSharpCode.NRefactory.Parser { - public interface IASTVisitor + public interface IAstVisitor { [Obsolete("Warning: you are visiting INode")] object Visit(INode node, object data); + object Visit(InterfaceImplementation interfaceImplementation, object data); + object Visit(CompilationUnit compilationUnit, object data); object Visit(TypeReference typeReference, object data); object Visit(InnerClassTypeReference innerClassTypeReference, object data); diff --git a/src/Libraries/NRefactory/Test/AssemblyInfo.cs b/src/Libraries/NRefactory/Test/AssemblyInfo.cs index 75ee8b00b7..952d90dc74 100644 --- a/src/Libraries/NRefactory/Test/AssemblyInfo.cs +++ b/src/Libraries/NRefactory/Test/AssemblyInfo.cs @@ -14,12 +14,12 @@ using System.Runtime.CompilerServices; // change them to the information which is associated with the assembly // you compile. -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyTitle("NRefactory Test")] +[assembly: AssemblyDescription("Unit tests for the parser and refactoring library for C# and VB.NET")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] +[assembly: AssemblyCompany("ic#code")] +[assembly: AssemblyProduct("SharpDevelop")] +[assembly: AssemblyCopyright("2004-2006 AlphaSierraPapa")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/Libraries/NRefactory/Test/General/UnitTest.cs b/src/Libraries/NRefactory/Test/General/UnitTest.cs index eaaa1fe5be..e15e5d640a 100644 --- a/src/Libraries/NRefactory/Test/General/UnitTest.cs +++ b/src/Libraries/NRefactory/Test/General/UnitTest.cs @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.Tests public void TestIASTVisitor() { Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes(); - Type visitor = typeof(IASTVisitor); + Type visitor = typeof(IAstVisitor); foreach (Type type in allTypes) { if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { @@ -93,7 +93,7 @@ namespace ICSharpCode.NRefactory.Tests if (!type.IsInterface && !type.IsEnum && (type.BaseType == typeof(System.Delegate)) && - (type.GetInterface(typeof(IASTVisitor).FullName) == null) && + (type.GetInterface(typeof(IAstVisitor).FullName) == null) && (type.FullName != "ICSharpCode.NRefactory.Parser.Error") && (type.FullName != "ICSharpCode.NRefactory.Tests.StructuralTest")) { Assert.IsNotNull(type.GetInterface(typeof(INode).FullName), type.FullName + " is not INode"); diff --git a/src/Libraries/NRefactory/Test/Parser/Statements/YieldStatementTests.cs b/src/Libraries/NRefactory/Test/Parser/Statements/YieldStatementTests.cs index aecdca433b..f8699c716f 100644 --- a/src/Libraries/NRefactory/Test/Parser/Statements/YieldStatementTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Statements/YieldStatementTests.cs @@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.Tests.AST public void YieldReturnStatementTest() { YieldStatement yieldStmt = ParseUtilCSharp.ParseStatement("yield return \"Foo\";"); - Assert.IsTrue(yieldStmt.IsYieldReturn()); + Assert.IsTrue(yieldStmt.IsYieldReturn); ReturnStatement retStmt = (ReturnStatement)yieldStmt.Statement; PrimitiveExpression expr = (PrimitiveExpression)retStmt.Expression; Assert.AreEqual("Foo", expr.Value); @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.Tests.AST public void YieldBreakStatementTest() { YieldStatement yieldStmt = ParseUtilCSharp.ParseStatement("yield break;"); - Assert.IsTrue(yieldStmt.IsYieldBreak()); + Assert.IsTrue(yieldStmt.IsYieldBreak); } [Test] diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs index 8f4d5f427b..4317385b94 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs @@ -27,7 +27,7 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.IsTrue(od.IsConversionOperator); Assert.AreEqual(1, od.Parameters.Count); Assert.AreEqual(ConversionType.Implicit, od.ConversionType); - Assert.AreEqual("double", od.ConvertToType.Type); + Assert.AreEqual("double", od.TypeReference.Type); } [Test] @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.IsTrue(od.IsConversionOperator); Assert.AreEqual(1, od.Parameters.Count); Assert.AreEqual(ConversionType.Explicit, od.ConversionType); - Assert.AreEqual("double", od.ConvertToType.Type); + Assert.AreEqual("double", od.TypeReference.Type); } [Test] @@ -63,7 +63,7 @@ namespace ICSharpCode.NRefactory.Tests.AST Assert.IsFalse(od.IsConversionOperator); Assert.AreEqual(1, od.Parameters.Count); Assert.AreEqual(ConversionType.None, od.ConversionType); - Assert.AreEqual("Complex", od.ConvertToType.Type); + Assert.AreEqual("Complex", od.TypeReference.Type); } #endregion } diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs index b313c904ec..ae80df2555 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs @@ -440,7 +440,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver DomRegion region = GetRegion(operatorDeclaration.StartLocation, operatorDeclaration.EndLocation); DomRegion bodyRegion = GetRegion(operatorDeclaration.EndLocation, operatorDeclaration.Body != null ? operatorDeclaration.Body.EndLocation : new Point(-1, -1)); - DefaultMethod method = new DefaultMethod(operatorDeclaration.Name, CreateReturnType(operatorDeclaration.ConvertToType), ConvertModifier(operatorDeclaration.Modifier), region, bodyRegion, c); + DefaultMethod method = new DefaultMethod(operatorDeclaration.Name, CreateReturnType(operatorDeclaration.TypeReference), ConvertModifier(operatorDeclaration.Modifier), region, bodyRegion, c); ConvertAttributes(operatorDeclaration, method); if(operatorDeclaration.Parameters != null) { diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/CodeGenerator.cs b/src/Main/Base/Project/Src/Services/RefactoringService/CodeGenerator.cs index 35ad33173f..4013a50d4c 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/CodeGenerator.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/CodeGenerator.cs @@ -104,7 +104,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring public static List ConvertAttributes(IList attributes, ClassFinder targetContext) { - AttributeSection sec = new AttributeSection(); + AttributeSection sec = new AttributeSection(null, null); foreach (IAttribute att in attributes) { sec.Attributes.Add(new ICSharpCode.NRefactory.Parser.AST.Attribute(att.Name, null, null)); } @@ -204,7 +204,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring return new EventDeclaration(ConvertType(e.ReturnType, targetContext), e.Name, ConvertModifier(e.Modifiers), - ConvertAttributes(e.Attributes, targetContext)); + ConvertAttributes(e.Attributes, targetContext), + null); } #endregion @@ -324,7 +325,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring string name = property.Name + "Changed"; EventDeclaration ed = new EventDeclaration(new TypeReference("EventHandler"), name, ConvertModifier(property.Modifiers & (ModifierEnum.VisibilityMask | ModifierEnum.Static)) - , null); + , null, null); InsertCodeAfter(property, document, ed); List arguments = new List(2); diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/EqualsCodeGenerator.cs b/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/EqualsCodeGenerator.cs index 2e7bb11770..d9d792c55e 100644 --- a/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/EqualsCodeGenerator.cs +++ b/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/EqualsCodeGenerator.cs @@ -56,7 +56,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(true, "true")))); VariableDeclaration var = new VariableDeclaration("my" + currentClass.Name, - new CastExpression(currentType, new IdentifierExpression("obj")), + new CastExpression(currentType, new IdentifierExpression("obj"), CastType.Cast), currentType); method.Body.AddChild(new LocalVariableDeclaration(var));