From 7cb469fe7363ca9bec88f4fac334f5ada2597a3a Mon Sep 17 00:00:00 2001 From: nub31 Date: Tue, 22 Jul 2025 20:08:49 +0200 Subject: [PATCH] remove generics for now --- .../Syntax/Generics/GenericInstantiator.cs | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 src/compiler/NubLang/Syntax/Generics/GenericInstantiator.cs diff --git a/src/compiler/NubLang/Syntax/Generics/GenericInstantiator.cs b/src/compiler/NubLang/Syntax/Generics/GenericInstantiator.cs deleted file mode 100644 index 0abd722..0000000 --- a/src/compiler/NubLang/Syntax/Generics/GenericInstantiator.cs +++ /dev/null @@ -1,77 +0,0 @@ -using NubLang.Syntax.Parsing.Node; - -namespace NubLang.Syntax.Generics; - -public class GenericInstantiator -{ - private readonly IEnumerable _syntaxTrees; - private readonly Queue _structQueue = []; - - public GenericInstantiator(IEnumerable syntaxTrees) - { - _syntaxTrees = syntaxTrees; - } - - public IEnumerable Visit() - { - _structQueue.Clear(); - - var syntaxTrees = new List(); - - foreach (var syntaxTree in _syntaxTrees) - { - var definitions = new List(); - foreach (var definition in syntaxTree.Definitions) - { - if (definition.Parameters.Any()) - { - switch (definition) - { - case StructSyntax structSyntax: - { - var usages = _syntaxTrees - .SelectMany(x => x.GetDescendants()) - .OfType() - .Where(x => x.Namespace == structSyntax.Namespace) - .Where(x => x.Name == structSyntax.Name); - - foreach (var usage in usages) - { - if (!_structQueue.Any(x => x.Type.Namespace == usage.Namespace && x.Type.Name == usage.Name)) - { - _structQueue.Enqueue(new GenericStructQueue(structSyntax, usage, false)); - } - } - - break; - } - default: - { - throw new ArgumentOutOfRangeException(nameof(definition)); - } - } - } - else - { - definitions.Add(definition); - } - } - - while (_structQueue.TryDequeue(out var item)) - { - definitions.Add(new StructSyntax(item.Type.Tokens, item.Struct.Namespace, [], item.Type.MangledName(), item.Struct.Fields, item.Struct.Functions)); - } - - syntaxTrees.Add(new SyntaxTree(syntaxTree.Tokens, syntaxTree.Namespace, definitions, syntaxTree.Diagnostics)); - } - - return syntaxTrees; - } -} - -public class GenericStructQueue(StructSyntax @struct, CustomTypeSyntax type, bool created) -{ - public StructSyntax Struct { get; init; } = @struct; - public CustomTypeSyntax Type { get; init; } = type; - public bool Created { get; set; } = created; -} \ No newline at end of file