This commit is contained in:
nub31
2025-10-31 14:42:58 +01:00
parent 031b118a24
commit 7c7624b1bc
17 changed files with 453 additions and 605 deletions

View File

@@ -1,6 +1,7 @@
using NubLang.Ast;
using NubLang.Diagnostics;
using NubLang.Generation;
using NubLang.Modules;
using NubLang.Syntax;
var diagnostics = new List<Diagnostic>();
@@ -19,13 +20,24 @@ foreach (var file in args)
syntaxTrees.Add(syntaxTree);
}
var modules = Module.Collect(syntaxTrees);
ModuleRepository moduleRepository;
try
{
moduleRepository = ModuleRepository.Create(syntaxTrees);
}
catch (CompileException e)
{
Console.Error.WriteLine(e.Diagnostic.FormatANSI());
return 1;
}
var compilationUnits = new List<List<TopLevelNode>>();
for (var i = 0; i < args.Length; i++)
{
var typeChecker = new TypeChecker(syntaxTrees[i], modules);
var compilationUnit = typeChecker.Check();
var typeChecker = new TypeChecker();
var compilationUnit = typeChecker.Check(syntaxTrees[i], moduleRepository);
compilationUnits.Add(compilationUnit);
diagnostics.AddRange(typeChecker.Diagnostics);