lang migration: rename signed integer types sN -> iN
Mechanical sweep of all .sx sources, plan docs, and tests/expected snapshots for the sx language rename (s8/s16/s32/s64 -> i8/i16/i32/i64). Verified: tools/run_tests.sh 23/23. Note: the ios-sim build has 2 pre-existing 'restart' dot-call errors from the sx opt-in UFCS change (sx a47ea14) — independent of this rename (present pre-sweep); migrated in the follow-up commit.
This commit is contained in:
@@ -33,14 +33,14 @@ GRAY_TOL :: 24; // max channel spread still considered neutral gray
|
||||
LUM_MARGIN :: 4; // lum headroom above the light checker shade
|
||||
|
||||
is_gray :: (r: u8, g: u8, b: u8) -> bool {
|
||||
hi := max(max(cast(s64) r, cast(s64) g), cast(s64) b);
|
||||
lo := min(min(cast(s64) r, cast(s64) g), cast(s64) b);
|
||||
hi := max(max(cast(i64) r, cast(i64) g), cast(i64) b);
|
||||
lo := min(min(cast(i64) r, cast(i64) g), cast(i64) b);
|
||||
hi - lo <= GRAY_TOL
|
||||
}
|
||||
|
||||
// Mark pixel `i` as removed background and queue it, if it is unvisited checker
|
||||
// (near-neutral gray no brighter than the light checker shade + margin).
|
||||
fd_seed :: (i: s64, bg: [*]u8, lum: [*]s64, src: [*]u8, stack: [*]s64, sp: *s64, lim: s64) {
|
||||
fd_seed :: (i: i64, bg: [*]u8, lum: [*]i64, src: [*]u8, stack: [*]i64, sp: *i64, lim: i64) {
|
||||
if bg[i] != 0 { return; }
|
||||
p := i * 4;
|
||||
if lum[i] <= lim and is_gray(src[p], src[p+1], src[p+2]) {
|
||||
@@ -50,35 +50,35 @@ fd_seed :: (i: s64, bg: [*]u8, lum: [*]s64, src: [*]u8, stack: [*]s64, sp: *s64,
|
||||
}
|
||||
}
|
||||
|
||||
main :: () -> s32 {
|
||||
w : s32 = 0;
|
||||
h : s32 = 0;
|
||||
ch : s32 = 0;
|
||||
main :: () -> i32 {
|
||||
w : i32 = 0;
|
||||
h : i32 = 0;
|
||||
ch : i32 = 0;
|
||||
src : [*]u8 = xx stbi_load(SRC_PATH, @w, @h, @ch, 4);
|
||||
if xx src == 0 {
|
||||
print("FATAL: could not load {}\n", SRC_PATH);
|
||||
return 1;
|
||||
}
|
||||
W := cast(s64) w;
|
||||
H := cast(s64) h;
|
||||
W := cast(i64) w;
|
||||
H := cast(i64) h;
|
||||
N := W * H;
|
||||
print("loaded {}x{} ({} src channels)\n", w, h, ch);
|
||||
|
||||
// Hoisted working locals (see codegen note above).
|
||||
y : s64 = 0;
|
||||
x : s64 = 0;
|
||||
i : s64 = 0;
|
||||
p : s64 = 0;
|
||||
r : s64 = 0;
|
||||
g : s64 = 0;
|
||||
b : s64 = 0;
|
||||
l : s64 = 0;
|
||||
y : i64 = 0;
|
||||
x : i64 = 0;
|
||||
i : i64 = 0;
|
||||
p : i64 = 0;
|
||||
r : i64 = 0;
|
||||
g : i64 = 0;
|
||||
b : i64 = 0;
|
||||
l : i64 = 0;
|
||||
|
||||
// Per-pixel luminance, plus the checker shades read off the border ring
|
||||
// (the border is pure checker — the glow never reaches the corners).
|
||||
lum : [*]s64 = xx context.allocator.alloc_bytes(N * size_of(s64));
|
||||
c_lo : s64 = 255;
|
||||
c_hi : s64 = 0;
|
||||
lum : [*]i64 = xx context.allocator.alloc_bytes(N * size_of(i64));
|
||||
c_lo : i64 = 255;
|
||||
c_hi : i64 = 0;
|
||||
y = 0;
|
||||
while y < H {
|
||||
x = 0;
|
||||
@@ -104,8 +104,8 @@ main :: () -> s32 {
|
||||
// border pixel. `bg[i]==1` marks a removed (transparent) background pixel.
|
||||
bg : [*]u8 = xx context.allocator.alloc_bytes(N);
|
||||
memset(xx bg, 0, N);
|
||||
stack : [*]s64 = xx context.allocator.alloc_bytes(N * size_of(s64));
|
||||
sp : s64 = 0;
|
||||
stack : [*]i64 = xx context.allocator.alloc_bytes(N * size_of(i64));
|
||||
sp : i64 = 0;
|
||||
checker_lim := c_hi + LUM_MARGIN;
|
||||
|
||||
x = 0;
|
||||
@@ -121,12 +121,12 @@ main :: () -> s32 {
|
||||
y += 1;
|
||||
}
|
||||
|
||||
cx : s64 = 0;
|
||||
cy : s64 = 0;
|
||||
dx : s64 = 0;
|
||||
dy : s64 = 0;
|
||||
nx : s64 = 0;
|
||||
ny : s64 = 0;
|
||||
cx : i64 = 0;
|
||||
cy : i64 = 0;
|
||||
dx : i64 = 0;
|
||||
dy : i64 = 0;
|
||||
nx : i64 = 0;
|
||||
ny : i64 = 0;
|
||||
while sp > 0 {
|
||||
sp -= 1;
|
||||
i = stack[sp];
|
||||
@@ -154,8 +154,8 @@ main :: () -> s32 {
|
||||
denom := cast(f32) (255 - c_hi);
|
||||
if denom < 1.0 { denom = 1.0; }
|
||||
alpha : [*]f32 = xx context.allocator.alloc_bytes(N * size_of(f32));
|
||||
kept : s64 = 0;
|
||||
n_bg : s64 = 0;
|
||||
kept : i64 = 0;
|
||||
n_bg : i64 = 0;
|
||||
a : f32 = 0.0;
|
||||
i = 0;
|
||||
while i < N {
|
||||
@@ -178,26 +178,26 @@ main :: () -> s32 {
|
||||
sxf := cast(f32) W / cast(f32) OUT_DIM;
|
||||
syf := cast(f32) H / cast(f32) OUT_DIM;
|
||||
max_a : f32 = 0.0;
|
||||
ty : s64 = 0;
|
||||
tx : s64 = 0;
|
||||
x0 : s64 = 0;
|
||||
x1 : s64 = 0;
|
||||
y0 : s64 = 0;
|
||||
y1 : s64 = 0;
|
||||
ty : i64 = 0;
|
||||
tx : i64 = 0;
|
||||
x0 : i64 = 0;
|
||||
x1 : i64 = 0;
|
||||
y0 : i64 = 0;
|
||||
y1 : i64 = 0;
|
||||
sum : f32 = 0.0;
|
||||
cnt : s64 = 0;
|
||||
sy : s64 = 0;
|
||||
sx : s64 = 0;
|
||||
cnt : i64 = 0;
|
||||
sy : i64 = 0;
|
||||
sx : i64 = 0;
|
||||
av : f32 = 0.0;
|
||||
o : s64 = 0;
|
||||
o : i64 = 0;
|
||||
ty = 0;
|
||||
while ty < OUT_DIM {
|
||||
tx = 0;
|
||||
while tx < OUT_DIM {
|
||||
x0 = cast(s64) (cast(f32) tx * sxf);
|
||||
x1 = cast(s64) (cast(f32) (tx + 1) * sxf);
|
||||
y0 = cast(s64) (cast(f32) ty * syf);
|
||||
y1 = cast(s64) (cast(f32) (ty + 1) * syf);
|
||||
x0 = cast(i64) (cast(f32) tx * sxf);
|
||||
x1 = cast(i64) (cast(f32) (tx + 1) * sxf);
|
||||
y0 = cast(i64) (cast(f32) ty * syf);
|
||||
y1 = cast(i64) (cast(f32) (ty + 1) * syf);
|
||||
if x1 <= x0 { x1 = x0 + 1; }
|
||||
if y1 <= y0 { y1 = y0 + 1; }
|
||||
sum = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user