diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-14 00:19:16 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-14 00:19:16 -0500 |
| commit | 1af5ab6d4e791b1beb5ce30b57b7c35cf96d8a25 (patch) | |
| tree | b33e6a77acaf43bfac1a2d42bbc1e5181f405474 /compile.c | |
| parent | b3e0f11644f439eb02a209f6ae965ceea7a1b2d5 (diff) | |
Add #line directives for source code mapping
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -19,13 +19,18 @@ CORD compile_type(env_t *env, type_ast_t *t) CORD compile_statement(env_t *env, ast_t *ast) { + CORD stmt; switch (ast->tag) { case If: case For: case While: case FunctionDef: case Return: case StructDef: case EnumDef: case Declare: case Assign: case UpdateAssign: case DocTest: - return compile(env, ast); + stmt = compile(env, ast); + break; default: - return CORD_asprintf("(void)%r;", compile(env, ast)); + stmt = CORD_asprintf("(void)%r;", compile(env, ast)); + break; } + int64_t line = get_line_number(ast->file, ast->start); + return stmt ? CORD_asprintf("#line %ld\n%r", line, stmt) : stmt; } CORD compile(env_t *env, ast_t *ast) |
