...
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using CLI;
|
||||
using Generation.QBE;
|
||||
using Syntax;
|
||||
using Syntax.Binding;
|
||||
using Syntax.Diagnostics;
|
||||
using Syntax.Node;
|
||||
using Syntax.Parsing;
|
||||
@@ -83,13 +82,11 @@ foreach (var file in options.Files)
|
||||
var tokenizeResult = Tokenizer.Tokenize(sourceText, out var tokenizerDiagnostics);
|
||||
diagnostics.AddRange(tokenizerDiagnostics);
|
||||
|
||||
var syntaxTree = Parser.ParseFile(tokenizeResult, out var parseDiagnostics);
|
||||
diagnostics.AddRange(parseDiagnostics);
|
||||
var parser = new Parser(tokenizeResult);
|
||||
var syntaxTree = parser.Parse();
|
||||
diagnostics.AddRange(syntaxTree.Diagnostics);
|
||||
|
||||
if (syntaxTree != null)
|
||||
{
|
||||
syntaxTrees[file] = syntaxTree;
|
||||
}
|
||||
syntaxTrees[file] = syntaxTree;
|
||||
}
|
||||
|
||||
var definitionTable = new DefinitionTable(syntaxTrees.Values);
|
||||
@@ -98,13 +95,12 @@ var boundSyntaxTrees = new Dictionary<string, BoundSyntaxTree>();
|
||||
|
||||
foreach (var (file, syntaxTree) in syntaxTrees)
|
||||
{
|
||||
var boundSyntaxTree = Binder.Bind(syntaxTree, definitionTable, out var binderDiagnostics);
|
||||
diagnostics.AddRange(binderDiagnostics);
|
||||
var binder = new Binder(syntaxTree, definitionTable);
|
||||
var boundSyntaxTree = binder.Bind();
|
||||
diagnostics.AddRange(boundSyntaxTree.Diagnostics);
|
||||
boundSyntaxTrees[file] = boundSyntaxTree;
|
||||
}
|
||||
|
||||
var boundDefinitionTable = new BoundDefinitionTable(boundSyntaxTrees.Values);
|
||||
|
||||
foreach (var diagnostic in diagnostics)
|
||||
{
|
||||
Console.Error.WriteLine(diagnostic.FormatANSI());
|
||||
@@ -115,6 +111,8 @@ if (diagnostics.Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Erro
|
||||
return 1;
|
||||
}
|
||||
|
||||
var boundDefinitionTable = new BoundDefinitionTable(boundSyntaxTrees.Values);
|
||||
|
||||
var objectFiles = new List<string>();
|
||||
|
||||
foreach (var file in options.Files)
|
||||
@@ -124,7 +122,7 @@ foreach (var file in options.Files)
|
||||
var ssa = QBEGenerator.Emit(boundSyntaxTrees[file], boundDefinitionTable, file);
|
||||
// File.WriteAllText(Path.Join(INT_DEBUG_DIR, $"{outFileName}.ssa"), ssa);
|
||||
File.WriteAllText(Path.Join(INT_DEBUG_DIR, $"{Path.GetFileNameWithoutExtension(file)}.ssa"), ssa);
|
||||
|
||||
|
||||
var asm = await QBE.Invoke(ssa);
|
||||
if (asm == null)
|
||||
{
|
||||
@@ -162,7 +160,7 @@ else
|
||||
Console.Error.WriteLine($"file '{options.CustomRuntime}' does not exist'");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
objectFiles.Add(options.CustomRuntime);
|
||||
}
|
||||
|
||||
@@ -195,7 +193,7 @@ async Task<string> CreateBuiltinRuntime()
|
||||
var runtime = resources.First(r => r.EndsWith(RUNTIME_NAME));
|
||||
|
||||
await using var reader = Assembly.GetExecutingAssembly().GetManifestResourceStream(runtime);
|
||||
|
||||
|
||||
if (reader == null)
|
||||
{
|
||||
throw new RuntimeCreationException($"Cannot open stream to '{RUNTIME_NAME}'");
|
||||
@@ -205,7 +203,7 @@ async Task<string> CreateBuiltinRuntime()
|
||||
await using var writer = new FileStream(runtimePath, FileMode.Create);
|
||||
|
||||
reader.CopyTo(writer);
|
||||
|
||||
|
||||
return runtimePath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user