aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/Qualifier.cs
blob: 3721b8dee3a784c3bee5a2f4a7e9456c9f29dfae (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
114
115
116
117
118
119
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);
            }
        }
    }
}