better comments in generated code
This commit is contained in:
@@ -95,6 +95,7 @@ public class QBEGenerator
|
|||||||
%size =l loadl %array
|
%size =l loadl %array
|
||||||
ret %size
|
ret %size
|
||||||
}
|
}
|
||||||
|
|
||||||
""");
|
""");
|
||||||
|
|
||||||
_writer.Comment("========== Referenced structs ==========");
|
_writer.Comment("========== Referenced structs ==========");
|
||||||
@@ -113,7 +114,6 @@ public class QBEGenerator
|
|||||||
EmitStructDefinition(structDef);
|
EmitStructDefinition(structDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
_writer.NewLine();
|
|
||||||
_writer.Comment("========== Function definitions ==========");
|
_writer.Comment("========== Function definitions ==========");
|
||||||
|
|
||||||
foreach (var funcDef in _definitions.OfType<FuncNode>())
|
foreach (var funcDef in _definitions.OfType<FuncNode>())
|
||||||
@@ -121,7 +121,6 @@ public class QBEGenerator
|
|||||||
EmitFuncDefinition(funcDef);
|
EmitFuncDefinition(funcDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
_writer.NewLine();
|
|
||||||
_writer.Comment("========== cstring literals ==========");
|
_writer.Comment("========== cstring literals ==========");
|
||||||
|
|
||||||
foreach (var cStringLiteral in _cStringLiterals)
|
foreach (var cStringLiteral in _cStringLiterals)
|
||||||
@@ -393,7 +392,7 @@ public class QBEGenerator
|
|||||||
|
|
||||||
private void EmitStructDefinition(StructNode structDef)
|
private void EmitStructDefinition(StructNode structDef)
|
||||||
{
|
{
|
||||||
_writer.Comment($" ===== {structDef.Module}::{structDef.Name} =====");
|
_writer.Comment($"{structDef.Module}::{structDef.Name}");
|
||||||
_writer.WriteLine($"export function {StructCtorName(structDef.Module, structDef.Name)}(l %struct) {{");
|
_writer.WriteLine($"export function {StructCtorName(structDef.Module, structDef.Name)}(l %struct) {{");
|
||||||
_writer.WriteLine("@start");
|
_writer.WriteLine("@start");
|
||||||
|
|
||||||
@@ -410,14 +409,14 @@ public class QBEGenerator
|
|||||||
|
|
||||||
_writer.Indented("ret");
|
_writer.Indented("ret");
|
||||||
_writer.WriteLine("}");
|
_writer.WriteLine("}");
|
||||||
|
_writer.NewLine();
|
||||||
|
|
||||||
foreach (var function in structDef.Functions)
|
foreach (var function in structDef.Functions)
|
||||||
{
|
{
|
||||||
_writer.Comment($" ===== {structDef.Module}::{structDef.Name}.{function.Name} =====");
|
_writer.Comment($"{structDef.Module}::{structDef.Name}.{function.Name}");
|
||||||
_labelIndex = 0;
|
_labelIndex = 0;
|
||||||
_tmpIndex = 0;
|
_tmpIndex = 0;
|
||||||
|
|
||||||
_writer.NewLine();
|
|
||||||
_writer.Write("export function ");
|
_writer.Write("export function ");
|
||||||
|
|
||||||
if (function.Signature.ReturnType is not VoidTypeNode)
|
if (function.Signature.ReturnType is not VoidTypeNode)
|
||||||
@@ -445,6 +444,7 @@ public class QBEGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
_writer.WriteLine("}");
|
_writer.WriteLine("}");
|
||||||
|
_writer.NewLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,6 +482,7 @@ public class QBEGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
_writer.WriteLine("}");
|
_writer.WriteLine("}");
|
||||||
|
_writer.NewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EmitBlock(BlockNode block)
|
private void EmitBlock(BlockNode block)
|
||||||
|
|||||||
@@ -1,18 +1,27 @@
|
|||||||
module "main"
|
module "main"
|
||||||
|
|
||||||
export extern "puts" func puts(text: cstring)
|
extern "puts" func puts(text: cstring)
|
||||||
|
|
||||||
export struct Human
|
struct Name
|
||||||
{
|
{
|
||||||
name: cstring
|
first: cstring
|
||||||
|
last: cstring
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Human
|
||||||
|
{
|
||||||
|
name: Name
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "main" func main(args: []cstring): i64
|
extern "main" func main(args: []cstring): i64
|
||||||
{
|
{
|
||||||
let x: cstring = "test"
|
let x: Human = {
|
||||||
|
name = {
|
||||||
|
first = "oliver"
|
||||||
|
last = "stene"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
x = x + "uwu"
|
puts(x.name.last)
|
||||||
|
|
||||||
puts(x)
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user