Replacing core allocation stuff, still need to rewrite map and token

structures
This commit is contained in:
Krzosa Karol
2022-10-10 00:05:38 +02:00
parent 13f2f20ea6
commit 2f153a7cd3
9 changed files with 43 additions and 36 deletions

View File

@@ -34,7 +34,7 @@ gen_last_line(){
}
function String
string_scope_name(Allocator *a, Ast_Scope *scope){
string_scope_name(Arena *a, Ast_Scope *scope){
String string = {};
if(scope->parent_scope) string = string_scope_name(a, scope->parent_scope);
assert_message(scope->scope_id != 0, "Scope id is equal to 0 which is invalid, scope didn't initialize id");
@@ -50,8 +50,8 @@ gen_scope_name(Ast_Scope *scope){
}
function String
unique_name(Allocator *allocator, Ast *ast){
Scratch scratch;
unique_name(Arena *allocator, Ast *ast){
Scratch scratch(allocator);
String result = string_scope_name(scratch, ast->parent_scope);
assert(result.len);
result = string_fmt(allocator, "%Q%d", result, ast->pos->line);
@@ -85,7 +85,7 @@ get_ctype_name_for_type(Ast_Type *type){
}
function String
string_simple_decl_prefix(Allocator *a, Ast_Type *ast){
string_simple_decl_prefix(Arena *a, Ast_Type *ast){
switch(ast->kind){
case TYPE_POINTER:{
String string = string_simple_decl_prefix(a, ast->base);
@@ -122,7 +122,7 @@ string_simple_decl_prefix(Allocator *a, Ast_Type *ast){
}
function String
string_simple_decl_postfix(Allocator *a, Ast_Type *ast){
string_simple_decl_postfix(Arena *a, Ast_Type *ast){
switch(ast->kind){
case TYPE_POINTER:
return string_simple_decl_postfix(a, ast->base);
@@ -141,7 +141,7 @@ string_simple_decl_postfix(Allocator *a, Ast_Type *ast){
}
function String
string_simple_decl(Allocator *a, Ast_Type *ast, Intern_String name = {}){
string_simple_decl(Arena *a, Ast_Type *ast, Intern_String name = {}){
if(ast->kind == TYPE_LAMBDA) {
String prefix = string_simple_decl_prefix(a, ast->func.ret);
String string = string_fmt(a, "%Q(*%Q)(", prefix, name);
@@ -173,7 +173,7 @@ gen_simple_decl(Ast_Type *ast, Intern_String name = {}){
}
function String
gen_string_simple_decl(Allocator *a, Ast_Type *ast, String name){
gen_string_simple_decl(Arena *a, Ast_Type *ast, String name){
Scratch scratch;
String string = string_simple_decl(scratch, ast, pctx->intern(name));
String result = string_copy(a, string);