Ejemplo n.º 1
0
        private void ProcessAttributes(AstNode node)
        {
            // Get the attributes node.
            AstNode attributes = node.GetAttributes();

            // Visit them.
            VisitList(attributes);
        }
Ejemplo n.º 2
0
        private void ProcessAttributes(AstNode node)
        {
            // Get the attributes node.
            AstNode attrNode = node.GetAttributes();

            // Ignore nodes without attributes.
            if(attrNode == null)
                return;

            // Retrieve the node member.
            List<ScopeMember> memberList = new List<ScopeMember> ();
            FunctionDefinition defunNode = node as FunctionDefinition;
            if(defunNode != null)
            {
                memberList.Add(defunNode.GetFunction());
            }
            else
            {
                FunctionPrototype protoNode = node as FunctionPrototype;
                if(protoNode != null)
                {
                    memberList.Add(protoNode.GetFunction());
                }
                else
                {
                    FieldDefinition fieldNode = node as FieldDefinition;
                    if(fieldNode != null)
                    {
                        // Add each one of the fields declared.
                        AstNode declNode = fieldNode.GetDeclarations();
                        while(declNode != null)
                        {
                            FieldDeclaration decl = (FieldDeclaration)declNode;
                            memberList.Add(decl.GetVariable());
                            declNode = declNode.GetNext();
                        }
                    }
                    else
                    {
                        ScopeNode scopeNode = node as ScopeNode;
                        if(scopeNode != null)
                            memberList.Add(scopeNode.GetScope());
                        else
                            Error(node, "unimplemented member node type.");
                    }
                }
            }

            // Visit the attributes, and add them to the member.
            while(attrNode != null)
            {
                // Visit it.
                attrNode.Accept(this);

                // Store the attribute.
                AttributeConstant attrConstant = (AttributeConstant)attrNode.GetNodeValue();
                foreach(ScopeMember member in memberList)
                    member.AddAttribute(attrConstant);

                // Check the next attribute.
                attrNode = attrNode.GetNext();
            }
        }