-
Notifications
You must be signed in to change notification settings - Fork 10
/
DITypeVoid.cs
37 lines (33 loc) · 1.59 KB
/
DITypeVoid.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 file="DITypeVoid.cs" company="Ubiquity.NET Contributors">
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
using System;
namespace Ubiquity.NET.Llvm.DebugInfo
{
/// <summary>Special Debug type to represent void</summary>
/// <remarks>
/// This doesn't have a corresponding node type in LLVM as the actual IR
/// representation is <see langword="null"/>. However, allowing null to
/// represent the "void" type complicates the API surface with respect to
/// nullability and correctness checks. Therefore, this type is the "null
/// object pattern" implementation for the debug type system to indicate
/// the void type.
/// </remarks>
public class DITypeVoid
: DIType
{
/// <summary>Gets the singleton DITypeVoid instance</summary>
public static DITypeVoid Instance => LazyInstance.Value;
private DITypeVoid( )
: base( default )
{
// LlvmMetadata.FromHandle<T>, internally knows about this null object pattern
// and when T is DIType and handle == default will get the singleton instance of
// this class. Since default(LLVMMetadaRef) isn't sufficiently distinct to use
// for caching a singleton is required to ensure reference equality "just works".
}
private static readonly Lazy<DITypeVoid> LazyInstance = new Lazy<DITypeVoid>(()=>new DITypeVoid());
}
}