ref counted strings
This commit is contained in:
@@ -128,7 +128,32 @@ else
|
||||
Directory.CreateDirectory(".build");
|
||||
}
|
||||
|
||||
var output = Generator.Emit(functions, moduleGraph, compileLib);
|
||||
string? entryPoint = null;
|
||||
|
||||
if (!compileLib)
|
||||
{
|
||||
if (!moduleGraph.TryResolveIdentifier("main", "main", true, out var info) || info.Type is not NubTypeFunc entryPointType)
|
||||
{
|
||||
DiagnosticFormatter.Print(Diagnostic.Error("func main::main(): i32 is not defined. If you wanted to compile as a library, specify --type=lib").Build(), Console.Error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!entryPointType.ReturnType.IsAssignableTo(NubTypeSInt.Get(32)))
|
||||
{
|
||||
DiagnosticFormatter.Print(Diagnostic.Error($"Entrypoint must return an i32 (currently '{entryPointType.ReturnType}')").Build(), Console.Error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (entryPointType.Parameters.Any())
|
||||
{
|
||||
DiagnosticFormatter.Print(Diagnostic.Error($"Entrypoint must not take any parameters").Build(), Console.Error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
entryPoint = info.MangledName;
|
||||
}
|
||||
|
||||
var output = Generator.Emit(functions, moduleGraph, entryPoint);
|
||||
File.WriteAllText(".build/out.c", output);
|
||||
|
||||
if (compileLib)
|
||||
|
||||
Reference in New Issue
Block a user