Generating proper slice name when rewriting tree

This commit is contained in:
Krzosa Karol
2022-06-14 12:07:04 +02:00
parent 946e4082cc
commit 699ca4b18a
2 changed files with 14 additions and 9 deletions

View File

@@ -131,6 +131,14 @@ gen_simple_decl(Ast_Type *ast, Intern_String name = {}, Ast_Scope *scope = 0, bo
gen("%.*s", (int)string.len, string.str);
}
function String
gen_string_simple_decl(Allocator *a, Ast_Type *ast, String name, Ast_Scope *scope, bool scope_names){
Scratch scratch;
String string = string_simple_decl(scratch, ast, pctx->intern(name), scope, scope_names);
String result = string_copy(a, string);
return result;
}
function B32
gen_value(Value a){
B32 result = true;
@@ -672,13 +680,7 @@ typedef struct String{
#endif
For(pctx->ordered_decls){
if(it->kind == AST_STRUCT){
if(it->type && it->type->kind == TYPE_TYPE && is_slice(it->type_val)){
genln("typedef struct struct ");
gen_simple_decl(it->type_val);
gen(";");
} else{
genln("typedef struct struct %s;", it->name.str);
}
genln("typedef struct struct %s;", it->name.str);
} else if(it->kind == AST_LAMBDA){
genln("");
gen_lambda(it->name, it->lambda, false);