Reorganize error check procedures

This commit is contained in:
gingerBill
2022-02-28 12:45:19 +00:00
parent ab9d1f99fd
commit 37bba4c0a6
+22 -25
View File
@@ -17,6 +17,23 @@ type_assertion_trap :: proc "contextless" () -> ! {
}
bounds_check_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, index, count: int) {
bounds_check_error(file_path, line, column, index, count)
}
slice_expr_error_hi_loc :: #force_inline proc "contextless" (using loc := #caller_location, hi: int, len: int) {
slice_expr_error_hi(file_path, line, column, hi, len)
}
slice_expr_error_lo_hi_loc :: #force_inline proc "contextless" (using loc := #caller_location, lo, hi: int, len: int) {
slice_expr_error_lo_hi(file_path, line, column, lo, hi, len)
}
dynamic_array_expr_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, low, high, max: int) {
dynamic_array_expr_error(file_path, line, column, low, high, max)
}
when ODIN_FOREIGN_ERROR_PROCEDURES {
foreign {
bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) ---
@@ -29,12 +46,8 @@ when ODIN_FOREIGN_ERROR_PROCEDURES {
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
@@ -203,6 +216,10 @@ type_assertion_check2 :: proc "contextless" (ok: bool, file: string, line, colum
}
handle_error(file, line, column, from, to, from_data)
}
}
// `make` related procedures below
make_slice_error_loc :: #force_inline proc "contextless" (loc := #caller_location, len: int) {
@@ -219,7 +236,7 @@ make_slice_error_loc :: #force_inline proc "contextless" (loc := #caller_locatio
handle_error(loc, len)
}
make_dynamic_array_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, len, cap: int) {
make_dynamic_array_error_loc :: #force_inline proc "contextless" (loc := #caller_location, len, cap: int) {
if 0 <= len && len <= cap {
return
}
@@ -248,23 +265,3 @@ make_map_expr_error_loc :: #force_inline proc "contextless" (loc := #caller_loca
}
handle_error(loc, cap)
}
}
bounds_check_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, index, count: int) {
bounds_check_error(file_path, line, column, index, count)
}
slice_expr_error_hi_loc :: #force_inline proc "contextless" (using loc := #caller_location, hi: int, len: int) {
slice_expr_error_hi(file_path, line, column, hi, len)
}
slice_expr_error_lo_hi_loc :: #force_inline proc "contextless" (using loc := #caller_location, lo, hi: int, len: int) {
slice_expr_error_lo_hi(file_path, line, column, lo, hi, len)
}
dynamic_array_expr_error_loc :: #force_inline proc "contextless" (using loc := #caller_location, low, high, max: int) {
dynamic_array_expr_error(file_path, line, column, low, high, max)
}