From 78fd11eef1d5480830ee982c52d0bd5c07d7d839 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 1 Jul 2021 11:29:19 -0500 Subject: [PATCH] initial version of new and better str_format --- bin/onyx | Bin 409160 -> 409160 bytes core/alloc/logging.onyx | 2 +- core/conv.onyx | 277 +++++++++++++++++++++++++ core/io/writer.onyx | 4 +- core/std.onyx | 4 +- core/stdio.onyx | 4 +- core/type_info/helper.onyx | 2 +- modules/immediate_mode/gl_utils.onyx | 4 +- src/onyxwasm.c | 7 + tests/aoc-2020/day1.onyx | 2 +- tests/aoc-2020/day10.onyx | 4 +- tests/aoc-2020/day11.onyx | 2 +- tests/aoc-2020/day12.onyx | 2 +- tests/aoc-2020/day13.onyx | 8 +- tests/aoc-2020/day14.onyx | 2 +- tests/aoc-2020/day15.onyx | 2 +- tests/aoc-2020/day16.onyx | 4 +- tests/aoc-2020/day17.onyx | 2 +- tests/aoc-2020/day18.onyx | 2 +- tests/aoc-2020/day19.onyx | 2 +- tests/aoc-2020/day2.onyx | 2 +- tests/aoc-2020/day20.onyx | 4 +- tests/aoc-2020/day21.onyx | 6 +- tests/aoc-2020/day22.onyx | 4 +- tests/aoc-2020/day23.onyx | 4 +- tests/aoc-2020/day24.onyx | 4 +- tests/aoc-2020/day25.onyx | 2 +- tests/aoc-2020/day3.onyx | 2 +- tests/aoc-2020/day4.onyx | 2 +- tests/aoc-2020/day5.onyx | 4 +- tests/aoc-2020/day6.onyx | 2 +- tests/aoc-2020/day7.onyx | 6 +- tests/aoc-2020/day8.onyx | 2 +- tests/aoc-2020/day9.onyx | 4 +- tests/array_struct_robustness.onyx | 2 +- tests/baked_parameters.onyx | 4 +- tests/better_field_accesses.onyx | 2 +- tests/defer_with_continue.onyx | 16 +- tests/float_parsing | 2 +- tests/i32map.onyx | 2 +- tests/lazy_iterators.onyx | 2 +- tests/multiple_returns_robustness.onyx | 2 +- tests/named_arguments_test.onyx | 10 +- tests/new_printf | 1 + tests/new_printf.onyx | 7 + tests/new_struct_behaviour.onyx | 4 +- tests/operator_overload.onyx | 12 +- tests/polymorphic_array_lengths.onyx | 2 +- tests/struct_robustness.onyx | 26 +-- tests/vararg_test.onyx | 2 +- 50 files changed, 386 insertions(+), 94 deletions(-) create mode 100644 tests/new_printf create mode 100644 tests/new_printf.onyx diff --git a/bin/onyx b/bin/onyx index 61def4067d2fce92f8f597256dd7c8137d717e57..018c527e86e83b881220b65689209e054c44cecf 100755 GIT binary patch delta 15595 zcmb`Odt6jy{`lt%=OCKNn4+ktm}6qzFi}ZSK~aaq#Kc?P#_(E{XsDRzprAR9C>r`; z*+!eSR z=kr|70cw1)HNM!YD6NH&p_|lYWIT3@)~|WiufZo%*2@`Mf30;{S0ng*g^xMSvaL~d z_k@ar&mB9`zv1lI=g0kd#2XcxUfvrqdY(4n<+}NUji?X%=_Xt0&2x*p-2Z5o`!#o$ z`^^zAYEOt;VA{7jZx{Tiz23Ga~NO z65XdVBBp7Y&)sc&#J!PPsk?Ae#2MY(vc`SS)QIitv~S#>pNZ(uN_)-i`#j>2o3u@0 z)uo6o+9LPvOA%Ym+MDj~-$%GwX@lK=kP*8hwU69mBlRP?mhaYX(#L69l{=%QKG&fB z=UeM*4Q;BsXM6p5O`GL@H&!>_q%9F=y6bbb=S7lL|D*PfyV0tTYo>kcPVJ-D4%SY) zTj%KGZ_y5j*(>x3+7a>M3O!kyBrdGb2Wel3jw|&?wZDnquGEhXx4H77Tv@tjr3lF5 zJs5*b=htb@w>{7OXWs z=BJ}X*=oIG^eYX)yg$5VQF-4M-3s&`w+--1S(fR_Nyu;&S`$6XyZdEEaiKNY6kYOF zOOq+2oh6nP=rPTo>k+E{_hNg2-c3sp2MhGr0na?EVMxqAkm-Co)0u8f@QgJ3q|KFX zwb@+5i-YNdN)$@7G*5*1wLl-E4Hv1a^|tL7lQYAWZA}jLfDTnD<2Hx~R_ooh<6`@2 zy_c3GUR$jv_i=fpjP7d6bUmCf!L={}e|Tbh1Z3DRrPhF);Pj_CP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-14,7 +14,7 @@ logging_allocator_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: res := allocator.func(allocator.data, aa, size, align, oldptr); use package core { printf } - printf("%s with size %i, align %i, oldptr %p returns %p\n", + printf("{} with size {}, align {}, oldptr {} returns {}\n", Allocation_Action_Strings[cast(u32) aa], size, align, oldptr, res); return res; diff --git a/core/conv.onyx b/core/conv.onyx index fe93b1f6..cd020b69 100644 --- a/core/conv.onyx +++ b/core/conv.onyx @@ -157,6 +157,7 @@ i64_to_str :: (n: i64, base: u64, buf: [] u8, min_length := 0) -> str { return str.{ data = c + 1, count = len }; } +#if false { @Hack @Cleanup // This is a big hack but it will work for now f64_to_str :: (f: f64, buf: [] u8) -> str { f *= 10000.0; @@ -181,7 +182,281 @@ f64_to_str :: (f: f64, buf: [] u8) -> str { return str.{ buf.data, len }; } +} + +// This is better than the above version, but still relies on converting the integer +// part of the float to an integer, which could overflow. +f64_to_str :: (f: f64, buf: [] u8) -> str { + math :: package core.math + + len := 0; + + if f < 0 { + f = -f; + buf[0] = #char "-"; + len += 1; + } + + dec_part := f - math.trunc(f); + int_part := f - dec_part; + dec_part = math.abs(dec_part); + + s1 := i64_to_str(~~int_part, 10, buf); + for i: 0 .. s1.count do buf.data[i + len] = s1.data[i]; + buf.data[s1.count + len] = #char "."; + len += s1.count + 1; + + digits := "0123456789"; + + decimals :: 4; + for i: decimals { + dec_part *= 10; + v := math.trunc(dec_part); + dec_part -= v; + + buf.data[len + i] = digits[cast(i32) v]; + } + len += decimals; + + return str.{ buf.data, len }; +} + +str_format :: (format: str, buffer: [] u8, va: ..any) -> str { + return str_format_va(format, buffer, ~~va); +} + +str_format_va :: (format: str, buffer: [] u8, va: [] any) -> str { + @Cleanup + Output :: struct { + data: ^u8; + count: u32; + capacity: u32; + + write :: #match { + (use output: ^Output, c: u8) { + if count >= capacity do return; + + data[count] = c; + count += 1; + }, + + (use output: ^Output, s: str) { + for c: s do output->write(c); + } + } + } + + output := Output.{ buffer.data, 0, buffer.count }; + + Format :: struct { + digits_after_decimal := cast(u32) 4; + } + formatting := Format.{}; + + vararg_index := 0; + + while i := 0; i < format.count { + defer i += 1; + + ch := format[i]; + + if ch == #char "{" { + if format[i + 1] == #char "{" { + output->write(#char "{"); + i += 1; + continue; + } + + while true { + i += 1; + ch = format[i]; + + switch ch { + case #char "." { + i += 1; + + digits := 0; + while format[i] >= #char "0" && format[i] <= #char "9" { + digits *= 10; + digits += ~~(format[i] - #char "0"); + i += 1; + } + + formatting.digits_after_decimal = digits; + } + case #default do break break; + } + } + } + + if ch == #char "}" { + if format[i + 1] == #char "}" { + output->write(#char "}"); + i += 1; + continue; + } + + arg := va[vararg_index]; + vararg_index += 1; + print_any(^output, arg); + + continue; + } + + output->write(ch); + } + + return .{ output.data, output.count }; + + print_any :: (output: ^Output, v: any) { + use package builtin.type_info + array :: package core.array + + switch v.type { + case bool { + value := *(cast(^bool) v.data); + if value do output->write("true"); + else do output->write("false"); + } + + case i32, u32 { + value := *(cast(^i32) v.data); + + ibuf : [128] u8; + istr := i64_to_str(~~value, 10, ~~ibuf); + output->write(istr); + } + + case i64, u64 { + value := *(cast(^i64) v.data); + + ibuf : [128] u8; + istr := i64_to_str(~~value, 10, ~~ibuf); + output->write(istr); + } + + case f32 { + value := *(cast(^f32) v.data); + + fbuf : [128] u8; + fstr := f64_to_str(~~value, ~~fbuf); + output->write(fstr); + } + + case f64 { + value := *(cast(^f64) v.data); + + fbuf : [128] u8; + fstr := f64_to_str(~~value, ~~fbuf); + output->write(fstr); + } + + case str do output->write(*(cast(^str) v.data)); + + case rawptr { + value := *(cast(^rawptr) v.data); + + ibuf : [128] u8; + istr := i64_to_str(~~value, 16, ~~ibuf); + output->write(istr); + } + + case #default { + info := get_type_info(v.type); + + if info.kind == .Struct { + s := cast(^Type_Info_Struct) info; + + if s.name.count > 0 do output->write(s.name); + output->write(" { "); + + for ^member: s.members { + if member != s.members.data do output->write(", "); + + output->write(member.name); + output->write(" = "); + + print_any(output, .{ ~~(cast(^u8) v.data + member.offset), member.type }); + } + + output->write(" }"); + } + + if info.kind == .Function do output->write(""); + + if info.kind == .Pointer { + value := *(cast(^rawptr) v.data); + + ibuf : [128] u8; + istr := i64_to_str(~~value, 16, ~~ibuf); + output->write(istr); + } + + // This assumes that the following type_info kinds are basically the same. + if info.kind == .Dynamic_Array || info.kind == .Slice || info.kind == .Variadic_Argument { + output->write("[ "); + + a := cast(^Type_Info_Dynamic_Array) info; + arr := cast(^array.Untyped_Array) v.data; + data := arr.data; + count := arr.count; + + for i: count { + if i != 0 do output->write(", "); + + print_any(output, .{ ~~(cast(^u8) data + get_type_info(a.of).size * i), a.of }); + } + + output->write(" ]"); + } + + if info.kind == .Array { + output->write("[ "); + + a := cast(^Type_Info_Array) info; + data := v.data; + + for i: a.count { + if i != 0 do output->write(", "); + + print_any(output, .{ ~~(cast(^u8) data + get_type_info(a.of).size * i), a.of }); + } + + output->write(" ]"); + } + + if info.kind == .Enum { + e := cast(^Type_Info_Enum) info; + + value: u64; + switch e.backing_type { + case i8, u8 do value = cast(u64) *(cast(^u8) v.data); + case i16, u16 do value = cast(u64) *(cast(^u16) v.data); + case i32, u32 do value = cast(u64) *(cast(^u32) v.data); + case i64, u64 do value = cast(u64) *(cast(^u64) v.data); + case #default do assert(false, "Bad enum backing type"); + } + + { + for ^member: e.members { + if value == member.value { + output->write(member.name); + break break; + } + } + + output->write("UNKNOWN"); + } + } + } + } + } +} + + +// Old % style print formatting +#if false { str_format :: (format: str, buffer: [] u8, va: ...) -> str { return str_format_va(format, buffer, va); } @@ -306,3 +581,5 @@ str_format_va :: (format: str, buffer: [] u8, va: vararg) -> str { return str.{ ~~buffer.data, len }; } +} + diff --git a/core/io/writer.onyx b/core/io/writer.onyx index 0bb40c2b..da730eae 100644 --- a/core/io/writer.onyx +++ b/core/io/writer.onyx @@ -75,10 +75,10 @@ write_range :: (use writer: ^Writer, r: range, sep := " ") { } } -write_format :: (use writer: ^Writer, format: str, va: ...) { +write_format :: (use writer: ^Writer, format: str, va: ..any) { // POTENTIAL BUG: this buffer will need to be bigger (or dynamic). buffer: [2048] u8; - write_str(writer, conv.str_format_va(format, ~~buffer, va)); + write_str(writer, conv.str_format_va(format, ~~buffer, ~~va)); } write_escaped_str :: (use writer: ^Writer, s: str) { diff --git a/core/std.onyx b/core/std.onyx index 0d12896c..139e13c6 100644 --- a/core/std.onyx +++ b/core/std.onyx @@ -33,6 +33,8 @@ package core #load "./runtime/build_opts" #load "./runtime/common" +#load "./type_info/helper" + #private_file runtime :: package runtime #if runtime.Runtime == runtime.Runtime_Wasi { #load "./runtime/wasi" @@ -40,8 +42,6 @@ package core #load "./wasi/env" #load "./wasi/clock" #load "./io/file" - - #load "./type_info/helper" } #if runtime.Runtime == runtime.Runtime_Js { diff --git a/core/stdio.onyx b/core/stdio.onyx index 90d4680e..51c9adea 100644 --- a/core/stdio.onyx +++ b/core/stdio.onyx @@ -29,9 +29,9 @@ println :: (x: $T) { print("\n"); } -printf :: (format: str, va: ...) { +printf :: (format: str, va: ..any) { buffer: [2048] u8; - print(conv.str_format_va(format, buffer[0 .. 2048], va)); + print(conv.str_format_va(format, buffer[0 .. 2048], ~~va)); } // This works on both slices and arrays diff --git a/core/type_info/helper.onyx b/core/type_info/helper.onyx index d85a476d..faa0704b 100644 --- a/core/type_info/helper.onyx +++ b/core/type_info/helper.onyx @@ -49,7 +49,7 @@ write_type_name :: (writer: ^io.Writer, t: type_expr) { case .Array { arr := cast(^Type_Info_Array) info; - io.write_format(writer, "[%i] ", arr.count); + io.write_format(writer, "[{}] ", arr.count); write_type_name(writer, arr.of); } diff --git a/modules/immediate_mode/gl_utils.onyx b/modules/immediate_mode/gl_utils.onyx index fbf8c1e1..9abbcb49 100644 --- a/modules/immediate_mode/gl_utils.onyx +++ b/modules/immediate_mode/gl_utils.onyx @@ -52,7 +52,7 @@ Shader :: struct { success := true; if gl.getShaderParameter(shader, gl.COMPILE_STATUS) == 0 { - printf("Error compiling shader."); + println("Error compiling shader."); gl.printShaderInfoLog(shader); success = false; } @@ -68,7 +68,7 @@ Shader :: struct { success := true; if gl.getProgramParameter(program, gl.LINK_STATUS) == 0 { - printf("Error linking program."); + println("Error linking program."); gl.printProgramInfoLog(program); success = false; } diff --git a/src/onyxwasm.c b/src/onyxwasm.c index 47849049..60d5a3c8 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -3089,6 +3089,13 @@ static void emit_string_literal(OnyxWasmModule* mod, AstStrLit* strlit) { i8* strdata = bh_alloc_array(global_heap_allocator, i8, strlit->token->length + 1); i32 length = string_process_escape_seqs(strdata, strlit->token->text, strlit->token->length); + // Warning for having '%' in a string literal (because that probably is being used for a old print format) + /* + if (charset_contains((const char *) strdata, '%')) { + onyx_report_warning(strlit->token->pos, "Found string literal with '%%'"); + } + */ + if (bh_table_has(StrLitInfo, mod->string_literals, (char *) strdata)) { StrLitInfo sti = bh_table_get(StrLitInfo, mod->string_literals, (char *) strdata); strlit->addr = sti.addr; diff --git a/tests/aoc-2020/day1.onyx b/tests/aoc-2020/day1.onyx index d4728cae..eecdcddc 100644 --- a/tests/aoc-2020/day1.onyx +++ b/tests/aoc-2020/day1.onyx @@ -17,7 +17,7 @@ main :: (args: [] cstr) { for i: nums do for j: nums do for k: nums { if j + i + k == 2020 { - printf("Answer: %i\n", i * j * k); + printf("Answer: {}\n", i * j * k); // Break out of all of the loops break break break; diff --git a/tests/aoc-2020/day10.onyx b/tests/aoc-2020/day10.onyx index 61f942b6..81fa2746 100644 --- a/tests/aoc-2020/day10.onyx +++ b/tests/aoc-2020/day10.onyx @@ -47,6 +47,6 @@ main :: (args: [] cstr) { for i: 1 .. nums.count do diffs[nums[i] - nums[i - 1] - 1] += 1; diffs[2] += 1; - printf("Diff prod: %i\n", diffs[0] * diffs[2]); - printf("Arrangements: %l\n", count_ending_paths(nums)); + printf("Diff prod: {}\n", diffs[0] * diffs[2]); + printf("Arrangements: {}\n", count_ending_paths(nums)); } diff --git a/tests/aoc-2020/day11.onyx b/tests/aoc-2020/day11.onyx index af756dc5..40a5df5a 100644 --- a/tests/aoc-2020/day11.onyx +++ b/tests/aoc-2020/day11.onyx @@ -96,6 +96,6 @@ main :: (args: [] cstr) { occupied := 0; for s: gos.seats do if s == SeatState.Occupied do occupied += 1; - printf("Occupied: %i\n", occupied); + printf("Occupied: {}\n", occupied); } diff --git a/tests/aoc-2020/day12.onyx b/tests/aoc-2020/day12.onyx index 0dd6ff55..6269127d 100644 --- a/tests/aoc-2020/day12.onyx +++ b/tests/aoc-2020/day12.onyx @@ -67,5 +67,5 @@ main :: (args: [] cstr) { } } - printf("Ship distance: %i\n", math.abs(ship.x) + math.abs(ship.y)); + printf("Ship distance: {}\n", math.abs(ship.x) + math.abs(ship.y)); } diff --git a/tests/aoc-2020/day13.onyx b/tests/aoc-2020/day13.onyx index 1cfd7f59..97fe1603 100644 --- a/tests/aoc-2020/day13.onyx +++ b/tests/aoc-2020/day13.onyx @@ -82,11 +82,11 @@ main :: (args: [] cstr) { // } // result := take_bus * (depart - est); - // printf("Bus: %i\n", take_bus); - // printf("Depart at: %i\n", depart); - // printf("Result: %i\n", result); + // printf("Bus: {}\n", take_bus); + // printf("Depart at: {}\n", depart); + // printf("Result: {}\n", result); // Part 2 result := chinese_remainder_theorem(buses, rems); - printf("Result: %l\n", result); + printf("Result: {}\n", result); } diff --git a/tests/aoc-2020/day14.onyx b/tests/aoc-2020/day14.onyx index 4fff2311..78a16dc7 100644 --- a/tests/aoc-2020/day14.onyx +++ b/tests/aoc-2020/day14.onyx @@ -125,5 +125,5 @@ main :: (args: [] cstr) { s: u64 = 0; for e: mem.entries do s += e.value; - printf("Sum: %l\n", s); + printf("Sum: {}\n", s); } diff --git a/tests/aoc-2020/day15.onyx b/tests/aoc-2020/day15.onyx index 168ced9c..c5417d9b 100644 --- a/tests/aoc-2020/day15.onyx +++ b/tests/aoc-2020/day15.onyx @@ -40,5 +40,5 @@ main :: (args: [] cstr) { turn += 1; } - printf("2020th: %i\n", last_num); + printf("2020th: {}\n", last_num); } diff --git a/tests/aoc-2020/day16.onyx b/tests/aoc-2020/day16.onyx index 5228289d..1742a204 100644 --- a/tests/aoc-2020/day16.onyx +++ b/tests/aoc-2020/day16.onyx @@ -92,7 +92,7 @@ main :: (args: [] cstr) { } } - printf("Scanning error: %i\n", total_scanning_error); + printf("Scanning error: {}\n", total_scanning_error); cols_to_assign := array.make(u32, fields.count); defer array.free(^cols_to_assign); @@ -134,5 +134,5 @@ main :: (args: [] cstr) { if string.starts_with(field.name, "departure") do prod *= ~~my_ticket[field.column]; } - printf("Departure multiply: %l\n", prod); + printf("Departure multiply: {}\n", prod); } diff --git a/tests/aoc-2020/day17.onyx b/tests/aoc-2020/day17.onyx index 9839aa0c..6c6825f2 100644 --- a/tests/aoc-2020/day17.onyx +++ b/tests/aoc-2020/day17.onyx @@ -100,5 +100,5 @@ main :: (args: [] cstr) { active_count := 0; for ^cube_entry: cubes.entries do if cube_entry.value.alive do active_count += 1; - printf("Active count: %i\n", active_count); + printf("Active count: {}\n", active_count); } diff --git a/tests/aoc-2020/day18.onyx b/tests/aoc-2020/day18.onyx index 64512186..1d798105 100644 --- a/tests/aoc-2020/day18.onyx +++ b/tests/aoc-2020/day18.onyx @@ -73,5 +73,5 @@ main :: (args: [] cstr) { total += parse_expression_mul(^file); } - printf("Total: %l\n", total); + printf("Total: {}\n", total); } diff --git a/tests/aoc-2020/day19.onyx b/tests/aoc-2020/day19.onyx index 928e1d72..3327b85f 100644 --- a/tests/aoc-2020/day19.onyx +++ b/tests/aoc-2020/day19.onyx @@ -171,5 +171,5 @@ main :: (args: [] cstr) { if cyk_algorithm(^grammar, line) do valid_count += 1; } - printf("Valid count: %i\n", valid_count); + printf("Valid count: {}\n", valid_count); } diff --git a/tests/aoc-2020/day2.onyx b/tests/aoc-2020/day2.onyx index 1731a912..fca7b94f 100644 --- a/tests/aoc-2020/day2.onyx +++ b/tests/aoc-2020/day2.onyx @@ -35,5 +35,5 @@ main :: (args: [] cstr) { if count == 1 do valid += 1; } - printf("Number valid: %i\n", valid); + printf("Number valid: {}\n", valid); } diff --git a/tests/aoc-2020/day20.onyx b/tests/aoc-2020/day20.onyx index dafa71cc..c616f275 100644 --- a/tests/aoc-2020/day20.onyx +++ b/tests/aoc-2020/day20.onyx @@ -313,7 +313,7 @@ main :: (args: [] cstr) { } } - printf("Corner product: %l\n", prod); + printf("Corner product: {}\n", prod); grid : [12 * 12] u32; memory.set(^grid, 0, sizeof [12 * 12] u32); @@ -369,5 +369,5 @@ main :: (args: [] cstr) { safe_count := 0; for c: forest do if c == #char "#" do safe_count += 1; - printf("Safe count: %i\n", safe_count); + printf("Safe count: {}\n", safe_count); } diff --git a/tests/aoc-2020/day21.onyx b/tests/aoc-2020/day21.onyx index 118eb6ce..f10729d8 100644 --- a/tests/aoc-2020/day21.onyx +++ b/tests/aoc-2020/day21.onyx @@ -129,7 +129,7 @@ main :: (args: [] cstr) { map.delete(^ingredient_map, safe); } - printf("Total safe: %i\n", total_safe); + printf("Total safe: {}\n", total_safe); matched_ingredients := array.make(Ingredient); defer array.free(^matched_ingredients); @@ -166,8 +166,8 @@ main :: (args: [] cstr) { return string.compare(i1.allergen, i2.allergen); }); - for ^mi: matched_ingredients do printf("%s -> %s\n", mi.name, mi.allergen); - for ^mi: matched_ingredients do printf("%s,", mi.name); + for ^mi: matched_ingredients do printf("{} -> {}\n", mi.name, mi.allergen); + for ^mi: matched_ingredients do printf("{},", mi.name); println("\n(Don't copy the last ','!)"); } diff --git a/tests/aoc-2020/day22.onyx b/tests/aoc-2020/day22.onyx index c1d99d90..616d62f4 100644 --- a/tests/aoc-2020/day22.onyx +++ b/tests/aoc-2020/day22.onyx @@ -134,7 +134,7 @@ main :: (args: [] cstr) { defer array.free(^player2_copy); combat_score := combat(^player1_copy, ^player2_copy); - printf("Answer: %i\n", combat_score); + printf("Answer: {}\n", combat_score); } { @@ -152,6 +152,6 @@ main :: (args: [] cstr) { if winner == 1 do score = score_player(^player1_copy); if winner == 2 do score = score_player(^player2_copy); - printf("Recursive answer: %i\n", score); + printf("Recursive answer: {}\n", score); } } diff --git a/tests/aoc-2020/day23.onyx b/tests/aoc-2020/day23.onyx index c40b3bb1..7f64f0cc 100644 --- a/tests/aoc-2020/day23.onyx +++ b/tests/aoc-2020/day23.onyx @@ -76,12 +76,12 @@ main :: (args: [] cstr) { // Part 1 // one_idx := get_idx(array.to_slice(^cups), 1); // for i: 1 .. 9 { - // printf("%i", cast(i32) cups[w(one_idx + i)]); + // printf("{}", cast(i32) cups[w(one_idx + i)]); // } // printf("\n"); // Part 2 one_idx := get_idx(array.to_slice(^cups), 1); prod: i64 = cast(i64) (cups[w(one_idx + 1)]) * cast(i64) (cups[w(one_idx + 2)]); - printf("Cup product: %l\n", prod); + printf("Cup product: {}\n", prod); } diff --git a/tests/aoc-2020/day24.onyx b/tests/aoc-2020/day24.onyx index 4979884a..0e52d1dd 100644 --- a/tests/aoc-2020/day24.onyx +++ b/tests/aoc-2020/day24.onyx @@ -74,7 +74,7 @@ main :: (args: [] cstr) { for ^cell: grid.entries { if cell.value.alive do black_count += 1; } - printf("Black count: %i\n", black_count); + printf("Black count: {}\n", black_count); // Part 2 cells_to_consider := array.make(Vec2); @@ -118,7 +118,7 @@ main :: (args: [] cstr) { for ^cell: grid.entries { if cell.value.alive do black_count += 1; } - printf("GOL black count: %i\n", black_count); + printf("GOL black count: {}\n", black_count); } get_neighbor_count :: (grid: ^map.Map(Vec2, Cell), pos: Vec2) -> u32 { diff --git a/tests/aoc-2020/day25.onyx b/tests/aoc-2020/day25.onyx index db11f1ec..7806bede 100644 --- a/tests/aoc-2020/day25.onyx +++ b/tests/aoc-2020/day25.onyx @@ -67,5 +67,5 @@ main :: (args: [] cstr) { encryption_key_0 := transform_subject(door_pub_key, card_loop_secret); encryption_key_1 := transform_subject(card_pub_key, door_loop_secret); - printf("%i == %i\n", encryption_key_0, encryption_key_1); + printf("{} == {}\n", encryption_key_0, encryption_key_1); } diff --git a/tests/aoc-2020/day3.onyx b/tests/aoc-2020/day3.onyx index 63a7553d..f494fe65 100644 --- a/tests/aoc-2020/day3.onyx +++ b/tests/aoc-2020/day3.onyx @@ -58,5 +58,5 @@ main :: (args: [] cstr) { tree_prod *= tree_count; } - printf("Tree product: %l\n", tree_prod); + printf("Tree product: {}\n", tree_prod); } diff --git a/tests/aoc-2020/day4.onyx b/tests/aoc-2020/day4.onyx index 94f6c3ed..6b70058a 100644 --- a/tests/aoc-2020/day4.onyx +++ b/tests/aoc-2020/day4.onyx @@ -40,5 +40,5 @@ main :: (args: [] cstr) { if field_count == 7 do valid_passports += 1; } - printf("Valid passports: %i\n", valid_passports); + printf("Valid passports: {}\n", valid_passports); } diff --git a/tests/aoc-2020/day5.onyx b/tests/aoc-2020/day5.onyx index 15be6298..0fa91620 100644 --- a/tests/aoc-2020/day5.onyx +++ b/tests/aoc-2020/day5.onyx @@ -31,8 +31,8 @@ main :: (args: [] cstr) { if vals[i + 1] - vals[i] != 1 do missing = vals[i] + 1; } - printf("Max val: %i\n", max_val); - printf("Your seat: %i\n", missing); + printf("Max val: {}\n", max_val); + printf("Your seat: {}\n", missing); } cmp_asc :: (a: $T, b: T) -> i32 do return ~~(a - b); diff --git a/tests/aoc-2020/day6.onyx b/tests/aoc-2020/day6.onyx index 1d731702..a034bbca 100644 --- a/tests/aoc-2020/day6.onyx +++ b/tests/aoc-2020/day6.onyx @@ -52,5 +52,5 @@ main :: (args: [] cstr) { unique_sum += unique; } - printf("Unique sum: %i\n", unique_sum); + printf("Unique sum: {}\n", unique_sum); } diff --git a/tests/aoc-2020/day7.onyx b/tests/aoc-2020/day7.onyx index 8c06460b..2fb4ea3c 100644 --- a/tests/aoc-2020/day7.onyx +++ b/tests/aoc-2020/day7.onyx @@ -106,13 +106,13 @@ main :: (args: [] cstr) { // // for container: bag.contained_in { // if !array.contains(^processed_bags, container.bag) && !array.contains(^to_process_bags, container.bag) { - // // printf("Adding %s to process.\n", container.bag.color); + // // printf("Adding {} to process.\n", container.bag.color); // array.push(^to_process_bags, container.bag); // } // } // } - // printf("Count: %i\n", processed_bags.count - 1); + // printf("Count: {}\n", processed_bags.count - 1); // Part 2 to_process := array.make(#type ^BagNode); @@ -132,5 +132,5 @@ main :: (args: [] cstr) { } } - printf("Count: %i\n", count - 1); + printf("Count: {}\n", count - 1); } diff --git a/tests/aoc-2020/day8.onyx b/tests/aoc-2020/day8.onyx index 61728050..d121d690 100644 --- a/tests/aoc-2020/day8.onyx +++ b/tests/aoc-2020/day8.onyx @@ -81,5 +81,5 @@ main :: (args: [] cstr) { elseif instr.opcode == OpCode.Jmp do instr.opcode = OpCode.Nop; } - printf("Accumulator value: %i\n", acc); + printf("Accumulator value: {}\n", acc); } diff --git a/tests/aoc-2020/day9.onyx b/tests/aoc-2020/day9.onyx index 8df60e34..9bcd661f 100644 --- a/tests/aoc-2020/day9.onyx +++ b/tests/aoc-2020/day9.onyx @@ -60,12 +60,12 @@ main :: (args: [] cstr) { } } - printf("Invalid number: %l\n", invalid); + printf("Invalid number: {}\n", invalid); start, end := find_contiguous_subarray_with_sum(nums, invalid); max := array.fold(nums.data[start .. end + 1], cast(u64) 0, math.max_poly); min := array.fold(nums.data[start .. end + 1], cast(u64) max, math.min_poly); - printf("Extrema sum: %l\n", min + max); + printf("Extrema sum: {}\n", min + max); } diff --git a/tests/array_struct_robustness.onyx b/tests/array_struct_robustness.onyx index 1668b9cf..39d93bc0 100644 --- a/tests/array_struct_robustness.onyx +++ b/tests/array_struct_robustness.onyx @@ -6,7 +6,7 @@ Vec2 :: struct { x: i32; y: i32; } // Overload print() to print Vec2's. #add_match io.write, (use writer: ^io.Writer, use v: Vec2) { - io.write_format(writer, "Vec2(%i, %i)", x, y); + io.write_format(writer, "Vec2({}, {})", x, y); } EntityStore :: struct { diff --git a/tests/baked_parameters.onyx b/tests/baked_parameters.onyx index 461466a6..237afbc3 100644 --- a/tests/baked_parameters.onyx +++ b/tests/baked_parameters.onyx @@ -3,7 +3,7 @@ use package core count_to :: ($N: i32) { - for i: 0 .. N do printf("%i ", i); + for i: 0 .. N do printf("{} ", i); print("\n"); } @@ -40,7 +40,7 @@ main :: (args: [] cstr) { print_age :: (ages: ^map.Map(str, u32), name: str) { age := map.get(ages, name); - printf("%s's age is %i.\n", name, age); + printf("{}'s age is {}.\n", name, age); } print_age(^ages, "Dwight"); diff --git a/tests/better_field_accesses.onyx b/tests/better_field_accesses.onyx index 3485f315..df0fe17f 100644 --- a/tests/better_field_accesses.onyx +++ b/tests/better_field_accesses.onyx @@ -17,7 +17,7 @@ get_foo :: () -> Foo { } main :: (args: [] cstr) { - printf("%i\n", "Hello World!".count); + printf("{}\n", "Hello World!".count); println(get_foo().name); println(get_foo().x); diff --git a/tests/defer_with_continue.onyx b/tests/defer_with_continue.onyx index 1c076ae7..6594a51a 100644 --- a/tests/defer_with_continue.onyx +++ b/tests/defer_with_continue.onyx @@ -7,31 +7,31 @@ main :: (args: [] cstr) { i := 0; while i < 10 { defer i += 1; - defer printf("Index is %i\n", i); + defer printf("Index is {}\n", i); if i == 3 { - printf("Skipping %i!!\n", i); + printf("Skipping {}!!\n", i); continue; } - printf("Doing something with "); + print("Doing something with "); } - printf("i is %i\n", i); + printf("i is {}\n", i); println("\n\n==================================="); i = 0; while i < 10 { defer i += 1; - defer printf("Index is %i\n", i); + defer printf("Index is {}\n", i); if i == 3 { - printf("Skipping %i!!\n", i); + printf("Skipping {}!!\n", i); break; } - printf("Doing something with "); + print("Doing something with "); } - printf("i is %i\n", i); + printf("i is {}\n", i); println("\n\n==================================="); switch i { diff --git a/tests/float_parsing b/tests/float_parsing index 4d983702..f84a3c91 100644 --- a/tests/float_parsing +++ b/tests/float_parsing @@ -1,7 +1,7 @@ 12.0000 12.0000 8.0000 -12.3400 +12.3399 0.3399 2.0000 1.0000 diff --git a/tests/i32map.onyx b/tests/i32map.onyx index 2a55f776..05ab5d3a 100644 --- a/tests/i32map.onyx +++ b/tests/i32map.onyx @@ -17,7 +17,7 @@ main :: (args: [] cstr) { println(map.has(^imap, 50)); println(map.has(^imap, 51)); - printf("%s%s\n", map.get(^imap, 50), map.get(^imap, 1234)); + printf("{}{}\n", map.get(^imap, 50), map.get(^imap, 1234)); map.delete(^imap, 50); println(map.has(^imap, 50)); diff --git a/tests/lazy_iterators.onyx b/tests/lazy_iterators.onyx index c069b3ab..b0f1abe4 100644 --- a/tests/lazy_iterators.onyx +++ b/tests/lazy_iterators.onyx @@ -67,6 +67,6 @@ main :: (args: [] cstr) { |> iter.zip(iter.const(42.0f)); for value: zipped_iterator { - printf("%i %f\n", value.first, value.second); + printf("{} {}\n", value.first, value.second); } } diff --git a/tests/multiple_returns_robustness.onyx b/tests/multiple_returns_robustness.onyx index 0021d167..79c3a10d 100644 --- a/tests/multiple_returns_robustness.onyx +++ b/tests/multiple_returns_robustness.onyx @@ -41,7 +41,7 @@ main :: (args: [] cstr) { least, greatest := get_extrema(i32.[ -5, 20, 5, -10, 200, 8 ]); - printf("%i to %i\n", least, greatest); + printf("{} to {}\n", least, greatest); iarr, farr := return_multiple_arrays(); array_print(iarr); diff --git a/tests/named_arguments_test.onyx b/tests/named_arguments_test.onyx index 4f993236..7b1bcc26 100644 --- a/tests/named_arguments_test.onyx +++ b/tests/named_arguments_test.onyx @@ -4,8 +4,8 @@ use package core main :: (args: [] cstr) { foo :: (x: i32, y: f32) { - printf("x is %i\n", x); - printf("y is %f\n", y); + printf("x is {}\n", x); + printf("y is {}\n", y); } foo(10, 20); @@ -42,8 +42,8 @@ main :: (args: [] cstr) { println(x); println(y); - for elem: z do printf("%f ", elem); - printf("\n"); + for elem: z do printf("{} ", elem); + print("\n"); } overload_with_varargs(10, 20, 30, 40, 50); @@ -61,7 +61,7 @@ main :: (args: [] cstr) { options_f := false, options_g := true, ) { - printf("%b %b %b %b %b %b %b\n", + printf("{} {} {} {} {} {} {}\n", options_a, options_b, options_c, options_d, options_e, options_f, diff --git a/tests/new_printf b/tests/new_printf new file mode 100644 index 00000000..3442358f --- /dev/null +++ b/tests/new_printf @@ -0,0 +1 @@ +123 Test { } false 0x4E8 diff --git a/tests/new_printf.onyx b/tests/new_printf.onyx new file mode 100644 index 00000000..c53077ad --- /dev/null +++ b/tests/new_printf.onyx @@ -0,0 +1,7 @@ +#load "core/std" + +use package core + +main :: (args: [] cstr) { + printf("{} {} {{ }} {} {}\n", 123, "Test", false, ^stdio.print_writer); +} diff --git a/tests/new_struct_behaviour.onyx b/tests/new_struct_behaviour.onyx index 4f114fb1..c3094a2b 100644 --- a/tests/new_struct_behaviour.onyx +++ b/tests/new_struct_behaviour.onyx @@ -66,7 +66,7 @@ main :: (args: [] cstr) { println(foo.some_constant); person := Foo2.SubStruct.{ name = "Joe", age = 30 }; - printf("%s is %i.\n", person.name, person.age); + printf("{} is {}.\n", person.name, person.age); { BasicallyANamespace.function_3(); @@ -80,7 +80,7 @@ main :: (args: [] cstr) { v := Vec3.{ 4, 9, 16 }; - printf("V3(%f, %f, %f)\n", v.x, v.y, v.z); + printf("V3({}, {}, {})\n", v.x, v.y, v.z); } BasicallyANamespace :: struct { diff --git a/tests/operator_overload.onyx b/tests/operator_overload.onyx index d3c0eefb..0fa1aaf0 100644 --- a/tests/operator_overload.onyx +++ b/tests/operator_overload.onyx @@ -68,24 +68,24 @@ main :: (args: [] cstr) { b := C(0, 1); c := a + b; - printf("(%f, %f)\n", c.re, c.im); + printf("({}, {})\n", c.re, c.im); c = a - b; - printf("(%f, %f)\n", c.re, c.im); + printf("({}, {})\n", c.re, c.im); c = a * b; - printf("(%f, %f)\n", c.re, c.im); + printf("({}, {})\n", c.re, c.im); } { a := make_vec(f32.[10, 20]); b := make_vec(f32.[3, 4]); c := a + b; - printf("(%f, %f)\n", c.data[0], c.data[1]); + printf("({}, {})\n", c.data[0], c.data[1]); d := make_vec(f32.[2, 3, 5, 7]); e := join(d, c); - for v: e.data do printf("%f ", v); + for v: e.data do printf("{} ", v); print("\n"); } @@ -93,7 +93,7 @@ main :: (args: [] cstr) { a := make_vec(Complex.[C(2, 3), C(0, 1)]); b := make_vec(Complex.[C(1, 0), C(3, 7)]); c := a * b; - printf("(%f, %f)\n", c.re, c.im); + printf("({}, {})\n", c.re, c.im); } println(test_overload("World!", "Hello!")); diff --git a/tests/polymorphic_array_lengths.onyx b/tests/polymorphic_array_lengths.onyx index 7f88e2b3..8ec8c4a3 100644 --- a/tests/polymorphic_array_lengths.onyx +++ b/tests/polymorphic_array_lengths.onyx @@ -4,7 +4,7 @@ use package core main :: (args: [] cstr) { arr := u32.[ 1, 2, 3, 4, 5 ]; - for elem: array_to_slice(arr) do printf("%i ", elem); + for elem: array_to_slice(arr) do printf("{} ", elem); roots : [20] f32; compute_roots(roots); diff --git a/tests/struct_robustness.onyx b/tests/struct_robustness.onyx index f84f7c88..55d5f974 100644 --- a/tests/struct_robustness.onyx +++ b/tests/struct_robustness.onyx @@ -27,7 +27,7 @@ main :: (args: [] cstr) { ss: SimpleStruct = SimpleStruct.{ 41, 67, "Steve" }; use ss; - printf("SimpleStruct<%i, %i>(%i, %i, %s)\n", + printf("SimpleStruct<{}, {}>({}, {}, {})\n", sizeof SimpleStruct, alignof SimpleStruct, cast(u32) age, height, name); @@ -44,7 +44,7 @@ main :: (args: [] cstr) { u : SimpleUnion; u.float_val = 0.5; - printf("%p == 0x3F000000\n", u.int_val); + printf("{} == 0x3F000000\n", cast(rawptr) u.int_val); } test_default_values :: () { @@ -64,7 +64,7 @@ main :: (args: [] cstr) { print_defaulted(ds2); print_defaulted :: (use ds: DefaultedStruct) { - printf("DefaultedStruct(%i, %f, %l, %d)\n", i, f, l, d); + printf("DefaultedStruct({}, {}, {}, {})\n", i, f, l, d); } } @@ -96,7 +96,7 @@ main :: (args: [] cstr) { // swu3 := StructWithUse.{ 1234, 1, 2, 5678 }; print_swu :: (use swu: StructWithUse) { - printf("StructWithUse(%i, (%f, %f), %i)\n", + printf("StructWithUse({}, ({}, {}), {})\n", first_member, x, y, last_member); } @@ -116,11 +116,11 @@ main :: (args: [] cstr) { ps1.t_data = 1234; ps1.r_data = 5678; - printf("PolyStruct(%i, %f)\n", ps1.t_data, ps1.r_data); + printf("PolyStruct({}, {})\n", ps1.t_data, ps1.r_data); // Currently, this is how you have to do this. ps2 := .{ 1234, 5678 }; - printf("PolyStruct(%f, %i)\n", ps2.t_data, ps2.r_data); + printf("PolyStruct({}, {})\n", ps2.t_data, ps2.r_data); } test_polymorphic_with_defaults :: () { @@ -134,7 +134,7 @@ main :: (args: [] cstr) { PolyStructTyped :: ; ps := PolyStructTyped.{}; - printf("PolyStruct(%i, %f)\n", ps.t_data, ps.r_data); + printf("PolyStruct({}, {})\n", ps.t_data, ps.r_data); } test_polymorphic_union_with_use :: () { @@ -147,12 +147,12 @@ main :: (args: [] cstr) { }; } - printf("%i == 16\n", sizeof PolyStruct(i32, [] u32)); + printf("{} == 16\n", sizeof PolyStruct(i32, [] u32)); ps : PolyStruct(i32, f64); ps.t_data = 1234; ps.r_data = 5678; - printf("%i, %d\n", ps.t_data, ps.r_data); + printf("{}, {}\n", ps.t_data, ps.r_data); } test_union_with_use :: () { @@ -171,10 +171,10 @@ main :: (args: [] cstr) { u : Union; u.x = 10; u.y = 20; - printf("Union(%i, %i)\n", u.x, u.y); + printf("Union({}, {})\n", u.x, u.y); u.name = "Joe"; - printf("Union(%s)\n", u.name); + printf("Union({})\n", u.name); } test_polymorphic_union :: () { @@ -187,9 +187,9 @@ main :: (args: [] cstr) { pu : PolyUnion(str, i32); pu.t_data = "Hello World."; - printf("PolyUnion(%s)\n", pu.t_data); + printf("PolyUnion({})\n", pu.t_data); pu.r_data = 0x4D2; - printf("PolyUnion(%i)\n", pu.r_data); + printf("PolyUnion({})\n", pu.r_data); } } diff --git a/tests/vararg_test.onyx b/tests/vararg_test.onyx index 7751a254..899930b5 100644 --- a/tests/vararg_test.onyx +++ b/tests/vararg_test.onyx @@ -23,5 +23,5 @@ main :: (args: [] cstr) { new_va_test("foo", 1, 2, 3.0f, 5.0f); old_va_test("bar", 1); - printf("Hello, %i, %s!\n", 1234, "World"); + printf("Hello, {}, {}!\n", 1234, "World"); } -- 2.25.1