From 0f4982ca26687ef73b6ca06babdbb65fffb120d6 Mon Sep 17 00:00:00 2001 From: Chris Anders Date: Mon, 23 Dec 2024 13:31:15 +0100 Subject: [PATCH] refactor: Cleanup --- .../SocordiaC/Compilation/CollectFunctionsListener.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NewSource/SocordiaC/Compilation/CollectFunctionsListener.cs b/NewSource/SocordiaC/Compilation/CollectFunctionsListener.cs index 0010ab61..1088468b 100644 --- a/NewSource/SocordiaC/Compilation/CollectFunctionsListener.cs +++ b/NewSource/SocordiaC/Compilation/CollectFunctionsListener.cs @@ -1,8 +1,12 @@ using System.Reflection; using DistIL.AsmIO; +using DistIL.CodeGen.Cil; +using DistIL.IR; +using DistIL.IR.Utils; using MrKWatkins.Ast.Listening; using Socordia.CodeAnalysis.AST; using Socordia.CodeAnalysis.AST.Declarations; +using MethodBody = DistIL.IR.MethodBody; namespace SocordiaC.Compilation; @@ -15,6 +19,11 @@ protected override void ListenToNode(Driver context, FunctionDefinition node) var method = type.CreateMethod(node.Signature.Name.Name, Utils.GetTypeFromNode(node.Signature.ReturnType, type), [], attrs); + if (!node.Modifiers.Contains(Modifier.Extern)) + { + method.Body = new MethodBody(method); + } + if (type == context.FunctionsType && method.IsStatic && method.Name == "main") { context.Compilation.Module.EntryPoint = method;