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); } }
public void Demangle(DemanglingContext context) { // TODO: this needs more finesse. IParsingResult arg = context.Stack.GetFunctionArg(Scope); arg?.Demangle(context); }
public void Demangle(DemanglingContext context) { Type.Demangle(context); context.Writer.Append(" "); Name.Demangle(context); Arguments?.Demangle(context); }
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("]"); }
public void Demangle(DemanglingContext context) { Type.Demangle(context); context.Writer.Append("{"); Expressions.Demangle(context); context.Writer.Append("}"); }
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(")"); } }
public void Demangle(DemanglingContext context) { context.Writer.Append("("); Expression.Demangle(context); context.Writer.Append(")("); Arguments.Demangle(context); context.Writer.Append(")"); }
public void Demangle(DemanglingContext context) { int number = Number.HasValue ? Number.Value + 1 : 0; context.Writer.Append("{lambda("); Signature.Demangle(context); context.Writer.Append($")#{number}}}"); }
public void DemangleAsInner(DemanglingContext context) { context.Writer.Append("&&"); if (context.Inner.Count > 0) { context.Inner.Pop().DemangleAsInner(context); } }
public void Demangle(DemanglingContext context) { // TODO: transactions safety? // TODO: extern C? BareType.Demangle(context); CvQualifiers?.Demangle(context); // TODO: ref_qualifier? }
public void Demangle(DemanglingContext context) { context.Writer.Append("reinterpret_cast<"); Type.Demangle(context); context.Writer.Append(">("); Expression.Demangle(context); context.Writer.Append(")"); }
public void Demangle(DemanglingContext context) { context.Writer.Append("{virtual override thunk("); Offset.Demangle(context); context.Writer.Append(", "); Encoding.Demangle(context); context.Writer.Append(")}"); }
public void Demangle(DemanglingContext context) { context.Writer.Append("::new[] ("); Expressions.Demangle(context); context.Writer.Append(") "); Type.Demangle(context); Initializer?.Demangle(context); }
public void Demangle(DemanglingContext context) { context.Inner.Push(CvQualifiers); Type.Demangle(context); if (context.Inner.Count > 0) { context.Inner.Pop().DemangleAsInner(context); } }
public void Demangle(DemanglingContext context) { foreach (IParsingResult level in Levels) { context.Writer.Append("::"); level.Demangle(context); } Name.Demangle(context); }
public void DemangleAsInner(DemanglingContext context) { if (context.Writer.Last != '(') { context.Writer.EnsureSpace(); } Type.Demangle(context); context.Writer.Append("::*"); }
public void Demangle(DemanglingContext context) { context.Inner.Push(this); Member.Demangle(context); if (context.Inner.Count > 0) { context.Inner.Pop().DemangleAsInner(context); } }
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); } }
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(")"); }
public void Demangle(DemanglingContext context) { context.Writer.Append("<"); Arguments.Demangle(context); if (context.Writer.Last == '>') { context.Writer.Append(" "); } context.Writer.Append(">"); }
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); }
public void Demangle(DemanglingContext context) { TemplateArgs args = Type.GetTemplateArgs(); context.Writer.EnsureSpace(); if (args != null) { context.Stack.Push(args); } Type.Demangle(context); }
public void Demangle(DemanglingContext context) { if (Arguments != null) { context.Stack.Push(Arguments); Parameter.Demangle(context); Arguments.Demangle(context); } else { Parameter.Demangle(context); } }
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"); } }
public void DemangleAsInner(DemanglingContext context) { TemplateArgs templateArgs = Name.GetTemplateArgs(); if (templateArgs != null) { context.Stack.Push(templateArgs); Type.DemangleWithoutType(context); } else { Type.DemangleWithType(context); } }
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(");"); } }
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); } }
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"); } }
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); }
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); }