Improve line directive mapping

This commit is contained in:
Krzosa Karol
2022-09-28 20:30:31 +02:00
parent 681b3c1f95
commit a7524a0071

View File

@@ -13,10 +13,12 @@ gen_indent(){
}
global Intern_String last_filename;
global int last_line;
function void
gen_line(Ast *node){
if(emit_line_directives){
genln("#line %d", node->pos->line+1);
last_line = node->pos->line+1;
genln("#line %d", last_line);
if(node->pos->file != last_filename){
last_filename = node->pos->file;
gen(" \"%Q\"", last_filename);
@@ -24,6 +26,13 @@ gen_line(Ast *node){
}
}
function void
gen_last_line(){
if(emit_line_directives){
genln("#line %d", last_line);
}
}
function String
string_scope_name(Allocator *a, Ast_Scope *scope){
String string = {};
@@ -217,6 +226,7 @@ gen_stmt_scope(Ast_Scope *scope, B32 switch_case_gen_break = 0){
}
if(switch_case_gen_break == 1) genln("break;");
global_indent--;
gen_last_line();
genln("}");
}
@@ -560,6 +570,7 @@ gen_ast(Ast *ast){
gen_ast(it);
}
global_indent--;
gen_last_line();
genln("}");
}
@@ -679,6 +690,7 @@ gen_ast(Ast *ast){
}
global_indent--;
gen_last_line();
genln("}");
BREAK();