mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-21 13:55:45 +00:00
Merge branch 'master' of github.com:odin-lang/Odin
This commit is contained in:
@@ -403,7 +403,9 @@ unordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_loca
|
||||
@builtin
|
||||
ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) {
|
||||
bounds_check_error_loc(loc, index, len(array));
|
||||
copy(array[index:], array[index+1:]);
|
||||
if index+1 < len(array) {
|
||||
copy(array[index:], array[index+1:]);
|
||||
}
|
||||
pop(array);
|
||||
}
|
||||
|
||||
|
||||
@@ -285,8 +285,25 @@ bounds_check_error :: proc "contextless" (file: string, line, column: int, index
|
||||
handle_error(file, line, column, index, count);
|
||||
}
|
||||
|
||||
slice_expr_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
||||
if 0 <= lo && lo <= hi && hi <= len do return;
|
||||
slice_expr_error_hi :: proc "contextless" (file: string, line, column: int, hi: int, len: int) {
|
||||
if 0 <= hi && hi <= len do return;
|
||||
handle_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
||||
fd := os.stderr;
|
||||
print_caller_location(fd, Source_Code_Location{file, line, column, "", 0});
|
||||
os.write_string(fd, " Invalid slice indices: ");
|
||||
print_i64(fd, i64(lo));
|
||||
os.write_string(fd, ":");
|
||||
print_i64(fd, i64(hi));
|
||||
os.write_string(fd, ":");
|
||||
print_i64(fd, i64(len));
|
||||
os.write_byte(fd, '\n');
|
||||
debug_trap();
|
||||
}
|
||||
handle_error(file, line, column, 0, hi, len);
|
||||
}
|
||||
|
||||
slice_expr_error_lo_hi :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
||||
if 0 <= lo && lo < len && lo <= hi && hi <= len do return;
|
||||
handle_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
||||
fd := os.stderr;
|
||||
print_caller_location(fd, Source_Code_Location{file, line, column, "", 0});
|
||||
@@ -343,8 +360,12 @@ bounds_check_error_loc :: inline proc "contextless" (using loc := #caller_locati
|
||||
bounds_check_error(file_path, int(line), int(column), index, count);
|
||||
}
|
||||
|
||||
slice_expr_error_loc :: inline proc "contextless" (using loc := #caller_location, lo, hi: int, len: int) {
|
||||
slice_expr_error(file_path, int(line), int(column), lo, hi, len);
|
||||
slice_expr_error_hi_loc :: inline proc "contextless" (using loc := #caller_location, hi: int, len: int) {
|
||||
slice_expr_error_hi(file_path, int(line), int(column), hi, len);
|
||||
}
|
||||
|
||||
slice_expr_error_lo_hi_loc :: inline proc "contextless" (using loc := #caller_location, lo, hi: int, len: int) {
|
||||
slice_expr_error_lo_hi(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) {
|
||||
|
||||
@@ -211,10 +211,15 @@ append_float :: proc(buf: []byte, f: f64, fmt: byte, prec, bit_size: int) -> str
|
||||
|
||||
quote :: proc(buf: []byte, s: string) -> string {
|
||||
write_byte :: inline proc(buf: []byte, i: ^int, bytes: ..byte) {
|
||||
if i^ >= len(buf) do return;
|
||||
n := copy(buf[i^:], bytes[:]);
|
||||
i^ += n;
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
return "";
|
||||
}
|
||||
|
||||
c :: '"';
|
||||
i := 0;
|
||||
|
||||
@@ -230,8 +235,10 @@ quote :: proc(buf: []byte, s: string) -> string {
|
||||
write_byte(buf, &i, digits[s[0]>>4]);
|
||||
write_byte(buf, &i, digits[s[0]&0xf]);
|
||||
}
|
||||
s2 := quote_rune(buf[i:], r);
|
||||
i += len(s2);
|
||||
if i < len(buf) {
|
||||
s2 := quote_rune(buf[i:], r);
|
||||
i += len(s2);
|
||||
}
|
||||
}
|
||||
write_byte(buf, &i, c);
|
||||
return string(buf[:i]);
|
||||
@@ -239,17 +246,27 @@ quote :: proc(buf: []byte, s: string) -> string {
|
||||
|
||||
quote_rune :: proc(buf: []byte, r: rune) -> string {
|
||||
write_byte :: inline proc(buf: []byte, i: ^int, bytes: ..byte) {
|
||||
n := copy(buf[i^:], bytes[:]);
|
||||
i^ += n;
|
||||
if i^ < len(buf) {
|
||||
n := copy(buf[i^:], bytes[:]);
|
||||
i^ += n;
|
||||
}
|
||||
}
|
||||
write_string :: inline proc(buf: []byte, i: ^int, s: string) {
|
||||
n := copy(buf[i^:], cast([]byte)s);
|
||||
i^ += n;
|
||||
if i^ < len(buf) {
|
||||
n := copy(buf[i^:], cast([]byte)s);
|
||||
i^ += n;
|
||||
}
|
||||
}
|
||||
write_rune :: inline proc(buf: []byte, i: ^int, r: rune) {
|
||||
b, w := utf8.encode_rune(r);
|
||||
n := copy(buf[i^:], b[:w]);
|
||||
i^ += n;
|
||||
if i^ < len(buf) {
|
||||
b, w := utf8.encode_rune(r);
|
||||
n := copy(buf[i^:], b[:w]);
|
||||
i^ += n;
|
||||
}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
return "";
|
||||
}
|
||||
|
||||
i := 0;
|
||||
|
||||
Reference in New Issue
Block a user