mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Reorganize error check procedures
This commit is contained in:
@@ -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 {
|
when ODIN_FOREIGN_ERROR_PROCEDURES {
|
||||||
foreign {
|
foreign {
|
||||||
bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) ---
|
bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) ---
|
||||||
@@ -29,13 +46,9 @@ 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) ---
|
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_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) ---
|
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 {
|
} else {
|
||||||
|
bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) {
|
||||||
bounds_check_error :: proc "contextless" (file: string, line, column: i32, index, count: int) {
|
|
||||||
if 0 <= index && index < count {
|
if 0 <= index && index < count {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -49,9 +62,9 @@ bounds_check_error :: proc "contextless" (file: string, line, column: i32, index
|
|||||||
bounds_trap()
|
bounds_trap()
|
||||||
}
|
}
|
||||||
handle_error(file, line, column, index, count)
|
handle_error(file, line, column, index, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
slice_handle_error :: proc "contextless" (file: string, line, column: i32, lo, hi: int, len: int) -> ! {
|
slice_handle_error :: proc "contextless" (file: string, line, column: i32, lo, hi: int, len: int) -> ! {
|
||||||
print_caller_location(Source_Code_Location{file, line, column, ""})
|
print_caller_location(Source_Code_Location{file, line, column, ""})
|
||||||
print_string(" Invalid slice indices ")
|
print_string(" Invalid slice indices ")
|
||||||
print_i64(i64(lo))
|
print_i64(i64(lo))
|
||||||
@@ -61,9 +74,9 @@ slice_handle_error :: proc "contextless" (file: string, line, column: i32, lo, h
|
|||||||
print_i64(i64(len))
|
print_i64(i64(len))
|
||||||
print_byte('\n')
|
print_byte('\n')
|
||||||
bounds_trap()
|
bounds_trap()
|
||||||
}
|
}
|
||||||
|
|
||||||
multi_pointer_slice_handle_error :: proc "contextless" (file: string, line, column: i32, lo, hi: int) -> ! {
|
multi_pointer_slice_handle_error :: proc "contextless" (file: string, line, column: i32, lo, hi: int) -> ! {
|
||||||
print_caller_location(Source_Code_Location{file, line, column, ""})
|
print_caller_location(Source_Code_Location{file, line, column, ""})
|
||||||
print_string(" Invalid slice indices ")
|
print_string(" Invalid slice indices ")
|
||||||
print_i64(i64(lo))
|
print_i64(i64(lo))
|
||||||
@@ -71,31 +84,31 @@ multi_pointer_slice_handle_error :: proc "contextless" (file: string, line, colu
|
|||||||
print_i64(i64(hi))
|
print_i64(i64(hi))
|
||||||
print_byte('\n')
|
print_byte('\n')
|
||||||
bounds_trap()
|
bounds_trap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
multi_pointer_slice_expr_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) {
|
||||||
if lo <= hi {
|
if lo <= hi {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
multi_pointer_slice_handle_error(file, line, column, lo, hi)
|
multi_pointer_slice_handle_error(file, line, column, lo, hi)
|
||||||
}
|
}
|
||||||
|
|
||||||
slice_expr_error_hi :: proc "contextless" (file: string, line, column: i32, hi: int, len: int) {
|
slice_expr_error_hi :: proc "contextless" (file: string, line, column: i32, hi: int, len: int) {
|
||||||
if 0 <= hi && hi <= len {
|
if 0 <= hi && hi <= len {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
slice_handle_error(file, line, column, 0, hi, len)
|
slice_handle_error(file, line, column, 0, hi, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
slice_expr_error_lo_hi :: proc "contextless" (file: string, line, column: i32, lo, hi: int, len: int) {
|
slice_expr_error_lo_hi :: proc "contextless" (file: string, line, column: i32, lo, hi: int, len: int) {
|
||||||
if 0 <= lo && lo <= len && lo <= hi && hi <= len {
|
if 0 <= lo && lo <= len && lo <= hi && hi <= len {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
slice_handle_error(file, line, column, lo, hi, len)
|
slice_handle_error(file, line, column, lo, hi, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic_array_expr_error :: proc "contextless" (file: string, line, column: i32, low, high, max: int) {
|
dynamic_array_expr_error :: proc "contextless" (file: string, line, column: i32, low, high, max: int) {
|
||||||
if 0 <= low && low <= high && high <= max {
|
if 0 <= low && low <= high && high <= max {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -111,10 +124,10 @@ dynamic_array_expr_error :: proc "contextless" (file: string, line, column: i32,
|
|||||||
bounds_trap()
|
bounds_trap()
|
||||||
}
|
}
|
||||||
handle_error(file, line, column, low, high, max)
|
handle_error(file, line, column, low, high, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32, row_index, column_index, row_count, column_count: int) {
|
matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32, row_index, column_index, row_count, column_count: int) {
|
||||||
if 0 <= row_index && row_index < row_count &&
|
if 0 <= row_index && row_index < row_count &&
|
||||||
0 <= column_index && column_index < column_count {
|
0 <= column_index && column_index < column_count {
|
||||||
return
|
return
|
||||||
@@ -134,10 +147,10 @@ matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32
|
|||||||
bounds_trap()
|
bounds_trap()
|
||||||
}
|
}
|
||||||
handle_error(file, line, column, row_index, column_index, row_count, column_count)
|
handle_error(file, line, column, row_index, column_index, row_count, column_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid) {
|
type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid) {
|
||||||
if ok {
|
if ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -151,9 +164,9 @@ type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column
|
|||||||
type_assertion_trap()
|
type_assertion_trap()
|
||||||
}
|
}
|
||||||
handle_error(file, line, column, from, to)
|
handle_error(file, line, column, from, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
type_assertion_check2 :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid, from_data: rawptr) {
|
type_assertion_check2 :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid, from_data: rawptr) {
|
||||||
if ok {
|
if ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -202,9 +215,13 @@ type_assertion_check2 :: proc "contextless" (ok: bool, file: string, line, colum
|
|||||||
type_assertion_trap()
|
type_assertion_trap()
|
||||||
}
|
}
|
||||||
handle_error(file, line, column, from, to, from_data)
|
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) {
|
make_slice_error_loc :: #force_inline proc "contextless" (loc := #caller_location, len: int) {
|
||||||
if 0 <= len {
|
if 0 <= len {
|
||||||
return
|
return
|
||||||
@@ -219,7 +236,7 @@ make_slice_error_loc :: #force_inline proc "contextless" (loc := #caller_locatio
|
|||||||
handle_error(loc, len)
|
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 {
|
if 0 <= len && len <= cap {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -248,23 +265,3 @@ make_map_expr_error_loc :: #force_inline proc "contextless" (loc := #caller_loca
|
|||||||
}
|
}
|
||||||
handle_error(loc, cap)
|
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)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user