Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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
                    {
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public EventDeclarationNode(Token token, ParseNodeList attributes, ParseNode backingMember)
     : base(ParseNodeType.EventDeclaration, token)
 {
     Attributes           = GetParentedNodeList(AttributeNode.GetAttributeList(attributes));
     implementationMember = GetParentedNode(backingMember);
 }