From e814a3693f9efbdd00113de4dd5937acd97bc486 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 15 Nov 2021 17:26:01 +0000 Subject: Improve usage of `file_id` --- src/parser.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index ba5df1f27..cbd4d61d5 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -11,7 +11,7 @@ Token token_end_of_line(AstFile *f, Token tok) { } gbString get_file_line_as_string(TokenPos const &pos, i32 *offset_) { - AstFile *file = get_ast_file_from_id(pos.file_id); + AstFile *file = thread_safe_get_ast_file_from_id(pos.file_id); if (file == nullptr) { return nullptr; } @@ -95,7 +95,7 @@ Ast *clone_ast(Ast *node) { if (node == nullptr) { return nullptr; } - AstFile *f = get_ast_file_from_id(node->file_id); + AstFile *f = node->thread_safe_file(); Ast *n = alloc_ast_node(f, node->kind); gb_memmove(n, node, ast_node_size(node->kind)); @@ -401,7 +401,7 @@ void error(Ast *node, char const *fmt, ...) { error_va(token.pos, end_pos, fmt, va); va_end(va); if (node != nullptr && node->file_id != 0) { - AstFile *f = get_ast_file_from_id(node->file_id); + AstFile *f = node->thread_safe_file(); f->error_count += 1; } } @@ -416,7 +416,7 @@ void error_no_newline(Ast *node, char const *fmt, ...) { error_no_newline_va(token.pos, fmt, va); va_end(va); if (node != nullptr && node->file_id != 0) { - AstFile *f = get_ast_file_from_id(node->file_id); + AstFile *f = node->thread_safe_file(); f->error_count += 1; } } @@ -446,7 +446,7 @@ void syntax_error(Ast *node, char const *fmt, ...) { syntax_error_va(token.pos, end_pos, fmt, va); va_end(va); if (node != nullptr && node->file_id != 0) { - AstFile *f = get_ast_file_from_id(node->file_id); + AstFile *f = node->thread_safe_file(); f->error_count += 1; } } @@ -4669,7 +4669,7 @@ ParseFileError init_ast_file(AstFile *f, String fullpath, TokenPos *err_pos) { GB_ASSERT(f != nullptr); f->fullpath = string_trim_whitespace(fullpath); // Just in case set_file_path_string(f->id, fullpath); - set_ast_file_from_id(f->id, f); + thread_safe_set_ast_file_from_id(f->id, f); if (!string_ends_with(f->fullpath, str_lit(".odin"))) { return ParseFile_WrongExtension; } -- cgit v1.2.3