예제 #1
0
 public void Visit(VariadicArgumentTypeDecl decl)
 {
     Deserialize(decl);
     decl.Element = TypeDecl.Deserialize(this.Element.Element("Element").Elements().First());
 }
예제 #2
0
 public void Visit(VariadicArgumentTypeDecl decl)
 {
     Serialize(decl);
     this.Element.Add(new XElement("Element", decl.Element.Serialize()));
 }
예제 #3
0
 public void Visit(VariadicArgumentTypeDecl decl)
 {
     this.Result = "... " + decl.Element.ToString();
 }
예제 #4
0
 public void Visit(VariadicArgumentTypeDecl decl)
 {
     decl.Element.Resolve(this.Symbol, this.Environment);
 }
예제 #5
0
 public void Visit(VariadicArgumentTypeDecl decl)
 {
     Serialize(decl);
     this.Element.Add(new XElement("Element", decl.Element.Serialize()));
 }
예제 #6
0
        static void ParseTypeContinueBeforeName(string[] tokens, ref int index, out TypeDecl decl, out Action<TypeDecl> continuation, out string name)
        {
            decl = null;
            continuation = null;
            name = null;

            while (true)
            {
                Decoration? decoration = null;
                if (CppParser.Token(tokens, ref index, "const"))
                {
                    decoration = Decoration.Const;
                }
                else if (CppParser.Token(tokens, ref index, "volatile"))
                {
                    decoration = Decoration.Volatile;
                }
                else if (CppParser.Token(tokens, ref index, "*"))
                {
                    decoration = Decoration.Pointer;
                }
                else if (CppParser.Token(tokens, ref index, "&"))
                {
                    if (CppParser.Token(tokens, ref index, "&"))
                    {
                        decoration = Decoration.RightRef;
                    }
                    else
                    {
                        decoration = Decoration.LeftRef;
                    }
                }
                else if (CppParser.Token(tokens, ref index, "."))
                {
                    CppParser.EnsureToken(tokens, ref index, ".");
                    CppParser.EnsureToken(tokens, ref index, ".");

                    var vaDecl = new VariadicArgumentTypeDecl
                    {
                    };
                    if (decl == null)
                    {
                        continuation = x => vaDecl.Element = x;
                    }
                    else
                    {
                        vaDecl.Element = decl;
                    }
                    decl = vaDecl;
                }
                else
                {
                    TypeDecl classType = null;
                    if (ParseMiniType(tokens, ref index, out classType))
                    {
                        if (CppParser.Token(tokens, ref index, ":"))
                        {
                            CppParser.EnsureToken(tokens, ref index, ":");
                            var classMemberTypeDecl = new ClassMemberTypeDecl
                            {
                                ClassType = classType,
                            };
                            if (decl == null)
                            {
                                continuation = x => classMemberTypeDecl.Element = x;
                            }
                            else
                            {
                                classMemberTypeDecl.Element = decl;
                            }
                            decl = classMemberTypeDecl;
                        }
                        else
                        {
                            var subType = classType as SubTypeDecl;
                            var refType = classType as RefTypeDecl;
                            if (subType != null)
                            {
                                name = subType.Name;

                                var classMemberTypeDecl = new ClassMemberTypeDecl
                                {
                                    ClassType = subType.Parent,
                                };
                                if (decl == null)
                                {
                                    continuation = x => classMemberTypeDecl.Element = x;
                                }
                                else
                                {
                                    classMemberTypeDecl.Element = decl;
                                }
                                decl = classMemberTypeDecl;
                            }
                            else if (refType != null)
                            {
                                name = refType.Name;
                            }
                            else
                            {
                                throw new ArgumentException("Failed to parse.");
                            }

                            if (name == "operator")
                            {
                                if (tokens[index + 1] == "(")
                                {
                                    name += " " + tokens[index];
                                    index += 1;
                                }
                                else if (tokens[index + 2] == "(")
                                {
                                    name += " " + tokens[index] + tokens[index + 1];
                                    index += 2;
                                }
                                else
                                {
                                    throw new ArgumentException("Failed to parse.");
                                }
                            }
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (decoration != null)
                {
                    var decorateDecl = new DecorateTypeDecl
                    {
                        Decoration = decoration.Value,
                    };
                    if (decl == null)
                    {
                        continuation = x => decorateDecl.Element = x;
                    }
                    else
                    {
                        decorateDecl.Element = decl;
                    }
                    decl = decorateDecl;
                }
            }
        }
예제 #7
0
 public void Visit(VariadicArgumentTypeDecl decl)
 {
     decl.Element.Resolve(this.Symbol, this.Environment);
 }
예제 #8
0
 public void Visit(VariadicArgumentTypeDecl decl)
 {
     this.Result = "... " + decl.Element.ToString();
 }