mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-01 19:02:13 +00:00
Add -foreign-error-procedures
This commit is contained in:
@@ -17,6 +17,24 @@ type_assertion_trap :: proc "contextless" () -> ! {
|
||||
}
|
||||
|
||||
|
||||
when ODIN_FOREIGN_ERROR_PROCEDURES {
|
||||
foreign {
|
||||
bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) ---
|
||||
slice_handle_error :: proc "contextless" (file: string, line, column: i32, lo, hi: int, len: int) -> ! ---
|
||||
multi_pointer_slice_handle_error :: proc "contextless" (file: string, line, column: i32, lo, hi: int) -> ! ---
|
||||
multi_pointer_slice_expr_error :: proc "contextless" (file: string, line, column: i32, lo, hi: int) ---
|
||||
slice_expr_error_hi :: proc "contextless" (file: string, line, column: i32, hi: int, len: int) ---
|
||||
slice_expr_error_lo_hi :: proc "contextless" (file: string, line, column: i32, lo, hi: int, len: int) ---
|
||||
dynamic_array_expr_error :: proc "contextless" (file: string, line, column: i32, low, high, max: int) ---
|
||||
matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32, row_index, column_index, row_count, column_count: int) ---
|
||||
type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid) ---
|
||||
type_assertion_check2 :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid, from_data: rawptr) ---
|
||||
make_slice_error_loc :: proc "contextless" (loc := #caller_location, len: int) ---
|
||||
make_dynamic_array_error_loc :: proc "contextless" (using loc := #caller_location, len, cap: int) ---
|
||||
make_map_expr_error_loc :: proc "contextless" (loc := #caller_location, cap: int) ---
|
||||
}
|
||||
} else {
|
||||
|
||||
bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) {
|
||||
if 0 <= index && index < count {
|
||||
return
|
||||
@@ -231,7 +249,7 @@ make_map_expr_error_loc :: #force_inline proc "contextless" (loc := #caller_loca
|
||||
handle_error(loc, cap)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@ struct BuildContext {
|
||||
bool ODIN_DEBUG; // Odin in debug mode
|
||||
bool ODIN_DISABLE_ASSERT; // Whether the default 'assert' et al is disabled in code or not
|
||||
bool ODIN_DEFAULT_TO_NIL_ALLOCATOR; // Whether the default allocator is a "nil" allocator or not (i.e. it does nothing)
|
||||
bool ODIN_FOREIGN_ERROR_PROCEDURES;
|
||||
|
||||
ErrorPosStyle ODIN_ERROR_POS_STYLE;
|
||||
|
||||
@@ -269,6 +270,7 @@ struct BuildContext {
|
||||
|
||||
bool copy_file_contents;
|
||||
|
||||
|
||||
u32 cmd_doc_flags;
|
||||
Array<String> extra_packages;
|
||||
|
||||
|
||||
@@ -976,6 +976,7 @@ void init_universal(void) {
|
||||
add_global_bool_constant("ODIN_USE_SEPARATE_MODULES", bc->use_separate_modules);
|
||||
add_global_bool_constant("ODIN_TEST", bc->command_kind == Command_test);
|
||||
add_global_bool_constant("ODIN_NO_ENTRY_POINT", bc->no_entry_point);
|
||||
add_global_bool_constant("ODIN_FOREIGN_ERROR_PROCEDURES", bc->ODIN_FOREIGN_ERROR_PROCEDURES);
|
||||
|
||||
|
||||
// Builtin Procedures
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -632,6 +632,7 @@ enum BuildFlagKind {
|
||||
BuildFlag_InsertSemicolon,
|
||||
BuildFlag_StrictStyle,
|
||||
BuildFlag_StrictStyleInitOnly,
|
||||
BuildFlag_ForeignErrorProcedures,
|
||||
|
||||
BuildFlag_Compact,
|
||||
BuildFlag_GlobalDefinitions,
|
||||
@@ -785,10 +786,13 @@ bool parse_build_flags(Array<String> args) {
|
||||
add_flag(&build_flags, BuildFlag_InsertSemicolon, str_lit("insert-semicolon"), BuildFlagParam_None, Command__does_check);
|
||||
add_flag(&build_flags, BuildFlag_StrictStyle, str_lit("strict-style"), BuildFlagParam_None, Command__does_check);
|
||||
add_flag(&build_flags, BuildFlag_StrictStyleInitOnly, str_lit("strict-style-init-only"), BuildFlagParam_None, Command__does_check);
|
||||
add_flag(&build_flags, BuildFlag_ForeignErrorProcedures, str_lit("foreign-error-procedures"), BuildFlagParam_None, Command__does_check);
|
||||
|
||||
add_flag(&build_flags, BuildFlag_Compact, str_lit("compact"), BuildFlagParam_None, Command_query);
|
||||
add_flag(&build_flags, BuildFlag_GlobalDefinitions, str_lit("global-definitions"), BuildFlagParam_None, Command_query);
|
||||
add_flag(&build_flags, BuildFlag_GoToDefinitions, str_lit("go-to-definitions"), BuildFlagParam_None, Command_query);
|
||||
|
||||
|
||||
add_flag(&build_flags, BuildFlag_Short, str_lit("short"), BuildFlagParam_None, Command_doc);
|
||||
add_flag(&build_flags, BuildFlag_AllPackages, str_lit("all-packages"), BuildFlagParam_None, Command_doc);
|
||||
add_flag(&build_flags, BuildFlag_DocFormat, str_lit("doc-format"), BuildFlagParam_None, Command_doc);
|
||||
@@ -1356,6 +1360,9 @@ bool parse_build_flags(Array<String> args) {
|
||||
case BuildFlag_DefaultToNilAllocator:
|
||||
build_context.ODIN_DEFAULT_TO_NIL_ALLOCATOR = true;
|
||||
break;
|
||||
case BuildFlag_ForeignErrorProcedures:
|
||||
build_context.ODIN_FOREIGN_ERROR_PROCEDURES = true;
|
||||
break;
|
||||
case BuildFlag_InsertSemicolon: {
|
||||
gb_printf_err("-insert-semicolon flag is not required any more\n");
|
||||
bad_flags = true;
|
||||
@@ -2084,6 +2091,11 @@ void print_show_help(String const arg0, String const &command) {
|
||||
print_usage_line(1, "-verbose-errors");
|
||||
print_usage_line(2, "Prints verbose error messages showing the code on that line and the location in that line");
|
||||
print_usage_line(0, "");
|
||||
|
||||
print_usage_line(1, "-foreign-error-procedures");
|
||||
print_usage_line(2, "States that the error procedues used in the runtime are defined in a separate translation unit");
|
||||
print_usage_line(0, "");
|
||||
|
||||
}
|
||||
|
||||
if (run_or_build) {
|
||||
|
||||
Reference in New Issue
Block a user