mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +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.
20 lines
697 B
JavaScript
20 lines
697 B
JavaScript
class Table {
|
|
constructor() { this.initialize(); }
|
|
initialize() { this.entries = {}; }
|
|
write(key, value) { this.entries[key] = value; }
|
|
read(key) { return this.entries[key]; }
|
|
install() { this.compute = function(value) { return this.read('factor') * value; }; }
|
|
}
|
|
const table = new Table();
|
|
table.write('factor', 3);
|
|
table.install();
|
|
console.log(table.compute(4));
|
|
const key = Math.random() < 2 ? 'factor' : 3;
|
|
console.log(table.read(key));
|
|
table.write(3, 7);
|
|
console.log(table.read(3));
|
|
class First { result(value) { return value + 1; } }
|
|
class Second { result(value) { return value * 2; } }
|
|
const chosen = Math.random() < 2 ? new First() : new Second();
|
|
console.log(chosen.result(3));
|