update runtime tok look for main in defult namespace

This commit is contained in:
nub31
2025-07-07 17:06:28 +02:00
parent 7f9a60fcb5
commit 2a8578726d
11 changed files with 65 additions and 116 deletions

View File

@@ -67,19 +67,19 @@ public partial class QBEGenerator
foreach (var funcDef in _syntaxTree.Definitions.OfType<BoundLocalFunc>())
{
EmitFuncDefinition(funcDef, LocalFuncName(funcDef), funcDef.Parameters, funcDef.ReturnType, funcDef.Body, funcDef.Exported);
EmitFuncDefinition(funcDef, LocalFuncName(funcDef), funcDef.Parameters, funcDef.ReturnType, funcDef.Body);
_writer.NewLine();
}
while (_anonymousFunctions.TryDequeue(out var anon))
{
EmitFuncDefinition(anon.Func, anon.Name, anon.Func.Parameters, anon.Func.ReturnType, anon.Func.Body, false);
EmitFuncDefinition(anon.Func, anon.Name, anon.Func.Parameters, anon.Func.ReturnType, anon.Func.Body);
_writer.NewLine();
}
foreach (var (impl, name) in _implFunctions)
{
EmitFuncDefinition(impl, name, impl.Parameters, impl.ReturnType, impl.Body, false);
EmitFuncDefinition(impl, name, impl.Parameters, impl.ReturnType, impl.Body);
_writer.NewLine();
}
@@ -347,7 +347,7 @@ public partial class QBEGenerator
return "l";
}
private void EmitFuncDefinition(BoundNode debugNode, string name, List<BoundFuncParameter> parameters, NubType returnType, BoundBlock body, bool exported)
private void EmitFuncDefinition(BoundNode debugNode, string name, List<BoundFuncParameter> parameters, NubType returnType, BoundBlock body)
{
_variables.Clear();
_variableScopes.Clear();
@@ -356,12 +356,7 @@ public partial class QBEGenerator
var builder = new StringBuilder();
if (exported)
{
builder.Append("export ");
}
builder.Append("function ");
builder.Append("export function ");
if (returnType is not NubVoidType)
{
builder.Append(FuncQBETypeName(returnType) + ' ');
@@ -503,7 +498,7 @@ public partial class QBEGenerator
private string LocalFuncName(BoundLocalFunc funcDef)
{
return funcDef.Exported ? $"${funcDef.Name}" : $"${funcDef.Namespace}_{funcDef.Name}";
return $"${funcDef.Namespace}_{funcDef.Name}";
}
private string ExternFuncName(BoundExternFunc funcDef)