2018-09-15 15:29:18 +02:00
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
|
|
|
{
|
|
|
|
public enum NodeType
|
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
CVQualifierType,
|
2018-09-15 15:29:18 +02:00
|
|
|
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; }
|
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
public BaseNode(NodeType Type)
|
2018-09-15 15:29:18 +02:00
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
this.Type = Type;
|
2018-09-15 15:29:18 +02:00
|
|
|
}
|
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
public virtual void Print(TextWriter Writer)
|
2018-09-15 15:29:18 +02:00
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
PrintLeft(Writer);
|
2018-09-15 15:29:18 +02:00
|
|
|
|
|
|
|
if (HasRightPart())
|
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
PrintRight(Writer);
|
2018-09-15 15:29:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
public abstract void PrintLeft(TextWriter Writer);
|
2018-09-15 15:29:18 +02:00
|
|
|
|
|
|
|
public virtual bool HasRightPart()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual bool IsArray()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual bool HasFunctions()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual string GetName()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
public virtual void PrintRight(TextWriter Writer) {}
|
2018-09-15 15:29:18 +02:00
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2018-12-05 01:52:39 +01:00
|
|
|
StringWriter Writer = new StringWriter();
|
2018-09-15 15:29:18 +02:00
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
Print(Writer);
|
2018-09-15 15:29:18 +02:00
|
|
|
|
2018-12-05 01:52:39 +01:00
|
|
|
return Writer.ToString();
|
2018-09-15 15:29:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|