Emitting proper lines and files, coding in the language!

This commit is contained in:
Krzosa Karol
2022-06-14 14:15:21 +02:00
parent f885abe3f5
commit d63a327e3e
5 changed files with 62 additions and 49 deletions

View File

@@ -13,10 +13,16 @@ gen_indent(){
for(S32 i = 0; i < global_indent; i++) gen(" ");
}
global Intern_String last_filename;
function void
gen_line(Ast *node){
if(emit_line_directives)
if(emit_line_directives){
genln("#line %d", node->pos->line+1);
if(node->pos->file != last_filename){
last_filename = node->pos->file;
gen(" \"%s\"", last_filename.str);
}
}
}
function String
@@ -415,6 +421,8 @@ gen_ast(Ast *ast){
}
CASE(LAMBDA, Decl){
gen_line(node);
genln("");
if(is_flag_set(node->expr->flags, AST_FOREIGN)){
gen("/*foreign*/");
}
@@ -662,11 +670,6 @@ typedef S32 Bool;
#define true 1
#define false 0
typedef struct Slice{
S64 len;
void *data;
}Slice;
typedef struct String{
U8 *str;
S64 len;