-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathCppQualifiedType.cs
41 lines (37 loc) · 1.41 KB
/
CppQualifiedType.cs
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
// Copyright (c) Alexandre Mutel. All rights reserved.
// Licensed under the BSD-Clause 2 license.
// See license.txt file in the project root for full license information.
namespace CppAst
{
/// <summary>
/// A C++ qualified type (e.g `const int`)
/// </summary>
public sealed class CppQualifiedType : CppTypeWithElementType
{
/// <summary>
/// Constructor for a C++ qualified type.
/// </summary>
/// <param name="qualifier">The C++ qualified (e.g `const`)</param>
/// <param name="elementType">The element type (e.g `int`)</param>
public CppQualifiedType(CppTypeQualifier qualifier, CppType elementType) : base(CppTypeKind.Qualified, elementType)
{
Qualifier = qualifier;
SizeOf = elementType.SizeOf;
}
/// <summary>
/// Gets the qualifier
/// </summary>
public CppTypeQualifier Qualifier { get; }
/// <inheritdoc />
public override CppType GetCanonicalType()
{
var elementTypeCanonical = ElementType.GetCanonicalType();
return ReferenceEquals(elementTypeCanonical, ElementType) ? this : new CppQualifiedType(Qualifier, elementTypeCanonical);
}
/// <inheritdoc />
public override string ToString()
{
return $"{ElementType.GetDisplayName()} {Qualifier.ToString().ToLowerInvariant()}";
}
}
}