- Emit a header comment to the output C file containing information about the generated code (source file and destination file)
This commit is contained in:
Tristan B. Velloza Kildaire 2022-12-11 17:52:36 +02:00
parent b43e8de0ef
commit c37b85b781
1 changed files with 41 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import std.conv : to;
import std.string : cmp;
import compiler.codegen.emit.dgenregs;
import gogga;
import std.range : walkLength;
public final class DCodeEmitter : CodeEmitter
{
@ -20,6 +21,45 @@ public final class DCodeEmitter : CodeEmitter
public override void emit()
{
// TODO: Implement me
// Emit header comment
emitHeaderComment("Hello this is an additional phrase added to the header");
gprintln("Static allocations needed: "~to!(string)(walkLength(initQueue[])));
emitStaticAllocations(initQueue);
gprintln("Code emittings needed: "~to!(string)(walkLength(codeQueue[])));
}
private void emitHeaderComment(string headerPhrase = "")
{
string moduleName = typeChecker.getModule().toString(); //TODO: Lookup actual module name (I was lazy)
string outputCFilename = file.name();
file.write(`
/**
* TLP compiler generated code
*
* Module name: `);
file.writeln(moduleName);
file.write(" * Output C file: ");
file.writeln(outputCFilename);
file.writeln(" */");
}
/**
* Emits the static allocations provided
*
* Params:
* initQueue = The allocation queue to emit static allocations from
*/
private void emitStaticAllocations(SList!(Instruction) initQueue)
{
}
}