From da1a45f7187a35823ccebcb509e87b74c10b9de3 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Thu, 17 Nov 2022 23:44:54 +0100 Subject: [PATCH] Remove iptrdiff and uptrdiff. Bump version to 0.3.100 --- README.md | 4 ++-- lib/std/core/env.c3 | 2 +- resources/examples/base64.c3 | 2 +- resources/examples/binarydigits.c3 | 2 +- resources/examples/brainfk.c3 | 14 ++++++------- resources/examples/contextfree/boolerr.c3 | 10 +++++----- .../examples/contextfree/guess_number.c3 | 4 ++-- resources/examples/fasta.c3 | 2 +- resources/examples/map.c3 | 8 ++++---- resources/examples/nbodies.c3 | 8 ++++---- .../examples/notworking/acornvm/value.c3 | 8 ++++---- resources/examples/plus_minus.c3 | 2 +- resources/testfragments/tmem.c3 | 4 ++-- src/compiler/compiler_internal.h | 2 +- src/compiler/enums.h | 6 ++---- src/compiler/llvm_codegen_expr.c | 4 ++-- src/compiler/parse_expr.c | 2 -- src/compiler/sema_casts.c | 4 ++-- src/compiler/sema_expr.c | 20 +++++++++---------- src/compiler/tb_codegen.c | 4 ++-- src/compiler/tokens.c | 4 ---- src/compiler/types.c | 11 +--------- src/version.h | 2 +- test/test_suite/abi/sysv_abi_avx.c3t | 2 +- test/test_suite/abi/sysv_abi_noavx.c3t | 2 +- test/test_suite/asm/asm_regression.c3t | 2 +- .../compile_time/compile_time_pointers.c3t | 4 ++-- .../distinct/distinct_struct_array.c3 | 2 +- test/test_suite/errors/error_regression_2.c3t | 6 +++--- test/test_suite/examples/gameoflife.c3 | 2 +- .../expressions/casts/cast_func_to_various.c3 | 4 ++-- .../expressions/fail_index_usize.c3 | 2 +- test/test_suite/expressions/type_support.c3t | 4 ++-- test/test_suite/initializer_lists/fasta.c3t | 2 +- test/test_suite/macros/userland_bitcast.c3t | 10 +++++----- .../methods/extension_method_generic.c3 | 2 +- test/test_suite/statements/foreach_custom.c3t | 4 ++-- .../statements/foreach_custom_macro.c3t | 4 ++-- .../foreach_more_implementations.c3t | 8 ++++---- .../statements/foreach_r_custom.c3t | 4 ++-- .../statements/foreach_r_custom_macro.c3t | 4 ++-- .../struct/struct_const_construct_simple.c3t | 2 +- test/test_suite2/abi/sysv_abi_avx.c3t | 2 +- test/test_suite2/abi/sysv_abi_noavx.c3t | 2 +- test/test_suite2/asm/asm_regression.c3t | 2 +- .../compile_time/compile_time_pointers.c3t | 4 ++-- .../distinct/distinct_struct_array.c3 | 2 +- .../test_suite2/errors/error_regression_2.c3t | 6 +++--- test/test_suite2/examples/gameoflife.c3 | 2 +- .../expressions/casts/cast_func_to_various.c3 | 2 +- .../expressions/fail_index_usize.c3 | 2 +- test/test_suite2/expressions/type_support.c3t | 4 ++-- test/test_suite2/initializer_lists/fasta.c3t | 2 +- test/test_suite2/macros/userland_bitcast.c3t | 10 +++++----- .../methods/extension_method_generic.c3 | 2 +- .../test_suite2/statements/foreach_custom.c3t | 4 ++-- .../statements/foreach_custom_macro.c3t | 4 ++-- .../foreach_more_implementations.c3t | 8 ++++---- .../statements/foreach_r_custom.c3t | 4 ++-- .../statements/foreach_r_custom_macro.c3t | 4 ++-- .../struct/struct_const_construct_simple.c3t | 2 +- 61 files changed, 125 insertions(+), 142 deletions(-) diff --git a/README.md b/README.md index 33b8906fe..5014bba09 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ module stack ; struct Stack { - usize capacity; - usize size; + usz capacity; + usz size; Type* elems; } diff --git a/lib/std/core/env.c3 b/lib/std/core/env.c3 index bc766add8..6a5d7d8b9 100644 --- a/lib/std/core/env.c3 +++ b/lib/std/core/env.c3 @@ -59,7 +59,7 @@ const bool I128_NATIVE_SUPPORT = $$PLATFORM_I128_SUPPORTED; const bool F16_SUPPORT = $$PLATFORM_F16_SUPPORTED; const bool F128_SUPPORT = $$PLATFORM_F128_SUPPORTED; const bool COMPILER_SAFE_MODE = $$COMPILER_SAFE_MODE; -const usize LLVM_VERSION = $$LLVM_VERSION; +const usz LLVM_VERSION = $$LLVM_VERSION; const bool BENCHMARKING = $$BENCHMARKING; const bool TESTING = $$TESTING; const usz TEMP_ALLOCATOR_SIZE = 128 * 1024; diff --git a/resources/examples/base64.c3 b/resources/examples/base64.c3 index 67cbddd87..ce70cf12a 100644 --- a/resources/examples/base64.c3 +++ b/resources/examples/base64.c3 @@ -61,7 +61,7 @@ fn void encode(char[] in, char *out) } // move back - usize last = in.len - 1; + usz last = in.len - 1; // check the last and add padding switch (last % 3) { diff --git a/resources/examples/binarydigits.c3 b/resources/examples/binarydigits.c3 index 2b4d49a55..19bdbb485 100644 --- a/resources/examples/binarydigits.c3 +++ b/resources/examples/binarydigits.c3 @@ -18,7 +18,7 @@ fn String bin(int x) str.append_repeat('0', bits); for (int i = 0; i < bits; i++) { - str.set((usize)(bits - i - 1), x & 1 ? '1' : '0'); + str.set((usz)(bits - i - 1), x & 1 ? '1' : '0'); x >>= 1; } return str; diff --git a/resources/examples/brainfk.c3 b/resources/examples/brainfk.c3 index b74881cc1..7781575a1 100644 --- a/resources/examples/brainfk.c3 +++ b/resources/examples/brainfk.c3 @@ -10,7 +10,7 @@ fault InterpretError INTEPRET_FAILED } -fn void! print_error(usize pos, char[] err) +fn void! print_error(usz pos, char[] err) { io::printfln("Error at %s: %s", pos, err); return InterpretError.INTEPRET_FAILED!; @@ -18,8 +18,8 @@ fn void! print_error(usize pos, char[] err) fn void! brainf(char[] program) { - usize sp = 0; - usize mem = 0; + usz sp = 0; + usz mem = 0; while (sp < program.len) { char c = program[sp++]; @@ -41,9 +41,9 @@ fn void! brainf(char[] program) case ',': memory[mem] = io::stdin().getc()!!; case '[': - usize indent = 1; + usz indent = 1; if (memory[mem]) continue; - usize start = sp - 1; + usz start = sp - 1; while (indent) { if (sp == program.len) return print_error(start, "No matching ']'"); @@ -56,8 +56,8 @@ fn void! brainf(char[] program) } case ']': if (!memory[mem]) continue; - usize start = sp--; - usize indent = 1; + usz start = sp--; + usz indent = 1; while (indent) { if (!sp) return print_error(start, "No matching '['"); diff --git a/resources/examples/contextfree/boolerr.c3 b/resources/examples/contextfree/boolerr.c3 index d4f4c4868..dd32f78bc 100644 --- a/resources/examples/contextfree/boolerr.c3 +++ b/resources/examples/contextfree/boolerr.c3 @@ -14,8 +14,8 @@ struct Summary private struct StringData { Allocator allocator; - usize len; - usize capacity; + usz len; + usz capacity; char[*] chars; } @@ -27,12 +27,12 @@ fn void Summary.print(Summary *s, File out) fn bool contains(char[] haystack, char[] needle) { - usize len = haystack.len; - usize needle_len = needle.len; + usz len = haystack.len; + usz needle_len = needle.len; if (len < needle_len) return false; if (!needle_len) return true; len -= needle_len - 1; - for (usize i = 0; i < len; i++) + for (usz i = 0; i < len; i++) { if (mem::equals(haystack[i..], needle)) { diff --git a/resources/examples/contextfree/guess_number.c3 b/resources/examples/contextfree/guess_number.c3 index d86863d88..576bacc12 100644 --- a/resources/examples/contextfree/guess_number.c3 +++ b/resources/examples/contextfree/guess_number.c3 @@ -2,7 +2,7 @@ module guess_number; import std::io; import libc; -extern fn isize getline(char** linep, usize* linecapp, CFile stream); +extern fn isz getline(char** linep, usz* linecapp, CFile stream); struct Game { @@ -33,7 +33,7 @@ fn int! askGuess(int high) fn char[]! readLine() { char* chars = tmalloc(1024)?; - isize loaded = getline(&chars, &&(usize)1023, libc::stdin()); + isz loaded = getline(&chars, &&(usz)1023, libc::stdin()); if (loaded < 0) return InputResult.FAILED_TO_READ!; chars[loaded] = 0; return chars[0..(loaded - 1)]; diff --git a/resources/examples/fasta.c3 b/resources/examples/fasta.c3 index 0adebf586..4faba77f7 100644 --- a/resources/examples/fasta.c3 +++ b/resources/examples/fasta.c3 @@ -56,7 +56,7 @@ const LINELEN = 60; // slowest character-at-a-time output fn void repeat_fasta(char[] seq, int n) { - usize len = seq.len; + usz len = seq.len; int i = void; for (i = 0; i < n; i++) { diff --git a/resources/examples/map.c3 b/resources/examples/map.c3 index 40abcdacf..b4d552489 100644 --- a/resources/examples/map.c3 +++ b/resources/examples/map.c3 @@ -10,14 +10,14 @@ struct Entry { Key key; Type value; - usize hash; + usz hash; Entry* next; bool used; } struct Map { - usize size; + usz size; Entry* map; uint mod; } @@ -37,7 +37,7 @@ fn Type! Map.valueForKey(Map *map, Key key) { if (!map.map) return MapResult.KEY_NOT_FOUND!; uint hash = key.hash(); - usize pos = hash & map.mod; + usz pos = hash & map.mod; Entry* entry = &map.map[pos]; if (!entry) return MapResult.KEY_NOT_FOUND!; while (entry) @@ -91,7 +91,7 @@ fn Type! Map.set(Map *map, Key key, Type value) @maydiscard } } -fn usize Map.size(Map* map) +fn usz Map.size(Map* map) { return map.size; } diff --git a/resources/examples/nbodies.c3 b/resources/examples/nbodies.c3 index a215dc601..473956b09 100644 --- a/resources/examples/nbodies.c3 +++ b/resources/examples/nbodies.c3 @@ -15,10 +15,10 @@ struct Planet fn void advance(Planet[] bodies) @noinline { - usize nbodies = bodies.len; + usz nbodies = bodies.len; foreach (i, Planet* &b : bodies) { - for (usize j = i + 1; j < nbodies; j++) + for (usz j = i + 1; j < nbodies; j++) { Planet* b2 = &bodies[j]; double dx = b.x - b2.x; @@ -45,12 +45,12 @@ fn void advance(Planet[] bodies) @noinline fn double energy(Planet[] bodies) { double e; - usize nbodies = bodies.len; + usz nbodies = bodies.len; foreach (i, Planet* &b : bodies) { e += 0.5 * b.mass * (b.vx * b.vx + b.vy * b.vy + b.vz * b.vz); - for (usize j = i + 1; j < nbodies; j++) + for (usz j = i + 1; j < nbodies; j++) { Planet* b2 = &bodies[j]; double dx = b.x - b2.x; diff --git a/resources/examples/notworking/acornvm/value.c3 b/resources/examples/notworking/acornvm/value.c3 index 4a4152c3c..4f09255fc 100644 --- a/resources/examples/notworking/acornvm/value.c3 +++ b/resources/examples/notworking/acornvm/value.c3 @@ -16,14 +16,14 @@ macro assert_exp($c, $e) */ /** A signed integer, whose size matches Value */ -typedef isize Aint; +typedef isz Aint; /** An unsigned integer, whose size matches Value */ -typedef usize Auint; +typedef usz Auint; /** A float, whose size matches Value (see avm_env.h) */ -$assert(usize.size == 8 || usize.size == 4) -$if (usize.size == 8) +$assert(usz.size == 8 || usz.size == 4) +$if (usz.size == 8) { typedef double as Afloat; } diff --git a/resources/examples/plus_minus.c3 b/resources/examples/plus_minus.c3 index 1764efb51..767ac5f7b 100644 --- a/resources/examples/plus_minus.c3 +++ b/resources/examples/plus_minus.c3 @@ -66,7 +66,7 @@ fn char[]! read_next(char[]* remaining) // Store the beginning of the parse char* ptr_start = remaining.ptr; - usize len = 0; + usz len = 0; while (remaining.len > 0 && (*remaining)[0] != ' ') { // Increase length diff --git a/resources/testfragments/tmem.c3 b/resources/testfragments/tmem.c3 index ff683f3dd..c5a44fe76 100644 --- a/resources/testfragments/tmem.c3 +++ b/resources/testfragments/tmem.c3 @@ -5,8 +5,8 @@ import std::io; struct String { Allocator allocator; - usize len; - usize capacity; + usz len; + usz capacity; char* ptr; } diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 9e44f17d9..d0ed8b2e4 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -1810,7 +1810,7 @@ extern Type *type_bool, *type_void, *type_voidptr; extern Type *type_float16, *type_float, *type_double, *type_f128; extern Type *type_ichar, *type_short, *type_int, *type_long, *type_isize, *type_isz; extern Type *type_char, *type_ushort, *type_uint, *type_ulong, *type_usize, *type_usz; -extern Type *type_iptr, *type_uptr, *type_iptrdiff, *type_uptrdiff; +extern Type *type_iptr, *type_uptr; extern Type *type_u128, *type_i128; extern Type *type_typeid, *type_anyerr, *type_typeinfo, *type_member; extern Type *type_any; diff --git a/src/compiler/enums.h b/src/compiler/enums.h index 15b6ba922..6c5212ef8 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -470,7 +470,6 @@ typedef enum TOKEN_ICHAR, TOKEN_INT, TOKEN_IPTR, - TOKEN_IPTRDIFF, TOKEN_ISIZE, TOKEN_ISZ, TOKEN_LONG, @@ -479,7 +478,6 @@ typedef enum TOKEN_UINT, TOKEN_ULONG, TOKEN_UPTR, - TOKEN_UPTRDIFF, TOKEN_USHORT, TOKEN_USIZE, TOKEN_USZ, @@ -604,9 +602,9 @@ typedef enum #define NON_VOID_TYPE_TOKENS \ TOKEN_BOOL: case TOKEN_CHAR: case TOKEN_DOUBLE: case TOKEN_FLOAT: \ case TOKEN_FLOAT16: case TOKEN_INT128: case TOKEN_ICHAR: case TOKEN_INT: \ - case TOKEN_IPTR: case TOKEN_IPTRDIFF: case TOKEN_ISIZE: case TOKEN_LONG: \ + case TOKEN_IPTR: case TOKEN_ISIZE: case TOKEN_LONG: \ case TOKEN_SHORT: case TOKEN_UINT128: case TOKEN_UINT: case TOKEN_ULONG: \ - case TOKEN_UPTR: case TOKEN_UPTRDIFF: case TOKEN_USHORT: case TOKEN_USIZE:\ + case TOKEN_UPTR: case TOKEN_USHORT: case TOKEN_USIZE:\ case TOKEN_USZ: case TOKEN_ISZ: case TOKEN_FLOAT128: case TOKEN_TYPEID: case TOKEN_ANYERR: case TOKEN_VARIANT #define TYPE_TOKENS NON_VOID_TYPE_TOKENS: case TOKEN_VOID #define TYPELIKE_TOKENS TYPE_TOKENS: case TOKEN_TYPE_IDENT: \ diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index ce78ba34f..540104f40 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -3524,10 +3524,10 @@ void llvm_emit_binary(GenContext *c, BEValue *be_value, Expr *expr, BEValue *lhs { if (lhs_type == rhs_type) { - LLVMTypeRef int_type = llvm_get_type(c, type_iptrdiff); + LLVMTypeRef int_type = llvm_get_type(c, type_isz); val = LLVMBuildSub(c->builder, LLVMBuildPtrToInt(c->builder, lhs_value, int_type, ""), LLVMBuildPtrToInt(c->builder, rhs_value, int_type, ""), ""); - val = LLVMBuildExactSDiv(c->builder, val, llvm_const_int(c, type_iptrdiff, type_abi_alignment(lhs_type->pointer)), ""); + val = LLVMBuildExactSDiv(c->builder, val, llvm_const_int(c, type_isz, type_abi_alignment(lhs_type->pointer)), ""); break; } rhs_value = LLVMBuildNeg(c->builder, rhs_value, ""); diff --git a/src/compiler/parse_expr.c b/src/compiler/parse_expr.c index f9df35b1d..b5d38395e 100644 --- a/src/compiler/parse_expr.c +++ b/src/compiler/parse_expr.c @@ -1690,8 +1690,6 @@ ParseRule rules[TOKEN_EOF + 1] = { [TOKEN_USZ] = { parse_type_identifier, NULL, PREC_NONE }, [TOKEN_IPTR] = { parse_type_identifier, NULL, PREC_NONE }, [TOKEN_UPTR] = { parse_type_identifier, NULL, PREC_NONE }, - [TOKEN_IPTRDIFF] = { parse_type_identifier, NULL, PREC_NONE }, - [TOKEN_UPTRDIFF] = { parse_type_identifier, NULL, PREC_NONE }, [TOKEN_FLOAT] = { parse_type_identifier, NULL, PREC_NONE }, [TOKEN_DOUBLE] = { parse_type_identifier, NULL, PREC_NONE }, [TOKEN_FLOAT16] = { parse_type_identifier, NULL, PREC_NONE }, diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 0b7a13376..ca1702f2a 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -1676,12 +1676,12 @@ bool cast_to_index(Expr *index) case TYPE_I16: case TYPE_I32: case TYPE_I64: - return cast(index, type_iptrdiff); + return cast(index, type_isz); case TYPE_U8: case TYPE_U16: case TYPE_U32: case TYPE_U64: - return cast(index, type_uptrdiff); + return cast(index, type_usz); case TYPE_U128: SEMA_ERROR(index, "You need to explicitly cast this to a uint or ulong."); return false; diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 7b68318d1..d5f481955 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -2446,7 +2446,7 @@ static inline bool sema_expr_analyse_pointer_offset(SemaContext *context, Expr * // 2. Evaluate the offset. Expr *offset = exprptr(expr->pointer_offset_expr.offset); if (!sema_analyse_expr(context, offset)) return false; - if (!cast_implicit(context, offset, type_iptrdiff)) return false; + if (!cast_implicit(context, offset, type_isz)) return false; // 3. Store optionality bool is_optional = IS_OPTIONAL(pointer) || IS_OPTIONAL(offset); @@ -4301,12 +4301,12 @@ static bool sema_expr_analyse_sub(SemaContext *context, Expr *expr, Expr *left, if (expr_both_const(left, right)) { - expr_rewrite_const_int(expr, type_iptrdiff, (left->const_expr.ptr - right->const_expr.ptr) / + expr_rewrite_const_int(expr, type_isz, (left->const_expr.ptr - right->const_expr.ptr) / type_size(left_type->pointer), false); return true; } // 3b. Set the type - expr->type = type_iptrdiff; + expr->type = type_isz; return true; } @@ -4320,15 +4320,15 @@ static bool sema_expr_analyse_sub(SemaContext *context, Expr *expr, Expr *left, return false; } - // 5. Make sure that the integer does not exceed iptrdiff in size. - if (type_size(right_type) > type_size(type_iptrdiff)) + // 5. Make sure that the integer does not exceed isz in size. + if (type_size(right_type) > type_size(type_isz)) { - SEMA_ERROR(expr, "Cannot subtract a '%s' from a pointer, please first cast it to '%s'.", type_to_error_string(right_type), type_to_error_string(type_iptrdiff)); + SEMA_ERROR(expr, "Cannot subtract a '%s' from a pointer, please first cast it to '%s'.", type_to_error_string(right_type), type_to_error_string(type_isz)); return false; } - // 6. Convert to iptrdiff - if (!cast_implicit(context, right, type_iptrdiff)) return true; + // 6. Convert to isz + if (!cast_implicit(context, right, type_isz)) return true; if (left->expr_kind == EXPR_POINTER_OFFSET) { @@ -4452,7 +4452,7 @@ static bool sema_expr_analyse_add(SemaContext *context, Expr *expr, Expr *left, // 3b. Cast it to usize or isize depending on underlying type. // Either is fine, but it looks a bit nicer if we actually do this and keep the sign. - bool success = cast_implicit(context, right, type_iptrdiff); + bool success = cast_implicit(context, right, type_isz); // No need to check the cast we just ensured it was an integer. assert(success && "This should always work"); @@ -6597,7 +6597,7 @@ static inline bool sema_expr_analyse_ct_offsetof(SemaContext *context, Expr *exp type = result_type; } - expr_rewrite_const_int(expr, type_iptrdiff, offset, true); + expr_rewrite_const_int(expr, type_isz, offset, true); return true; } diff --git a/src/compiler/tb_codegen.c b/src/compiler/tb_codegen.c index cf7edf23f..8bb2c09f3 100644 --- a/src/compiler/tb_codegen.c +++ b/src/compiler/tb_codegen.c @@ -574,10 +574,10 @@ void tinybackend_emit_binary(TbContext *c, TBEValue *TBE_VALUE, Expr *expr, TBEV /*bool is_constant = LLVMIsConstant(lhs_value) && LLVMIsConstant(rhs_value); if (lhs_type == rhs_type) { - LLVMTypeRef int_type = llvm_get_type(c, type_iptrdiff); + LLVMTypeRef int_type = llvm_get_type(c, type_isz); val = LLVMBuildSub(c->builder, LLVMBuildPtrToInt(c->builder, lhs_value, int_type, ""), LLVMBuildPtrToInt(c->builder, rhs_value, int_type, ""), ""); - val = LLVMBuildExactSDiv(c->builder, val, llvm_const_int(c, type_iptrdiff, type_abi_alignment(lhs_type->pointer)), ""); + val = LLVMBuildExactSDiv(c->builder, val, llvm_const_int(c, type_isz, type_abi_alignment(lhs_type->pointer)), ""); break; } rhs_value = LLVMConstNeg(rhs_value); diff --git a/src/compiler/tokens.c b/src/compiler/tokens.c index 2ad6eb844..8ea080f26 100644 --- a/src/compiler/tokens.c +++ b/src/compiler/tokens.c @@ -315,10 +315,6 @@ const char *token_type_to_string(TokenType type) return "iptr"; case TOKEN_UPTR: return "uptr"; - case TOKEN_IPTRDIFF: - return "iptrdiff"; - case TOKEN_UPTRDIFF: - return "uptrdiff"; case TOKEN_FLOAT16: return "float16"; case TOKEN_DOCS_START: diff --git a/src/compiler/types.c b/src/compiler/types.c index bdcbee843..33d70f485 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -11,7 +11,7 @@ static struct Type u0, u1, i8, i16, i32, i64, i128, ixx; Type u8, u16, u32, u64, u128; Type f16, f32, f64, f128, fxx; - Type usz, isz, usize, isize, uptr, iptr, uptrdiff, iptrdiff; + Type usz, isz, usize, isize, uptr, iptr; Type voidstar, typeid, anyerr, member, typeinfo, untyped_list; Type any, anyfail; } t; @@ -32,7 +32,6 @@ Type *type_int = &t.i32; Type *type_long = &t.i64; Type *type_i128 = &t.i128; Type *type_iptr = &t.iptr; -Type *type_iptrdiff = &t.iptrdiff; Type *type_isize = &t.isize; Type *type_isz = &t.isz; Type *type_char = &t.u8; @@ -41,7 +40,6 @@ Type *type_uint = &t.u32; Type *type_ulong = &t.u64; Type *type_u128 = &t.u128; Type *type_uptr = &t.uptr; -Type *type_uptrdiff = &t.uptrdiff; Type *type_usize = &t.usize; Type *type_usz = &t.usz; Type *type_anyerr = &t.anyerr; @@ -1465,9 +1463,6 @@ void type_setup(PlatformTarget *target) type_create_alias("uptr", &t.uptr, type_int_unsigned_by_bitsize(target->width_pointer)); type_create_alias("iptr", &t.iptr, type_int_signed_by_bitsize(target->width_pointer)); - type_create_alias("uptrdiff", &t.uptrdiff, type_int_unsigned_by_bitsize(target->width_pointer)); - type_create_alias("iptrdiff", &t.iptrdiff, type_int_signed_by_bitsize(target->width_pointer)); - alignment_subarray = MAX(type_abi_alignment(&t.voidstar), type_abi_alignment(t.usz.canonical)); size_subarray = (unsigned)(alignment_subarray * 2); type_init("anyerr", &t.anyerr, TYPE_ANYERR, target->width_pointer, target->align_pointer); @@ -1602,8 +1597,6 @@ Type *type_from_token(TokenType type) return type_int; case TOKEN_IPTR: return type_iptr; - case TOKEN_IPTRDIFF: - return type_iptrdiff; case TOKEN_ISIZE: return type_isize; case TOKEN_ISZ: @@ -1620,8 +1613,6 @@ Type *type_from_token(TokenType type) return type_ulong; case TOKEN_UPTR: return type_uptr; - case TOKEN_UPTRDIFF: - return type_uptrdiff; case TOKEN_USHORT: return type_ushort; case TOKEN_USIZE: diff --git a/src/version.h b/src/version.h index a93fec036..7f9b18c89 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.3.99" \ No newline at end of file +#define COMPILER_VERSION "0.3.100" \ No newline at end of file diff --git a/test/test_suite/abi/sysv_abi_avx.c3t b/test/test_suite/abi/sysv_abi_avx.c3t index d881e09bf..8f36042b0 100644 --- a/test/test_suite/abi/sysv_abi_avx.c3t +++ b/test/test_suite/abi/sysv_abi_avx.c3t @@ -5,7 +5,7 @@ module foo; struct StringRef { char* str; - usize size; + usz size; } char gc; diff --git a/test/test_suite/abi/sysv_abi_noavx.c3t b/test/test_suite/abi/sysv_abi_noavx.c3t index 639a77407..75c83e061 100644 --- a/test/test_suite/abi/sysv_abi_noavx.c3t +++ b/test/test_suite/abi/sysv_abi_noavx.c3t @@ -5,7 +5,7 @@ module foo; struct StringRef { char* str; - usize size; + usz size; } char gc; diff --git a/test/test_suite/asm/asm_regression.c3t b/test/test_suite/asm/asm_regression.c3t index 29a57891c..099dbdb35 100644 --- a/test/test_suite/asm/asm_regression.c3t +++ b/test/test_suite/asm/asm_regression.c3t @@ -13,7 +13,7 @@ fn void main() int* gp = &g; int[4] a = { 3, 4, 5, 6 }; int* xa = &a; - usize asf = 1; + usz asf = 1; int aa = 3; asm { diff --git a/test/test_suite/compile_time/compile_time_pointers.c3t b/test/test_suite/compile_time/compile_time_pointers.c3t index 85d798ef5..ae7c411b1 100644 --- a/test/test_suite/compile_time/compile_time_pointers.c3t +++ b/test/test_suite/compile_time/compile_time_pointers.c3t @@ -4,12 +4,12 @@ module test; const uptr ABC = 0x213; const void* BAC = (void*)144 - 1; const void* EXX = (void*)155; -const iptrdiff KEX = BAC - EXX; +const isz KEX = BAC - EXX; const void* CAB = BAC; const uptr ZAB = (uptr)CAB; const int* BOB = (int*)16 - 1; const int* BAB = (int*)16 + 1; -const iptrdiff AO = BAB - BOB; +const isz AO = BAB - BOB; $if (ZAB > 100): int abc = 123; diff --git a/test/test_suite/distinct/distinct_struct_array.c3 b/test/test_suite/distinct/distinct_struct_array.c3 index 9794d6363..f6e4eb4e1 100644 --- a/test/test_suite/distinct/distinct_struct_array.c3 +++ b/test/test_suite/distinct/distinct_struct_array.c3 @@ -14,6 +14,6 @@ define StructArr = distinct Struct2[3]; fn void test(int x) { StructArr z = { { .x = 1 }, { .y = x }, { 1, 2 }}; - usize len = z.len; + usz len = z.len; Foo zz = z[2].x; } diff --git a/test/test_suite/errors/error_regression_2.c3t b/test/test_suite/errors/error_regression_2.c3t index 2dd74c493..3fd6c10a5 100644 --- a/test/test_suite/errors/error_regression_2.c3t +++ b/test/test_suite/errors/error_regression_2.c3t @@ -22,12 +22,12 @@ fn void Summary.print(Summary *s, CFile out) fn bool contains(char[] haystack, char[] needle) { - usize len = haystack.len; - usize needle_len = needle.len; + usz len = haystack.len; + usz needle_len = needle.len; if (len < needle_len) return false; if (!needle_len) return true; len -= needle_len - 1; - for (usize i = 0; i < len; i++) + for (usz i = 0; i < len; i++) { if (libc::memcmp(&haystack[i], needle.ptr, needle_len) == 0) { diff --git a/test/test_suite/examples/gameoflife.c3 b/test/test_suite/examples/gameoflife.c3 index a663e892e..676449291 100644 --- a/test/test_suite/examples/gameoflife.c3 +++ b/test/test_suite/examples/gameoflife.c3 @@ -5,7 +5,7 @@ extern fn int atoi(char *val); extern void *__stdoutp; extern fn void fflush(void *std); extern fn int rand(); -extern fn void* malloc(usize size); +extern fn void* malloc(usz size); extern fn void usleep(int time); diff --git a/test/test_suite/expressions/casts/cast_func_to_various.c3 b/test/test_suite/expressions/casts/cast_func_to_various.c3 index 6c747a215..66cc71069 100644 --- a/test/test_suite/expressions/casts/cast_func_to_various.c3 +++ b/test/test_suite/expressions/casts/cast_func_to_various.c3 @@ -3,7 +3,7 @@ struct Struct int x; } -enum Enum : uptr +enum Enum : usz { A, B } @@ -36,7 +36,7 @@ fn void test4(Func arg) fn void test7(Func arg) { - usize g = (usize)(arg); + usz g = (usz)(arg); FuncOther k = (FuncOther)(arg); FuncSame l = (FuncSame)(arg); FuncOther ke = arg; // #error: 'Func' (fn void(int)) to 'FuncOther' (fn bool(char*)) diff --git a/test/test_suite/expressions/fail_index_usize.c3 b/test/test_suite/expressions/fail_index_usize.c3 index 911ebd3e0..80e6f0c40 100644 --- a/test/test_suite/expressions/fail_index_usize.c3 +++ b/test/test_suite/expressions/fail_index_usize.c3 @@ -1,4 +1,4 @@ -fn void test(int* array, usize n) +fn void test(int* array, usz n) { array[n] = 33; n[array] = 33; // #error: Cannot index diff --git a/test/test_suite/expressions/type_support.c3t b/test/test_suite/expressions/type_support.c3t index fdf530741..a5cd4933b 100644 --- a/test/test_suite/expressions/type_support.c3t +++ b/test/test_suite/expressions/type_support.c3t @@ -16,9 +16,9 @@ macro print_type_info(...) fn void main() { io::printfln("Unsigned integers:"); - print_type_info(char, ushort, uint, ulong, uptr, uptrdiff, usize); + print_type_info(char, ushort, uint, ulong, uptr, usz, usz); io::printfln("Signed integers:"); - print_type_info(ichar, short, int, long, iptr, iptrdiff, isize); + print_type_info(ichar, short, int, long, iptr, isz, isz); io::printfln("Floats:"); print_type_info(float, double); } diff --git a/test/test_suite/initializer_lists/fasta.c3t b/test/test_suite/initializer_lists/fasta.c3t index f35c4ea19..233708ece 100644 --- a/test/test_suite/initializer_lists/fasta.c3t +++ b/test/test_suite/initializer_lists/fasta.c3t @@ -58,7 +58,7 @@ const LINELEN = 60; // slowest character-at-a-time output fn void repeat_fasta(char[] seq, int n) { - usize len = seq.len; + usz len = seq.len; int i = void; for (i = 0; i < n; i++) { diff --git a/test/test_suite/macros/userland_bitcast.c3t b/test/test_suite/macros/userland_bitcast.c3t index 23024aa7b..9816bbfc8 100644 --- a/test/test_suite/macros/userland_bitcast.c3t +++ b/test/test_suite/macros/userland_bitcast.c3t @@ -4,33 +4,33 @@ macro testbitcast(expr, $Type) { $assert($sizeof(expr) == $Type.sizeof, "Cannot bitcast between types of different size."); $Type x = void; - var $size = (usize)($sizeof(expr)); + var $size = (usz)($sizeof(expr)); $if ($alignof(expr) >= 8 && $Type.alignof >= 8): ulong *b = (ulong*)(&expr); ulong *to = (ulong*)(&x); - for (usize i = 0; i < $size; i += 8) + for (usz i = 0; i < $size; i += 8) { to[i] = b[i]; } $elif ($alignof(expr) >= 4 && $Type.alignof >= 4): uint* b = (uint*)(&expr); uint* to = (uint*)(&x); - for (usize i = 0; i < $size; i += 4) + for (usz i = 0; i < $size; i += 4) { to[i] = b[i]; } $elif ($alignof(expr) >= 2 && $Type.alignof >= 2): ushort* b = (ushort*)(&expr); ushort* to = (ushort*)(&x); - for (usize i = 0; i < $size; i += 2) + for (usz i = 0; i < $size; i += 2) { to[i] = b[i]; } $else: char* b = (char*)(&expr); char* to = (char*)(&x); - for (usize i = 0; i < $size; i++) + for (usz i = 0; i < $size; i++) { to[i] = b[i]; } diff --git a/test/test_suite/methods/extension_method_generic.c3 b/test/test_suite/methods/extension_method_generic.c3 index 29c452f8d..ab13e4eb1 100644 --- a/test/test_suite/methods/extension_method_generic.c3 +++ b/test/test_suite/methods/extension_method_generic.c3 @@ -5,7 +5,7 @@ define IntArray = List; extern fn void printf(char*, ...); -fn void IntArray.someFunc(IntArray *this, usize param) { +fn void IntArray.someFunc(IntArray *this, usz param) { //do something this.push((int)param); } diff --git a/test/test_suite/statements/foreach_custom.c3t b/test/test_suite/statements/foreach_custom.c3t index 38c1d2a49..481036d1a 100644 --- a/test/test_suite/statements/foreach_custom.c3t +++ b/test/test_suite/statements/foreach_custom.c3t @@ -6,12 +6,12 @@ struct Foo int[] x; } -macro int Foo.@operator_element_at(Foo &foo, usize index) @operator([]) +macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) { return foo.x[index]; } -macro usize Foo.@operator_len(Foo &foo) @operator(len) +macro usz Foo.@operator_len(Foo &foo) @operator(len) { return foo.x.len; } diff --git a/test/test_suite/statements/foreach_custom_macro.c3t b/test/test_suite/statements/foreach_custom_macro.c3t index acdc14f22..449c9be9e 100644 --- a/test/test_suite/statements/foreach_custom_macro.c3t +++ b/test/test_suite/statements/foreach_custom_macro.c3t @@ -5,12 +5,12 @@ struct Foo int[] x; } -macro int Foo.@operator_element_at(Foo &foo, usize index) @operator([]) +macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) { return foo.x[index]; } -macro usize Foo.@operator_len(Foo &foo) @operator(len) +macro usz Foo.@operator_len(Foo &foo) @operator(len) { return foo.x.len; } diff --git a/test/test_suite/statements/foreach_more_implementations.c3t b/test/test_suite/statements/foreach_more_implementations.c3t index ae21391d5..8008fed16 100644 --- a/test/test_suite/statements/foreach_more_implementations.c3t +++ b/test/test_suite/statements/foreach_more_implementations.c3t @@ -4,21 +4,21 @@ module test; import std::io; struct Vector { - usize size; + usz size; int* elements; } -macro int Vector.get(Vector* vector, usize element) @operator([]) +macro int Vector.get(Vector* vector, usz element) @operator([]) { return vector.elements[element]; } -macro int* Vector.get_ref(Vector* vector, usize element) @operator(&[]) +macro int* Vector.get_ref(Vector* vector, usz element) @operator(&[]) { return &vector.elements[element]; } -macro usize Vector.size(Vector vector) @operator(len) { +macro usz Vector.size(Vector vector) @operator(len) { return vector.size; } diff --git a/test/test_suite/statements/foreach_r_custom.c3t b/test/test_suite/statements/foreach_r_custom.c3t index 40bb45176..646ae4287 100644 --- a/test/test_suite/statements/foreach_r_custom.c3t +++ b/test/test_suite/statements/foreach_r_custom.c3t @@ -6,12 +6,12 @@ struct Foo int[] x; } -macro int Foo.@operator_element_at(Foo &foo, usize index) @operator([]) +macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) { return foo.x[index]; } -macro usize Foo.@operator_len(Foo &foo) @operator(len) +macro usz Foo.@operator_len(Foo &foo) @operator(len) { return foo.x.len; } diff --git a/test/test_suite/statements/foreach_r_custom_macro.c3t b/test/test_suite/statements/foreach_r_custom_macro.c3t index 0c3ac3d5d..72bd73583 100644 --- a/test/test_suite/statements/foreach_r_custom_macro.c3t +++ b/test/test_suite/statements/foreach_r_custom_macro.c3t @@ -5,12 +5,12 @@ struct Foo int[] x; } -macro int Foo.@operator_element_at(Foo &foo, usize index) @operator([]) +macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) { return foo.x[index]; } -macro usize Foo.@operator_len(Foo &foo) @operator(len) +macro usz Foo.@operator_len(Foo &foo) @operator(len) { return foo.x.len; } diff --git a/test/test_suite/struct/struct_const_construct_simple.c3t b/test/test_suite/struct/struct_const_construct_simple.c3t index a20c36d8d..badb3449d 100644 --- a/test/test_suite/struct/struct_const_construct_simple.c3t +++ b/test/test_suite/struct/struct_const_construct_simple.c3t @@ -7,7 +7,7 @@ struct Foo long bar; } -private usize x = Foo.sizeof; +private usz x = Foo.sizeof; private Foo foo1 = { 1, 2 }; private Foo foo2 = { .foo = 2 }; diff --git a/test/test_suite2/abi/sysv_abi_avx.c3t b/test/test_suite2/abi/sysv_abi_avx.c3t index f25bb9300..44d71bb5c 100644 --- a/test/test_suite2/abi/sysv_abi_avx.c3t +++ b/test/test_suite2/abi/sysv_abi_avx.c3t @@ -5,7 +5,7 @@ module foo; struct StringRef { char* str; - usize size; + usz size; } char gc; diff --git a/test/test_suite2/abi/sysv_abi_noavx.c3t b/test/test_suite2/abi/sysv_abi_noavx.c3t index e55821ecf..e3ee93e90 100644 --- a/test/test_suite2/abi/sysv_abi_noavx.c3t +++ b/test/test_suite2/abi/sysv_abi_noavx.c3t @@ -5,7 +5,7 @@ module foo; struct StringRef { char* str; - usize size; + usz size; } char gc; diff --git a/test/test_suite2/asm/asm_regression.c3t b/test/test_suite2/asm/asm_regression.c3t index ab6aa0525..5064780d7 100644 --- a/test/test_suite2/asm/asm_regression.c3t +++ b/test/test_suite2/asm/asm_regression.c3t @@ -13,7 +13,7 @@ fn void main() int* gp = &g; int[4] a = { 3, 4, 5, 6 }; int* xa = &a; - usize asf = 1; + usz asf = 1; int aa = 3; asm { diff --git a/test/test_suite2/compile_time/compile_time_pointers.c3t b/test/test_suite2/compile_time/compile_time_pointers.c3t index 4c60c3372..6e115970b 100644 --- a/test/test_suite2/compile_time/compile_time_pointers.c3t +++ b/test/test_suite2/compile_time/compile_time_pointers.c3t @@ -4,12 +4,12 @@ module test; const uptr ABC = 0x213; const void* BAC = (void*)144 - 1; const void* EXX = (void*)155; -const iptrdiff KEX = BAC - EXX; +const isz KEX = BAC - EXX; const void* CAB = BAC; const uptr ZAB = (uptr)CAB; const int* BOB = (int*)16 - 1; const int* BAB = (int*)16 + 1; -const iptrdiff AO = BAB - BOB; +const isz AO = BAB - BOB; $if (ZAB > 100): int abc = 123; diff --git a/test/test_suite2/distinct/distinct_struct_array.c3 b/test/test_suite2/distinct/distinct_struct_array.c3 index 9794d6363..f6e4eb4e1 100644 --- a/test/test_suite2/distinct/distinct_struct_array.c3 +++ b/test/test_suite2/distinct/distinct_struct_array.c3 @@ -14,6 +14,6 @@ define StructArr = distinct Struct2[3]; fn void test(int x) { StructArr z = { { .x = 1 }, { .y = x }, { 1, 2 }}; - usize len = z.len; + usz len = z.len; Foo zz = z[2].x; } diff --git a/test/test_suite2/errors/error_regression_2.c3t b/test/test_suite2/errors/error_regression_2.c3t index a429d8e30..5021b89c5 100644 --- a/test/test_suite2/errors/error_regression_2.c3t +++ b/test/test_suite2/errors/error_regression_2.c3t @@ -22,12 +22,12 @@ fn void Summary.print(Summary *s, CFile out) fn bool contains(char[] haystack, char[] needle) { - usize len = haystack.len; - usize needle_len = needle.len; + usz len = haystack.len; + usz needle_len = needle.len; if (len < needle_len) return false; if (!needle_len) return true; len -= needle_len - 1; - for (usize i = 0; i < len; i++) + for (usz i = 0; i < len; i++) { if (libc::memcmp(&haystack[i], needle.ptr, needle_len) == 0) { diff --git a/test/test_suite2/examples/gameoflife.c3 b/test/test_suite2/examples/gameoflife.c3 index a663e892e..676449291 100644 --- a/test/test_suite2/examples/gameoflife.c3 +++ b/test/test_suite2/examples/gameoflife.c3 @@ -5,7 +5,7 @@ extern fn int atoi(char *val); extern void *__stdoutp; extern fn void fflush(void *std); extern fn int rand(); -extern fn void* malloc(usize size); +extern fn void* malloc(usz size); extern fn void usleep(int time); diff --git a/test/test_suite2/expressions/casts/cast_func_to_various.c3 b/test/test_suite2/expressions/casts/cast_func_to_various.c3 index 6c747a215..2d358af62 100644 --- a/test/test_suite2/expressions/casts/cast_func_to_various.c3 +++ b/test/test_suite2/expressions/casts/cast_func_to_various.c3 @@ -36,7 +36,7 @@ fn void test4(Func arg) fn void test7(Func arg) { - usize g = (usize)(arg); + usz g = (usz)(arg); FuncOther k = (FuncOther)(arg); FuncSame l = (FuncSame)(arg); FuncOther ke = arg; // #error: 'Func' (fn void(int)) to 'FuncOther' (fn bool(char*)) diff --git a/test/test_suite2/expressions/fail_index_usize.c3 b/test/test_suite2/expressions/fail_index_usize.c3 index 911ebd3e0..80e6f0c40 100644 --- a/test/test_suite2/expressions/fail_index_usize.c3 +++ b/test/test_suite2/expressions/fail_index_usize.c3 @@ -1,4 +1,4 @@ -fn void test(int* array, usize n) +fn void test(int* array, usz n) { array[n] = 33; n[array] = 33; // #error: Cannot index diff --git a/test/test_suite2/expressions/type_support.c3t b/test/test_suite2/expressions/type_support.c3t index a5ec1158b..3a08d7781 100644 --- a/test/test_suite2/expressions/type_support.c3t +++ b/test/test_suite2/expressions/type_support.c3t @@ -16,9 +16,9 @@ macro print_type_info(...) fn void main() { io::printfln("Unsigned integers:"); - print_type_info(char, ushort, uint, ulong, uptr, uptrdiff, usize); + print_type_info(char, ushort, uint, ulong, uptr, usz, usz); io::printfln("Signed integers:"); - print_type_info(ichar, short, int, long, iptr, iptrdiff, isize); + print_type_info(ichar, short, int, long, iptr, isz, isz); io::printfln("Floats:"); print_type_info(float, double); } diff --git a/test/test_suite2/initializer_lists/fasta.c3t b/test/test_suite2/initializer_lists/fasta.c3t index d30a7c64b..bb38c3c9c 100644 --- a/test/test_suite2/initializer_lists/fasta.c3t +++ b/test/test_suite2/initializer_lists/fasta.c3t @@ -58,7 +58,7 @@ const LINELEN = 60; // slowest character-at-a-time output fn void repeat_fasta(char[] seq, int n) { - usize len = seq.len; + usz len = seq.len; int i = void; for (i = 0; i < n; i++) { diff --git a/test/test_suite2/macros/userland_bitcast.c3t b/test/test_suite2/macros/userland_bitcast.c3t index ec8a0316a..bc1d944fe 100644 --- a/test/test_suite2/macros/userland_bitcast.c3t +++ b/test/test_suite2/macros/userland_bitcast.c3t @@ -4,33 +4,33 @@ macro testbitcast(expr, $Type) { $assert($sizeof(expr) == $Type.sizeof, "Cannot bitcast between types of different size."); $Type x = void; - var $size = (usize)($sizeof(expr)); + var $size = (usz)($sizeof(expr)); $if ($alignof(expr) >= 8 && $Type.alignof >= 8): ulong *b = (ulong*)(&expr); ulong *to = (ulong*)(&x); - for (usize i = 0; i < $size; i += 8) + for (usz i = 0; i < $size; i += 8) { to[i] = b[i]; } $elif ($alignof(expr) >= 4 && $Type.alignof >= 4): uint* b = (uint*)(&expr); uint* to = (uint*)(&x); - for (usize i = 0; i < $size; i += 4) + for (usz i = 0; i < $size; i += 4) { to[i] = b[i]; } $elif ($alignof(expr) >= 2 && $Type.alignof >= 2): ushort* b = (ushort*)(&expr); ushort* to = (ushort*)(&x); - for (usize i = 0; i < $size; i += 2) + for (usz i = 0; i < $size; i += 2) { to[i] = b[i]; } $else: char* b = (char*)(&expr); char* to = (char*)(&x); - for (usize i = 0; i < $size; i++) + for (usz i = 0; i < $size; i++) { to[i] = b[i]; } diff --git a/test/test_suite2/methods/extension_method_generic.c3 b/test/test_suite2/methods/extension_method_generic.c3 index 29c452f8d..ab13e4eb1 100644 --- a/test/test_suite2/methods/extension_method_generic.c3 +++ b/test/test_suite2/methods/extension_method_generic.c3 @@ -5,7 +5,7 @@ define IntArray = List; extern fn void printf(char*, ...); -fn void IntArray.someFunc(IntArray *this, usize param) { +fn void IntArray.someFunc(IntArray *this, usz param) { //do something this.push((int)param); } diff --git a/test/test_suite2/statements/foreach_custom.c3t b/test/test_suite2/statements/foreach_custom.c3t index f94116d9a..2c76f8bfa 100644 --- a/test/test_suite2/statements/foreach_custom.c3t +++ b/test/test_suite2/statements/foreach_custom.c3t @@ -6,12 +6,12 @@ struct Foo int[] x; } -macro int Foo.@operator_element_at(Foo &foo, usize index) @operator([]) +macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) { return foo.x[index]; } -macro usize Foo.@operator_len(Foo &foo) @operator(len) +macro usz Foo.@operator_len(Foo &foo) @operator(len) { return foo.x.len; } diff --git a/test/test_suite2/statements/foreach_custom_macro.c3t b/test/test_suite2/statements/foreach_custom_macro.c3t index 87e0b3bc6..47347644a 100644 --- a/test/test_suite2/statements/foreach_custom_macro.c3t +++ b/test/test_suite2/statements/foreach_custom_macro.c3t @@ -5,12 +5,12 @@ struct Foo int[] x; } -macro int Foo.@operator_element_at(Foo &foo, usize index) @operator([]) +macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) { return foo.x[index]; } -macro usize Foo.@operator_len(Foo &foo) @operator(len) +macro usz Foo.@operator_len(Foo &foo) @operator(len) { return foo.x.len; } diff --git a/test/test_suite2/statements/foreach_more_implementations.c3t b/test/test_suite2/statements/foreach_more_implementations.c3t index 1be5fb012..fbff1e940 100644 --- a/test/test_suite2/statements/foreach_more_implementations.c3t +++ b/test/test_suite2/statements/foreach_more_implementations.c3t @@ -4,21 +4,21 @@ module test; import std::io; struct Vector { - usize size; + usz size; int* elements; } -macro int Vector.get(Vector* vector, usize element) @operator([]) +macro int Vector.get(Vector* vector, usz element) @operator([]) { return vector.elements[element]; } -macro int* Vector.get_ref(Vector* vector, usize element) @operator(&[]) +macro int* Vector.get_ref(Vector* vector, usz element) @operator(&[]) { return &vector.elements[element]; } -macro usize Vector.size(Vector vector) @operator(len) { +macro usz Vector.size(Vector vector) @operator(len) { return vector.size; } diff --git a/test/test_suite2/statements/foreach_r_custom.c3t b/test/test_suite2/statements/foreach_r_custom.c3t index d627ba7ac..9540756fa 100644 --- a/test/test_suite2/statements/foreach_r_custom.c3t +++ b/test/test_suite2/statements/foreach_r_custom.c3t @@ -6,12 +6,12 @@ struct Foo int[] x; } -macro int Foo.@operator_element_at(Foo &foo, usize index) @operator([]) +macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) { return foo.x[index]; } -macro usize Foo.@operator_len(Foo &foo) @operator(len) +macro usz Foo.@operator_len(Foo &foo) @operator(len) { return foo.x.len; } diff --git a/test/test_suite2/statements/foreach_r_custom_macro.c3t b/test/test_suite2/statements/foreach_r_custom_macro.c3t index 9b0cb771a..7133b7456 100644 --- a/test/test_suite2/statements/foreach_r_custom_macro.c3t +++ b/test/test_suite2/statements/foreach_r_custom_macro.c3t @@ -5,12 +5,12 @@ struct Foo int[] x; } -macro int Foo.@operator_element_at(Foo &foo, usize index) @operator([]) +macro int Foo.@operator_element_at(Foo &foo, usz index) @operator([]) { return foo.x[index]; } -macro usize Foo.@operator_len(Foo &foo) @operator(len) +macro usz Foo.@operator_len(Foo &foo) @operator(len) { return foo.x.len; } diff --git a/test/test_suite2/struct/struct_const_construct_simple.c3t b/test/test_suite2/struct/struct_const_construct_simple.c3t index 54e473501..0f3192eb8 100644 --- a/test/test_suite2/struct/struct_const_construct_simple.c3t +++ b/test/test_suite2/struct/struct_const_construct_simple.c3t @@ -7,7 +7,7 @@ struct Foo long bar; } -private usize x = Foo.sizeof; +private usz x = Foo.sizeof; private Foo foo1 = { 1, 2 }; private Foo foo2 = { .foo = 2 };