@scriptc/compiler 0.4.6 → 0.4.7

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 (652) hide show
  1. package/ambient/node-fallback/events.d.ts +6 -1
  2. package/ambient/node-fallback/fs-promises.d.ts +1 -1
  3. package/ambient/node-fallback/fs.d.ts +54 -10
  4. package/ambient/node-fallback/http.d.ts +3 -1
  5. package/ambient/node-fallback/net.d.ts +19 -0
  6. package/ambient/node-fallback/querystring.d.ts +3 -3
  7. package/ambient/scriptc-node-fallback.d.ts +58 -13
  8. package/dist/backend/executable-features.js +13 -0
  9. package/dist/backend/executable-features.js.map +1 -1
  10. package/dist/backend/immutability.d.ts +12 -1
  11. package/dist/backend/immutability.js +50 -4
  12. package/dist/backend/immutability.js.map +1 -1
  13. package/dist/backend/immutability.test.js +95 -1
  14. package/dist/backend/immutability.test.js.map +1 -1
  15. package/dist/backend/library-pack.js +2 -0
  16. package/dist/backend/library-pack.js.map +1 -1
  17. package/dist/backend/linker.d.ts +11 -0
  18. package/dist/backend/linker.js +31 -3
  19. package/dist/backend/linker.js.map +1 -1
  20. package/dist/backend/lld.d.ts +7 -2
  21. package/dist/backend/lld.js +5 -3
  22. package/dist/backend/lld.js.map +1 -1
  23. package/dist/backend/lld.test.js +10 -4
  24. package/dist/backend/lld.test.js.map +1 -1
  25. package/dist/backend/llvm/constant-callbacks.test.js +50 -1
  26. package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
  27. package/dist/backend/llvm/cpu-dispatch.js +6 -5
  28. package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
  29. package/dist/backend/llvm/dyn.d.ts +53 -1
  30. package/dist/backend/llvm/dyn.js +221 -9
  31. package/dist/backend/llvm/dyn.js.map +1 -1
  32. package/dist/backend/llvm/emit-function.js +1 -1
  33. package/dist/backend/llvm/emit-function.js.map +1 -1
  34. package/dist/backend/llvm/emit-module.js +148 -50
  35. package/dist/backend/llvm/emit-module.js.map +1 -1
  36. package/dist/backend/llvm/emit-statements.js +39 -19
  37. package/dist/backend/llvm/emit-statements.js.map +1 -1
  38. package/dist/backend/llvm/emitter.d.ts +29 -2
  39. package/dist/backend/llvm/emitter.js +86 -7
  40. package/dist/backend/llvm/emitter.js.map +1 -1
  41. package/dist/backend/llvm/expr-calls.d.ts +4 -1
  42. package/dist/backend/llvm/expr-calls.js +20 -4
  43. package/dist/backend/llvm/expr-calls.js.map +1 -1
  44. package/dist/backend/llvm/expr-dynamic.js +209 -16
  45. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  46. package/dist/backend/llvm/expr-primitives.js +94 -11
  47. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  48. package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
  49. package/dist/backend/llvm/expr-stream-bridges.js +42 -2
  50. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  51. package/dist/backend/llvm/expr-stream-callbacks.d.ts +16 -0
  52. package/dist/backend/llvm/expr-stream-callbacks.js +206 -20
  53. package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
  54. package/dist/backend/llvm/integer-values.d.ts +2 -0
  55. package/dist/backend/llvm/integer-values.js +6 -0
  56. package/dist/backend/llvm/integer-values.js.map +1 -1
  57. package/dist/backend/llvm/js-ic.d.ts +38 -0
  58. package/dist/backend/llvm/js-ic.js +295 -1
  59. package/dist/backend/llvm/js-ic.js.map +1 -1
  60. package/dist/backend/llvm/lib-dispatch.js +20 -0
  61. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  62. package/dist/backend/llvm/lib-filesystem.js +116 -11
  63. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  64. package/dist/backend/llvm/lib-process.js +136 -24
  65. package/dist/backend/llvm/lib-process.js.map +1 -1
  66. package/dist/backend/llvm/lib-shared.js +70 -0
  67. package/dist/backend/llvm/lib-shared.js.map +1 -1
  68. package/dist/backend/llvm/lib-stream.js +67 -0
  69. package/dist/backend/llvm/lib-stream.js.map +1 -1
  70. package/dist/backend/llvm/loop-entry-versions.d.ts +2 -2
  71. package/dist/backend/llvm/loop-entry-versions.js +43 -21
  72. package/dist/backend/llvm/loop-entry-versions.js.map +1 -1
  73. package/dist/backend/llvm/loop-state.d.ts +7 -1
  74. package/dist/backend/llvm/loop-state.js +20 -2
  75. package/dist/backend/llvm/loop-state.js.map +1 -1
  76. package/dist/backend/llvm/map-number-lookup.d.ts +3 -1
  77. package/dist/backend/llvm/map-number-lookup.js +7 -3
  78. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  79. package/dist/backend/llvm/map-number-lookup.test.js +52 -11
  80. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  81. package/dist/backend/llvm/receiver-brackets.test.d.ts +1 -0
  82. package/dist/backend/llvm/receiver-brackets.test.js +68 -0
  83. package/dist/backend/llvm/receiver-brackets.test.js.map +1 -0
  84. package/dist/backend/llvm/record-views.d.ts +22 -2
  85. package/dist/backend/llvm/record-views.js +139 -10
  86. package/dist/backend/llvm/record-views.js.map +1 -1
  87. package/dist/backend/llvm/record-views.test.js +76 -0
  88. package/dist/backend/llvm/record-views.test.js.map +1 -1
  89. package/dist/backend/llvm/reference-writes.js +1 -0
  90. package/dist/backend/llvm/reference-writes.js.map +1 -1
  91. package/dist/backend/llvm/shapes.d.ts +3 -0
  92. package/dist/backend/llvm/shapes.js +18 -3
  93. package/dist/backend/llvm/shapes.js.map +1 -1
  94. package/dist/backend/llvm/shapes.test.js +4 -0
  95. package/dist/backend/llvm/shapes.test.js.map +1 -1
  96. package/dist/backend/llvm/speculative-integers.d.ts +10 -1
  97. package/dist/backend/llvm/speculative-integers.js +59 -8
  98. package/dist/backend/llvm/speculative-integers.js.map +1 -1
  99. package/dist/backend/llvm/unwind-abi.d.ts +3 -3
  100. package/dist/backend/llvm/unwind-abi.js +8 -3
  101. package/dist/backend/llvm/unwind-abi.js.map +1 -1
  102. package/dist/backend/llvm/walkers.js +1 -1
  103. package/dist/backend/llvm/walkers.js.map +1 -1
  104. package/dist/backend/native/contracts.d.ts +54 -0
  105. package/dist/backend/native/executable.js +87 -5
  106. package/dist/backend/native/executable.js.map +1 -1
  107. package/dist/backend/native/library.js +1 -1
  108. package/dist/backend/native/library.js.map +1 -1
  109. package/dist/backend/native/runtime-inputs.js +5 -1
  110. package/dist/backend/native/runtime-inputs.js.map +1 -1
  111. package/dist/backend/native/vendor.d.ts +1 -1
  112. package/dist/backend/native/vendor.js +1 -1
  113. package/dist/backend/native/vendor.js.map +1 -1
  114. package/dist/backend/native-codegen.js +3 -0
  115. package/dist/backend/native-codegen.js.map +1 -1
  116. package/dist/backend/native-link-info-core.d.ts +43 -0
  117. package/dist/backend/native-link-info-core.js.map +1 -1
  118. package/dist/backend/native-link-info.js +1 -0
  119. package/dist/backend/native-link-info.js.map +1 -1
  120. package/dist/backend/native-profile.d.ts +4 -1
  121. package/dist/backend/native-profile.js +12 -1
  122. package/dist/backend/native-profile.js.map +1 -1
  123. package/dist/backend/native-profile.test.js +10 -0
  124. package/dist/backend/native-profile.test.js.map +1 -1
  125. package/dist/backend/publication.d.ts +4 -1
  126. package/dist/backend/publication.js +4 -2
  127. package/dist/backend/publication.js.map +1 -1
  128. package/dist/backend/runtime-abi.d.ts +2 -2
  129. package/dist/backend/runtime-abi.js +2 -2
  130. package/dist/backend/runtime-pack-core.d.ts +31 -7
  131. package/dist/backend/runtime-pack-core.js +21 -1
  132. package/dist/backend/runtime-pack-core.js.map +1 -1
  133. package/dist/backend/runtime-pack-native.d.ts +18 -1
  134. package/dist/backend/runtime-pack-native.js +138 -29
  135. package/dist/backend/runtime-pack-native.js.map +1 -1
  136. package/dist/backend/runtime-pack-native.test.js +166 -4
  137. package/dist/backend/runtime-pack-native.test.js.map +1 -1
  138. package/dist/backend/runtime-pack-targets.test.js +3 -1
  139. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  140. package/dist/backend/runtime-pack.d.ts +7 -0
  141. package/dist/backend/runtime-pack.js +25 -3
  142. package/dist/backend/runtime-pack.js.map +1 -1
  143. package/dist/backend/runtime-pack.test.js +3 -11
  144. package/dist/backend/runtime-pack.test.js.map +1 -1
  145. package/dist/backend/vendor-archives.d.ts +4 -1
  146. package/dist/backend/vendor-archives.js +264 -3
  147. package/dist/backend/vendor-archives.js.map +1 -1
  148. package/dist/backend/vendor-inputs.d.ts +36 -0
  149. package/dist/backend/vendor-inputs.js +42 -0
  150. package/dist/backend/vendor-inputs.js.map +1 -1
  151. package/dist/backend/vendor-inputs.test.js +28 -1
  152. package/dist/backend/vendor-inputs.test.js.map +1 -1
  153. package/dist/backend/warm-cache.js +2 -0
  154. package/dist/backend/warm-cache.js.map +1 -1
  155. package/dist/compat/fetch-profile.d.ts +7 -1
  156. package/dist/compat/fetch-profile.js +23 -10
  157. package/dist/compat/fetch-profile.js.map +1 -1
  158. package/dist/compile-types.d.ts +7 -0
  159. package/dist/contracts/check.d.ts +3 -0
  160. package/dist/contracts/check.js +18 -5
  161. package/dist/contracts/check.js.map +1 -1
  162. package/dist/coverage/surface-manifest.js +1 -1
  163. package/dist/coverage/surface-manifest.js.map +1 -1
  164. package/dist/diagnostics/codes.d.ts +6 -0
  165. package/dist/diagnostics/codes.js +6 -0
  166. package/dist/diagnostics/codes.js.map +1 -1
  167. package/dist/diagnostics/diagnostic.d.ts +50 -0
  168. package/dist/diagnostics/diagnostic.js +142 -3
  169. package/dist/diagnostics/diagnostic.js.map +1 -1
  170. package/dist/diagnostics/dynamic-tier.js +3 -1
  171. package/dist/diagnostics/dynamic-tier.js.map +1 -1
  172. package/dist/executable/executable-cache.d.ts +29 -0
  173. package/dist/executable/executable-cache.js +18 -0
  174. package/dist/executable/executable-cache.js.map +1 -1
  175. package/dist/executable/executable-cache.test.js +5 -1
  176. package/dist/executable/executable-cache.test.js.map +1 -1
  177. package/dist/executable/prepare.d.ts +13 -3
  178. package/dist/executable/prepare.js +271 -18
  179. package/dist/executable/prepare.js.map +1 -1
  180. package/dist/frontend/early-errors.d.ts +14 -0
  181. package/dist/frontend/early-errors.js +305 -0
  182. package/dist/frontend/early-errors.js.map +1 -0
  183. package/dist/frontend/early-errors.test.d.ts +1 -0
  184. package/dist/frontend/early-errors.test.js +42 -0
  185. package/dist/frontend/early-errors.test.js.map +1 -0
  186. package/dist/frontend/inferred-js-diagnostics.test.js +23 -0
  187. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  188. package/dist/frontend/input-tracker.d.ts +47 -0
  189. package/dist/frontend/input-tracker.js +173 -36
  190. package/dist/frontend/input-tracker.js.map +1 -1
  191. package/dist/frontend/input-tracker.test.js +86 -2
  192. package/dist/frontend/input-tracker.test.js.map +1 -1
  193. package/dist/frontend/js-inference.d.ts +2 -0
  194. package/dist/frontend/js-inference.js +18 -0
  195. package/dist/frontend/js-inference.js.map +1 -0
  196. package/dist/frontend/lowering/binding-analysis.d.ts +2 -1
  197. package/dist/frontend/lowering/binding-analysis.js +65 -1
  198. package/dist/frontend/lowering/binding-analysis.js.map +1 -1
  199. package/dist/frontend/lowering/builtin-calls.js +9 -0
  200. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  201. package/dist/frontend/lowering/builtin-namespaces.d.ts +1 -1
  202. package/dist/frontend/lowering/builtin-namespaces.js +19 -2
  203. package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
  204. package/dist/frontend/lowering/builtins/child-process-methods.d.ts +7 -0
  205. package/dist/frontend/lowering/builtins/child-process-methods.js +50 -10
  206. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  207. package/dist/frontend/lowering/builtins/child-process.js +5 -1
  208. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  209. package/dist/frontend/lowering/builtins/dates.d.ts +1 -1
  210. package/dist/frontend/lowering/builtins/dates.js +23 -1
  211. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  212. package/dist/frontend/lowering/builtins/environment.d.ts +55 -0
  213. package/dist/frontend/lowering/builtins/environment.js +213 -2
  214. package/dist/frontend/lowering/builtins/environment.js.map +1 -1
  215. package/dist/frontend/lowering/builtins/filesystem-calls.js +47 -16
  216. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  217. package/dist/frontend/lowering/builtins/filesystem.d.ts +25 -7
  218. package/dist/frontend/lowering/builtins/filesystem.js +185 -16
  219. package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
  220. package/dist/frontend/lowering/builtins/module-calls.js +39 -2
  221. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  222. package/dist/frontend/lowering/builtins/module-resolution.d.ts +8 -0
  223. package/dist/frontend/lowering/builtins/module-resolution.js +31 -5
  224. package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
  225. package/dist/frontend/lowering/builtins/operating-system.d.ts +3 -2
  226. package/dist/frontend/lowering/builtins/operating-system.js +5 -4
  227. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  228. package/dist/frontend/lowering/builtins/process.d.ts +17 -1
  229. package/dist/frontend/lowering/builtins/process.js +285 -19
  230. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  231. package/dist/frontend/lowering/builtins/querystring.d.ts +8 -0
  232. package/dist/frontend/lowering/builtins/querystring.js +202 -18
  233. package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
  234. package/dist/frontend/lowering/builtins/readline.js +21 -3
  235. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  236. package/dist/frontend/lowering/builtins/reflection.js +60 -1
  237. package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
  238. package/dist/frontend/lowering/builtins/text-codecs.js +208 -59
  239. package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
  240. package/dist/frontend/lowering/builtins/url.js +20 -1
  241. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  242. package/dist/frontend/lowering/builtins/v8.d.ts +5 -5
  243. package/dist/frontend/lowering/builtins/v8.js +7 -5
  244. package/dist/frontend/lowering/builtins/v8.js.map +1 -1
  245. package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +17 -2
  246. package/dist/frontend/lowering/builtins/web-streams-dyn.js +97 -9
  247. package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -1
  248. package/dist/frontend/lowering/call-signatures.js +77 -0
  249. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  250. package/dist/frontend/lowering/cjs-exports-object.d.ts +3 -0
  251. package/dist/frontend/lowering/cjs-exports-object.js +1 -1
  252. package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
  253. package/dist/frontend/lowering/cjs-inline-require.js +5 -0
  254. package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
  255. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +5 -0
  256. package/dist/frontend/lowering/class-dynamic-dispatch.js +114 -0
  257. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  258. package/dist/frontend/lowering/class-protocols.js +59 -10
  259. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  260. package/dist/frontend/lowering/class-runtime-statics.js +15 -0
  261. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  262. package/dist/frontend/lowering/class-views.d.ts +13 -0
  263. package/dist/frontend/lowering/class-views.js +51 -0
  264. package/dist/frontend/lowering/class-views.js.map +1 -0
  265. package/dist/frontend/lowering/coercions/function-adapters.d.ts +15 -1
  266. package/dist/frontend/lowering/coercions/function-adapters.js +54 -10
  267. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  268. package/dist/frontend/lowering/coercions/state.d.ts +7 -0
  269. package/dist/frontend/lowering/coercions/state.js +7 -0
  270. package/dist/frontend/lowering/coercions/state.js.map +1 -1
  271. package/dist/frontend/lowering/coercions/structural-plans.js +60 -3
  272. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  273. package/dist/frontend/lowering/coercions/structural.js +29 -1
  274. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  275. package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
  276. package/dist/frontend/lowering/containers/array-callbacks.js +132 -28
  277. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  278. package/dist/frontend/lowering/containers/array-construction.js +16 -5
  279. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  280. package/dist/frontend/lowering/containers/array-methods.js +16 -0
  281. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  282. package/dist/frontend/lowering/containers/bytes.js +4 -0
  283. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  284. package/dist/frontend/lowering/containers/callback-arguments.d.ts +11 -0
  285. package/dist/frontend/lowering/containers/callback-arguments.js +53 -0
  286. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  287. package/dist/frontend/lowering/containers/filter-predicates.d.ts +10 -0
  288. package/dist/frontend/lowering/containers/filter-predicates.js +69 -3
  289. package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
  290. package/dist/frontend/lowering/containers/indexed-objects.js +46 -2
  291. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  292. package/dist/frontend/lowering/expressions/array-literals.d.ts +14 -0
  293. package/dist/frontend/lowering/expressions/array-literals.js +26 -10
  294. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  295. package/dist/frontend/lowering/expressions/binary.js +104 -12
  296. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  297. package/dist/frontend/lowering/expressions/element-access.js +121 -4
  298. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  299. package/dist/frontend/lowering/expressions/identifiers.js +143 -3
  300. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  301. package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +11 -1
  302. package/dist/frontend/lowering/expressions/keyed-field-targets.js +22 -1
  303. package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
  304. package/dist/frontend/lowering/expressions/narrowing.js +25 -1
  305. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  306. package/dist/frontend/lowering/expressions/object-literals.d.ts +5 -1
  307. package/dist/frontend/lowering/expressions/object-literals.js +778 -229
  308. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  309. package/dist/frontend/lowering/expressions/optional-chains.js +66 -20
  310. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  311. package/dist/frontend/lowering/expressions/property-access.d.ts +31 -0
  312. package/dist/frontend/lowering/expressions/property-access.js +796 -12
  313. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  314. package/dist/frontend/lowering/expressions/relational.js +29 -1
  315. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  316. package/dist/frontend/lowering/expressions/typeof.js +17 -0
  317. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  318. package/dist/frontend/lowering/expressions/updates.js +132 -17
  319. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  320. package/dist/frontend/lowering/frozen-records.d.ts +6 -0
  321. package/dist/frontend/lowering/frozen-records.js +10 -4
  322. package/dist/frontend/lowering/frozen-records.js.map +1 -1
  323. package/dist/frontend/lowering/frozen-records.test.d.ts +1 -0
  324. package/dist/frontend/lowering/frozen-records.test.js +44 -0
  325. package/dist/frontend/lowering/frozen-records.test.js.map +1 -0
  326. package/dist/frontend/lowering/function-names.d.ts +9 -0
  327. package/dist/frontend/lowering/function-names.js +95 -0
  328. package/dist/frontend/lowering/function-names.js.map +1 -0
  329. package/dist/frontend/lowering/function-returns.js +5 -3
  330. package/dist/frontend/lowering/function-returns.js.map +1 -1
  331. package/dist/frontend/lowering/generic-functions.d.ts +49 -0
  332. package/dist/frontend/lowering/generic-functions.js +365 -7
  333. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  334. package/dist/frontend/lowering/global-values.d.ts +9 -0
  335. package/dist/frontend/lowering/global-values.js +44 -0
  336. package/dist/frontend/lowering/global-values.js.map +1 -1
  337. package/dist/frontend/lowering/handle-properties.js +34 -1
  338. package/dist/frontend/lowering/handle-properties.js.map +1 -1
  339. package/dist/frontend/lowering/key-order-witness.d.ts +54 -0
  340. package/dist/frontend/lowering/key-order-witness.js +546 -5
  341. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  342. package/dist/frontend/lowering/lib-boundary.js +14 -0
  343. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  344. package/dist/frontend/lowering/lower-assert.js +110 -1
  345. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  346. package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
  347. package/dist/frontend/lowering/lower-builtin-values.js +332 -58
  348. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  349. package/dist/frontend/lowering/lower-calls.d.ts +22 -1
  350. package/dist/frontend/lowering/lower-calls.js +427 -48
  351. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  352. package/dist/frontend/lowering/lower-calls.test.d.ts +1 -0
  353. package/dist/frontend/lowering/lower-calls.test.js +78 -0
  354. package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
  355. package/dist/frontend/lowering/lower-classes.d.ts +16 -5
  356. package/dist/frontend/lowering/lower-classes.js +168 -51
  357. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  358. package/dist/frontend/lowering/lower-event-emitter.d.ts +9 -0
  359. package/dist/frontend/lowering/lower-event-emitter.js +383 -41
  360. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  361. package/dist/frontend/lowering/lower-exprs.d.ts +14 -0
  362. package/dist/frontend/lowering/lower-exprs.js +25 -0
  363. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  364. package/dist/frontend/lowering/lower-functions.js +2 -0
  365. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  366. package/dist/frontend/lowering/lower-inspect.js +80 -33
  367. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  368. package/dist/frontend/lowering/lower-modules.js +87 -25
  369. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  370. package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
  371. package/dist/frontend/lowering/lower-node-island.js +456 -61
  372. package/dist/frontend/lowering/lower-node-island.js.map +1 -1
  373. package/dist/frontend/lowering/lower-server.js +160 -9
  374. package/dist/frontend/lowering/lower-server.js.map +1 -1
  375. package/dist/frontend/lowering/lower-shared-modules.js +13 -1
  376. package/dist/frontend/lowering/lower-shared-modules.js.map +1 -1
  377. package/dist/frontend/lowering/lower-stdlib.d.ts +3 -2
  378. package/dist/frontend/lowering/lower-stdlib.js +32 -18
  379. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  380. package/dist/frontend/lowering/lower-stmts.d.ts +21 -4
  381. package/dist/frontend/lowering/lower-stmts.js +580 -103
  382. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  383. package/dist/frontend/lowering/lower-stream.js +126 -8
  384. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  385. package/dist/frontend/lowering/lower-timers.js +133 -21
  386. package/dist/frontend/lowering/lower-timers.js.map +1 -1
  387. package/dist/frontend/lowering/lowerer.d.ts +139 -3
  388. package/dist/frontend/lowering/lowerer.js +579 -43
  389. package/dist/frontend/lowering/lowerer.js.map +1 -1
  390. package/dist/frontend/lowering/lowerer.test.js +1 -1
  391. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  392. package/dist/frontend/lowering/module-namespace-elements.js +15 -0
  393. package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
  394. package/dist/frontend/lowering/new-target.js +2 -2
  395. package/dist/frontend/lowering/nullish-empty-pattern.d.ts +17 -0
  396. package/dist/frontend/lowering/nullish-empty-pattern.js +118 -0
  397. package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -0
  398. package/dist/frontend/lowering/partial-assertions.d.ts +39 -0
  399. package/dist/frontend/lowering/partial-assertions.js +195 -0
  400. package/dist/frontend/lowering/partial-assertions.js.map +1 -0
  401. package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
  402. package/dist/frontend/lowering/primitive-wrappers.js +220 -0
  403. package/dist/frontend/lowering/primitive-wrappers.js.map +1 -0
  404. package/dist/frontend/lowering/private-statics.d.ts +46 -0
  405. package/dist/frontend/lowering/private-statics.js +322 -0
  406. package/dist/frontend/lowering/private-statics.js.map +1 -0
  407. package/dist/frontend/lowering/record-sources.d.ts +12 -1
  408. package/dist/frontend/lowering/record-sources.js +60 -0
  409. package/dist/frontend/lowering/record-sources.js.map +1 -1
  410. package/dist/frontend/lowering/strict-equality.d.ts +4 -0
  411. package/dist/frontend/lowering/strict-equality.js +14 -0
  412. package/dist/frontend/lowering/strict-equality.js.map +1 -1
  413. package/dist/frontend/lowering/surfaces.d.ts +27 -0
  414. package/dist/frontend/lowering/surfaces.js +135 -62
  415. package/dist/frontend/lowering/surfaces.js.map +1 -1
  416. package/dist/frontend/lowering/unit-journal.d.ts +128 -17
  417. package/dist/frontend/lowering/unit-journal.js +310 -53
  418. package/dist/frontend/lowering/unit-journal.js.map +1 -1
  419. package/dist/frontend/lowering/unit-journal.test.js +91 -3
  420. package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
  421. package/dist/frontend/lowering/unit-reuse.d.ts +92 -0
  422. package/dist/frontend/lowering/unit-reuse.js +1008 -0
  423. package/dist/frontend/lowering/unit-reuse.js.map +1 -0
  424. package/dist/frontend/lowering/width-lift.d.ts +12 -0
  425. package/dist/frontend/npm-file-import.test.d.ts +1 -0
  426. package/dist/frontend/npm-file-import.test.js +76 -0
  427. package/dist/frontend/npm-file-import.test.js.map +1 -0
  428. package/dist/frontend/npm-static.js +17 -2
  429. package/dist/frontend/npm-static.js.map +1 -1
  430. package/dist/frontend/npm.d.ts +9 -0
  431. package/dist/frontend/npm.js +82 -0
  432. package/dist/frontend/npm.js.map +1 -1
  433. package/dist/frontend/pipeline-native.js +2 -1
  434. package/dist/frontend/pipeline-native.js.map +1 -1
  435. package/dist/frontend/pipeline.d.ts +4 -0
  436. package/dist/frontend/pipeline.js +68 -7
  437. package/dist/frontend/pipeline.js.map +1 -1
  438. package/dist/frontend/program-node.d.ts +3 -0
  439. package/dist/frontend/program-node.js +13 -6
  440. package/dist/frontend/program-node.js.map +1 -1
  441. package/dist/frontend/program.d.ts +9 -0
  442. package/dist/frontend/program.js +159 -7
  443. package/dist/frontend/program.js.map +1 -1
  444. package/dist/frontend/provenance-core.js +4 -0
  445. package/dist/frontend/provenance-core.js.map +1 -1
  446. package/dist/frontend/services.d.ts +14 -0
  447. package/dist/frontend/services.js +52 -2
  448. package/dist/frontend/services.js.map +1 -1
  449. package/dist/frontend/services.test.js +61 -1
  450. package/dist/frontend/services.test.js.map +1 -1
  451. package/dist/frontend/shape-inference/analyze.d.ts +5 -0
  452. package/dist/frontend/shape-inference/analyze.js +104 -4
  453. package/dist/frontend/shape-inference/analyze.js.map +1 -1
  454. package/dist/frontend/shape-inference/domain.js +0 -1
  455. package/dist/frontend/shape-inference/domain.js.map +1 -1
  456. package/dist/frontend/shape-inference/index.js +5 -1
  457. package/dist/frontend/shape-inference/index.js.map +1 -1
  458. package/dist/frontend/shape-inference/memo.d.ts +2 -1
  459. package/dist/frontend/shape-inference/memo.js +6 -2
  460. package/dist/frontend/shape-inference/memo.js.map +1 -1
  461. package/dist/frontend/shape-inference/overlay.d.ts +1 -1
  462. package/dist/frontend/shape-inference/overlay.js +116 -2
  463. package/dist/frontend/shape-inference/overlay.js.map +1 -1
  464. package/dist/frontend/shape-inference/static-objects.js +11 -6
  465. package/dist/frontend/shape-inference/static-objects.js.map +1 -1
  466. package/dist/frontend/source-phase-imports.test.d.ts +1 -0
  467. package/dist/frontend/source-phase-imports.test.js +37 -0
  468. package/dist/frontend/source-phase-imports.test.js.map +1 -0
  469. package/dist/frontend/ts7/ast-node.d.ts +6 -1
  470. package/dist/frontend/ts7/ast-node.js +12 -0
  471. package/dist/frontend/ts7/ast-node.js.map +1 -1
  472. package/dist/frontend/ts7/ast-wire-protocols.test.js +11 -3
  473. package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -1
  474. package/dist/frontend/ts7/ast-wire.js +3 -5
  475. package/dist/frontend/ts7/ast-wire.js.map +1 -1
  476. package/dist/frontend/ts7/checker-backend.d.ts +13 -0
  477. package/dist/frontend/ts7/checker-backend.js +84 -2
  478. package/dist/frontend/ts7/checker-backend.js.map +1 -1
  479. package/dist/frontend/ts7/checker-backend.test.js +126 -2
  480. package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
  481. package/dist/frontend/ts7/program-host.d.ts +22 -1
  482. package/dist/frontend/ts7/program-host.js +49 -4
  483. package/dist/frontend/ts7/program-host.js.map +1 -1
  484. package/dist/frontend/ts7/program-host.test.js +83 -0
  485. package/dist/frontend/ts7/program-host.test.js.map +1 -1
  486. package/dist/frontend/ts7/rpc-process.d.ts +16 -1
  487. package/dist/frontend/ts7/rpc-process.js +170 -92
  488. package/dist/frontend/ts7/rpc-process.js.map +1 -1
  489. package/dist/frontend/ts7/rpc-process.test.js +49 -21
  490. package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
  491. package/dist/frontend/tsc-codes.js +70 -0
  492. package/dist/frontend/tsc-codes.js.map +1 -1
  493. package/dist/frontend/type-mapper.d.ts +7 -2
  494. package/dist/frontend/type-mapper.js +148 -1
  495. package/dist/frontend/type-mapper.js.map +1 -1
  496. package/dist/index.d.ts +1 -1
  497. package/dist/index.js +152 -8
  498. package/dist/index.js.map +1 -1
  499. package/dist/ir/api.d.ts +1 -1
  500. package/dist/ir/api.js +1 -1
  501. package/dist/ir/api.js.map +1 -1
  502. package/dist/ir/build.d.ts +3 -2
  503. package/dist/ir/build.js +4 -2
  504. package/dist/ir/build.js.map +1 -1
  505. package/dist/ir/builtin-effects.js +53 -0
  506. package/dist/ir/builtin-effects.js.map +1 -1
  507. package/dist/ir/builtin-signatures.d.ts +1 -1
  508. package/dist/ir/builtin-signatures.js +211 -10
  509. package/dist/ir/builtin-signatures.js.map +1 -1
  510. package/dist/ir/codec.d.ts +82 -0
  511. package/dist/ir/codec.generated.d.ts +13 -0
  512. package/dist/ir/codec.generated.js +5274 -0
  513. package/dist/ir/codec.generated.js.map +1 -0
  514. package/dist/ir/codec.js +325 -0
  515. package/dist/ir/codec.js.map +1 -0
  516. package/dist/ir/codec.test.d.ts +1 -0
  517. package/dist/ir/codec.test.js +225 -0
  518. package/dist/ir/codec.test.js.map +1 -0
  519. package/dist/ir/fields.generated.d.ts +20 -10
  520. package/dist/ir/fields.generated.js +1031 -11
  521. package/dist/ir/fields.generated.js.map +1 -1
  522. package/dist/ir/fields.test.js +46 -2
  523. package/dist/ir/fields.test.js.map +1 -1
  524. package/dist/ir/function-references.d.ts +5 -4
  525. package/dist/ir/function-references.js +8 -4
  526. package/dist/ir/function-references.js.map +1 -1
  527. package/dist/ir/function-references.test.js +7 -0
  528. package/dist/ir/function-references.test.js.map +1 -1
  529. package/dist/ir/inline-array-sources.js +4 -1
  530. package/dist/ir/inline-array-sources.js.map +1 -1
  531. package/dist/ir/inline-array-views.d.ts +13 -0
  532. package/dist/ir/inline-array-views.js +944 -0
  533. package/dist/ir/inline-array-views.js.map +1 -0
  534. package/dist/ir/inline-arrays.d.ts +7 -0
  535. package/dist/ir/inline-arrays.js +190 -55
  536. package/dist/ir/inline-arrays.js.map +1 -1
  537. package/dist/ir/inline-arrays.test.js +140 -2
  538. package/dist/ir/inline-arrays.test.js.map +1 -1
  539. package/dist/ir/integer-ranges.js +16 -6
  540. package/dist/ir/integer-ranges.js.map +1 -1
  541. package/dist/ir/ir.d.ts +75 -44
  542. package/dist/ir/ir.js.map +1 -1
  543. package/dist/ir/js-ic.d.ts +10 -9
  544. package/dist/ir/js-ic.js +28 -20
  545. package/dist/ir/js-ic.js.map +1 -1
  546. package/dist/ir/js-ic.test.js +10 -2
  547. package/dist/ir/js-ic.test.js.map +1 -1
  548. package/dist/ir/jsval.js +374 -63
  549. package/dist/ir/jsval.js.map +1 -1
  550. package/dist/ir/jsval.test.js +96 -2
  551. package/dist/ir/jsval.test.js.map +1 -1
  552. package/dist/ir/loop-entry-ranges.js +112 -9
  553. package/dist/ir/loop-entry-ranges.js.map +1 -1
  554. package/dist/ir/loop-entry-ranges.test.js +40 -0
  555. package/dist/ir/loop-entry-ranges.test.js.map +1 -1
  556. package/dist/ir/parameter-versions.d.ts +2 -1
  557. package/dist/ir/parameter-versions.js +3 -1
  558. package/dist/ir/parameter-versions.js.map +1 -1
  559. package/dist/ir/receiver-readers.js +58 -2
  560. package/dist/ir/receiver-readers.js.map +1 -1
  561. package/dist/ir/runtime-features.d.ts +60 -1
  562. package/dist/ir/runtime-features.js +277 -2
  563. package/dist/ir/runtime-features.js.map +1 -1
  564. package/dist/ir/runtime-features.test.js +165 -1
  565. package/dist/ir/runtime-features.test.js.map +1 -1
  566. package/dist/ir/saturating-loop-jams.d.ts +8 -1
  567. package/dist/ir/saturating-loop-jams.js +46 -7
  568. package/dist/ir/saturating-loop-jams.js.map +1 -1
  569. package/dist/ir/saturating-loop-jams.test.js +39 -1
  570. package/dist/ir/saturating-loop-jams.test.js.map +1 -1
  571. package/dist/ir/self-captures.js +8 -1
  572. package/dist/ir/self-captures.js.map +1 -1
  573. package/dist/ir/self-captures.test.js +15 -0
  574. package/dist/ir/self-captures.test.js.map +1 -1
  575. package/dist/ir/serialize.d.ts +3 -2
  576. package/dist/ir/serialize.js +6 -2
  577. package/dist/ir/serialize.js.map +1 -1
  578. package/dist/ir/validate.js +82 -4
  579. package/dist/ir/validate.js.map +1 -1
  580. package/dist/ir/validate.test.js +46 -0
  581. package/dist/ir/validate.test.js.map +1 -1
  582. package/dist/library/ir-policy.js +3 -0
  583. package/dist/library/ir-policy.js.map +1 -1
  584. package/dist/native/cache.js +2 -0
  585. package/dist/native/cache.js.map +1 -1
  586. package/dist/native/cli.js +2 -0
  587. package/dist/native/cli.js.map +1 -1
  588. package/dist/native/compiler.js +8 -2
  589. package/dist/native/compiler.js.map +1 -1
  590. package/dist/native/prepare.js +32 -3
  591. package/dist/native/prepare.js.map +1 -1
  592. package/dist/native/sanitizer.js +53 -3
  593. package/dist/native/sanitizer.js.map +1 -1
  594. package/dist/native/sanitizer.test.js +88 -2
  595. package/dist/native/sanitizer.test.js.map +1 -1
  596. package/dist/native/toolchain.js +9 -2
  597. package/dist/native/toolchain.js.map +1 -1
  598. package/dist/node-islands/boundary.d.ts +25 -1
  599. package/dist/node-islands/boundary.js +28 -2
  600. package/dist/node-islands/boundary.js.map +1 -1
  601. package/dist/node-islands/detect.d.ts +18 -1
  602. package/dist/node-islands/detect.js +365 -40
  603. package/dist/node-islands/detect.js.map +1 -1
  604. package/dist/node-islands/detect.test.js +151 -4
  605. package/dist/node-islands/detect.test.js.map +1 -1
  606. package/dist/node-islands/effect-gate.js +30 -20
  607. package/dist/node-islands/effect-gate.js.map +1 -1
  608. package/dist/node-islands/effect-gate.test.js +4 -1
  609. package/dist/node-islands/effect-gate.test.js.map +1 -1
  610. package/dist/node-islands/libnode.d.ts +1 -1
  611. package/dist/node-islands/libnode.js +1 -1
  612. package/dist/node-islands/libnode.js.map +1 -1
  613. package/dist/node-islands/modules.d.ts +28 -0
  614. package/dist/node-islands/modules.js +156 -0
  615. package/dist/node-islands/modules.js.map +1 -1
  616. package/dist/node-islands/modules.test.js +105 -1
  617. package/dist/node-islands/modules.test.js.map +1 -1
  618. package/dist/node-islands/policy.js +2 -3
  619. package/dist/node-islands/policy.js.map +1 -1
  620. package/dist/node-islands/probe-recorder.d.ts +1 -0
  621. package/dist/node-islands/probe-recorder.js +596 -0
  622. package/dist/node-islands/probe-recorder.js.map +1 -0
  623. package/dist/node-islands/probe-recorder.test.d.ts +1 -0
  624. package/dist/node-islands/probe-recorder.test.js +80 -0
  625. package/dist/node-islands/probe-recorder.test.js.map +1 -0
  626. package/dist/node-islands/report.test.js +2 -0
  627. package/dist/node-islands/report.test.js.map +1 -1
  628. package/dist/node-islands/rules.js +4 -0
  629. package/dist/node-islands/rules.js.map +1 -1
  630. package/dist/node-islands/scan.d.ts +7 -1
  631. package/dist/node-islands/scan.js +51 -2
  632. package/dist/node-islands/scan.js.map +1 -1
  633. package/dist/node-islands/snapshot.d.ts +38 -1
  634. package/dist/node-islands/snapshot.js +165 -161
  635. package/dist/node-islands/snapshot.js.map +1 -1
  636. package/dist/node-islands/snapshot.test.js +63 -2
  637. package/dist/node-islands/snapshot.test.js.map +1 -1
  638. package/dist/node-islands/summary.js +8 -0
  639. package/dist/node-islands/summary.js.map +1 -1
  640. package/dist/node-islands/type-strip.d.ts +11 -0
  641. package/dist/node-islands/type-strip.js +157 -0
  642. package/dist/node-islands/type-strip.js.map +1 -0
  643. package/dist/node-islands/type-strip.test.d.ts +1 -0
  644. package/dist/node-islands/type-strip.test.js +31 -0
  645. package/dist/node-islands/type-strip.test.js.map +1 -0
  646. package/dist/project-config.d.ts +4 -0
  647. package/dist/project-config.js +19 -0
  648. package/dist/project-config.js.map +1 -1
  649. package/dist/project-config.test.js +10 -0
  650. package/dist/project-config.test.js.map +1 -1
  651. package/package.json +20 -20
  652. package/surface-manifest.json +43 -11
@@ -1,6 +1,9 @@
1
+ import { programCreatesWrappers } from "./primitive-wrappers.js";
1
2
  import { arrayClassMemberOwner, arrayClassReceiver, lowerArrayClassStaticCall, } from "./builtins/array-classes.js";
2
3
  import { structuralCallInstance } from "./structural-instances.js";
4
+ import { classViewOf } from "./class-views.js";
3
5
  import { checkedPrivateMethodReceiver, privateNameClass } from "./private-brands.js";
6
+ import { lowerStaticPrivateCall } from "./private-statics.js";
4
7
  import { assertFunctionAliasOf } from "./lower-assert.js";
5
8
  import { keyedHelperName } from "./stable-names.js";
6
9
  import { perKeyOrder } from "./key-order-witness.js";
@@ -38,7 +41,7 @@ import { lowerClassSymbolMethodCall } from "./symbol-methods.js";
38
41
  import { lowerReadlineDisposeCall } from "./builtins/readline.js";
39
42
  import { errorToStringCall } from "./error-methods.js";
40
43
  import { lowerClassPrototypeAssign, lowerClassPrototypeDescriptors } from "./class-prototypes.js";
41
- import { BYTES_ELEMENT_NAME, BYTES_U8, BIGINT_T, BOOL, CAUGHT, DYN, DYN_HANDLE_KINDS, F64, NULL_T, STRING, SYMBOL_T, UNDEFINED_T, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, funcOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, shapeKeyOrders, typeEquals, RUNTIME_EMITTER_CLASS, } from "../../ir/ir.js";
44
+ import { BYTES_ELEMENT_NAME, BYTES_U8, BIGINT_T, BOOL, CAUGHT, DYN, DYN_HANDLE_KINDS, F64, NULL_T, STRING, SYMBOL_T, UNDEFINED_T, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, funcOf, isDynTypedRefType, isUnitType, recordTextCodecClass, shapeHasAccessorSlots, shapeKeyOrders, typeEquals, RUNTIME_EMITTER_CLASS, } from "../../ir/ir.js";
42
45
  import { lowerProtocolMethodCall } from "./class-protocol-dispatch.js";
43
46
  import { isJsSourceFile, locOf, requireSpecOf } from "../program.js";
44
47
  import { isPackageShimFile, isShimIntrinsicName } from "../package-shims.js";
@@ -56,6 +59,7 @@ import { lowerGeneratorHelperCall, lowerHelperReturnCall, lowerIteratorFromCall,
56
59
  import { lowerObjectAssignIndexShape, lowerObjectConstructor, lowerObjectFromEntriesCall, lowerObjectIterOverIndexShape, } from "./containers/indexed-objects.js";
57
60
  import { lowerTupleReadMethodCall } from "./containers/array-methods.js";
58
61
  import { tryFuseIndexRead } from "./array-values.js";
62
+ import { isPrimitivePrototypeRead } from "./expressions/property-access.js";
59
63
  import { lowerBufferConstruct, lowerBytesPrototypeSetCall, lowerBytesStaticCall, } from "./containers/bytes.js";
60
64
  import { lowerRegexMethodCall, lowerStringIndexCall, lowerStringMethodCall, lowerStringPaddingCall, lowerStringSplitCall, isDynPrimitiveKindMethod, lowerDynPrimitiveMethodCall, lowerExtraNumberMethodCall, } from "./containers/string-and-regexp.js";
61
65
  import { createRequireSpecOf } from "./builtins/module-bindings.js";
@@ -69,7 +73,7 @@ import { lowerDirentMethodCall, lowerFileHandleMethodCall, lowerDirMethodCall, l
69
73
  import { fencePerfEntryKeyWalk, isPerfEntryType, lowerHistogramMethodCall, lowerPerfHooksCall, perfEntryTag, } from "./builtins/performance.js";
70
74
  import { fenceX509KeyWalk } from "./builtins/x509.js";
71
75
  import { lowerProcStreamMethodCall, lowerProcessBuiltinModuleNamespace, } from "./builtins/process.js";
72
- import { recordMayKeepSource, throughRecordSource } from "./record-sources.js";
76
+ import { recordMayKeepSource, recordSourceTest, throughRecordSource } from "./record-sources.js";
73
77
  import { lowerReflectCall } from "./builtins/reflection.js";
74
78
  import { lowerAbsenceProbe, v8CalleeText, lowerPromiseAllTupleCall, lowerPromiseRejectCall, lowerToNumberArgument, stringWrapperToString, symbolFieldInfo, templateRawTextOf, primitiveCtorClosure, } from "./lower-exprs.js";
75
79
  import { isSafeToDiscard } from "./expressions/evaluation-safety.js";
@@ -88,7 +92,8 @@ import { lowerConsoleInstanceCall, lowerConsoleMethodCall, lowerConsoleOutput, }
88
92
  import { STREAM_API_MEMBERS, STREAM_OPERATORS, lowerStreamMethodCall, lowerStreamStaticCall, streamSidesOf, } from "./lower-stream.js";
89
93
  import { ambientNsRootOf, ambientUndefReadType, ambientUndefVarRootOf, ambientUndefinedFnSymbolOf, contextualUndefReadType, fenceEarlyAliasUse, fenceEarlyNsMemberRef, nsMemberIdentOf, nsUndefRead, } from "./lower-namespaces.js";
90
94
  import { expandoMemberRead } from "./lower-expando.js";
91
- import { fenceNodeModuleMutationCall, lowerRequireCacheKeys } from "./lower-node-module.js";
95
+ import { fenceNodeModuleMutationCall, isCjsRequireGlobal, lowerRequireCacheKeys, } from "./lower-node-module.js";
96
+ import { pathModuleValue } from "./lower-builtin-values.js";
92
97
  import { defaultAfterUndefined, lowerOptionalArgument, lowerStaticallyUndefinedArgument, positionNumber, } from "./optional-arguments.js";
93
98
  import { fenceSymbolFieldCopy } from "./symbol-fields.js";
94
99
  import { lowerClassDataDescriptor, lowerClassDescriptorRead } from "./class-descriptors.js";
@@ -106,6 +111,7 @@ import { maybePromiseReturnStmt, promiseArmedUnionOf, promiseOrUnitUnionOf, } fr
106
111
  import { requireObjLitGenericReceiver, objLitGenericFnNodeOf, objLitGenericFnInfoOf, genericCallInstance, } from "./generic-functions.js";
107
112
  import { codeGenerationCalleeOf, lowerCodeGenerationCall } from "./code-generation.js";
108
113
  import { lowerRecordInheritedCall } from "./record-inherited.js";
114
+ import { fenceDatePrototypeWriteCall } from "./expressions/property-access.js";
109
115
  const ZLIB_STREAM_METHODS = new Set(["flush", "params", "close", "reset"]);
110
116
  /** The node:util member a `(0, member)` callee names, or null. */
111
117
  function indirectUtilCalleeOf(lowerer, callee) {
@@ -269,6 +275,20 @@ export function lowerCall(lowerer, expr) {
269
275
  if (inlineValue)
270
276
  return inlineValue;
271
277
  }
278
+ // `require("path/posix")` of a builtin as a value: the module's
279
+ // namespace, as a `const posix = require("path/posix")` binding is.
280
+ if (ts.isIdentifier(expr.expression) &&
281
+ expr.expression.text === "require" &&
282
+ isCjsRequireGlobal(lowerer, expr.expression)) {
283
+ const module = lowerer.builtinNamespaceModuleOf(expr);
284
+ // The platform namespaces are the path module objects.
285
+ if (module === "path/posix" || module === "path/win32")
286
+ return pathModuleValue(lowerer, module, loc);
287
+ if (module !== null && module !== "constants") {
288
+ const moduleId = `builtin:${module}`;
289
+ return { kind: "moduleNsRef", moduleId, type: { kind: "moduleNs", moduleId }, loc };
290
+ }
291
+ }
272
292
  // A call whose chain ROOTS at an ambient-undefined name (`declare
273
293
  // const value: Y | undefined; value?.foo("a")`, `declare function
274
294
  // chain...; chain(o).mapValues(f).value()`, a trap binding's read):
@@ -441,6 +461,9 @@ export function lowerCall(lowerer, expr) {
441
461
  if (ts.isPropertyAccessExpression(expr.expression) &&
442
462
  ts.isPrivateIdentifier(expr.expression.name) &&
443
463
  !expr.expression.questionDotToken) {
464
+ const staticPrivate = lowerStaticPrivateCall(lowerer, expr, expr.expression);
465
+ if (staticPrivate)
466
+ return staticPrivate;
444
467
  const privateCall = lowerCheckedPrivateMethodCall(lowerer, expr, expr.expression);
445
468
  if (privateCall)
446
469
  return privateCall;
@@ -1561,6 +1584,11 @@ export function lowerCall(lowerer, expr) {
1561
1584
  lowerer.unsupported("SC1090", expr, `calls of the generic method '${expr.expression.name.text}' through this receiver (no compiled declaration with a body resolves statically here — ambient 'declare class' and interface-only methods are signature-only, and only class, static, and object-literal generic methods with bodies monomorphize)`);
1562
1585
  }
1563
1586
  }
1587
+ {
1588
+ const unionCall = lowerUnionReceiverMethodCall(lowerer, expr, expr.expression);
1589
+ if (unionCall)
1590
+ return unionCall;
1591
+ }
1564
1592
  lowerer.unsupported("SC1090", expr, `method calls like '${ts.getTextOfNode(expr.expression)}'`);
1565
1593
  }
1566
1594
  // `s[Symbol.iterator]()` on a string: the string iterator as a value.
@@ -1753,7 +1781,7 @@ function callableInstanceStringCall(lowerer, expr, callee, loc) {
1753
1781
  }
1754
1782
  /** A call through an evaluated callee value: checked-dynamic callees,
1755
1783
  * function unions, typed-rest and runtime-arity closures. */
1756
- function lowerCallThroughValue(lowerer, expr, callee, loc) {
1784
+ export function lowerCallThroughValue(lowerer, expr, callee, loc) {
1757
1785
  // A CHECKED-DYNAMIC callee — `fn(a, b)` where fn is an implicit-any
1758
1786
  // JS binding (the mustCall body's `fn(...args)`), a dyn capture, or a
1759
1787
  // keyed read off a dyn value: the dynCall boundary. Arguments convert
@@ -2283,8 +2311,12 @@ function objectToStringTag(lowerer, type) {
2283
2311
  return "Symbol";
2284
2312
  case "array":
2285
2313
  return "Array";
2286
- case "record":
2287
- return "Object";
2314
+ case "record": {
2315
+ // TextEncoder and TextDecoder define Symbol.toStringTag on their
2316
+ // prototypes.
2317
+ const shape = lowerer.shapes.get(type.shapeId);
2318
+ return (shape && recordTextCodecClass(shape)) ?? "Object";
2319
+ }
2288
2320
  case "func":
2289
2321
  case "classval":
2290
2322
  return "Function";
@@ -2393,6 +2425,29 @@ function immediateObjectTagReceiver(lowerer, node) {
2393
2425
  }
2394
2426
  return null;
2395
2427
  }
2428
+ /** Array.prototype methods whose `.<name>.call(receiver, ...)` form the
2429
+ * array-like unit runs generically when `receiver` is not a native array:
2430
+ * the rest of the prototype's methods besides the invoke unit's own set
2431
+ * (at, slice, indexOf, lastIndexOf, includes and the higher-order
2432
+ * callbacks). */
2433
+ const ARRAY_LIKE_BORROW_METHODS = new Set([
2434
+ "concat",
2435
+ "copyWithin",
2436
+ "fill",
2437
+ "flat",
2438
+ "flatMap",
2439
+ "join",
2440
+ "pop",
2441
+ "push",
2442
+ "reverse",
2443
+ "shift",
2444
+ "splice",
2445
+ "toReversed",
2446
+ "toSorted",
2447
+ "toSpliced",
2448
+ "unshift",
2449
+ "with",
2450
+ ]);
2396
2451
  const ARRAY_BORROW_METHODS = new Set([
2397
2452
  "at",
2398
2453
  "every",
@@ -2421,7 +2476,7 @@ function lowerArrayPrototypeBorrowCall(lowerer, call, access) {
2421
2476
  return null;
2422
2477
  const method = access.expression;
2423
2478
  if (method.questionDotToken ||
2424
- !ARRAY_BORROW_METHODS.has(method.name.text) ||
2479
+ !(ARRAY_BORROW_METHODS.has(method.name.text) || ARRAY_LIKE_BORROW_METHODS.has(method.name.text)) ||
2425
2480
  !ts.isPropertyAccessExpression(method.expression) ||
2426
2481
  method.expression.questionDotToken ||
2427
2482
  method.expression.name.text !== "prototype" ||
@@ -2435,7 +2490,12 @@ function lowerArrayPrototypeBorrowCall(lowerer, call, access) {
2435
2490
  const args = call.arguments.nodes.slice(1).map((arg) => lowerer.lowerExprExpecting(arg, DYN));
2436
2491
  return {
2437
2492
  kind: "libCall",
2438
- fn: "dyn.arrayProtoCall",
2493
+ // The array-like unit runs an extended method's algorithm over a
2494
+ // receiver that is not a native array and delegates the rest to the
2495
+ // invoke unit's dispatch.
2496
+ fn: ARRAY_LIKE_BORROW_METHODS.has(method.name.text)
2497
+ ? "dyn.arrayLikeProtoCall"
2498
+ : "dyn.arrayProtoCall",
2439
2499
  args: [
2440
2500
  receiver,
2441
2501
  { kind: "strLit", value: method.name.text, type: STRING, loc },
@@ -3062,6 +3122,57 @@ function isFreshCallResult(node) {
3062
3122
  e = e.expression;
3063
3123
  return ts.isCallExpression(e);
3064
3124
  }
3125
+ /** A METHOD call on a union receiver whose arms declare the member with
3126
+ * DIFFERENT signatures (`OAuthAuth | ApiKeyAuth` both declare `login`, one
3127
+ * with an options parameter): no single static signature picks an arm, and
3128
+ * JavaScript does not pick one either — it reads the property off the value
3129
+ * and calls it. Box the receiver into the checked-dynamic value and lower
3130
+ * the read and the call dynamically, so the member lookup and the call stay
3131
+ * checked (a missing member throws V8's own TypeError) and the result
3132
+ * crosses back through the expected type's checked conversion. Null when
3133
+ * the receiver is not a union of object/record arms with a dyn-safe layout,
3134
+ * leaving the method-call fence in place. */
3135
+ function lowerUnionReceiverMethodCall(lowerer, call, access) {
3136
+ if (access.questionDotToken || call.questionDotToken)
3137
+ return null;
3138
+ if (call.arguments.nodes.some(ts.isSpreadElement))
3139
+ return null;
3140
+ const value = tryLowerExpression(lowerer, access.expression);
3141
+ if (value?.type.kind !== "union")
3142
+ return null;
3143
+ const union = lowerer.unions.get(value.type.unionId);
3144
+ if (!union || !union.arms.every((arm) => arm.kind === "object" || arm.kind === "record")) {
3145
+ return null;
3146
+ }
3147
+ if (!lowerer.dynConvertible(value.type))
3148
+ return null;
3149
+ const loc = locOf(call);
3150
+ const boxed = lowerer.coerceToExpected(value, DYN);
3151
+ const local = lowerer.declareHiddenLocal("%unionReceiver", DYN);
3152
+ const receiver = { kind: "varRef", localId: local.id, type: DYN, loc };
3153
+ const member = {
3154
+ kind: "dynKeyGet",
3155
+ value: receiver,
3156
+ key: { kind: "strLit", value: access.name.text, type: STRING, loc },
3157
+ type: DYN,
3158
+ loc,
3159
+ };
3160
+ return {
3161
+ kind: "seqExpr",
3162
+ stmts: [{ kind: "varDecl", localId: local.id, init: boxed, loc }],
3163
+ result: {
3164
+ kind: "dynCall",
3165
+ callee: member,
3166
+ receiver,
3167
+ calleeName: ts.getTextOfNode(access),
3168
+ args: call.arguments.nodes.map((arg) => lowerer.lowerExprExpecting(arg, DYN)),
3169
+ type: DYN,
3170
+ loc,
3171
+ },
3172
+ type: DYN,
3173
+ loc,
3174
+ };
3175
+ }
3065
3176
  /** METHOD calls on dyn receivers (`pkg.name.replace(...)`, `rawName.split`,
3066
3177
  * `ws.packages.filter(...)` — JSON.parse-derived values): validate the
3067
3178
  * receiver's dyn kind, extract, and ride the STATIC method machinery — the
@@ -3277,6 +3388,12 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
3277
3388
  recv = lowerer.coerceToExpected(recv, DYN);
3278
3389
  if (recv.type.kind !== "dyn")
3279
3390
  return null;
3391
+ // `Number.prototype.m(...)` reads the prototype OBJECT, whose `m` is its
3392
+ // own member, so every primitive specialization below — which assumes a
3393
+ // primitive receiver and coerces the value it is given — would be wrong.
3394
+ // The shared dispatch reads the member and calls it with the prototype as
3395
+ // `this`, which is Node's answer for the wrapper around +0 / false.
3396
+ const prototypeReceiver = isPrimitivePrototypeRead(lowerer, access.expression);
3280
3397
  if (access.name.text === "normalize" &&
3281
3398
  call.arguments.nodes.length <= 1 &&
3282
3399
  !call.arguments.nodes.some(ts.isSpreadElement)) {
@@ -3383,7 +3500,7 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
3383
3500
  // prototype declares (Array carries includes/indexOf/slice too), so no
3384
3501
  // other kind inherits them. Shared names would need a receiver-kind
3385
3502
  // dispatch — they keep the fence.
3386
- if (DYN_STRING_ONLY_METHODS.has(access.name.text) && !ownCallable) {
3503
+ if (DYN_STRING_ONLY_METHODS.has(access.name.text) && !ownCallable && !prototypeReceiver) {
3387
3504
  // A checked-dynamic object can still carry its OWN member of that
3388
3505
  // name: zod's schemas assign `trim`, `toLowerCase` and `startsWith`
3389
3506
  // in their constructors (`z.string().trim().min(1)`), an object's
@@ -3394,9 +3511,10 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
3394
3511
  // receiver's runtime kind: a string runs the string lowering, anything
3395
3512
  // else calls its member as Node does.
3396
3513
  if ((checkerUntyped ||
3397
- (lowerer.typeOf(access).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0) &&
3398
- !call.questionDotToken &&
3399
- !access.questionDotToken &&
3514
+ (lowerer.typeOf(access).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0 ||
3515
+ // A receiver of the boxed String type may be a wrapper object.
3516
+ (lowerer.createsWrappers ??= programCreatesWrappers(lowerer))) &&
3517
+ !lowerer.chainBlocked(call, access) &&
3400
3518
  !call.arguments.nodes.some(ts.isSpreadElement))
3401
3519
  return lowerStringOrMemberCall(lowerer, call, access, recv);
3402
3520
  const checked = () => dynStringReceiver(lowerer, recv, access);
@@ -3408,8 +3526,7 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
3408
3526
  // or number receiver runs the typed lowering, every other kind keeps the
3409
3527
  // runtime dispatch.
3410
3528
  if (!ownCallable &&
3411
- !call.questionDotToken &&
3412
- !access.questionDotToken &&
3529
+ !prototypeReceiver &&
3413
3530
  isDynPrimitiveKindMethod(access.name.text) &&
3414
3531
  !lowerer.chainBlocked(access, call)) {
3415
3532
  const primitive = lowerDynPrimitiveMethodCall(lowerer, call, access.name.text, ts.getTextOfNode(access), recv);
@@ -3423,6 +3540,7 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
3423
3540
  if (access.name.text === "toString" &&
3424
3541
  call.arguments.nodes.length <= 1 &&
3425
3542
  !ownCallable &&
3543
+ !prototypeReceiver &&
3426
3544
  !(checkerUntyped && jsAssignsOwnToString(lowerer, access.expression))) {
3427
3545
  const argument = call.arguments.nodes[0];
3428
3546
  return {
@@ -3440,7 +3558,7 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
3440
3558
  // Every dyn kind's prototype chain declares valueOf, and the runtime
3441
3559
  // answers each kind's own: primitives and plain objects themselves, a
3442
3560
  // Date its time value, an own or inherited valueOf member its result.
3443
- if (access.name.text === "valueOf" && call.arguments.nodes.length === 0) {
3561
+ if (access.name.text === "valueOf" && call.arguments.nodes.length === 0 && !prototypeReceiver) {
3444
3562
  const webAssembly = lowerWebAssemblyValueOf(lowerer, access.expression, recv, locOf(call));
3445
3563
  if (webAssembly !== null)
3446
3564
  return webAssembly;
@@ -3537,9 +3655,13 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
3537
3655
  !ownToString &&
3538
3656
  !stringOnlyName)
3539
3657
  return null;
3540
- // Optional forms (`obj.cb?.()`, `obj?.cb()`) belong to the chain
3541
- // machinery's short-circuit semantics — not modeled here yet.
3542
- if (call.questionDotToken || access.questionDotToken)
3658
+ // An UNHANDLED `?.` step (`obj.cb?.()`, `obj?.cb()`) belongs to the chain
3659
+ // machinery's short-circuit semantics. Inside the guarded body of a chain
3660
+ // the active lowering has ALREADY proven the receiver present, so the
3661
+ // step is a plain read-and-call there — the same "read the member, call
3662
+ // it" shape below, with `dynCall` throwing Node's catchable
3663
+ // "obj.cb is not a function" for a present but non-callable member.
3664
+ if (lowerer.chainBlocked(call, access))
3543
3665
  return null;
3544
3666
  const loc = locOf(call);
3545
3667
  const receiverLocal = lowerer.declareHiddenLocal("%dynCallReceiver", DYN);
@@ -3604,7 +3726,24 @@ function lowerStringOrMemberCall(lowerer, call, access, recv) {
3604
3726
  const loc = locOf(call);
3605
3727
  const receiverLocal = lowerer.declareHiddenLocal("%dynCallReceiver", DYN);
3606
3728
  const receiver = varRef(receiverLocal.id, DYN, loc);
3607
- const isString = { kind: "dynTest", test: "string", value: receiver, type: BOOL, loc };
3729
+ const nameLit = { kind: "strLit", value: access.name.text, type: STRING, loc };
3730
+ const receiverIsString = {
3731
+ kind: "dynTest",
3732
+ test: "string",
3733
+ value: receiver,
3734
+ type: BOOL,
3735
+ loc,
3736
+ };
3737
+ // In a program that creates wrapper objects, a receiver whose member is
3738
+ // the builtin String.prototype method runs the string lowering on
3739
+ // ToString of the receiver, after the arguments, as the builtin does.
3740
+ // The member is read once: the check inspects the value the call read.
3741
+ const wrappers = (lowerer.createsWrappers ??= programCreatesWrappers(lowerer));
3742
+ const builtinLocal = wrappers ? lowerer.declareHiddenLocal("%dynCallStringMethod", BOOL) : null;
3743
+ const isString = builtinLocal
3744
+ ? { kind: "varRef", localId: builtinLocal.id, type: BOOL, loc }
3745
+ : receiverIsString;
3746
+ const stringLocal = wrappers ? lowerer.declareHiddenLocal("%dynCallString", DYN) : null;
3608
3747
  const calleeLocal = lowerer.declareHiddenLocal("%dynCallCallee", DYN);
3609
3748
  const callee = varRef(calleeLocal.id, DYN, loc);
3610
3749
  const stmts = [
@@ -3614,7 +3753,7 @@ function lowerStringOrMemberCall(lowerer, call, access, recv) {
3614
3753
  localId: calleeLocal.id,
3615
3754
  init: {
3616
3755
  kind: "ternary",
3617
- cond: isString,
3756
+ cond: receiverIsString,
3618
3757
  then: dynUndefinedExpr(loc),
3619
3758
  else_: {
3620
3759
  kind: "dynKeyGet",
@@ -3628,16 +3767,52 @@ function lowerStringOrMemberCall(lowerer, call, access, recv) {
3628
3767
  },
3629
3768
  loc,
3630
3769
  },
3770
+ ...(builtinLocal
3771
+ ? [
3772
+ {
3773
+ kind: "varDecl",
3774
+ localId: builtinLocal.id,
3775
+ init: {
3776
+ kind: "logical",
3777
+ op: "||",
3778
+ left: receiverIsString,
3779
+ right: {
3780
+ kind: "libCall",
3781
+ fn: "wrapper.isStringMethod",
3782
+ args: [callee, nameLit],
3783
+ type: BOOL,
3784
+ loc,
3785
+ },
3786
+ type: BOOL,
3787
+ loc,
3788
+ },
3789
+ loc,
3790
+ },
3791
+ ]
3792
+ : []),
3631
3793
  ];
3632
3794
  const args = call.arguments.nodes.map((node) => {
3633
- const value = lowerer.lowerExpr(node);
3795
+ const lowered = lowerer.lowerExpr(node);
3796
+ // A unit-typed argument (`f()` of a void function, a literal undefined
3797
+ // or null) has no local storage of its own: hold it as the dynamic
3798
+ // value both branches receive.
3799
+ const value = lowered.type.kind === "void" ||
3800
+ lowered.type.kind === "undefinedT" ||
3801
+ lowered.type.kind === "nullT"
3802
+ ? lowerer.coerceToExpected(lowered, DYN)
3803
+ : lowered;
3634
3804
  const local = lowerer.declareHiddenLocal("%dynCallArg", value.type);
3635
3805
  stmts.push({ kind: "varDecl", localId: local.id, init: value, loc: value.loc });
3636
3806
  return { node, value: varRef(local.id, value.type, value.loc) };
3637
3807
  });
3638
3808
  // String.prototype methods ignore arguments past the ones they read.
3639
3809
  const arity = DYN_STRING_ONLY_ARITY[access.name.text] ?? call.arguments.nodes.length;
3640
- const stringReceiver = () => ({ kind: "dynCheck", value: receiver, type: STRING, loc });
3810
+ const stringReceiver = () => ({
3811
+ kind: "dynCheck",
3812
+ value: stringLocal ? varRef(stringLocal.id, DYN, loc) : receiver,
3813
+ type: STRING,
3814
+ loc,
3815
+ });
3641
3816
  const lowerString = () => (call.arguments.nodes.length <= arity
3642
3817
  ? lowerRegexMethodCall(lowerer, call, access, stringReceiver)
3643
3818
  : null) ??
@@ -3659,7 +3834,35 @@ function lowerStringOrMemberCall(lowerer, call, access, recv) {
3659
3834
  kind: "ternary",
3660
3835
  cond: isString,
3661
3836
  then: stringCall
3662
- ? lowerer.coerceToExpected(stringCall, DYN)
3837
+ ? stringLocal
3838
+ ? {
3839
+ kind: "seqExpr",
3840
+ stmts: [
3841
+ {
3842
+ kind: "varDecl",
3843
+ localId: stringLocal.id,
3844
+ init: {
3845
+ kind: "ternary",
3846
+ cond: receiverIsString,
3847
+ then: receiver,
3848
+ else_: {
3849
+ kind: "libCall",
3850
+ fn: "wrapper.thisString",
3851
+ args: [receiver, nameLit],
3852
+ type: DYN,
3853
+ loc,
3854
+ },
3855
+ type: DYN,
3856
+ loc,
3857
+ },
3858
+ loc,
3859
+ },
3860
+ ],
3861
+ result: lowerer.coerceToExpected(stringCall, DYN),
3862
+ type: DYN,
3863
+ loc,
3864
+ }
3865
+ : lowerer.coerceToExpected(stringCall, DYN)
3663
3866
  : nodeThrowExpr(0, "SC1090", `method calls like '${ts.getTextOfNode(access)}' on a string are not supported yet [SC1090 at ${ts.getSourceFileOfNode(call).fileName}:${ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(call), ts.tokenStartOfNode(call)).line + 1}]`, DYN, loc),
3664
3867
  else_: memberCall,
3665
3868
  type: DYN,
@@ -4713,17 +4916,57 @@ function lowerPrimitiveProtoCall(lowerer, call, recv, name, memberSym) {
4713
4916
  }
4714
4917
  // Number.prototype.toLocaleString("en-US") — the spec makes it
4715
4918
  // NumberFormat(locale).format(this), so the en-US embedded formatter
4716
- // answers exactly. The unlowered forms fence by NAME: no locale (the
4717
- // host environment's default, which a compiled binary cannot carry),
4718
- // other locales (ICU data the binary does not embed), options bags.
4919
+ // answers exactly. Without a locale (or with `undefined`) the DEFAULT
4920
+ // locale answers, over the ICU data scr_intl.c loads; other locales and
4921
+ // options bags stay fenced.
4719
4922
  if (name === "toLocaleString" && recvKind === "f64") {
4720
- if (call.arguments.nodes.length === 0) {
4721
- lowerer.noLowering("Number.prototype.toLocaleString without a locale", call, "the default locale is the host environment's, which a compiled binary cannot carry — " +
4722
- 'pass it explicitly: x.toLocaleString("en-US")');
4923
+ // Exactly undefined (or void): what the absent form means. A union that
4924
+ // merely includes undefined may hold a locale at run time and falls
4925
+ // through to the refusal below.
4926
+ const isUndefined = (node) => {
4927
+ const flags = lowerer.typeOf(node).flags;
4928
+ return flags === ts.TypeFlags.Undefined || flags === ts.TypeFlags.Void;
4929
+ };
4930
+ const defaultLocale = call.arguments.nodes.length === 0 ||
4931
+ (call.arguments.nodes.length === 1 &&
4932
+ !ts.isSpreadElement(call.arguments.nodes[0]) &&
4933
+ isUndefined(call.arguments.nodes[0]));
4934
+ if (defaultLocale) {
4935
+ const operand = lowerer.lowerExpr(recv);
4936
+ if (operand.type.kind !== "f64")
4937
+ return null;
4938
+ const stmts = [];
4939
+ let formatted = operand;
4940
+ if (call.arguments.nodes.length === 1) {
4941
+ // An explicit undefined may be any expression that evaluates to it
4942
+ // (a call, a variable), so it still runs, after the receiver and
4943
+ // before the formatting: the receiver's value is read first, so an
4944
+ // argument that writes it does not change the number formatted. Its
4945
+ // unit value has no standalone representation, so it is coerced
4946
+ // into the dynamic slot every argument occupies.
4947
+ const receiver = lowerer.declareHiddenLocal("%localeReceiver", F64);
4948
+ stmts.push({ kind: "varDecl", localId: receiver.id, init: operand, loc });
4949
+ formatted = varRef(receiver.id, F64, loc);
4950
+ const arg = call.arguments.nodes[0];
4951
+ const value = lowerer.lowerExpr(arg);
4952
+ stmts.push({
4953
+ kind: "exprStmt",
4954
+ expr: value.type.kind === "void" ? value : lowerer.coerceInto(arg, value, DYN),
4955
+ loc,
4956
+ });
4957
+ }
4958
+ const call_ = {
4959
+ kind: "libCall",
4960
+ fn: "icu.numFormatDefault",
4961
+ args: [formatted],
4962
+ type: STRING,
4963
+ loc,
4964
+ };
4965
+ return stmts.length ? { kind: "seqExpr", stmts, result: call_, type: STRING, loc } : call_;
4723
4966
  }
4724
4967
  if (call.arguments.nodes.length > 1) {
4725
- lowerer.noLowering("Number.prototype.toLocaleString with an options bag", call, "the embedded data covers DEFAULT options only (decimal notation, up to 3 fraction " +
4726
- 'digits, grouping) — x.toLocaleString("en-US")');
4968
+ lowerer.noLowering("Number.prototype.toLocaleString with an options bag", call, "what lowers is the DEFAULT options shape (decimal notation, up to 3 fraction digits, " +
4969
+ "grouping) at the default locale or at en-US — omit the options bag");
4727
4970
  }
4728
4971
  const locNode = call.arguments.nodes[0];
4729
4972
  if (ts.isSpreadElement(locNode) ||
@@ -4731,8 +4974,8 @@ function lowerPrimitiveProtoCall(lowerer, call, recv, name, memberSym) {
4731
4974
  locNode.text !== "en-US") {
4732
4975
  lowerer.noLowering(!ts.isSpreadElement(locNode) && ts.isStringLiteralLike(locNode)
4733
4976
  ? `Number.prototype.toLocaleString at locale "${locNode.text}"`
4734
- : "Number.prototype.toLocaleString with a non-literal locale", locNode, '"en-US" (Node\'s default-build locale) is the one locale whose data the runtime embeds — ' +
4735
- "everything else is ICU data the binary does not carry");
4977
+ : "Number.prototype.toLocaleString with a non-literal locale", locNode, "what lowers is the default locale (no argument) and the composed en-US form — " +
4978
+ "other locales are ICU data the binary does not negotiate yet");
4736
4979
  }
4737
4980
  const operand = lowerer.lowerExpr(recv);
4738
4981
  if (operand.type.kind !== "f64")
@@ -6506,6 +6749,33 @@ export function recordKeysArrayCall(lowerer, receiver, argIr, shape, loc) {
6506
6749
  }
6507
6750
  body.push(...perKeyOrder(current, ref, walks, loc));
6508
6751
  body.push({ kind: "return", value: outRef, loc });
6752
+ // A record that kept undeclared keys answers for-in through its live
6753
+ // kept view, exactly as Object.keys does at its call site. Gated on
6754
+ // the shape being one a kept width spread builds (a shape that keeps
6755
+ // no source stays byte-identical to main) and on the shape holding a
6756
+ // source at all.
6757
+ if (lowerer.keyOrder.keptSourceShapes.has(argIr.shapeId) &&
6758
+ recordMayKeepSource(lowerer, argIr)) {
6759
+ body.unshift({
6760
+ kind: "if",
6761
+ cond: recordSourceTest(ref, loc),
6762
+ then: [
6763
+ {
6764
+ kind: "return",
6765
+ value: {
6766
+ kind: "libCall",
6767
+ fn: "dyn.objKeyStrings",
6768
+ args: [{ kind: "dynFrom", value: ref, liveRef: true, type: DYN, loc }],
6769
+ type: resultT,
6770
+ loc,
6771
+ },
6772
+ loc,
6773
+ },
6774
+ ],
6775
+ else_: null,
6776
+ loc,
6777
+ });
6778
+ }
6509
6779
  fn.body = body;
6510
6780
  };
6511
6781
  finalize();
@@ -6567,6 +6837,35 @@ export function recordHasOwnHelper(lowerer, shapeId, loc) {
6567
6837
  body,
6568
6838
  loc,
6569
6839
  });
6840
+ // A record that kept undeclared keys answers an undeclared key through
6841
+ // its kept view: the declared branches above stay exact (the table's
6842
+ // placeholders only fill declared names the record owns), and the
6843
+ // closed-shape `false` fallback becomes the view's own-key test when a
6844
+ // kept width spread builds this shape.
6845
+ if (!shape.indexValue && recordMayKeepSource(lowerer, recT)) {
6846
+ const fn = lowerer.liftedFns[lowerer.liftedFns.length - 1];
6847
+ lowerer.shapeOrderHelperFinalizers.push(() => {
6848
+ if (!lowerer.keyOrder.keptSourceShapes.has(shapeId))
6849
+ return;
6850
+ const last = fn.body[fn.body.length - 1];
6851
+ if (last.kind !== "return")
6852
+ return;
6853
+ last.value = {
6854
+ kind: "logical",
6855
+ op: "&&",
6856
+ left: recordSourceTest(rRef, loc),
6857
+ right: {
6858
+ kind: "libCall",
6859
+ fn: "dyn.hasOwn",
6860
+ args: [{ kind: "dynFrom", value: rRef, liveRef: true, type: DYN, loc }, kRef],
6861
+ type: BOOL,
6862
+ loc,
6863
+ },
6864
+ type: BOOL,
6865
+ loc,
6866
+ };
6867
+ });
6868
+ }
6570
6869
  return helper;
6571
6870
  }
6572
6871
  /** Whether `Object.assign(instance, record)` can copy every field of the
@@ -6839,6 +7138,44 @@ function isDynEntryPairsType(lowerer, t) {
6839
7138
  const field = (name) => shape.fields.find((f) => f.name === name)?.type;
6840
7139
  return field("0")?.kind === "string" && field("1")?.kind === "dyn";
6841
7140
  }
7141
+ /** True when the expression is statically a PLAIN OBJECT at runtime: a dyn
7142
+ * object literal, or a record (a literal, a clone, or any expression of a
7143
+ * record type, which dynFrom boxes field by field). Both build an ordinary
7144
+ * object whose fields are own data properties, which the plain-object
7145
+ * descriptor reader answers exactly. Every other expression (a variable of
7146
+ * any other type, a call, an array, a function) may be an object of any
7147
+ * kind with inherited fields, so it takes the entry points whose
7148
+ * ToPropertyDescriptor reads every object kind (dyn.definePropertyShapes
7149
+ * and its siblings). */
7150
+ export function isPlainObjectLiteral(expr) {
7151
+ if (expr.kind === "dynObjLit")
7152
+ return true;
7153
+ if (expr.kind !== "dynFrom")
7154
+ return false;
7155
+ const value = expr.value;
7156
+ return value.kind === "dynObjLit" || value.type.kind === "record";
7157
+ }
7158
+ /** True when the expression is a plain property-descriptor map for
7159
+ * Object.defineProperties or Object.create: a plain object
7160
+ * (isPlainObjectLiteral) whose every field is a plain object too. A dyn
7161
+ * literal's field values are checked with isPlainObjectLiteral and a
7162
+ * record's fields by their types, since dynFrom boxes a record-typed field
7163
+ * into an ordinary object. A map with any other field (`{ a: view }`, where
7164
+ * `view` is a DataView or an array) takes the any-object entry points. */
7165
+ export function isPlainDescriptorMap(expr, getRecord) {
7166
+ if (!isPlainObjectLiteral(expr))
7167
+ return false;
7168
+ const literal = expr.kind === "dynFrom" ? expr.value : expr;
7169
+ if (literal.kind === "dynObjLit")
7170
+ return (literal.fields ?? []).every((field) => isPlainObjectLiteral(field.value));
7171
+ if (literal.type.kind !== "record")
7172
+ return false;
7173
+ const shape = getRecord(literal.type.shapeId);
7174
+ return (shape !== undefined &&
7175
+ !shape.tuple &&
7176
+ shape.indexValue === undefined &&
7177
+ shape.fields.every((field) => field.type.kind === "record"));
7178
+ }
6842
7179
  function lowerObjectStaticCall(lowerer, call, access) {
6843
7180
  if (call.questionDotToken || access.questionDotToken)
6844
7181
  return null;
@@ -6883,6 +7220,16 @@ function lowerObjectStaticCall(lowerer, call, access) {
6883
7220
  object.type.kind === "bool" ||
6884
7221
  isUnitType(object.type))
6885
7222
  object = { kind: "dynFrom", value: object, type: DYN, loc: locOf(call) };
7223
+ // An array or class instance reflects through its own checked-dynamic
7224
+ // view (own fields and elements, in property order). A record keeps its
7225
+ // static key walk below when it has one — `getOwnPropertyNames` over a
7226
+ // fixed record is exactly Object.keys' construction, and boxing a typed
7227
+ // record would link the dynamic tier into a program that needs none of
7228
+ // it. The descriptor and symbol forms have no static walk, so a record
7229
+ // takes the view there.
7230
+ const staticWalk = member === "getOwnPropertyNames" && object.type.kind === "record";
7231
+ if (!staticWalk && object.type.kind !== "dyn" && lowerer.dynConvertible(object.type))
7232
+ object = lowerer.coerceToExpected(object, DYN);
6886
7233
  if (object.type.kind === "dyn")
6887
7234
  return {
6888
7235
  kind: "libCall",
@@ -7133,7 +7480,12 @@ function lowerObjectStaticCall(lowerer, call, access) {
7133
7480
  if (descriptors.type.kind === "dyn")
7134
7481
  return {
7135
7482
  kind: "libCall",
7136
- fn: "dyn.objCreateWithProperties",
7483
+ // A descriptor map built by an expression, or a literal map with a
7484
+ // descriptor built by one, may hold an array, a function or an
7485
+ // object with inherited fields.
7486
+ fn: isPlainDescriptorMap(descriptors, (id) => lowerer.shapes.get(id))
7487
+ ? "dyn.objCreateWithProperties"
7488
+ : "dyn.objCreateWithPropertiesShapes",
7137
7489
  args: [proto, descriptors],
7138
7490
  type: DYN,
7139
7491
  loc,
@@ -7147,6 +7499,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
7147
7499
  const prototype = lowerClassPrototypeAssign(lowerer, call);
7148
7500
  if (prototype)
7149
7501
  return prototype;
7502
+ // A standard-library prototype value as the target is a write through it.
7503
+ if (call.arguments.nodes.length > 0)
7504
+ fenceDatePrototypeWriteCall(lowerer, call.arguments.nodes[0]);
7150
7505
  if (isJsSourceFile(ts.getSourceFileOfNode(call)) &&
7151
7506
  call.arguments.nodes.length > 0 &&
7152
7507
  !call.arguments.nodes.some(ts.isSpreadElement)) {
@@ -7220,8 +7575,14 @@ function lowerObjectStaticCall(lowerer, call, access) {
7220
7575
  const sProbe = tryLowerExpression(lowerer, call.arguments.nodes[1]);
7221
7576
  // CHECKED-DYNAMIC target and source (the JS file-scope
7222
7577
  // object-literal identity story): the runtime dyn copy — own
7223
- // members of the source land on the target, which returns.
7224
- if (tProbe?.type.kind === "dyn") {
7578
+ // members of the source land on the target, which returns. A
7579
+ // CLASS-INSTANCE target joins them when the call's own RESULT type
7580
+ // is checked-dynamic: that is the `C & { extra }` intersection
7581
+ // (mapClassExpandoIntersection), whose value IS the instance, so
7582
+ // the same dyn copy writes the expando members onto its view and
7583
+ // answers the instance — identity and prototype intact.
7584
+ if (tProbe?.type.kind === "dyn" ||
7585
+ (tProbe?.type.kind === "object" && lowerer.mapTypeOf(lowerer.typeOf(call))?.kind === "dyn")) {
7225
7586
  const loc = locOf(call);
7226
7587
  const target = lowerer.lowerExpr(call.arguments.nodes[0]);
7227
7588
  const rawSource = lowerer.lowerExpr(call.arguments.nodes[1]);
@@ -7232,8 +7593,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
7232
7593
  if (ts.isObjectLiteralExpression(targetNode))
7233
7594
  fenceClassCopyIntoFreshObject(lowerer, call, call.arguments.nodes[1], rawSource);
7234
7595
  const source = lowerer.coerceToExpected(rawSource, DYN);
7235
- if (target.type.kind === "dyn" && source.type.kind === "dyn") {
7236
- return { kind: "libCall", fn: "dyn.assign", args: [target, source], type: DYN, loc };
7596
+ const dynTarget = target.type.kind === "dyn" ? target : lowerer.coerceToExpected(target, DYN);
7597
+ if (dynTarget.type.kind === "dyn" && source.type.kind === "dyn") {
7598
+ return { kind: "libCall", fn: "dyn.assign", args: [dynTarget, source], type: DYN, loc };
7237
7599
  }
7238
7600
  }
7239
7601
  // A CLASS-INSTANCE target and a plain record source whose fields are
@@ -7439,8 +7801,14 @@ function lowerObjectStaticCall(lowerer, call, access) {
7439
7801
  (member === "getOwnPropertyDescriptor" && call.arguments.nodes.length === 2)) {
7440
7802
  if (call.arguments.nodes.some((a) => ts.isSpreadElement(a)))
7441
7803
  return null;
7442
- let target = tryLowerExpression(lowerer, call.arguments.nodes[0]);
7443
7804
  const targetNode = call.arguments.nodes[0];
7805
+ // Object.defineProperty/defineProperties over a standard-library prototype
7806
+ // value: a typed Date never observes a dynamic definition there, so the
7807
+ // write keeps the fence it reached before the value existed. The
7808
+ // descriptor READ below is not a write and stays open.
7809
+ if (member === "defineProperty")
7810
+ fenceDatePrototypeWriteCall(lowerer, targetNode);
7811
+ let target = tryLowerExpression(lowerer, targetNode);
7444
7812
  // The checker gives C.prototype the instance type, but its lowered
7445
7813
  // value is the shared prototype table, not an instance to unbox.
7446
7814
  const prototypeTarget = ts.isPropertyAccessExpression(targetNode) &&
@@ -7517,7 +7885,10 @@ function lowerObjectStaticCall(lowerer, call, access) {
7517
7885
  return null;
7518
7886
  return {
7519
7887
  kind: "libCall",
7520
- fn: "dyn.defineProperty",
7888
+ // A descriptor built by an expression may be an array, a function or an
7889
+ // object with inherited fields, which only the any-object entry point
7890
+ // reads; a plain object literal keeps the plain-object reader.
7891
+ fn: isPlainObjectLiteral(descriptor) ? "dyn.defineProperty" : "dyn.definePropertyShapes",
7521
7892
  args: [target, key, descriptor],
7522
7893
  type: DYN,
7523
7894
  loc: locOf(call),
@@ -7533,6 +7904,10 @@ function lowerObjectStaticCall(lowerer, call, access) {
7533
7904
  if (member === "defineProperties" &&
7534
7905
  call.arguments.nodes.length === 2 &&
7535
7906
  !call.arguments.nodes.some((a) => ts.isSpreadElement(a))) {
7907
+ // A standard-library prototype value as the target is a write through it,
7908
+ // exactly like the defineProperty form above: a typed Date never observes
7909
+ // a definition made on the dynamic prototype object.
7910
+ fenceDatePrototypeWriteCall(lowerer, call.arguments.nodes[0]);
7536
7911
  const prototype = lowerClassPrototypeDescriptors(lowerer, call, member);
7537
7912
  if (prototype)
7538
7913
  return prototype;
@@ -7573,7 +7948,12 @@ function lowerObjectStaticCall(lowerer, call, access) {
7573
7948
  if (descs.type.kind === "dyn") {
7574
7949
  return {
7575
7950
  kind: "libCall",
7576
- fn: "dyn.defineProps",
7951
+ // As for Object.create above: a descriptor map built by an
7952
+ // expression, or a literal map with a descriptor built by one, takes
7953
+ // the any-object entry point.
7954
+ fn: isPlainDescriptorMap(descs, (id) => lowerer.shapes.get(id))
7955
+ ? "dyn.defineProps"
7956
+ : "dyn.definePropsShapes",
7577
7957
  args: [target, descs],
7578
7958
  type: DYN,
7579
7959
  loc: locOf(call),
@@ -9959,7 +10339,8 @@ function maybePromiseHandlerResult(lowerer, call, value, R) {
9959
10339
  }
9960
10340
  return stmt;
9961
10341
  }
9962
- /** `view.m(args)` where `view` is a `Pick<C, K>` / `Omit<C, K>` view of a
10342
+ /** `view.m(args)` where `view` is a `Pick<C, K>` / `Omit<C, K>` view (inline
10343
+ * or through type aliases, classViewOf) of a
9963
10344
  * program class C and `m` is one of C's GENERIC methods (its overloads
9964
10345
  * included): generic methods have no dispatchable method value, so the
9965
10346
  * view's live receiver is extracted as the C instance it holds (a checked
@@ -9967,12 +10348,10 @@ function maybePromiseHandlerResult(lowerer, call, value, R) {
9967
10348
  * text naming C) and the call monomorphizes statically against C, the
9968
10349
  * same lowering a C-typed receiver gets. Null for other receivers. */
9969
10350
  function pickViewGenericMethodCall(lowerer, call, access, recvTs) {
9970
- const alias = recvTs.getAliasSymbol();
9971
- if (alias === undefined || (ts.symbolName(alias) !== "Pick" && ts.symbolName(alias) !== "Omit"))
9972
- return null;
9973
- if (!alias.declarations.every((d) => ts.getSourceFileOfNode(d).isDeclarationFile))
10351
+ const view = classViewOf(lowerer.checker, recvTs);
10352
+ if (view === null)
9974
10353
  return null;
9975
- const source = recvTs.getAliasTypeArguments()[0];
10354
+ const source = view.source;
9976
10355
  const symbol = source?.getSymbol();
9977
10356
  const info = symbol ? lowerer.classBySymbol.get(symbol) : undefined;
9978
10357
  if (!info || call.questionDotToken || access.questionDotToken)
@@ -9989,7 +10368,7 @@ function pickViewGenericMethodCall(lowerer, call, access, recvTs) {
9989
10368
  if (lowered.type.kind === "object" &&
9990
10369
  lowered.type.className !== info.def.name &&
9991
10370
  !lowerer.isSubclassOf(lowered.type.className, info.def.name)) {
9992
- lowerer.unsupported("SC1090", access, `calling the generic method '${access.name.text}' through a '${ts.symbolName(alias)}' view of '${info.def.name}' that holds a '${lowerer.fmt(lowered.type)}'`);
10371
+ lowerer.unsupported("SC1090", access, `calling the generic method '${access.name.text}' through a '${view.name}' view of '${info.def.name}' that holds a '${lowerer.fmt(lowered.type)}'`);
9993
10372
  }
9994
10373
  const receiver = lowered.type.kind === "object"
9995
10374
  ? lowered