-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b41cf8f
commit 290052d
Showing
38 changed files
with
734 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Silk.NET.SilkTouch.Symbols; | ||
|
||
/// <summary> | ||
/// The Id of a <see cref="TypeSymbol"/> | ||
/// </summary> | ||
public readonly struct TypeId : IEquatable<TypeId> | ||
{ | ||
private readonly Guid _guid; | ||
private TypeId(Guid guid) | ||
{ | ||
_guid = guid; | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new, unique, instance | ||
/// </summary> | ||
/// <returns>The new instance</returns> | ||
public static TypeId CreateNew() => new TypeId(Guid.NewGuid()); | ||
|
||
/// <inheritdoc /> | ||
public bool Equals(TypeId other) => _guid.Equals(other._guid); | ||
|
||
/// <inheritdoc /> | ||
public override bool Equals(object? obj) => obj is TypeId other && Equals(other); | ||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() => _guid.GetHashCode(); | ||
|
||
/// <inheritdoc /> | ||
public static bool operator ==(TypeId left, TypeId right) => left.Equals(right); | ||
|
||
/// <inheritdoc /> | ||
public static bool operator !=(TypeId left, TypeId right) => !left.Equals(right); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Concurrent; | ||
|
||
namespace Silk.NET.SilkTouch.Symbols; | ||
|
||
/// <summary> | ||
/// A simple type store to store and reference <see cref="TypeSymbol"/>s by Id | ||
/// </summary> | ||
public sealed class TypeStore | ||
{ | ||
private ConcurrentDictionary<TypeId, TypeSymbol> _dictionary = new(); | ||
|
||
/// <summary> | ||
/// Stores the given <see cref="TypeSymbol"/> for later resolution | ||
/// </summary> | ||
/// <param name="typeSymbol">The <see cref="TypeSymbol"/> to store</param> | ||
public void Store(TypeSymbol typeSymbol) | ||
{ | ||
_dictionary[typeSymbol.Id] = typeSymbol; | ||
} | ||
|
||
/// <summary> | ||
/// Resolves a <see cref="TypeSymbol"/> by it's <see cref="TypeSymbol.Id"/> | ||
/// </summary> | ||
/// <param name="id">The Id to use for resolution</param> | ||
/// <param name="typeSymbol">The <see cref="TypeSymbol"/> found or null</param> | ||
/// <returns>Whether a type could be resolved</returns> | ||
public bool TryResolve(TypeId id, out TypeSymbol? typeSymbol) | ||
{ | ||
return _dictionary.TryGetValue(id, out typeSymbol); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.