public AttributeBlockNode(Token token, AttributeTargets location, ParseNodeList attributes) : base(ParseNodeType.AttributeBlock, token) { _location = location; _attributes = GetParentedNodeList(attributes); }
public SwitchSectionNode(Token token, ParseNodeList labels, ParseNodeList statements) : base(ParseNodeType.SwitchSection, token) { _labels = GetParentedNodeList(labels); _statements = GetParentedNodeList(statements); }
public ConstantFieldDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, ParseNodeList initializers) : base(ParseNodeType.ConstFieldDeclaration, token, attributes, modifiers, type, initializers, false) { }
public EnumerationFieldNode(ParseNodeList attributes, AtomicNameNode name, ParseNode value) : base(ParseNodeType.EnumerationFieldDeclaration, name.token) { _attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); _name = (AtomicNameNode)GetParentedNode(name); if (value is LiteralNode) { LiteralNode literalNode = (LiteralNode)value; _value = ((LiteralToken)literalNode.Token).LiteralValue; } else { // TODO: Clearly we need something more general... // C# allows expressions. Likely expressions to be used // include negative values, binary OR'd values, // expressions involving other enum members (esp. hard to deal with) // For now, just adding support for negative numbers, as // everything else can be worked around in source code. UnaryExpressionNode expressionNode = value as UnaryExpressionNode; if ((expressionNode != null) && (expressionNode.Operator == TokenType.Minus) && (expressionNode.Child is LiteralNode)) { try { LiteralToken literalToken = (LiteralToken)((LiteralNode)expressionNode.Child).Token; int numericValue = (int)Convert.ChangeType(literalToken.LiteralValue, typeof(int)); _value = -numericValue; } catch { } } } }
public TypeParameterConstraintNode(AtomicNameNode typeParameter, ParseNodeList typeConstraints, bool hasConstructorConstraint) : base(ParseNodeType.ConstraintClause, typeParameter.token) { _typeParameter = typeParameter; _typeConstraints = typeConstraints; _hasConstructorConstraint = hasConstructorConstraint; }
public DestructorDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, AtomicNameNode name, BlockStatementNode body) : base(ParseNodeType.DestructorDeclaration, token, attributes, modifiers, /* return type */ null, name, new ParseNodeList(), body) { }
public SwitchNode(Token token, ParseNode condition, ParseNodeList cases) : base(ParseNodeType.Switch, token) { _condition = GetParentedNode(condition); _cases = GetParentedNodeList(cases); }
public VariableDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, ParseNodeList initializers, bool isFixed) : this(ParseNodeType.VariableDeclaration, token, attributes, modifiers, type, initializers, isFixed) { }
public NamespaceNode(Token token, string name, ParseNodeList usingClauses, ParseNodeList members) : base(ParseNodeType.Namespace, token) { _name = name; _usingClauses = GetParentedNodeList(usingClauses); _members = GetParentedNodeList(members); }
private void Visit(ParseNode node, PropertyInfo propertyInfo) { string name = propertyInfo.Name; object value = propertyInfo.GetValue(node, null); string text = name + " (" + propertyInfo.PropertyType.Name + ")"; if (value != null) { if (value is ParseNodeList) { ParseNodeList nodeList = (ParseNodeList)value; if (nodeList.Count == 0) { text += " : Empty"; } else { text += " : " + nodeList.Count.ToString(); } StartChildren(text); foreach (ParseNode nodeItem in nodeList) { Visit(nodeItem); } EndChildren(); } else if (value is ParseNode) { StartChildren(text); Visit((ParseNode)value); EndChildren(); } else { if (value is string) { text += " : \"" + (string)value + "\""; } else { text += " : " + value.ToString(); } StartChildren(text); EndChildren(); } } else { text += " : null"; StartChildren(text); EndChildren(); } }
public TryNode(Token token, ParseNode body, ParseNodeList catchClauses, ParseNode finallyClause) : base(ParseNodeType.Try, token) { _body = GetParentedNode(body); _catchClauses = GetParentedNodeList(catchClauses); _finallyClause = GetParentedNode(finallyClause); }
public FieldDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, ParseNodeList initializers, bool isFixed) : this(ParseNodeType.FieldDeclaration, token, attributes, modifiers, type, initializers, isFixed) { }
public OperatorDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, TokenType operatorNodeType, ParseNode returnType, ParseNodeList formals, BlockStatementNode body) : base(ParseNodeType.OperatorDeclaration, token, attributes, modifiers, returnType, /* name */ null, formals, body) { this.operatorTokenType = operatorNodeType; }
public NamespaceNode(Token token, NameNode nameNode, ParseNodeList externAliases, ParseNodeList usingClauses, ParseNodeList members) : base(ParseNodeType.Namespace, token) { _name = nameNode.Name; _externAliases = GetParentedNodeList(externAliases); _usingClauses = GetParentedNodeList(usingClauses); _members = GetParentedNodeList(members); }
public CompilationUnitNode(Token token, ParseNodeList externAliases, ParseNodeList usingClauses, ParseNodeList attributes, ParseNodeList members) : base(ParseNodeType.CompilationUnit, token) { _externAliases = GetParentedNodeList(externAliases); _usingClauses = GetParentedNodeList(usingClauses); _attributes = GetParentedNodeList(attributes); _members = GetParentedNodeList(GetNamespaces(members)); }
public PropertyDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, NameNode interfaceType, AtomicNameNode name, AccessorNode getOrRemove, AccessorNode setOrAdd) : this(ParseNodeType.PropertyDeclaration, token, attributes, modifiers, type, interfaceType, getOrRemove, setOrAdd) { _name = (AtomicNameNode)GetParentedNode(name); }
public ParameterNode(Token token, ParseNodeList attributes, ParameterFlags flags, ParseNode type, AtomicNameNode name) : base(ParseNodeType.FormalParameter, token) { _attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); _flags = flags; _type = GetParentedNode(type); _name = (AtomicNameNode)GetParentedNode(name); }
public AccessorNode(Token token, ParseNodeList attributes, AtomicNameNode name, BlockStatementNode body, Modifiers modifiers) : base(ParseNodeType.AccessorDeclaration, token) { _name = (AtomicNameNode)GetParentedNode(name); _implementation = (BlockStatementNode)GetParentedNode(body); _attributes = GetParentedNodeList(attributes); _modifiers = modifiers; }
public DelegateTypeNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode returnType, AtomicNameNode name, ParseNodeList typeParameters, ParseNodeList parameters, ParseNodeList constraintClauses) : base(ParseNodeType.Delegate, token, TokenType.Delegate, attributes, modifiers, name, typeParameters, constraintClauses) { _returnType = GetParentedNode(returnType); _parameters = GetParentedNodeList(parameters); }
public IndexerDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, NameNode interfaceType, ParseNodeList parameters, AccessorNode get, AccessorNode set) : base(ParseNodeType.IndexerDeclaration, token, attributes, modifiers, type, interfaceType, get, set) { _parameters = GetParentedNodeList(parameters); }
public CustomTypeNode(Token token, TokenType type, ParseNodeList attributes, Modifiers modifiers, AtomicNameNode name, ParseNodeList typeParameters, ParseNodeList baseTypes, ParseNodeList constraintClauses, ParseNodeList members) : base(ParseNodeType.Type, token, type, attributes, modifiers, name, typeParameters, constraintClauses) { _baseTypes = GetParentedNodeList(baseTypes); _members = GetParentedNodeList(members); }
public ConstructorDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, AtomicNameNode name, ParseNodeList formals, bool callBase, ParseNode baseArguments, BlockStatementNode body) : base(ParseNodeType.ConstructorDeclaration, token, attributes, modifiers, /* return type */ null, name, formals, body) { _callBase = callBase; _baseArguments = GetParentedNode(baseArguments); }
internal void IncludeCompilationUnitUsingClauses() { CompilationUnitNode compilationUnit = (CompilationUnitNode)parent; if (compilationUnit.UsingClauses.Count != 0) { ParseNodeList mergedUsings = new ParseNodeList(); mergedUsings.Append(compilationUnit.UsingClauses); if (_usingClauses.Count != 0) { mergedUsings.Append(_usingClauses); } _usingClauses = GetParentedNodeList(mergedUsings); } }
protected FieldDeclarationNode(ParseNodeType nodeType, Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, ParseNodeList initializers, bool isFixed) : base(nodeType, token) { _attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); _modifiers = modifiers; _type = GetParentedNode(type); _initializers = GetParentedNodeList(initializers); _isFixed = isFixed; }
protected VariableDeclarationNode(ParseNodeType nodeType, Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, ParseNodeList initializers, bool isFixed) : base(nodeType, token) { this.attributes = GetParentedNodeList(attributes); this.modifiers = modifiers; this.type = GetParentedNode(type); this.initializers = GetParentedNodeList(initializers); this.isFixed = isFixed; }
public static AttributeNode FindAttribute(ParseNodeList attributeNodes, string attributeName) { if ((attributeNodes == null) || (attributeNodes.Count == 0)) { return null; } foreach (AttributeNode attrNode in attributeNodes) { if (attrNode.TypeName.Equals(attributeName, StringComparison.Ordinal)) { return attrNode; } } return null; }
public UserTypeNode(ParseNodeType type, Token token, TokenType tokenType, ParseNodeList attributes, Modifiers modifiers, AtomicNameNode name, ParseNodeList typeParameters, ParseNodeList constraintClauses) : base(type, token) { _type = tokenType; _attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); _modifiers = modifiers; _nameNode = name; _typeParameters = GetParentedNodeList(typeParameters); _constraintClauses = GetParentedNodeList(constraintClauses); }
protected PropertyDeclarationNode(ParseNodeType nodeType, Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, NameNode interfaceType, AccessorNode getOrRemove, AccessorNode setOrAdd) : base(nodeType, token) { _attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); _modifiers = modifiers; _type = GetParentedNode(type); _interfaceType = (NameNode)GetParentedNode(interfaceType); _getOrRemove = (AccessorNode)GetParentedNode(getOrRemove); _setOrAdd = (AccessorNode)GetParentedNode(setOrAdd); }
public MethodDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode returnType, NameNode interfaceType, AtomicNameNode name, ParseNodeList typeParameters, ParseNodeList formals, ParseNodeList constraints, BlockStatementNode body) : this(ParseNodeType.MethodDeclaration, token, attributes, modifiers, returnType, name, formals, body) { _interfaceType = (NameNode)GetParentedNode(interfaceType); _typeParameters = GetParentedNodeList(typeParameters); _constraints = GetParentedNodeList(constraints); }
protected MethodDeclarationNode(ParseNodeType nodeType, Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode returnType, AtomicNameNode name, ParseNodeList formals, BlockStatementNode body) : base(nodeType, token) { _attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); _modifiers = modifiers; _returnType = GetParentedNode(returnType); _name = (AtomicNameNode)GetParentedNode(name); _parameters = GetParentedNodeList(formals); _implementation = (BlockStatementNode)GetParentedNode(body); }
public static ParseNodeList GetAttributeList(ParseNodeList attributeBlocks) { if ((attributeBlocks == null) || (attributeBlocks.Count == 0)) { return attributeBlocks; } ParseNodeList attributes = new ParseNodeList(); foreach (AttributeBlockNode attributeBlock in attributeBlocks) { ParseNodeList localAttributes = attributeBlock.Attributes; if (localAttributes.Count != 0) { attributes.Append(localAttributes); } } return attributes; }
private void BuildCodeModel() { _compilationUnitList = new ParseNodeList(); CodeModelBuilder codeModelBuilder = new CodeModelBuilder(_options, this); CodeModelValidator codeModelValidator = new CodeModelValidator(this); CodeModelProcessor validationProcessor = new CodeModelProcessor(codeModelValidator, _options); foreach (IStreamSource source in _options.Sources) { CompilationUnitNode compilationUnit = codeModelBuilder.BuildCodeModel(source); if (compilationUnit != null) { validationProcessor.Process(compilationUnit); _compilationUnitList.Append(compilationUnit); } } }
public static AttributeNode FindAttribute(ParseNodeList attributeNodes, string attributeName) { if ((attributeNodes == null) || (attributeNodes.Count == 0)) { return(null); } foreach (AttributeNode attrNode in attributeNodes) { if (attrNode.TypeName.Equals(attributeName, StringComparison.Ordinal)) { return(attrNode); } } return(null); }
public static ParseNodeList GetAttributeList(ParseNodeList attributeBlocks) { if ((attributeBlocks == null) || (attributeBlocks.Count == 0)) { return(attributeBlocks); } ParseNodeList attributes = new ParseNodeList(); foreach (AttributeBlockNode attributeBlock in attributeBlocks) { ParseNodeList localAttributes = attributeBlock.Attributes; if (localAttributes.Count != 0) { attributes.Append(localAttributes); } } return(attributes); }
private ParseNodeList GetNamespaces(ParseNodeList members) { ParseNodeList namespaceList = new ParseNodeList(); foreach (ParseNode memberNode in members) { NamespaceNode namespaceNode = memberNode as NamespaceNode; if (namespaceNode == null) { // Top-level type nodes are turned into children of a namespace with // an empty name. Token nsToken = new Token(TokenType.Namespace, memberNode.Token.SourcePath, memberNode.Token.Position); namespaceNode = new NamespaceNode(nsToken, String.Empty, _usingClauses, new ParseNodeList(memberNode)); } namespaceList.Append(namespaceNode); } return(namespaceList); }