Rewrite the C++ Demangler (#416)
* Rewrite the C++ Demangler This new Demangler provides support to almost every possible mangled symbols and should behaves like GNU c++filt. It works on 98.9% of the sdk's symbols and 99.5% of Puyo Puyo Tetris's symbols. * Fix code style * Fix noexcept enclosed expression parsing issues * fix code style issues
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ArraySubscriptingExpression : BaseNode
|
||||
{
|
||||
private BaseNode LeftNode;
|
||||
private BaseNode Subscript;
|
||||
|
||||
public ArraySubscriptingExpression(BaseNode LeftNode, BaseNode Subscript) : base(NodeType.ArraySubscriptingExpression)
|
||||
{
|
||||
this.LeftNode = LeftNode;
|
||||
this.Subscript = Subscript;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("(");
|
||||
LeftNode.Print(Writer);
|
||||
Writer.Write(")[");
|
||||
Subscript.Print(Writer);
|
||||
Writer.Write("]");
|
||||
}
|
||||
}
|
||||
}
|
59
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ArrayType.cs
Normal file
59
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ArrayType.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ArrayType : BaseNode
|
||||
{
|
||||
private BaseNode Base;
|
||||
private BaseNode DimensionExpression;
|
||||
private string DimensionString;
|
||||
|
||||
public ArrayType(BaseNode Base, BaseNode DimensionExpression = null) : base(NodeType.ArrayType)
|
||||
{
|
||||
this.Base = Base;
|
||||
this.DimensionExpression = DimensionExpression;
|
||||
}
|
||||
|
||||
public ArrayType(BaseNode Base, string DimensionString) : base(NodeType.ArrayType)
|
||||
{
|
||||
this.Base = Base;
|
||||
this.DimensionString = DimensionString;
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool IsArray()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Base.PrintLeft(Writer);
|
||||
}
|
||||
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
// FIXME: detect if previous char was a ].
|
||||
Writer.Write(" ");
|
||||
|
||||
Writer.Write("[");
|
||||
|
||||
if (DimensionString != null)
|
||||
{
|
||||
Writer.Write(DimensionString);
|
||||
}
|
||||
else if (DimensionExpression != null)
|
||||
{
|
||||
DimensionExpression.Print(Writer);
|
||||
}
|
||||
|
||||
Writer.Write("]");
|
||||
|
||||
Base.PrintRight(Writer);
|
||||
}
|
||||
}
|
||||
}
|
113
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/BaseNode.cs
Normal file
113
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/BaseNode.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public enum NodeType
|
||||
{
|
||||
CVQualifierType,
|
||||
SimpleReferenceType,
|
||||
NameType,
|
||||
EncodedFunction,
|
||||
NestedName,
|
||||
SpecialName,
|
||||
LiteralOperator,
|
||||
NodeArray,
|
||||
ElaboratedType,
|
||||
PostfixQualifiedType,
|
||||
SpecialSubstitution,
|
||||
ExpandedSpecialSubstitution,
|
||||
CtorDtorNameType,
|
||||
EnclosedExpression,
|
||||
ForwardTemplateReference,
|
||||
NameTypeWithTemplateArguments,
|
||||
PackedTemplateArgument,
|
||||
TemplateArguments,
|
||||
BooleanExpression,
|
||||
CastExpression,
|
||||
CallExpression,
|
||||
IntegerCastExpression,
|
||||
PackedTemplateParameter,
|
||||
PackedTemplateParameterExpansion,
|
||||
IntegerLiteral,
|
||||
DeleteExpression,
|
||||
MemberExpression,
|
||||
ArraySubscriptingExpression,
|
||||
InitListExpression,
|
||||
PostfixExpression,
|
||||
ConditionalExpression,
|
||||
ThrowExpression,
|
||||
FunctionParameter,
|
||||
ConversionExpression,
|
||||
BinaryExpression,
|
||||
PrefixExpression,
|
||||
BracedExpression,
|
||||
BracedRangeExpression,
|
||||
NewExpression,
|
||||
QualifiedName,
|
||||
StdQualifiedName,
|
||||
DtOrName,
|
||||
GlobalQualifiedName,
|
||||
NoexceptSpec,
|
||||
DynamicExceptionSpec,
|
||||
FunctionType,
|
||||
PointerType,
|
||||
ReferenceType,
|
||||
ConversionOperatorType,
|
||||
LocalName,
|
||||
CtorVtableSpecialName,
|
||||
ArrayType
|
||||
}
|
||||
|
||||
public abstract class BaseNode
|
||||
{
|
||||
public NodeType Type { get; protected set; }
|
||||
|
||||
public BaseNode(NodeType Type)
|
||||
{
|
||||
this.Type = Type;
|
||||
}
|
||||
|
||||
public virtual void Print(TextWriter Writer)
|
||||
{
|
||||
PrintLeft(Writer);
|
||||
|
||||
if (HasRightPart())
|
||||
{
|
||||
PrintRight(Writer);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void PrintLeft(TextWriter Writer);
|
||||
|
||||
public virtual bool HasRightPart()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsArray()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HasFunctions()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual string GetName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void PrintRight(TextWriter Writer) {}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringWriter Writer = new StringWriter();
|
||||
|
||||
Print(Writer);
|
||||
|
||||
return Writer.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class BinaryExpression : BaseNode
|
||||
{
|
||||
private BaseNode LeftPart;
|
||||
private string Name;
|
||||
private BaseNode RightPart;
|
||||
|
||||
public BinaryExpression(BaseNode LeftPart, string Name, BaseNode RightPart) : base(NodeType.BinaryExpression)
|
||||
{
|
||||
this.LeftPart = LeftPart;
|
||||
this.Name = Name;
|
||||
this.RightPart = RightPart;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (Name.Equals(">"))
|
||||
{
|
||||
Writer.Write("(");
|
||||
}
|
||||
|
||||
Writer.Write("(");
|
||||
LeftPart.Print(Writer);
|
||||
Writer.Write(") ");
|
||||
|
||||
Writer.Write(Name);
|
||||
|
||||
Writer.Write(" (");
|
||||
RightPart.Print(Writer);
|
||||
Writer.Write(")");
|
||||
|
||||
if (Name.Equals(">"))
|
||||
{
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class BracedExpression : BaseNode
|
||||
{
|
||||
private BaseNode Element;
|
||||
private BaseNode Expression;
|
||||
private bool IsArrayExpression;
|
||||
|
||||
public BracedExpression(BaseNode Element, BaseNode Expression, bool IsArrayExpression) : base(NodeType.BracedExpression)
|
||||
{
|
||||
this.Element = Element;
|
||||
this.Expression = Expression;
|
||||
this.IsArrayExpression = IsArrayExpression;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (IsArrayExpression)
|
||||
{
|
||||
Writer.Write("[");
|
||||
Element.Print(Writer);
|
||||
Writer.Write("]");
|
||||
}
|
||||
else
|
||||
{
|
||||
Writer.Write(".");
|
||||
Element.Print(Writer);
|
||||
}
|
||||
|
||||
if (!Expression.GetType().Equals(NodeType.BracedExpression) || !Expression.GetType().Equals(NodeType.BracedRangeExpression))
|
||||
{
|
||||
Writer.Write(" = ");
|
||||
}
|
||||
|
||||
Expression.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class BracedRangeExpression : BaseNode
|
||||
{
|
||||
private BaseNode FirstNode;
|
||||
private BaseNode LastNode;
|
||||
private BaseNode Expression;
|
||||
|
||||
public BracedRangeExpression(BaseNode FirstNode, BaseNode LastNode, BaseNode Expression) : base(NodeType.BracedRangeExpression)
|
||||
{
|
||||
this.FirstNode = FirstNode;
|
||||
this.LastNode = LastNode;
|
||||
this.Expression = Expression;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("[");
|
||||
FirstNode.Print(Writer);
|
||||
Writer.Write(" ... ");
|
||||
LastNode.Print(Writer);
|
||||
Writer.Write("]");
|
||||
|
||||
if (!Expression.GetType().Equals(NodeType.BracedExpression) || !Expression.GetType().Equals(NodeType.BracedRangeExpression))
|
||||
{
|
||||
Writer.Write(" = ");
|
||||
}
|
||||
|
||||
Expression.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
25
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/CallExpression.cs
Normal file
25
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/CallExpression.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class CallExpression : NodeArray
|
||||
{
|
||||
private BaseNode Callee;
|
||||
|
||||
public CallExpression(BaseNode Callee, List<BaseNode> Nodes) : base(Nodes, NodeType.CallExpression)
|
||||
{
|
||||
this.Callee = Callee;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Callee.Print(Writer);
|
||||
|
||||
Writer.Write("(");
|
||||
Writer.Write(string.Join<BaseNode>(", ", Nodes.ToArray()));
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
30
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/CasExpression.cs
Normal file
30
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/CasExpression.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class CastExpression : BaseNode
|
||||
{
|
||||
private string Kind;
|
||||
private BaseNode To;
|
||||
private BaseNode From;
|
||||
|
||||
public CastExpression(string Kind, BaseNode To, BaseNode From) : base(NodeType.CastExpression)
|
||||
{
|
||||
this.Kind = Kind;
|
||||
this.To = To;
|
||||
this.From = From;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write(Kind);
|
||||
Writer.Write("<");
|
||||
To.PrintLeft(Writer);
|
||||
Writer.Write(">(");
|
||||
From.PrintLeft(Writer);
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ConditionalExpression : BaseNode
|
||||
{
|
||||
private BaseNode ThenNode;
|
||||
private BaseNode ElseNode;
|
||||
private BaseNode ConditionNode;
|
||||
|
||||
public ConditionalExpression(BaseNode ConditionNode, BaseNode ThenNode, BaseNode ElseNode) : base(NodeType.ConditionalExpression)
|
||||
{
|
||||
this.ThenNode = ThenNode;
|
||||
this.ConditionNode = ConditionNode;
|
||||
this.ElseNode = ElseNode;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("(");
|
||||
ConditionNode.Print(Writer);
|
||||
Writer.Write(") ? (");
|
||||
ThenNode.Print(Writer);
|
||||
Writer.Write(") : (");
|
||||
ElseNode.Print(Writer);
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ConversionExpression : BaseNode
|
||||
{
|
||||
private BaseNode TypeNode;
|
||||
private BaseNode Expressions;
|
||||
|
||||
public ConversionExpression(BaseNode TypeNode, BaseNode Expressions) : base(NodeType.ConversionExpression)
|
||||
{
|
||||
this.TypeNode = TypeNode;
|
||||
this.Expressions = Expressions;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("(");
|
||||
TypeNode.Print(Writer);
|
||||
Writer.Write(")(");
|
||||
Expressions.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ConversionOperatorType : ParentNode
|
||||
{
|
||||
public ConversionOperatorType(BaseNode Child) : base(NodeType.ConversionOperatorType, Child) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("operator ");
|
||||
Child.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class CtorDtorNameType : ParentNode
|
||||
{
|
||||
private bool IsDestructor;
|
||||
|
||||
public CtorDtorNameType(BaseNode Name, bool IsDestructor) : base(NodeType.CtorDtorNameType, Name)
|
||||
{
|
||||
this.IsDestructor = IsDestructor;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (IsDestructor)
|
||||
{
|
||||
Writer.Write("~");
|
||||
}
|
||||
|
||||
Writer.Write(Child.GetName());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class CtorVtableSpecialName : BaseNode
|
||||
{
|
||||
private BaseNode FirstType;
|
||||
private BaseNode SecondType;
|
||||
|
||||
public CtorVtableSpecialName(BaseNode FirstType, BaseNode SecondType) : base(NodeType.CtorVtableSpecialName)
|
||||
{
|
||||
this.FirstType = FirstType;
|
||||
this.SecondType = SecondType;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("construction vtable for ");
|
||||
FirstType.Print(Writer);
|
||||
Writer.Write("-in-");
|
||||
SecondType.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class DeleteExpression : ParentNode
|
||||
{
|
||||
private bool IsGlobal;
|
||||
private bool IsArrayExpression;
|
||||
|
||||
public DeleteExpression(BaseNode Child, bool IsGlobal, bool IsArrayExpression) : base(NodeType.DeleteExpression, Child)
|
||||
{
|
||||
this.IsGlobal = IsGlobal;
|
||||
this.IsArrayExpression = IsArrayExpression;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (IsGlobal)
|
||||
{
|
||||
Writer.Write("::");
|
||||
}
|
||||
|
||||
Writer.Write("delete");
|
||||
|
||||
if (IsArrayExpression)
|
||||
{
|
||||
Writer.Write("[] ");
|
||||
}
|
||||
|
||||
Child.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
15
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/DtorName.cs
Normal file
15
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/DtorName.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class DtorName : ParentNode
|
||||
{
|
||||
public DtorName(BaseNode Name) : base(NodeType.DtOrName, Name) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("~");
|
||||
Child.PrintLeft(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class DynamicExceptionSpec : ParentNode
|
||||
{
|
||||
public DynamicExceptionSpec(BaseNode Child) : base(NodeType.DynamicExceptionSpec, Child) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("throw(");
|
||||
Child.Print(Writer);
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
21
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ElaboratedType.cs
Normal file
21
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ElaboratedType.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ElaboratedType : ParentNode
|
||||
{
|
||||
private string Elaborated;
|
||||
|
||||
public ElaboratedType(string Elaborated, BaseNode Type) : base(NodeType.ElaboratedType, Type)
|
||||
{
|
||||
this.Elaborated = Elaborated;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write(Elaborated);
|
||||
Writer.Write(" ");
|
||||
Child.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class EnclosedExpression : BaseNode
|
||||
{
|
||||
private string Prefix;
|
||||
private BaseNode Expression;
|
||||
private string Postfix;
|
||||
|
||||
public EnclosedExpression(string Prefix, BaseNode Expression, string Postfix) : base(NodeType.EnclosedExpression)
|
||||
{
|
||||
this.Prefix = Prefix;
|
||||
this.Expression = Expression;
|
||||
this.Postfix = Postfix;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write(Prefix);
|
||||
Expression.Print(Writer);
|
||||
Writer.Write(Postfix);
|
||||
}
|
||||
}
|
||||
}
|
77
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/EncodedFunction.cs
Normal file
77
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/EncodedFunction.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class EncodedFunction : BaseNode
|
||||
{
|
||||
private BaseNode Name;
|
||||
private BaseNode Params;
|
||||
private BaseNode CV;
|
||||
private BaseNode Ref;
|
||||
private BaseNode Attrs;
|
||||
private BaseNode Ret;
|
||||
|
||||
public EncodedFunction(BaseNode Name, BaseNode Params, BaseNode CV, BaseNode Ref, BaseNode Attrs, BaseNode Ret) : base(NodeType.NameType)
|
||||
{
|
||||
this.Name = Name;
|
||||
this.Params = Params;
|
||||
this.CV = CV;
|
||||
this.Ref = Ref;
|
||||
this.Attrs = Attrs;
|
||||
this.Ret = Ret;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (Ret != null)
|
||||
{
|
||||
Ret.PrintLeft(Writer);
|
||||
|
||||
if (!Ret.HasRightPart())
|
||||
{
|
||||
Writer.Write(" ");
|
||||
}
|
||||
}
|
||||
|
||||
Name.Print(Writer);
|
||||
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("(");
|
||||
|
||||
if (Params != null)
|
||||
{
|
||||
Params.Print(Writer);
|
||||
}
|
||||
|
||||
Writer.Write(")");
|
||||
|
||||
if (Ret != null)
|
||||
{
|
||||
Ret.PrintRight(Writer);
|
||||
}
|
||||
|
||||
if (CV != null)
|
||||
{
|
||||
CV.Print(Writer);
|
||||
}
|
||||
|
||||
if (Ref != null)
|
||||
{
|
||||
Ref.Print(Writer);
|
||||
}
|
||||
|
||||
if (Attrs != null)
|
||||
{
|
||||
Attrs.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
48
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/FoldExpression.cs
Normal file
48
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/FoldExpression.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class FoldExpression : BaseNode
|
||||
{
|
||||
private bool IsLeftFold;
|
||||
private string OperatorName;
|
||||
private BaseNode Expression;
|
||||
private BaseNode Initializer;
|
||||
|
||||
public FoldExpression(bool IsLeftFold, string OperatorName, BaseNode Expression, BaseNode Initializer) : base(NodeType.FunctionParameter)
|
||||
{
|
||||
this.IsLeftFold = IsLeftFold;
|
||||
this.OperatorName = OperatorName;
|
||||
this.Expression = Expression;
|
||||
this.Initializer = Initializer;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("(");
|
||||
|
||||
if (IsLeftFold && Initializer != null)
|
||||
{
|
||||
Initializer.Print(Writer);
|
||||
Writer.Write(" ");
|
||||
Writer.Write(OperatorName);
|
||||
Writer.Write(" ");
|
||||
}
|
||||
|
||||
Writer.Write(IsLeftFold ? "... " : " ");
|
||||
Writer.Write(OperatorName);
|
||||
Writer.Write(!IsLeftFold ? " ..." : " ");
|
||||
Expression.Print(Writer);
|
||||
|
||||
if (!IsLeftFold && Initializer != null)
|
||||
{
|
||||
Initializer.Print(Writer);
|
||||
Writer.Write(" ");
|
||||
Writer.Write(OperatorName);
|
||||
Writer.Write(" ");
|
||||
}
|
||||
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ForwardTemplateReference : BaseNode
|
||||
{
|
||||
// TODO: Compute inside the Demangler
|
||||
public BaseNode Reference;
|
||||
private int Index;
|
||||
|
||||
public ForwardTemplateReference(int Index) : base(NodeType.ForwardTemplateReference)
|
||||
{
|
||||
this.Index = Index;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
return Reference.GetName();
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Reference.PrintLeft(Writer);
|
||||
}
|
||||
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
Reference.PrintRight(Writer);
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
return Reference.HasRightPart();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class FunctionParameter : BaseNode
|
||||
{
|
||||
private string Number;
|
||||
|
||||
public FunctionParameter(string Number) : base(NodeType.FunctionParameter)
|
||||
{
|
||||
this.Number = Number;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("fp ");
|
||||
|
||||
if (Number != null)
|
||||
{
|
||||
Writer.Write(Number);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
61
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/FunctionType.cs
Normal file
61
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/FunctionType.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class FunctionType : BaseNode
|
||||
{
|
||||
private BaseNode ReturnType;
|
||||
private BaseNode Params;
|
||||
private BaseNode CVQualifier;
|
||||
private SimpleReferenceType ReferenceQualifier;
|
||||
private BaseNode ExceptionSpec;
|
||||
|
||||
public FunctionType(BaseNode ReturnType, BaseNode Params, BaseNode CVQualifier, SimpleReferenceType ReferenceQualifier, BaseNode ExceptionSpec) : base(NodeType.FunctionType)
|
||||
{
|
||||
this.ReturnType = ReturnType;
|
||||
this.Params = Params;
|
||||
this.CVQualifier = CVQualifier;
|
||||
this.ReferenceQualifier = ReferenceQualifier;
|
||||
this.ExceptionSpec = ExceptionSpec;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
ReturnType.PrintLeft(Writer);
|
||||
Writer.Write(" ");
|
||||
}
|
||||
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("(");
|
||||
Params.Print(Writer);
|
||||
Writer.Write(")");
|
||||
|
||||
ReturnType.PrintRight(Writer);
|
||||
|
||||
CVQualifier.Print(Writer);
|
||||
|
||||
if (ReferenceQualifier.Qualifier != Reference.None)
|
||||
{
|
||||
Writer.Write(" ");
|
||||
ReferenceQualifier.PrintQualifier(Writer);
|
||||
}
|
||||
|
||||
if (ExceptionSpec != null)
|
||||
{
|
||||
Writer.Write(" ");
|
||||
ExceptionSpec.Print(Writer);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HasFunctions()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class GlobalQualifiedName : ParentNode
|
||||
{
|
||||
public GlobalQualifiedName(BaseNode Child) : base(NodeType.GlobalQualifiedName, Child) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("::");
|
||||
Child.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class InitListExpression : BaseNode
|
||||
{
|
||||
private BaseNode TypeNode;
|
||||
private List<BaseNode> Nodes;
|
||||
|
||||
public InitListExpression(BaseNode TypeNode, List<BaseNode> Nodes) : base(NodeType.InitListExpression)
|
||||
{
|
||||
this.TypeNode = TypeNode;
|
||||
this.Nodes = Nodes;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (TypeNode != null)
|
||||
{
|
||||
TypeNode.Print(Writer);
|
||||
}
|
||||
|
||||
Writer.Write("{");
|
||||
Writer.Write(string.Join<BaseNode>(", ", Nodes.ToArray()));
|
||||
Writer.Write("}");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class IntegerCastExpression : ParentNode
|
||||
{
|
||||
private string Number;
|
||||
|
||||
public IntegerCastExpression(BaseNode Type, string Number) : base(NodeType.IntegerCastExpression, Type)
|
||||
{
|
||||
this.Number = Number;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("(");
|
||||
Child.Print(Writer);
|
||||
Writer.Write(")");
|
||||
Writer.Write(Number);
|
||||
}
|
||||
}
|
||||
}
|
41
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/IntegerLiteral.cs
Normal file
41
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/IntegerLiteral.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class IntegerLiteral : BaseNode
|
||||
{
|
||||
private string LitteralName;
|
||||
private string LitteralValue;
|
||||
|
||||
public IntegerLiteral(string LitteralName, string LitteralValue) : base(NodeType.IntegerLiteral)
|
||||
{
|
||||
this.LitteralValue = LitteralValue;
|
||||
this.LitteralName = LitteralName;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (LitteralName.Length > 3)
|
||||
{
|
||||
Writer.Write("(");
|
||||
Writer.Write(LitteralName);
|
||||
Writer.Write(")");
|
||||
}
|
||||
|
||||
if (LitteralValue[0] == 'n')
|
||||
{
|
||||
Writer.Write("-");
|
||||
Writer.Write(LitteralValue.Substring(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Writer.Write(LitteralValue);
|
||||
}
|
||||
|
||||
if (LitteralName.Length <= 3)
|
||||
{
|
||||
Writer.Write(LitteralName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/LiteralOperator.cs
Normal file
16
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/LiteralOperator.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class LiteralOperator : ParentNode
|
||||
{
|
||||
public LiteralOperator(BaseNode Child) : base(NodeType.LiteralOperator, Child) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("operator \"");
|
||||
Child.PrintLeft(Writer);
|
||||
Writer.Write("\"");
|
||||
}
|
||||
}
|
||||
}
|
23
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/LocalName.cs
Normal file
23
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/LocalName.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class LocalName : BaseNode
|
||||
{
|
||||
private BaseNode Encoding;
|
||||
private BaseNode Entity;
|
||||
|
||||
public LocalName(BaseNode Encoding, BaseNode Entity) : base(NodeType.LocalName)
|
||||
{
|
||||
this.Encoding = Encoding;
|
||||
this.Entity = Entity;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Encoding.Print(Writer);
|
||||
Writer.Write("::");
|
||||
Entity.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class MemberExpression : BaseNode
|
||||
{
|
||||
private BaseNode LeftNode;
|
||||
private string Kind;
|
||||
private BaseNode RightNode;
|
||||
|
||||
public MemberExpression(BaseNode LeftNode, string Kind, BaseNode RightNode) : base(NodeType.MemberExpression)
|
||||
{
|
||||
this.LeftNode = LeftNode;
|
||||
this.Kind = Kind;
|
||||
this.RightNode = RightNode;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
LeftNode.Print(Writer);
|
||||
Writer.Write(Kind);
|
||||
RightNode.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
29
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NameType.cs
Normal file
29
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NameType.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class NameType : BaseNode
|
||||
{
|
||||
private string NameValue;
|
||||
|
||||
public NameType(string NameValue, NodeType Type) : base(Type)
|
||||
{
|
||||
this.NameValue = NameValue;
|
||||
}
|
||||
|
||||
public NameType(string NameValue) : base(NodeType.NameType)
|
||||
{
|
||||
this.NameValue = NameValue;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
return NameValue;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write(NameValue);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class NameTypeWithTemplateArguments : BaseNode
|
||||
{
|
||||
private BaseNode Prev;
|
||||
private BaseNode TemplateArgument;
|
||||
|
||||
public NameTypeWithTemplateArguments(BaseNode Prev, BaseNode TemplateArgument) : base(NodeType.NameTypeWithTemplateArguments)
|
||||
{
|
||||
this.Prev = Prev;
|
||||
this.TemplateArgument = TemplateArgument;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
return Prev.GetName();
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Prev.Print(Writer);
|
||||
TemplateArgument.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
26
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NestedName.cs
Normal file
26
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NestedName.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class NestedName : ParentNode
|
||||
{
|
||||
private BaseNode Name;
|
||||
|
||||
public NestedName(BaseNode Name, BaseNode Type) : base(NodeType.NestedName, Type)
|
||||
{
|
||||
this.Name = Name;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
return Name.GetName();
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Child.Print(Writer);
|
||||
Writer.Write("::");
|
||||
Name.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
55
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NewExpression.cs
Normal file
55
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NewExpression.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class NewExpression : BaseNode
|
||||
{
|
||||
private NodeArray Expressions;
|
||||
private BaseNode TypeNode;
|
||||
private NodeArray Initializers;
|
||||
|
||||
private bool IsGlobal;
|
||||
private bool IsArrayExpression;
|
||||
|
||||
public NewExpression(NodeArray Expressions, BaseNode TypeNode, NodeArray Initializers, bool IsGlobal, bool IsArrayExpression) : base(NodeType.NewExpression)
|
||||
{
|
||||
this.Expressions = Expressions;
|
||||
this.TypeNode = TypeNode;
|
||||
this.Initializers = Initializers;
|
||||
|
||||
this.IsGlobal = IsGlobal;
|
||||
this.IsArrayExpression = IsArrayExpression;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (IsGlobal)
|
||||
{
|
||||
Writer.Write("::operator ");
|
||||
}
|
||||
|
||||
Writer.Write("new ");
|
||||
|
||||
if (IsArrayExpression)
|
||||
{
|
||||
Writer.Write("[] ");
|
||||
}
|
||||
|
||||
if (Expressions.Nodes.Count != 0)
|
||||
{
|
||||
Writer.Write("(");
|
||||
Expressions.Print(Writer);
|
||||
Writer.Write(")");
|
||||
}
|
||||
|
||||
TypeNode.Print(Writer);
|
||||
|
||||
if (Initializers.Nodes.Count != 0)
|
||||
{
|
||||
Writer.Write("(");
|
||||
Initializers.Print(Writer);
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
31
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NodeArray.cs
Normal file
31
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NodeArray.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class NodeArray : BaseNode
|
||||
{
|
||||
public List<BaseNode> Nodes { get; protected set; }
|
||||
|
||||
public NodeArray(List<BaseNode> Nodes) : base(NodeType.NodeArray)
|
||||
{
|
||||
this.Nodes = Nodes;
|
||||
}
|
||||
|
||||
public NodeArray(List<BaseNode> Nodes, NodeType Type) : base(Type)
|
||||
{
|
||||
this.Nodes = Nodes;
|
||||
}
|
||||
|
||||
public override bool IsArray()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write(string.Join<BaseNode>(", ", Nodes.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
16
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NoexceptSpec.cs
Normal file
16
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/NoexceptSpec.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class NoexceptSpec : ParentNode
|
||||
{
|
||||
public NoexceptSpec(BaseNode Child) : base(NodeType.NoexceptSpec, Child) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("noexcept(");
|
||||
Child.Print(Writer);
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class PackedTemplateParameter : NodeArray
|
||||
{
|
||||
public PackedTemplateParameter(List<BaseNode> Nodes) : base(Nodes, NodeType.PackedTemplateParameter) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
foreach (BaseNode Node in Nodes)
|
||||
{
|
||||
Node.PrintLeft(Writer);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
foreach (BaseNode Node in Nodes)
|
||||
{
|
||||
Node.PrintLeft(Writer);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
foreach (BaseNode Node in Nodes)
|
||||
{
|
||||
if (Node.HasRightPart())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class PackedTemplateParameterExpansion : ParentNode
|
||||
{
|
||||
public PackedTemplateParameterExpansion(BaseNode Child) : base(NodeType.PackedTemplateParameterExpansion, Child) {}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (Child is PackedTemplateParameter)
|
||||
{
|
||||
if (((PackedTemplateParameter)Child).Nodes.Count != 0)
|
||||
{
|
||||
Child.Print(Writer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Writer.Write("...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ParentNode.cs
Normal file
17
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ParentNode.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public abstract class ParentNode : BaseNode
|
||||
{
|
||||
public BaseNode Child { get; private set; }
|
||||
|
||||
public ParentNode(NodeType Type, BaseNode Child) : base(Type)
|
||||
{
|
||||
this.Child = Child;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
return Child.GetName();
|
||||
}
|
||||
}
|
||||
}
|
45
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/PointerType.cs
Normal file
45
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/PointerType.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class PointerType : BaseNode
|
||||
{
|
||||
private BaseNode Child;
|
||||
|
||||
public PointerType(BaseNode Child) : base(NodeType.PointerType)
|
||||
{
|
||||
this.Child = Child;
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
return Child.HasRightPart();
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Child.PrintLeft(Writer);
|
||||
if (Child.IsArray())
|
||||
{
|
||||
Writer.Write(" ");
|
||||
}
|
||||
|
||||
if (Child.IsArray() || Child.HasFunctions())
|
||||
{
|
||||
Writer.Write("(");
|
||||
}
|
||||
|
||||
Writer.Write("*");
|
||||
}
|
||||
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
if (Child.IsArray() || Child.HasFunctions())
|
||||
{
|
||||
Writer.Write(")");
|
||||
}
|
||||
|
||||
Child.PrintRight(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class PostfixExpression : ParentNode
|
||||
{
|
||||
private string Operator;
|
||||
|
||||
public PostfixExpression(BaseNode Type, string Operator) : base(NodeType.PostfixExpression, Type)
|
||||
{
|
||||
this.Operator = Operator;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("(");
|
||||
Child.Print(Writer);
|
||||
Writer.Write(")");
|
||||
Writer.Write(Operator);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class PostfixQualifiedType : ParentNode
|
||||
{
|
||||
private string PostfixQualifier;
|
||||
|
||||
public PostfixQualifiedType(string PostfixQualifier, BaseNode Type) : base(NodeType.PostfixQualifiedType, Type)
|
||||
{
|
||||
this.PostfixQualifier = PostfixQualifier;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Child.Print(Writer);
|
||||
Writer.Write(PostfixQualifier);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class PrefixExpression : ParentNode
|
||||
{
|
||||
private string Prefix;
|
||||
|
||||
public PrefixExpression(string Prefix, BaseNode Child) : base(NodeType.PrefixExpression, Child)
|
||||
{
|
||||
this.Prefix = Prefix;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write(Prefix);
|
||||
Writer.Write("(");
|
||||
Child.Print(Writer);
|
||||
Writer.Write(")");
|
||||
}
|
||||
}
|
||||
}
|
23
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/QualifiedName.cs
Normal file
23
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/QualifiedName.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class QualifiedName : BaseNode
|
||||
{
|
||||
private BaseNode Qualifier;
|
||||
private BaseNode Name;
|
||||
|
||||
public QualifiedName(BaseNode Qualifier, BaseNode Name) : base(NodeType.QualifiedName)
|
||||
{
|
||||
this.Qualifier = Qualifier;
|
||||
this.Name = Name;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Qualifier.Print(Writer);
|
||||
Writer.Write("::");
|
||||
Name.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
120
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/Qualifier.cs
Normal file
120
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/Qualifier.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public enum CV
|
||||
{
|
||||
None,
|
||||
Const,
|
||||
Volatile,
|
||||
Restricted = 4
|
||||
}
|
||||
|
||||
public enum Reference
|
||||
{
|
||||
None,
|
||||
RValue,
|
||||
LValue
|
||||
}
|
||||
|
||||
public class CVType : ParentNode
|
||||
{
|
||||
public CV Qualifier;
|
||||
|
||||
public CVType(CV Qualifier, BaseNode Child) : base(NodeType.CVQualifierType, Child)
|
||||
{
|
||||
this.Qualifier = Qualifier;
|
||||
}
|
||||
|
||||
public void PrintQualifier(TextWriter Writer)
|
||||
{
|
||||
if ((Qualifier & CV.Const) != 0)
|
||||
{
|
||||
Writer.Write(" const");
|
||||
}
|
||||
|
||||
if ((Qualifier & CV.Volatile) != 0)
|
||||
{
|
||||
Writer.Write(" volatile");
|
||||
}
|
||||
|
||||
if ((Qualifier & CV.Restricted) != 0)
|
||||
{
|
||||
Writer.Write(" restrict");
|
||||
}
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (Child != null)
|
||||
{
|
||||
Child.PrintLeft(Writer);
|
||||
}
|
||||
|
||||
PrintQualifier(Writer);
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
return Child != null && Child.HasRightPart();
|
||||
}
|
||||
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
if (Child != null)
|
||||
{
|
||||
Child.PrintRight(Writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleReferenceType : ParentNode
|
||||
{
|
||||
public Reference Qualifier;
|
||||
|
||||
public SimpleReferenceType(Reference Qualifier, BaseNode Child) : base(NodeType.SimpleReferenceType, Child)
|
||||
{
|
||||
this.Qualifier = Qualifier;
|
||||
}
|
||||
|
||||
public void PrintQualifier(TextWriter Writer)
|
||||
{
|
||||
if ((Qualifier & Reference.LValue) != 0)
|
||||
{
|
||||
Writer.Write("&");
|
||||
}
|
||||
|
||||
if ((Qualifier & Reference.RValue) != 0)
|
||||
{
|
||||
Writer.Write("&&");
|
||||
}
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (Child != null)
|
||||
{
|
||||
Child.PrintLeft(Writer);
|
||||
}
|
||||
else if (Qualifier != Reference.None)
|
||||
{
|
||||
Writer.Write(" ");
|
||||
}
|
||||
|
||||
PrintQualifier(Writer);
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
return Child != null && Child.HasRightPart();
|
||||
}
|
||||
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
if (Child != null)
|
||||
{
|
||||
Child.PrintRight(Writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ReferenceType.cs
Normal file
47
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ReferenceType.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ReferenceType : BaseNode
|
||||
{
|
||||
private string Reference;
|
||||
private BaseNode Child;
|
||||
|
||||
public ReferenceType(string Reference, BaseNode Child) : base(NodeType.ReferenceType)
|
||||
{
|
||||
this.Reference = Reference;
|
||||
this.Child = Child;
|
||||
}
|
||||
|
||||
public override bool HasRightPart()
|
||||
{
|
||||
return Child.HasRightPart();
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Child.PrintLeft(Writer);
|
||||
|
||||
if (Child.IsArray())
|
||||
{
|
||||
Writer.Write(" ");
|
||||
}
|
||||
|
||||
if (Child.IsArray() || Child.HasFunctions())
|
||||
{
|
||||
Writer.Write("(");
|
||||
}
|
||||
|
||||
Writer.Write(Reference);
|
||||
}
|
||||
public override void PrintRight(TextWriter Writer)
|
||||
{
|
||||
if (Child.IsArray() || Child.HasFunctions())
|
||||
{
|
||||
Writer.Write(")");
|
||||
}
|
||||
|
||||
Child.PrintRight(Writer);
|
||||
}
|
||||
}
|
||||
}
|
20
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/SpecialName.cs
Normal file
20
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/SpecialName.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class SpecialName : ParentNode
|
||||
{
|
||||
private string SpecialValue;
|
||||
|
||||
public SpecialName(string SpecialValue, BaseNode Type) : base(NodeType.SpecialName, Type)
|
||||
{
|
||||
this.SpecialValue = SpecialValue;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write(SpecialValue);
|
||||
Child.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class SpecialSubstitution : BaseNode
|
||||
{
|
||||
public enum SpecialType
|
||||
{
|
||||
Allocator,
|
||||
BasicString,
|
||||
String,
|
||||
IStream,
|
||||
OStream,
|
||||
IOStream,
|
||||
}
|
||||
|
||||
private SpecialType SpecialSubstitutionKey;
|
||||
|
||||
public SpecialSubstitution(SpecialType SpecialSubstitutionKey) : base(NodeType.SpecialSubstitution)
|
||||
{
|
||||
this.SpecialSubstitutionKey = SpecialSubstitutionKey;
|
||||
}
|
||||
|
||||
public void SetExtended()
|
||||
{
|
||||
Type = NodeType.ExpandedSpecialSubstitution;
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
switch (SpecialSubstitutionKey)
|
||||
{
|
||||
case SpecialType.Allocator:
|
||||
return "allocator";
|
||||
case SpecialType.BasicString:
|
||||
return "basic_string";
|
||||
case SpecialType.String:
|
||||
if (Type == NodeType.ExpandedSpecialSubstitution)
|
||||
{
|
||||
return "basic_string";
|
||||
}
|
||||
|
||||
return "string";
|
||||
case SpecialType.IStream:
|
||||
return "istream";
|
||||
case SpecialType.OStream:
|
||||
return "ostream";
|
||||
case SpecialType.IOStream:
|
||||
return "iostream";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetExtendedName()
|
||||
{
|
||||
switch (SpecialSubstitutionKey)
|
||||
{
|
||||
case SpecialType.Allocator:
|
||||
return "std::allocator";
|
||||
case SpecialType.BasicString:
|
||||
return "std::basic_string";
|
||||
case SpecialType.String:
|
||||
return "std::basic_string<char, std::char_traits<char>, std::allocator<char> >";
|
||||
case SpecialType.IStream:
|
||||
return "std::basic_istream<char, std::char_traits<char> >";
|
||||
case SpecialType.OStream:
|
||||
return "std::basic_ostream<char, std::char_traits<char> >";
|
||||
case SpecialType.IOStream:
|
||||
return "std::basic_iostream<char, std::char_traits<char> >";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
if (Type == NodeType.ExpandedSpecialSubstitution)
|
||||
{
|
||||
Writer.Write(GetExtendedName());
|
||||
}
|
||||
else
|
||||
{
|
||||
Writer.Write("std::");
|
||||
Writer.Write(GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class StdQualifiedName : ParentNode
|
||||
{
|
||||
public StdQualifiedName(BaseNode Child) : base(NodeType.StdQualifiedName, Child) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("std::");
|
||||
Child.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class TemplateArguments : NodeArray
|
||||
{
|
||||
public TemplateArguments(List<BaseNode> Nodes) : base(Nodes, NodeType.TemplateArguments) { }
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
string Params = string.Join<BaseNode>(", ", Nodes.ToArray());
|
||||
|
||||
Writer.Write("<");
|
||||
|
||||
Writer.Write(Params);
|
||||
|
||||
if (Params.EndsWith(">"))
|
||||
{
|
||||
Writer.Write(" ");
|
||||
}
|
||||
|
||||
Writer.Write(">");
|
||||
}
|
||||
}
|
||||
}
|
20
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ThrowExpression.cs
Normal file
20
Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/ThrowExpression.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
||||
{
|
||||
public class ThrowExpression : BaseNode
|
||||
{
|
||||
private BaseNode Expression;
|
||||
|
||||
public ThrowExpression(BaseNode Expression) : base(NodeType.ThrowExpression)
|
||||
{
|
||||
this.Expression = Expression;
|
||||
}
|
||||
|
||||
public override void PrintLeft(TextWriter Writer)
|
||||
{
|
||||
Writer.Write("throw ");
|
||||
Expression.Print(Writer);
|
||||
}
|
||||
}
|
||||
}
|
3367
Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs
Normal file
3367
Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user