Files
scriptc/tests/corpus/js-class-fluent-overrides.js
Chris Tate 05021faf2f Support three.js meshes and materials in static builds
- Compile mesh construction, transforms, cloning, and material updates for native and WASI targets.
- Preserve subclass dispatch, fluent returns, and shared array identity in JavaScript packages.
- Support native class arrays and recursive conversions without materializing classes for type checks.
2026-09-29 23:34:18 -05:00

29 lines
1015 B
JavaScript

class Base {
constructor() { this.value = 1; }
copy(source) { this.value = source.value; return this; }
dispatch(source) { return this.copy(source); }
}
class Child extends Base {
constructor() { super(); this.extra = 2; }
copy(source) { super.copy(source); this.extra = source.extra; return this; }
childOnly() { return this.extra; }
}
class Leaf extends Child {
constructor() { super(); this.leaf = 3; }
copy(source) {
super.copy(source);
if (source.leaf === 0) return (this);
this.leaf = source.leaf;
return this;
}
}
const source = new Leaf();
source.value = 4; source.extra = 5; source.leaf = 6;
const target = new Leaf();
console.log('direct', target.copy(source) === target, target.value, target.extra, target.leaf);
console.log('chain', target.copy(source).childOnly(), target.copy(source).leaf);
source.extra = 8;
console.log('virtual', target.dispatch(source) === target, target.extra);
source.leaf = 0;
console.log('early', target.copy(source) === target, target.leaf);