This commit is contained in:
nub31
2025-10-24 15:33:56 +02:00
parent 766ca9a6b9
commit 3505e2547a
5 changed files with 113 additions and 119 deletions

View File

@@ -18,7 +18,7 @@ public static class CType
NubConstArrayType arr => CreateConstArrayType(arr, variableName, constArraysAsPointers),
NubArrayType arr => CreateArrayType(arr, variableName),
NubFuncType fn => CreateFuncType(fn, variableName),
NubStructType st => $"struct {st.Module}_{st.Name}" + (variableName != null ? $" {variableName}" : ""),
NubStructType st => $"struct {st.Module}_{st.Name}_{NameMangler.Mangle(st)}" + (variableName != null ? $" {variableName}" : ""),
_ => throw new NotSupportedException($"C type generation not supported for: {type}")
};
}

View File

@@ -29,11 +29,6 @@ public class Generator
return externSymbol ?? $"{module}_{name}";
}
private static string StructName(string module, string name)
{
return $"{module}_{name}";
}
public string Emit()
{
_writer.WriteLine("""
@@ -53,7 +48,7 @@ public class Generator
foreach (var structType in _compilationUnit.ImportedStructTypes)
{
_writer.WriteLine($"struct {StructName(structType.Module, structType.Name)}");
_writer.WriteLine(CType.Create(structType));
_writer.WriteLine("{");
using (_writer.Indent())
{