...
This commit is contained in:
@@ -61,9 +61,7 @@ public class Generator
|
||||
writer.Write("struct ");
|
||||
|
||||
if (s.Packed)
|
||||
{
|
||||
writer.Write("__attribute__((__packed__)) ");
|
||||
}
|
||||
|
||||
writer.WriteLine(NameMangler.Mangle(module.Name, name, NubTypeStruct.Get(module.Name, name)));
|
||||
writer.WriteLine("{");
|
||||
@@ -87,8 +85,15 @@ public class Generator
|
||||
{
|
||||
if (info.Type is NubTypeFunc fn)
|
||||
{
|
||||
if (info.External)
|
||||
writer.Write("extern ");
|
||||
switch (info.Kind)
|
||||
{
|
||||
case Module.DefinitionKind.External:
|
||||
writer.Write("extern ");
|
||||
break;
|
||||
case Module.DefinitionKind.Internal:
|
||||
writer.Write("static ");
|
||||
break;
|
||||
}
|
||||
|
||||
writer.WriteLine($"{CType(fn.ReturnType, info.MangledName)}({string.Join(", ", fn.Parameters.Select(p => CType(p)))});");
|
||||
}
|
||||
@@ -112,16 +117,20 @@ public class Generator
|
||||
return {{info.MangledName}}();
|
||||
}
|
||||
""");
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
foreach (var function in functions)
|
||||
{
|
||||
if (!moduleGraph.TryResolveIdentifier(function.Module, function.Name.Ident, true, out var info))
|
||||
throw new UnreachableException($"Module graph does not have info about the function {function.Module}::{function.Name.Ident}. This should have been caught earlier");
|
||||
|
||||
if (info.Kind == Module.DefinitionKind.Internal)
|
||||
writer.Write("static ");
|
||||
|
||||
var parameters = function.Parameters.Select(x => CType(x.Type, x.Name.Ident));
|
||||
|
||||
writer.WriteLine($"{CType(function.ReturnType, info.MangledName)}({string.Join(", ", parameters)})");
|
||||
writer.WriteLine("{");
|
||||
using (writer.Indent())
|
||||
|
||||
Reference in New Issue
Block a user