migrate to the new for-loop syntax
Drop the ':' before captures (for xs (x) / for 0..n (i)); the index capture becomes the trailing open range (for xs, 0.. (x, i)). 136 headers across 26 files, mechanical. Five headless tests (banner_layout, hit_test, swipe_commit, swipe_intent, swipe_reshuffle) also gain a direct #import "modules/ui/types.sx" — they named Point/Frame through a transitive import, which bare visibility no longer permits. Gates: sx build --target ios-sim main.sx links; tools/run_tests.sh 23/23.
This commit is contained in:
@@ -18,7 +18,7 @@ t :: #import "test.sx";
|
||||
// maps to `.empty`, so a board can be hand-written with holes in any position.
|
||||
char_to_gem :: (c: u8) -> Gem {
|
||||
if c == EMPTY_CHAR { return .empty; }
|
||||
for 0..GEM_COUNT: (i) {
|
||||
for 0..GEM_COUNT (i) {
|
||||
if GEM_CHARS[i] == c { return cast(Gem) i; }
|
||||
}
|
||||
.red
|
||||
@@ -27,9 +27,9 @@ char_to_gem :: (c: u8) -> Gem {
|
||||
// Load an 8x8 board from `rows` (top row first, each exactly BOARD_COLS chars).
|
||||
load_board :: (rows: []string) -> Board {
|
||||
b : Board = ---;
|
||||
for 0..BOARD_ROWS: (row) {
|
||||
for 0..BOARD_ROWS (row) {
|
||||
line := rows[row];
|
||||
for 0..BOARD_COLS: (col) {
|
||||
for 0..BOARD_COLS (col) {
|
||||
b.set(col, row, char_to_gem(line[col]));
|
||||
}
|
||||
}
|
||||
@@ -42,15 +42,15 @@ load_board :: (rows: []string) -> Board {
|
||||
// them a hole. This single check covers holes-bubble-to-top, gems-settle-to-
|
||||
// bottom, order-preservation, and the all-holes / no-holes edge columns at once.
|
||||
check_collapsed :: (orig: *Board, b: *Board) -> bool {
|
||||
for 0..BOARD_COLS: (col) {
|
||||
for 0..BOARD_COLS (col) {
|
||||
gems : [BOARD_ROWS]Gem = ---;
|
||||
n := 0;
|
||||
for 0..BOARD_ROWS: (row) {
|
||||
for 0..BOARD_ROWS (row) {
|
||||
g := orig.at(col, row);
|
||||
if g != .empty { gems[n] = g; n += 1; }
|
||||
}
|
||||
boundary := BOARD_ROWS - n; // first row that must hold a gem
|
||||
for 0..BOARD_ROWS: (row) {
|
||||
for 0..BOARD_ROWS (row) {
|
||||
if row < boundary {
|
||||
if b.at(col, row) != .empty { return false; }
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user