Example #1
0
        /// <summary>
        /// Visits the specified typedef.
        /// </summary>
        /// <param name="typedef">The typedef.</param>
        public override void Visit(Typedef typedef)
        {
            Write("typedef").Write(" ");
            Write(typedef.Qualifiers, true);
            VisitDynamic(typedef.Type);
            Write(" ");

            if (typedef.IsGroup)
            {
                for (int i = 0; i < typedef.SubDeclarators.Count; i++)
                {
                    var declarator = typedef.SubDeclarators[i];
                    if (i > 0)
                    {
                        Write(",").WriteSpace();
                    }

                    Write(declarator.Name);
                }
            }
            else
            {
                Write(typedef.Name);
            }

            Write(";");
            WriteLine();
        }
        public override void BuildNode(ITreeBuilder treeBuilder,
                                       object dataObject,
                                       NodeInfo nodeInfo)
        {
            Typedef t = (Typedef)dataObject;

            nodeInfo.Label = t.Name;
            nodeInfo.Icon  = Context.GetIcon(Stock.Interface);
        }
        public override void BuildNode(ITreeBuilder treeBuilder,
                                       object dataObject,
                                       ref string label,
                                       ref Gdk.Pixbuf icon,
                                       ref Gdk.Pixbuf closedIcon)
        {
            Typedef t = (Typedef)dataObject;

            label = t.Name;
            icon  = Context.GetIcon(Stock.Interface);
        }
Example #4
0
        /// <summary>
        /// The create typedef ast.
        /// </summary>
        /// <param name="parsingcontext">
        /// </param>
        /// <param name="node">
        /// </param>
        protected static void CreateTypedefAst(ParsingContext parsingcontext, ParseTreeNode node)
        {
            var value = Ast <Typedef>(node);

            // [0]             [1]                     [2]                   [3]
            // _("typedef") + typedefable_type + variable_declarator_list + ";"
            // | _("typedef") + storage_class_specifier + typedefable_type + variable_declarator_list + ";";
            int indexType = 1;

            if (node.ChildNodes.Count == 4)
            {
                value.Qualifiers = CreateEnumFlags(Qualifier.None, node.ChildNodes[0].ChildNodes);
                indexType++;
            }

            value.Type = (TypeBase)node.ChildNodes[indexType].AstNode;
            var identifierList = (List <Identifier>)node.ChildNodes[indexType + 1].AstNode;

            var declarators = new List <Typedef>(identifierList.Count);

            // Create declarators for typedefs
            foreach (var identifier in identifierList)
            {
                var declarator = new Typedef(value.Type)
                {
                    Span = identifier.Span,
                    Name = identifier
                };

                if (identifier.HasIndices)
                {
                    var arrayType = new ArrayType {
                        Type = declarator.Type, Span = identifier.Span
                    };
                    arrayType.Dimensions.AddRange(identifier.Indices);
                    declarator.Type = arrayType;
                    identifier.Indices.Clear();
                }

                declarators.Add(declarator);
            }

            if (declarators.Count == 1)
            {
                value.Type = declarators[0].Type;
                value.Name = declarators[0].Name;
            }
            else
            {
                value.SubDeclarators = declarators;
            }
        }
Example #5
0
 /// <inheritdoc/>
 public override void Visit(Typedef typedef)
 {
 }