Пример #1
0
        public void Visit(RefTypeDecl decl)
        {
            switch (decl.Name)
            {
            case "__int8":
            case "__int16":
            case "__int32":
            case "__int64":
            case "char":
            case "wchar_t":
            case "bool":
            case "float":
            case "double":
            case "void":
            case "int":
            case "long":
                return;
            }

            for (int pass = 0; pass < 2; pass++)
            {
                var current = this.Symbol;
                while (current != null)
                {
                    if (!(current is TypedefDecl))
                    {
                        if (!(current is NamespaceDecl) && !(current is GlobalDecl))
                        {
                            var content = this.Environment.GetSymbolContent(current, false);
                            var decls   = FindSymbolInContent(decl, decl.Name, content, pass == 0, pass == 1 && !this.SupressError);
                            if (decls != null)
                            {
                                this.Environment.ResolvedTypes.Add(decl, decls);
                                return;
                            }
                        }
                        else
                        {
                            var references = this.Environment.NamespaceReferences[current is GlobalDecl ? "" : current.NameKey];
                            foreach (var reference in references)
                            {
                                var content = this.Environment.NamespaceContents[reference];
                                var decls   = FindSymbolInContent(decl, decl.Name, content, pass == 0, pass == 1 && !this.SupressError);
                                if (decls != null)
                                {
                                    this.Environment.ResolvedTypes.Add(decl, decls);
                                    return;
                                }
                            }
                        }
                    }
                    current = current.Parent;
                }
            }

            AddError(decl, decl.Name);
        }
Пример #2
0
 public void Visit(RefTypeDecl decl)
 {
     Deserialize(decl);
     decl.Name = Element.Attribute("Name").Value;
 }
Пример #3
0
 public void Visit(RefTypeDecl decl)
 {
     this.Result = decl.Name;
 }
Пример #4
0
 public void Visit(RefTypeDecl decl)
 {
     Serialize(decl);
     this.Element.Add(new XAttribute("Name", decl.Name));
 }
Пример #5
0
 public void Visit(RefTypeDecl decl)
 {
     Serialize(decl);
     this.Element.Add(new XAttribute("Name", decl.Name));
 }
Пример #6
0
        static bool ParseMiniType(string[] tokens, ref int index, out TypeDecl decl)
        {
            decl = null;
            if (CppParser.Token(tokens, ref index, "const"))
            {
                decl = new DecorateTypeDecl
                {
                    Decoration = Decoration.Const,
                    Element = EnsureMiniType(tokens, ref index),
                };
                return true;
            }
            else if (CppParser.Token(tokens, ref index, "volatile"))
            {
                decl = new DecorateTypeDecl
                {
                    Decoration = Decoration.Volatile,
                    Element = EnsureMiniType(tokens, ref index),
                };
                return true;
            }
            else if (CppParser.Token(tokens, ref index, "signed"))
            {
                decl = new DecorateTypeDecl
                {
                    Decoration = Decoration.Signed,
                    Element = EnsureMiniType(tokens, ref index),
                };
                return true;
            }
            else if (CppParser.Token(tokens, ref index, "unsigned"))
            {
                decl = new DecorateTypeDecl
                {
                    Decoration = Decoration.Unsigned,
                    Element = EnsureMiniType(tokens, ref index),
                };
                return true;
            }
            else if (CppParser.Token(tokens, ref index, "decltype"))
            {
                CppParser.EnsureToken(tokens, ref index, "(");
                int oldIndex = index;
                CppParser.SkipUntil(tokens, ref index, ")");

                decl = new DeclTypeDecl
                {
                    Expression = tokens
                        .Skip(oldIndex)
                        .Take(index - 1 - oldIndex)
                        .Aggregate((a, b) => a + " " + b),
                };
                return true;
            }
            else if (CppParser.Token(tokens, ref index, "false") || CppParser.Token(tokens, ref index, "true"))
            {
                decl = new ConstantTypeDecl
                {
                    Value = tokens[index - 1],
                };
                return true;
            }
            else
            {
                if (index < tokens.Length)
                {
                    int value = 0;
                    if (int.TryParse(tokens[index], out value))
                    {
                        index++;
                        decl = new ConstantTypeDecl
                        {
                            Value = tokens[index - 1],
                        };
                        return true;
                    }
                }

                string token = null;
                CppParser.Token(tokens, ref index, "typename");
                if (CppParser.Id(tokens, ref index, out token))
                {
                    decl = new RefTypeDecl
                    {
                        Name = token,
                    };

                    if (token != "operator")
                    {
                        while (true)
                        {
                            if (CppParser.Token(tokens, ref index, "<"))
                            {
                                var genericDecl = new GenericTypeDecl
                                {
                                    Element = decl,
                                    TypeArguments = new List<TypeDecl>(),
                                };
                                decl = genericDecl;

                                if (!CppParser.Token(tokens, ref index, ">"))
                                {
                                    while (true)
                                    {
                                        genericDecl.TypeArguments.Add(EnsureTypeWithoutName(tokens, ref index));

                                        if (CppParser.Token(tokens, ref index, ">"))
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            CppParser.EnsureToken(tokens, ref index, ",");
                                        }
                                    }
                                }
                            }
                            else if (CppParser.Token(tokens, ref index, ":"))
                            {
                                CppParser.EnsureToken(tokens, ref index, ":");
                                CppParser.Token(tokens, ref index, "template");
                                if (CppParser.Id(tokens, ref index, out token))
                                {
                                    decl = new SubTypeDecl
                                    {
                                        Parent = decl,
                                        Name = token,
                                    };
                                }
                                else
                                {
                                    index -= 2;
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
Пример #7
0
        public void Visit(RefTypeDecl decl)
        {
            switch (decl.Name)
            {
                case "__int8":
                case "__int16":
                case "__int32":
                case "__int64":
                case "char":
                case "wchar_t":
                case "bool":
                case "float":
                case "double":
                case "void":
                case "int":
                case "long":
                    return;
            }

            for (int pass = 0; pass < 2; pass++)
            {
                var current = this.Symbol;
                while (current != null)
                {
                    if (!(current is TypedefDecl))
                    {
                        if (!(current is NamespaceDecl) && !(current is GlobalDecl))
                        {
                            var content = this.Environment.GetSymbolContent(current);
                            var decls = FindSymbolInContent(decl, decl.Name, content, pass == 0, pass == 1 && !this.SupressError);
                            if (decls != null)
                            {
                                this.Environment.ResolvedTypes.Add(decl, decls);
                                return;
                            }
                        }
                        else
                        {
                            var references = this.Environment.NamespaceReferences[current is GlobalDecl ? "" : current.NameKey];
                            foreach (var reference in references)
                            {
                                var content = this.Environment.NamespaceContents[reference];
                                var decls = FindSymbolInContent(decl, decl.Name, content, pass == 0, pass == 1 && !this.SupressError);
                                if (decls != null)
                                {
                                    this.Environment.ResolvedTypes.Add(decl, decls);
                                    return;
                                }
                            }
                        }
                    }
                    current = current.Parent;
                }
            }

            AddError(decl, decl.Name);
        }
Пример #8
0
 public void Visit(RefTypeDecl decl)
 {
     this.Result = decl.Name;
 }