2018-09-15 15:29:18 +02:00
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
|
|
|
{
|
|
|
|
public enum NodeType
|
|
|
|
{
|
2018-12-06 12:16:24 +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-06 12:16:24 +01:00
|
|
|
public BaseNode(NodeType type)
|
2018-09-15 15:29:18 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
Type = type;
|
2018-09-15 15:29:18 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
public virtual void Print(TextWriter writer)
|
2018-09-15 15:29:18 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
PrintLeft(writer);
|
2018-09-15 15:29:18 +02:00
|
|
|
|
|
|
|
if (HasRightPart())
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
PrintRight(writer);
|
2018-09-15 15:29:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +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-06 12:16:24 +01:00
|
|
|
public virtual void PrintRight(TextWriter writer) {}
|
2018-09-15 15:29:18 +02:00
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
StringWriter writer = new StringWriter();
|
2018-09-15 15:29:18 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
Print(writer);
|
2018-09-15 15:29:18 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
return writer.ToString();
|
2018-09-15 15:29:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|