Add runtime messages for make for the len/cap parameters

This commit is contained in:
gingerBill
2018-08-08 13:04:40 +01:00
committed by Ginger Bill
parent 835d7dcab2
commit 3a1a7b40f9
2 changed files with 52 additions and 5 deletions
+42
View File
@@ -293,6 +293,7 @@ dynamic_array_expr_error :: proc "contextless" (file: string, line, column: int,
debug_trap();
}
type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: int, from, to: typeid) {
if ok do return;
@@ -318,6 +319,47 @@ slice_expr_error_loc :: inline proc "contextless" (using loc := #caller_location
slice_expr_error(file_path, int(line), int(column), lo, hi, len);
}
dynamic_array_expr_error_loc :: inline proc "contextless" (using loc := #caller_location, low, high, max: int) {
dynamic_array_expr_error(file_path, int(line), int(column), low, high, max);
}
make_slice_error_loc :: inline proc "contextless" (using loc := #caller_location, len: int) {
if 0 < len do return;
fd := os.stderr;
__print_caller_location(fd, loc);
os.write_string(fd, " Invalid slice length for make: ");
__print_i64(fd, i64(len));
os.write_byte(fd, '\n');
debug_trap();
}
make_dynamic_array_error_loc :: inline proc "contextless" (using loc := #caller_location, len, cap: int) {
if 0 < len && len < cap do return;
fd := os.stderr;
__print_caller_location(fd, loc);
os.write_string(fd, " Invalid dynamic array parameters for make: ");
__print_i64(fd, i64(len));
os.write_byte(fd, ':');
__print_i64(fd, i64(cap));
os.write_byte(fd, '\n');
debug_trap();
}
map_expr_error_loc :: inline proc "contextless" (using loc := #caller_location, cap: int) {
if 0 < cap do return;
fd := os.stderr;
__print_caller_location(fd, loc);
os.write_string(fd, " Invalid map capacity for make: ");
__print_i64(fd, i64(cap));
os.write_byte(fd, '\n');
debug_trap();
}
@(default_calling_convention = "c")