@scriptc/compiler 0.0.8 → 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 (66) 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 +108 -5
  5. package/dist/backend/emission/emit-exprs.js.map +1 -1
  6. package/dist/backend/emission/emit-types.d.ts +3 -0
  7. package/dist/backend/emission/emit-types.js +12 -0
  8. package/dist/backend/emission/emit-types.js.map +1 -1
  9. package/dist/backend/emission/emit-walkers.d.ts +7 -5
  10. package/dist/backend/emission/emit-walkers.js +23 -10
  11. package/dist/backend/emission/emit-walkers.js.map +1 -1
  12. package/dist/backend/emission/emitter.d.ts +1 -1
  13. package/dist/backend/emission/emitter.js +30 -9
  14. package/dist/backend/emission/emitter.js.map +1 -1
  15. package/dist/backend/llvm/emitter.js +206 -11
  16. package/dist/backend/llvm/emitter.js.map +1 -1
  17. package/dist/diagnostics/diagnostic.d.ts +55 -10
  18. package/dist/diagnostics/diagnostic.js +82 -20
  19. package/dist/diagnostics/diagnostic.js.map +1 -1
  20. package/dist/frontend/lowering/lower-assert.js +16 -0
  21. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  22. package/dist/frontend/lowering/lower-builtins.d.ts +11 -0
  23. package/dist/frontend/lowering/lower-builtins.js +111 -3
  24. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  25. package/dist/frontend/lowering/lower-calls.d.ts +30 -11
  26. package/dist/frontend/lowering/lower-calls.js +418 -8
  27. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  28. package/dist/frontend/lowering/lower-classes.js +27 -1
  29. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  30. package/dist/frontend/lowering/lower-containers.d.ts +4 -2
  31. package/dist/frontend/lowering/lower-containers.js +193 -43
  32. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  33. package/dist/frontend/lowering/lower-emitter.js +54 -0
  34. package/dist/frontend/lowering/lower-emitter.js.map +1 -1
  35. package/dist/frontend/lowering/lower-exprs.js +52 -7
  36. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  37. package/dist/frontend/lowering/lower-stmts.js +445 -13
  38. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  39. package/dist/frontend/lowering/lower-stream.js +28 -2
  40. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  41. package/dist/frontend/lowering/lowerer.d.ts +66 -14
  42. package/dist/frontend/lowering/lowerer.js +273 -28
  43. package/dist/frontend/lowering/lowerer.js.map +1 -1
  44. package/dist/frontend/lowering/surfaces.js +20 -3
  45. package/dist/frontend/lowering/surfaces.js.map +1 -1
  46. package/dist/frontend/npm-static-rewrite.d.ts +7 -2
  47. package/dist/frontend/npm-static-rewrite.js +566 -138
  48. package/dist/frontend/npm-static-rewrite.js.map +1 -1
  49. package/dist/frontend/npm-static.js +11 -2
  50. package/dist/frontend/npm-static.js.map +1 -1
  51. package/dist/frontend/program.js +5 -5
  52. package/dist/frontend/program.js.map +1 -1
  53. package/dist/frontend/shared.d.ts +6 -1
  54. package/dist/frontend/shared.js +46 -1
  55. package/dist/frontend/shared.js.map +1 -1
  56. package/dist/frontend/types.js +4 -2
  57. package/dist/frontend/types.js.map +1 -1
  58. package/dist/index.js +150 -25
  59. package/dist/index.js.map +1 -1
  60. package/dist/ir/nodes.d.ts +131 -7
  61. package/dist/ir/nodes.js +41 -3
  62. package/dist/ir/nodes.js.map +1 -1
  63. package/dist/ir/validate.js +58 -8
  64. package/dist/ir/validate.js.map +1 -1
  65. package/package.json +2 -2
  66. package/surface-manifest.json +10 -3
@@ -4,12 +4,13 @@
4
4
  * accessor access, upcasts, `new` expressions, and the builtin Error
5
5
  * hierarchy registration. */
6
6
  import * as ts from "../ts7/adapter.js";
7
- import { BOOL, DYN, F64, JSVAL, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, UNDEFINED_T, URL_T, VOID, arrayOf, isSupportedMapKey, isUnitType, typeEquals } from "../../ir/nodes.js";
7
+ import { BOOL, DYN, F64, bytesOf, JSVAL, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, UNDEFINED_T, URL_T, VOID, arrayOf, isSupportedMapKey, isUnitType, typeEquals } from "../../ir/nodes.js";
8
8
  import { MAX_GENERIC_INSTANCES, genericCallInstance, implicitAnyParamSymbolsOf, implicitCallInstance, implicitMonoFile, omittedArgFor } from "./lower-calls.js";
9
9
  import { isGenericCallableMemberType, typeKey } from "../types.js";
10
10
  import { cjsClassExprWholeExportOf, isCjsJsFile, isJsSourceFile, isModuleExportsAccess, isNodeTypesPath, locOf } from "../program.js";
11
11
  import { PoisonError, dynFallbackType, dynUndefinedExpr, newFnCtx, own } from "./lowerer.js";
12
12
  import { bufEncoding, lowerMapSeedArrayNew } from "./lower-containers.js";
13
+ import { pureReemittable } from "./lower-exprs.js";
13
14
  import { lowerSearchParamsNew } from "./lower-builtins.js";
14
15
  import { requiresDynamicPackageDiag, unsupportedDiag } from "../../diagnostics/diagnostic.js";
15
16
  import { STREAM_API_MEMBERS, STREAM_PROP_MEMBERS, UNDERSCORE_METHODS, lowerStreamNew, lowerStreamSuperCall, streamCtorShape } from "./lower-stream.js";
@@ -4757,6 +4758,30 @@ export function lowerNew(L, expr) {
4757
4758
  // families carry pointed hints: each states WHY no honest static
4758
4759
  // lowering exists (or what to use instead).
4759
4760
  if (L.isStdlibSymbol(symbol ?? undefined)) {
4761
+ // The deprecated `new Buffer(string, encoding?)` ctor's string arm
4762
+ // with a NON-STRING first argument and a string second: Node
4763
+ // throws ERR_INVALID_ARG_TYPE synchronously (and DEP0005 never
4764
+ // fires on this throwing path, so the compiled silence matches).
4765
+ // Every other new Buffer form keeps the fence below — the
4766
+ // constructing forms would owe the deprecation warning.
4767
+ if (expr.expression.text === "Buffer" &&
4768
+ expr.arguments?.length === 2 &&
4769
+ !expr.arguments.some(ts.isSpreadElement) &&
4770
+ L.mapTypeOf(L.typeOf(expr.arguments[0]))?.kind !== "string" &&
4771
+ L.mapTypeOf(L.typeOf(expr.arguments[1]))?.kind === "string") {
4772
+ const first = L.lowerExpr(expr.arguments[0]);
4773
+ if (first.kind === "unitLit" || first.type.kind === "dyn" || L.dynConvertible(first.type)) {
4774
+ const got = first.type.kind === "dyn" ? first : { kind: "dynFrom", value: first, type: DYN, loc };
4775
+ // The encoding argument still evaluates in Node before the
4776
+ // throw only via the ctor body's later reads — it does NOT
4777
+ // observe it before throwing, so dropping it is exact for
4778
+ // effect-free operands; effectful ones keep the fence.
4779
+ const enc = L.lowerExpr(expr.arguments[1]);
4780
+ if (enc.kind === "strLit" || pureReemittable(enc)) {
4781
+ return { kind: "libCall", fn: "buffer.newStringFail", args: [got], type: bytesOf("u8"), loc };
4782
+ }
4783
+ }
4784
+ }
4760
4785
  const ctorHints = {
4761
4786
  RegExp: "use a regex literal (/pattern/flags) — constructed regexes have no lowering",
4762
4787
  String: "boxed wrapper objects have no lowering — use the string primitive (the box is only distinguishable via typeof/identity, which nothing here can honor)",
@@ -4767,6 +4792,7 @@ export function lowerNew(L, expr) {
4767
4792
  WeakRef: "deref()-after-collect exposes GC timing — genuinely dynamic; hold a strong reference instead",
4768
4793
  FinalizationRegistry: "finalization callbacks expose GC timing — genuinely dynamic; release resources explicitly instead",
4769
4794
  SharedArrayBuffer: "no shared-memory threads exist in a compiled program — Uint8Array is the byte storage",
4795
+ ArrayBuffer: "no free-standing ArrayBuffer value exists — typed arrays own their storage: allocate the view directly (new Uint8Array(n)), or erase a fresh buffer into one (new Uint8Array(new ArrayBuffer(n)), new DataView(new ArrayBuffer(n), ...))",
4770
4796
  Proxy: "property-access metaprogramming has no static lowering (every property read must resolve at compile time)",
4771
4797
  Function: "runtime code generation cannot be compiled ahead of time (the eval stance) — write the function",
4772
4798
  };