-
Notifications
You must be signed in to change notification settings - Fork 0
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
fbbab24
commit d8d84f2
Showing
596 changed files
with
33,285 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# http://editorconfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{c,h,rsrc,ail}] | ||
end_of_line = lf | ||
|
||
[*.{xml,csproj}] | ||
indent_size = 2 | ||
|
||
[*.{bat,cs,sln,csproj}] | ||
end_of_line = crlf | ||
|
||
# .NET formatting settings: | ||
[*.cs] | ||
dotnet_sort_system_directives_first = true | ||
|
||
# CA1062: Validate arguments of public methods | ||
dotnet_diagnostic.CA1062.severity = silent | ||
|
||
# CA1715: Identifiers should have correct prefix | ||
dotnet_diagnostic.CA1715.severity = silent | ||
|
||
# CA1710: Identifiers should have correct suffix | ||
dotnet_diagnostic.CA1710.severity = silent | ||
|
||
# CA1032: Implement standard exception constructors | ||
dotnet_diagnostic.CA1032.severity = silent | ||
|
||
# CA1303: Do not pass literals as localized parameters | ||
dotnet_diagnostic.CA1303.severity = silent | ||
|
||
# CA1716: Identifiers should not match keywords | ||
dotnet_diagnostic.CA1716.severity = silent |
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,20 @@ | ||
* text=auto | ||
|
||
*.vson text eol=lf encoding=UTF-8 | ||
*.json text eol=lf encoding=UTF-8 | ||
*.ad text encoding=UTF-8 | ||
*.md text | ||
*.bat text eol=crlf | ||
*.c text eol=lf | ||
*.h text eol=lf | ||
*.rsrc text eol=lf | ||
*.sh text eol=lf | ||
*.yml text eol=lf | ||
|
||
*.cs text eol=crlf | ||
*.sln text eol=crlf | ||
*.csproj text eol=crlf | ||
|
||
# These files must be UTF-8 w/ BOM to work, so treat them as binary | ||
RuntimeLibrary.c binary | ||
RuntimeLibrary.h binary |
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,12 @@ | ||
# VS Files | ||
.vs/ | ||
bin/ | ||
obj/ | ||
*.user | ||
launchSettings.json | ||
|
||
# VS Code Files | ||
.vscode/ | ||
|
||
# OSX Files | ||
.DS_Store |
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,3 @@ | ||
[submodule "azoth.language.tests"] | ||
path = azoth.language.tests | ||
url = https://github.com/azoth-lang/azoth.language.tests.git |
Large diffs are not rendered by default.
Oops, something went wrong.
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,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Azoth/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
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,66 @@ | ||
using Azoth.Tools.Bootstrap.Compiler.Core; | ||
using Azoth.Tools.Bootstrap.Framework; | ||
|
||
namespace Azoth.Tools.Bootstrap.Compiler.API | ||
{ | ||
public class AssemblyBuilder : CodeBuilder | ||
{ | ||
public new const string LineTerminator = "\n"; | ||
|
||
/// Whether we need a blank separator line before the next declaration | ||
public bool NeedsDeclarationSeparatorLine { get; private set; } | ||
|
||
public AssemblyBuilder(string indentCharacters = " ") | ||
: base(indentCharacters, LineTerminator) | ||
{ | ||
} | ||
|
||
public override void EndLine(string value) | ||
{ | ||
base.EndLine(value); | ||
NeedsDeclarationSeparatorLine = true; | ||
} | ||
|
||
public override void EndLine() | ||
{ | ||
base.EndLine(); | ||
NeedsDeclarationSeparatorLine = true; | ||
} | ||
|
||
public override void AppendLine(string value) | ||
{ | ||
base.AppendLine(value); | ||
NeedsDeclarationSeparatorLine = true; | ||
} | ||
|
||
public override void BlankLine() | ||
{ | ||
base.BlankLine(); | ||
NeedsDeclarationSeparatorLine = false; | ||
} | ||
|
||
public virtual void DeclarationSeparatorLine() | ||
{ | ||
if (!NeedsDeclarationSeparatorLine) return; | ||
base.BlankLine(); | ||
NeedsDeclarationSeparatorLine = false; | ||
} | ||
|
||
public override void BeginBlock() | ||
// ensures CurrentIndentDepth == old(CurrentIndentDepth) + 1 | ||
{ | ||
base.AppendLine("{"); | ||
base.BeginBlock(); | ||
NeedsDeclarationSeparatorLine = false; | ||
} | ||
|
||
public override void EndBlock() | ||
// ensures CurrentIndentDepth == old(CurrentIndentDepth) - 1 | ||
{ | ||
Requires.That(nameof(CurrentIndent), CurrentIndentDepth > 0, "indent depth must not be zero"); | ||
base.EndBlock(); | ||
base.AppendLine("}"); | ||
NeedsDeclarationSeparatorLine = true; | ||
} | ||
} | ||
} |
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,122 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Threading.Tasks.Dataflow; | ||
using Azoth.Tools.Bootstrap.Compiler.Core; | ||
using Azoth.Tools.Bootstrap.Compiler.CST; | ||
using Azoth.Tools.Bootstrap.Compiler.IntermediateLanguage; | ||
using Azoth.Tools.Bootstrap.Compiler.Lexing; | ||
using Azoth.Tools.Bootstrap.Compiler.Names; | ||
using Azoth.Tools.Bootstrap.Compiler.Parsing; | ||
using Azoth.Tools.Bootstrap.Compiler.Semantics; | ||
using Azoth.Tools.Bootstrap.Framework; | ||
|
||
namespace Azoth.Tools.Bootstrap.Compiler.API | ||
{ | ||
public class AzothCompiler | ||
{ | ||
/// <summary> | ||
/// Whether to store the liveness analysis for each function and method. | ||
/// Default Value: false | ||
/// </summary> | ||
public bool SaveLivenessAnalysis { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Whether to store the borrow checker claims for each function and method. | ||
/// Default Value: false | ||
/// </summary> | ||
public bool SaveReachabilityGraphs { get; set; } = false; | ||
|
||
public Task<PackageIL> CompilePackageAsync( | ||
Name name, | ||
IEnumerable<ICodeFileSource> files, | ||
FixedDictionary<Name, Task<PackageIL>> referenceTasks) | ||
{ | ||
return CompilePackageAsync(name, files, referenceTasks, TaskScheduler.Default); | ||
} | ||
|
||
public async Task<PackageIL> CompilePackageAsync( | ||
Name name, | ||
IEnumerable<ICodeFileSource> fileSources, | ||
FixedDictionary<Name, Task<PackageIL>> referenceTasks, | ||
TaskScheduler taskScheduler) | ||
{ | ||
var lexer = new Lexer(); | ||
var parser = new CompilationUnitParser(); | ||
var parseBlock = new TransformBlock<ICodeFileSource, ICompilationUnitSyntax>( | ||
async (fileSource) => | ||
{ | ||
var file = await fileSource.LoadAsync().ConfigureAwait(false); | ||
var context = new ParseContext(file, new Diagnostics()); | ||
var tokens = lexer.Lex(context).WhereNotTrivia(); | ||
return parser.Parse(tokens); | ||
}, new ExecutionDataflowBlockOptions() | ||
{ | ||
TaskScheduler = taskScheduler, | ||
EnsureOrdered = false, | ||
}); | ||
|
||
foreach (var fileSource in fileSources) | ||
parseBlock.Post(fileSource); | ||
|
||
parseBlock.Complete(); | ||
|
||
await parseBlock.Completion.ConfigureAwait(false); | ||
|
||
if (!parseBlock.TryReceiveAll(out var compilationUnits)) | ||
throw new Exception("Not all compilation units are ready"); | ||
|
||
var referencePairs = await Task | ||
.WhenAll(referenceTasks.Select(async kv => | ||
(alias: kv.Key, package: await kv.Value.ConfigureAwait(false)))) | ||
.ConfigureAwait(false); | ||
var references = referencePairs.ToFixedDictionary(r => r.alias, r => r.package); | ||
|
||
// TODO add the references to the package syntax | ||
var packageSyntax = new PackageSyntax(name, compilationUnits.ToFixedSet(), references); | ||
|
||
var analyzer = new SemanticAnalyzer() | ||
{ | ||
SaveLivenessAnalysis = SaveLivenessAnalysis, | ||
SaveReachabilityGraphs = SaveReachabilityGraphs, | ||
}; | ||
|
||
return analyzer.Check(packageSyntax); | ||
} | ||
|
||
public PackageIL CompilePackage( | ||
string name, | ||
IEnumerable<ICodeFileSource> fileSources, | ||
FixedDictionary<Name, PackageIL> references) | ||
{ | ||
return CompilePackage(name, fileSources.Select(s => s.Load()), references); | ||
} | ||
|
||
public PackageIL CompilePackage( | ||
string name, | ||
IEnumerable<CodeFile> files, | ||
FixedDictionary<Name, PackageIL> references) | ||
{ | ||
var lexer = new Lexer(); | ||
var parser = new CompilationUnitParser(); | ||
var compilationUnits = files | ||
.Select(file => | ||
{ | ||
var context = new ParseContext(file, new Diagnostics()); | ||
var tokens = lexer.Lex(context).WhereNotTrivia(); | ||
return parser.Parse(tokens); | ||
}) | ||
.ToFixedSet(); | ||
var packageSyntax = new PackageSyntax(name, compilationUnits, references); | ||
|
||
var analyzer = new SemanticAnalyzer() | ||
{ | ||
SaveLivenessAnalysis = SaveLivenessAnalysis, | ||
SaveReachabilityGraphs = SaveReachabilityGraphs, | ||
}; | ||
|
||
return analyzer.Check(packageSyntax); | ||
} | ||
} | ||
} |
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
<AssemblyName>Azoth.Tools.Bootstrap.Compiler.API</AssemblyName> | ||
<RootNamespace>Azoth.Tools.Bootstrap.Compiler.API</RootNamespace> | ||
<LangVersion>8.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<WarningsAsErrors /> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<WarningsAsErrors /> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ExhaustiveMatching.Analyzer" Version="0.5.0" /> | ||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.11.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Compiler.Core\Compiler.Core.csproj" /> | ||
<ProjectReference Include="..\Compiler.Parsing\Compiler.Parsing.csproj" /> | ||
<ProjectReference Include="..\Compiler.Semantics\Compiler.Semantics.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.