This commit is contained in:
nub31
2025-02-02 21:18:20 +01:00
parent 9719cd4426
commit 006fedba37
2 changed files with 36 additions and 65 deletions

View File

@@ -42,6 +42,7 @@ public class Generator
{
_builder.AppendLine("global _start");
_builder.AppendLine("extern gc_init");
_builder.AppendLine("extern gc_alloc");
_builder.AppendLine("extern str_cmp");
foreach (var externFuncDefinition in _definitions.OfType<ExternFuncDefinitionNode>())
@@ -51,11 +52,12 @@ public class Generator
_builder.AppendLine();
_builder.AppendLine("section .text");
// TODO: Only add start label if entrypoint is present, otherwise assume library
var main = _symbolTable.ResolveLocalFunc(Entrypoint, []);
_builder.AppendLine("_start:");
_builder.AppendLine(" call gc_init");
_builder.AppendLine($" call {main.StartLabel}");
_builder.AppendLine(main.ReturnType.HasValue