From aeaef8c0ffadab4145fd002f2edd87a6db66ebd1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Feb 2023 09:02:57 -0700 Subject: update std lib and compiler sources to new for loop syntax --- src/arch/wasm/CodeGen.zig | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/arch/wasm/CodeGen.zig') diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index 7ce6a0482b..53dc28626c 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -1255,7 +1255,7 @@ fn genFunc(func: *CodeGen) InnerError!void { // reserve space and insert all prologue instructions at the front of the instruction list // We insert them in reserve order as there is no insertSlice in multiArrayList. try func.mir_instructions.ensureUnusedCapacity(func.gpa, prologue.items.len); - for (prologue.items) |_, index| { + for (prologue.items, 0..) |_, index| { const inst = prologue.items[prologue.items.len - 1 - index]; func.mir_instructions.insertAssumeCapacity(0, inst); } @@ -3117,7 +3117,7 @@ fn mergeBranch(func: *CodeGen, branch: *const Branch) !void { const target_values = target_slice.items(.value); try parent.values.ensureUnusedCapacity(func.gpa, branch.values.count()); - for (target_keys) |key, index| { + for (target_keys, 0..) |key, index| { // TODO: process deaths from branches parent.values.putAssumeCapacity(key, target_values[index]); } @@ -3501,7 +3501,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { const values = try func.gpa.alloc(CaseValue, items.len); errdefer func.gpa.free(values); - for (items) |ref, i| { + for (items, 0..) |ref, i| { const item_val = func.air.value(ref).?; const int_val = func.valueAsI32(item_val, target_ty); if (lowest_maybe == null or int_val < lowest_maybe.?) { @@ -3561,7 +3561,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { while (value <= highest) : (value += 1) { // idx represents the branch we jump to const idx = blk: { - for (case_list.items) |case, idx| { + for (case_list.items, 0..) |case, idx| { for (case.values) |case_value| { if (case_value.integer == value) break :blk @intCast(u32, idx); } @@ -3588,7 +3588,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { }; try func.branches.ensureUnusedCapacity(func.gpa, case_list.items.len + @boolToInt(has_else_body)); - for (case_list.items) |case, index| { + for (case_list.items, 0..) |case, index| { // when sparse, we use if/else-chain, so emit conditional checks if (is_sparse) { // for single value prong we can emit a simple if @@ -4558,7 +4558,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { // copy stack pointer into a temporary local, which is // moved for each element to store each value in the right position. const offset = try func.buildPointerOffset(result, 0, .new); - for (elements) |elem, elem_index| { + for (elements, 0..) |elem, elem_index| { const elem_val = try func.resolveInst(elem); try func.store(offset, elem_val, elem_ty, 0); @@ -4587,7 +4587,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { // we ensure a new local is created so it's zero-initialized const result = try func.ensureAllocLocal(backing_type); var current_bit: u16 = 0; - for (elements) |elem, elem_index| { + for (elements, 0..) |elem, elem_index| { const field = fields[elem_index]; if (!field.ty.hasRuntimeBitsIgnoreComptime()) continue; @@ -4623,7 +4623,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { else => { const result = try func.allocStack(result_ty); const offset = try func.buildPointerOffset(result, 0, .new); // pointer to offset - for (elements) |elem, elem_index| { + for (elements, 0..) |elem, elem_index| { if (result_ty.structFieldValueComptime(elem_index) != null) continue; const elem_ty = result_ty.structFieldType(elem_index); @@ -6149,7 +6149,7 @@ fn callIntrinsic( } else WValue{ .none = {} }; // Lower all arguments to the stack before we call our function - for (args) |arg, arg_i| { + for (args, 0..) |arg, arg_i| { assert(!(want_sret_param and arg == .stack)); assert(param_types[arg_i].hasRuntimeBitsIgnoreComptime()); try func.lowerArg(.C, param_types[arg_i], arg); -- cgit v1.2.3