mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
* feat: support static buffer constructors and prototype methods - Preserve typed-array constructor identity and shared storage across JavaScript class APIs. - Support chained indexed assignments and mutable prototype methods with native receiver dispatch. - Compile Three.js geometry merging, instancing, and keyframe interpolation without a JavaScript engine. * fix: preserve native collection and dispatch semantics - Preserve typed-array identity in collections and JavaScript argument evaluation. - Keep symbol-backed fields and unreachable methods on their existing static paths. - Restore compiler bootstrapping and deferred class diagnostics. * fix: preserve inferred returns in native compilation - Update recorded return statements in place so native compilation preserves mixed JavaScript return values. * test: update inferred array coverage expectations - Recognize heterogeneous writes supported by shared JavaScript array storage.
19 lines
945 B
TypeScript
19 lines
945 B
TypeScript
const bytes = new Uint8Array(4);
|
|
const numbers = [0, 0, 0, 0];
|
|
let trace = "";
|
|
function target(): Uint8Array { trace += "receiver "; return bytes; }
|
|
function index(n: number): number { trace += "index" + n + " "; return n; }
|
|
function value(): number { trace += "value "; return 257.5; }
|
|
console.log(target()[index(0)] = target()[index(1)] = value());
|
|
console.log(bytes[0], bytes[1], trace);
|
|
console.log(numbers[0] = numbers[1] = 9, numbers.join(","));
|
|
console.log(bytes[99] = -7.5, bytes.length);
|
|
console.log(bytes[-1] = 12.5, bytes[0.5] = 12.5, bytes[NaN] = 12.5, bytes[Infinity] = 12.5, bytes[-Infinity] = 12.5);
|
|
const floats = new Float32Array(1);
|
|
const assigned = floats[0] = 1 / 3;
|
|
console.log(assigned === 1 / 3, floats[0] === Math.fround(1 / 3));
|
|
let current = new Uint8Array(1);
|
|
const original = current;
|
|
function replace(): number { current = new Uint8Array(1); return 6; }
|
|
console.log(current[0] = replace(), original[0], current[0]);
|