This commit is contained in:
nub31
2026-02-10 23:03:27 +01:00
parent 9d8d8f255a
commit c65fbeba13
8 changed files with 266 additions and 199 deletions

View File

@@ -3,9 +3,16 @@ using System.Diagnostics.CodeAnalysis;
namespace Compiler;
public class ModuleGraph(Dictionary<string, ModuleGraph.Module> modules)
public class ModuleGraph
{
public static Builder Create() => new();
public static Builder CreateBuilder() => new();
private ModuleGraph(Dictionary<string, Module> modules)
{
this.modules = modules;
}
private readonly Dictionary<string, Module> modules;
public List<Module> GetModules()
{
@@ -23,7 +30,7 @@ public class ModuleGraph(Dictionary<string, ModuleGraph.Module> modules)
return new Manifest(1, GetModules().Select(x => x.CreateManifestModule()).ToList());
}
public sealed class Module(string name)
public class Module(string name)
{
public string Name { get; } = name;
private readonly Dictionary<string, CustomTypeInfo> customTypes = new();
@@ -108,7 +115,7 @@ public class ModuleGraph(Dictionary<string, ModuleGraph.Module> modules)
public ManifestCustomTypeInfo CreateManifestCustomTypeInfo()
{
return new ManifestCustomTypeInfo(TypeMangler.Encode(Type), Exported);
return new ManifestCustomTypeInfo(TypeEncoder.Encode(Type), Exported);
}
}
@@ -120,7 +127,7 @@ public class ModuleGraph(Dictionary<string, ModuleGraph.Module> modules)
public ManifestIdentifierInfo CreateManifestIdentifierInfo()
{
return new ManifestIdentifierInfo(TypeMangler.Encode(Type), Exported);
return new ManifestIdentifierInfo(TypeEncoder.Encode(Type), Exported);
}
}
}
@@ -159,13 +166,13 @@ public class ModuleGraph(Dictionary<string, ModuleGraph.Module> modules)
foreach (var customType in manifestModule.CustomTypes)
{
var decoded = TypeMangler.Decode(customType.Value.EncodedType);
var decoded = TypeDecoder.Decode(customType.Value.EncodedType);
module.AddCustomType(customType.Key, new Module.CustomTypeInfo(decoded, customType.Value.Exported, Module.Source.Lib));
}
foreach (var identifier in manifestModule.Identifiers)
{
var decoded = TypeMangler.Decode(identifier.Value.EncodedType);
var decoded = TypeDecoder.Decode(identifier.Value.EncodedType);
module.AddIdentifier(identifier.Key, new Module.IdentifierInfo(decoded, identifier.Value.Exported, Module.Source.Lib));
}
}
@@ -234,7 +241,7 @@ public class ModuleGraph(Dictionary<string, ModuleGraph.Module> modules)
}
}
if (diagnostics.Any(x => x.Severity == DiagnosticSeverity.Error))
if (diagnostics.Any(x => x.Severity == Diagnostic.DiagnosticSeverity.Error))
return null;
return new ModuleGraph(modules);