From fb3d73cb204e886e0d716f529a64d9549f43c36d Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 28 May 2019 12:52:20 +0100 Subject: [PATCH] Make core library use `a.. (r: rune, multiple_bytes: bool, if len(s) < 2 { return; } - for i in 0..len(s)-1 { + for i in 0.. 7 { return; @@ -262,7 +262,7 @@ unquote_char :: proc(s: string, quote: byte) -> (r: rune, multiple_bytes: bool, return; } - for i in 0..count-1 { + for i in 0.. Marshal_Error { case Type_Info_Array: write_byte(b, '['); - for i in 0..info.count-1 { + for i in 0.. 0 do write_string(b, ", "); data := uintptr(v.data) + uintptr(i*info.elem_size); @@ -155,7 +155,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error { case Type_Info_Dynamic_Array: write_byte(b, '['); array := cast(^mem.Raw_Dynamic_Array)v.data; - for i in 0..array.len-1 { + for i in 0.. 0 do write_string(b, ", "); data := uintptr(array.data) + uintptr(i*info.elem_size); @@ -166,7 +166,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error { case Type_Info_Slice: write_byte(b, '['); slice := cast(^mem.Raw_Slice)v.data; - for i in 0..slice.len-1 { + for i in 0.. 0 do write_string(b, ", "); data := uintptr(slice.data) + uintptr(i*info.elem_size); @@ -188,7 +188,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error { entry_type := ed.elem.variant.(Type_Info_Struct); entry_size := ed.elem_size; - for i in 0..entries.len-1 { + for i in 0.. 0 do write_string(b, ", "); data := uintptr(entries.data) + uintptr(i*entry_size); diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index c75cbba27..de5e7a27c 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -336,7 +336,7 @@ _arg_number :: proc(fi: ^Info, arg_index: int, format: string, offset, arg_count parse_arg_number :: proc(format: string) -> (int, int, bool) { if len(format) < 3 do return 0, 1, false; - for i in 1..len(format)-1 { + for i in 1.. 0 && space do strings.write_byte(fi.buf, ' '); char_set := __DIGITS_UPPER; if verb == 'x' do char_set = __DIGITS_LOWER; @@ -859,7 +859,7 @@ fmt_bit_set :: proc(fi: ^Info, v: any, name: string = "") { e, is_enum := et.variant.(runtime.Type_Info_Enum); commas := 0; - loop: for i in 0 .. bit_size-1 { + loop: for i in 0 ..< bit_size { if bits & (1< 0 do strings.write_string(fi.buf, ", "); - if hash do for in 0..fi.indent-1 do strings.write_byte(fi.buf, '\t'); + if hash do for in 0.. 0 do strings.write_string(fi.buf, ", "); data := uintptr(v.data) + uintptr(i*info.elem_size); @@ -1098,7 +1098,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { strings.write_byte(fi.buf, '['); defer strings.write_byte(fi.buf, ']'); array := cast(^mem.Raw_Dynamic_Array)v.data; - for i in 0..array.len-1 { + for i in 0.. 0 do strings.write_string(fi.buf, ", "); data := uintptr(array.data) + uintptr(i*info.elem_size); @@ -1112,7 +1112,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { } strings.write_byte(fi.buf, '<'); defer strings.write_byte(fi.buf, '>'); - for i in 0..info.count-1 { + for i in 0.. 0 do strings.write_string(fi.buf, ", "); data := uintptr(v.data) + uintptr(i*info.elem_size); @@ -1128,7 +1128,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { strings.write_byte(fi.buf, '['); defer strings.write_byte(fi.buf, ']'); slice := cast(^mem.Raw_Slice)v.data; - for i in 0..slice.len-1 { + for i in 0.. 0 do strings.write_string(fi.buf, ", "); data := uintptr(slice.data) + uintptr(i*info.elem_size); @@ -1155,7 +1155,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { entry_type := ed.elem.variant.(runtime.Type_Info_Struct); entry_size := ed.elem_size; - for i in 0..entries.len-1 { + for i in 0.. 0 do strings.write_string(fi.buf, ", "); data := uintptr(entries.data) + uintptr(i*entry_size); @@ -1194,7 +1194,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { for _, i in info.names { if !hash && i > 0 do strings.write_string(fi.buf, ", "); if hash { - for in 0..fi.indent-1 { + for in 0.. E { res: E; - for i in 0..N-1 { + for i in 0.. T { identity :: proc($T: typeid/[$N][N]$E) -> T { m: T; - for i in 0..N-1 do m[i][i] = E(1); + for i in 0.. M { - for j in 0..N-1 { - for i in 0..N-1 { + for j in 0.. M { mat3_mul :: proc(a, b: Mat3) -> Mat3 { c: Mat3; - for j in 0..2 { - for i in 0..2 { + for j in 0..<3 { + for i in 0..<3 { c[j][i] = a[0][i]*b[j][0] + a[1][i]*b[j][1] + a[2][i]*b[j][2]; @@ -325,8 +325,8 @@ mat3_mul :: proc(a, b: Mat3) -> Mat3 { mat4_mul :: proc(a, b: Mat4) -> Mat4 { c: Mat4; - for j in 0..3 { - for i in 0..3 { + for j in 0..<4 { + for i in 0..<4 { c[j][i] = a[0][i]*b[j][0] + a[1][i]*b[j][1] + a[2][i]*b[j][2] + diff --git a/core/runtime/core.odin b/core/runtime/core.odin index 8b6fc7319..50a221a8c 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -892,7 +892,7 @@ __dynamic_map_reserve :: proc(using header: Map_Header, cap: int, loc := #caller old_len := len(m.hashes); __slice_resize(&m.hashes, cap, m.entries.allocator, loc); - for i in old_len..len(m.hashes)-1 do m.hashes[i] = -1; + for i in old_len.. int) { for { init_swap, prev_swap := -1, -1; - for j in init_j..last_j-1 { + for j in init_j.. 0 { array[j], array[j+1] = array[j+1], array[j]; prev_swap = j; @@ -34,7 +34,7 @@ bubble_sort :: proc(array: $A/[]$T) { for { init_swap, prev_swap := -1, -1; - for j in init_j..last_j-1 { + for j in init_j.. array[j+1] { array[j], array[j+1] = array[j+1], array[j]; prev_swap = j; @@ -106,7 +106,7 @@ merge_sort_proc :: proc(array: $A/[]$T, f: proc(T, T) -> int) { merge_slices :: proc(arr1, arr2, out: A, f: proc(T, T) -> int) { N1, N2 := len(arr1), len(arr2); i, j := 0, 0; - for k in 0..N1+N2-1 { + for k in 0.. int) { a, b, m, M := N/2, N, 1, _log2(N); for i in 0..M { - for j in 0..a-1 { + for j in 0.. 0 { add_bytes(&b, '.'); - for i in 0..prec-1 { + for i in 0.. int { n, m := 0, len(d); loop: for r in s { switch r { - case 0.._surr1-1, _surr3 .. _surr_self-1: + case 0..<_surr1, _surr3 ..< _surr_self: if m+1 < n do break loop; d[n] = u16(r); n += 1; @@ -59,7 +59,7 @@ encode_string :: proc(d: []u16, s: string) -> int { n, m := 0, len(d); loop: for r in s { switch r { - case 0.._surr1-1, _surr3 .. _surr_self-1: + case 0..<_surr1, _surr3 ..< _surr_self: if m+1 < n do break loop; d[n] = u16(r); n += 1;