@scriptc/compiler 0.0.7 → 0.0.9

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.
Files changed (94) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +13 -0
  2. package/dist/backend/cc.js +14 -0
  3. package/dist/backend/cc.js.map +1 -1
  4. package/dist/backend/emission/emit-exprs.js +155 -6
  5. package/dist/backend/emission/emit-exprs.js.map +1 -1
  6. package/dist/backend/emission/emit-island.js +9 -1
  7. package/dist/backend/emission/emit-island.js.map +1 -1
  8. package/dist/backend/emission/emit-stmts.js +3 -1
  9. package/dist/backend/emission/emit-stmts.js.map +1 -1
  10. package/dist/backend/emission/emit-types.d.ts +3 -0
  11. package/dist/backend/emission/emit-types.js +12 -0
  12. package/dist/backend/emission/emit-types.js.map +1 -1
  13. package/dist/backend/emission/emit-walkers.d.ts +7 -5
  14. package/dist/backend/emission/emit-walkers.js +45 -18
  15. package/dist/backend/emission/emit-walkers.js.map +1 -1
  16. package/dist/backend/emission/emitter.d.ts +1 -1
  17. package/dist/backend/emission/emitter.js +35 -10
  18. package/dist/backend/emission/emitter.js.map +1 -1
  19. package/dist/backend/emission/may-throw.js +4 -3
  20. package/dist/backend/emission/may-throw.js.map +1 -1
  21. package/dist/backend/llvm/emitter.js +300 -18
  22. package/dist/backend/llvm/emitter.js.map +1 -1
  23. package/dist/diagnostics/diagnostic.d.ts +98 -11
  24. package/dist/diagnostics/diagnostic.js +185 -25
  25. package/dist/diagnostics/diagnostic.js.map +1 -1
  26. package/dist/frontend/lib-contract.d.ts +24 -6
  27. package/dist/frontend/lib-contract.js +125 -44
  28. package/dist/frontend/lib-contract.js.map +1 -1
  29. package/dist/frontend/lowering/lower-assert.js +16 -0
  30. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  31. package/dist/frontend/lowering/lower-builtins.d.ts +11 -0
  32. package/dist/frontend/lowering/lower-builtins.js +127 -4
  33. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  34. package/dist/frontend/lowering/lower-calls.d.ts +77 -18
  35. package/dist/frontend/lowering/lower-calls.js +978 -44
  36. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  37. package/dist/frontend/lowering/lower-classes.d.ts +14 -1
  38. package/dist/frontend/lowering/lower-classes.js +112 -16
  39. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  40. package/dist/frontend/lowering/lower-containers.d.ts +4 -2
  41. package/dist/frontend/lowering/lower-containers.js +236 -44
  42. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  43. package/dist/frontend/lowering/lower-emitter.js +55 -1
  44. package/dist/frontend/lowering/lower-emitter.js.map +1 -1
  45. package/dist/frontend/lowering/lower-exprs.d.ts +26 -3
  46. package/dist/frontend/lowering/lower-exprs.js +507 -47
  47. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  48. package/dist/frontend/lowering/lower-island.d.ts +7 -0
  49. package/dist/frontend/lowering/lower-island.js +71 -10
  50. package/dist/frontend/lowering/lower-island.js.map +1 -1
  51. package/dist/frontend/lowering/lower-mixins.d.ts +1 -1
  52. package/dist/frontend/lowering/lower-mixins.js +1 -1
  53. package/dist/frontend/lowering/lower-modules.js +95 -4
  54. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  55. package/dist/frontend/lowering/lower-stmts.js +866 -56
  56. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  57. package/dist/frontend/lowering/lower-stream.js +28 -2
  58. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  59. package/dist/frontend/lowering/lowerer.d.ts +85 -17
  60. package/dist/frontend/lowering/lowerer.js +459 -37
  61. package/dist/frontend/lowering/lowerer.js.map +1 -1
  62. package/dist/frontend/lowering/surfaces.js +20 -3
  63. package/dist/frontend/lowering/surfaces.js.map +1 -1
  64. package/dist/frontend/npm-static-rewrite.d.ts +7 -2
  65. package/dist/frontend/npm-static-rewrite.js +566 -138
  66. package/dist/frontend/npm-static-rewrite.js.map +1 -1
  67. package/dist/frontend/npm-static.js +11 -2
  68. package/dist/frontend/npm-static.js.map +1 -1
  69. package/dist/frontend/program.js +5 -5
  70. package/dist/frontend/program.js.map +1 -1
  71. package/dist/frontend/shared.d.ts +6 -1
  72. package/dist/frontend/shared.js +46 -1
  73. package/dist/frontend/shared.js.map +1 -1
  74. package/dist/frontend/types.d.ts +28 -1
  75. package/dist/frontend/types.js +304 -10
  76. package/dist/frontend/types.js.map +1 -1
  77. package/dist/index.d.ts +2 -1
  78. package/dist/index.js +181 -26
  79. package/dist/index.js.map +1 -1
  80. package/dist/ir/nodes.d.ts +159 -9
  81. package/dist/ir/nodes.js +76 -6
  82. package/dist/ir/nodes.js.map +1 -1
  83. package/dist/ir/validate.js +93 -14
  84. package/dist/ir/validate.js.map +1 -1
  85. package/dist/library/profile.d.ts +17 -3
  86. package/dist/library/profile.js +38 -9
  87. package/dist/library/profile.js.map +1 -1
  88. package/dist/library/sidecar.js +162 -43
  89. package/dist/library/sidecar.js.map +1 -1
  90. package/dist/library/trap-teaching.d.ts +11 -0
  91. package/dist/library/trap-teaching.js +49 -0
  92. package/dist/library/trap-teaching.js.map +1 -0
  93. package/package.json +2 -2
  94. package/surface-manifest.json +46 -4
@@ -0,0 +1,49 @@
1
+ /* The structured trap-teaching encoding (ratified 2026-07-23). A library-mode
2
+ * sink message that carries a diagnostic code and/or the trapping symbol is
3
+ * assembled as
4
+ *
5
+ * 0x01 text 0x1F code 0x1F symbol [ 0x1F remediation ]
6
+ *
7
+ * The human teaching text LEADS the buffer so a plain-text host still shows
8
+ * something useful; 0x01 (ASCII SOH) is the version marker — every baseline
9
+ * (unstructured) message is UTF-8 whose first byte is printable, and no
10
+ * emitter path may ever produce an unstructured message whose first byte is
11
+ * below 0x20, so `msg_len > 0 && msg[0] == 0x01` identifies a structured
12
+ * message unambiguously. Fields ride 0x1F (ASCII Unit Separator); the whole
13
+ * remediation field, separator included, is absent when the profile supplies
14
+ * none. Emitters MUST NOT append fields beyond these four under this marker;
15
+ * parsers MUST ignore any field past the fourth.
16
+ *
17
+ * Division of labor (the spec's compatibility clause): the profile authors
18
+ * teaching and remediation text, the COMPILER assembles the buffer here
19
+ * (code, symbol, framing), and the runtime funnel and the host sink carry
20
+ * the bytes opaque and unchanged — the sink signature (ctx, msg pointer,
21
+ * len, address) is frozen; all structure lives in the message bytes.
22
+ *
23
+ * Code space: SC-prefixed codes belong exclusively to the compiler's
24
+ * diagnostics registry; embedder-supplied codes are embedder-prefixed and
25
+ * validated only as tokens free of the reserved bytes (profile.ts), never
26
+ * for registry membership. */
27
+ /** The structured-message version marker (byte 0). A future encoding
28
+ * revision bumps the marker byte — the marker IS the version. */
29
+ export const TRAP_TEACHING_MARKER = "\u0001";
30
+ /** The field separator between text, code, symbol, and remediation. */
31
+ export const TRAP_TEACHING_SEP = "\u001f";
32
+ /** Assemble one structured trap-teaching message. Every field must already
33
+ * be free of the two reserved bytes — profile-supplied text is validated at
34
+ * profile load (SC4001), and the compiler's own texts, codes, and symbols
35
+ * never contain control bytes — so a violation here is an internal error,
36
+ * never a user-reportable state. */
37
+ export function assembleTrapTeaching(text, code, symbol, remediation) {
38
+ const fields = [["text", text], ["code", code], ["symbol", symbol]];
39
+ if (remediation !== undefined)
40
+ fields.push(["remediation", remediation]);
41
+ for (const [name, value] of fields) {
42
+ if (value.includes(TRAP_TEACHING_MARKER) || value.includes(TRAP_TEACHING_SEP)) {
43
+ throw new Error(`trap-teaching assembler: ${name} contains a reserved byte (0x01/0x1F)`);
44
+ }
45
+ }
46
+ return (TRAP_TEACHING_MARKER + text + TRAP_TEACHING_SEP + code + TRAP_TEACHING_SEP + symbol +
47
+ (remediation !== undefined ? TRAP_TEACHING_SEP + remediation : ""));
48
+ }
49
+ //# sourceMappingURL=trap-teaching.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trap-teaching.js","sourceRoot":"","sources":["../../src/library/trap-teaching.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;8BAyB8B;AAE9B;iEACiE;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAC7C,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAE1C;;;;oCAIoC;AACpC,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,IAAY,EACZ,MAAc,EACd,WAAoB;IAEpB,MAAM,MAAM,GAAuB,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACxF,IAAI,WAAW,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;IACzE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;QACnC,IAAI,KAAK,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,uCAAuC,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;IACD,OAAO,CACL,oBAAoB,GAAG,IAAI,GAAG,iBAAiB,GAAG,IAAI,GAAG,iBAAiB,GAAG,MAAM;QACnF,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CACnE,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scriptc/compiler",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "The scriptc compiler — TypeScript/JavaScript frontend, typed IR, LLVM and C backends",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://scriptc.dev",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "typescript": "7.0.2",
32
32
  "typescript5": "npm:typescript@5.9.3",
33
- "@scriptc/runtime": "0.0.7"
33
+ "@scriptc/runtime": "0.0.9"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "node node_modules/typescript5/bin/tsc -p tsconfig.json"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "compilerVersion": "0.0.7",
3
+ "compilerVersion": "0.0.9",
4
4
  "coverage": [
5
5
  "Entries are projected mechanically from the compiler's own decision tables: the diagnostics registry, the unsupported-syntax dispatch tables, the stdlib and node-builtin lowering tables, and the supported-builtin-module list. Nothing is hand-maintained; the manifest regenerates byte-identically from the source tree at this version.",
6
6
  "Absence from this manifest means 'not projected', never 'unsupported'. Surfaces lowered through dedicated code paths rather than tables are not yet projected: console, JSON, process, Promise/async and the timer surface, the net/http/tls/https/dgram/dns/assert/test/stream/readline module member surfaces, template literals, the regex slice, and global functions (parseInt, parseFloat, isNaN, isFinite).",
@@ -17,7 +17,7 @@
17
17
  "name": "package imports",
18
18
  "status": "unsupported",
19
19
  "code": "SC1010",
20
- "note": "relative imports (./file, ../dir/file), package.json-mediated project imports (#alias via the imports field, self-name references via exports), installed npm packages (their code runs under --dynamic), and the built-in fs, fs/promises, path, os, url, crypto, zlib, child_process, net, http, tls, https, http2, dgram, dns, util, util/types, string_decoder, readline, events, stream, buffer, assert, assert/strict, worker_threads, cluster, tty, async_hooks, timers, timers/promises, diagnostics_channel, perf_hooks, and node:test and node:module modules (bare or node:-prefixed) are supported"
20
+ "note": "relative imports (./file, ../dir/file), package.json-mediated project imports (#alias via the imports field, self-name references via exports), installed npm packages (their code runs under --dynamic), and the built-in fs, fs/promises, path, os, url, crypto, zlib, child_process, net, http, tls, https, http2, dgram, dns, util, util/types, string_decoder, querystring, readline, events, stream, stream/promises, buffer, assert, assert/strict, worker_threads, cluster, tty, async_hooks, timers, timers/promises, diagnostics_channel, perf_hooks, and node:test and node:module modules (bare or node:-prefixed) are supported"
21
21
  },
22
22
  {
23
23
  "id": "diagnostic.sc1012",
@@ -201,14 +201,14 @@
201
201
  {
202
202
  "id": "diagnostic.sc2001",
203
203
  "kind": "diagnostic-fence",
204
- "name": "values of types outside the compilable set",
204
+ "name": "values of types outside the compilable set (bigint and symbol primitives, constructor objects, and library-derived or unresolved generic shapes)",
205
205
  "status": "unsupported",
206
206
  "code": "SC2001"
207
207
  },
208
208
  {
209
209
  "id": "diagnostic.sc2002",
210
210
  "kind": "diagnostic-fence",
211
- "name": "record width subtyping (shapes must match exactly)",
211
+ "name": "record shape flows outside the width-copy rules (shapes must match exactly or width-coerce)",
212
212
  "status": "unsupported",
213
213
  "code": "SC2002"
214
214
  },
@@ -226,6 +226,41 @@
226
226
  "status": "unsupported",
227
227
  "code": "SC2004"
228
228
  },
229
+ {
230
+ "id": "diagnostic.sc2005",
231
+ "kind": "diagnostic-fence",
232
+ "name": "values whose type keeps a generic call signature (a compiled function is one concrete signature)",
233
+ "status": "unsupported",
234
+ "code": "SC2005"
235
+ },
236
+ {
237
+ "id": "diagnostic.sc2006",
238
+ "kind": "diagnostic-fence",
239
+ "name": "index-signature object types outside the supported shape",
240
+ "status": "unsupported",
241
+ "code": "SC2006"
242
+ },
243
+ {
244
+ "id": "diagnostic.sc2007",
245
+ "kind": "diagnostic-fence",
246
+ "name": "values of overloaded function type (a compiled function value is one signature)",
247
+ "status": "unsupported",
248
+ "code": "SC2007"
249
+ },
250
+ {
251
+ "id": "diagnostic.sc2008",
252
+ "kind": "diagnostic-fence",
253
+ "name": "intersection types with no resolved lowering",
254
+ "status": "unsupported",
255
+ "code": "SC2008"
256
+ },
257
+ {
258
+ "id": "diagnostic.sc2009",
259
+ "kind": "diagnostic-fence",
260
+ "name": "supported container and function shapes over a component type outside its slot",
261
+ "status": "unsupported",
262
+ "code": "SC2009"
263
+ },
229
264
  {
230
265
  "id": "diagnostic.sc2010",
231
266
  "kind": "diagnostic-fence",
@@ -1176,6 +1211,13 @@
1176
1211
  "status": "static",
1177
1212
  "note": "recognized module (bare and node:-prefixed specifiers)"
1178
1213
  },
1214
+ {
1215
+ "id": "node-builtin.stream.promises",
1216
+ "kind": "node-builtin",
1217
+ "name": "stream/promises",
1218
+ "status": "static",
1219
+ "note": "recognized module (bare and node:-prefixed specifiers)"
1220
+ },
1179
1221
  {
1180
1222
  "id": "node-builtin.string_decoder",
1181
1223
  "kind": "node-builtin",