示例#1
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;
 }
示例#2
0
 public ParameterNode(
     Token token,
     ParseNodeList attributes,
     ParameterFlags flags,
     ParseNode type,
     AtomicNameNode name,
     bool isExtensionMethodTarget = false)
     : base(ParseNodeType.FormalParameter, token)
 {
     Attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes));
     Flags      = flags;
     IsExtensionMethodTarget = isExtensionMethodTarget;
     Type      = GetParentedNode(type);
     this.name = (AtomicNameNode)GetParentedNode(name);
 }
示例#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;
     this.typeParameters    = GetParentedNodeList(typeParameters);
     this.constraintClauses = GetParentedNodeList(constraintClauses);
 }
示例#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);
     this.interfaceType = (NameNode)GetParentedNode(interfaceType);
     GetAccessor        = (AccessorNode)GetParentedNode(getOrRemove);
     SetAccessor        = (AccessorNode)GetParentedNode(setOrAdd);
 }
示例#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;
     Type           = GetParentedNode(returnType);
     this.name      = (AtomicNameNode)GetParentedNode(name);
     Parameters     = GetParentedNodeList(formals);
     Implementation = (BlockStatementNode)GetParentedNode(body);
 }
示例#6
0
        public EnumerationFieldNode(ParseNodeList attributes, AtomicNameNode name,
                                    ParseNode value)
            : base(ParseNodeType.EnumerationFieldDeclaration, name.Token)
        {
            Attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes));
            this.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.

                if (value is UnaryExpressionNode expressionNode && expressionNode.Operator == TokenType.Minus &&
                    expressionNode.Child is LiteralNode node)
                {
                    try
                    {
                        LiteralToken literalToken =
                            (LiteralToken)node.Token;
                        int numericValue = (int)Convert.ChangeType(literalToken.LiteralValue, typeof(int));

                        Value = -numericValue;
                    }
                    catch
                    {
                    }
                }
            }
        }
示例#7
0
 public EventDeclarationNode(Token token, ParseNodeList attributes, ParseNode backingMember)
     : base(ParseNodeType.EventDeclaration, token)
 {
     Attributes           = GetParentedNodeList(AttributeNode.GetAttributeList(attributes));
     implementationMember = GetParentedNode(backingMember);
 }