aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Ast/BracedExpression.cs
blob: 53fbb2040dc36eef58de1362e70530d84e3e7412 (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
using System.IO;

namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
{
    public class BracedExpression : BaseNode
    {
        private readonly BaseNode _element;
        private readonly BaseNode _expression;
        private readonly bool _isArrayExpression;

        public BracedExpression(BaseNode element, BaseNode expression, bool isArrayExpression) : base(NodeType.BracedExpression)
        {
            _element = element;
            _expression = expression;
            _isArrayExpression = isArrayExpression;
        }

        public override void PrintLeft(TextWriter writer)
        {
            if (_isArrayExpression)
            {
                writer.Write("[");
                _element.Print(writer);
                writer.Write("]");
            }
            else
            {
                writer.Write(".");
                _element.Print(writer);
            }

            if (!_expression.GetType().Equals(NodeType.BracedExpression) || !_expression.GetType().Equals(NodeType.BracedRangeExpression))
            {
                writer.Write(" = ");
            }

            _expression.Print(writer);
        }
    }
}