Ejemplo n.º 1
0
        // Builds an argument for the constructor.
        public static void BuildArgument(IronyParser parser, Constructor method, ParseTreeNode node)
        {
            // Check for a directioned argument (out, ref).
            if (node.Term.ToString() == "out_parameter")
            {
                var a = new DirectionedParameter(null, node.FindToken().Convert());
                switch (node.ChildNodes[0].ChildNodes[0].Term.ToString())
                {
                case "ref":
                    a.Direction = ParameterDirection.Ref;
                    break;

                case "out":
                    a.Direction = ParameterDirection.Out;
                    break;
                }
                a.TypeName = parser.CheckAlias(node.ChildNodes[1].FindTokenAndGetText());
                a.Name     = node.ChildNodes[2].FindTokenAndGetText();
                method.Parameters.Add(a);
            }
            else
            {
                // Build an undirectioned argument.
                var a = new SimpleParameter(null, node.FindToken().Convert());
                a.TypeName = parser.CheckAlias(node.ChildNodes[0].FindTokenAndGetText());
                a.Name     = node.ChildNodes[1].FindTokenAndGetText();
                method.Parameters.Add(a);
            }
        }
Ejemplo n.º 2
0
        // Build the arguments of the delegate declaration.
        public static void BuildArgument(IronyParser parser, DelegateDeclaration method, ParseTreeNode node)
        {
            if (node.Term.ToString() == "out_parameter")
            {
                var a = new DirectionedParameter(null, node.FindToken().Convert());
                switch (node.ChildNodes[0].ChildNodes[0].Term.ToString())
                {
                case "ref":
                    a.Direction = ParameterDirection.Ref;
                    break;

                case "out":
                    a.Direction = ParameterDirection.Out;
                    break;
                }
                a.TypeName = parser.CheckAlias(node.ChildNodes[1].FindTokenAndGetText());
                a.Name     = node.ChildNodes[2].FindTokenAndGetText();
                method.Parameters.Add(a);
            }
            else if (node.Term.ToString() == "array_parameter")
            {
                var a = new SimpleParameter(null, node.FindToken().Convert());
                a.TypeName = parser.CheckAlias(node.ChildNodes[0].FindTokenAndGetText()) + "[]";
                a.Name     = node.ChildNodes[3].FindTokenAndGetText();
                method.Parameters.Add(a);
            }
            else if (node.Term.ToString() == "generic_parameter")
            {
                var    a        = new SimpleParameter(null, node.FindToken().Convert());
                string typeName = node.ChildNodes[0].ChildNodes[0].FindTokenAndGetText() + "<";
                for (int i = 0; i < node.ChildNodes[0].ChildNodes[2].ChildNodes.Count; i++)
                {
                    typeName += parser.CheckAlias(node.ChildNodes[0].ChildNodes[2].ChildNodes[i].FindTokenAndGetText());
                    if (i < node.ChildNodes[0].ChildNodes[2].ChildNodes.Count - 1)
                    {
                        typeName += ",";
                    }
                }
                typeName  += ">";
                a.TypeName = typeName;
                a.Name     = node.ChildNodes[1].FindTokenAndGetText();
                method.Parameters.Add(a);
            }
            else
            {
                var a = new SimpleParameter(null, node.FindToken().Convert());
                a.TypeName = parser.CheckAlias(node.ChildNodes[0].FindTokenAndGetText());
                a.Name     = node.ChildNodes[1].FindTokenAndGetText();
                method.Parameters.Add(a);
            }
        }