diff --git a/src/Draco.Compiler.Tests/EndToEnd/EndToEndTestsBase.cs b/src/Draco.Compiler.Tests/EndToEnd/EndToEndTestsBase.cs index e0031af55..d90f56598 100644 --- a/src/Draco.Compiler.Tests/EndToEnd/EndToEndTestsBase.cs +++ b/src/Draco.Compiler.Tests/EndToEnd/EndToEndTestsBase.cs @@ -80,7 +80,7 @@ protected static TResult Invoke( string methodName, TextReader? stdin = null, TextWriter? stdout = null, - string moduleName = CompilerConstants.DefaultModuleName, + string moduleName = Constants.DefaultModuleName, params object[] args) { Console.SetIn(stdin ?? Console.In); @@ -106,7 +106,7 @@ protected static TResult Invoke(Assembly assembly, string moduleName, s protected static TResult Invoke(Assembly assembly, string methodName, params object[] args) => Invoke( assembly: assembly, - moduleName: CompilerConstants.DefaultModuleName, + moduleName: Constants.DefaultModuleName, methodName: methodName, stdin: null, stdout: null, diff --git a/src/Draco.Compiler.Tests/Semantics/IntegralDomainTests.cs b/src/Draco.Compiler.Tests/Semantics/IntegralDomainTests.cs index fd35fc76c..b16659111 100644 --- a/src/Draco.Compiler.Tests/Semantics/IntegralDomainTests.cs +++ b/src/Draco.Compiler.Tests/Semantics/IntegralDomainTests.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Draco.Compiler.Internal.FlowAnalysis.Domain; using static Draco.Compiler.Internal.BoundTree.BoundTreeFactory; diff --git a/src/Draco.Compiler/Api/Compilation.cs b/src/Draco.Compiler/Api/Compilation.cs index 5473df3fd..44b73ef24 100644 --- a/src/Draco.Compiler/Api/Compilation.cs +++ b/src/Draco.Compiler/Api/Compilation.cs @@ -16,6 +16,7 @@ using Draco.Compiler.Internal.Symbols.Metadata; using Draco.Compiler.Internal.Symbols.Source; using Draco.Compiler.Internal.Symbols.Synthetized; +using Draco.Compiler.Internal.Utilities; using ModuleSymbol = Draco.Compiler.Internal.Symbols.ModuleSymbol; namespace Draco.Compiler.Api; diff --git a/src/Draco.Compiler/Api/Semantics/SemanticModel.cs b/src/Draco.Compiler/Api/Semantics/SemanticModel.cs index 0da233078..2188b43c0 100644 --- a/src/Draco.Compiler/Api/Semantics/SemanticModel.cs +++ b/src/Draco.Compiler/Api/Semantics/SemanticModel.cs @@ -6,12 +6,12 @@ using System.Linq; using Draco.Compiler.Api.Diagnostics; using Draco.Compiler.Api.Syntax; -using Draco.Compiler.Internal; using Draco.Compiler.Internal.Binding; using Draco.Compiler.Internal.BoundTree; using Draco.Compiler.Internal.Diagnostics; using Draco.Compiler.Internal.Symbols; using Draco.Compiler.Internal.Symbols.Source; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Api.Semantics; diff --git a/src/Draco.Compiler/Api/Syntax/SeparatedSyntaxList.cs b/src/Draco.Compiler/Api/Syntax/SeparatedSyntaxList.cs index e83def4a9..1492a49bc 100644 --- a/src/Draco.Compiler/Api/Syntax/SeparatedSyntaxList.cs +++ b/src/Draco.Compiler/Api/Syntax/SeparatedSyntaxList.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using Draco.Compiler.Internal; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Api.Syntax; diff --git a/src/Draco.Compiler/Api/Syntax/SyntaxList.cs b/src/Draco.Compiler/Api/Syntax/SyntaxList.cs index 896f9fc92..2dc581459 100644 --- a/src/Draco.Compiler/Api/Syntax/SyntaxList.cs +++ b/src/Draco.Compiler/Api/Syntax/SyntaxList.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using Draco.Compiler.Internal; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Api.Syntax; diff --git a/src/Draco.Compiler/Api/Syntax/SyntaxNode.cs b/src/Draco.Compiler/Api/Syntax/SyntaxNode.cs index a329b6524..ee4618faf 100644 --- a/src/Draco.Compiler/Api/Syntax/SyntaxNode.cs +++ b/src/Draco.Compiler/Api/Syntax/SyntaxNode.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Runtime.CompilerServices; using Draco.Compiler.Api.Diagnostics; -using Draco.Compiler.Internal; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Api.Syntax; diff --git a/src/Draco.Compiler/Api/Syntax/SyntaxTree.cs b/src/Draco.Compiler/Api/Syntax/SyntaxTree.cs index 47a70303c..309d76a42 100644 --- a/src/Draco.Compiler/Api/Syntax/SyntaxTree.cs +++ b/src/Draco.Compiler/Api/Syntax/SyntaxTree.cs @@ -3,9 +3,9 @@ using System.Collections.Immutable; using System.Linq; using Draco.Compiler.Api.Diagnostics; -using Draco.Compiler.Internal; using Draco.Compiler.Internal.Syntax; using Draco.Compiler.Internal.Syntax.Rewriting; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Api.Syntax; diff --git a/src/Draco.Compiler/Internal/Binding/ImportBinder.cs b/src/Draco.Compiler/Internal/Binding/ImportBinder.cs index 3943881f4..a4951a055 100644 --- a/src/Draco.Compiler/Internal/Binding/ImportBinder.cs +++ b/src/Draco.Compiler/Internal/Binding/ImportBinder.cs @@ -8,6 +8,7 @@ using Draco.Compiler.Internal.Diagnostics; using Draco.Compiler.Internal.Symbols; using Draco.Compiler.Internal.Symbols.Error; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Binding; diff --git a/src/Draco.Compiler/Internal/Codegen/MetadataCodegen.cs b/src/Draco.Compiler/Internal/Codegen/MetadataCodegen.cs index e66baa29c..73404f171 100644 --- a/src/Draco.Compiler/Internal/Codegen/MetadataCodegen.cs +++ b/src/Draco.Compiler/Internal/Codegen/MetadataCodegen.cs @@ -155,7 +155,7 @@ public TypeReferenceHandle GetModuleReferenceHandle(IModule module) // We take its parent module : this.GetModuleReferenceHandle(module.Parent); var name = string.IsNullOrEmpty(module.Name) - ? CompilerConstants.DefaultModuleName + ? Constants.DefaultModuleName : module.Name; handle = this.GetOrAddTypeReference( parent: resolutionScope, @@ -443,7 +443,7 @@ private void EncodeModule(IModule module, TypeDefinitionHandle? parentModule = n } var attributes = visibility | TypeAttributes.Class | TypeAttributes.AutoLayout | TypeAttributes.BeforeFieldInit | TypeAttributes.Abstract | TypeAttributes.Sealed; - var name = string.IsNullOrEmpty(module.Name) ? CompilerConstants.DefaultModuleName : module.Name; + var name = string.IsNullOrEmpty(module.Name) ? Constants.DefaultModuleName : module.Name; // Create the type var createdModule = this.AddTypeDefinition( diff --git a/src/Draco.Compiler/Internal/CompilerConstants.cs b/src/Draco.Compiler/Internal/Constants.cs similarity index 89% rename from src/Draco.Compiler/Internal/CompilerConstants.cs rename to src/Draco.Compiler/Internal/Constants.cs index f265184b3..28c7667f0 100644 --- a/src/Draco.Compiler/Internal/CompilerConstants.cs +++ b/src/Draco.Compiler/Internal/Constants.cs @@ -1,6 +1,6 @@ namespace Draco.Compiler.Internal; -internal static class CompilerConstants +internal static class Constants { /// /// The default name of the root module in IL. diff --git a/src/Draco.Compiler/Internal/Declarations/MergedModuleDeclaration.cs b/src/Draco.Compiler/Internal/Declarations/MergedModuleDeclaration.cs index 71dacaa52..a3d269dd6 100644 --- a/src/Draco.Compiler/Internal/Declarations/MergedModuleDeclaration.cs +++ b/src/Draco.Compiler/Internal/Declarations/MergedModuleDeclaration.cs @@ -2,6 +2,7 @@ using System.Collections.Immutable; using System.Linq; using Draco.Compiler.Api.Syntax; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Declarations; diff --git a/src/Draco.Compiler/Internal/Declarations/SingleModuleDeclaration.cs b/src/Draco.Compiler/Internal/Declarations/SingleModuleDeclaration.cs index 57bc68146..7fdcca238 100644 --- a/src/Draco.Compiler/Internal/Declarations/SingleModuleDeclaration.cs +++ b/src/Draco.Compiler/Internal/Declarations/SingleModuleDeclaration.cs @@ -3,6 +3,7 @@ using System.Collections.Immutable; using System.Linq; using Draco.Compiler.Api.Syntax; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Declarations; diff --git a/src/Draco.Compiler/Internal/OptimizingIr/AssemblyCodegen.cs b/src/Draco.Compiler/Internal/OptimizingIr/AssemblyCodegen.cs index 01c083690..a2743dcb8 100644 --- a/src/Draco.Compiler/Internal/OptimizingIr/AssemblyCodegen.cs +++ b/src/Draco.Compiler/Internal/OptimizingIr/AssemblyCodegen.cs @@ -40,7 +40,7 @@ private void Complete() { // Set the entry point, in case we have one var mainProcedure = (Procedure?)this.assembly.RootModule.Procedures.Values - .FirstOrDefault(p => p.Name == CompilerConstants.EntryPointName); + .FirstOrDefault(p => p.Name == Constants.EntryPointName); this.assembly.EntryPoint = mainProcedure; } } diff --git a/src/Draco.Compiler/Internal/Symbols/FunctionSymbol.cs b/src/Draco.Compiler/Internal/Symbols/FunctionSymbol.cs index a44f93ab2..76f4740f6 100644 --- a/src/Draco.Compiler/Internal/Symbols/FunctionSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/FunctionSymbol.cs @@ -3,6 +3,7 @@ using System.Text; using Draco.Compiler.Api.Syntax; using Draco.Compiler.Internal.Symbols.Generic; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols; @@ -89,8 +90,7 @@ public override Api.Semantics.Visibility Visibility { get { - var syntax = this.DeclaringSyntax as FunctionDeclarationSyntax; - if (syntax is null) return Api.Semantics.Visibility.Internal; // Default + if (this.DeclaringSyntax is not FunctionDeclarationSyntax syntax) return Api.Semantics.Visibility.Internal; // Default return GetVisibilityFromTokenKind(syntax.VisibilityModifier?.Kind); } } diff --git a/src/Draco.Compiler/Internal/Symbols/Generic/FieldInstanceSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Generic/FieldInstanceSymbol.cs index 93e50e28c..492f771ad 100644 --- a/src/Draco.Compiler/Internal/Symbols/Generic/FieldInstanceSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Generic/FieldInstanceSymbol.cs @@ -1,3 +1,5 @@ +using Draco.Compiler.Internal.Utilities; + namespace Draco.Compiler.Internal.Symbols.Generic; /// diff --git a/src/Draco.Compiler/Internal/Symbols/Generic/FunctionInstanceSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Generic/FunctionInstanceSymbol.cs index f82022991..32b05fd90 100644 --- a/src/Draco.Compiler/Internal/Symbols/Generic/FunctionInstanceSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Generic/FunctionInstanceSymbol.cs @@ -1,6 +1,7 @@ using System.Collections.Immutable; using System.Linq; using System.Text; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Generic; diff --git a/src/Draco.Compiler/Internal/Symbols/Generic/ParameterInstanceSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Generic/ParameterInstanceSymbol.cs index f1e425b33..59758e9cf 100644 --- a/src/Draco.Compiler/Internal/Symbols/Generic/ParameterInstanceSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Generic/ParameterInstanceSymbol.cs @@ -1,3 +1,5 @@ +using Draco.Compiler.Internal.Utilities; + namespace Draco.Compiler.Internal.Symbols.Generic; /// diff --git a/src/Draco.Compiler/Internal/Symbols/Generic/PropertyInstanceSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Generic/PropertyInstanceSymbol.cs index f6b1fd049..4b52e0e8c 100644 --- a/src/Draco.Compiler/Internal/Symbols/Generic/PropertyInstanceSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Generic/PropertyInstanceSymbol.cs @@ -1,3 +1,5 @@ +using Draco.Compiler.Internal.Utilities; + namespace Draco.Compiler.Internal.Symbols.Generic; /// diff --git a/src/Draco.Compiler/Internal/Symbols/Generic/TypeInstanceSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Generic/TypeInstanceSymbol.cs index 8f3cdecda..7384b08d6 100644 --- a/src/Draco.Compiler/Internal/Symbols/Generic/TypeInstanceSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Generic/TypeInstanceSymbol.cs @@ -2,6 +2,7 @@ using System.Collections.Immutable; using System.Linq; using System.Text; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Generic; diff --git a/src/Draco.Compiler/Internal/Symbols/MergedModuleSymbol.cs b/src/Draco.Compiler/Internal/Symbols/MergedModuleSymbol.cs index 848dfc3bf..310337e47 100644 --- a/src/Draco.Compiler/Internal/Symbols/MergedModuleSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/MergedModuleSymbol.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols; diff --git a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataAssemblySymbol.cs b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataAssemblySymbol.cs index 705d1adde..bf18625db 100644 --- a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataAssemblySymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataAssemblySymbol.cs @@ -3,6 +3,7 @@ using System.Reflection; using System.Reflection.Metadata; using Draco.Compiler.Api; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Metadata; diff --git a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataFieldSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataFieldSymbol.cs index 4c6e1aaca..dba5cd6da 100644 --- a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataFieldSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataFieldSymbol.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Metadata; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Metadata; diff --git a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataMethodSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataMethodSymbol.cs index 81ed250ec..36d266024 100644 --- a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataMethodSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataMethodSymbol.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Reflection.Metadata; using System.Threading; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Metadata; diff --git a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataNamespaceSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataNamespaceSymbol.cs index b22a350df..0a5424327 100644 --- a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataNamespaceSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataNamespaceSymbol.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Metadata; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Metadata; diff --git a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataPropertySymbol.cs b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataPropertySymbol.cs index 90b5d2848..f67180b13 100644 --- a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataPropertySymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataPropertySymbol.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Reflection.Metadata; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Metadata; @@ -93,9 +94,7 @@ private void BuildOverride() private PropertySymbol? GetExplicitOverride() { - var accessor = this.Getter ?? this.Setter; - if (accessor is null) throw new InvalidOperationException(); - + var accessor = this.Getter ?? this.Setter ?? throw new InvalidOperationException(); if (accessor.Override is not null) return (accessor.Override as IPropertyAccessorSymbol)?.Property; return null; } diff --git a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataStaticClassSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataStaticClassSymbol.cs index 8160ba72c..2d2c73b6e 100644 --- a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataStaticClassSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataStaticClassSymbol.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Metadata; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Metadata; diff --git a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataTypeSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataTypeSymbol.cs index fef1c243c..e5f5108ff 100644 --- a/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataTypeSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Metadata/MetadataTypeSymbol.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Metadata; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Metadata; diff --git a/src/Draco.Compiler/Internal/Symbols/Source/SourceFunctionSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Source/SourceFunctionSymbol.cs index 6007e33c8..219bf1b3e 100644 --- a/src/Draco.Compiler/Internal/Symbols/Source/SourceFunctionSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Source/SourceFunctionSymbol.cs @@ -8,6 +8,7 @@ using Draco.Compiler.Internal.Diagnostics; using Draco.Compiler.Internal.FlowAnalysis; using Draco.Compiler.Internal.Symbols.Synthetized; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Source; diff --git a/src/Draco.Compiler/Internal/Symbols/Source/SourceModuleSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Source/SourceModuleSymbol.cs index e1d2e34bd..11839f803 100644 --- a/src/Draco.Compiler/Internal/Symbols/Source/SourceModuleSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Source/SourceModuleSymbol.cs @@ -8,6 +8,7 @@ using Draco.Compiler.Api.Syntax; using Draco.Compiler.Internal.Binding; using Draco.Compiler.Internal.Declarations; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Source; diff --git a/src/Draco.Compiler/Internal/Symbols/Source/SourceParameterSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Source/SourceParameterSymbol.cs index a4cabdd0f..6e6956f98 100644 --- a/src/Draco.Compiler/Internal/Symbols/Source/SourceParameterSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Source/SourceParameterSymbol.cs @@ -1,6 +1,7 @@ using Draco.Compiler.Api.Diagnostics; using Draco.Compiler.Api.Syntax; using Draco.Compiler.Internal.Binding; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Source; diff --git a/src/Draco.Compiler/Internal/Symbols/Synthetized/ArrayConstructorSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Synthetized/ArrayConstructorSymbol.cs index 94085e817..819cdb964 100644 --- a/src/Draco.Compiler/Internal/Symbols/Synthetized/ArrayConstructorSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Synthetized/ArrayConstructorSymbol.cs @@ -1,6 +1,7 @@ using System.Collections.Immutable; using System.Linq; using Draco.Compiler.Internal.BoundTree; +using Draco.Compiler.Internal.Utilities; using static Draco.Compiler.Internal.BoundTree.BoundTreeFactory; namespace Draco.Compiler.Internal.Symbols.Synthetized; diff --git a/src/Draco.Compiler/Internal/Symbols/Synthetized/ArrayIndexPropertySymbol.cs b/src/Draco.Compiler/Internal/Symbols/Synthetized/ArrayIndexPropertySymbol.cs index c71606bb8..7257c2a4c 100644 --- a/src/Draco.Compiler/Internal/Symbols/Synthetized/ArrayIndexPropertySymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Synthetized/ArrayIndexPropertySymbol.cs @@ -1,5 +1,6 @@ using System.Collections.Immutable; using System.Linq; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols.Synthetized; diff --git a/src/Draco.Compiler/Internal/Symbols/Synthetized/IntrinsicSymbols.cs b/src/Draco.Compiler/Internal/Symbols/Synthetized/IntrinsicSymbols.cs index 2a0b79591..5e0c8b9b1 100644 --- a/src/Draco.Compiler/Internal/Symbols/Synthetized/IntrinsicSymbols.cs +++ b/src/Draco.Compiler/Internal/Symbols/Synthetized/IntrinsicSymbols.cs @@ -7,6 +7,7 @@ using Draco.Compiler.Internal.OptimizingIr; using Draco.Compiler.Internal.OptimizingIr.Model; using Draco.Compiler.Internal.Symbols.Error; +using Draco.Compiler.Internal.Utilities; using static Draco.Compiler.Internal.OptimizingIr.InstructionFactory; namespace Draco.Compiler.Internal.Symbols.Synthetized; diff --git a/src/Draco.Compiler/Internal/Symbols/Synthetized/SynthetizedMetadataConstructorSymbol.cs b/src/Draco.Compiler/Internal/Symbols/Synthetized/SynthetizedMetadataConstructorSymbol.cs index 9407c6913..1df4ed65b 100644 --- a/src/Draco.Compiler/Internal/Symbols/Synthetized/SynthetizedMetadataConstructorSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/Synthetized/SynthetizedMetadataConstructorSymbol.cs @@ -5,6 +5,7 @@ using Draco.Compiler.Internal.BoundTree; using Draco.Compiler.Internal.Symbols.Generic; using Draco.Compiler.Internal.Symbols.Metadata; +using Draco.Compiler.Internal.Utilities; using static Draco.Compiler.Internal.BoundTree.BoundTreeFactory; namespace Draco.Compiler.Internal.Symbols.Synthetized; diff --git a/src/Draco.Compiler/Internal/Symbols/TypeSymbol.cs b/src/Draco.Compiler/Internal/Symbols/TypeSymbol.cs index d88b30827..41fc616de 100644 --- a/src/Draco.Compiler/Internal/Symbols/TypeSymbol.cs +++ b/src/Draco.Compiler/Internal/Symbols/TypeSymbol.cs @@ -2,6 +2,7 @@ using System.Collections.Immutable; using System.Linq; using Draco.Compiler.Internal.Symbols.Generic; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols; @@ -73,7 +74,7 @@ public IEnumerable BaseTypes public override bool CanBeShadowedBy(Symbol other) { - if (other is not TypeSymbol type) return false; + if (other is not TypeSymbol) return false; if (this.Name != other.Name) return false; return this.GenericParameters.Length == other.GenericParameters.Length; } diff --git a/src/Draco.Compiler/Internal/Symbols/WellKnownTypes.cs b/src/Draco.Compiler/Internal/Symbols/WellKnownTypes.cs index eaabd9750..21c21678d 100644 --- a/src/Draco.Compiler/Internal/Symbols/WellKnownTypes.cs +++ b/src/Draco.Compiler/Internal/Symbols/WellKnownTypes.cs @@ -5,6 +5,7 @@ using Draco.Compiler.Internal.Symbols.Generic; using Draco.Compiler.Internal.Symbols.Metadata; using Draco.Compiler.Internal.Symbols.Synthetized; +using Draco.Compiler.Internal.Utilities; namespace Draco.Compiler.Internal.Symbols; diff --git a/src/Draco.Compiler/Internal/InterlockedUtils.cs b/src/Draco.Compiler/Internal/Utilities/InterlockedUtils.cs similarity index 95% rename from src/Draco.Compiler/Internal/InterlockedUtils.cs rename to src/Draco.Compiler/Internal/Utilities/InterlockedUtils.cs index 3a664d974..fecfb2f54 100644 --- a/src/Draco.Compiler/Internal/InterlockedUtils.cs +++ b/src/Draco.Compiler/Internal/Utilities/InterlockedUtils.cs @@ -2,7 +2,7 @@ using System.Collections.Immutable; using System.Threading; -namespace Draco.Compiler.Internal; +namespace Draco.Compiler.Internal.Utilities; /// /// Utility functions for atomic operations. diff --git a/src/Draco.SourceGeneration/Templates/RedSyntaxTree.sbncs b/src/Draco.SourceGeneration/Templates/RedSyntaxTree.sbncs index b1c18ab6a..0e28a211e 100644 --- a/src/Draco.SourceGeneration/Templates/RedSyntaxTree.sbncs +++ b/src/Draco.SourceGeneration/Templates/RedSyntaxTree.sbncs @@ -25,9 +25,9 @@ namespace Draco.Compiler.Api.Syntax; {{else}} {{field_prefix($field)}} => {{if $field.IsNullable}} - Internal.InterlockedUtils.InitializeMaybeNull( + Internal.Utilities.InterlockedUtils.InitializeMaybeNull( {{else}} - Internal.InterlockedUtils.InitializeNull( + Internal.Utilities.InterlockedUtils.InitializeNull( {{end}} ref this.{{$backingField}}, () => ({{$field.Type}})this.Green.{{$field.Name}}{{nullable($field)}}.ToRedNode(this.Tree, this, {{$fieldFullPosition}})); diff --git a/src/Draco.SourceGeneration/Templates/WellKnownTypes.sbncs b/src/Draco.SourceGeneration/Templates/WellKnownTypes.sbncs index 0365cee6f..3311931a8 100644 --- a/src/Draco.SourceGeneration/Templates/WellKnownTypes.sbncs +++ b/src/Draco.SourceGeneration/Templates/WellKnownTypes.sbncs @@ -24,7 +24,7 @@ internal sealed partial class WellKnownTypes {{for $b in $assembly.PublicKeyToken}}{{$b}}, {{end}} }; - public MetadataAssemblySymbol {{$prop_name}} => InterlockedUtils.InitializeNull( + public MetadataAssemblySymbol {{$prop_name}} => Internal.Utilities.InterlockedUtils.InitializeNull( ref this.{{$field_name}}, () => this.GetAssemblyWithNameAndToken("{{$assembly.Name}}", {{$prop_name}}_PublicKeyToken)); private MetadataAssemblySymbol? {{$field_name}}; @@ -35,7 +35,7 @@ internal sealed partial class WellKnownTypes {{$field_name = camel_case($prop_name)}} {{$path = string.split($type.Name, '.')}} - public MetadataTypeSymbol {{$prop_name}} => InterlockedUtils.InitializeNull( + public MetadataTypeSymbol {{$prop_name}} => Internal.Utilities.InterlockedUtils.InitializeNull( ref this.{{$field_name}}, () => this.GetTypeFromAssembly( {{nameify($type.Assembly.Name)}}, @@ -58,7 +58,7 @@ internal sealed partial class IntrinsicSymbols {{$prop_name = capitalize($intrinsic.Name)}} {{$field_name = camel_case($prop_name)}} - public TypeSymbol {{$prop_name}} => InterlockedUtils.InitializeNull( + public TypeSymbol {{$prop_name}} => Internal.Utilities.InterlockedUtils.InitializeNull( ref this.{{$field_name}}, () => new MetadataBackedPrimitiveTypeSymbol( name: "{{$intrinsic.Name}}",