Files
cground/src/compiler.c

33 lines
1.1 KiB
C
Raw Normal View History

#include "compiler.h"
#include "types.h"
2026-01-21 13:25:13 +11:00
#include <tram.h>
2026-01-21 13:25:13 +11:00
void compileGroundProgram(GroundProgram* program, char* name) {
Tram_Program tramProgram = Tram_Program_Create();
2026-01-21 13:25:13 +11:00
Tram_ParameterList parameters = Tram_ParameterList_Create(1, (Tram_Parameter[]){Tram_Parameter_Variable("main")});
Tram_Program_AddInstruction(&tramProgram, Tram_Instruction_Create(Tram_InstructionType_CreateLabel, parameters));
2026-01-21 13:25:13 +11:00
for (size_t i = 0; i < program->size; i++) {
compileGroundInstruction(&program->instructions[i], &tramProgram);
2026-01-21 13:25:13 +11:00
}
Tram_Compiler* compiler = Tram_Compiler_Create(tramProgram);
Tram_Compiler_SetLogLevel(compiler, Tram_LogLevel_Debug);
Tram_Compiler_SetTarget(compiler, Tram_Target_x86_64_Linux_libc);
Tram_Compiler_Compile(compiler);
2026-01-21 13:25:13 +11:00
if (Tram_Compiler_HasCompiled(compiler)) {
Tram_Compiler_AssembleAndLink(compiler, name, (Tram_LinkerArgs){.size = 0, .data = NULL});
} else {
printf("Compilation failed\n");
exit(EXIT_FAILURE);
}
}
void compileGroundInstruction(GroundInstruction* instruction, Tram_Program* program) {
}