diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-02 17:50:56 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-02 18:29:51 +0900 |
| commit | 2509637fb653cc8f5987736c1485a35245baa9b7 (patch) | |
| tree | 18f5cbc7d750b90d916f4d1db5dc5c823178bb54 /src/codegen.c | |
| parent | d81d087caf4fdb9a6ce482133d5c50c3113d13cc (diff) | |
| download | ducc-2509637fb653cc8f5987736c1485a35245baa9b7.tar.gz ducc-2509637fb653cc8f5987736c1485a35245baa9b7.tar.zst ducc-2509637fb653cc8f5987736c1485a35245baa9b7.zip | |
feat: generate .file and .loc directives
Diffstat (limited to 'src/codegen.c')
| -rw-r--r-- | src/codegen.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/codegen.c b/src/codegen.c index bc1e3d3..7f85fbd 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -777,6 +777,9 @@ static void codegen_block_stmt(CodeGen* g, AstNode* ast) { } static void codegen_stmt(CodeGen* g, AstNode* ast) { + // TODO: support multiple files. + fprintf(g->out, " .loc 1 %d 0\n", ast->loc.line); + if (ast->kind == AstNodeKind_list) { codegen_block_stmt(g, ast); } else if (ast->kind == AstNodeKind_return_stmt) { @@ -864,11 +867,14 @@ static void codegen_global_var(CodeGen* g, AstNode* var) { } } -void codegen(Program* prog, FILE* out) { +void codegen(Program* prog, const char* input_filename, FILE* out) { CodeGen* g = codegen_new(prog, out); fprintf(g->out, ".intel_syntax noprefix\n\n"); + // TODO: support multiple files. + fprintf(g->out, ".file 1 \"%s\"\n\n", input_filename); + // For GNU ld: // https://sourceware.org/binutils/docs/ld/Options.html fprintf(g->out, ".section .note.GNU-stack,\"\",@progbits\n\n"); |
