示例#1
0
            public void Demangle(DemanglingContext context)
            {
                // Whether the first type in the BareFunctionType is a return
                // type or parameter depends on the context in which it
                // appears.
                //
                // * Templates and functions in a type or parameter position
                // always have return types.
                //
                // * Non-template functions that are not in a type or parameter
                // position do not have a return type.
                //
                // We know we are not printing a type, so we only need to check
                // whether this is a template.
                //
                // For the details, see
                // http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.function-type
                TemplateArgs templateArgs = Name.GetTemplateArgs();

                if (templateArgs != null)
                {
                    context.Stack.Push(templateArgs);
                    Type.Demangle(context);
                    context.Writer.Append(" ");
                }

                context.Inner.Push(this);
                Name.Demangle(context);
                if (context.Inner.Count > 0)
                {
                    context.Inner.Pop().DemangleAsInner(context);
                }
            }
示例#2
0
        public void Demangle(DemanglingContext context)
        {
            // TODO: this needs more finesse.
            IParsingResult arg = context.Stack.GetFunctionArg(Scope);

            arg?.Demangle(context);
        }
示例#3
0
 public void Demangle(DemanglingContext context)
 {
     Type.Demangle(context);
     context.Writer.Append(" ");
     Name.Demangle(context);
     Arguments?.Demangle(context);
 }
示例#4
0
        public void DemangleAsInner(DemanglingContext context)
        {
            bool innerIsArray = false;

            while (context.Inner.Count > 0)
            {
                IDemangleAsInner inner = context.Inner.Pop();

                innerIsArray = inner is ArrayType;
                if (!innerIsArray)
                {
                    context.Writer.EnsureSpace();
                    context.Writer.Append("(");
                }
                inner.DemangleAsInner(context);
                if (!innerIsArray)
                {
                    context.Writer.Append(")");
                }
            }
            if (!innerIsArray)
            {
                context.Writer.EnsureSpace();
            }
            context.Writer.Append("[");
            DemangleSize(context);
            context.Writer.Append("]");
        }
示例#5
0
 public void Demangle(DemanglingContext context)
 {
     Type.Demangle(context);
     context.Writer.Append("{");
     Expressions.Demangle(context);
     context.Writer.Append("}");
 }
示例#6
0
            public void Demangle(DemanglingContext context)
            {
                SimpleOperatorName question = OperatorName as SimpleOperatorName;

                if (question.Value == SimpleOperatorName.Values.Question)
                {
                    FirstExpression.Demangle(context);
                    context.Writer.Append(" ? ");
                    SecondExpression.Demangle(context);
                    context.Writer.Append(" : ");
                    ThirdExpression.Demangle(context);
                }
                else
                {
                    // Nonsensical ternary operator? Just print it like a function call,
                    // I suppose...
                    //
                    // TODO: should we detect and reject this during parsing?
                    OperatorName.Demangle(context);
                    context.Writer.Append("(");
                    FirstExpression.Demangle(context);
                    context.Writer.Append(", ");
                    SecondExpression.Demangle(context);
                    context.Writer.Append(", ");
                    ThirdExpression.Demangle(context);
                    context.Writer.Append(")");
                }
            }
示例#7
0
 public void Demangle(DemanglingContext context)
 {
     context.Writer.Append("(");
     Expression.Demangle(context);
     context.Writer.Append(")(");
     Arguments.Demangle(context);
     context.Writer.Append(")");
 }
示例#8
0
        public void Demangle(DemanglingContext context)
        {
            int number = Number.HasValue ? Number.Value + 1 : 0;

            context.Writer.Append("{lambda(");
            Signature.Demangle(context);
            context.Writer.Append($")#{number}}}");
        }
示例#9
0
 public void DemangleAsInner(DemanglingContext context)
 {
     context.Writer.Append("&&");
     if (context.Inner.Count > 0)
     {
         context.Inner.Pop().DemangleAsInner(context);
     }
 }
示例#10
0
 public void Demangle(DemanglingContext context)
 {
     // TODO: transactions safety?
     // TODO: extern C?
     BareType.Demangle(context);
     CvQualifiers?.Demangle(context);
     // TODO: ref_qualifier?
 }
示例#11
0
 public void Demangle(DemanglingContext context)
 {
     context.Writer.Append("reinterpret_cast<");
     Type.Demangle(context);
     context.Writer.Append(">(");
     Expression.Demangle(context);
     context.Writer.Append(")");
 }
示例#12
0
 public void Demangle(DemanglingContext context)
 {
     context.Writer.Append("{virtual override thunk(");
     Offset.Demangle(context);
     context.Writer.Append(", ");
     Encoding.Demangle(context);
     context.Writer.Append(")}");
 }
示例#13
0
 public void Demangle(DemanglingContext context)
 {
     context.Writer.Append("::new[] (");
     Expressions.Demangle(context);
     context.Writer.Append(") ");
     Type.Demangle(context);
     Initializer?.Demangle(context);
 }
示例#14
0
 public void Demangle(DemanglingContext context)
 {
     context.Inner.Push(CvQualifiers);
     Type.Demangle(context);
     if (context.Inner.Count > 0)
     {
         context.Inner.Pop().DemangleAsInner(context);
     }
 }
示例#15
0
 public void Demangle(DemanglingContext context)
 {
     foreach (IParsingResult level in Levels)
     {
         context.Writer.Append("::");
         level.Demangle(context);
     }
     Name.Demangle(context);
 }
示例#16
0
 public void DemangleAsInner(DemanglingContext context)
 {
     if (context.Writer.Last != '(')
     {
         context.Writer.EnsureSpace();
     }
     Type.Demangle(context);
     context.Writer.Append("::*");
 }
示例#17
0
 public void Demangle(DemanglingContext context)
 {
     context.Inner.Push(this);
     Member.Demangle(context);
     if (context.Inner.Count > 0)
     {
         context.Inner.Pop().DemangleAsInner(context);
     }
 }
示例#18
0
 public void Demangle(DemanglingContext context)
 {
     context.Inner.Push(this);
     Types[0].Demangle(context);
     if (context.Inner.Count > 0)
     {
         context.Writer.EnsureSpace();
         context.Inner.Pop().DemangleAsInner(context);
     }
 }
示例#19
0
 public void Demangle(DemanglingContext context)
 {
     context.Writer.Append("(");
     FirstExpression.Demangle(context);
     context.Writer.Append(")");
     OperatorName.Demangle(context);
     context.Writer.Append("(");
     SecondExpression.Demangle(context);
     context.Writer.Append(")");
 }
示例#20
0
 public void Demangle(DemanglingContext context)
 {
     context.Writer.Append("<");
     Arguments.Demangle(context);
     if (context.Writer.Last == '>')
     {
         context.Writer.Append(" ");
     }
     context.Writer.Append(">");
 }
示例#21
0
            public void Demangle(DemanglingContext context)
            {
                // Use new context with arguments on stack for name demangling
                DemanglingContext tempContext = context;

                tempContext.Stack.Push(Args);
                Name.Demangle(tempContext);

                // Return to old context
                Args.Demangle(context);
            }
示例#22
0
            public void Demangle(DemanglingContext context)
            {
                TemplateArgs args = Type.GetTemplateArgs();

                context.Writer.EnsureSpace();
                if (args != null)
                {
                    context.Stack.Push(args);
                }
                Type.Demangle(context);
            }
示例#23
0
 public void Demangle(DemanglingContext context)
 {
     if (Arguments != null)
     {
         context.Stack.Push(Arguments);
         Parameter.Demangle(context);
         Arguments.Demangle(context);
     }
     else
     {
         Parameter.Demangle(context);
     }
 }
示例#24
0
 public void Demangle(DemanglingContext context)
 {
     Encoding.Demangle(context);
     if (Name != null)
     {
         context.Writer.Append("::");
         Name.Demangle(context);
     }
     else
     {
         // No name means that this is the symbol for a string literal.
         context.Writer.Append("::string literal");
     }
 }
示例#25
0
            public void DemangleAsInner(DemanglingContext context)
            {
                TemplateArgs templateArgs = Name.GetTemplateArgs();

                if (templateArgs != null)
                {
                    context.Stack.Push(templateArgs);
                    Type.DemangleWithoutType(context);
                }
                else
                {
                    Type.DemangleWithType(context);
                }
            }
示例#26
0
 public void Demangle(DemanglingContext context)
 {
     if (context.GccCompatibleDemangle)
     {
         context.Writer.Append("VTT for ");
         Type.Demangle(context);
     }
     else
     {
         context.Writer.Append("{vtt(");
         Type.Demangle(context);
         context.Writer.Append(");");
     }
 }
示例#27
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);
            }
        }
示例#28
0
 public void Demangle(DemanglingContext context)
 {
     if (Const)
     {
         context.Writer.EnsureSpace();
         context.Writer.Append("const");
     }
     if (Volatile)
     {
         context.Writer.EnsureSpace();
         context.Writer.Append("volatile");
     }
     if (Restrict)
     {
         context.Writer.EnsureSpace();
         context.Writer.Append("restrict");
     }
 }
示例#29
0
        internal void Verify(string input, IParsingResult expected, string endsWith = "...")
        {
            ParsingContext parsingContext = CreateContext(input);
            IParsingResult result         = Parse(parsingContext);

            CompareParsingResult(expected, result);
            Assert.IsTrue(string.IsNullOrEmpty(endsWith) || input.EndsWith(endsWith));
            if (!string.IsNullOrEmpty(endsWith))
            {
                Assert.AreEqual(input.Length - endsWith.Length, parsingContext.Parser.Position, "Not everything was parsed");
            }

            // Demangle to verify that there are no exceptions
            DemanglingContext demanglingContext = DemanglingContext.Create(parsingContext, true);

            result?.Demangle(demanglingContext);
            System.Console.WriteLine(demanglingContext.Writer.Text);
        }
示例#30
0
            public void Demangle(DemanglingContext context)
            {
                // Handle GCC's anonymous namespace mangling.
                const string anonymusNamespacePrefix = "_GLOBAL_";

                if (Name.StartsWith(anonymusNamespacePrefix) && Name.Length >= anonymusNamespacePrefix.Length + 2)
                {
                    char first  = Name[anonymusNamespacePrefix.Length];
                    char second = Name[anonymusNamespacePrefix.Length + 1];

                    if (second == 'N' && (first == '.' || first == '$' || first == '_'))
                    {
                        context.Writer.Append("(anonymous namespace)");
                        return;
                    }
                }

                context.Writer.Append(Name);
            }