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