@scriptc/compiler 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/emission/emit-exprs.js +2 -0
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/llvm/emitter.js +19 -4
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/coverage/report.d.ts +1 -0
- package/dist/coverage/report.js +12 -0
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.d.ts +22 -0
- package/dist/coverage/surface-manifest.js +295 -0
- package/dist/coverage/surface-manifest.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +16 -0
- package/dist/diagnostics/diagnostic.js +24 -0
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +10 -5
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +3 -0
- package/dist/frontend/lowering/lower-containers.js +64 -0
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +14 -2
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +8 -3
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +3 -3
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +2 -2
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.js +4 -3
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/program.js +104 -21
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/shared.d.ts +7 -0
- package/dist/frontend/shared.js +9 -0
- package/dist/frontend/shared.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +1 -1
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +1 -0
- package/dist/ir/validate.js.map +1 -1
- package/package.json +6 -4
- package/surface-manifest.json +2052 -0
|
@@ -133,6 +133,9 @@ export declare function lowerArrayAtCall(L: Lowerer, call: ts.CallExpression, ac
|
|
|
133
133
|
* no mapper) keeps the fence. Null when the callee isn't an
|
|
134
134
|
* Array-static access. */
|
|
135
135
|
export declare function lowerArrayFromCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
136
|
+
/** `Array.from(s)` / `[...s]` on a STRING: the code-point split into a
|
|
137
|
+
* fresh string[], through one interned helper per module. */
|
|
138
|
+
export declare function strCharsCall(L: Lowerer, src: IrExpr, loc: SrcLoc): IrExpr;
|
|
136
139
|
/** Ambient Map method calls. `get`/`set`/`has`/`delete`/`clear` lower to
|
|
137
140
|
* mapIntrinsic; `forEach` desugars to a direct call of a synthetic loop
|
|
138
141
|
* function over the iteration primitives (lowerMapForEachCall). Null when
|
|
@@ -1675,6 +1675,17 @@ export function lowerArrayFromCall(L, call, access) {
|
|
|
1675
1675
|
return { kind: "arrayNewLen", length: n, type: arrT, loc };
|
|
1676
1676
|
}
|
|
1677
1677
|
}
|
|
1678
|
+
// `Array.from(s)` on a STRING: the string iterator's code-point walk
|
|
1679
|
+
// into a fresh string[] (astral characters stay whole, where a
|
|
1680
|
+
// charAt/index walk would truncate the surrogate halves) — the same
|
|
1681
|
+
// interned helper `[...s]` lowers through.
|
|
1682
|
+
if (args.length === 1 && !ts.isObjectLiteralExpression(args[0])) {
|
|
1683
|
+
const src = L.lowerExpr(args[0]);
|
|
1684
|
+
if (src.type.kind === "string")
|
|
1685
|
+
return strCharsCall(L, src, loc);
|
|
1686
|
+
L.noLowering("Array.from with this argument shape", call, "Array.from({ length: n }, (v, i) => ...) and Array.from(aString) are the lowered " +
|
|
1687
|
+
"forms — copy arrays with [...a] and drain Map/Set iterators where they are made");
|
|
1688
|
+
}
|
|
1678
1689
|
const n = args.length === 2 && ts.isObjectLiteralExpression(args[0]) && args[0].properties.length === 1
|
|
1679
1690
|
? lowerLengthProp(L, args[0].properties[0])
|
|
1680
1691
|
: null;
|
|
@@ -1708,6 +1719,59 @@ export function lowerArrayFromCall(L, call, access) {
|
|
|
1708
1719
|
}
|
|
1709
1720
|
return { kind: "call", callee: helper, args: [n, fnArg], type: arrayOf(fnRet), loc };
|
|
1710
1721
|
}
|
|
1722
|
+
/** `Array.from(s)` / `[...s]` on a STRING: the code-point split into a
|
|
1723
|
+
* fresh string[], through one interned helper per module. */
|
|
1724
|
+
export function strCharsCall(L, src, loc) {
|
|
1725
|
+
const key = "strChars";
|
|
1726
|
+
let helper = L.arrHofHelpers.get(key);
|
|
1727
|
+
if (!helper) {
|
|
1728
|
+
helper = "%str.chars";
|
|
1729
|
+
L.arrHofHelpers.set(key, helper);
|
|
1730
|
+
L.liftedFns.push(buildStrCharsFn(helper, loc));
|
|
1731
|
+
}
|
|
1732
|
+
return { kind: "call", callee: helper, args: [src], type: arrayOf(STRING), loc };
|
|
1733
|
+
}
|
|
1734
|
+
/** The code-point split, from existing IR nodes — the string for-of
|
|
1735
|
+
* desugar's UTF-16 cursor as a function:
|
|
1736
|
+
*
|
|
1737
|
+
* out = [];
|
|
1738
|
+
* i = 0;
|
|
1739
|
+
* while (i < s.length) { ch = cpAt(s, i); i += ch.length; out.push(ch); }
|
|
1740
|
+
* return out;
|
|
1741
|
+
*/
|
|
1742
|
+
function buildStrCharsFn(name, loc) {
|
|
1743
|
+
const outT = arrayOf(STRING);
|
|
1744
|
+
const ref = (localId, type) => ({ kind: "varRef", localId, type, loc });
|
|
1745
|
+
const sLen = (recv) => ({ kind: "strIntrinsic", method: "length", receiver: recv, args: [], type: F64, loc });
|
|
1746
|
+
const body = [
|
|
1747
|
+
{ kind: "varDecl", localId: "out.0", init: { kind: "arrayLit", elems: [], type: outT, loc }, loc },
|
|
1748
|
+
{ kind: "varDecl", localId: "i.0", init: { kind: "numLit", value: 0, type: F64, loc }, loc },
|
|
1749
|
+
{
|
|
1750
|
+
kind: "while",
|
|
1751
|
+
cond: { kind: "bin", op: "<", left: ref("i.0", F64), right: sLen(ref("s.0", STRING)), type: BOOL, loc },
|
|
1752
|
+
body: [
|
|
1753
|
+
{ kind: "varDecl", localId: "ch.0", init: { kind: "strIntrinsic", method: "cpAt", receiver: ref("s.0", STRING), args: [ref("i.0", F64)], type: STRING, loc }, loc },
|
|
1754
|
+
{ kind: "assign", localId: "i.0", value: { kind: "bin", op: "+", left: ref("i.0", F64), right: sLen(ref("ch.0", STRING)), type: F64, loc }, loc },
|
|
1755
|
+
{ kind: "exprStmt", expr: { kind: "arrIntrinsic", method: "push", receiver: ref("out.0", outT), args: [ref("ch.0", STRING)], type: F64, loc }, loc },
|
|
1756
|
+
],
|
|
1757
|
+
loc,
|
|
1758
|
+
},
|
|
1759
|
+
{ kind: "return", value: ref("out.0", outT), loc },
|
|
1760
|
+
];
|
|
1761
|
+
return {
|
|
1762
|
+
name,
|
|
1763
|
+
params: [{ localId: "s.0", name: "s", type: STRING }],
|
|
1764
|
+
returnType: outT,
|
|
1765
|
+
locals: [
|
|
1766
|
+
{ id: "s.0", name: "s", type: STRING, mutable: true },
|
|
1767
|
+
{ id: "out.0", name: "out", type: outT, mutable: false },
|
|
1768
|
+
{ id: "i.0", name: "i", type: F64, mutable: true },
|
|
1769
|
+
{ id: "ch.0", name: "ch", type: STRING, mutable: false },
|
|
1770
|
+
],
|
|
1771
|
+
body,
|
|
1772
|
+
loc,
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1711
1775
|
/** The lowered `length` value of the one-property source literal, or null
|
|
1712
1776
|
* (shorthand `{ length }` counts — resolved through the shorthand VALUE
|
|
1713
1777
|
* symbol like any object literal; spreads/accessors/computed names do
|