コード例 #1
0
ファイル: FunctionGenerator.cs プロジェクト: ronsaldo/chela
        public override AstNode Visit(AttributeInstance node)
        {
            // Create the attribute constant.
            Class attributeClass = node.GetAttributeClass();
            Method attributeCtor = node.GetAttributeConstructor();
            AttributeConstant attrConstant = new AttributeConstant(attributeClass, attributeCtor);

            // Set the attribute constant as the node value.
            node.SetNodeValue(attrConstant);

            // Store the arguments.
            AstNode arg = node.GetArguments();
            while(arg != null)
            {
                // Vist the argument.
                arg.Accept(this);

                // Add the argument.
                ConstantValue value = (ConstantValue)arg.GetNodeValue();
                AttributeArgument attrArg = (AttributeArgument)arg;
                Variable property = attrArg.GetProperty();
                if(property != null)
                    attrConstant.AddPropertyValue(property, value);
                else
                    attrConstant.AddArgument(value);

                // Check the next argument.
                arg = arg.GetNext();
            }
            return node;
        }