Exemple #1
0
        public TypedefNameDecl FindTypedef(string name, bool createDecl = false)
        {
            var entries = name.Split(new string[] { "::" },
                                     StringSplitOptions.RemoveEmptyEntries).ToList();

            if (entries.Count <= 1)
            {
                var typeDef = Typedefs.FirstOrDefault(e => e.Name.Equals(name));

                if (typeDef == null && createDecl)
                {
                    typeDef = new TypedefDecl {
                        Name = name, Namespace = this
                    };
                    Declarations.Add(typeDef);
                }

                return(typeDef);
            }

            var typeDefName = entries[entries.Count - 1];
            var namespaces  = entries.Take(entries.Count - 1);

            var @namespace = FindNamespace(namespaces);

            if (@namespace == null)
            {
                return(null);
            }

            return(@namespace.FindTypedef(typeDefName, createDecl));
        }
Exemple #2
0
        public ITypeAlias FindTypeAlias(string Name, bool Create = false)
        {
            var foundTypeAlias = Typedefs.FirstOrDefault(t => t.Name == Name);

            if (foundTypeAlias != null)
            {
                return((ITypeAlias)foundTypeAlias);
            }

            if (!Create)
            {
                return(null);
            }

            var talias = new TypeAlias();

            talias.Name      = Name;
            talias.Namespace = this;

            return(talias);
        }
Exemple #3
0
        ITypedefDecl IDeclarationContext.FindTypedef(string Name, bool Create)
        {
            var foundTypedef = Typedefs.FirstOrDefault(td => td.Name == Name);

            if (foundTypedef != null)
            {
                return((ITypedefDecl)foundTypedef);
            }

            if (!Create)
            {
                return(null);
            }

            var tdef = new TypedefDecl();

            tdef.Name      = Name;
            tdef.Namespace = this;

            return(tdef);
        }