mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-26 12:54:57 +00:00
Add ODIN_ERROR_POS_STYLE constant and change runtime.print_caller_location based on that constant
This commit is contained in:
@@ -143,11 +143,21 @@ print_int :: proc "contextless" (x: int) { print_i64(i64(x)) }
|
||||
|
||||
print_caller_location :: proc "contextless" (using loc: Source_Code_Location) {
|
||||
print_string(file_path)
|
||||
print_byte('(')
|
||||
print_u64(u64(line))
|
||||
print_byte(':')
|
||||
print_u64(u64(column))
|
||||
print_byte(')')
|
||||
when ODIN_ERROR_POS_STYLE == .Default {
|
||||
print_byte('(')
|
||||
print_u64(u64(line))
|
||||
print_byte(':')
|
||||
print_u64(u64(column))
|
||||
print_byte(')')
|
||||
} else when ODIN_ERROR_POS_STYLE == .Unix {
|
||||
print_byte(':')
|
||||
print_u64(u64(line))
|
||||
print_byte(':')
|
||||
print_u64(u64(column))
|
||||
print_byte(':')
|
||||
} else {
|
||||
#panic("unhandled ODIN_ERROR_POS_STYLE")
|
||||
}
|
||||
}
|
||||
print_typeid :: proc "contextless" (id: typeid) {
|
||||
if id == nil {
|
||||
|
||||
@@ -168,6 +168,8 @@ enum TimingsExportFormat : i32 {
|
||||
enum ErrorPosStyle {
|
||||
ErrorPosStyle_Default, // path(line:column) msg
|
||||
ErrorPosStyle_Unix, // path:line:column: msg
|
||||
|
||||
ErrorPosStyle_COUNT
|
||||
};
|
||||
|
||||
// This stores the information for the specify architecture of this build
|
||||
|
||||
@@ -893,6 +893,16 @@ void init_universal(void) {
|
||||
add_global_enum_constant(fields, "ODIN_ENDIAN", target_endians[bc->metrics.arch]);
|
||||
}
|
||||
|
||||
{
|
||||
GlobalEnumValue values[ErrorPosStyle_COUNT] = {
|
||||
{"Default", ErrorPosStyle_Default},
|
||||
{"Unix", ErrorPosStyle_Unix},
|
||||
};
|
||||
|
||||
auto fields = add_global_enum_type(str_lit("Odin_Error_Pos_Style_Type"), values, gb_count_of(values));
|
||||
add_global_enum_constant(fields, "ODIN_ERROR_POS_STYLE", build_context.ODIN_ERROR_POS_STYLE);
|
||||
}
|
||||
|
||||
|
||||
add_global_bool_constant("ODIN_DEBUG", bc->ODIN_DEBUG);
|
||||
add_global_bool_constant("ODIN_DISABLE_ASSERT", bc->ODIN_DISABLE_ASSERT);
|
||||
|
||||
Reference in New Issue
Block a user