Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Oct 4, 2023
1 parent d014e2f commit 20be7ee
Show file tree
Hide file tree
Showing 40 changed files with 50 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/Draco.Compiler.Tests/EndToEnd/EndToEndTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected static TResult Invoke<TResult>(
string methodName,
TextReader? stdin = null,
TextWriter? stdout = null,
string moduleName = CompilerConstants.DefaultModuleName,
string moduleName = Constants.DefaultModuleName,
params object[] args)
{
Console.SetIn(stdin ?? Console.In);
Expand All @@ -106,7 +106,7 @@ protected static TResult Invoke<TResult>(Assembly assembly, string moduleName, s

protected static TResult Invoke<TResult>(Assembly assembly, string methodName, params object[] args) => Invoke<TResult>(
assembly: assembly,
moduleName: CompilerConstants.DefaultModuleName,
moduleName: Constants.DefaultModuleName,
methodName: methodName,
stdin: null,
stdout: null,
Expand Down
5 changes: 0 additions & 5 deletions src/Draco.Compiler.Tests/Semantics/IntegralDomainTests.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/Draco.Compiler/Api/Compilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Api/Semantics/SemanticModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Api/Syntax/SeparatedSyntaxList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Api/Syntax/SyntaxList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Api/Syntax/SyntaxNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Draco.Compiler/Api/Syntax/SyntaxTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/Draco.Compiler/Internal/Binding/ImportBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/Draco.Compiler/Internal/Codegen/MetadataCodegen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Draco.Compiler.Internal;

internal static class CompilerConstants
internal static class Constants
{
/// <summary>
/// The default name of the root module in IL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
4 changes: 2 additions & 2 deletions src/Draco.Compiler/Internal/Symbols/FunctionSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Draco.Compiler.Internal.Utilities;

namespace Draco.Compiler.Internal.Symbols.Generic;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Draco.Compiler.Internal.Utilities;

namespace Draco.Compiler.Internal.Symbols.Generic;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Draco.Compiler.Internal.Utilities;

namespace Draco.Compiler.Internal.Symbols.Generic;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/Draco.Compiler/Internal/Symbols/MergedModuleSymbol.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Reflection.Metadata;
using Draco.Compiler.Internal.Utilities;

namespace Draco.Compiler.Internal.Symbols.Metadata;

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using System.Linq;
using Draco.Compiler.Internal.Utilities;

namespace Draco.Compiler.Internal.Symbols.Synthetized;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/Draco.Compiler/Internal/Symbols/TypeSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -73,7 +74,7 @@ public IEnumerable<TypeSymbol> 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;
}
Expand Down
1 change: 1 addition & 0 deletions src/Draco.Compiler/Internal/Symbols/WellKnownTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Immutable;
using System.Threading;

namespace Draco.Compiler.Internal;
namespace Draco.Compiler.Internal.Utilities;

/// <summary>
/// Utility functions for atomic operations.
Expand Down
4 changes: 2 additions & 2 deletions src/Draco.SourceGeneration/Templates/RedSyntaxTree.sbncs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}));
Expand Down
Loading

0 comments on commit 20be7ee

Please sign in to comment.