Пример #1
0
 public AttributeBlockNode(Token token,
                           AttributeTargets location,
                           ParseNodeList attributes)
     : base(ParseNodeType.AttributeBlock, token) {
     _location = location;
     _attributes = GetParentedNodeList(attributes);
 }
Пример #2
0
 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) {
 }
Пример #4
0
        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) {
 }
Пример #7
0
 public SwitchNode(Token token,
                   ParseNode condition,
                   ParseNodeList cases)
     : base(ParseNodeType.Switch, token) {
     _condition = GetParentedNode(condition);
     _cases = GetParentedNodeList(cases);
 }
Пример #8
0
 public AttributeBlockNode(Token token,
                           AttributeTargets location,
                           ParseNodeList attributes)
     : base(ParseNodeType.AttributeBlock, token)
 {
     _location   = location;
     _attributes = GetParentedNodeList(attributes);
 }
Пример #9
0
 public VariableDeclarationNode(Token token,
                                ParseNodeList attributes,
                                Modifiers modifiers,
                                ParseNode type,
                                ParseNodeList initializers,
                                bool isFixed)
     : this(ParseNodeType.VariableDeclaration, token, attributes, modifiers, type, initializers, isFixed) {
 }
Пример #10
0
 public ConstantFieldDeclarationNode(Token token,
                                     ParseNodeList attributes,
                                     Modifiers modifiers,
                                     ParseNode type,
                                     ParseNodeList initializers)
     : base(ParseNodeType.ConstFieldDeclaration, token, attributes, modifiers, type, initializers, false)
 {
 }
Пример #11
0
 public SwitchNode(Token token,
                   ParseNode condition,
                   ParseNodeList cases)
     : base(ParseNodeType.Switch, token)
 {
     _condition = GetParentedNode(condition);
     _cases     = GetParentedNodeList(cases);
 }
Пример #12
0
 public SwitchSectionNode(Token token,
                          ParseNodeList labels,
                          ParseNodeList statements)
     : base(ParseNodeType.SwitchSection, token)
 {
     _labels     = GetParentedNodeList(labels);
     _statements = GetParentedNodeList(statements);
 }
Пример #13
0
 public NamespaceNode(Token token, string name,
                      ParseNodeList usingClauses,
                      ParseNodeList members)
     : base(ParseNodeType.Namespace, token) {
     _name = name;
     _usingClauses = GetParentedNodeList(usingClauses);
     _members = GetParentedNodeList(members);
 }
 public TypeParameterConstraintNode(AtomicNameNode typeParameter, ParseNodeList typeConstraints,
                                    bool hasConstructorConstraint)
     : base(ParseNodeType.ConstraintClause, typeParameter.token)
 {
     _typeParameter            = typeParameter;
     _typeConstraints          = typeConstraints;
     _hasConstructorConstraint = hasConstructorConstraint;
 }
Пример #15
0
 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)
 {
 }
Пример #16
0
 public NamespaceNode(Token token, string name,
                      ParseNodeList usingClauses,
                      ParseNodeList members)
     : base(ParseNodeType.Namespace, token)
 {
     _name         = name;
     _usingClauses = GetParentedNodeList(usingClauses);
     _members      = GetParentedNodeList(members);
 }
Пример #17
0
        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();
            }
        }
Пример #18
0
 public TryNode(Token token,
                ParseNode body,
                ParseNodeList catchClauses,
                ParseNode finallyClause)
     : base(ParseNodeType.Try, token) {
     _body = GetParentedNode(body);
     _catchClauses = GetParentedNodeList(catchClauses);
     _finallyClause = GetParentedNode(finallyClause);
 }
Пример #19
0
 public FieldDeclarationNode(Token token,
                             ParseNodeList attributes,
                             Modifiers modifiers,
                             ParseNode type,
                             ParseNodeList initializers,
                             bool isFixed)
     : this(ParseNodeType.FieldDeclaration, token, attributes, modifiers, type, initializers, isFixed)
 {
 }
Пример #20
0
 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;
 }
Пример #21
0
 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);
 }
Пример #22
0
 public TryNode(Token token,
                ParseNode body,
                ParseNodeList catchClauses,
                ParseNode finallyClause)
     : base(ParseNodeType.Try, token)
 {
     _body          = GetParentedNode(body);
     _catchClauses  = GetParentedNodeList(catchClauses);
     _finallyClause = GetParentedNode(finallyClause);
 }
Пример #23
0
 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);
 }
Пример #24
0
 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;
 }
Пример #25
0
 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));
 }
Пример #26
0
 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);
 }
Пример #27
0
 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);
 }
Пример #28
0
 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;
 }
Пример #29
0
 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 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);
 }
Пример #31
0
 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 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);
 }
Пример #33
0
 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);
 }
Пример #34
0
 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 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);
 }
Пример #37
0
 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);
 }
Пример #38
0
        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);
            }
        }
Пример #39
0
 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;
 }
Пример #40
0
 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);
 }
Пример #41
0
 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;
 }
Пример #42
0
 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);
 }
Пример #43
0
        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;
        }
Пример #44
0
 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;
 }
Пример #45
0
 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;
 }
Пример #46
0
 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);
 }
Пример #47
0
 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);
 }
Пример #48
0
 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);
 }
Пример #49
0
 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);
 }
Пример #50
0
        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;
        }
Пример #51
0
 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);
 }
Пример #52
0
        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);
                }
            }
        }
Пример #53
0
 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);
 }
Пример #54
0
 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);
 }
Пример #55
0
 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);
 }
Пример #56
0
        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);
        }
Пример #57
0
        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);
            }
        }
Пример #58
0
        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);
        }
Пример #59
0
        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);
        }