Skip to content

Commit

Permalink
refactor: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
furesoft committed Dec 23, 2024
1 parent 25d3cff commit 0f4982c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions NewSource/SocordiaC/Compilation/CollectFunctionsListener.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit 0f4982c

Please sign in to comment.