Esempio n. 1
0
        public static IParsingResultExtended Parse(ParsingContext context)
        {
            RewindState rewind = context.RewindState;

            if (!context.Parser.VerifyString("N"))
            {
                return(null);
            }

            CvQualifiers           cvQualifiers = CvQualifiers.Parse(context);
            RefQualifier           refQualifier = RefQualifier.Parse(context);
            IParsingResultExtended prefix       = Parsers.Prefix.Parse(context);

            if (prefix == null)
            {
                context.Rewind(rewind);
                return(null);
            }

            if (!(prefix is Parsers.Prefix.NestedName) && !(prefix is Parsers.Prefix.Template))
            {
                context.Rewind(rewind);
                return(null);
            }

            if (!context.Parser.VerifyString("E"))
            {
                context.Rewind(rewind);
                return(null);
            }

            return(new NestedName(prefix, cvQualifiers, refQualifier));
        }
Esempio n. 2
0
        public static IParsingResult Parse(ParsingContext context)
        {
            RewindState rewind = context.RewindState;

            if (!context.Parser.VerifyString("f"))
            {
                return(null);
            }

            int scope = 0;

            if (context.Parser.VerifyString("L"))
            {
                if (!context.Parser.ParseNumber(out scope))
                {
                    context.Rewind(rewind);
                    return(null);
                }
            }

            if (context.Parser.VerifyString("p"))
            {
                CvQualifiers qualifiers = CvQualifiers.Parse(context);
                int?         param      = context.Parser.ParseNumber();

                if (context.Parser.VerifyString("_"))
                {
                    return(new FunctionParam(qualifiers, scope, param));
                }
            }

            context.Rewind(rewind);
            return(null);
        }
Esempio n. 3
0
        public static IParsingResultExtended Parse(ParsingContext context)
        {
            RewindState  rewind          = context.RewindState;
            CvQualifiers cvQualifiers    = CvQualifiers.Parse(context);
            bool         transactionSafe = context.Parser.VerifyString("Dx");

            if (context.Parser.VerifyString("F"))
            {
                bool             externC  = context.Parser.VerifyString("Y");
                BareFunctionType bareType = BareFunctionType.Parse(context);

                if (bareType != null)
                {
                    RefQualifier refQualifier = RefQualifier.Parse(context);

                    if (context.Parser.VerifyString("E"))
                    {
                        return(new FunctionType(bareType, cvQualifiers, refQualifier, transactionSafe, externC));
                    }
                }
            }

            context.Rewind(rewind);
            return(null);
        }
Esempio n. 4
0
 public void Demangle(DemanglingContext context)
 {
     // TODO: transactions safety?
     // TODO: extern C?
     BareType.Demangle(context);
     CvQualifiers?.Demangle(context);
     // TODO: ref_qualifier?
 }
Esempio n. 5
0
 public FunctionType(BareFunctionType bareType, CvQualifiers cvQualifiers, RefQualifier refQualifier, bool transactionSafe, bool externC)
 {
     CvQualifiers    = cvQualifiers;
     TransactionSafe = transactionSafe;
     ExternC         = externC;
     BareType        = bareType;
     RefQualifier    = refQualifier;
 }
Esempio n. 6
0
        public void Demangle(DemanglingContext context)
        {
            Prefix.Demangle(context);

            if (context.Inner.Count > 0)
            {
                context.Inner.Pop().DemangleAsInner(context);
            }

            CvQualifiers?.Demangle(context);
            if (RefQualifier != null)
            {
                context.Writer.EnsureSpace();
                RefQualifier.Demangle(context);
            }
        }
Esempio n. 7
0
        public static CvQualifiers Parse(ParsingContext context)
        {
            CvQualifiers qualifiers = null;

            if (context.Parser.VerifyString("r"))
            {
                qualifiers          = qualifiers ?? new CvQualifiers();
                qualifiers.Restrict = true;
            }

            if (context.Parser.VerifyString("V"))
            {
                qualifiers          = qualifiers ?? new CvQualifiers();
                qualifiers.Volatile = true;
            }

            if (context.Parser.VerifyString("K"))
            {
                qualifiers       = qualifiers ?? new CvQualifiers();
                qualifiers.Const = true;
            }

            return(qualifiers);
        }
Esempio n. 8
0
 public NestedName(IParsingResultExtended prefix, CvQualifiers cvQualifiers, RefQualifier refQualifier)
 {
     Prefix       = prefix;
     CvQualifiers = cvQualifiers;
     RefQualifier = refQualifier;
 }
Esempio n. 9
0
 public FunctionParam(CvQualifiers cvQualifiers, int scope, int?param)
 {
     CvQualifiers = cvQualifiers;
     Scope        = scope;
     Param        = param;
 }
Esempio n. 10
0
 public Qualified(CvQualifiers qualifiers, IParsingResultExtended type)
 {
     CvQualifiers = qualifiers;
     Type         = type;
 }
Esempio n. 11
0
        public static IParsingResultExtended Parse(ParsingContext context)
        {
            IParsingResultExtended type = BuiltinType.Parse(context);

            if (type != null)
            {
                return(type);
            }

            type = ClassEnumType.Parse(context);
            if (type != null)
            {
                return(AddToSubstitutionTable(context, type));
            }

            RewindState rewind = context.RewindState;

            type = Substitution.Parse(context);
            if (type != null)
            {
                if (context.Parser.Peek != 'I')
                {
                    return(type);
                }

                context.Rewind(rewind);
            }

            type = FunctionType.Parse(context) ?? ArrayType.Parse(context) ?? PointerToMemberType.Parse(context);
            if (type != null)
            {
                return(AddToSubstitutionTable(context, type));
            }

            type = TemplateParam.Parse(context);
            if (type != null)
            {
                if (context.Parser.Peek != 'I')
                {
                    return(AddToSubstitutionTable(context, type));
                }

                context.Rewind(rewind);
            }

            type = TemplateTemplateParam.Parse(context);
            if (type != null)
            {
                TemplateArgs arguments = TemplateArgs.Parse(context);

                if (arguments == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }

                return(AddToSubstitutionTable(context, new TemplateTemplate(type, arguments)));
            }

            type = Decltype.Parse(context);
            if (type != null)
            {
                return(type);
            }

            CvQualifiers qualifiers = CvQualifiers.Parse(context);

            if (qualifiers != null)
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }

                if (type is BuiltinType)
                {
                    return(new QualifiedBuiltin(qualifiers, type));
                }
                return(AddToSubstitutionTable(context, new Qualified(qualifiers, type)));
            }

            if (context.Parser.VerifyString("P"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new PointerTo(type)));
            }

            if (context.Parser.VerifyString("R"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new LvalueRef(type)));
            }

            if (context.Parser.VerifyString("O"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new RvalueRef(type)));
            }

            if (context.Parser.VerifyString("C"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new Complex(type)));
            }

            if (context.Parser.VerifyString("G"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new Imaginary(type)));
            }

            if (context.Parser.VerifyString("U"))
            {
                IParsingResult name = SourceName.Parse(context);

                if (name == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }

                TemplateArgs arguments = TemplateArgs.Parse(context);

                type = Parse(context);
                return(AddToSubstitutionTable(context, new VendorExtension(name, arguments, type)));
            }

            if (context.Parser.VerifyString("Dp"))
            {
                type = Parse(context);
                if (type == null)
                {
                    context.Rewind(rewind);
                    return(null);
                }
                return(AddToSubstitutionTable(context, new PackExtension(type)));
            }

            return(null);
        }