aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/BaseNode.cs
blob: fc60fb6e9a52d3fa2ff4b235165f3ce2a2286fc7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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)
        {
            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();

            Print(writer);

            return writer.ToString();
        }
    }
}