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 TypeParameterConstraintNode(AtomicNameNode typeParameter, ParseNodeList typeConstraints,
                                    bool hasConstructorConstraint)
     : base(ParseNodeType.ConstraintClause, typeParameter.token)
 {
     _typeParameter            = typeParameter;
     _typeConstraints          = typeConstraints;
     _hasConstructorConstraint = hasConstructorConstraint;
 }
Beispiel #5
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)
 {
 }
Beispiel #6
0
 public CatchNode(Token token, ParseNode type,
                  AtomicNameNode name,
                  ParseNode body)
     : base(ParseNodeType.Catch, token) {
     _type = GetParentedNode(type);
     _name = (AtomicNameNode)GetParentedNode(name);
     _body = GetParentedNode(body);
 }
 public CatchNode(Token token, ParseNode type,
                  AtomicNameNode name,
                  ParseNode body)
     : base(ParseNodeType.Catch, token)
 {
     _type = GetParentedNode(type);
     _name = (AtomicNameNode)GetParentedNode(name);
     _body = GetParentedNode(body);
 }
Beispiel #8
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;
 }
Beispiel #9
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 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);
 }
Beispiel #11
0
 public ForeachNode(Token token,
                    ParseNode type,
                    AtomicNameNode name,
                    ParseNode container,
                    ParseNode body)
     : base(ParseNodeType.Foreach, token) {
     _type = GetParentedNode(type);
     _name = (AtomicNameNode)GetParentedNode(name);
     _container = GetParentedNode(container);
     _body = GetParentedNode(body);
 }
 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 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);
 }
 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;
 }
Beispiel #15
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);
 }
Beispiel #16
0
 public ForeachNode(Token token,
                    ParseNode type,
                    AtomicNameNode name,
                    ParseNode container,
                    ParseNode body)
     : base(ParseNodeType.Foreach, token)
 {
     _type      = GetParentedNode(type);
     _name      = (AtomicNameNode)GetParentedNode(name);
     _container = GetParentedNode(container);
     _body      = GetParentedNode(body);
 }
Beispiel #17
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);
 }
Beispiel #18
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);
 }
Beispiel #19
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);
 }
Beispiel #20
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);
 }
Beispiel #21
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);
 }
 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);
 }
Beispiel #23
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);
 }
 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);
 }
Beispiel #25
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);
 }
Beispiel #26
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);
 }
Beispiel #27
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 {
                    }
                }
            }
        }
Beispiel #28
0
 public ExternAliasNode(Token token, AtomicNameNode aliasName)
     : base(ParseNodeType.ExternAlias, token)
 {
     _aliasName = (AtomicNameNode)GetParentedNode(aliasName);
 }
Beispiel #29
0
 public TypeParameterNode(ParseNodeList attributes, AtomicNameNode name)
     : base(ParseNodeType.TypeParameter, name.token) {
     _attributes = attributes;
     _name = name;
 }
 public ExternAliasNode(Token token, AtomicNameNode aliasName)
     : base(ParseNodeType.ExternAlias, token)
 {
     _aliasName = (AtomicNameNode)GetParentedNode(aliasName);
 }
Beispiel #31
0
 public UsingAliasNode(Token token, AtomicNameNode name, NameNode type)
     : base(ParseNodeType.UsingAlias, token)
 {
     _aliasName = (AtomicNameNode)GetParentedNode(name);
     _typeName  = (NameNode)GetParentedNode(type);
 }
 public AliasQualifiedNameNode(AtomicNameNode left, NameNode right)
     : base(ParseNodeType.AliasQualifiedName, left.token)
 {
     _aliasName = (AtomicNameNode)GetParentedNode(left);
     _name      = (NameNode)GetParentedNode(right);
 }
Beispiel #33
0
 public TypeParameterNode(ParseNodeList attributes, AtomicNameNode name)
     : base(ParseNodeType.TypeParameter, name.token)
 {
     _attributes = attributes;
     _name       = name;
 }
Beispiel #34
0
 public VariableInitializerNode(AtomicNameNode name, ParseNode value)
     : base(ParseNodeType.VariableDeclarator, name.token)
 {
     _name  = (AtomicNameNode)GetParentedNode(name);
     _value = GetParentedNode(value);
 }
Beispiel #35
0
 public UsingAliasNode(Token token, AtomicNameNode name, NameNode type)
     : base(ParseNodeType.UsingAlias, token)
 {
     _aliasName = (AtomicNameNode)GetParentedNode(name);
     _typeName = (NameNode)GetParentedNode(type);
 }
 public LabeledStatementNode(AtomicNameNode label, ParseNode statement)
     : base(ParseNodeType.LabeledStatement, label.token)
 {
     _label = (AtomicNameNode)GetParentedNode(label);
     _statement = GetParentedNode(statement);
 }
 public VariableInitializerNode(AtomicNameNode name, ParseNode value)
     : base(ParseNodeType.VariableDeclarator, name.token)
 {
     _name = (AtomicNameNode)GetParentedNode(name);
     _value = GetParentedNode(value);
 }
 public AliasQualifiedNameNode(AtomicNameNode left, NameNode right)
     : base(ParseNodeType.AliasQualifiedName, left.token)
 {
     _aliasName = (AtomicNameNode)GetParentedNode(left);
     _name = (NameNode)GetParentedNode(right);
 }
 public LabeledStatementNode(AtomicNameNode label, ParseNode statement)
     : base(ParseNodeType.LabeledStatement, label.token)
 {
     _label     = (AtomicNameNode)GetParentedNode(label);
     _statement = GetParentedNode(statement);
 }