mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-29 17:34:34 +00:00
Minimize TokenPos size by using i32 for line/column/offset and file_id instead of String
To make `i32` safe, the parser limits the file size of odin files to a maximum of 2GiB (which will be good enough for the vast vast majority of cases)
This commit is contained in:
@@ -3955,7 +3955,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
|
||||
gbAllocator a = heap_allocator();
|
||||
|
||||
GB_ASSERT(o.value.kind == ExactValue_String);
|
||||
String base_dir = dir_from_path(bd->token.pos.file);
|
||||
String base_dir = dir_from_path(get_file_path_string(bd->token.pos.file_id));
|
||||
String original_string = o.value.value_string;
|
||||
|
||||
|
||||
@@ -7239,7 +7239,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
||||
if (proc->kind == Entity_Variable) {
|
||||
sep = ":=";
|
||||
}
|
||||
error_line("\t%.*s%.*s%.*s %s %s at %.*s(%td:%td)\n", LIT(prefix), LIT(prefix_sep), LIT(name), sep, pt, LIT(pos.file), pos.line, pos.column);
|
||||
error_line("\t%.*s%.*s%.*s %s %s at %s\n", LIT(prefix), LIT(prefix_sep), LIT(name), sep, pt, token_pos_to_string(pos));
|
||||
}
|
||||
if (procs.count > 0) {
|
||||
error_line("\n");
|
||||
@@ -7300,8 +7300,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
|
||||
error_line("\n\t");
|
||||
}
|
||||
}
|
||||
error_line("at %.*s(%td:%td)\n", LIT(pos.file), pos.line, pos.column);
|
||||
// error_line("\t%.*s %s %s at %.*s(%td:%td) %lld\n", LIT(name), sep, pt, LIT(pos.file), pos.line, pos.column, valids[i].score);
|
||||
error_line("at %s\n", token_pos_to_string(pos));
|
||||
}
|
||||
result_type = t_invalid;
|
||||
} else {
|
||||
@@ -8255,7 +8254,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
|
||||
o->mode = Addressing_Constant;
|
||||
if (bd->name == "file") {
|
||||
o->type = t_untyped_string;
|
||||
o->value = exact_value_string(bd->token.pos.file);
|
||||
o->value = exact_value_string(get_file_path_string(bd->token.pos.file_id));
|
||||
} else if (bd->name == "line") {
|
||||
o->type = t_untyped_integer;
|
||||
o->value = exact_value_i64(bd->token.pos.line);
|
||||
|
||||
Reference in New Issue
Block a user