Use shorthand assignment syntax where possible

610f0e95b38de4157af0ebca998d95150282bc1a64770cb058ee7440ad25f5ed
Use eg. `x += y` instead of `x = x + y` now that it's supported.
Alexis Sellier committed ago 1 parent 18a89807
compiler/radiance.rad +15 -15
220 220
    let mut idx: u32 = 0;
221 221
222 222
    while idx < args.len {
223 223
        let arg = args[idx];
224 224
        if mem::eq(arg, "-pkg") {
225 -
            idx = idx + 1;
225 +
            idx += 1;
226 226
            if idx >= args.len {
227 227
                io::printError("radiance: `-pkg` requires a package name\n");
228 228
                throw Error::Other;
229 229
            }
230 230
            if pkgCount >= MAX_PACKAGES {
231 231
                io::printError("radiance: too many packages specified\n");
232 232
                throw Error::Other;
233 233
            }
234 234
            pkgNames[pkgCount] = args[idx];
235 235
            currentPkgIdx = pkgCount;
236 -
            pkgCount = pkgCount + 1;
236 +
            pkgCount += 1;
237 237
        } else if mem::eq(arg, "-mod") {
238 -
            idx = idx + 1;
238 +
            idx += 1;
239 239
            if idx >= args.len {
240 240
                io::printError("radiance: `-mod` requires a module path\n");
241 241
                throw Error::Other;
242 242
            }
243 243
            let pkgIdx = currentPkgIdx else {
247 247
            if moduleCounts[pkgIdx] >= MAX_LOADED_MODULES {
248 248
                io::printError("radiance: too many modules specified for package\n");
249 249
                throw Error::Other;
250 250
            }
251 251
            modulePaths[pkgIdx][moduleCounts[pkgIdx]] = args[idx];
252 -
            moduleCounts[pkgIdx] = moduleCounts[pkgIdx] + 1;
252 +
            moduleCounts[pkgIdx] += 1;
253 253
        } else if mem::eq(arg, "-entry") {
254 -
            idx = idx + 1;
254 +
            idx += 1;
255 255
            if idx >= args.len {
256 256
                io::printError("radiance: `-entry` requires a package name\n");
257 257
                throw Error::Other;
258 258
            }
259 259
            entryPkgName = args[idx];
260 260
        } else if mem::eq(arg, "-test") {
261 261
            buildTest = true;
262 262
        } else if mem::eq(arg, "-debug") {
263 263
            debugEnabled = true;
264 264
        } else if mem::eq(arg, "-o") {
265 -
            idx = idx + 1;
265 +
            idx += 1;
266 266
            if idx >= args.len {
267 267
                io::printError("radiance: `-o` requires an output path\n");
268 268
                throw Error::Other;
269 269
            }
270 270
            outputPath = args[idx];
271 271
        } else if mem::eq(arg, "-dump") {
272 -
            idx = idx + 1;
272 +
            idx += 1;
273 273
            if idx >= args.len {
274 274
                io::printError("radiance: `-dump` requires a mode (eg. ast)\n");
275 275
                throw Error::Other;
276 276
            }
277 277
            let mode = args[idx];
293 293
            io::printError("radiance: unknown argument `");
294 294
            io::printError(arg);
295 295
            io::printError("`\n");
296 296
            throw Error::Other;
297 297
        }
298 -
        idx = idx + 1;
298 +
        idx += 1;
299 299
    }
300 300
    if pkgCount == 0 {
301 301
        io::printError("radiance: no package specified\n");
302 302
        throw Error::Other;
303 303
    }
520 520
        let stmt = block.statements.list[i];
521 521
        if let case ast::NodeValue::FnDecl(decl) = stmt.value {
522 522
            if let fnName = getTestFnName(&decl) {
523 523
                if *testCount < tests.len {
524 524
                    tests[*testCount] = TestDesc { modPath, fnName };
525 -
                    *testCount = *testCount + 1;
525 +
                    *testCount += 1;
526 526
                } else {
527 527
                    panic "collectModuleTests: too many tests";
528 528
                }
529 529
            }
530 530
        }
690 690
        return;
691 691
    }
692 692
    let mut path: [u8; MAX_PATH_LEN] = undefined;
693 693
    let mut pos: u32 = 0;
694 694
695 -
    pos = pos + try! mem::copy(&mut path[pos..], basePath);
696 -
    pos = pos + try! mem::copy(&mut path[pos..], ext);
695 +
    pos += try! mem::copy(&mut path[pos..], basePath);
696 +
    pos += try! mem::copy(&mut path[pos..], ext);
697 697
    path[pos] = 0; // Null-terminate for syscall.
698 698
699 699
    if not unix::writeFile(&path[..pos], data) {
700 700
        io::printError("radiance: fatal: failed to write data file\n");
701 701
        throw Error::Other;
721 721
    for i in 0..entries.len {
722 722
        let entry = &entries[i];
723 723
        let modEntry = module::get(graph, entry.moduleId) else {
724 724
            panic "writeDebugInfo: module not found for debug entry";
725 725
        };
726 -
        pos = pos + try! mem::copy(&mut buf[pos..], @sliceOf(&entry.pc as *u8, 4));
727 -
        pos = pos + try! mem::copy(&mut buf[pos..], @sliceOf(&entry.offset as *u8, 4));
728 -
        pos = pos + try! mem::copy(&mut buf[pos..], modEntry.filePath);
726 +
        pos += try! mem::copy(&mut buf[pos..], @sliceOf(&entry.pc as *u8, 4));
727 +
        pos += try! mem::copy(&mut buf[pos..], @sliceOf(&entry.offset as *u8, 4));
728 +
        pos += try! mem::copy(&mut buf[pos..], modEntry.filePath);
729 729
730 730
        buf[pos] = 0;
731 -
        pos = pos + 1;
731 +
        pos += 1;
732 732
    }
733 733
    try writeDataWithExt(&buf[..pos], basePath, DEBUG_EXT);
734 734
}
735 735
736 736
/// Run the resolver on the parsed modules.
lib/std/arch/rv64.rad +9 -9
197 197
    for i in 0..program.data.len {
198 198
        let data = &program.data[i];
199 199
        if data.readOnly == readOnly and not data.isUndefined {
200 200
            offset = mem::alignUp(offset, data.alignment);
201 201
            syms[*count] = DataSym { name: data.name, addr: base + offset };
202 -
            *count = *count + 1;
203 -
            offset = offset + data.size;
202 +
            *count += 1;
203 +
            offset += data.size;
204 204
        }
205 205
    }
206 206
    // Uninitialized data after.
207 207
    for i in 0..program.data.len {
208 208
        let data = &program.data[i];
209 209
        if data.readOnly == readOnly and data.isUndefined {
210 210
            offset = mem::alignUp(offset, data.alignment);
211 211
            syms[*count] = DataSym { name: data.name, addr: base + offset };
212 -
            *count = *count + 1;
213 -
            offset = offset + data.size;
212 +
            *count += 1;
213 +
            offset += data.size;
214 214
        }
215 215
    }
216 216
    return offset;
217 217
}
218 218
242 242
                    match v.item {
243 243
                        case il::DataItem::Val { typ, val } => {
244 244
                            let size = il::typeSize(typ);
245 245
                            let valPtr = &val as *u8;
246 246
                            try! mem::copy(&mut buf[offset..], @sliceOf(valPtr, size));
247 -
                            offset = offset + size;
247 +
                            offset += size;
248 248
                        },
249 249
                        case il::DataItem::Sym(name) => {
250 250
                            let addr = lookupDataSymAddr(dataSyms, name) else {
251 251
                                panic "emitSection: data symbol not found";
252 252
                            };
259 259
                            let hiPtr = &hi as *u8;
260 260
261 261
                            try! mem::copy(&mut buf[offset..], @sliceOf(loPtr, 4));
262 262
                            try! mem::copy(&mut buf[(offset + 4)..], @sliceOf(hiPtr, 4));
263 263
264 -
                            offset = offset + 8;
264 +
                            offset += 8;
265 265
                        },
266 266
                        case il::DataItem::Fn(name) => {
267 267
                            let addr = codeBase + labels::funcOffset(fnLabels, name) as u32;
268 268
                            let lo: u32 = addr;
269 269
                            let hi: u32 = 0;
271 271
                            let hiPtr = &hi as *u8;
272 272
273 273
                            try! mem::copy(&mut buf[offset..], @sliceOf(loPtr, 4));
274 274
                            try! mem::copy(&mut buf[(offset + 4)..], @sliceOf(hiPtr, 4));
275 275
276 -
                            offset = offset + 8;
276 +
                            offset += 8;
277 277
                        },
278 278
                        case il::DataItem::Str(s) => {
279 279
                            try! mem::copy(&mut buf[offset..], s);
280 -
                            offset = offset + s.len;
280 +
                            offset += s.len;
281 281
                        },
282 282
                        case il::DataItem::Undef => {
283 283
                            buf[offset] = 0;
284 -
                            offset = offset + 1;
284 +
                            offset += 1;
285 285
                        },
286 286
                    }
287 287
                }
288 288
            }
289 289
        }
lib/std/arch/rv64/emit.rad +9 -9
167 167
        if (usedCalleeSaved & (1 << i)) != 0 {
168 168
            frame.savedRegs[frame.savedRegsLen] = SavedReg {
169 169
                reg: super::CALLEE_SAVED[i],
170 170
                offset,
171 171
            };
172 -
            frame.savedRegsLen = frame.savedRegsLen + 1;
173 -
            offset = offset - super::DWORD_SIZE;
172 +
            frame.savedRegsLen += 1;
173 +
            offset -= super::DWORD_SIZE;
174 174
        }
175 175
    }
176 176
    return frame;
177 177
}
178 178
217 217
pub fn emit(e: *mut Emitter, instr: u32) {
218 218
    if e.codeLen >= e.code.len {
219 219
        panic "emit: code buffer full";
220 220
    }
221 221
    e.code[e.codeLen] = instr;
222 -
    e.codeLen = e.codeLen + 1;
222 +
    e.codeLen += 1;
223 223
}
224 224
225 225
/// Compute branch offset to a function by name.
226 226
pub fn branchOffsetToFunc(e: *Emitter, srcIndex: u32, name: *[u8]) -> i32 {
227 227
    return labels::branchToFunc(&e.labels, srcIndex, name, super::INSTR_SIZE);
248 248
pub fn recordFunc(e: *mut Emitter, name: *[u8]) {
249 249
    if e.funcsLen >= e.funcs.len {
250 250
        panic "recordFunc: funcs buffer full";
251 251
    }
252 252
    e.funcs[e.funcsLen] = FuncAddr { name, index: e.codeLen };
253 -
    e.funcsLen = e.funcsLen + 1;
253 +
    e.funcsLen += 1;
254 254
}
255 255
256 256
/// Record a local branch needing later patching.
257 257
/// Emits two placeholder instructions that will be patched later.
258 258
pub fn recordBranch(e: *mut Emitter, targetBlock: u32, kind: BranchKind) {
262 262
    e.pendingBranches[e.pendingBranchesLen] = PendingBranch {
263 263
        index: e.codeLen,
264 264
        target: targetBlock,
265 265
        kind: kind,
266 266
    };
267 -
    e.pendingBranchesLen = e.pendingBranchesLen + 1;
267 +
    e.pendingBranchesLen += 1;
268 268
269 269
    emit(e, encode::nop()); // Placeholder for branch/auipc.
270 270
    emit(e, encode::nop()); // Placeholder for nop/jal/jalr.
271 271
}
272 272
279 279
    }
280 280
    e.pendingCalls[e.pendingCallsLen] = PendingCall {
281 281
        index: e.codeLen,
282 282
        target,
283 283
    };
284 -
    e.pendingCallsLen = e.pendingCallsLen + 1;
284 +
    e.pendingCallsLen += 1;
285 285
286 286
    emit(e, encode::nop()); // Placeholder for AUIPC.
287 287
    emit(e, encode::nop()); // Placeholder for JALR.
288 288
}
289 289
297 297
    e.pendingAddrLoads[e.pendingAddrLoadsLen] = PendingAddrLoad {
298 298
        index: e.codeLen,
299 299
        target,
300 300
        rd: rd,
301 301
    };
302 -
    e.pendingAddrLoadsLen = e.pendingAddrLoadsLen + 1;
302 +
    e.pendingAddrLoadsLen += 1;
303 303
304 304
    emit(e, encode::nop()); // Placeholder for AUIPC.
305 305
    emit(e, encode::nop()); // Placeholder for ADDI.
306 306
}
307 307
430 430
    let lo = imm & 0xFFF;
431 431
    let mut hi = (imm >> 12) & 0xFFFFF;
432 432
    // If `lo`'s sign bit is set, it will be sign-extended to negative.
433 433
    // Compensate by incrementing `hi`.
434 434
    if (lo & 0x800) != 0 {
435 -
        hi = hi + 1;
435 +
        hi += 1;
436 436
        return SplitImm { hi, lo: lo | 0xFFFFF000 as i32 };
437 437
    }
438 438
    return SplitImm { hi, lo };
439 439
}
440 440
685 685
    e.debugEntries[e.debugEntriesLen] = DebugEntry {
686 686
        pc,
687 687
        moduleId: loc.moduleId,
688 688
        offset: loc.offset,
689 689
    };
690 -
    e.debugEntriesLen = e.debugEntriesLen + 1;
690 +
    e.debugEntriesLen += 1;
691 691
}
692 692
693 693
/// Get debug entries as a slice.
694 694
pub fn getDebugEntries(e: *Emitter) -> *[DebugEntry] {
695 695
    return &e.debugEntries[..e.debugEntriesLen];
lib/std/arch/rv64/isel.rad +11 -11
239 239
        for i in 0..block.instrs.len {
240 240
            match block.instrs.list[i] {
241 241
                case il::Instr::Reserve { size, alignment, .. } => {
242 242
                    if let case il::Val::Imm(sz) = size {
243 243
                        offset = mem::alignUpI32(offset, alignment as i32);
244 -
                        offset = offset + (sz as i32);
244 +
                        offset += (sz as i32);
245 245
                    }
246 246
                },
247 247
                else => {},
248 248
            }
249 249
        }
451 451
                    emit::emitLd(s.e, super::SCRATCH1, super::SCRATCH1, offset);
452 452
                } else {
453 453
                    emit::emitLd(s.e, super::SCRATCH1, rsrc, offset);
454 454
                }
455 455
                emit::emitSd(s.e, super::SCRATCH1, rdst, offset);
456 -
                offset = offset + super::DWORD_SIZE;
457 -
                remaining = remaining - super::DWORD_SIZE;
456 +
                offset += super::DWORD_SIZE;
457 +
                remaining -= super::DWORD_SIZE;
458 458
            }
459 459
            if remaining >= super::WORD_SIZE {
460 460
                if offset > super::MAX_IMM - super::WORD_SIZE {
461 461
                    emit::emitAddImm(s.e, rsrc, rsrc, offset);
462 462
                    if rdst.n != rsrc.n {
469 469
                    emit::emitLw(s.e, super::SCRATCH1, super::SCRATCH1, offset);
470 470
                } else {
471 471
                    emit::emitLw(s.e, super::SCRATCH1, rsrc, offset);
472 472
                }
473 473
                emit::emitSw(s.e, super::SCRATCH1, rdst, offset);
474 -
                offset = offset + super::WORD_SIZE;
475 -
                remaining = remaining - super::WORD_SIZE;
474 +
                offset += super::WORD_SIZE;
475 +
                remaining -= super::WORD_SIZE;
476 476
            }
477 477
            while remaining > 0 {
478 478
                if offset > super::MAX_IMM - 1 {
479 479
                    emit::emitAddImm(s.e, rsrc, rsrc, offset);
480 480
                    if rdst.n != rsrc.n {
487 487
                    emit::emitLb(s.e, super::SCRATCH1, super::SCRATCH1, offset);
488 488
                } else {
489 489
                    emit::emitLb(s.e, super::SCRATCH1, rsrc, offset);
490 490
                }
491 491
                emit::emitSb(s.e, super::SCRATCH1, rdst, offset);
492 -
                offset = offset + 1;
493 -
                remaining = remaining - 1;
492 +
                offset += 1;
493 +
                remaining -= 1;
494 494
            }
495 495
            // Restore base registers if they were advanced (never happens
496 496
            // in the both-spilled case since size <= MAX_IMM).
497 497
            if not bothSpilled {
498 498
                let advanced = size as i32 - offset;
903 903
            match args[i] {
904 904
                case il::Val::Reg(r) => {
905 905
                    if let _ = regalloc::spill::spillSlot(&s.ralloc.spill, r) {
906 906
                        // Spilled value needs load, not a register move.
907 907
                        pending[i] = true;
908 -
                        numPending = numPending + 1;
908 +
                        numPending += 1;
909 909
                    } else {
910 910
                        let src = getReg(s, r);
911 911
                        if src != dst {
912 912
                            // Register-to-register move needed.
913 913
                            srcRegs[i] = src;
914 914
                            isRegMove[i] = true;
915 915
                            pending[i] = true;
916 -
                            numPending = numPending + 1;
916 +
                            numPending += 1;
917 917
                        } else {
918 918
                            // No move needed.
919 919
                        }
920 920
                    }
921 921
                },
922 922
                case il::Val::Imm(_), il::Val::DataSym(_), il::Val::FnAddr(_) => {
923 923
                    pending[i] = true;
924 -
                    numPending = numPending + 1;
924 +
                    numPending += 1;
925 925
                },
926 926
                case il::Val::Undef => {
927 927
                    // Undefined values don't need any move.
928 928
                }
929 929
            }
958 958
                        // Load immediate, symbol, or spilled value.
959 959
                        loadVal(s, dst, args[i]);
960 960
                    }
961 961
                    found = true;
962 962
                    pending[i] = false;
963 -
                    numPending = numPending - 1;
963 +
                    numPending -= 1;
964 964
965 965
                    break;
966 966
                }
967 967
            }
968 968
        }
lib/std/arch/rv64/printer.rad +1 -1
97 97
fn writeMnem(out: *mut sexpr::Output, m: *[u8]) {
98 98
    write(out, m);
99 99
    let mut i = m.len;
100 100
    while i < MNEMONIC_WIDTH {
101 101
        write(out, " ");
102 -
        i = i + 1;
102 +
        i += 1;
103 103
    }
104 104
}
105 105
106 106
////////////////////////////////
107 107
// Instruction Format Helpers //
lib/std/arch/rv64/tests/aggregate.return.rad +2 -2
100 100
fn testAggregateReturnInLoop() -> i32 {
101 101
    let mut total: u32 = 0;
102 102
    let mut idx: u32 = 0;
103 103
    while idx < 5 {
104 104
        let p: Pair = makePair(idx, idx + 10);
105 -
        total = total + p.a + p.b;
106 -
        idx = idx + 1;
105 +
        total += p.a + p.b;
106 +
        idx += 1;
107 107
    }
108 108
    // total = sum(i + i+10 for i in 0..5) = sum(2i+10) = 2*(0+1+2+3+4) + 50 = 20 + 50 = 70
109 109
    if total != 70 {
110 110
        return 1;
111 111
    }
lib/std/arch/rv64/tests/arith.assignment.rad +7 -7
6 6
7 7
    // Test addition.
8 8
    c = a + b; // c = 9
9 9
10 10
    // Test subtraction.
11 -
    c = c - b; // c = 6
11 +
    c -= b; // c = 6
12 12
13 13
    // Test multiplication.
14 -
    c = c * b; // c = 18
14 +
    c *= b; // c = 18
15 15
16 16
    // Test division.
17 -
    c = c / b; // c = 6
17 +
    c /= b; // c = 6
18 18
19 19
    // Test mixed operations.
20 20
    d = a * b + c / b;   // d = 18 + 2 = 20
21 -
    d = d + a * b / a;   // d = 20 + 3 = 23
22 -
    d = d + (b * a - c); // d = 23 + (18 - 6) = 35
23 -
    d = d + (c - a / b); // d = 35 + (6 - 2) = 39
24 -
    d = d + 3;           // d = 42
21 +
    d += a * b / a;   // d = 20 + 3 = 23
22 +
    d += (b * a - c); // d = 23 + (18 - 6) = 35
23 +
    d += (c - a / b); // d = 35 + (6 - 2) = 39
24 +
    d += 3;           // d = 42
25 25
26 26
    return (d) - 42;
27 27
}
lib/std/arch/rv64/tests/array.index.assign.rad +5 -5
9 9
    arr[3] = 40;
10 10
    arr[4] = 50;
11 11
12 12
    let mut sum: i32 = 0;
13 13
14 -
    sum = sum + arr[0];
15 -
    sum = sum + arr[1];
16 -
    sum = sum + arr[2];
17 -
    sum = sum + arr[3];
18 -
    sum = sum - arr[4];
14 +
    sum += arr[0];
15 +
    sum += arr[1];
16 +
    sum += arr[2];
17 +
    sum += arr[3];
18 +
    sum -= arr[4];
19 19
20 20
    if sum != 50 {
21 21
        return 1;
22 22
    }
23 23
    return 0;
lib/std/arch/rv64/tests/array.index.rad +4 -4
2 2
3 3
@default fn main() -> i32 {
4 4
    let mut arr: [i32; 4] = [10, 20, 30, 40];
5 5
    let mut sum: i32 = 0;
6 6
7 -
    sum = sum + arr[0];
8 -
    sum = sum + arr[1];
9 -
    sum = sum + arr[2];
10 -
    sum = sum + arr[3];
7 +
    sum += arr[0];
8 +
    sum += arr[1];
9 +
    sum += arr[2];
10 +
    sum += arr[3];
11 11
12 12
    return (sum) - 100;
13 13
}
lib/std/arch/rv64/tests/array.length.rad +2 -2
4 4
    let mut ary: [i32; 7] = [1, 2, 3, 4, 5, 6, 7];
5 5
    let mut sum: i32 = 0;
6 6
    let mut i: u32 = 0;
7 7
8 8
    while (i < ary.len) {
9 -
        sum = sum + ary[i];
10 -
        i = i + 1;
9 +
        sum += ary[i];
10 +
        i += 1;
11 11
    }
12 12
    return (sum) - 28;
13 13
}
lib/std/arch/rv64/tests/array.math.rad +4 -4
3 3
4 4
fn sumMatrix(mat: [[i32; 3]; 2]) -> i32 {
5 5
    let mut sum: i32 = 0;
6 6
    for vec in mat {
7 7
        for x in vec {
8 -
            sum = sum + x;
8 +
            sum += x;
9 9
        }
10 10
    }
11 11
    return sum;
12 12
}
13 13
14 14
fn sumMatrixTransposed(mat: [[i32; 2]; 3]) -> i32 {
15 15
    let mut sum: i32 = 0;
16 16
    for vec in (mat) {
17 17
        for x in (vec) {
18 -
            sum = sum + x;
18 +
            sum += x;
19 19
        }
20 20
    }
21 21
    return sum;
22 22
}
23 23
28 28
29 29
    while (i < matrix.len) {
30 30
        let mut j: u32 = 0;
31 31
        while (j < matrix[i].len) {
32 32
            result[j][i] = matrix[i][j];
33 -
            j = j + 1;
33 +
            j += 1;
34 34
        }
35 -
        i = i + 1;
35 +
        i += 1;
36 36
    }
37 37
    return result;
38 38
}
39 39
40 40
@default fn main() -> i32 {
lib/std/arch/rv64/tests/array.record.elements.rad +5 -5
22 22
fn sumPoints(points: [Point; 4]) -> i32 {
23 23
    let mut sum: i32 = 0;
24 24
    let mut i: u32 = 0;
25 25
26 26
    while (i < 4) {
27 -
        sum = sum + points[i].x + points[i].y;
28 -
        i = i + 1;
27 +
        sum += points[i].x + points[i].y;
28 +
        i += 1;
29 29
    }
30 30
    return sum;
31 31
}
32 32
33 33
fn shiftPoints(points: [Point; 4], dx: i32, dy: i32) -> [Point; 4] {
41 41
    while (i < 4) {
42 42
        result[i] = Point {
43 43
            x: points[i].x + dx,
44 44
            y: points[i].y + dy
45 45
        };
46 -
        i = i + 1;
46 +
        i += 1;
47 47
    }
48 48
    return result;
49 49
}
50 50
51 51
@default fn main() -> i32 {
63 63
    let mut shifted: [Point; 4] = shiftPoints(points, 1, 1);
64 64
    // Calculate distance between original and shifted array elements.
65 65
    let mut distance: i32 = 0;
66 66
    let mut i: u32 = 0;
67 67
    while (i < points.len) {
68 -
        distance = distance + calculateDistance(points[i], shifted[i]);
69 -
        i = i + 1;
68 +
        distance += calculateDistance(points[i], shifted[i]);
69 +
        i += 1;
70 70
    }
71 71
    return total + distance + shifted[3].x - points[0].y;
72 72
}
lib/std/arch/rv64/tests/assign.mutable.rad +5 -5
16 16
fn testBasicAliasing() -> i32 {
17 17
    let mut x: i32 = 10;
18 18
    let mut y: i32 = x;  // y aliases x's value
19 19
20 20
    x = 20;          // Modify x
21 -
    y = y + 5;       // Modify y independently
21 +
    y += 5;       // Modify y independently
22 22
23 23
    return x + y;    // Should be 20 + 15 = 35
24 24
}
25 25
26 26
/// Struct aliasing and field mutation.
67 67
    let mut result: i32 = 0;
68 68
    let mut temp: i32 = 10;
69 69
    result = temp;      // First assignment
70 70
71 71
    temp = 20;          // Overwrite temp
72 -
    result = result + temp; // result = 10 + 20 = 30
72 +
    result += temp; // result = 10 + 20 = 30
73 73
74 74
    // Create new scope with same variable name
75 75
    if true {
76 76
        let mut temp: i32 = 50;   // Shadow outer temp
77 -
        result = result + temp; // result = 30 + 50 = 80
77 +
        result += temp; // result = 30 + 50 = 80
78 78
        temp = 60;        // Modify inner temp
79 -
        result = result + temp; // result = 80 + 60 = 140
79 +
        result += temp; // result = 80 + 60 = 140
80 80
    }
81 -
    result = result + temp;   // Should use outer temp (20)
81 +
    result += temp;   // Should use outer temp (20)
82 82
83 83
    return result;            // 140 + 20 = 160
84 84
}
85 85
86 86
/// Array of structs with aliasing.
lib/std/arch/rv64/tests/assign.rad +3 -3
1 1
@default fn main() -> i32 {
2 2
    let mut i: i32 = 36;
3 -
    i = i + 1; // 37
4 -
    i = i + 2; // 39
5 -
    i = i + 3; // 42
3 +
    i += 1; // 37
4 +
    i += 2; // 39
5 +
    i += 3; // 42
6 6
7 7
    return i - 42;
8 8
}
lib/std/arch/rv64/tests/assign.shadow.mutable.rad +4 -4
4 4
    let mut result: i32 = 0;
5 5
    let mut temp: i32 = 10;
6 6
    result = temp;
7 7
8 8
    temp = 20;
9 -
    result = result + temp;
9 +
    result += temp;
10 10
11 11
    if true {
12 12
        let mut temp: i32 = 50;
13 -
        result = result + temp;
13 +
        result += temp;
14 14
        temp = 60;
15 -
        result = result + temp;
15 +
        result += temp;
16 16
    }
17 17
    // Must refer to outer `temp` (20), not inner shadowed `temp` (60).
18 -
    result = result + temp;
18 +
    result += temp;
19 19
20 20
    return result;
21 21
}
22 22
23 23
@default fn main() -> i32 {
lib/std/arch/rv64/tests/bool.short.circuit.rad +1 -1
1 1
//! Test short-circuiting behavior of 'and' and 'or' operators.
2 2
fn modify(counter: *mut i32, ret: bool) -> bool {
3 -
    *counter = *counter + 1;
3 +
    *counter += 1;
4 4
    return ret;
5 5
}
6 6
7 7
@default fn main() -> i32 {
8 8
    // Test 'and' short-circuits when first operand is false.
lib/std/arch/rv64/tests/builtin.sliceof.mut.rad +8 -8
8 8
9 9
    // Create a mutable slice from the pointer and length
10 10
    let slice: *mut [i32] = @sliceOf(ptr, 4);
11 11
12 12
    // Double each element via the slice
13 -
    slice[0] = slice[0] * 2;
14 -
    slice[1] = slice[1] * 2;
15 -
    slice[2] = slice[2] * 2;
16 -
    slice[3] = slice[3] * 2;
13 +
    slice[0] *= 2;
14 +
    slice[1] *= 2;
15 +
    slice[2] *= 2;
16 +
    slice[3] *= 2;
17 17
18 18
    // Sum the modified elements
19 19
    let mut sum: i32 = 0;
20 -
    sum = sum + slice[0];
21 -
    sum = sum + slice[1];
22 -
    sum = sum + slice[2];
23 -
    sum = sum + slice[3];
20 +
    sum += slice[0];
21 +
    sum += slice[1];
22 +
    sum += slice[2];
23 +
    sum += slice[3];
24 24
25 25
    return (sum) - 200;
26 26
}
lib/std/arch/rv64/tests/builtin.sliceof.rad +4 -4
10 10
    // Create a slice from the pointer and length
11 11
    let slice: *[i32] = @sliceOf(ptr, 4);
12 12
13 13
    // Access elements via the slice and sum them
14 14
    let mut sum: i32 = 0;
15 -
    sum = sum + slice[0];
16 -
    sum = sum + slice[1];
17 -
    sum = sum + slice[2];
18 -
    sum = sum + slice[3];
15 +
    sum += slice[0];
16 +
    sum += slice[1];
17 +
    sum += slice[2];
18 +
    sum += slice[3];
19 19
20 20
    return sum;
21 21
}
lib/std/arch/rv64/tests/call.clobber.rad +1 -1
1 1
//! Test that values live across function calls are not clobbered.
2 2
fn modify(counter: *mut i32, ret: bool) -> bool {
3 -
    *counter = *counter + 1;
3 +
    *counter += 1;
4 4
    return ret;
5 5
}
6 6
7 7
@default fn main() -> i32 {
8 8
    let mut x: i32 = 0;
lib/std/arch/rv64/tests/cond.for.else.break.rad +2 -2
2 2
@default fn main() -> i32 {
3 3
    let mut i: i32 = 0;
4 4
    let xs: [i32; 7] = [1, 2, 3, 4, 5, 6, 7];
5 5
6 6
    for x in (xs) {
7 -
        i = i + x;
7 +
        i += x;
8 8
        if (i >= 10) {
9 9
            break; // This should skip the else clause.
10 10
        }
11 11
    } else {
12 -
        i = i + 100; // This should NOT run because we break.
12 +
        i += 100; // This should NOT run because we break.
13 13
    }
14 14
    return (i) - 10;
15 15
}
lib/std/arch/rv64/tests/cond.for.indexed.rad +1 -1
2 2
@default fn main() -> u32 {
3 3
    let arr: [u32; 3] = [10, 20, 30];
4 4
    let mut sum: u32 = 0;
5 5
6 6
    for value, index in arr {
7 -
        sum = sum + value + index;
7 +
        sum += value + index;
8 8
    }
9 9
    return (sum) - 63;
10 10
    //  (10+0) + (20+1) + (30+2) = 10 + 21 + 32 = 63
11 11
}
lib/std/arch/rv64/tests/cond.for.rad +1 -1
2 2
@default fn main() -> i32 {
3 3
    let mut i: i32 = 0;
4 4
    let xs: [i32; 7] = [1, 2, 3, 4, 5, 6, 7];
5 5
6 6
    for x in (xs) {
7 -
        i = i + x;
7 +
        i += x;
8 8
    }
9 9
    return (i) - 28;
10 10
}
lib/std/arch/rv64/tests/cond.for.range.indexed.rad +2 -2
5 5
    // Test range iteration with index.
6 6
    // val: 5, 6, 7, 8
7 7
    // idx: 0, 1, 2, 3
8 8
    // sum: (5+0) + (6+1) + (7+2) + (8+3) = 5 + 7 + 9 + 11 = 32
9 9
    for val, idx in 5..9 {
10 -
        sum = sum + val + idx as i32;
10 +
        sum += val + idx as i32;
11 11
    }
12 12
13 13
    // Test that value starts from a non-zero offset while index starts at 0.
14 14
    // val: 10, 11
15 15
    // idx: 0, 1
16 16
    // sum: 32 + (10-0) + (11-1) = 32 + 10 + 10 = 52
17 17
    for v, i in 10..12 {
18 -
        sum = sum + v - i as i32;
18 +
        sum += v - i as i32;
19 19
    }
20 20
21 21
    return (sum) - 52;
22 22
}
lib/std/arch/rv64/tests/cond.for.range.rad +1 -1
2 2
@default fn main() -> i32 {
3 3
    let xs: [i32; 4] = [3, 4, 5, 6];
4 4
    let mut sum: i32 = 0;
5 5
6 6
    for i in 0..xs.len {
7 -
        sum = sum + xs[i];
7 +
        sum += xs[i];
8 8
    }
9 9
    return (sum) - 18;
10 10
}
lib/std/arch/rv64/tests/cond.for.unsigned.range.rad +3 -3
3 3
    let start: u32 = 2147483647;
4 4
    let end: u32 = 2147483648;
5 5
    let mut count: i32 = 0;
6 6
7 7
    for i in start..end {
8 -
        count = count + 1;
8 +
        count += 1;
9 9
    }
10 10
    if count != 1 {
11 11
        return 1;
12 12
    }
13 13
15 15
    let start2: u32 = 2147483648;
16 16
    let end2: u32 = 2147483651;
17 17
    let mut count2: i32 = 0;
18 18
19 19
    for i in start2..end2 {
20 -
        count2 = count2 + 1;
20 +
        count2 += 1;
21 21
    }
22 22
    if count2 != 3 {
23 23
        return 2;
24 24
    }
25 25
26 26
    // Signed range still uses signed ordering.
27 27
    let mut sum: i32 = 0;
28 28
    for i in -2..2 {
29 -
        sum = sum + i;
29 +
        sum += i;
30 30
    }
31 31
    if sum != -2 {
32 32
        return 3;
33 33
    }
34 34
lib/std/arch/rv64/tests/cond.forever.break.continue.rad +1 -1
1 1
@default fn main() -> i32 {
2 2
    let mut i: i32 = 0;
3 3
4 4
    loop {
5 5
        if (i < 42) {
6 -
            i = i + 1;
6 +
            i += 1;
7 7
            continue;
8 8
        }
9 9
        break;
10 10
    }
11 11
    return (i) - 42;
lib/std/arch/rv64/tests/cond.forever.break.rad +2 -2
4 4
    loop {
5 5
        loop {
6 6
            if (i > 39) {
7 7
                break;
8 8
            }
9 -
            i = i + 1;
9 +
            i += 1;
10 10
        }
11 -
        i = i + 2;
11 +
        i += 2;
12 12
        break;
13 13
    }
14 14
    return (i) - 42;
15 15
}
lib/std/arch/rv64/tests/cond.if.else.rad +1 -1
2 2
    let mut i: i32 = 41;
3 3
4 4
    if (i == 42) {
5 5
        return (1) - 42;
6 6
    } else {
7 -
        i = i + 1;
7 +
        i += 1;
8 8
    }
9 9
10 10
    if (i == 42) {
11 11
        return (42) - 42;
12 12
    } else {
lib/std/arch/rv64/tests/cond.if.elseif.rad +2 -2
4 4
    if (i == 42) {
5 5
        return (1) - 42;
6 6
    } else if (i == 41) {
7 7
        return (1) - 42;
8 8
    } else if (i == 40) {
9 -
        i = i + 2;
9 +
        i += 2;
10 10
    } else {
11 -
        i = i + 1;
11 +
        i += 1;
12 12
    }
13 13
14 14
    if (i == 42) {
15 15
        return (42) - 42;
16 16
    } else if (i == 41) {
lib/std/arch/rv64/tests/cond.while.else.break.rad +2 -2
1 1
2 2
@default fn main() -> i32 {
3 3
    let mut i: i32 = 0;
4 4
5 5
    while (i < 100) {
6 -
        i = i + 1;
6 +
        i += 1;
7 7
        if (i == 42) {
8 8
            break; // This should skip the else clause.
9 9
        }
10 10
    } else {
11 -
        i = i + 100; // This should NOT run because we break.
11 +
        i += 100; // This should NOT run because we break.
12 12
    }
13 13
    return (i) - 42;
14 14
}
lib/std/arch/rv64/tests/cond.while.rad +1 -1
1 1
@default fn main() -> i32 {
2 2
    let mut i: i32 = 0;
3 3
4 4
    while (i < 42) {
5 -
        i = i + 1;
5 +
        i += 1;
6 6
    }
7 7
    return (i) - 42;
8 8
}
lib/std/arch/rv64/tests/const.array.copy.mutate.rad +1 -1
4 4
const SEED: [i32; 4] = [1, 2, 3, 4];
5 5
6 6
fn crunch() -> i32 {
7 7
    let mut working: [i32; 4] = SEED;
8 8
9 -
    working[0] = working[0] + 5;
9 +
    working[0] += 5;
10 10
    working[3] = working[1] + working[2];
11 11
12 12
    return working[0] + working[3];
13 13
}
14 14
lib/std/arch/rv64/tests/const.array.rad +1 -1
3 3
const NUMBERS: [i32; 4] = [1, 2, 3, 4];
4 4
5 5
@default fn main() -> i32 {
6 6
    let mut sum: i32 = 0;
7 7
    for n in (NUMBERS) {
8 -
        sum = sum + n;
8 +
        sum += n;
9 9
    }
10 10
    return (sum) - 10;
11 11
}
lib/std/arch/rv64/tests/const.record.array.rad +1 -1
15 15
16 16
fn sumPoints(points: [Point; 3]) -> i32 {
17 17
    let mut sum: i32 = 0;
18 18
19 19
    for p in (points) {
20 -
        sum = sum + p.x + p.y;
20 +
        sum += p.x + p.y;
21 21
    }
22 22
    return sum;
23 23
}
24 24
25 25
// Array of structs as a function parameter
lib/std/arch/rv64/tests/const.record.array.simple.rad +3 -3
14 14
15 15
@default fn main() -> i32 {
16 16
    let mut sum: i32 = 0;
17 17
18 18
    // Add all points' x and y values
19 -
    sum = sum + POINTS[0].x + POINTS[0].y;  // 1 + 2 = 3
20 -
    sum = sum + POINTS[1].x + POINTS[1].y;  // 3 + 4 = 7
21 -
    sum = sum + POINTS[2].x + POINTS[2].y;  // 5 + 6 = 11
19 +
    sum += POINTS[0].x + POINTS[0].y;  // 1 + 2 = 3
20 +
    sum += POINTS[1].x + POINTS[1].y;  // 3 + 4 = 7
21 +
    sum += POINTS[2].x + POINTS[2].y;  // 5 + 6 = 11
22 22
23 23
    return (sum) - 21;  // 3 + 7 + 11 = 21
24 24
}
lib/std/arch/rv64/tests/error.try.optional.rad +2 -2
98 98
99 99
    // Test 7: try? in while-let loop
100 100
    let mut count: u32 = 0;
101 101
    let mut iter: u32 = 0;
102 102
    while let value = try? maybeValue(iter) {
103 -
        count = count + value;
104 -
        iter = iter + 1;
103 +
        count += value;
104 +
        iter += 1;
105 105
    }
106 106
    if count != 6 {
107 107
        return 13;
108 108
    }
109 109
lib/std/arch/rv64/tests/error.try.rad +7 -7
37 37
38 38
fn shortCircuit(flag: bool) -> u32 throws (TestError) {
39 39
    let mut counter: u32 = 1;
40 40
41 41
    if flag {
42 -
        counter = counter + try returnsErr(2);
42 +
        counter += try returnsErr(2);
43 43
    } else {
44 44
        try returnsErr(0);
45 -
        counter = counter + 100;
45 +
        counter += 100;
46 46
    }
47 47
    return counter;
48 48
}
49 49
50 50
fn aggregateTwo() -> u32 throws (TestError) {
83 83
    let mut total: u32 = 0;
84 84
    let mut idx: u32 = 0;
85 85
    while idx < 3 {
86 86
        if failMid {
87 87
            if idx == 1 {
88 -
                total = total + try returnsErr(0);
88 +
                total += try returnsErr(0);
89 89
            } else {
90 -
                total = total + try returnsErr(2);
90 +
                total += try returnsErr(2);
91 91
            }
92 92
        } else {
93 -
            total = total + try returnsErr(2);
93 +
            total += try returnsErr(2);
94 94
        }
95 -
        idx = idx + 1;
95 +
        idx += 1;
96 96
    }
97 97
    return total;
98 98
}
99 99
100 100
fn structSuccess(state: *mut ResultSink) -> u32 throws (TestError) {
101 101
    let value: u32 = try returnsOk();
102 102
    state.last = value;
103 -
    state.count = state.count + 1;
103 +
    state.count += 1;
104 104
    return value;
105 105
}
106 106
107 107
fn structFailure(state: *mut ResultSink) -> u32 throws (TestError) {
108 108
    try returnsErr(1);
lib/std/arch/rv64/tests/loop.complex.flow.rad +2 -2
27 27
        match result {
28 28
            case Result::Ok(v) => {
29 29
                sum = v;
30 30
            },
31 31
            case Result::Err(e) => {
32 -
                errCount = errCount + 1;
32 +
                errCount += 1;
33 33
            },
34 34
        }
35 -
        i = i + 1;
35 +
        i += 1;
36 36
    }
37 37
38 38
    // val sequence: -2, -1, 0, 1, 2, 3
39 39
    // Err for val <= 0: errCount = 3 (for -2, -1, 0)
40 40
    // Ok for val > 0: sum = 0 + 1 + 2 + 3 = 6
lib/std/arch/rv64/tests/loop.sealblock.rad +4 -4
6 6
@default fn main() -> i32 {
7 7
    // Simple loop with mutable variable.
8 8
    let mut sum: i32 = 0;
9 9
    let mut i: i32 = 0;
10 10
    while i < 5 {
11 -
        sum = sum + i;
12 -
        i = i + 1;
11 +
        sum += i;
12 +
        i += 1;
13 13
    }
14 14
    // sum = 0 + 1 + 2 + 3 + 4 = 10
15 15
    if sum != 10 {
16 16
        return 1;
17 17
    }
18 18
19 19
    // For loop with mutable variable.
20 20
    let mut count: i32 = 0;
21 21
    for j in 0..4 {
22 -
        count = count + 1;
22 +
        count += 1;
23 23
    }
24 24
    if count != 4 {
25 25
        return 2;
26 26
    }
27 27
28 28
    // Nested pattern: mutable var with function call in loop.
29 29
    let mut total: i32 = 0;
30 30
    for k in 0..3 {
31 -
        total = total + addOne(k);
31 +
        total += addOne(k);
32 32
    }
33 33
    // total = 1 + 2 + 3 = 6
34 34
    if total != 6 {
35 35
        return 3;
36 36
    }
lib/std/arch/rv64/tests/match.mutref.push.rad +1 -1
10 10
    Yes,
11 11
}
12 12
13 13
fn pushItem(list: *mut U32List, value: u32) {
14 14
    list.data[list.len] = value;
15 -
    list.len = list.len + 1;
15 +
    list.len += 1;
16 16
}
17 17
18 18
fn addToUnsealedBlock(state: *mut Sealed, value: u32) -> bool {
19 19
    match state {
20 20
        case Sealed::No { items } => {
lib/std/arch/rv64/tests/mutref.loop.bug.rad +3 -3
20 20
fn testZeroIter(n: u32) -> u32 {
21 21
    let mut val: u32 = 42;
22 22
    let mut i: u32 = 0;
23 23
    while i < n {
24 24
        set(&mut val, val + 1);
25 -
        i = i + 1;
25 +
        i += 1;
26 26
    }
27 27
    return val;
28 28
}
29 29
30 30
/// Multiple iterations: accumulate via &mut pointer in a loop.
31 31
fn testMultiIter() -> u32 {
32 32
    let mut acc: u32 = 0;
33 33
    let mut i: u32 = 0;
34 34
    while i < 5 {
35 35
        set(&mut acc, acc + i);
36 -
        i = i + 1;
36 +
        i += 1;
37 37
    }
38 38
    return acc;
39 39
}
40 40
41 41
/// Multiple address-taken variables in the same loop.
44 44
    let mut b: u32 = 100;
45 45
    let mut i: u32 = 0;
46 46
    while i < 3 {
47 47
        set(&mut a, a + 1);
48 48
        set(&mut b, b - 1);
49 -
        i = i + 1;
49 +
        i += 1;
50 50
    }
51 51
    return a + b;
52 52
}
53 53
54 54
@default fn main() -> i32 {
lib/std/arch/rv64/tests/opt.record.rad +1 -1
30 30
        return 0;
31 31
    }
32 32
33 33
    let wrapper = Wrapper { opt: 7 };
34 34
    if let value = wrapper.opt {
35 -
        total = total + value;
35 +
        total += value;
36 36
    } else {
37 37
        return 0;
38 38
    }
39 39
40 40
    let call = take_optional(9);
lib/std/arch/rv64/tests/opt.while.let.complex.rad +1 -1
12 12
@default fn main() -> i32 {
13 13
    let mut cur: u32 = 7;
14 14
    let mut sum: u32 = 0;
15 15
16 16
    while let x = decr(cur); x > 1 {
17 -
        sum = sum + x;
17 +
        sum += x;
18 18
        cur = x;
19 19
    }
20 20
21 21
    // sum should be 6 + 5 + 4 + 3 + 2 = 20
22 22
    if sum != 20 {
lib/std/arch/rv64/tests/placeholder.comprehensive.rad +1 -1
19 19
20 20
    // Test 4: for loop with placeholder for value
21 21
    let arr: [i32; 3] = [1, 2, 3];
22 22
    let mut count: i32 = 0;
23 23
    for _ in &arr[..] {
24 -
        count = count + 1;
24 +
        count += 1;
25 25
    }
26 26
    if count != 3 {
27 27
        return 3;
28 28
    }
29 29
    return 0;
lib/std/arch/rv64/tests/prog.ackermann.rad +13 -13
39 39
    if m == 3 {
40 40
        // 2^(n+3) - 3
41 41
        let mut power: i32 = 1;
42 42
        let mut i: u32 = 0;
43 43
        while i < n + 3 {
44 -
            power = power * 2;
45 -
            i = i + 1;
44 +
            power *= 2;
45 +
            i += 1;
46 46
        }
47 47
        return power - 3;
48 48
    }
49 49
    // For m >= 4, fall back to recursion (only safe for very small n).
50 50
    if n == 0 {
56 56
/// Power of 2 helper.
57 57
fn pow2(exp: u32) -> i32 {
58 58
    let mut result: i32 = 1;
59 59
    let mut i: u32 = 0;
60 60
    while i < exp {
61 -
        result = result * 2;
62 -
        i = i + 1;
61 +
        result *= 2;
62 +
        i += 1;
63 63
    }
64 64
    return result;
65 65
}
66 66
67 67
/// Test known small values using the recursive implementation.
124 124
    while n < 50 {
125 125
        let expected: i32 = n as i32 + 1;
126 126
        if ackMemo(0, n) != expected {
127 127
            return 1;
128 128
        }
129 -
        n = n + 1;
129 +
        n += 1;
130 130
    }
131 131
132 132
    // Verify m=1 row.
133 133
    n = 0;
134 134
    while n < 50 {
135 135
        let expected: i32 = n as i32 + 2;
136 136
        if ackMemo(1, n) != expected {
137 137
            return 2;
138 138
        }
139 -
        n = n + 1;
139 +
        n += 1;
140 140
    }
141 141
142 142
    // Verify m=2 row.
143 143
    n = 0;
144 144
    while n < 50 {
145 145
        let expected: i32 = (2 * n + 3) as i32;
146 146
        if ackMemo(2, n) != expected {
147 147
            return 3;
148 148
        }
149 -
        n = n + 1;
149 +
        n += 1;
150 150
    }
151 151
152 152
    // Verify m=3 row for small n.
153 153
    // A(3,0)=5, A(3,1)=13, A(3,2)=29, A(3,3)=61, A(3,4)=125
154 154
    if ackMemo(3, 0) != 5 {
192 192
            let r: i32 = ack(m, n);
193 193
            let memoR: i32 = ackMemo(m, n);
194 194
            if r != memoR {
195 195
                return (m * 20 + n) as i32 + 1;
196 196
            }
197 -
            n = n + 1;
197 +
            n += 1;
198 198
        }
199 -
        m = m + 1;
199 +
        m += 1;
200 200
    }
201 201
    return 0;
202 202
}
203 203
204 204
/// Test the Ackermann inverse property: A(m, n) > n for all m, n.
214 214
            // A(m, n) < A(m, n+1) (strictly increasing in n).
215 215
            let valNext: i32 = ackMemo(m, n + 1);
216 216
            if valNext <= val {
217 217
                return 2;
218 218
            }
219 -
            n = n + 1;
219 +
            n += 1;
220 220
        }
221 -
        m = m + 1;
221 +
        m += 1;
222 222
    }
223 223
224 224
    // A(m, n) < A(m+1, n) (strictly increasing in m).
225 225
    let mut m2: u32 = 0;
226 226
    while m2 < 3 {
229 229
            let lower: i32 = ackMemo(m2, n2);
230 230
            let upper: i32 = ackMemo(m2 + 1, n2);
231 231
            if upper <= lower {
232 232
                return 3;
233 233
            }
234 -
            n2 = n2 + 1;
234 +
            n2 += 1;
235 235
        }
236 -
        m2 = m2 + 1;
236 +
        m2 += 1;
237 237
    }
238 238
239 239
    return 0;
240 240
}
241 241
lib/std/arch/rv64/tests/prog.bignum.rad +14 -14
10 10
fn bnFromU32(dst: *mut [u32], val: u32) {
11 11
    dst[0] = val;
12 12
    let mut i: u32 = 1;
13 13
    while i < LIMBS {
14 14
        dst[i] = 0;
15 -
        i = i + 1;
15 +
        i += 1;
16 16
    }
17 17
}
18 18
19 19
/// Set a big number to zero.
20 20
fn bnZero(dst: *mut [u32]) {
21 21
    let mut i: u32 = 0;
22 22
    while i < LIMBS {
23 23
        dst[i] = 0;
24 -
        i = i + 1;
24 +
        i += 1;
25 25
    }
26 26
}
27 27
28 28
/// Copy src to dst.
29 29
fn bnCopy(dst: *mut [u32], src: *[u32]) {
30 30
    let mut i: u32 = 0;
31 31
    while i < LIMBS {
32 32
        dst[i] = src[i];
33 -
        i = i + 1;
33 +
        i += 1;
34 34
    }
35 35
}
36 36
37 37
/// Compare two big numbers. Returns 0 if equal, 1 if a > b, -1 if a < b.
38 38
fn bnCmp(a: *[u32], b: *[u32]) -> i32 {
45 45
            return -1;
46 46
        }
47 47
        if i == 0 {
48 48
            break;
49 49
        }
50 -
        i = i - 1;
50 +
        i -= 1;
51 51
    }
52 52
    return 0;
53 53
}
54 54
55 55
/// Add two big numbers: dst = a + b. Returns carry (0 or 1).
67 67
        if sum < sumLo {
68 68
            carry2 = 1;
69 69
        }
70 70
        dst[i] = sum;
71 71
        carry = carry1 + carry2;
72 -
        i = i + 1;
72 +
        i += 1;
73 73
    }
74 74
    return carry;
75 75
}
76 76
77 77
/// Subtract two big numbers: dst = a - b. Returns borrow (0 or 1).
89 89
        if result > diff {
90 90
            borrow2 = 1;
91 91
        }
92 92
        dst[i] = result;
93 93
        borrow = borrow1 + borrow2;
94 -
        i = i + 1;
94 +
        i += 1;
95 95
    }
96 96
    return borrow;
97 97
}
98 98
99 99
/// Multiply two LIMBS-word numbers, producing a 2*LIMBS-word result in wide.
100 100
fn bnMul(wide: *mut [u32], a: *[u32], b: *[u32]) {
101 101
    let mut i: u32 = 0;
102 102
    while i < LIMBS * 2 {
103 103
        wide[i] = 0;
104 -
        i = i + 1;
104 +
        i += 1;
105 105
    }
106 106
107 107
    i = 0;
108 108
    while i < LIMBS {
109 109
        let mut carry: u32 = 0;
143 143
                c2 = 1;
144 144
            }
145 145
            wide[i + j] = sum2;
146 146
            carry = hi + c1 + c2;
147 147
148 -
            j = j + 1;
148 +
            j += 1;
149 149
        }
150 -
        wide[i + LIMBS] = wide[i + LIMBS] + carry;
151 -
        i = i + 1;
150 +
        wide[i + LIMBS] += carry;
151 +
        i += 1;
152 152
    }
153 153
}
154 154
155 155
/// Left shift a big number by 1 bit.
156 156
fn bnShl1(dst: *mut [u32], src: *[u32]) {
158 158
    let mut i: u32 = 0;
159 159
    while i < LIMBS {
160 160
        let newCarry: u32 = src[i] >> 31;
161 161
        dst[i] = (src[i] << 1) | carry;
162 162
        carry = newCarry;
163 -
        i = i + 1;
163 +
        i += 1;
164 164
    }
165 165
}
166 166
167 167
/// Right shift a big number by 1 bit.
168 168
fn bnShr1(dst: *mut [u32], src: *[u32]) {
169 169
    let mut carry: u32 = 0;
170 170
    let mut i: u32 = LIMBS;
171 171
    while i > 0 {
172 -
        i = i - 1;
172 +
        i -= 1;
173 173
        let newCarry: u32 = src[i] & 1;
174 174
        dst[i] = (src[i] >> 1) | (carry << 31);
175 175
        carry = newCarry;
176 176
    }
177 177
}
387 387
    let mut i: u32 = 2;
388 388
    while i <= 48 {
389 389
        bnAdd(&mut fibC[..], &fibA[..], &fibB[..]);
390 390
        bnCopy(&mut fibA[..], &fibB[..]);
391 391
        bnCopy(&mut fibB[..], &fibC[..]);
392 -
        i = i + 1;
392 +
        i += 1;
393 393
    }
394 394
395 395
    if fibB[0] != 0x1E8D0A40 {
396 396
        return 1;
397 397
    }
407 407
    i = 2;
408 408
    while i <= 47 {
409 409
        bnAdd(&mut fc[..], &fa[..], &fb[..]);
410 410
        bnCopy(&mut fa[..], &fb[..]);
411 411
        bnCopy(&mut fb[..], &fc[..]);
412 -
        i = i + 1;
412 +
        i += 1;
413 413
    }
414 414
    bnAdd(&mut fc[..], &fa[..], &fb[..]);
415 415
    if bnCmp(&fc[..], &fibB[..]) != 0 {
416 416
        return 3;
417 417
    }
lib/std/arch/rv64/tests/prog.bubblesort.rad +3 -3
12 12
                let tmp: i32 = data[i];
13 13
                data[i] = data[i + 1];
14 14
                data[i + 1] = tmp;
15 15
                swapped = true;
16 16
            }
17 -
            i = i + 1;
17 +
            i += 1;
18 18
        }
19 19
        if not swapped {
20 20
            // Already sorted, early exit.
21 21
            return;
22 22
        }
23 -
        n = n - 1;
23 +
        n -= 1;
24 24
    }
25 25
}
26 26
27 27
/// Verify the array is sorted in ascending order.
28 28
fn isSorted(data: *[i32]) -> bool {
40 40
41 41
/// Compute the sum of all elements.
42 42
fn sum(data: *[i32]) -> i32 {
43 43
    let mut total: i32 = 0;
44 44
    for val in data {
45 -
        total = total + val;
45 +
        total += val;
46 46
    }
47 47
    return total;
48 48
}
49 49
50 50
/// Verify specific positions in the sorted output.
lib/std/arch/rv64/tests/prog.cordic.rad +11 -11
37 37
    while i < ITERATIONS {
38 38
        let dx: i32 = x >> i as i32;
39 39
        let dy: i32 = y >> i as i32;
40 40
41 41
        if z >= 0 {
42 -
            x = x - dy;
43 -
            y = y + dx;
44 -
            z = z - atanTable[i];
42 +
            x -= dy;
43 +
            y += dx;
44 +
            z -= atanTable[i];
45 45
        } else {
46 -
            x = x + dy;
47 -
            y = y - dx;
48 -
            z = z + atanTable[i];
46 +
            x += dy;
47 +
            y -= dx;
48 +
            z += atanTable[i];
49 49
        }
50 -
        i = i + 1;
50 +
        i += 1;
51 51
    }
52 52
53 53
    return CosSin { cos: x, sin: y };
54 54
}
55 55
57 57
fn cosSin(angle: i32, atanTable: *[i32]) -> CosSin {
58 58
    let mut a: i32 = angle;
59 59
60 60
    // Reduce to [-pi, pi].
61 61
    while a > PI {
62 -
        a = a - 2 * PI;
62 +
        a -= 2 * PI;
63 63
    }
64 64
    while a < 0 - PI {
65 -
        a = a + 2 * PI;
65 +
        a += 2 * PI;
66 66
    }
67 67
68 68
    // If in [pi/2, pi], use cos(a) = -cos(pi-a), sin(a) = sin(pi-a).
69 69
    if a > HALF_PI {
70 70
        let r: CosSin = cordicRotate(PI - a, atanTable);
183 183
184 184
        // Allow ~2% error due to fixed-point precision.
185 185
        if err > 1311 {
186 186
            return 1;
187 187
        }
188 -
        i = i + step;
188 +
        i += step;
189 189
    }
190 190
    return 0;
191 191
}
192 192
193 193
/// Test symmetry: sin(-x) = -sin(x), cos(-x) = cos(x).
207 207
        }
208 208
        // sin(-x) should equal -sin(x).
209 209
        if abs(rPos.sin + rNeg.sin) > 655 {
210 210
            return 2;
211 211
        }
212 -
        i = i + 1;
212 +
        i += 1;
213 213
    }
214 214
    return 0;
215 215
}
216 216
217 217
/// Test specific known value: cos(pi/3) = 0.5, sin(pi/3) = 0.866.
lib/std/arch/rv64/tests/prog.crc32.rad +5 -5
10 10
        let mut j: u32 = 0;
11 11
        while j < 8 {
12 12
            if crc & 1 == 1 {
13 13
                crc = (crc >> 1) ^ 0xEDB88320;
14 14
            } else {
15 -
                crc = crc >> 1;
15 +
                crc >>= 1;
16 16
            }
17 -
            j = j + 1;
17 +
            j += 1;
18 18
        }
19 19
        table[i] = crc;
20 -
        i = i + 1;
20 +
        i += 1;
21 21
    }
22 22
}
23 23
24 24
/// Compute CRC-32 of a byte slice.
25 25
fn crc32(table: *[u32], data: *[u8]) -> u32 {
27 27
    let mut i: u32 = 0;
28 28
    while i < data.len {
29 29
        let byte: u8 = data[i];
30 30
        let index: u32 = (crc ^ byte as u32) & 0xFF;
31 31
        crc = (crc >> 8) ^ table[index];
32 -
        i = i + 1;
32 +
        i += 1;
33 33
    }
34 34
    return crc ^ 0xFFFFFFFF;
35 35
}
36 36
37 37
/// Test the lookup table has been built correctly.
77 77
    // Build a 32-byte buffer with values 0..31.
78 78
    let mut buf: [u8; 32] = [0; 32];
79 79
    let mut i: u32 = 0;
80 80
    while i < 32 {
81 81
        buf[i] = i as u8;
82 -
        i = i + 1;
82 +
        i += 1;
83 83
    }
84 84
    let crcFull = crc32(table, &buf[..]);
85 85
86 86
    // CRC should be non-zero and deterministic.
87 87
    if crcFull == 0 {
lib/std/arch/rv64/tests/prog.dijkstra.rad +12 -12
61 61
    }
62 62
}
63 63
64 64
fn heapPush(g: *mut Graph, dist: u32, node: u32) {
65 65
    g.heap[g.heapSize] = HeapEntry { dist, node };
66 -
    g.heapSize = g.heapSize + 1;
66 +
    g.heapSize += 1;
67 67
    siftUp(g, g.heapSize - 1);
68 68
}
69 69
70 70
/// Pop from the heap. Returns nil if the heap is empty.
71 71
fn heapPop(g: *mut Graph) -> ?HeapEntry {
72 72
    if g.heapSize == 0 {
73 73
        return nil;
74 74
    }
75 75
    let result: HeapEntry = g.heap[0];
76 -
    g.heapSize = g.heapSize - 1;
76 +
    g.heapSize -= 1;
77 77
    g.heap[0] = g.heap[g.heapSize];
78 78
    if g.heapSize > 0 {
79 79
        siftDown(g, 0);
80 80
    }
81 81
    return result;
95 95
    let mut i: u32 = 0;
96 96
    while i < MAX_NODES {
97 97
        let mut j: u32 = 0;
98 98
        while j < MAX_NODES {
99 99
            g.adj[i][j] = INF;
100 -
            j = j + 1;
100 +
            j += 1;
101 101
        }
102 102
        g.dist[i] = INF;
103 103
        g.prev[i] = -1;
104 104
        g.visited[i] = false;
105 -
        i = i + 1;
105 +
        i += 1;
106 106
    }
107 107
    g.heapSize = 0;
108 108
}
109 109
110 110
/// Get the predecessor as an optional; -1 means no predecessor.
136 136
                    g.dist[v] = newDist;
137 137
                    g.prev[v] = u as i32;
138 138
                    heapPush(g, newDist, v);
139 139
                }
140 140
            }
141 -
            v = v + 1;
141 +
            v += 1;
142 142
        }
143 143
    }
144 144
}
145 145
146 146
/// Reconstruct the shortest path from source to target.
147 147
fn reconstructPath(g: *Graph, target: u32, path: *mut [u32]) -> u32 {
148 148
    let mut len: u32 = 0;
149 149
150 150
    path[len] = target;
151 -
    len = len + 1;
151 +
    len += 1;
152 152
153 153
    let mut cur: ?u32 = getPrev(g, target);
154 154
    while let node = cur {
155 155
        path[len] = node;
156 -
        len = len + 1;
156 +
        len += 1;
157 157
        cur = getPrev(g, node);
158 158
    }
159 159
160 160
    // Reverse the path.
161 161
    let mut a: u32 = 0;
162 162
    let mut b: u32 = len - 1;
163 163
    while a < b {
164 164
        let tmp: u32 = path[a];
165 165
        path[a] = path[b];
166 166
        path[b] = tmp;
167 -
        a = a + 1;
168 -
        b = b - 1;
167 +
        a += 1;
168 +
        b -= 1;
169 169
    }
170 170
    return len;
171 171
}
172 172
173 173
fn testLinear(g: *mut Graph) -> i32 {
259 259
                if i > j {
260 260
                    diff = i - j;
261 261
                }
262 262
                addEdge(g, i, j, diff * 3 + 1);
263 263
            }
264 -
            j = j + 1;
264 +
            j += 1;
265 265
        }
266 -
        i = i + 1;
266 +
        i += 1;
267 267
    }
268 268
269 269
    dijkstra(g, 0);
270 270
271 271
    let mut k: u32 = 1;
272 272
    while k < 8 {
273 273
        let expected: u32 = k * 3 + 1;
274 274
        if g.dist[k] != expected {
275 275
            return k as i32;
276 276
        }
277 -
        k = k + 1;
277 +
        k += 1;
278 278
    }
279 279
280 280
    return 0;
281 281
}
282 282
lib/std/arch/rv64/tests/prog.eval.rad +1 -1
33 33
34 34
/// Allocate a new node, returning its index.
35 35
fn newNode(pool: *mut Pool, expr: Expr) -> u32 {
36 36
    let idx = pool.count;
37 37
    pool.nodes[idx] = expr;
38 -
    pool.count = pool.count + 1;
38 +
    pool.count += 1;
39 39
    return idx;
40 40
}
41 41
42 42
/// Convenience constructors.
43 43
fn num(pool: *mut Pool, n: i32) -> u32 {
lib/std/arch/rv64/tests/prog.hanoi.rad +3 -3
21 21
22 22
/// Record a move.
23 23
fn recordMove(ml: *mut MoveLog, disk: u32, from: u32, to: u32) {
24 24
    if ml.count < MAX_MOVES {
25 25
        ml.moves[ml.count] = Move { disk, from, to };
26 -
        ml.count = ml.count + 1;
26 +
        ml.count += 1;
27 27
    }
28 28
}
29 29
30 30
/// Solve Tower of Hanoi recursively.
31 31
/// Move `n` disks from peg `from` to peg `to` using `aux` as auxiliary.
131 131
            return 1;
132 132
        }
133 133
        if d == 0 {
134 134
            break;
135 135
        }
136 -
        d = d - 1;
136 +
        d -= 1;
137 137
    }
138 138
139 139
    // Replay all moves.
140 140
    let mut i: u32 = 0;
141 141
    while i < ml.count {
145 145
            return 2;
146 146
        }
147 147
        if not pegPush(&mut pegs, m.to, disk) {
148 148
            return 3;
149 149
        }
150 -
        i = i + 1;
150 +
        i += 1;
151 151
    }
152 152
153 153
    // All disks should be on peg 1.
154 154
    if pegs.top[0] != 0 {
155 155
        return 4;
lib/std/arch/rv64/tests/prog.huffman.rad +16 -16
36 36
}
37 37
38 38
fn newLeaf(s: *mut HuffState, freq: u32, symbol: u32) -> u32 {
39 39
    let idx: u32 = s.nodeCount;
40 40
    s.nodes[idx] = HNode { freq, kind: HNodeKind::Leaf(symbol), left: NIL, right: NIL };
41 -
    s.nodeCount = s.nodeCount + 1;
41 +
    s.nodeCount += 1;
42 42
    return idx;
43 43
}
44 44
45 45
fn newInterior(s: *mut HuffState, freq: u32, left: u32, right: u32) -> u32 {
46 46
    let idx: u32 = s.nodeCount;
47 47
    s.nodes[idx] = HNode { freq, kind: HNodeKind::Interior, left, right };
48 -
    s.nodeCount = s.nodeCount + 1;
48 +
    s.nodeCount += 1;
49 49
    return idx;
50 50
}
51 51
52 52
/// Get the symbol from a node, or nil if it's an interior node.
53 53
fn nodeSymbol(node: *HNode) -> ?u32 {
105 105
    }
106 106
}
107 107
108 108
fn heapPush(s: *mut HuffState, nodeIdx: u32) {
109 109
    s.heap[s.heapSize] = nodeIdx;
110 -
    s.heapSize = s.heapSize + 1;
110 +
    s.heapSize += 1;
111 111
    siftUp(s, s.heapSize - 1);
112 112
}
113 113
114 114
fn heapPop(s: *mut HuffState) -> u32 {
115 115
    let result: u32 = s.heap[0];
116 -
    s.heapSize = s.heapSize - 1;
116 +
    s.heapSize -= 1;
117 117
    s.heap[0] = s.heap[s.heapSize];
118 118
    if s.heapSize > 0 {
119 119
        siftDown(s, 0);
120 120
    }
121 121
    return result;
163 163
164 164
fn writeBit(s: *mut HuffState, bit: u32) {
165 165
    let byteIdx: u32 = s.bitCount / 8;
166 166
    let bitIdx: u32 = 7 - (s.bitCount % 8);
167 167
    if bit == 1 {
168 -
        s.bitstream[byteIdx] = s.bitstream[byteIdx] | (1 as u8 << bitIdx as u8);
168 +
        s.bitstream[byteIdx] |= (1 as u8 << bitIdx as u8);
169 169
    }
170 -
    s.bitCount = s.bitCount + 1;
170 +
    s.bitCount += 1;
171 171
}
172 172
173 173
fn readBit(s: *HuffState, pos: u32) -> u32 {
174 174
    let byteIdx: u32 = pos / 8;
175 175
    let bitIdx: u32 = 7 - (pos % 8);
179 179
fn encode(s: *mut HuffState, msg: *[u32]) {
180 180
    s.bitCount = 0;
181 181
    let mut i: u32 = 0;
182 182
    while i < MAX_BITS {
183 183
        s.bitstream[i] = 0;
184 -
        i = i + 1;
184 +
        i += 1;
185 185
    }
186 186
187 187
188 188
    for sym in msg {
189 189
        let bits: u32 = s.codeBits[sym];
190 190
        let len: u32 = s.codeLen[sym];
191 191
        let mut b: u32 = 0;
192 192
        while b < len {
193 193
            let bit: u32 = (bits >> (len - 1 - b)) & 1;
194 194
            writeBit(s, bit);
195 -
            b = b + 1;
195 +
            b += 1;
196 196
        }
197 197
    }
198 198
}
199 199
200 200
fn decode(s: *HuffState, root: u32, numSymbols: u32, out: *mut [u32]) -> u32 {
204 204
    while decoded < numSymbols {
205 205
        let mut cur: u32 = root;
206 206
        // Walk the tree until we find a leaf.
207 207
        while nodeSymbol(&s.nodes[cur]) == nil {
208 208
            let bit: u32 = readBit(s, bitPos);
209 -
            bitPos = bitPos + 1;
209 +
            bitPos += 1;
210 210
            if bit == 0 {
211 211
                cur = s.nodes[cur].left;
212 212
            } else {
213 213
                cur = s.nodes[cur].right;
214 214
            }
215 215
        }
216 216
        let sym = nodeSymbol(&s.nodes[cur]) else {
217 217
            return decoded;
218 218
        };
219 219
        out[decoded] = sym;
220 -
        decoded = decoded + 1;
220 +
        decoded += 1;
221 221
    }
222 222
    return decoded;
223 223
}
224 224
225 225
fn resetCodes(s: *mut HuffState) {
226 226
    let mut i: u32 = 0;
227 227
    while i < MAX_SYMBOLS {
228 228
        s.codeBits[i] = 0;
229 229
        s.codeLen[i] = 0;
230 -
        i = i + 1;
230 +
        i += 1;
231 231
    }
232 232
}
233 233
234 234
fn testBasic(s: *mut HuffState) -> i32 {
235 235
    let freqs: [u32; 5] = [5, 9, 12, 13, 16];
246 246
    let mut i: u32 = 0;
247 247
    while i < 5 {
248 248
        if s.codeLen[i] == 0 {
249 249
            return 2;
250 250
        }
251 -
        i = i + 1;
251 +
        i += 1;
252 252
    }
253 253
254 254
    // No two symbols at the same depth should have the same code.
255 255
    let mut a: u32 = 0;
256 256
    while a < 5 {
259 259
            if s.codeLen[a] == s.codeLen[b] {
260 260
                if s.codeBits[a] == s.codeBits[b] {
261 261
                    return 3;
262 262
                }
263 263
            }
264 -
            b = b + 1;
264 +
            b += 1;
265 265
        }
266 -
        a = a + 1;
266 +
        a += 1;
267 267
    }
268 268
269 269
    return 0;
270 270
}
271 271
310 310
    while i < 6 {
311 311
        if s.codeLen[i] > 0 and s.codeLen[i] < shortestLen {
312 312
            shortestLen = s.codeLen[i];
313 313
            shortestSym = i;
314 314
        }
315 -
        i = i + 1;
315 +
        i += 1;
316 316
    }
317 317
    if shortestSym != 0 {
318 318
        return 1;
319 319
    }
320 320
351 351
    let mut i: u32 = 0;
352 352
    while i < 8 {
353 353
        if s.codeLen[i] != 3 {
354 354
            return 2;
355 355
        }
356 -
        i = i + 1;
356 +
        i += 1;
357 357
    }
358 358
359 359
    let msg: [u32; 8] = [0, 1, 2, 3, 4, 5, 6, 7];
360 360
    encode(s, &msg[..]);
361 361
lib/std/arch/rv64/tests/prog.hybridsort.rad +5 -5
15 15
    while i < data.len {
16 16
        let key = data[i];
17 17
        let mut j: i32 = i as i32 - 1;
18 18
        while j >= 0 and data[j as u32] > key {
19 19
            data[(j + 1) as u32] = data[j as u32];
20 -
            j = j - 1;
20 +
            j -= 1;
21 21
        }
22 22
        data[(j + 1) as u32] = key;
23 -
        i = i + 1;
23 +
        i += 1;
24 24
    }
25 25
}
26 26
27 27
/// Selection sort on the given array.
28 28
fn selectionSort(data: *mut [i32]) {
32 32
        let mut j: u32 = i + 1;
33 33
        while j < data.len {
34 34
            if data[j] < data[minIdx] {
35 35
                minIdx = j;
36 36
            }
37 -
            j = j + 1;
37 +
            j += 1;
38 38
        }
39 39
        if minIdx != i {
40 40
            let tmp = data[i];
41 41
            data[i] = data[minIdx];
42 42
            data[minIdx] = tmp;
43 43
        }
44 -
        i = i + 1;
44 +
        i += 1;
45 45
    }
46 46
}
47 47
48 48
/// Check that an array is sorted in ascending order.
49 49
fn isSorted(data: *[i32]) -> bool {
61 61
62 62
/// Compute sum of all elements.
63 63
fn sum(data: *[i32]) -> i32 {
64 64
    let mut total: i32 = 0;
65 65
    for val in data {
66 -
        total = total + val;
66 +
        total += val;
67 67
    }
68 68
    return total;
69 69
}
70 70
71 71
/// Compare two arrays element by element.
lib/std/arch/rv64/tests/prog.linkedlist.rad +6 -6
17 17
}
18 18
19 19
/// Allocate a node from the pool. Returns its index.
20 20
fn alloc(list: *mut List, value: i32) -> u32 {
21 21
    let idx = list.free;
22 -
    list.free = list.free + 1;
22 +
    list.free += 1;
23 23
    list.pool[idx] = Node { value, next: nil };
24 24
    return idx;
25 25
}
26 26
27 27
/// Push a value onto the front of the list.
44 44
/// Get the length of the list.
45 45
fn length(list: *List) -> u32 {
46 46
    let mut count: u32 = 0;
47 47
    let mut cur = list.head;
48 48
    while let idx = cur {
49 -
        count = count + 1;
49 +
        count += 1;
50 50
        cur = list.pool[idx].next;
51 51
    }
52 52
    return count;
53 53
}
54 54
71 71
    while let idx = cur {
72 72
        if i == index {
73 73
            return list.pool[idx].value;
74 74
        }
75 75
        cur = list.pool[idx].next;
76 -
        i = i + 1;
76 +
        i += 1;
77 77
    }
78 78
    return nil;
79 79
}
80 80
81 81
/// Reverse the linked list in-place.
94 94
/// Compute the sum of all values in the list.
95 95
fn sum(list: *List) -> i32 {
96 96
    let mut total: i32 = 0;
97 97
    let mut cur = list.head;
98 98
    while let idx = cur {
99 -
        total = total + list.pool[idx].value;
99 +
        total += list.pool[idx].value;
100 100
        cur = list.pool[idx].next;
101 101
    }
102 102
    return total;
103 103
}
104 104
234 234
235 235
    // Push 32 elements.
236 236
    let mut i: u32 = 0;
237 237
    while i < 32 {
238 238
        push(list, i as i32 * 3);
239 -
        i = i + 1;
239 +
        i += 1;
240 240
    }
241 241
242 242
    if length(list) != 32 {
243 243
        return 1;
244 244
    }
276 276
        };
277 277
        let expected = j as i32 * 3;
278 278
        if v != expected {
279 279
            return 6;
280 280
        }
281 -
        j = j + 1;
281 +
        j += 1;
282 282
    }
283 283
284 284
    if length(list) != 0 {
285 285
        return 7;
286 286
    }
lib/std/arch/rv64/tests/prog.lzw.rad +19 -19
27 27
fn initEncDict(s: *mut LzwState) {
28 28
    s.encDictSize = INIT_DICT;
29 29
    let mut i: u32 = 0;
30 30
    while i < 256 {
31 31
        s.encDict[i] = DictEntry { prefix: 0xFFFF, suffix: i as u8 };
32 -
        i = i + 1;
32 +
        i += 1;
33 33
    }
34 34
}
35 35
36 36
fn initDecDict(s: *mut LzwState) {
37 37
    s.decDictSize = INIT_DICT;
38 38
    let mut i: u32 = 0;
39 39
    while i < 256 {
40 40
        s.decDict[i] = DictEntry { prefix: 0xFFFF, suffix: i as u8 };
41 -
        i = i + 1;
41 +
        i += 1;
42 42
    }
43 43
}
44 44
45 45
fn dictLookup(s: *LzwState, prefix: u32, suffix: u8) -> u32 {
46 46
    let mut i: u32 = 0;
47 47
    while i < s.encDictSize {
48 48
        if s.encDict[i].prefix == prefix and s.encDict[i].suffix == suffix {
49 49
            return i;
50 50
        }
51 -
        i = i + 1;
51 +
        i += 1;
52 52
    }
53 53
    return 0xFFFFFFFF;
54 54
}
55 55
56 56
fn dictAdd(s: *mut LzwState, prefix: u32, suffix: u8) {
57 57
    if s.encDictSize < MAX_DICT {
58 58
        s.encDict[s.encDictSize] = DictEntry { prefix, suffix };
59 -
        s.encDictSize = s.encDictSize + 1;
59 +
        s.encDictSize += 1;
60 60
    }
61 61
}
62 62
63 63
fn emitCode(s: *mut LzwState, code: u32) {
64 64
    s.encoded[s.encLen] = code;
65 -
    s.encLen = s.encLen + 1;
65 +
    s.encLen += 1;
66 66
}
67 67
68 68
fn encode(s: *mut LzwState, data: *[u8]) {
69 69
    initEncDict(s);
70 70
    s.encLen = 0;
85 85
        } else {
86 86
            emitCode(s, w);
87 87
            dictAdd(s, w, c);
88 88
            w = c as u32;
89 89
        }
90 -
        i = i + 1;
90 +
        i += 1;
91 91
    }
92 92
    emitCode(s, w);
93 93
    emitCode(s, EOI_CODE);
94 94
}
95 95
96 96
fn decodeString(s: *mut LzwState, code: u32) -> u32 {
97 97
    let mut len: u32 = 0;
98 98
    let mut c: u32 = code;
99 99
    while c != 0xFFFF and c < s.decDictSize {
100 100
        s.temp[len] = s.decDict[c].suffix;
101 -
        len = len + 1;
101 +
        len += 1;
102 102
        c = s.decDict[c].prefix;
103 103
    }
104 104
    let mut a: u32 = 0;
105 105
    let mut b: u32 = len - 1;
106 106
    while a < b {
107 107
        let tmp: u8 = s.temp[a];
108 108
        s.temp[a] = s.temp[b];
109 109
        s.temp[b] = tmp;
110 -
        a = a + 1;
111 -
        b = b - 1;
110 +
        a += 1;
111 +
        b -= 1;
112 112
    }
113 113
    return len;
114 114
}
115 115
116 116
fn firstByte(s: *LzwState, code: u32) -> u8 {
122 122
}
123 123
124 124
fn decDictAdd(s: *mut LzwState, prefix: u32, suffix: u8) {
125 125
    if s.decDictSize < MAX_DICT {
126 126
        s.decDict[s.decDictSize] = DictEntry { prefix, suffix };
127 -
        s.decDictSize = s.decDictSize + 1;
127 +
        s.decDictSize += 1;
128 128
    }
129 129
}
130 130
131 131
fn outputByte(s: *mut LzwState, b: u8) {
132 132
    s.decoded[s.decLen] = b;
133 -
    s.decLen = s.decLen + 1;
133 +
    s.decLen += 1;
134 134
}
135 135
136 136
fn decode(s: *mut LzwState) {
137 137
    initDecDict(s);
138 138
    s.decLen = 0;
141 141
        return;
142 142
    }
143 143
144 144
    let mut pos: u32 = 0;
145 145
    let mut code: u32 = s.encoded[pos];
146 -
    pos = pos + 1;
146 +
    pos += 1;
147 147
148 148
    if code == EOI_CODE {
149 149
        return;
150 150
    }
151 151
152 152
    outputByte(s, code as u8);
153 153
    let mut prevCode: u32 = code;
154 154
155 155
    while pos < s.encLen {
156 156
        code = s.encoded[pos];
157 -
        pos = pos + 1;
157 +
        pos += 1;
158 158
159 159
        if code == EOI_CODE {
160 160
            return;
161 161
        }
162 162
163 163
        if code < s.decDictSize {
164 164
            let len: u32 = decodeString(s, code);
165 165
            let mut i: u32 = 0;
166 166
            while i < len {
167 167
                outputByte(s, s.temp[i]);
168 -
                i = i + 1;
168 +
                i += 1;
169 169
            }
170 170
            decDictAdd(s, prevCode, s.temp[0]);
171 171
        } else {
172 172
            let fb: u8 = firstByte(s, prevCode);
173 173
            let len: u32 = decodeString(s, prevCode);
174 174
            let mut i: u32 = 0;
175 175
            while i < len {
176 176
                outputByte(s, s.temp[i]);
177 -
                i = i + 1;
177 +
                i += 1;
178 178
            }
179 179
            outputByte(s, fb);
180 180
            decDictAdd(s, prevCode, fb);
181 181
        }
182 182
        prevCode = code;
192 192
    decode(s);
193 193
    if s.decLen != 10 { return 2; }
194 194
    let mut i: u32 = 0;
195 195
    while i < 10 {
196 196
        if s.decoded[i] != data[i] { return 3; }
197 -
        i = i + 1;
197 +
        i += 1;
198 198
    }
199 199
    return 0;
200 200
}
201 201
202 202
fn testDistinct(s: *mut LzwState) -> i32 {
206 206
    decode(s);
207 207
    if s.decLen != 16 { return 1; }
208 208
    let mut i: u32 = 0;
209 209
    while i < 16 {
210 210
        if s.decoded[i] != data[i] { return 2; }
211 -
        i = i + 1;
211 +
        i += 1;
212 212
    }
213 213
    return 0;
214 214
}
215 215
216 216
fn testRepetitive(s: *mut LzwState) -> i32 {
222 222
    decode(s);
223 223
    if s.decLen != 64 { return 2; }
224 224
    let mut i: u32 = 0;
225 225
    while i < 64 {
226 226
        if s.decoded[i] != 65 { return 3; }
227 -
        i = i + 1;
227 +
        i += 1;
228 228
    }
229 229
    return 0;
230 230
}
231 231
232 232
fn testMixed(s: *mut LzwState) -> i32 {
236 236
    decode(s);
237 237
    if s.decLen != 24 { return 1; }
238 238
    let mut i: u32 = 0;
239 239
    while i < 24 {
240 240
        if s.decoded[i] != data[i] { return 2; }
241 -
        i = i + 1;
241 +
        i += 1;
242 242
    }
243 243
244 244
    if s.encLen - 1 >= 24 { return 3; }
245 245
246 246
    return 0;
lib/std/arch/rv64/tests/prog.matmul.rad +10 -10
16 16
        let mut j: u32 = 0;
17 17
        while j < N {
18 18
            let mut sum: i32 = 0;
19 19
            let mut k: u32 = 0;
20 20
            while k < N {
21 -
                sum = sum + a.rows[i][k] * b.rows[k][j];
22 -
                k = k + 1;
21 +
                sum += a.rows[i][k] * b.rows[k][j];
22 +
                k += 1;
23 23
            }
24 24
            c.rows[i][j] = sum;
25 -
            j = j + 1;
25 +
            j += 1;
26 26
        }
27 -
        i = i + 1;
27 +
        i += 1;
28 28
    }
29 29
}
30 30
31 31
/// Verify c matches expected.
32 32
fn verifyResult(c: *Mat4, expected: *Mat4) -> i32 {
35 35
        let mut j: u32 = 0;
36 36
        while j < N {
37 37
            if c.rows[i][j] != expected.rows[i][j] {
38 38
                return (i * N + j) as i32 + 1;
39 39
            }
40 -
            j = j + 1;
40 +
            j += 1;
41 41
        }
42 -
        i = i + 1;
42 +
        i += 1;
43 43
    }
44 44
    return 0;
45 45
}
46 46
47 47
/// Compute the trace (sum of diagonal) of a matrix.
48 48
fn trace(m: *Mat4) -> i32 {
49 49
    let mut sum: i32 = 0;
50 50
    let mut i: u32 = 0;
51 51
    while i < N {
52 -
        sum = sum + m.rows[i][i];
53 -
        i = i + 1;
52 +
        sum += m.rows[i][i];
53 +
        i += 1;
54 54
    }
55 55
    return sum;
56 56
}
57 57
58 58
/// Zero out a matrix.
60 60
    let mut i: u32 = 0;
61 61
    while i < N {
62 62
        let mut j: u32 = 0;
63 63
        while j < N {
64 64
            m.rows[i][j] = 0;
65 -
            j = j + 1;
65 +
            j += 1;
66 66
        }
67 -
        i = i + 1;
67 +
        i += 1;
68 68
    }
69 69
}
70 70
71 71
/// Multiply matrices multiple times to test repeated computation.
72 72
fn testRepeatedMultiply(c: *mut Mat4, a: *Mat4, b: *Mat4) -> i32 {
lib/std/arch/rv64/tests/prog.mersenne.rad +22 -22
28 28
        let lh: u32 = clo * hi;
29 29
        let hl: u32 = chi * lo;
30 30
31 31
        let result: u32 = ll + ((lh + hl) << 16) + i;
32 32
        s.mt[i] = result;
33 -
        i = i + 1;
33 +
        i += 1;
34 34
    }
35 35
    s.mti = N;
36 36
}
37 37
38 38
fn generateNumbers(s: *mut MtState) {
43 43
        let mut mag: u32 = 0;
44 44
        if y & 1 == 1 {
45 45
            mag = MATRIX_A;
46 46
        }
47 47
        s.mt[i] = s.mt[i + M] ^ (y >> 1) ^ mag;
48 -
        i = i + 1;
48 +
        i += 1;
49 49
    }
50 50
51 51
    while i < N - 1 {
52 52
        let y: u32 = (s.mt[i] & UPPER_MASK) | (s.mt[i + 1] & LOWER_MASK);
53 53
        let mut mag: u32 = 0;
54 54
        if y & 1 == 1 {
55 55
            mag = MATRIX_A;
56 56
        }
57 57
        s.mt[i] = s.mt[i + M - N] ^ (y >> 1) ^ mag;
58 -
        i = i + 1;
58 +
        i += 1;
59 59
    }
60 60
61 61
    let y: u32 = (s.mt[N - 1] & UPPER_MASK) | (s.mt[0] & LOWER_MASK);
62 62
    let mut mag: u32 = 0;
63 63
    if y & 1 == 1 {
72 72
    if s.mti >= N {
73 73
        generateNumbers(s);
74 74
    }
75 75
76 76
    let mut y: u32 = s.mt[s.mti];
77 -
    s.mti = s.mti + 1;
77 +
    s.mti += 1;
78 78
79 -
    y = y ^ (y >> 11);
80 -
    y = y ^ ((y << 7) & 0x9D2C5680);
81 -
    y = y ^ ((y << 15) & 0xEFC60000);
82 -
    y = y ^ (y >> 18);
79 +
    y ^= (y >> 11);
80 +
    y ^= ((y << 7) & 0x9D2C5680);
81 +
    y ^= ((y << 15) & 0xEFC60000);
82 +
    y ^= (y >> 18);
83 83
84 84
    return y;
85 85
}
86 86
87 87
fn testKnownSequence(s: *mut MtState) -> i32 {
110 110
111 111
    let mut first: [u32; 10] = [0; 10];
112 112
    let mut i: u32 = 0;
113 113
    while i < 10 {
114 114
        first[i] = mtNext(s);
115 -
        i = i + 1;
115 +
        i += 1;
116 116
    }
117 117
118 118
    mtInit(s, 42);
119 119
120 120
    i = 0;
121 121
    while i < 10 {
122 122
        let v: u32 = mtNext(s);
123 123
        if v != first[i] { return i as i32 + 1; }
124 -
        i = i + 1;
124 +
        i += 1;
125 125
    }
126 126
127 127
    return 0;
128 128
}
129 129
155 155
156 156
    let mut i: u32 = 0;
157 157
    while i < NUM_SAMPLES {
158 158
        let val: u32 = mtNext(s);
159 159
        let bin: u32 = val >> 28;
160 -
        bins[bin] = bins[bin] + 1;
161 -
        i = i + 1;
160 +
        bins[bin] += 1;
161 +
        i += 1;
162 162
    }
163 163
164 164
    let mut chi2Scaled: u32 = 0;
165 165
    let mut b: u32 = 0;
166 166
    while b < NUM_BINS {
167 167
        let obs: i32 = bins[b] as i32;
168 168
        let exp: i32 = EXPECTED as i32;
169 169
        let diff: i32 = obs - exp;
170 -
        chi2Scaled = chi2Scaled + (diff * diff) as u32;
171 -
        b = b + 1;
170 +
        chi2Scaled += (diff * diff) as u32;
171 +
        b += 1;
172 172
    }
173 173
174 174
    if chi2Scaled > 5000 { return 1; }
175 175
176 176
    b = 0;
177 177
    while b < NUM_BINS {
178 178
        if bins[b] == 0 { return 2; }
179 -
        b = b + 1;
179 +
        b += 1;
180 180
    }
181 181
182 182
    b = 0;
183 183
    while b < NUM_BINS {
184 184
        if bins[b] > NUM_SAMPLES / 2 { return 3; }
185 -
        b = b + 1;
185 +
        b += 1;
186 186
    }
187 187
188 188
    return 0;
189 189
}
190 190
193 193
194 194
    let mut last: u32 = 0;
195 195
    let mut i: u32 = 0;
196 196
    while i < 700 {
197 197
        last = mtNext(s);
198 -
        i = i + 1;
198 +
        i += 1;
199 199
    }
200 200
201 201
    mtInit(s, 7);
202 202
    let mut last2: u32 = 0;
203 203
    i = 0;
204 204
    while i < 700 {
205 205
        last2 = mtNext(s);
206 -
        i = i + 1;
206 +
        i += 1;
207 207
    }
208 208
209 209
    if last != last2 { return 1; }
210 210
211 211
    let mut more: u32 = 0;
212 212
    i = 0;
213 213
    while i < 700 {
214 214
        more = mtNext(s);
215 -
        i = i + 1;
215 +
        i += 1;
216 216
    }
217 217
    if more == 0 { return 2; }
218 218
219 219
    return 0;
220 220
}
226 226
    let mut andAll: u32 = 0xFFFFFFFF;
227 227
228 228
    let mut i: u32 = 0;
229 229
    while i < 200 {
230 230
        let v: u32 = mtNext(s);
231 -
        orAll = orAll | v;
232 -
        andAll = andAll & v;
233 -
        i = i + 1;
231 +
        orAll |= v;
232 +
        andAll &= v;
233 +
        i += 1;
234 234
    }
235 235
236 236
    if orAll != 0xFFFFFFFF { return 1; }
237 237
    if andAll == 0xFFFFFFFF { return 2; }
238 238
    if andAll != 0 { return 3; }
lib/std/arch/rv64/tests/prog.nqueens.rad +9 -9
20 20
        let rowDiff: i32 = row as i32 - i as i32;
21 21
        let colDiff: i32 = col as i32 - qcol;
22 22
        if colDiff == rowDiff or colDiff == 0 - rowDiff {
23 23
            return false;
24 24
        }
25 -
        i = i + 1;
25 +
        i += 1;
26 26
    }
27 27
    return true;
28 28
}
29 29
30 30
fn solve(b: *mut Board, row: u32) {
31 31
    if row == b.boardSize {
32 -
        b.solutionCount = b.solutionCount + 1;
32 +
        b.solutionCount += 1;
33 33
        return;
34 34
    }
35 35
    let mut col: u32 = 0;
36 36
    while col < b.boardSize {
37 37
        if isSafe(b, row, col) {
38 38
            b.queens[row] = col as i32;
39 39
            solve(b, row + 1);
40 40
            b.queens[row] = -1;
41 41
        }
42 -
        col = col + 1;
42 +
        col += 1;
43 43
    }
44 44
}
45 45
46 46
fn resetBoard(b: *mut Board) {
47 47
    let mut i: u32 = 0;
48 48
    while i < MAX_N {
49 49
        b.queens[i] = -1;
50 -
        i = i + 1;
50 +
        i += 1;
51 51
    }
52 52
    b.solutionCount = 0;
53 53
}
54 54
55 55
fn solveNQueens(b: *mut Board, n: u32) -> u32 {
65 65
    while n <= 8 {
66 66
        let count: u32 = solveNQueens(b, n);
67 67
        if count != expected[n] {
68 68
            return n as i32;
69 69
        }
70 -
        n = n + 1;
70 +
        n += 1;
71 71
    }
72 72
    return 0;
73 73
}
74 74
75 75
fn testKnownSolution() -> i32 {
85 85
            let rowDiff: i32 = j as i32 - i as i32;
86 86
            let colDiff: i32 = solution[j] - solution[i];
87 87
            if colDiff == rowDiff or colDiff == 0 - rowDiff {
88 88
                return 2;
89 89
            }
90 -
            j = j + 1;
90 +
            j += 1;
91 91
        }
92 -
        i = i + 1;
92 +
        i += 1;
93 93
    }
94 94
95 95
    let mut used: [bool; 8] = [false; 8];
96 96
    let mut k: u32 = 0;
97 97
    while k < 8 {
98 98
        let col: u32 = solution[k] as u32;
99 99
        if used[col] {
100 100
            return 3;
101 101
        }
102 102
        used[col] = true;
103 -
        k = k + 1;
103 +
        k += 1;
104 104
    }
105 105
106 106
    return 0;
107 107
}
108 108
121 121
    let expected: [u32; 9] = [0, 1, 0, 0, 2, 10, 4, 40, 92];
122 122
123 123
    let mut n: u32 = 4;
124 124
    while n <= 8 {
125 125
        if expected[n] == 0 { return 1; }
126 -
        n = n + 1;
126 +
        n += 1;
127 127
    }
128 128
129 129
    if expected[2] != 0 { return 2; }
130 130
    if expected[3] != 0 { return 3; }
131 131
    if expected[7] <= expected[6] { return 4; }
lib/std/arch/rv64/tests/prog.rbtree.rad +11 -11
23 23
    inorderCount: u32,
24 24
}
25 25
26 26
fn allocNode(t: *mut RBTree, key: i32) -> u32 {
27 27
    let idx: u32 = t.poolNext;
28 -
    t.poolNext = t.poolNext + 1;
28 +
    t.poolNext += 1;
29 29
    t.pool[idx] = RBNode { key, color: RED, left: NIL, right: NIL, parent: NIL };
30 30
    return idx;
31 31
}
32 32
33 33
fn rotateLeft(t: *mut RBTree, x: u32) {
150 150
    if x == NIL {
151 151
        return;
152 152
    }
153 153
    inorderWalk(t, t.pool[x].left);
154 154
    t.inorder[t.inorderCount] = t.pool[x].key;
155 -
    t.inorderCount = t.inorderCount + 1;
155 +
    t.inorderCount += 1;
156 156
    inorderWalk(t, t.pool[x].right);
157 157
}
158 158
159 159
fn countNodes(t: *RBTree, x: u32) -> u32 {
160 160
    if x == NIL {
203 203
204 204
fn resetTree(t: *mut RBTree) {
205 205
    let mut i: u32 = 0;
206 206
    while i < POOL_SIZE {
207 207
        t.pool[i] = RBNode { key: 0, color: BLACK, left: NIL, right: NIL, parent: NIL };
208 -
        i = i + 1;
208 +
        i += 1;
209 209
    }
210 210
    t.poolNext = 1;
211 211
    t.root = NIL;
212 212
    t.inorderCount = 0;
213 213
}
216 216
    resetTree(t);
217 217
218 218
    let mut i: i32 = 0;
219 219
    while i < 32 {
220 220
        insert(t, i);
221 -
        i = i + 1;
221 +
        i += 1;
222 222
    }
223 223
224 224
    if countNodes(t, t.root) != 32 { return 1; }
225 225
    if t.pool[t.root].color != BLACK { return 2; }
226 226
233 233
    inorderWalk(t, t.root);
234 234
    if t.inorderCount != 32 { return 5; }
235 235
    let mut j: u32 = 0;
236 236
    while j < 32 {
237 237
        if t.inorder[j] != j as i32 { return 6; }
238 -
        j = j + 1;
238 +
        j += 1;
239 239
    }
240 240
241 241
    return 0;
242 242
}
243 243
248 248
    while i >= 0 {
249 249
        insert(t, i);
250 250
        if i == 0 {
251 251
            break;
252 252
        }
253 -
        i = i - 1;
253 +
        i -= 1;
254 254
    }
255 255
256 256
    if countNodes(t, t.root) != 32 { return 1; }
257 257
    if blackHeight(t, t.root) == -1 { return 2; }
258 258
    if not noRedRed(t, t.root) { return 3; }
260 260
    t.inorderCount = 0;
261 261
    inorderWalk(t, t.root);
262 262
    let mut j: u32 = 0;
263 263
    while j < 32 {
264 264
        if t.inorder[j] != j as i32 { return 4; }
265 -
        j = j + 1;
265 +
        j += 1;
266 266
    }
267 267
268 268
    return 0;
269 269
}
270 270
279 279
        seed = (seed * 1103515245 + 12345) & 0x7FFFFFFF;
280 280
        let val: u32 = seed % 48;
281 281
        if not inserted[val] {
282 282
            insert(t, val as i32);
283 283
            inserted[val] = true;
284 -
            count = count + 1;
284 +
            count += 1;
285 285
        }
286 286
    }
287 287
288 288
    if countNodes(t, t.root) != 48 { return 1; }
289 289
    if blackHeight(t, t.root) == -1 { return 2; }
290 290
    if not noRedRed(t, t.root) { return 3; }
291 291
292 292
    let mut i: i32 = 0;
293 293
    while i < 48 {
294 294
        if not search(t, i) { return 4; }
295 -
        i = i + 1;
295 +
        i += 1;
296 296
    }
297 297
298 298
    if search(t, -1) { return 5; }
299 299
    if search(t, 48) { return 6; }
300 300
    if search(t, 100) { return 7; }
303 303
    inorderWalk(t, t.root);
304 304
    if t.inorderCount != 48 { return 8; }
305 305
    let mut j: u32 = 0;
306 306
    while j < 48 {
307 307
        if t.inorder[j] != j as i32 { return 9; }
308 -
        j = j + 1;
308 +
        j += 1;
309 309
    }
310 310
311 311
    return 0;
312 312
}
313 313
315 315
    resetTree(t);
316 316
317 317
    let mut i: i32 = 0;
318 318
    while i < 63 {
319 319
        insert(t, i);
320 -
        i = i + 1;
320 +
        i += 1;
321 321
    }
322 322
323 323
    let bh: i32 = blackHeight(t, t.root);
324 324
    if bh < 3 { return 1; }
325 325
    if bh > 7 { return 2; }
lib/std/arch/rv64/tests/prog.regex.rad +16 -16
37 37
}
38 38
39 39
fn newState(nfa: *mut NfaState) -> u32 {
40 40
    let s: u32 = nfa.stateCount;
41 41
    nfa.stateFirst[s] = NIL;
42 -
    nfa.stateCount = nfa.stateCount + 1;
42 +
    nfa.stateCount += 1;
43 43
    return s;
44 44
}
45 45
46 46
fn addTrans(nfa: *mut NfaState, from: u32, kind: u32, ch: u8, to: u32) {
47 47
    let idx: u32 = nfa.transCount;
48 48
    nfa.trans[idx] = Trans { kind, ch, to };
49 49
    nfa.transNext[idx] = nfa.stateFirst[from];
50 50
    nfa.stateFirst[from] = idx;
51 -
    nfa.transCount = nfa.transCount + 1;
51 +
    nfa.transCount += 1;
52 52
}
53 53
54 54
fn pushFrag(nfa: *mut NfaState, f: Frag) {
55 55
    nfa.fragStack[nfa.fragTop] = f;
56 -
    nfa.fragTop = nfa.fragTop + 1;
56 +
    nfa.fragTop += 1;
57 57
}
58 58
59 59
fn popFrag(nfa: *mut NfaState) -> Frag {
60 -
    nfa.fragTop = nfa.fragTop - 1;
60 +
    nfa.fragTop -= 1;
61 61
    return nfa.fragStack[nfa.fragTop];
62 62
}
63 63
64 64
fn setEmpty(s: *mut [u32]) {
65 65
    s[0] = 0;
69 69
}
70 70
71 71
fn setAdd(s: *mut [u32], bit: u32) {
72 72
    let word: u32 = bit / 32;
73 73
    let pos: u32 = bit % 32;
74 -
    s[word] = s[word] | (1 << pos);
74 +
    s[word] |= (1 << pos);
75 75
}
76 76
77 77
fn setHas(s: *[u32], bit: u32) -> bool {
78 78
    let word: u32 = bit / 32;
79 79
    let pos: u32 = bit % 32;
109 109
                        }
110 110
                    }
111 111
                    t = nfa.transNext[t];
112 112
                }
113 113
            }
114 -
            s = s + 1;
114 +
            s += 1;
115 115
        }
116 116
    }
117 117
118 118
    setCopy(states, nfa.closure);
119 119
}
123 123
    nfa.transCount = 0;
124 124
    nfa.fragTop = 0;
125 125
    let mut i: u32 = 0;
126 126
    while i < MAX_STATES {
127 127
        nfa.stateFirst[i] = NIL;
128 -
        i = i + 1;
128 +
        i += 1;
129 129
    }
130 130
    i = 0;
131 131
    while i < MAX_TRANSITIONS {
132 132
        nfa.transNext[i] = NIL;
133 -
        i = i + 1;
133 +
        i += 1;
134 134
    }
135 135
}
136 136
137 137
fn compile(nfa: *mut NfaState, pattern: *[u8]) -> u32 {
138 138
    resetNFA(nfa);
157 157
                addTrans(nfa, s, TRANS_EPSILON, 0, body);
158 158
                addTrans(nfa, s, TRANS_EPSILON, 0, e);
159 159
                addTrans(nfa, body, TRANS_EPSILON, 0, e);
160 160
161 161
                pushFrag(nfa, Frag { start: s, endState: e });
162 -
                i = i + 2;
162 +
                i += 2;
163 163
                continue;
164 164
            }
165 165
            if nextCh == 43 {
166 166
                let s: u32 = newState(nfa);
167 167
                let m: u32 = newState(nfa);
175 175
                    addTrans(nfa, m, TRANS_CHAR, ch, m);
176 176
                }
177 177
                addTrans(nfa, m, TRANS_EPSILON, 0, e);
178 178
179 179
                pushFrag(nfa, Frag { start: s, endState: e });
180 -
                i = i + 2;
180 +
                i += 2;
181 181
                continue;
182 182
            }
183 183
            if nextCh == 63 {
184 184
                let s: u32 = newState(nfa);
185 185
                let m: u32 = newState(nfa);
192 192
                }
193 193
                addTrans(nfa, s, TRANS_EPSILON, 0, e);
194 194
                addTrans(nfa, m, TRANS_EPSILON, 0, e);
195 195
196 196
                pushFrag(nfa, Frag { start: s, endState: e });
197 -
                i = i + 2;
197 +
                i += 2;
198 198
                continue;
199 199
            }
200 200
        }
201 201
202 202
        let s: u32 = newState(nfa);
205 205
            addTrans(nfa, s, TRANS_DOT, 0, e);
206 206
        } else {
207 207
            addTrans(nfa, s, TRANS_CHAR, ch, e);
208 208
        }
209 209
        pushFrag(nfa, Frag { start: s, endState: e });
210 -
        i = i + 1;
210 +
        i += 1;
211 211
    }
212 212
213 213
    if nfa.fragTop == 0 {
214 214
        let s: u32 = newState(nfa);
215 215
        nfa.acceptState = s;
219 219
    let numFrags: u32 = nfa.fragTop;
220 220
    let mut frags: [Frag; 64] = [Frag { start: 0, endState: 0 }; 64];
221 221
    let mut k: u32 = 0;
222 222
    while k < numFrags {
223 223
        frags[numFrags - 1 - k] = popFrag(nfa);
224 -
        k = k + 1;
224 +
        k += 1;
225 225
    }
226 226
227 227
    let mut j: u32 = 0;
228 228
    while j < numFrags - 1 {
229 229
        addTrans(nfa, frags[j].endState, TRANS_EPSILON, 0, frags[j + 1].start);
230 -
        j = j + 1;
230 +
        j += 1;
231 231
    }
232 232
233 233
    nfa.acceptState = frags[numFrags - 1].endState;
234 234
    return frags[0].start;
235 235
}
255 255
                        setAdd(nfa.nextSet, nfa.trans[t].to);
256 256
                    }
257 257
                    t = nfa.transNext[t];
258 258
                }
259 259
            }
260 -
            s = s + 1;
260 +
            s += 1;
261 261
        }
262 262
263 263
        epsilonClosure(nfa, nfa.nextSet);
264 264
        setCopy(nfa.current, nfa.nextSet);
265 265
266 266
        if setIsEmpty(nfa.current) {
267 267
            return false;
268 268
        }
269 -
        i = i + 1;
269 +
        i += 1;
270 270
    }
271 271
272 272
    return setHas(nfa.current, nfa.acceptState);
273 273
}
274 274
lib/std/arch/rv64/tests/prog.sha256.rad +14 -14
54 54
fn prepareSchedule(s: *mut Sha256, block: *[u32]) {
55 55
    // Copy the first 16 words directly.
56 56
    let mut i: u32 = 0;
57 57
    while i < 16 {
58 58
        s.w[i] = block[i];
59 -
        i = i + 1;
59 +
        i += 1;
60 60
    }
61 61
    // Extend to 64 words.
62 62
    while i < 64 {
63 63
        s.w[i] = ssig1(s.w[i - 2]) + s.w[i - 7] + ssig0(s.w[i - 15]) + s.w[i - 16];
64 -
        i = i + 1;
64 +
        i += 1;
65 65
    }
66 66
}
67 67
68 68
/// Run the 64-round compression function.
69 69
fn compress(s: *mut Sha256, k: *[u32]) {
86 86
        e = d + t1;
87 87
        d = c;
88 88
        c = b;
89 89
        b = a;
90 90
        a = t1 + t2;
91 -
        i = i + 1;
91 +
        i += 1;
92 92
    }
93 93
94 -
    s.h[0] = s.h[0] + a;
95 -
    s.h[1] = s.h[1] + b;
96 -
    s.h[2] = s.h[2] + c;
97 -
    s.h[3] = s.h[3] + d;
98 -
    s.h[4] = s.h[4] + e;
99 -
    s.h[5] = s.h[5] + f;
100 -
    s.h[6] = s.h[6] + g;
101 -
    s.h[7] = s.h[7] + hh;
94 +
    s.h[0] += a;
95 +
    s.h[1] += b;
96 +
    s.h[2] += c;
97 +
    s.h[3] += d;
98 +
    s.h[4] += e;
99 +
    s.h[5] += f;
100 +
    s.h[6] += g;
101 +
    s.h[7] += hh;
102 102
}
103 103
104 104
/// Reset hash state to initial values.
105 105
fn resetHash(s: *mut Sha256) {
106 106
    let mut i: u32 = 0;
107 107
    while i < 8 {
108 108
        s.h[i] = INIT_H[i];
109 -
        i = i + 1;
109 +
        i += 1;
110 110
    }
111 111
}
112 112
113 113
/// Pad and hash a short message (up to 55 bytes, fits in one 512-bit block).
114 114
fn hashMessage(s: *mut Sha256, k: *[u32], msg: *[u8]) -> i32 {
122 122
123 123
    // Copy message.
124 124
    let mut i: u32 = 0;
125 125
    while i < msg.len {
126 126
        blockBytes[i] = msg[i];
127 -
        i = i + 1;
127 +
        i += 1;
128 128
    }
129 129
130 130
    // Append the 1-bit (0x80).
131 131
    blockBytes[msg.len] = 0x80;
132 132
144 144
        let base = w * 4;
145 145
        block[w] = (blockBytes[base] as u32 << 24)
146 146
                  | (blockBytes[base + 1] as u32 << 16)
147 147
                  | (blockBytes[base + 2] as u32 << 8)
148 148
                  | (blockBytes[base + 3] as u32);
149 -
        w = w + 1;
149 +
        w += 1;
150 150
    }
151 151
152 152
    resetHash(s);
153 153
    prepareSchedule(s, &block[..]);
154 154
    compress(s, k);
lib/std/arch/rv64/tests/prog.sieve.rad +4 -4
5 5
/// Mark all multiples of p as composite.
6 6
fn markMultiples(sieve: *mut [bool], p: u32) {
7 7
    let mut i: u32 = p * p;
8 8
    while i < sieve.len {
9 9
        sieve[i] = true;
10 -
        i = i + p;
10 +
        i += p;
11 11
    }
12 12
}
13 13
14 14
/// Run the sieve algorithm.
15 15
fn runSieve(sieve: *mut [bool]) {
20 20
    let mut p: u32 = 2;
21 21
    while p * p < sieve.len {
22 22
        if not sieve[p] {
23 23
            markMultiples(sieve, p);
24 24
        }
25 -
        p = p + 1;
25 +
        p += 1;
26 26
    }
27 27
}
28 28
29 29
/// Count the number of primes found.
30 30
fn countPrimes(sieve: *[bool]) -> u32 {
31 31
    let mut count: u32 = 0;
32 32
    for composite in sieve {
33 33
        if not composite {
34 -
            count = count + 1;
34 +
            count += 1;
35 35
        }
36 36
    }
37 37
    return count;
38 38
}
39 39
42 42
    let mut count: u32 = 0;
43 43
    for composite, idx in sieve {
44 44
        if not composite {
45 45
            if count < primes.len {
46 46
                primes[count] = idx;
47 -
                count = count + 1;
47 +
                count += 1;
48 48
            }
49 49
        }
50 50
    }
51 51
    return count;
52 52
}
lib/std/arch/rv64/tests/prog.symtab.rad +11 -11
58 58
}
59 59
60 60
/// Push a new scope.
61 61
fn pushScope(tab: *mut SymTab) {
62 62
    tab.scopes[tab.scopeDepth] = ScopeMarker { symbolCount: tab.symbolCount };
63 -
    tab.scopeDepth = tab.scopeDepth + 1;
63 +
    tab.scopeDepth += 1;
64 64
}
65 65
66 66
/// Pop the current scope, removing all symbols defined in it.
67 67
fn popScope(tab: *mut SymTab) {
68 68
    if tab.scopeDepth == 0 {
69 69
        return;
70 70
    }
71 -
    tab.scopeDepth = tab.scopeDepth - 1;
71 +
    tab.scopeDepth -= 1;
72 72
    let marker = tab.scopes[tab.scopeDepth];
73 73
74 74
    // Remove symbols added in this scope (in reverse order).
75 75
    while tab.symbolCount > marker.symbolCount {
76 -
        tab.symbolCount = tab.symbolCount - 1;
76 +
        tab.symbolCount -= 1;
77 77
        let sym = tab.symbols[tab.symbolCount];
78 78
        let bucket = sym.nameHash % HASH_SIZE;
79 79
80 80
        // Remove from hash chain.
81 81
        tab.buckets[bucket] = sym.next;
120 120
        depth: tab.scopeDepth,
121 121
        next: tab.buckets[bucket],
122 122
        shadow: shadowIdx,
123 123
    };
124 124
    tab.buckets[bucket] = idx;
125 -
    tab.symbolCount = tab.symbolCount + 1;
125 +
    tab.symbolCount += 1;
126 126
    return idx;
127 127
}
128 128
129 129
/// Look up a symbol by name. Returns the value if found.
130 130
fn lookup(tab: *SymTab, name: *[u8]) -> ?i32 {
242 242
    // Define x at each of 8 scope levels.
243 243
    let mut i: u32 = 0;
244 244
    while i < 8 {
245 245
        pushScope(tab);
246 246
        define(tab, "x", i as i32 * 10);
247 -
        i = i + 1;
247 +
        i += 1;
248 248
    }
249 249
250 250
    // x should be the innermost value.
251 251
    let x = lookup(tab, "x") else {
252 252
        return 1;
264 264
        };
265 265
        let expected = (i - 1) as i32 * 10;
266 266
        if val != expected {
267 267
            return 4;
268 268
        }
269 -
        i = i - 1;
269 +
        i -= 1;
270 270
    }
271 271
272 272
    popScope(tab);
273 273
    return 0;
274 274
}
288 288
289 289
    // Verify all of them.
290 290
    let mut sum: i32 = 0;
291 291
    for name, i in names {
292 292
        if let val = lookup(tab, name) {
293 -
            sum = sum + val;
293 +
            sum += val;
294 294
        } else {
295 295
            return 1;
296 296
        }
297 297
    }
298 298
319 319
            return 1;
320 320
        };
321 321
        if not update(tab, "counter", cur + 1) {
322 322
            return 2;
323 323
        }
324 -
        i = i + 1;
324 +
        i += 1;
325 325
    }
326 326
327 327
    let final_val = lookup(tab, "counter") else {
328 328
        return 3;
329 329
    };
405 405
        let result = lookup(tab, name);
406 406
        if let exp = expected[i] {
407 407
            // We expect a value.
408 408
            if let r = result {
409 409
                if r != exp {
410 -
                    failures = failures + 1;
410 +
                    failures += 1;
411 411
                }
412 412
            } else {
413 -
                failures = failures + 1;
413 +
                failures += 1;
414 414
            }
415 415
        } else {
416 416
            // We expect nil.
417 417
            if let _ = result {
418 -
                failures = failures + 1;
418 +
                failures += 1;
419 419
            }
420 420
        }
421 421
    }
422 422
423 423
    if failures != 0 {
lib/std/arch/rv64/tests/prog.tokenizer.rad +6 -6
85 85
}
86 86
87 87
/// Advance the lexer by one character.
88 88
fn advance(lex: *mut Lexer) {
89 89
    if lex.pos < lex.source.len {
90 -
        lex.pos = lex.pos + 1;
90 +
        lex.pos += 1;
91 91
    }
92 92
}
93 93
94 94
/// Skip whitespace characters.
95 95
fn skipWhitespace(lex: *mut Lexer) {
140 140
            case Token::Invalid(_) => {
141 141
                return false;
142 142
            }
143 143
            case Token::Eof => {
144 144
                list.tokens[list.count] = tok;
145 -
                list.count = list.count + 1;
145 +
                list.count += 1;
146 146
                done = true;
147 147
            }
148 148
            else => {
149 149
                if list.count >= list.tokens.len - 1 {
150 150
                    return false;
151 151
                }
152 152
                list.tokens[list.count] = tok;
153 -
                list.count = list.count + 1;
153 +
                list.count += 1;
154 154
            }
155 155
        }
156 156
    }
157 157
    return true;
158 158
}
159 159
160 160
/// Allocate a new expression node.
161 161
fn newExpr(pool: *mut ExprPool, expr: Expr) -> u32 {
162 162
    let idx = pool.count;
163 163
    pool.nodes[idx] = expr;
164 -
    pool.count = pool.count + 1;
164 +
    pool.count += 1;
165 165
    return idx;
166 166
}
167 167
168 168
/// Get the current token in the parser.
169 169
fn currentToken(p: *Parser) -> Token {
174 174
}
175 175
176 176
/// Advance the parser to the next token.
177 177
fn advanceParser(p: *mut Parser) {
178 178
    if p.pos < p.tokenCount {
179 -
        p.pos = p.pos + 1;
179 +
        p.pos += 1;
180 180
    }
181 181
}
182 182
183 183
/// Parse a primary expression (number, parenthesized expression, or unary minus).
184 184
fn parsePrimary(p: *mut Parser) -> ?u32 {
461 461
    let mut numCount: u32 = 0;
462 462
    let slice = &tokenBuf[0..list.count];
463 463
    for tok in slice {
464 464
        match tok {
465 465
            case Token::Number(_) => {
466 -
                numCount = numCount + 1;
466 +
                numCount += 1;
467 467
            }
468 468
            else => {}
469 469
        }
470 470
    }
471 471
    if numCount != 3 {
lib/std/arch/rv64/tests/prog.vm.rad +5 -5
85 85
fn push(vm: *mut VM, value: i32) throws (VmError) {
86 86
    if vm.sp >= MAX_STACK {
87 87
        throw VmError::StackOverflow;
88 88
    }
89 89
    vm.stack[vm.sp] = value;
90 -
    vm.sp = vm.sp + 1;
90 +
    vm.sp += 1;
91 91
}
92 92
93 93
/// Pop a value from the stack.
94 94
fn pop(vm: *mut VM) -> i32 throws (VmError) {
95 95
    if vm.sp == 0 {
96 96
        throw VmError::StackUnderflow;
97 97
    }
98 -
    vm.sp = vm.sp - 1;
98 +
    vm.sp -= 1;
99 99
    return vm.stack[vm.sp];
100 100
}
101 101
102 102
/// Peek at the top of the stack without removing.
103 103
fn peek(vm: *VM) -> i32 throws (VmError) {
109 109
110 110
/// Execute the bytecode program.
111 111
fn execute(vm: *mut VM) -> i32 throws (VmError) {
112 112
    while vm.pc < vm.codeLen {
113 113
        let instr = vm.code[vm.pc];
114 -
        vm.pc = vm.pc + 1;
114 +
        vm.pc += 1;
115 115
116 116
        match instr {
117 117
            case Op::Push(val) => {
118 118
                try push(vm, val);
119 119
            }
210 210
                let mut base: u32 = 0;
211 211
                if vm.frameCount > 0 {
212 212
                    base = vm.frames[vm.frameCount - 1].localBase + MAX_LOCALS;
213 213
                }
214 214
                vm.frames[vm.frameCount] = Frame { returnAddr: vm.pc, localBase: base };
215 -
                vm.frameCount = vm.frameCount + 1;
215 +
                vm.frameCount += 1;
216 216
                vm.pc = target;
217 217
            }
218 218
            case Op::Ret => {
219 219
                if vm.frameCount == 0 {
220 220
                    throw VmError::InvalidPC;
221 221
                }
222 -
                vm.frameCount = vm.frameCount - 1;
222 +
                vm.frameCount -= 1;
223 223
                vm.pc = vm.frames[vm.frameCount].returnAddr;
224 224
            }
225 225
            case Op::Halt => {
226 226
                return try pop(vm);
227 227
            }
lib/std/arch/rv64/tests/ptr.mutate.rad +2 -2
3 3
fn mutate1(ptr: *mut i32) {
4 4
    *ptr = 39;
5 5
}
6 6
7 7
fn mutate2(ptr: *mut i32) {
8 -
    *ptr = *ptr + 2;
9 -
    *ptr = *ptr + 1;
8 +
    *ptr += 2;
9 +
    *ptr += 1;
10 10
}
11 11
12 12
@default fn main() -> i32 {
13 13
    let mut ptr: i32 = 0;
14 14
lib/std/arch/rv64/tests/record.array.elements.rad +5 -5
12 12
fn vectorSum(vec: Vector) -> i32 {
13 13
    let mut sum: i32 = 0;
14 14
    let mut i: u32 = 0;
15 15
16 16
    while (i < vec.data.len) {
17 -
        sum = sum + vec.data[i];
18 -
        i = i + 1;
17 +
        sum += vec.data[i];
18 +
        i += 1;
19 19
    }
20 20
    return sum;
21 21
}
22 22
23 23
fn vectorScale(vec: Vector, scale: i32) -> Vector {
24 24
    let mut result: Vector = Vector { data: [0, 0, 0, 0] };
25 25
    let mut i: u32 = 0;
26 26
27 27
    while (i < vec.data.len) {
28 28
        result.data[i] = vec.data[i] * scale;
29 -
        i = i + 1;
29 +
        i += 1;
30 30
    }
31 31
    return result;
32 32
}
33 33
34 34
// Sum of the diagonal elements.
35 35
fn matrixTrace(mat: Matrix) -> i32 {
36 36
    let mut sum: i32 = 0;
37 37
    let mut i: u32 = 0;
38 38
39 39
    while (i < mat.rows.len) {
40 -
        sum = sum + mat.rows[i].data[i];
41 -
        i = i + 1;
40 +
        sum += mat.rows[i].data[i];
41 +
        i += 1;
42 42
    }
43 43
    return sum;
44 44
}
45 45
46 46
@default fn main() -> i32 {
lib/std/arch/rv64/tests/record.field.assign.rad +1 -1
4 4
@default fn main() -> i32 {
5 5
    let mut v: Vector = Vector { x: 3, y: 2 };
6 6
7 7
    v.x = 40;
8 8
    v.y = 1;
9 -
    v.y = v.y * 2;
9 +
    v.y *= 2;
10 10
11 11
    return (v.x + v.y) - 42;
12 12
}
lib/std/arch/rv64/tests/ref.immut.loop.bug.rad +1 -1
13 13
fn testZeroIter(n: u32) -> u32 {
14 14
    let val: u32 = 42;
15 15
    let mut i: u32 = 0;
16 16
    while i < n {
17 17
        let _ = read(&val);
18 -
        i = i + 1;
18 +
        i += 1;
19 19
    }
20 20
    return val;
21 21
}
22 22
23 23
@default fn main() -> i32 {
lib/std/arch/rv64/tests/reserve.loop.rad +2 -2
3 3
@default fn main() -> i32 {
4 4
    let mut total: i32 = 0;
5 5
    let mut i: i32 = 0;
6 6
    while i < 10000 {
7 7
        let p: Pair = Pair { a: i, b: i + 1 };
8 -
        total = total + p.a + p.b;
9 -
        i = i + 1;
8 +
        total += p.a + p.b;
9 +
        i += 1;
10 10
    }
11 11
    // Expected: sum(i) + sum(i+1) for i=0..9999
12 12
    // = 2 * 9999*10000/2 + 10000 = 99990000 + 10000 = 100000000
13 13
    if total != 100000000 {
14 14
        return 1;
lib/std/arch/rv64/tests/spill.blockarg.clobber.rad +11 -11
39 39
40 40
fn prepareSchedule(s: *mut State, block: *[u32]) {
41 41
    let mut i: u32 = 0;
42 42
    while i < 16 {
43 43
        s.w[i] = block[i];
44 -
        i = i + 1;
44 +
        i += 1;
45 45
    }
46 46
    while i < 64 {
47 47
        s.w[i] = ssig1(s.w[i - 2]) + s.w[i - 7] + ssig0(s.w[i - 15]) + s.w[i - 16];
48 -
        i = i + 1;
48 +
        i += 1;
49 49
    }
50 50
}
51 51
52 52
/// SHA-256 compression: 64 rounds with 8 rotating working variables.
53 53
/// Exercises heavy register pressure and spilled block-argument shuffles.
71 71
        e = d + t1;
72 72
        d = c;
73 73
        c = b;
74 74
        b = a;
75 75
        a = t1 + t2;
76 -
        i = i + 1;
76 +
        i += 1;
77 77
    }
78 78
79 -
    s.h[0] = s.h[0] + a;
80 -
    s.h[1] = s.h[1] + b;
81 -
    s.h[2] = s.h[2] + c;
82 -
    s.h[3] = s.h[3] + d;
83 -
    s.h[4] = s.h[4] + e;
84 -
    s.h[5] = s.h[5] + f;
85 -
    s.h[6] = s.h[6] + g;
86 -
    s.h[7] = s.h[7] + hh;
79 +
    s.h[0] += a;
80 +
    s.h[1] += b;
81 +
    s.h[2] += c;
82 +
    s.h[3] += d;
83 +
    s.h[4] += e;
84 +
    s.h[5] += f;
85 +
    s.h[6] += g;
86 +
    s.h[7] += hh;
87 87
}
88 88
89 89
@default fn main() -> i32 {
90 90
    let k: [u32; 64] = [
91 91
        0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
lib/std/arch/rv64/tests/spill.loop.rad +1 -1
34 34
    let mut currentOffset: u32 = 0;
35 35
    let mut maxAlignment: u32 = 1;
36 36
    for i in 0..tags.len {
37 37
        let layout = getLayout(tags[i]);
38 38
        currentOffset = alignUp(currentOffset, layout.alignment);
39 -
        currentOffset = currentOffset + layout.size;
39 +
        currentOffset += layout.size;
40 40
        maxAlignment = max(maxAlignment, layout.alignment);
41 41
    }
42 42
    return Layout {
43 43
        size: alignUp(currentOffset, maxAlignment),
44 44
        alignment: maxAlignment,
lib/std/arch/rv64/tests/static.array.mutate.rad +1 -1
1 1
//! Test mutating a static array.
2 2
3 3
static BUFFER: [i32; 3] = [1, 2, 3];
4 4
5 5
fn bump(slot: u32, amount: i32) -> i32 {
6 -
    BUFFER[slot] = BUFFER[slot] + amount;
6 +
    BUFFER[slot] += amount;
7 7
    return BUFFER[0] + BUFFER[1] + BUFFER[2];
8 8
}
9 9
10 10
@default fn main() -> i32 {
11 11
    let a: i32 = bump(0, 4);
lib/std/arch/rv64/tests/static.basic.rad +2 -2
3 3
static GLOBAL: i32 = 0;
4 4
5 5
fn updateCounter(i: i32) -> i32 {
6 6
    static counter: i32 = 0;
7 7
8 -
    counter = counter + i;
9 -
    GLOBAL = GLOBAL + i * 10;
8 +
    counter += i;
9 +
    GLOBAL += i * 10;
10 10
11 11
    return counter;
12 12
}
13 13
14 14
@default fn main() -> i32 {
lib/std/arch/rv64/tests/static.record.array.rad +2 -2
9 9
    values: [5, 1, 9, 2],
10 10
    bias: 4,
11 11
};
12 12
13 13
fn rebalance() -> i32 {
14 -
    TABLE.values[0] = TABLE.values[0] + TABLE.bias;
15 -
    TABLE.values[3] = TABLE.values[3] + 1;
14 +
    TABLE.values[0] += TABLE.bias;
15 +
    TABLE.values[3] += 1;
16 16
    return TABLE.values[0] + TABLE.values[3] + TABLE.bias;
17 17
}
18 18
19 19
@default fn main() -> i32 {
20 20
    let first: i32 = rebalance();
lib/std/arch/rv64/tests/static.slice.offset.rad +1 -1
22 22
    TBL.scratch = &mut SCRATCH[..];
23 23
    TBL.entries = &mut STORAGE[..];
24 24
    TBL.len     = 0;
25 25
26 26
    TBL.entries[TBL.len] = Entry { a: 7, b: 9 };
27 -
    TBL.len               = TBL.len + 1;
27 +
    TBL.len += 1;
28 28
29 29
    if STORAGE[0].a != 7 or STORAGE[0].b != 9 {
30 30
        return 1;
31 31
    }
32 32
    if SCRATCH[0].a != 0 or SCRATCH[0].b != 0 {
lib/std/arch/rv64/tests/union.payload.mutref.rad +1 -1
20 20
21 21
fn addItemViaMatchRef(blk: *mut Block, val: u32) -> bool {
22 22
    match &mut blk.state {
23 23
        case Sealed::No { items } => {
24 24
            items.data[items.len] = val;
25 -
            items.len = items.len + 1;
25 +
            items.len += 1;
26 26
            return true;
27 27
        },
28 28
        case Sealed::Yes => {
29 29
            return false;
30 30
        },
lib/std/arch/rv64/tests/var.infer.rad +1 -1
20 20
@default fn main() -> i32 {
21 21
    let inferredFlag = alwaysTrue();
22 22
    if not (inferredFlag) { panic "assert"; }
23 23
24 24
    let mut counter = returnsCount();
25 -
    counter = counter + 1;
25 +
    counter += 1;
26 26
    if not (counter == 6) { panic "assert"; }
27 27
28 28
    let pair = loadPair();
29 29
    let left = pair.left;
30 30
lib/std/collections/dict.rad +1 -1
40 40
        if entry.key.len == 0 {
41 41
            if m.count >= m.entries.len / 2 {
42 42
                panic "dict::insert: table full";
43 43
            }
44 44
            m.entries[idx] = Entry { key, value };
45 -
            m.count = m.count + 1;
45 +
            m.count += 1;
46 46
            return;
47 47
        }
48 48
        if mem::eq(entry.key, key) {
49 49
            m.entries[idx].value = value;
50 50
            return;
lib/std/fmt.rad +14 -14
20 20
    let mut x: u32 = val;
21 21
    let mut i: u32 = buffer.len;
22 22
23 23
    // Handle the zero case separately to ensure a single '0' is written.
24 24
    if x == 0 {
25 -
        i = i - 1;
25 +
        i -= 1;
26 26
        buffer[i] = '0';
27 27
    } else {
28 28
        // Write digits backwards from the end of the buffer.
29 29
        while x != 0 {
30 -
            i = i - 1;
30 +
            i -= 1;
31 31
            buffer[i] = ('0' + (x % 10) as u8);
32 -
            x = x / 10;
32 +
            x /= 10;
33 33
        }
34 34
    }
35 35
    // Return the slice from the start of the written number to
36 36
    // the end of the buffer.
37 37
    return &buffer[i..];
50 50
    } else {
51 51
        x = val as u32;
52 52
    }
53 53
    // Handle the zero case separately to ensure a single '0' is written.
54 54
    if x == 0 {
55 -
        i = i - 1;
55 +
        i -= 1;
56 56
        buffer[i] = '0';
57 57
    } else {
58 58
        // Write digits backwards from the end of the buffer.
59 59
        while x != 0 {
60 -
            i = i - 1;
60 +
            i -= 1;
61 61
            buffer[i] = '0' + (x % 10) as u8;
62 -
            x = x / 10;
62 +
            x /= 10;
63 63
        }
64 64
        // Add the negative sign if needed.
65 65
        if neg {
66 -
            i = i - 1;
66 +
            i -= 1;
67 67
            buffer[i] = '-';
68 68
        }
69 69
    }
70 70
    return &buffer[i..];
71 71
}
76 76
77 77
    let mut x: u64 = val;
78 78
    let mut i: u32 = buffer.len;
79 79
80 80
    if x == 0 {
81 -
        i = i - 1;
81 +
        i -= 1;
82 82
        buffer[i] = '0';
83 83
    } else {
84 84
        while x != 0 {
85 -
            i = i - 1;
85 +
            i -= 1;
86 86
            buffer[i] = ('0' + (x % 10) as u8);
87 -
            x = x / 10;
87 +
            x /= 10;
88 88
        }
89 89
    }
90 90
    return &buffer[i..];
91 91
}
92 92
102 102
        x = -val as u64;
103 103
    } else {
104 104
        x = val as u64;
105 105
    }
106 106
    if x == 0 {
107 -
        i = i - 1;
107 +
        i -= 1;
108 108
        buffer[i] = '0';
109 109
    } else {
110 110
        while x != 0 {
111 -
            i = i - 1;
111 +
            i -= 1;
112 112
            buffer[i] = '0' + (x % 10) as u8;
113 -
            x = x / 10;
113 +
            x /= 10;
114 114
        }
115 115
        if neg {
116 -
            i = i - 1;
116 +
            i -= 1;
117 117
            buffer[i] = '-';
118 118
        }
119 119
    }
120 120
    return &buffer[i..];
121 121
}
lib/std/io.rad +1 -1
49 49
        }
50 50
        if n > chunk.len {
51 51
            total = buf.len;
52 52
            break;
53 53
        }
54 -
        total = total + n;
54 +
        total += n;
55 55
    }
56 56
    return &buf[..total];
57 57
}
lib/std/lang/alloc.rad +1 -1
86 86
}
87 87
88 88
/// Commits `size` bytes of allocation, advancing the offset.
89 89
/// Use after writing to the buffer returned by [`remainingBuf`].
90 90
pub fn commit(arena: *mut Arena, size: u32) {
91 -
    arena.offset = arena.offset + size;
91 +
    arena.offset += size;
92 92
}
93 93
94 94
/// Allocate a slice of `count` elements, each of `size` bytes with given alignment.
95 95
///
96 96
/// Returns a type-erased slice that should be cast to the appropriate `*[T]`.
lib/std/lang/ast.rad +1 -1
47 47
pub fn nodeListPush(self: *mut NodeList, node: *Node) -> u32 {
48 48
    if self.len >= self.list.len {
49 49
        panic "nodeListPush: out of space";
50 50
    }
51 51
    self.list[self.len] = node;
52 -
    self.len = self.len + 1;
52 +
    self.len += 1;
53 53
54 54
    return self.len;
55 55
}
56 56
57 57
/// Grow a node list's backing storage by `extra` slots.
lib/std/lang/ast/printer.rad +4 -4
290 290
        case super::NodeValue::ArrayRepeatLit(rep) =>
291 291
            return sexpr::list(a, "array-repeat", &[toExpr(a, rep.item), toExpr(a, rep.count)]),
292 292
        case super::NodeValue::RecordLit(lit) => {
293 293
            let mut total: u32 = lit.fields.len;
294 294
            if let _ = lit.typeName {
295 -
                total = total + 1;
295 +
                total += 1;
296 296
            }
297 297
            let buf = try! sexpr::allocExprs(a, total);
298 298
            let mut idx: u32 = 0;
299 299
            if let tn = lit.typeName {
300 300
                buf[idx] = toExpr(a, tn); idx = idx + 1;
331 331
            let mut head = "catch";
332 332
            let mut children: [sexpr::Expr; 3] = undefined;
333 333
            let mut len: u32 = 0;
334 334
            if let b = clause.binding {
335 335
                children[len] = toExpr(a, b);
336 -
                len = len + 1;
336 +
                len += 1;
337 337
            }
338 338
            if let t = clause.typeNode {
339 339
                children[len] = toExpr(a, t);
340 -
                len = len + 1;
340 +
                len += 1;
341 341
            }
342 342
            children[len] = toExpr(a, clause.body);
343 -
            len = len + 1;
343 +
            len += 1;
344 344
            return sexpr::list(a, head, &children[..len]);
345 345
        }
346 346
        case super::NodeValue::Block(blk) => {
347 347
            let children = nodeListToExprs(a, &blk.statements);
348 348
            return sexpr::block(a, "block", &[], children);
lib/std/lang/gen/bitset.rad +11 -11
62 62
        return;
63 63
    }
64 64
    let word = n / 32;
65 65
    let b = n % 32;
66 66
67 -
    bs.bits[word] = bs.bits[word] | (1 << b);
67 +
    bs.bits[word] |= (1 << b);
68 68
}
69 69
70 70
/// Clear bit `n` in the bitset.
71 71
pub fn clear(bs: *mut Bitset, n: u32) {
72 72
    if n >= bs.len {
73 73
        return;
74 74
    }
75 75
    let word = n / 32;
76 76
    let b = n % 32;
77 77
78 -
    bs.bits[word] = bs.bits[word] & ~(1 << b);
78 +
    bs.bits[word] &= ~(1 << b);
79 79
}
80 80
81 81
/// Check if bit `n` is set.
82 82
pub fn contains(bs: *Bitset, n: u32) -> bool {
83 83
    if n >= bs.len {
92 92
/// Count the number of set bits.
93 93
pub fn count(bs: *Bitset) -> u32 {
94 94
    let mut total: u32 = 0;
95 95
    let numWords = wordsFor(bs.len);
96 96
    for i in 0..numWords {
97 -
        total = total + popCount(bs.bits[i]);
97 +
        total += popCount(bs.bits[i]);
98 98
    }
99 99
    return total;
100 100
}
101 101
102 102
/// Population count for a 32-bit word.
103 103
fn popCount(x: u32) -> u32 {
104 104
    let mut n = x;
105 -
    n = n - ((n >> 1) & 0x55555555);
105 +
    n -= ((n >> 1) & 0x55555555);
106 106
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
107 107
    n = (n + (n >> 4)) & 0x0F0F0F0F;
108 -
    n = n + (n >> 8);
109 -
    n = n + (n >> 16);
108 +
    n += (n >> 8);
109 +
    n += (n >> 16);
110 110
111 111
    return n & 0x3F;
112 112
}
113 113
114 114
/// Union: `dst = dst | src`.
115 115
pub fn union_(dst: *mut Bitset, src: *Bitset) {
116 116
    let numWords = wordsFor(dst.len);
117 117
    let srcWords = wordsFor(src.len);
118 118
    let minWords = min(numWords, srcWords);
119 119
    for i in 0..minWords {
120 -
        dst.bits[i] = dst.bits[i] | src.bits[i];
120 +
        dst.bits[i] |= src.bits[i];
121 121
    }
122 122
}
123 123
124 124
/// Subtract: `dst = dst - src`.
125 125
pub fn subtract(dst: *mut Bitset, src: *Bitset) {
126 126
    let numWords = wordsFor(dst.len);
127 127
    let srcWords = wordsFor(src.len);
128 128
    let minWords = min(numWords, srcWords);
129 129
    for i in 0..minWords {
130 -
        dst.bits[i] = dst.bits[i] & ~src.bits[i];
130 +
        dst.bits[i] &= ~src.bits[i];
131 131
    }
132 132
}
133 133
134 134
/// Check if two bitsets are equal.
135 135
pub fn eq(a: *Bitset, b: *Bitset) -> bool {
193 193
    let numWords = wordsFor(it.bs.len);
194 194
    while it.wordIdx < numWords {
195 195
        let word = it.bs.bits[it.wordIdx];
196 196
        // Skip empty words entirely.
197 197
        if word == 0 and it.bitIdx == 0 {
198 -
            it.wordIdx = it.wordIdx + 1;
198 +
            it.wordIdx += 1;
199 199
        } else {
200 200
            while it.bitIdx < 32 {
201 201
                let n = it.wordIdx * 32 + it.bitIdx;
202 202
                if n >= it.bs.len {
203 203
                    return nil;
204 204
                }
205 -
                it.bitIdx = it.bitIdx + 1;
205 +
                it.bitIdx += 1;
206 206
                if (word & (1 << (it.bitIdx - 1))) != 0 {
207 207
                    return n;
208 208
                }
209 209
            }
210 -
            it.wordIdx = it.wordIdx + 1;
210 +
            it.wordIdx += 1;
211 211
            it.bitIdx = 0;
212 212
        }
213 213
    }
214 214
    return nil;
215 215
}
lib/std/lang/gen/bitset/tests.rad +2 -2
186 186
    let mut it = super::iter(&bs);
187 187
    let mut count: u32 = 0;
188 188
    let mut sum: u32 = 0;
189 189
190 190
    while let n = super::iterNext(&mut it) {
191 -
        count = count + 1;
192 -
        sum = sum + n;
191 +
        count += 1;
192 +
        sum += n;
193 193
    }
194 194
195 195
    try testing::expect(count == 4);
196 196
    try testing::expect(sum == 3 + 31 + 32 + 50);
197 197
}
lib/std/lang/gen/labels.rad +1 -1
40 40
pub fn recordBlock(l: *mut Labels, blockIdx: u32, offset: i32) {
41 41
    if blockIdx >= l.blockOffsets.len {
42 42
        panic "recordBlock: block index out of range";
43 43
    }
44 44
    l.blockOffsets[blockIdx] = offset;
45 -
    l.blockCount = l.blockCount + 1;
45 +
    l.blockCount += 1;
46 46
}
47 47
48 48
/// Look up a block's byte offset by index. O(1).
49 49
pub fn blockOffset(l: *Labels, blockIdx: u32) -> i32 {
50 50
    if blockIdx >= l.blockCount {
lib/std/lang/gen/regalloc/assign.rad +4 -4
108 108
            let pred = &blkEnd[block.preds[0]];
109 109
            for k in 0..pred.n {
110 110
                if bitset::contains(&live.liveIn[b], pred.virtRegs[k]) {
111 111
                    current.virtRegs[current.n] = pred.virtRegs[k];
112 112
                    current.physRegs[current.n] = pred.physRegs[k];
113 -
                    current.n = current.n + 1;
113 +
                    current.n += 1;
114 114
                    bitset::set(&mut usedRegs, pred.physRegs[k] as u32);
115 115
                }
116 116
            }
117 117
        }
118 118
176 176
    let mut usedCalleeSaved: u32 = 0;
177 177
    for i in 0..maxReg {
178 178
        if let phys = assignments[i] {
179 179
            for j in 0..config.calleeSaved.len {
180 180
                if phys == config.calleeSaved[j] {
181 -
                    usedCalleeSaved = usedCalleeSaved | (1 << j);
181 +
                    usedCalleeSaved |= (1 << j);
182 182
                }
183 183
            }
184 184
        }
185 185
    }
186 186
222 222
    if rmap.n >= MAX_ACTIVE {
223 223
        panic "rmapSet: register map overflow";
224 224
    }
225 225
    rmap.virtRegs[rmap.n] = virtReg;
226 226
    rmap.physRegs[rmap.n] = physReg;
227 -
    rmap.n = rmap.n + 1;
227 +
    rmap.n += 1;
228 228
}
229 229
230 230
/// Remove a mapping from register map.
231 231
fn rmapRemove(rmap: *mut RegMap, virtReg: u32) {
232 232
    for i in 0..rmap.n {
233 233
        if rmap.virtRegs[i] == virtReg {
234 234
            // Swap with last and decrement.
235 -
            rmap.n = rmap.n - 1;
235 +
            rmap.n -= 1;
236 236
            if i < rmap.n {
237 237
                rmap.virtRegs[i] = rmap.virtRegs[rmap.n];
238 238
                rmap.physRegs[i] = rmap.physRegs[rmap.n];
239 239
            }
240 240
            return;
lib/std/lang/gen/regalloc/liveness.rad +1 -1
119 119
        changed = false;
120 120
121 121
        // Process blocks in reverse order (approximates post-order).
122 122
        let mut b = blockCount;
123 123
        while b > 0 {
124 -
            b = b - 1;
124 +
            b -= 1;
125 125
            let block = &func.blocks[b];
126 126
127 127
            // Compute new `liveOut` as union of successor `liveIn` sets.
128 128
            bitset::clearAll(&mut scratch);
129 129
            addSuccessorLiveIn(func, block, liveIn, &mut scratch);
lib/std/lang/gen/regalloc/spill.rad +5 -5
122 122
        bitset::copy(&mut scratch, &live.liveOut[b]);
123 123
124 124
        // Walk instructions backwards.
125 125
        let mut i = block.instrs.len;
126 126
        while i > 0 {
127 -
            i = i - 1;
127 +
            i -= 1;
128 128
            let instr = block.instrs.list[i];
129 129
130 130
            // Limit register pressure before processing this instruction.
131 131
            limitPressure(&mut scratch, &mut spilled, costs, numRegs);
132 132
167 167
    let mut frameSize: i32 = 0;
168 168
    let mut it = bitset::iter(&spilled);
169 169
170 170
    while let n = bitset::iterNext(&mut it) {
171 171
        slots[n] = frameSize;
172 -
        frameSize = frameSize + slotSize as i32;
172 +
        frameSize += slotSize as i32;
173 173
    }
174 174
    return SpillInfo { slots, frameSize, calleeClass, maxReg };
175 175
}
176 176
177 177
/// Calculate spill costs for all registers, weighted by loop depth.
221 221
    for i in 1..c.n {
222 222
        let key = c.entries[i];
223 223
        let mut j: u32 = i;
224 224
        while j > 0 and c.entries[j - 1].cost > key.cost {
225 225
            c.entries[j] = c.entries[j - 1];
226 -
            j = j - 1;
226 +
            j -= 1;
227 227
        }
228 228
        c.entries[j] = key;
229 229
    }
230 230
    let mut toSpill = excess;
231 231
    if toSpill > c.n {
245 245
        if c.n >= MAX_CANDIDATES {
246 246
            panic "collectCandidates: too many live values";
247 247
        }
248 248
        if reg < costs.len {
249 249
            c.entries[c.n] = CostEntry { reg, cost: costs[reg].defs + costs[reg].uses };
250 -
            c.n = c.n + 1;
250 +
            c.n += 1;
251 251
        }
252 252
    }
253 253
    return c;
254 254
}
255 255
297 297
        if not isCallDst(callDst, n) and n < costs.len {
298 298
            candidates[numCandidates] = CostEntry {
299 299
                reg: n,
300 300
                cost: costs[n].defs + costs[n].uses,
301 301
            };
302 -
            numCandidates = numCandidates + 1;
302 +
            numCandidates += 1;
303 303
        }
304 304
    }
305 305
    // Spill cheapest candidates if crossing count exceeds callee-saved capacity.
306 306
    if numCandidates > numCalleeSaved {
307 307
        let mut c = Candidates { entries: candidates, n: numCandidates };
lib/std/lang/il.rad +4 -4
83 83
84 84
/// Format a qualified symbol name: `pkg::mod::path::name`.
85 85
pub fn formatQualifiedName(arena: *mut alloc::Arena, path: *[*[u8]], name: *[u8]) -> *[u8] {
86 86
    let mut totalLen: u32 = name.len;
87 87
    for segment in path {
88 -
        totalLen = totalLen + segment.len + PATH_SEPARATOR.len;
88 +
        totalLen += segment.len + PATH_SEPARATOR.len;
89 89
    }
90 90
    let buf = try! alloc::allocSlice(arena, 1, 1, totalLen) as *mut [u8];
91 91
    let mut pos: u32 = 0;
92 92
93 93
    for segment in path {
94 -
        pos = pos + try! mem::copy(&mut buf[pos..], segment);
95 -
        pos = pos + try! mem::copy(&mut buf[pos..], PATH_SEPARATOR);
94 +
        pos += try! mem::copy(&mut buf[pos..], segment);
95 +
        pos += try! mem::copy(&mut buf[pos..], PATH_SEPARATOR);
96 96
    }
97 97
    try! mem::copy(&mut buf[pos..], name);
98 98
99 99
    return &buf[..totalLen];
100 100
}
417 417
pub fn instrListPush(self: *mut InstrList, instr: Instr) {
418 418
    if self.len >= self.list.len {
419 419
        panic "instrListPush: out of space";
420 420
    }
421 421
    self.list[self.len] = instr;
422 -
    self.len = self.len + 1;
422 +
    self.len += 1;
423 423
}
424 424
425 425
///////////////////////
426 426
// Utility Functions //
427 427
///////////////////////
lib/std/lang/lower.rad +23 -23
329 329
        if self.errTags[i].ty == errType {
330 330
            return self.errTags[i].tag;
331 331
        }
332 332
    }
333 333
    let tag = self.errTagCounter;
334 -
    self.errTagCounter = self.errTagCounter + 1;
334 +
    self.errTagCounter += 1;
335 335
336 336
    if self.errTagsLen >= self.errTags.len {
337 337
        self.errTags = try! alloc::growSlice(
338 338
            self.arena,
339 339
            self.errTags as *mut [opaque],
341 341
            @sizeOf(ErrTagEntry),
342 342
            @alignOf(ErrTagEntry)
343 343
        ) as *mut [ErrTagEntry];
344 344
    }
345 345
    self.errTags[self.errTagsLen] = ErrTagEntry { ty: errType, tag };
346 -
    self.errTagsLen = self.errTagsLen + 1;
346 +
    self.errTagsLen += 1;
347 347
348 348
    return tag;
349 349
}
350 350
351 351
/// Builder for accumulating data values during constant lowering.
379 379
            b.arena, b.values, b.len,
380 380
            @sizeOf(il::DataValue), @alignOf(il::DataValue)
381 381
        ) as *mut [il::DataValue];
382 382
    }
383 383
    b.values[b.len] = value;
384 -
    b.len = b.len + 1;
384 +
    b.len += 1;
385 385
386 386
    if value.item != il::DataItem::Undef {
387 387
        b.allUndef = false;
388 388
    }
389 389
}
902 902
fn registerFnSym(self: *mut Lowerer, sym: *resolver::Symbol, qualName: *[u8]) {
903 903
    if self.fnSymsLen >= self.fnSyms.len {
904 904
        panic "registerFnSym: symbol table full";
905 905
    }
906 906
    self.fnSyms[self.fnSymsLen] = FnSymEntry { sym, qualName };
907 -
    self.fnSymsLen = self.fnSymsLen + 1;
907 +
    self.fnSymsLen += 1;
908 908
}
909 909
910 910
/// Look up a function's qualified name by its symbol.
911 911
/// Returns `nil` if the symbol wasn't registered (e.g. callee's module is not yet lowered).
912 912
// TODO: This is kind of dubious as an optimization, if it depends on the order
1058 1058
}
1059 1059
1060 1060
/// Generate a unique label by appending the global counter to the base.
1061 1061
fn nextLabel(self: *mut FnLowerer, base: *[u8]) -> *[u8] throws (LowerError) {
1062 1062
    let idx = self.labelCounter;
1063 -
    self.labelCounter = self.labelCounter + 1;
1063 +
    self.labelCounter += 1;
1064 1064
1065 1065
    return try labelWithSuffix(self, base, idx);
1066 1066
}
1067 1067
1068 1068
///////////////////////////////
1480 1480
            self.arena, self.data, self.dataCount,
1481 1481
            @sizeOf(il::Data), @alignOf(il::Data)
1482 1482
        ) as *mut [il::Data];
1483 1483
    }
1484 1484
    self.data[self.dataCount] = data;
1485 -
    self.dataCount = self.dataCount + 1;
1485 +
    self.dataCount += 1;
1486 1486
}
1487 1487
1488 1488
/// Add a function to the lowerer's function list.
1489 1489
fn pushFn(self: *mut Lowerer, f: *il::Fn) throws (LowerError) {
1490 1490
    if self.fnCount >= self.fns.len {
1492 1492
            self.arena, self.fns, self.fnCount,
1493 1493
            @sizeOf(*il::Fn), @alignOf(*il::Fn)
1494 1494
        ) as *mut [*il::Fn];
1495 1495
    }
1496 1496
    self.fns[self.fnCount] = f;
1497 -
    self.fnCount = self.fnCount + 1;
1497 +
    self.fnCount += 1;
1498 1498
}
1499 1499
1500 1500
/// Find an existing string data entry with matching content.
1501 1501
// TODO: Optimize with hash table or remove?
1502 1502
fn findStringData(self: *Lowerer, s: *[u8]) -> ?*[u8] {
1677 1677
}
1678 1678
1679 1679
/// Generate a unique data name for inline literals, eg. `fnName/N`
1680 1680
fn nextDataName(self: *mut FnLowerer) -> *[u8] throws (LowerError) {
1681 1681
    let counter = self.dataCounter;
1682 -
    self.dataCounter = self.dataCounter + 1;
1682 +
    self.dataCounter += 1;
1683 1683
    return try labelWithSuffix(self, self.fnName, counter);
1684 1684
}
1685 1685
1686 1686
/// Get the next available SSA register.
1687 1687
fn nextReg(self: *mut FnLowerer) -> il::Reg {
1688 1688
    let reg = il::Reg { n: self.regCounter };
1689 -
    self.regCounter = self.regCounter + 1;
1689 +
    self.regCounter += 1;
1690 1690
    return reg;
1691 1691
}
1692 1692
1693 1693
/// Initialize a growable parameter list.
1694 1694
fn paramList(self: *mut FnLowerer, cap: u32) -> BlockParams throws (LowerError) {
1703 1703
            self.low.arena, list.list, list.len,
1704 1704
            @sizeOf(il::Param), @alignOf(il::Param)
1705 1705
        ) as *mut [il::Param];
1706 1706
    }
1707 1707
    list.list[list.len] = param;
1708 -
    list.len = list.len + 1;
1708 +
    list.len += 1;
1709 1709
}
1710 1710
1711 1711
/// Remove the last block parameter and its associated variable.
1712 1712
/// Used when detecting a trivial phi that can be eliminated.
1713 1713
fn removeLastBlockParam(self: *mut FnLowerer, block: BlockId) {
1714 1714
    let blk = getBlockMut(self, block);
1715 1715
    if blk.params.len > 0 {
1716 -
        blk.params.len = blk.params.len - 1;
1716 +
        blk.params.len -= 1;
1717 1717
    }
1718 1718
    if blk.paramVars.len > 0 {
1719 -
        blk.paramVars.len = blk.paramVars.len - 1;
1719 +
        blk.paramVars.len -= 1;
1720 1720
    }
1721 1721
}
1722 1722
1723 1723
/// Rewrite cached SSA values for a variable across all blocks, and also
1724 1724
/// rewrite any terminator arguments that reference the provisional register.
1774 1774
            self.low.arena, list.list, list.len,
1775 1775
            @sizeOf(u32), @alignOf(u32)
1776 1776
        ) as *mut [u32];
1777 1777
    }
1778 1778
    list.list[list.len] = value;
1779 -
    list.len = list.len + 1;
1779 +
    list.len += 1;
1780 1780
}
1781 1781
1782 1782
////////////////////////////
1783 1783
// Basic Block Management //
1784 1784
////////////////////////////
1835 1835
        preds,
1836 1836
        vars,
1837 1837
        sealState: Sealed::No { incompleteVars: try u32List(self, 0) },
1838 1838
        loopDepth: self.loopDepth,
1839 1839
    };
1840 -
    self.blockCount = self.blockCount + 1;
1840 +
    self.blockCount += 1;
1841 1841
1842 1842
    return id;
1843 1843
}
1844 1844
1845 1845
/// Create a new block with a single parameter.
1929 1929
                self.low.arena, block.locs, block.locsLen,
1930 1930
                @sizeOf(il::SrcLoc), @alignOf(il::SrcLoc)
1931 1931
            ) as *mut [il::SrcLoc];
1932 1932
        }
1933 1933
        block.locs[block.locsLen] = self.srcLoc;
1934 -
        block.locsLen = block.locsLen + 1;
1934 +
        block.locsLen += 1;
1935 1935
    }
1936 1936
    il::instrListPush(instrs, instr);
1937 1937
}
1938 1938
1939 1939
/// Emit an unconditional jump to `target`.
2399 2399
            instrs: data.instrs,
2400 2400
            locs: &data.locs[..data.locsLen],
2401 2401
            preds,
2402 2402
            loopDepth: data.loopDepth,
2403 2403
        };
2404 -
        count = count + 1;
2404 +
        count += 1;
2405 2405
    }
2406 2406
    return &blocks[..count];
2407 2407
}
2408 2408
2409 2409
/////////////////////
2418 2418
    }
2419 2419
    let slot = &mut self.loopStack[self.loopDepth];
2420 2420
2421 2421
    slot.breakTarget = breakBlock;
2422 2422
    slot.continueTarget = continueBlock;
2423 -
    self.loopDepth = self.loopDepth + 1;
2423 +
    self.loopDepth += 1;
2424 2424
}
2425 2425
2426 2426
/// Exit the current loop context.
2427 2427
fn exitLoop(self: *mut FnLowerer) {
2428 2428
    if self.loopDepth == 0 {
2429 2429
        panic "exitLoop: loopDepth is zero";
2430 2430
    }
2431 -
    self.loopDepth = self.loopDepth - 1;
2431 +
    self.loopDepth -= 1;
2432 2432
}
2433 2433
2434 2434
/// Get the current loop context.
2435 2435
fn currentLoop(self: *mut FnLowerer) -> ?*mut LoopCtx {
2436 2436
    if self.loopDepth == 0 {
2564 2564
    if self.varsLen >= self.vars.len {
2565 2565
        panic "newVar: out of capacity";
2566 2566
    }
2567 2567
    let id = self.varsLen;
2568 2568
    self.vars[id] = VarData { name, type, mutable, addressTaken: false };
2569 -
    self.varsLen = self.varsLen + 1;
2569 +
    self.varsLen += 1;
2570 2570
2571 2571
    let v = Var { id };
2572 2572
    if self.currentBlock != nil {
2573 2573
        defVar(self, v, val);
2574 2574
    }
2632 2632
/// Look up a variable by name in the current scope.
2633 2633
/// Searches from most recently declared to first, enabling shadowing.
2634 2634
fn lookupVarByName(self: *FnLowerer, name: *[u8]) -> ?Var {
2635 2635
    let mut id = self.varsLen;
2636 2636
    while id > 0 {
2637 -
        id = id - 1;
2637 +
        id -= 1;
2638 2638
        if let varName = self.vars[id].name {
2639 2639
            if mem::eq(varName, name) {
2640 2640
                return Var { id };
2641 2641
            }
2642 2642
        }
2911 2911
            throw LowerError::ExpectedIdentifier;
2912 2912
        };
2913 2913
        let v = newVar(self, name, type, false, il::Val::Undef);
2914 2914
2915 2915
        self.params[self.paramsLen] = FnParamBinding { var: v, reg };
2916 -
        self.paramsLen = self.paramsLen + 1;
2916 +
        self.paramsLen += 1;
2917 2917
    }
2918 2918
    return params;
2919 2919
}
2920 2920
2921 2921
/// Resolve match subject.
3243 3243
                    cases[caseIdx] = il::SwitchCase {
3244 3244
                        value: constToScalar(cv),
3245 3245
                        target: blocks[i].n,
3246 3246
                        args: &mut []
3247 3247
                    };
3248 -
                    caseIdx = caseIdx + 1;
3248 +
                    caseIdx += 1;
3249 3249
                }
3250 3250
            }
3251 3251
        }
3252 3252
        try addPredecessor(self, blocks[i], entry);
3253 3253
    }
5921 5921
            cases[caseIdx] = il::SwitchCase {
5922 5922
                value: getOrAssignErrorTag(self.low, errTy) as i64,
5923 5923
                target: blocks[i].n,
5924 5924
                args: &mut []
5925 5925
            };
5926 -
            caseIdx = caseIdx + 1;
5926 +
            caseIdx += 1;
5927 5927
        } else {
5928 5928
            errTypes[i] = nil;
5929 5929
            defaultIdx = i;
5930 5930
        }
5931 5931
    }
lib/std/lang/lower/tests/assign.loop.rad +2 -2
1 1
/// Assignment in a loop, accumulating a value.
2 2
fn assignLoop(n: i32) -> i32 {
3 3
    let mut sum: i32 = 0;
4 4
    let mut i: i32 = 0;
5 5
    while i < n {
6 -
        sum = sum + i;
7 -
        i = i + 1;
6 +
        sum += i;
7 +
        i += 1;
8 8
    }
9 9
    return sum;
10 10
}
lib/std/lang/lower/tests/assign.multi.var.rad +1 -1
2 2
fn assignMultiVar() -> i32 {
3 3
    let mut a: i32 = 1;
4 4
    let mut b: i32 = 2;
5 5
    a = 10;
6 6
    b = 20;
7 -
    a = a + b;
7 +
    a += b;
8 8
    return a;
9 9
}
lib/std/lang/lower/tests/assign.param.rad +2 -2
1 1
/// Assignment overwriting a parameter value.
2 2
fn assignParam(x: i32) -> i32 {
3 3
    let mut y: i32 = x;
4 -
    y = y + 1;
5 -
    y = y * 2;
4 +
    y += 1;
5 +
    y *= 2;
6 6
    return y;
7 7
}
lib/std/lang/lower/tests/assign.self.ref.rad +2 -2
1 1
/// Assignment where the new value depends on the old value.
2 2
fn assignSelfRef() -> i32 {
3 3
    let mut x: i32 = 1;
4 -
    x = x + x;
5 -
    x = x * x;
4 +
    x += x;
5 +
    x *= x;
6 6
    return x;
7 7
}
lib/std/lang/lower/tests/average.rad +1 -1
1 1
/// Compute the sum of a list of numbers.
2 2
fn average(numbers: *[u32]) -> u32 {
3 3
    let mut sum: u32 = 0;
4 4
5 5
    for i in numbers {
6 -
        sum = sum + i;
6 +
        sum += i;
7 7
    }
8 8
    return sum / numbers.len;
9 9
}
lib/std/lang/lower/tests/loop.break.rad +1 -1
2 2
    let mut i: i32 = 0;
3 3
    loop {
4 4
        if i >= n {
5 5
            break;
6 6
        }
7 -
        i = i + 1;
7 +
        i += 1;
8 8
    }
9 9
    return i;
10 10
}
lib/std/lang/lower/tests/loop.continue.rad +2 -2
1 1
fn loopContinue(n: i32) -> i32 {
2 2
    let mut i: i32 = 0;
3 3
    let mut sum: i32 = 0;
4 4
    while i < n {
5 -
        i = i + 1;
5 +
        i += 1;
6 6
        if i == 3 {
7 7
            continue;
8 8
        }
9 -
        sum = sum + i;
9 +
        sum += i;
10 10
    }
11 11
    return sum;
12 12
}
lib/std/lang/lower/tests/loop.for.array.rad +1 -1
1 1
/// Iterates over an array with index binding and sums elements.
2 2
fn forArrayIndexed(arr: [i32; 3]) -> i32 {
3 3
    let mut sum: i32 = 0;
4 4
    for elem, idx in arr {
5 -
        sum = sum + elem + idx as i32;
5 +
        sum += elem + idx as i32;
6 6
    }
7 7
    return sum;
8 8
}
lib/std/lang/lower/tests/loop.for.array.ril +2 -2
5 5
    br.slt w32 %1 3 @body2 @merge3;
6 6
  @body2
7 7
    mul w64 %2 %1 4;
8 8
    add w64 %3 %0 %2;
9 9
    sload w32 %4 %3 0;
10 -
    add w32 %6 %5 %4;
11 -
    add w32 %7 %6 %1;
10 +
    add w32 %6 %4 %1;
11 +
    add w32 %7 %5 %6;
12 12
    jmp @step4;
13 13
  @merge3
14 14
    ret %5;
15 15
  @step4
16 16
    add w32 %8 %1 1;
lib/std/lang/lower/tests/loop.for.continue.rad +2 -2
4 4
    let mut sum: u32 = 0;
5 5
    for i in 0..n {
6 6
        if i == 2 {
7 7
            continue;
8 8
        }
9 -
        sum = sum + i;
9 +
        sum += i;
10 10
    }
11 11
    return sum;
12 12
}
13 13
14 14
fn forContinueArray(arr: [i32; 4]) -> i32 {
15 15
    let mut sum: i32 = 0;
16 16
    for elem in arr {
17 17
        if elem == 0 {
18 18
            continue;
19 19
        }
20 -
        sum = sum + elem;
20 +
        sum += elem;
21 21
    }
22 22
    return sum;
23 23
}
lib/std/lang/lower/tests/loop.for.indexed.rad +1 -1
1 1
fn loopForIndexed(n: i32) -> i32 {
2 2
    let mut sum: i32 = 0;
3 3
    for val, idx in 0..n {
4 -
        sum = sum + val + idx as i32;
4 +
        sum += val + idx as i32;
5 5
    }
6 6
    return sum;
7 7
}
lib/std/lang/lower/tests/loop.for.indexed.ril +4 -4
1 1
fn w32 $loopForIndexed(w32 %0) {
2 2
  @entry0
3 3
    jmp @loop1(0, 0, 0);
4 -
  @loop1(w32 %1, w32 %2, w32 %4)
4 +
  @loop1(w32 %1, w32 %2, w32 %3)
5 5
    br.slt w32 %1 %0 @body2 @merge3;
6 6
  @body2
7 -
    add w32 %3 %2 %1;
8 -
    add w32 %5 %3 %4;
7 +
    add w32 %4 %1 %3;
8 +
    add w32 %5 %2 %4;
9 9
    jmp @step4;
10 10
  @merge3
11 11
    ret %2;
12 12
  @step4
13 13
    add w32 %6 %1 1;
14 -
    add w32 %7 %4 1;
14 +
    add w32 %7 %3 1;
15 15
    jmp @loop1(%6, %5, %7);
16 16
}
lib/std/lang/lower/tests/loop.for.placeholder.rad +2 -2
1 1
// Test for loop with placeholder binding
2 2
3 3
fn forPlaceholder(n: u32) -> u32 {
4 4
    let mut count: u32 = 0;
5 5
    for _ in 0..n {
6 -
        count = count + 1;
6 +
        count += 1;
7 7
    }
8 8
    return count;
9 9
}
10 10
11 11
fn forPlaceholderArray(arr: [i32; 4]) -> i32 {
12 12
    let mut count: i32 = 0;
13 13
    for _ in arr {
14 -
        count = count + 1;
14 +
        count += 1;
15 15
    }
16 16
    return count;
17 17
}
lib/std/lang/lower/tests/loop.for.rad +1 -1
1 1
fn loopFor(n: i32) -> i32 {
2 2
    let mut sum: i32 = 0;
3 3
    for i in 0..n {
4 -
        sum = sum + i;
4 +
        sum += i;
5 5
    }
6 6
    return sum;
7 7
}
lib/std/lang/lower/tests/loop.for.slice.rad +1 -1
1 1
/// Iterates over a slice with index binding and sums elements.
2 2
fn forSliceIndexed(s: *[i32]) -> i32 {
3 3
    let mut sum: i32 = 0;
4 4
    for elem, idx in s {
5 -
        sum = sum + elem + idx as i32;
5 +
        sum += elem + idx as i32;
6 6
    }
7 7
    return sum;
8 8
}
lib/std/lang/lower/tests/loop.for.slice.ril +2 -2
7 7
    br.slt w32 %3 %1 @body2 @merge3;
8 8
  @body2
9 9
    mul w64 %4 %3 4;
10 10
    add w64 %5 %2 %4;
11 11
    sload w32 %6 %5 0;
12 -
    add w32 %8 %7 %6;
13 -
    add w32 %9 %8 %3;
12 +
    add w32 %8 %6 %3;
13 +
    add w32 %9 %7 %8;
14 14
    jmp @step4;
15 15
  @merge3
16 16
    ret %7;
17 17
  @step4
18 18
    add w32 %10 %3 1;
lib/std/lang/lower/tests/loop.for.unsigned.range.rad +2 -2
1 1
fn loopForUnsignedRange(start: u32, end: u32) -> u32 {
2 2
    let mut count: u32 = 0;
3 3
    for _ in start..end {
4 -
        count = count + 1;
4 +
        count += 1;
5 5
    }
6 6
    return count;
7 7
}
8 8
9 9
fn loopForSignedRange(start: i32, end: i32) -> i32 {
10 10
    let mut count: i32 = 0;
11 11
    for _ in start..end {
12 -
        count = count + 1;
12 +
        count += 1;
13 13
    }
14 14
    return count;
15 15
}
lib/std/lang/lower/tests/loop.nested.break.rad +3 -3
5 5
    let mut i: i32 = 0;
6 6
7 7
    loop {
8 8
        let mut j: i32 = 0;
9 9
        loop {
10 -
            result = result + 1;
11 -
            j = j + 1;
10 +
            result += 1;
11 +
            j += 1;
12 12
            if j >= n {
13 13
                break;
14 14
            }
15 15
        }
16 -
        i = i + 1;
16 +
        i += 1;
17 17
        if i >= n {
18 18
            break;
19 19
        }
20 20
    }
21 21
    return result;
lib/std/lang/lower/tests/loop.nested.continue.rad +3 -3
3 3
fn nestedContinue(n: i32) -> i32 {
4 4
    let mut result: i32 = 0;
5 5
    let mut i: i32 = 0;
6 6
7 7
    while i < n {
8 -
        i = i + 1;
8 +
        i += 1;
9 9
        if i == 2 {
10 10
            continue;
11 11
        }
12 12
        let mut j: i32 = 0;
13 13
        while j < n {
14 -
            j = j + 1;
14 +
            j += 1;
15 15
            if j == 1 {
16 16
                continue;
17 17
            }
18 -
            result = result + 1;
18 +
            result += 1;
19 19
        }
20 20
    }
21 21
    return result;
22 22
}
lib/std/lang/lower/tests/loop.return.rad +1 -1
1 1
fn loopReturn() -> i32 {
2 2
    let mut i: i32 = 0;
3 3
    loop {
4 -
        i = i + 1;
4 +
        i += 1;
5 5
        if i == 10 {
6 6
            return i;
7 7
        }
8 8
    }
9 9
}
lib/std/lang/lower/tests/loop.while.nested.shortcircuit.rad +3 -3
11 11
    let mut outer: i32 = 0;
12 12
    let mut total: i32 = 0;
13 13
    while outer < n {
14 14
        let mut inner: i32 = outer;
15 15
        while inner > 0 and inner < 100 {
16 -
            inner = inner - 1;
16 +
            inner -= 1;
17 17
        }
18 -
        total = total + outer;
19 -
        outer = outer + 1;
18 +
        total += outer;
19 +
        outer += 1;
20 20
    }
21 21
    return total;
22 22
}
lib/std/lang/lower/tests/loop.while.rad +2 -2
1 1
fn loopWhile(n: i32) -> i32 {
2 2
    let mut i: i32 = 0;
3 3
    let mut sum: i32 = 0;
4 4
    while i < n {
5 -
        sum = sum + i;
6 -
        i = i + 1;
5 +
        sum += i;
6 +
        i += 1;
7 7
    }
8 8
    return sum;
9 9
}
lib/std/lang/lower/tests/loop.whilelet.case.rad +1 -1
2 2
fn whileLetCase(x: i32) -> i32 {
3 3
    let mut cur: i32 = x;
4 4
    let mut steps: i32 = 0;
5 5
    while let case 0 = cur {
6 6
        cur = 1;
7 -
        steps = steps + 1;
7 +
        steps += 1;
8 8
    }
9 9
    return steps;
10 10
}
lib/std/lang/lower/tests/loop.whilelet.guard.rad +1 -1
2 2
fn whileLetCaseGuard(x: i32) -> i32 {
3 3
    let mut cur: i32 = x;
4 4
    let mut steps: i32 = 0;
5 5
    while let case 0 = cur; steps < 3 {
6 6
        cur = 0;
7 -
        steps = steps + 1;
7 +
        steps += 1;
8 8
    }
9 9
    return steps;
10 10
}
lib/std/lang/lower/tests/loop.whilelet.optional.rad +1 -1
1 1
// Returns the iteration count for a single guarded loop.
2 2
fn whileLetOptional(p: ?*i32) -> i32 {
3 3
    let mut steps: i32 = 0;
4 4
    while let _ = p {
5 -
        steps = steps + 1;
5 +
        steps += 1;
6 6
        break;
7 7
    }
8 8
    return steps;
9 9
}
lib/std/lang/lower/tests/loop.whilelet.union.rad +1 -1
4 4
/// Sum values from a linked iteration using while-let case with binding.
5 5
fn sumWhileLet(x: Option) -> u32 {
6 6
    let mut opt = x;
7 7
    let mut sum: u32 = 0;
8 8
    while let case Option::Some(val) = opt {
9 -
        sum = sum + val;
9 +
        sum += val;
10 10
        opt = Option::None;
11 11
    }
12 12
    return sum;
13 13
}
lib/std/lang/lower/tests/mutref.loop.rad +1 -1
6 6
fn test() -> i32 {
7 7
    let mut maxReg: u32 = 0;
8 8
    let mut i: u32 = 0;
9 9
    while i < 3 {
10 10
        callback(i, &mut maxReg as *mut opaque);
11 -
        i = i + 1;
11 +
        i += 1;
12 12
    }
13 13
    return maxReg as i32;
14 14
}
lib/std/lang/lower/tests/mutref.scalar.rad +1 -1
1 1
fn modify(counter: *mut i32, ret: bool) -> bool {
2 -
    *counter = *counter + 1;
2 +
    *counter += 1;
3 3
    return ret;
4 4
}
5 5
6 6
fn test() -> i32 {
7 7
    let mut x: i32 = 0;
lib/std/lang/lower/tests/reserve.loop.rad +2 -2
3 3
fn reserveInLoop(n: i32) -> i32 {
4 4
    let mut sum: i32 = 0;
5 5
    let mut i: i32 = 0;
6 6
    while i < n {
7 7
        let p: Pair = Pair { a: i, b: i + 1 };
8 -
        sum = sum + p.a + p.b;
9 -
        i = i + 1;
8 +
        sum += p.a + p.b;
9 +
        i += 1;
10 10
    }
11 11
    return sum;
12 12
}
lib/std/lang/lower/tests/reserve.loop.ril +3 -3
7 7
    reserve %3 8 4;
8 8
    store w32 %1 %3 0;
9 9
    add w32 %4 %1 1;
10 10
    store w32 %4 %3 4;
11 11
    sload w32 %6 %3 0;
12 -
    add w32 %7 %5 %6;
13 -
    sload w32 %8 %3 4;
14 -
    add w32 %9 %7 %8;
12 +
    sload w32 %7 %3 4;
13 +
    add w32 %8 %6 %7;
14 +
    add w32 %9 %5 %8;
15 15
    add w32 %10 %1 1;
16 16
    jmp @while1(%10, %2, %9);
17 17
  @merge3
18 18
    ret %5;
19 19
}
lib/std/lang/lower/tests/slice.mutable.rad +1 -1
3 3
fn mutSliceStore(s: *mut [i32], idx: u32, val: i32) {
4 4
    s[idx] = val;
5 5
}
6 6
7 7
fn mutSliceIncrement(s: *mut [i32], idx: u32) {
8 -
    s[idx] = s[idx] + 1;
8 +
    s[idx] += 1;
9 9
}
10 10
11 11
fn mutSliceSwap(s: *mut [i32], i: u32, j: u32) {
12 12
    let tmp = s[i];
13 13
    s[i] = s[j];
lib/std/lang/lower/tests/static.assign.rad +1 -1
1 1
/// Test static variable assignment.
2 2
static COUNTER: i32 = 0;
3 3
4 4
fn increment() -> i32 {
5 -
    COUNTER = COUNTER + 1;
5 +
    COUNTER += 1;
6 6
    return COUNTER;
7 7
}
lib/std/lang/lower/tests/static.local.decl.rad +1 -1
1 1
/// Test lowering of function-local static and const declarations.
2 2
fn localStaticAndConst() -> i32 {
3 3
    static LOCAL: i32 = 7;
4 4
    const ADD: i32 = 5;
5 5
6 -
    LOCAL = LOCAL + ADD;
6 +
    LOCAL += ADD;
7 7
    return LOCAL;
8 8
}
lib/std/lang/lower/tests/union.match.ref.rad +1 -1
31 31
32 32
/// While-let on a mutable union reference.
33 33
fn whileLetRef(ptr: *mut Option) -> u32 {
34 34
    let mut sum: u32 = 0;
35 35
    while let case Option::Some(val) = ptr {
36 -
        sum = sum + *val;
36 +
        sum += *val;
37 37
        *ptr = Option::None;
38 38
    }
39 39
    return sum;
40 40
}
41 41
lib/std/lang/module.rad +5 -5
263 263
    for i in 0..filePath.len {
264 264
        if filePath[i] == PATH_SEP {
265 265
            if i > last {
266 266
                debug::assertMsg(count < components.len, "parsePath: output slice is large enough");
267 267
                components[count] = &filePath[last..i];
268 -
                count = count + 1;
268 +
                count += 1;
269 269
            }
270 270
            last = i + 1;
271 271
        }
272 272
    }
273 273
    if last >= filePath.len {
279 279
    if let name = trimExtension(&filePath[last..]) {
280 280
        components[count] = name;
281 281
    } else {
282 282
        return nil;
283 283
    };
284 -
    count = count + 1;
284 +
    count += 1;
285 285
286 286
    return count;
287 287
}
288 288
289 289
/// Register a module from a file path, creating the full hierarchy as needed.
338 338
fn allocModule(graph: *mut ModuleGraph, packageId: u16, name: *[u8], filePath: *[u8]) -> *mut ModuleEntry throws (ModuleError) {
339 339
    if graph.entriesLen >= graph.entries.len {
340 340
        throw ModuleError::CapacityExceeded;
341 341
    }
342 342
    let idx = graph.entriesLen;
343 -
    graph.entriesLen = graph.entriesLen + 1;
343 +
    graph.entriesLen += 1;
344 344
345 345
    // TODO: This is a common pattern that needs better syntax.
346 346
    let m = &mut graph.entries[idx];
347 347
    *m = ModuleEntry {
348 348
        id: idx as u16,
368 368
fn appendPathSegment(entry: *mut ModuleEntry, segment: *[u8]) throws (ModuleError) {
369 369
    if entry.pathDepth >= entry.path.len {
370 370
        throw ModuleError::PathTooDeep;
371 371
    }
372 372
    entry.path[entry.pathDepth] = segment;
373 -
    entry.pathDepth = entry.pathDepth + 1;
373 +
    entry.pathDepth += 1;
374 374
}
375 375
376 376
/// Append a child identifier to the parent's child list.
377 377
fn addChild(parent: *mut ModuleEntry, childId: u16) -> u16 throws (ModuleError) {
378 378
    if parent.childrenLen >= parent.children.len {
379 379
        throw ModuleError::CapacityExceeded;
380 380
    }
381 381
    parent.children[parent.childrenLen] = childId;
382 -
    parent.childrenLen = parent.childrenLen + 1;
382 +
    parent.childrenLen += 1;
383 383
384 384
    return childId;
385 385
}
386 386
387 387
/// Check if `id` points at an allocated entry.
lib/std/lang/parser.rad +8 -8
208 208
    if start + 1 < text.len and text[start] == '0' {
209 209
        let prefix = text[start + 1];
210 210
        if prefix == 'x' or prefix == 'X' {
211 211
            radix = 16;
212 212
            radixType = ast::Radix::Hex;
213 -
            start = start + 2;
213 +
            start += 2;
214 214
        } else if prefix == 'b' or prefix == 'B' {
215 215
            radix = 2;
216 216
            radixType = ast::Radix::Binary;
217 -
            start = start + 2;
217 +
            start += 2;
218 218
        }
219 219
        if start >= text.len {
220 220
            throw failParsing(p, "integer literal prefix must be followed by digits");
221 221
        }
222 222
    }
228 228
            throw failParsing(p, "invalid digit in integer literal");
229 229
        };
230 230
        if value > (U64_MAX / radix64) {
231 231
            throw failParsing(p, "integer literal overflow");
232 232
        }
233 -
        value = value * radix64;
233 +
        value *= radix64;
234 234
235 235
        if value > U64_MAX - (digit as u64) {
236 236
            throw failParsing(p, "integer literal overflow");
237 237
        }
238 -
        value = value + (digit as u64);
238 +
        value += (digit as u64);
239 239
    }
240 240
    return ast::IntLiteral {
241 241
        text, magnitude: value, radix: radixType, signed, negative,
242 242
    };
243 243
}
299 299
                case '\\' => dst[j] = '\\',
300 300
                case '"'  => dst[j] = '"',
301 301
                case '0'  => dst[j] = 0,
302 302
                else      => dst[j] = raw[i + 1],
303 303
            }
304 -
            i = i + 2;
304 +
            i += 2;
305 305
        } else {
306 306
            dst[j] = raw[i];
307 -
            i = i + 1;
307 +
            i += 1;
308 308
        }
309 -
        j = j + 1;
309 +
        j += 1;
310 310
    }
311 311
    return j;
312 312
}
313 313
314 314
/// Emit a single attribute node.
1135 1135
    debug::assert(message.len > 0);
1136 1136
1137 1137
    // Ignore errors once the error list is full.
1138 1138
    if p.errors.count < p.errors.list.len {
1139 1139
        p.errors.list[p.errors.count] = Error { message, token };
1140 -
        p.errors.count = p.errors.count + 1;
1140 +
        p.errors.count += 1;
1141 1141
    }
1142 1142
}
1143 1143
1144 1144
/// Fail the parsing process with the given error.
1145 1145
fn failParsing(p: *mut Parser, err: *[u8]) -> ParseError {
lib/std/lang/resolver.rad +14 -14
839 839
    // Don't record more than one error per node.
840 840
    if let n = node; errorForNode(self, n) != nil {
841 841
        return ResolveError::Failure;
842 842
    }
843 843
    self.errors.list[self.errors.listLen] = Error { kind, node, moduleId: self.currentMod };
844 -
    self.errors.listLen = self.errors.listLen + 1;
844 +
    self.errors.listLen += 1;
845 845
846 846
    return ResolveError::Failure;
847 847
}
848 848
849 849
/// Like [`emitError`], but for type mismatches specifically.
930 930
{
931 931
    if self.loopDepth >= MAX_LOOP_DEPTH {
932 932
        panic "visitLoop: loop nesting depth exceeded";
933 933
    }
934 934
    self.loopStack[self.loopDepth] = LoopCtx { hasBreak: false };
935 -
    self.loopDepth = self.loopDepth + 1;
935 +
    self.loopDepth += 1;
936 936
937 937
    let ty = try infer(self, body) catch {
938 938
        if self.loopDepth == 0 {
939 939
            panic "visitLoop: loop depth underflow";
940 940
        }
941 -
        self.loopDepth = self.loopDepth - 1;
941 +
        self.loopDepth -= 1;
942 942
        throw ResolveError::Failure;
943 943
    };
944 944
    // Pop and check if break was encountered.
945 -
    self.loopDepth = self.loopDepth - 1;
945 +
    self.loopDepth -= 1;
946 946
947 947
    if self.loopStack[self.loopDepth].hasBreak {
948 948
        return Type::Void;
949 949
    }
950 950
    return Type::Never;
1895 1895
    // Propagate module ID to the symbol for fast lookup.
1896 1896
    if let modId = scope.moduleId {
1897 1897
        sym.moduleId = modId;
1898 1898
    }
1899 1899
    scope.symbols[scope.symbolsLen] = sym;
1900 -
    scope.symbolsLen = scope.symbolsLen + 1;
1900 +
    scope.symbolsLen += 1;
1901 1901
}
1902 1902
1903 1903
/// Bind a value identifier in the current scope.
1904 1904
/// Returns `nil` if the identifier is a placeholder (`_`).
1905 1905
fn bindValueIdent(
2607 2607
2608 2608
    for i in 0..attrNodes.len {
2609 2609
        let node = attrNodes.list[i];
2610 2610
        let case ast::NodeValue::Attribute(attr) = node.value
2611 2611
            else panic "resolveAttributes: invalid attribute node";
2612 -
        mask = mask | (attr as u32);
2612 +
        mask |= (attr as u32);
2613 2613
    }
2614 2614
    return mask;
2615 2615
}
2616 2616
2617 2617
/// Ensure the `default` attribute is only applied to functions.
2924 2924
        let paramTy = try infer(self, paramNode) catch {
2925 2925
            exitFn(self);
2926 2926
            throw ResolveError::Failure;
2927 2927
        };
2928 2928
        fnType.paramTypes[fnType.paramTypesLen] = allocType(self, paramTy);
2929 -
        fnType.paramTypesLen = fnType.paramTypesLen + 1;
2929 +
        fnType.paramTypesLen += 1;
2930 2930
    }
2931 2931
2932 2932
    for i in 0..decl.sig.throwList.len {
2933 2933
        if fnType.throwListLen >= fnType.throwList.len {
2934 2934
            break;
2937 2937
        let throwTy = try infer(self, throwNode) catch {
2938 2938
            exitFn(self);
2939 2939
            throw ResolveError::Failure;
2940 2940
        };
2941 2941
        fnType.throwList[fnType.throwListLen] = allocType(self, throwTy);
2942 -
        fnType.throwListLen = fnType.throwListLen + 1;
2942 +
        fnType.throwListLen += 1;
2943 2943
    }
2944 2944
    exitFn(self);
2945 2945
2946 2946
    // Bind the function name.
2947 2947
    let ty = Type::Fn(allocFnType(self, fnType));
3043 3043
        // Compute field offset by aligning to field's alignment.
3044 3044
        let fieldLayout = getTypeLayout(fieldType);
3045 3045
        currentOffset = mem::alignUp(currentOffset, fieldLayout.alignment);
3046 3046
3047 3047
        result[fieldsLen] = RecordField { name: fieldName, fieldType, offset: currentOffset as i32 };
3048 -
        fieldsLen = fieldsLen + 1;
3048 +
        fieldsLen += 1;
3049 3049
3050 3050
        // Advance offset past this field.
3051 -
        currentOffset = currentOffset + fieldLayout.size;
3051 +
        currentOffset += fieldLayout.size;
3052 3052
3053 3053
        // Track max alignment for record layout.
3054 3054
        maxAlignment = max(maxAlignment, fieldLayout.alignment);
3055 3055
    }
3056 3056
    // Compute cached layout.
3158 3158
        variants[variantCount] = UnionVariant {
3159 3159
            name: variantName,
3160 3160
            valueType: variantType,
3161 3161
            symbol: variantSym,
3162 3162
        };
3163 -
        variantCount = variantCount + 1;
3163 +
        variantCount += 1;
3164 3164
    }
3165 3165
    // Compute cached layout values.
3166 3166
    let tagSize: u32 = 1;
3167 3167
    let mut maxVarSize: u32 = 0;
3168 3168
    let mut maxVarAlign: u32 = 1;
3671 3671
                    if let case NodeExtra::UnionVariant { ordinal: ix, .. } = self.nodeData.entries[pattern.id].extra {
3672 3672
                        if covered[ix] {
3673 3673
                            throw emitError(self, pattern, ErrorKind::DuplicateMatchPattern);
3674 3674
                        }
3675 3675
                        covered[ix] = true;
3676 -
                        coveredCount = coveredCount + 1;
3676 +
                        coveredCount += 1;
3677 3677
                    }
3678 3678
                }
3679 3679
            }
3680 3680
        }
3681 3681
    }
5381 5381
5382 5382
            for i in 0..t.params.len {
5383 5383
                let paramTy = try infer(self, t.params.list[i]);
5384 5384
5385 5385
                fnType.paramTypes[fnType.paramTypesLen] = allocType(self, paramTy);
5386 -
                fnType.paramTypesLen = fnType.paramTypesLen + 1;
5386 +
                fnType.paramTypesLen += 1;
5387 5387
            }
5388 5388
            for i in 0..t.throwList.len {
5389 5389
                let tyNode = t.throwList.list[i];
5390 5390
                let throwTy = try infer(self, tyNode);
5391 5391
5392 5392
                fnType.throwList[fnType.throwListLen] = allocType(self, throwTy);
5393 -
                fnType.throwListLen = fnType.throwListLen + 1;
5393 +
                fnType.throwListLen += 1;
5394 5394
            }
5395 5395
            if let ret = t.returnType {
5396 5396
                fnType.returnType = allocType(self, try infer(self, ret));
5397 5397
            } else {
5398 5398
                fnType.returnType = allocType(self, Type::Void);
lib/std/lang/scanner.rad +3 -3
352 352
    return s.source[s.cursor + 1];
353 353
}
354 354
355 355
/// Advance scanner and return the character that was consumed.
356 356
fn advance(s: *mut Scanner) -> u8 {
357 -
    s.cursor = s.cursor + 1;
357 +
    s.cursor += 1;
358 358
    return s.source[s.cursor - 1];
359 359
}
360 360
361 361
/// Consume the expected character if it matches the current position.
362 362
fn consume(s: *mut Scanner, expected: u8) -> bool {
712 712
        return nil;
713 713
    }
714 714
    for ch in &source[..offset] {
715 715
        if ch == '\n' {
716 716
            c = 1;
717 -
            l = l + 1;
717 +
            l += 1;
718 718
        } else {
719 -
            c = c + 1;
719 +
            c += 1;
720 720
        }
721 721
    }
722 722
    return Location { file, line: l, col: c };
723 723
}
lib/std/lang/sexpr.rad +1 -1
104 104
            if toWrite > remaining {
105 105
                toWrite = remaining;
106 106
            }
107 107
            for i in 0..toWrite {
108 108
                buf[*pos] = s[i];
109 -
                *pos = *pos + 1;
109 +
                *pos += 1;
110 110
            }
111 111
        }
112 112
    }
113 113
}
114 114
lib/std/lang/strings.rad +1 -1
67 67
        case Lookup::Empty(idx) => {
68 68
            if sp.count >= TABLE_SIZE / 2 {
69 69
                panic "intern: string pool is full";
70 70
            }
71 71
            sp.table[idx] = str;
72 -
            sp.count = sp.count + 1;
72 +
            sp.count += 1;
73 73
74 74
            return str;
75 75
        }
76 76
    }
77 77
}
lib/std/mem.rad +2 -2
47 47
/// Count number of set bits in a 32-bit value.
48 48
pub fn popCount(x: u32) -> i32 {
49 49
    let mut n = x;
50 50
    let mut count: i32 = 0;
51 51
    while n != 0 {
52 -
        count = count + (n & 1) as i32;
53 -
        n = n >> 1;
52 +
        count += (n & 1) as i32;
53 +
        n >>= 1;
54 54
    }
55 55
    return count;
56 56
}
57 57
58 58
/// Check whether two byte slices have the same length and contents.
lib/std/sys/unix.rad +2 -2
63 63
            return n;
64 64
        }
65 65
        if n == 0 {
66 66
            break;
67 67
        }
68 -
        total = total + n as u32;
68 +
        total += n as u32;
69 69
    }
70 70
    return total as i32;
71 71
}
72 72
73 73
/// Writes to a file descriptor from the provided buffer.
123 123
        let n = write(fd, chunk);
124 124
        if n <= 0 {
125 125
            close(fd);
126 126
            return false;
127 127
        }
128 -
        written = written + n as u32;
128 +
        written += n as u32;
129 129
    }
130 130
    close(fd);
131 131
132 132
    return true;
133 133
}
lib/std/testing.rad +2 -2
61 61
    try testFn() catch {
62 62
        success = false;
63 63
    };
64 64
    if success {
65 65
        io::printLn("ok");
66 -
        ctx.passed = ctx.passed + 1;
66 +
        ctx.passed += 1;
67 67
    } else {
68 68
        io::printLn("FAILED");
69 -
        ctx.failed = ctx.failed + 1;
69 +
        ctx.failed += 1;
70 70
    }
71 71
}
72 72
73 73
fn printTestSummary(ctx: *Ctx) {
74 74
    if (ctx.failed > 0) {
lib/std/vec.rad +2 -2
72 72
    let off: u32 = vec.len * vec.stride;
73 73
    let dst: *mut u8 = &mut vec.data[off];
74 74
    let src: *u8 = elem as *u8;
75 75
76 76
    copyBytes(dst, src, vec.stride);
77 -
    vec.len = vec.len + 1;
77 +
    vec.len += 1;
78 78
79 79
    return true;
80 80
}
81 81
82 82
/// Pop an element from the end of the vector.
85 85
/// Returns false if the vector is empty.
86 86
pub fn pop(vec: *mut RawVec, out: *mut opaque) -> bool {
87 87
    if vec.len == 0 {
88 88
        return false;
89 89
    }
90 -
    vec.len = vec.len - 1;
90 +
    vec.len -= 1;
91 91
92 92
    let off: u32 = vec.len * vec.stride;
93 93
    let src: *u8 = &vec.data[off];
94 94
    let dst: *mut u8 = out as *mut u8;
95 95
test/lower/lower-test.rad +2 -2
39 39
40 40
    while i < line.len and line[i] != ';' {
41 41
        if line[i] != ' ' and line[i] != '\t' {
42 42
            end = i + 1;
43 43
        }
44 -
        i = i + 1;
44 +
        i += 1;
45 45
    }
46 46
    return &line[..end];
47 47
}
48 48
49 49
/// Get next line from string at offset. Returns the line and updates offset past newline.
50 50
fn nextLine(s: *[u8], offset: *mut u32) -> *[u8] {
51 51
    let start = *offset;
52 52
    let mut i = start;
53 53
54 54
    while i < s.len and s[i] != '\n' {
55 -
        i = i + 1;
55 +
        i += 1;
56 56
    }
57 57
    let line = &s[start..i];
58 58
    if i < s.len {
59 59
        *offset = i + 1;
60 60
    } else {