Example #1
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);
 }
Example #2
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;
 }
Example #3
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);
 }
Example #4
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);
 }
Example #5
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);
 }
Example #6
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 {
                    }
                }
            }
        }
Example #7
0
 public EventDeclarationNode(Token token, ParseNodeList attributes, ParseNode backingMember)
     : base(ParseNodeType.EventDeclaration, token)
 {
     _attributes           = GetParentedNodeList(AttributeNode.GetAttributeList(attributes));
     _implementationMember = GetParentedNode(backingMember);
 }