mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
Support native runtime values used by OpenTUI
- Add shared ArrayBuffer storage and native Unicode grapheme segmentation. - Preserve builtin modules, globals, and byte views across JavaScript bindings. - Compile package initialization expressions and optional native callables.
This commit is contained in:
@@ -1,14 +1,6 @@
|
||||
// The DataView fences: `.buffer` escaping the one composed position that
|
||||
// consumes it and a constructor
|
||||
// over something that isn't a typed array's `.buffer`.
|
||||
|
||||
const buf = new Uint8Array(8);
|
||||
const view = new DataView(buf.buffer);
|
||||
|
||||
// '.buffer' only compiles inside new DataView(x.buffer, ...).
|
||||
const escaped = buf.buffer;
|
||||
|
||||
// The constructor wants a typed array's own '.buffer'.
|
||||
const ab = new ArrayBuffer(8);
|
||||
const direct = new DataView(ab);
|
||||
void view;
|
||||
// Stored ArrayBuffers and DataViews lower; Float16 accessors remain unsupported.
|
||||
const buffer = new ArrayBuffer(16);
|
||||
const view = new DataView(buffer);
|
||||
view.setFloat16(0, 1.5);
|
||||
console.log(view.getFloat16(0));
|
||||
// End of the diagnostic fixture.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
const n: number = 3;
|
||||
const t = n > 0 ? "pos" : "neg";
|
||||
const o = { ...{ a: 1 } };
|
||||
const b = "a" in { a: 1 };
|
||||
const m = typeof "ab".indexOf("b"); // a CALL operand — pure computations fold now
|
||||
const u = n === 3 ? 1 : 2;
|
||||
const s: string = "abc";
|
||||
const mixed = n === 3 && s;
|
||||
console.log(t, m, u, b, mixed);
|
||||
@@ -0,0 +1,5 @@
|
||||
// The native implementation covers default Unicode grapheme segmentation.
|
||||
new Intl.Segmenter("en-US");
|
||||
new Intl.Segmenter(undefined, { granularity: "word" });
|
||||
new Intl.Segmenter(undefined, { granularity: "sentence" });
|
||||
// End of the diagnostic fixture.
|
||||
Reference in New Issue
Block a user