mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-20 05:40:17 +08:00
Represent ordinary JavaScript arrays with hole, value, and explicit-undefined states; add sparse side storage and carry missing values through the frontend, native backends, runtime, and Node-facing consumers.
20 lines
621 B
TypeScript
20 lines
621 B
TypeScript
/* Ask 4's inbound declared-integer edge: `take`'s parameter is
|
||
* profile-declared i64 (takeU's u64), so the generated wrapper
|
||
* range-checks every HOST call — a value past ±(2^53 − 1) cannot ride
|
||
* f64 exactly, and silent rounding is a coercion the author never wrote,
|
||
* so the wrapper delivers the SC4012 host-contract trap instead.
|
||
* In-range values convert exactly. */
|
||
let seen: number[] = [];
|
||
|
||
export function take(x: number): void {
|
||
seen.push(x);
|
||
}
|
||
|
||
export function takeU(x: number): void {
|
||
seen.push(x);
|
||
}
|
||
|
||
export function last(): number {
|
||
return seen.length === 0 ? -1 : seen[seen.length - 1]!;
|
||
}
|