forked from xoofx/CppAst.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCppPointerType.cs
37 lines (33 loc) · 1.11 KB
/
CppPointerType.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
// 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.
using System;
namespace CppAst
{
/// <summary>
/// A C++ pointer type (e.g `int*`)
/// </summary>
public sealed class CppPointerType : CppTypeWithElementType
{
/// <summary>
/// Constructor of a pointer type.
/// </summary>
/// <param name="elementType">The element type pointed to.</param>
public CppPointerType(CppType elementType) : base(CppTypeKind.Pointer, elementType)
{
SizeOf = IntPtr.Size;
}
/// <inheritdoc />
public override string ToString()
{
return $"{ElementType.GetDisplayName()} *";
}
/// <inheritdoc />
public override CppType GetCanonicalType()
{
var elementTypeCanonical = ElementType.GetCanonicalType();
if (ReferenceEquals(elementTypeCanonical, ElementType)) return this;
return new CppPointerType(elementTypeCanonical);
}
}
}