mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-05 04:27:51 +00:00
Begin minimizing Ast size
This commit is contained in:
@@ -65,7 +65,7 @@ Ast *alloc_ast_node(AstFile *f, AstKind kind) {
|
||||
|
||||
Ast *node = cast(Ast *)gb_alloc(a, size);
|
||||
node->kind = kind;
|
||||
node->file = f;
|
||||
node->file_id = f ? f->id : 0;
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,8 @@ Ast *clone_ast(Ast *node) {
|
||||
if (node == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
Ast *n = alloc_ast_node(node->file, node->kind);
|
||||
AstFile *f = get_ast_file_from_id(node->file_id);
|
||||
Ast *n = alloc_ast_node(f, node->kind);
|
||||
gb_memmove(n, node, ast_node_size(node->kind));
|
||||
|
||||
switch (n->kind) {
|
||||
@@ -399,8 +400,9 @@ void error(Ast *node, char const *fmt, ...) {
|
||||
va_start(va, fmt);
|
||||
error_va(token.pos, end_pos, fmt, va);
|
||||
va_end(va);
|
||||
if (node != nullptr && node->file != nullptr) {
|
||||
node->file->error_count += 1;
|
||||
if (node != nullptr && node->file_id != 0) {
|
||||
AstFile *f = get_ast_file_from_id(node->file_id);
|
||||
f->error_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,8 +415,9 @@ void error_no_newline(Ast *node, char const *fmt, ...) {
|
||||
va_start(va, fmt);
|
||||
error_no_newline_va(token.pos, fmt, va);
|
||||
va_end(va);
|
||||
if (node != nullptr && node->file != nullptr) {
|
||||
node->file->error_count += 1;
|
||||
if (node != nullptr && node->file_id != 0) {
|
||||
AstFile *f = get_ast_file_from_id(node->file_id);
|
||||
f->error_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,8 +445,9 @@ void syntax_error(Ast *node, char const *fmt, ...) {
|
||||
va_start(va, fmt);
|
||||
syntax_error_va(token.pos, end_pos, fmt, va);
|
||||
va_end(va);
|
||||
if (node != nullptr && node->file != nullptr) {
|
||||
node->file->error_count += 1;
|
||||
if (node != nullptr && node->file_id != 0) {
|
||||
AstFile *f = get_ast_file_from_id(node->file_id);
|
||||
f->error_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user