@scriptc/compiler 0.1.7 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +98 -39
- package/ambient/scriptc-overrides.d.ts +10 -6
- package/ambient/scriptc.d.ts +15 -0
- package/dist/backend/build-cache.d.ts +1 -3
- package/dist/backend/build-cache.js +3 -22
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cache-root.d.ts +3 -0
- package/dist/backend/cache-root.js +23 -0
- package/dist/backend/cache-root.js.map +1 -0
- package/dist/backend/cycle-analysis.d.ts +15 -0
- package/dist/backend/cycle-analysis.js +108 -0
- package/dist/backend/cycle-analysis.js.map +1 -0
- package/dist/backend/cycle-analysis.test.js +124 -0
- package/dist/backend/cycle-analysis.test.js.map +1 -0
- package/dist/backend/executable-features.d.ts +4 -0
- package/dist/backend/executable-features.js +42 -0
- package/dist/backend/executable-features.js.map +1 -0
- package/dist/backend/external-c.d.ts +5 -27
- package/dist/backend/external-c.js +5 -40
- package/dist/backend/external-c.js.map +1 -1
- package/dist/backend/ffi-callbacks.d.ts +2 -3
- package/dist/backend/ffi-callbacks.js +2 -3
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/library-identity-markers.d.ts +4 -9
- package/dist/backend/library-identity-markers.js +11 -49
- package/dist/backend/library-identity-markers.js.map +1 -1
- package/dist/backend/library-pack.d.ts +5 -0
- package/dist/backend/library-pack.js +123 -0
- package/dist/backend/library-pack.js.map +1 -0
- package/dist/backend/link-plan-core.d.ts +20 -0
- package/dist/backend/link-plan-core.js +18 -0
- package/dist/backend/link-plan-core.js.map +1 -0
- package/dist/backend/link-plan.d.ts +1 -1
- package/dist/backend/link-plan.js +16 -17
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/link-trace.d.ts +2 -0
- package/dist/backend/link-trace.js +24 -0
- package/dist/backend/link-trace.js.map +1 -0
- package/dist/backend/linker.js +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/literals.d.ts +9 -0
- package/dist/backend/literals.js +35 -0
- package/dist/backend/literals.js.map +1 -0
- package/dist/backend/literals.test.d.ts +1 -0
- package/dist/backend/literals.test.js +53 -0
- package/dist/backend/literals.test.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +2 -0
- package/dist/backend/llvm/blocks.js +9 -4
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/blocks.test.d.ts +1 -0
- package/dist/backend/llvm/blocks.test.js +91 -0
- package/dist/backend/llvm/blocks.test.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +14 -8
- package/dist/backend/llvm/classes.js +88 -30
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +5 -1
- package/dist/backend/llvm/common.js +45 -4
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/debug-info.js +2 -7
- package/dist/backend/llvm/debug-info.js.map +1 -1
- package/dist/backend/llvm/debug-info.test.d.ts +1 -0
- package/dist/backend/llvm/debug-info.test.js +110 -0
- package/dist/backend/llvm/debug-info.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +21 -2
- package/dist/backend/llvm/dyn.js +647 -251
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +596 -1
- package/dist/backend/llvm/emitter.js +769 -425
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.d.ts +1 -0
- package/dist/backend/llvm/emitter.test.js +179 -0
- package/dist/backend/llvm/emitter.test.js.map +1 -0
- package/dist/backend/llvm/expr-async.js +23 -14
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +2 -2
- package/dist/backend/llvm/expr-bytes.js +60 -31
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-callbacks.js +25 -22
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +136 -35
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +1 -1
- package/dist/backend/llvm/expr-containers.js +43 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +5 -260
- package/dist/backend/llvm/expr-control.js +10 -6
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -1
- package/dist/backend/llvm/expr-dispatch.js +2 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +78 -81
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-island.d.ts +1 -1
- package/dist/backend/llvm/expr-island.js +11 -7
- package/dist/backend/llvm/expr-island.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +62 -31
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +1 -1
- package/dist/backend/llvm/expr-records.d.ts +5 -1
- package/dist/backend/llvm/expr-records.js +54 -7
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +4 -4
- package/dist/backend/llvm/expr-stream-bridges.js +220 -131
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.d.ts +1 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js +55 -0
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -0
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +12 -12
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/layouts.d.ts +19 -0
- package/dist/backend/llvm/layouts.js +12 -0
- package/dist/backend/llvm/layouts.js.map +1 -0
- package/dist/backend/llvm/lib-abi.d.ts +19 -0
- package/dist/backend/llvm/lib-abi.js +82 -0
- package/dist/backend/llvm/lib-abi.js.map +1 -0
- package/dist/backend/llvm/lib-connect.d.ts +2 -0
- package/dist/backend/llvm/lib-connect.js +51 -0
- package/dist/backend/llvm/lib-connect.js.map +1 -0
- package/dist/backend/llvm/lib-datagram.d.ts +2 -0
- package/dist/backend/llvm/lib-datagram.js +135 -0
- package/dist/backend/llvm/lib-datagram.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.js +50 -6
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +30 -18
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.d.ts +2 -0
- package/dist/backend/llvm/lib-http2.js +215 -0
- package/dist/backend/llvm/lib-http2.js.map +1 -0
- package/dist/backend/llvm/lib-lookup.d.ts +2 -0
- package/dist/backend/llvm/lib-lookup.js +39 -0
- package/dist/backend/llvm/lib-lookup.js.map +1 -0
- package/dist/backend/llvm/lib-network.js +25 -2
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +44 -19
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +162 -3
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +3 -2
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/lib-test.d.ts +2 -0
- package/dist/backend/llvm/lib-test.js +34 -0
- package/dist/backend/llvm/lib-test.js.map +1 -0
- package/dist/backend/llvm/lib-tls.d.ts +2 -0
- package/dist/backend/llvm/lib-tls.js +82 -0
- package/dist/backend/llvm/lib-tls.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +10 -9
- package/dist/backend/llvm/shapes.js +42 -131
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/unsupported.d.ts +1 -0
- package/dist/backend/llvm/unsupported.js +1 -2
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.js +1 -7
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/mangle.d.ts +2 -2
- package/dist/backend/mangle.js +16 -5
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/{c/may-throw.d.ts → may-throw.d.ts} +1 -1
- package/dist/backend/{c/may-throw.js → may-throw.js} +51 -46
- package/dist/backend/may-throw.js.map +1 -0
- package/dist/backend/may-throw.test.d.ts +1 -0
- package/dist/backend/may-throw.test.js +58 -0
- package/dist/backend/may-throw.test.js.map +1 -0
- package/dist/backend/native-codegen-core.d.ts +22 -0
- package/dist/backend/native-codegen-core.js +44 -0
- package/dist/backend/native-codegen-core.js.map +1 -0
- package/dist/backend/native-codegen.d.ts +3 -19
- package/dist/backend/native-codegen.js +5 -44
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +2 -2
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +94 -0
- package/dist/backend/native-link-info-core.js +62 -0
- package/dist/backend/native-link-info-core.js.map +1 -0
- package/dist/backend/native-link-info.d.ts +3 -88
- package/dist/backend/native-link-info.js +12 -243
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +41 -146
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +12 -30
- package/dist/backend/native-toolchain.js +83 -233
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +77 -5
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/native-tools.d.ts +24 -0
- package/dist/backend/native-tools.js +33 -0
- package/dist/backend/native-tools.js.map +1 -0
- package/dist/backend/object-localize.js +19 -8
- package/dist/backend/object-localize.js.map +1 -1
- package/dist/backend/object-localize.test.js +22 -0
- package/dist/backend/object-localize.test.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +101 -0
- package/dist/backend/runtime-pack-core.js +172 -0
- package/dist/backend/runtime-pack-core.js.map +1 -0
- package/dist/backend/runtime-pack-native.d.ts +21 -0
- package/dist/backend/runtime-pack-native.js +73 -0
- package/dist/backend/runtime-pack-native.js.map +1 -0
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.d.ts +3 -83
- package/dist/backend/runtime-pack.js +8 -151
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +24 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.d.ts +22 -0
- package/dist/backend/target-diagnostics.js +108 -0
- package/dist/backend/target-diagnostics.js.map +1 -0
- package/dist/backend/target-platform.d.ts +15 -0
- package/dist/backend/target-platform.js +72 -0
- package/dist/backend/target-platform.js.map +1 -0
- package/dist/backend/targets.d.ts +13 -4
- package/dist/backend/targets.js +103 -34
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +72 -4
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/backend/toolchain-environment.d.ts +6 -0
- package/dist/backend/toolchain-environment.js +99 -0
- package/dist/backend/toolchain-environment.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +1 -9
- package/dist/backend/vendor-archives.js +2 -9
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +9 -0
- package/dist/backend/vendor-inputs.js +10 -0
- package/dist/backend/vendor-inputs.js.map +1 -0
- package/dist/backend/warm-cache.d.ts +3 -0
- package/dist/backend/warm-cache.js +41 -0
- package/dist/backend/warm-cache.js.map +1 -0
- package/dist/cli/command.d.ts +3 -0
- package/dist/cli/command.js +328 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/host.d.ts +24 -0
- package/dist/cli/host.js +2 -0
- package/dist/cli/host.js.map +1 -0
- package/dist/cli/output-options.d.ts +26 -0
- package/dist/cli/output-options.js +60 -0
- package/dist/cli/output-options.js.map +1 -0
- package/dist/cli/paths.d.ts +12 -0
- package/dist/cli/paths.js +42 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/usage.d.ts +74 -0
- package/dist/cli/usage.js +86 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/cli/wasi-paths.d.ts +8 -0
- package/dist/cli/wasi-paths.js +41 -0
- package/dist/cli/wasi-paths.js.map +1 -0
- package/dist/cli/wasi-runner.d.ts +2 -0
- package/dist/cli/wasi-runner.js +28 -0
- package/dist/cli/wasi-runner.js.map +1 -0
- package/dist/compat/fetch-profile.js +37 -7
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +162 -0
- package/dist/compile-types.js +2 -0
- package/dist/compile-types.js.map +1 -0
- package/dist/coverage/report.js +11 -5
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +5 -2
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.js +5 -10
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -4
- package/dist/executable/executable-cache.js +5 -6
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +16 -17
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +14 -0
- package/dist/executable/prepare.js +66 -0
- package/dist/executable/prepare.js.map +1 -0
- package/dist/ffi/ffi-manifest.d.ts +11 -4
- package/dist/ffi/ffi-manifest.js +170 -58
- package/dist/ffi/ffi-manifest.js.map +1 -1
- package/dist/ffi/ffi-manifest.test.d.ts +1 -0
- package/dist/ffi/ffi-manifest.test.js +111 -0
- package/dist/ffi/ffi-manifest.test.js.map +1 -0
- package/dist/format-integer.d.ts +3 -0
- package/dist/format-integer.js +14 -0
- package/dist/format-integer.js.map +1 -0
- package/dist/frontend/analysis.d.ts +5 -0
- package/dist/frontend/analysis.js +88 -0
- package/dist/frontend/analysis.js.map +1 -0
- package/dist/frontend/arguments-usage.d.ts +1 -3
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +1 -1
- package/dist/frontend/builtin-modules.js +1 -1
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/cjs-lexer.d.ts +4 -25
- package/dist/frontend/cjs-lexer.js +6 -806
- package/dist/frontend/cjs-lexer.js.map +1 -1
- package/dist/frontend/cjs-resolve.d.ts +5 -0
- package/dist/frontend/cjs-resolve.js +429 -0
- package/dist/frontend/cjs-resolve.js.map +1 -0
- package/dist/frontend/cjs-syntax.d.ts +26 -0
- package/dist/frontend/cjs-syntax.js +806 -0
- package/dist/frontend/cjs-syntax.js.map +1 -0
- package/dist/frontend/comptime-node.d.ts +4 -0
- package/dist/frontend/comptime-node.js +16 -0
- package/dist/frontend/comptime-node.js.map +1 -0
- package/dist/frontend/comptime-node.test.d.ts +1 -0
- package/dist/frontend/comptime-node.test.js +37 -0
- package/dist/frontend/comptime-node.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +3 -4
- package/dist/frontend/dts-paths.js +15 -8
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/fork-target.js +2 -2
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/helper-tokens.d.ts +1 -0
- package/dist/frontend/helper-tokens.js +147 -0
- package/dist/frontend/helper-tokens.js.map +1 -0
- package/dist/frontend/helper-tokens.test.d.ts +1 -0
- package/dist/frontend/helper-tokens.test.js +35 -0
- package/dist/frontend/helper-tokens.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.d.ts +5 -0
- package/dist/frontend/inferred-js-diagnostics.js +69 -0
- package/dist/frontend/inferred-js-diagnostics.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.d.ts +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +58 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -0
- package/dist/frontend/input-tracker.d.ts +5 -2
- package/dist/frontend/input-tracker.js +24 -3
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +23 -0
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lib-contract.js +32 -24
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/literal-values.d.ts +4 -0
- package/dist/frontend/literal-values.js +21 -0
- package/dist/frontend/literal-values.js.map +1 -0
- package/dist/frontend/literal-values.test.d.ts +1 -0
- package/dist/frontend/literal-values.test.js +91 -0
- package/dist/frontend/literal-values.test.js.map +1 -0
- package/dist/frontend/lowering/abstract-equality.d.ts +1 -1
- package/dist/frontend/lowering/abstract-equality.js +3 -0
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.js +11 -6
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +4 -1
- package/dist/frontend/lowering/array-values.js +43 -1
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/callback-arg.js +1 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -1
- package/dist/frontend/lowering/class-callbacks.d.ts +12 -0
- package/dist/frontend/lowering/class-callbacks.js +74 -0
- package/dist/frontend/lowering/class-callbacks.js.map +1 -0
- package/dist/frontend/lowering/class-construction.d.ts +12 -0
- package/dist/frontend/lowering/class-construction.js +156 -0
- package/dist/frontend/lowering/class-construction.js.map +1 -0
- package/dist/frontend/lowering/class-descriptors.d.ts +10 -0
- package/dist/frontend/lowering/class-descriptors.js +114 -0
- package/dist/frontend/lowering/class-descriptors.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +51 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1158 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.d.ts +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +93 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -0
- package/dist/frontend/lowering/class-instance-constructor.d.ts +7 -0
- package/dist/frontend/lowering/class-instance-constructor.js +67 -0
- package/dist/frontend/lowering/class-instance-constructor.js.map +1 -0
- package/dist/frontend/lowering/class-method-values.d.ts +13 -0
- package/dist/frontend/lowering/class-method-values.js +235 -0
- package/dist/frontend/lowering/class-method-values.js.map +1 -0
- package/dist/frontend/lowering/class-prototypes.d.ts +19 -0
- package/dist/frontend/lowering/class-prototypes.js +242 -0
- package/dist/frontend/lowering/class-prototypes.js.map +1 -0
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +66 -0
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -0
- package/dist/frontend/lowering/class-static-data.d.ts +6 -0
- package/dist/frontend/lowering/class-static-data.js +56 -0
- package/dist/frontend/lowering/class-static-data.js.map +1 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.d.ts +4 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.js +26 -0
- package/dist/frontend/lowering/containers/buffer-numeric-methods.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.d.ts +11 -7
- package/dist/frontend/lowering/containers/bytes.js +208 -163
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +2 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +58 -63
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.d.ts +7 -0
- package/dist/frontend/lowering/containers/string-replacement.js +217 -0
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -0
- package/dist/frontend/lowering/error-methods.d.ts +14 -0
- package/dist/frontend/lowering/error-methods.js +177 -0
- package/dist/frontend/lowering/error-methods.js.map +1 -0
- package/dist/frontend/lowering/expressions/global-symbols.d.ts +6 -0
- package/dist/frontend/lowering/expressions/global-symbols.js +11 -0
- package/dist/frontend/lowering/expressions/global-symbols.js.map +1 -0
- package/dist/frontend/lowering/expressions/native-proxy.d.ts +7 -0
- package/dist/frontend/lowering/expressions/native-proxy.js +51 -0
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.d.ts +6 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js +132 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -0
- package/dist/frontend/lowering/expressions/object-literals.d.ts +8 -8
- package/dist/frontend/lowering/expressions/object-literals.js +509 -183
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +3 -4
- package/dist/frontend/lowering/expressions/optional-chains.js +88 -24
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/try-lower-expression.js +1 -0
- package/dist/frontend/lowering/expressions/try-lower-expression.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-field-write.d.ts +8 -0
- package/dist/frontend/lowering/expressions/union-field-write.js +71 -0
- package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -0
- package/dist/frontend/lowering/function-context.d.ts +101 -0
- package/dist/frontend/lowering/function-context.js +109 -0
- package/dist/frontend/lowering/function-context.js.map +1 -0
- package/dist/frontend/lowering/generator-delegation.d.ts +7 -0
- package/dist/frontend/lowering/generator-delegation.js +85 -0
- package/dist/frontend/lowering/generator-delegation.js.map +1 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +11 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +143 -0
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +4 -1
- package/dist/frontend/lowering/lib-boundary.js +112 -20
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.test.d.ts +1 -0
- package/dist/frontend/lowering/lib-boundary.test.js +45 -0
- package/dist/frontend/lowering/lib-boundary.test.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +1 -1
- package/dist/frontend/lowering/lower-assert.d.ts +1 -1
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +18 -0
- package/dist/frontend/lowering/lower-builtin-values.js +249 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +33 -46
- package/dist/frontend/lowering/lower-builtins.js +676 -365
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +28 -22
- package/dist/frontend/lowering/lower-calls.js +1660 -412
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +95 -57
- package/dist/frontend/lowering/lower-classes.js +1491 -404
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
- package/dist/frontend/lowering/lower-comptime.js +23 -32
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +36 -32
- package/dist/frontend/lowering/lower-containers.js +925 -181
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.d.ts +1 -1
- package/dist/frontend/lowering/lower-dgram.js +3 -2
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.d.ts +1 -1
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +30 -1
- package/dist/frontend/lowering/lower-event-emitter.js +58 -26
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.d.ts +7 -1
- package/dist/frontend/lowering/lower-expando.js +14 -6
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +37 -13
- package/dist/frontend/lowering/lower-exprs.js +2163 -863
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +2 -5
- package/dist/frontend/lowering/lower-generators.js +88 -46
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +7 -0
- package/dist/frontend/lowering/lower-global-value.js +17 -0
- package/dist/frontend/lowering/lower-global-value.js.map +1 -0
- package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
- package/dist/frontend/lowering/lower-inspect.js +17 -8
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +7 -8
- package/dist/frontend/lowering/lower-island.js +66 -33
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.d.ts +2 -2
- package/dist/frontend/lowering/lower-mixins.js +5 -3
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +1 -1
- package/dist/frontend/lowering/lower-modules.js +445 -39
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-modules.test.js +39 -0
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -0
- package/dist/frontend/lowering/lower-namespaces.d.ts +1 -1
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-module.d.ts +1 -1
- package/dist/frontend/lowering/lower-node-module.js +13 -10
- package/dist/frontend/lowering/lower-node-module.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +1 -1
- package/dist/frontend/lowering/lower-server.js +6 -10
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +17 -17
- package/dist/frontend/lowering/lower-stmts.js +855 -514
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +1 -1
- package/dist/frontend/lowering/lower-stream.js +20 -11
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.d.ts +1 -1
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lower-url.d.ts +6 -0
- package/dist/frontend/lowering/lower-url.js +77 -0
- package/dist/frontend/lowering/lower-url.js.map +1 -0
- package/dist/frontend/lowering/lowerer.d.ts +140 -190
- package/dist/frontend/lowering/lowerer.js +1193 -712
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.d.ts +1 -0
- package/dist/frontend/lowering/lowerer.test.js +172 -0
- package/dist/frontend/lowering/lowerer.test.js.map +1 -0
- package/dist/frontend/lowering/native-ffi.d.ts +5 -0
- package/dist/frontend/lowering/native-ffi.js +40 -0
- package/dist/frontend/lowering/native-ffi.js.map +1 -0
- package/dist/frontend/lowering/object-enumeration-receiver.d.ts +7 -0
- package/dist/frontend/lowering/object-enumeration-receiver.js +33 -0
- package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -0
- package/dist/frontend/lowering/object-factory-new.d.ts +8 -0
- package/dist/frontend/lowering/object-factory-new.js +68 -0
- package/dist/frontend/lowering/object-factory-new.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.js +6 -1
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.js +2 -1
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-locals.d.ts +14 -0
- package/dist/frontend/lowering/runtime-optional-locals.js +41 -0
- package/dist/frontend/lowering/runtime-optional-locals.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.d.ts +1 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.js +85 -0
- package/dist/frontend/lowering/runtime-optional-locals.test.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.d.ts +8 -0
- package/dist/frontend/lowering/sanitize-class-types.js +79 -0
- package/dist/frontend/lowering/sanitize-class-types.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.d.ts +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js +60 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js.map +1 -0
- package/dist/frontend/lowering/static-this.d.ts +5 -1
- package/dist/frontend/lowering/static-this.js +28 -2
- package/dist/frontend/lowering/static-this.js.map +1 -1
- package/dist/frontend/lowering/string-index.d.ts +7 -0
- package/dist/frontend/lowering/string-index.js +39 -0
- package/dist/frontend/lowering/string-index.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +10 -3
- package/dist/frontend/lowering/surfaces.js +86 -37
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/symbol-fields.d.ts +22 -0
- package/dist/frontend/lowering/symbol-fields.js +183 -0
- package/dist/frontend/lowering/symbol-fields.js.map +1 -0
- package/dist/frontend/lowering/symbol-methods.d.ts +7 -0
- package/dist/frontend/lowering/symbol-methods.js +30 -0
- package/dist/frontend/lowering/symbol-methods.js.map +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.d.ts +12 -0
- package/dist/frontend/lowering/text-decoder-encoding.js +82 -0
- package/dist/frontend/lowering/text-decoder-encoding.js.map +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.d.ts +1 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.js +38 -0
- package/dist/frontend/lowering/text-decoder-encoding.test.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.d.ts +9 -0
- package/dist/frontend/lowering/union-narrow.js +59 -0
- package/dist/frontend/lowering/union-narrow.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.test.d.ts +1 -0
- package/dist/frontend/lowering/union-narrow.test.js +72 -0
- package/dist/frontend/lowering/union-narrow.test.js.map +1 -0
- package/dist/frontend/lowering/union-retag.d.ts +43 -0
- package/dist/frontend/lowering/union-retag.js +259 -0
- package/dist/frontend/lowering/union-retag.js.map +1 -0
- package/dist/frontend/lowering/union-retag.test.d.ts +1 -0
- package/dist/frontend/lowering/union-retag.test.js +405 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -0
- package/dist/frontend/lowering/unregistered-class-types.d.ts +14 -0
- package/dist/frontend/lowering/unregistered-class-types.js +94 -0
- package/dist/frontend/lowering/unregistered-class-types.js.map +1 -0
- package/dist/frontend/lowering/unregistered-class-types.test.d.ts +1 -0
- package/dist/frontend/lowering/unregistered-class-types.test.js +65 -0
- package/dist/frontend/lowering/unregistered-class-types.test.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +40 -0
- package/dist/frontend/lowering/width-lift.js +2 -0
- package/dist/frontend/lowering/width-lift.js.map +1 -0
- package/dist/frontend/module-syntax.d.ts +58 -0
- package/dist/frontend/module-syntax.js +123 -0
- package/dist/frontend/module-syntax.js.map +1 -0
- package/dist/frontend/module-syntax.test.d.ts +1 -0
- package/dist/frontend/module-syntax.test.js +78 -0
- package/dist/frontend/module-syntax.test.js.map +1 -0
- package/dist/frontend/npm-fetch-analysis.d.ts +17 -0
- package/dist/frontend/npm-fetch-analysis.js +100 -0
- package/dist/frontend/npm-fetch-analysis.js.map +1 -0
- package/dist/frontend/npm-fetch-analysis.test.d.ts +1 -0
- package/dist/frontend/npm-fetch-analysis.test.js +107 -0
- package/dist/frontend/npm-fetch-analysis.test.js.map +1 -0
- package/dist/frontend/npm-fetch-node.d.ts +2 -0
- package/dist/frontend/npm-fetch-node.js +12 -0
- package/dist/frontend/npm-fetch-node.js.map +1 -0
- package/dist/frontend/npm-fetch-syntax.d.ts +6 -0
- package/dist/frontend/npm-fetch-syntax.js +207 -0
- package/dist/frontend/npm-fetch-syntax.js.map +1 -0
- package/dist/frontend/npm-node.d.ts +10 -0
- package/dist/frontend/npm-node.js +14 -0
- package/dist/frontend/npm-node.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.d.ts +8 -0
- package/dist/frontend/npm-static-bundled-cjs.js +236 -0
- package/dist/frontend/npm-static-bundled-cjs.js.map +1 -0
- package/dist/frontend/npm-static-bundled-cjs.test.d.ts +1 -0
- package/dist/frontend/npm-static-bundled-cjs.test.js +69 -0
- package/dist/frontend/npm-static-bundled-cjs.test.js.map +1 -0
- package/dist/frontend/npm-static-declaration-syntax.d.ts +57 -0
- package/dist/frontend/npm-static-declaration-syntax.js +944 -0
- package/dist/frontend/npm-static-declaration-syntax.js.map +1 -0
- package/dist/frontend/npm-static-declarations.d.ts +11 -39
- package/dist/frontend/npm-static-declarations.js +22 -561
- package/dist/frontend/npm-static-declarations.js.map +1 -1
- package/dist/frontend/npm-static-declarations.test.js +245 -6
- package/dist/frontend/npm-static-declarations.test.js.map +1 -1
- package/dist/frontend/npm-static-prune.d.ts +1 -1
- package/dist/frontend/npm-static-prune.js +121 -38
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-prune.test.js +9 -1
- package/dist/frontend/npm-static-prune.test.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-host.d.ts +4 -0
- package/dist/frontend/npm-static-rewrite-host.js +179 -0
- package/dist/frontend/npm-static-rewrite-host.js.map +1 -0
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +16 -0
- package/dist/frontend/npm-static-rewrite-syntax.js +905 -0
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -0
- package/dist/frontend/npm-static-rewrite.d.ts +0 -5
- package/dist/frontend/npm-static-rewrite.js +2 -1079
- package/dist/frontend/npm-static-rewrite.js.map +1 -1
- package/dist/frontend/npm-static-subtyping.d.ts +5 -0
- package/dist/frontend/npm-static-subtyping.js +55 -0
- package/dist/frontend/npm-static-subtyping.js.map +1 -0
- package/dist/frontend/npm-static-subtyping.test.d.ts +1 -0
- package/dist/frontend/npm-static-subtyping.test.js +58 -0
- package/dist/frontend/npm-static-subtyping.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +7 -15
- package/dist/frontend/npm-static.js +19 -28
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +8 -69
- package/dist/frontend/npm.js +21 -361
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -2
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.d.ts +6 -0
- package/dist/frontend/pipeline-native.js +32 -0
- package/dist/frontend/pipeline-native.js.map +1 -0
- package/dist/frontend/pipeline.d.ts +54 -0
- package/dist/frontend/pipeline.js +382 -0
- package/dist/frontend/pipeline.js.map +1 -0
- package/dist/frontend/pipeline.test.d.ts +1 -0
- package/dist/frontend/pipeline.test.js +77 -0
- package/dist/frontend/pipeline.test.js.map +1 -0
- package/dist/frontend/program-analysis.d.ts +10 -0
- package/dist/frontend/program-analysis.js +14 -0
- package/dist/frontend/program-analysis.js.map +1 -0
- package/dist/frontend/program-node.d.ts +9 -0
- package/dist/frontend/program-node.js +48 -0
- package/dist/frontend/program-node.js.map +1 -0
- package/dist/frontend/program.d.ts +39 -20
- package/dist/frontend/program.js +393 -189
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +105 -2
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.d.ts +9 -0
- package/dist/frontend/provenance-core.js +435 -0
- package/dist/frontend/provenance-core.js.map +1 -0
- package/dist/frontend/provenance.d.ts +0 -4
- package/dist/frontend/provenance.js +4 -459
- package/dist/frontend/provenance.js.map +1 -1
- package/dist/frontend/resolve.d.ts +3 -1
- package/dist/frontend/resolve.js +6 -3
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.d.ts +4 -3
- package/dist/frontend/runtime-resolve.js +22 -18
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.test.js +53 -0
- package/dist/frontend/runtime-resolve.test.js.map +1 -1
- package/dist/frontend/services-node.d.ts +5 -0
- package/dist/frontend/services-node.js +19 -0
- package/dist/frontend/services-node.js.map +1 -0
- package/dist/frontend/services-node.test.d.ts +1 -0
- package/dist/frontend/services-node.test.js +70 -0
- package/dist/frontend/services-node.test.js.map +1 -0
- package/dist/frontend/services.d.ts +44 -0
- package/dist/frontend/services.js +90 -0
- package/dist/frontend/services.js.map +1 -0
- package/dist/frontend/services.test.d.ts +1 -0
- package/dist/frontend/services.test.js +174 -0
- package/dist/frontend/services.test.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +3 -3
- package/dist/frontend/ts7/adapter.js +14 -31
- package/dist/frontend/ts7/adapter.js.map +1 -1
- package/dist/frontend/ts7/api.d.ts +16 -0
- package/dist/frontend/ts7/api.js +24 -0
- package/dist/frontend/ts7/api.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.d.ts +31 -0
- package/dist/frontend/ts7/ast-bytes.js +137 -0
- package/dist/frontend/ts7/ast-bytes.js.map +1 -0
- package/dist/frontend/ts7/ast-bytes.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-bytes.test.js +73 -0
- package/dist/frontend/ts7/ast-bytes.test.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.generated.d.ts +353 -0
- package/dist/frontend/ts7/ast-guards.generated.js +1951 -0
- package/dist/frontend/ts7/ast-guards.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-guards.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-guards.test.js +43 -0
- package/dist/frontend/ts7/ast-guards.test.js.map +1 -0
- package/dist/frontend/ts7/ast-node.d.ts +194 -0
- package/dist/frontend/ts7/ast-node.js +448 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -0
- package/dist/frontend/ts7/ast-node.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-node.test.js +266 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -0
- package/dist/frontend/ts7/ast-schema.generated.d.ts +503 -0
- package/dist/frontend/ts7/ast-schema.generated.js +1446 -0
- package/dist/frontend/ts7/ast-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-text.d.ts +6 -0
- package/dist/frontend/ts7/ast-text.js +124 -0
- package/dist/frontend/ts7/ast-text.js.map +1 -0
- package/dist/frontend/ts7/ast-text.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-text.test.js +38 -0
- package/dist/frontend/ts7/ast-text.test.js.map +1 -0
- package/dist/frontend/ts7/ast-tokens.generated.d.ts +2 -0
- package/dist/frontend/ts7/ast-tokens.generated.js +155 -0
- package/dist/frontend/ts7/ast-tokens.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.d.ts +42 -0
- package/dist/frontend/ts7/ast-types.generated.d.ts +1615 -0
- package/dist/frontend/ts7/ast-types.generated.js +5 -0
- package/dist/frontend/ts7/ast-types.generated.js.map +1 -0
- package/dist/frontend/ts7/ast-types.js +3 -0
- package/dist/frontend/ts7/ast-types.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.d.ts +58 -0
- package/dist/frontend/ts7/ast-wire.js +267 -0
- package/dist/frontend/ts7/ast-wire.js.map +1 -0
- package/dist/frontend/ts7/ast-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/ast-wire.test.js +151 -0
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -0
- package/dist/frontend/ts7/ast.d.ts +14 -14
- package/dist/frontend/ts7/ast.js +25 -18
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/census-check.js +1 -0
- package/dist/frontend/ts7/census-check.js.map +1 -1
- package/dist/frontend/ts7/checker-cache.d.ts +48 -0
- package/dist/frontend/ts7/checker-cache.js +92 -0
- package/dist/frontend/ts7/checker-cache.js.map +1 -0
- package/dist/frontend/ts7/checker.d.ts +19 -46
- package/dist/frontend/ts7/checker.js +231 -161
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.d.ts +1 -0
- package/dist/frontend/ts7/checker.test.js +335 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -0
- package/dist/frontend/ts7/enums.d.ts +4 -27
- package/dist/frontend/ts7/enums.generated.d.ts +878 -0
- package/dist/frontend/ts7/enums.generated.js +1313 -0
- package/dist/frontend/ts7/enums.generated.js.map +1 -0
- package/dist/frontend/ts7/enums.js +4 -45
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/enums.test.d.ts +1 -0
- package/dist/frontend/ts7/enums.test.js +48 -0
- package/dist/frontend/ts7/enums.test.js.map +1 -0
- package/dist/frontend/ts7/native-api.d.ts +10 -0
- package/dist/frontend/ts7/native-api.js +10 -0
- package/dist/frontend/ts7/native-api.js.map +1 -0
- package/dist/frontend/ts7/native-host.d.ts +2 -0
- package/dist/frontend/ts7/native-host.js +11 -0
- package/dist/frontend/ts7/native-host.js.map +1 -0
- package/dist/frontend/ts7/native-process.d.ts +14 -0
- package/dist/frontend/ts7/native-process.js +62 -0
- package/dist/frontend/ts7/native-process.js.map +1 -0
- package/dist/frontend/ts7/program-adapter.d.ts +10 -98
- package/dist/frontend/ts7/program-adapter.js +16 -310
- package/dist/frontend/ts7/program-adapter.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +115 -0
- package/dist/frontend/ts7/program-host.js +347 -0
- package/dist/frontend/ts7/program-host.js.map +1 -0
- package/dist/frontend/ts7/program-host.test.d.ts +1 -0
- package/dist/frontend/ts7/program-host.test.js +207 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-api.d.ts +12 -0
- package/dist/frontend/ts7/rpc-api.js +23 -0
- package/dist/frontend/ts7/rpc-api.js.map +1 -0
- package/dist/frontend/ts7/rpc-client.d.ts +27 -0
- package/dist/frontend/ts7/rpc-client.js +102 -0
- package/dist/frontend/ts7/rpc-client.js.map +1 -0
- package/dist/frontend/ts7/rpc-client.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-client.test.js +133 -0
- package/dist/frontend/ts7/rpc-client.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-filesystem.d.ts +16 -0
- package/dist/frontend/ts7/rpc-filesystem.js +42 -0
- package/dist/frontend/ts7/rpc-filesystem.js.map +1 -0
- package/dist/frontend/ts7/rpc-filesystem.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-filesystem.test.js +89 -0
- package/dist/frontend/ts7/rpc-filesystem.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-process.d.ts +2 -0
- package/dist/frontend/ts7/rpc-process.js +148 -0
- package/dist/frontend/ts7/rpc-process.js.map +1 -0
- package/dist/frontend/ts7/rpc-process.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-process.test.js +29 -0
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -0
- package/dist/frontend/ts7/rpc-wire.d.ts +46 -0
- package/dist/frontend/ts7/rpc-wire.js +195 -0
- package/dist/frontend/ts7/rpc-wire.js.map +1 -0
- package/dist/frontend/ts7/rpc-wire.test.d.ts +1 -0
- package/dist/frontend/ts7/rpc-wire.test.js +168 -0
- package/dist/frontend/ts7/rpc-wire.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-checker.d.ts +137 -0
- package/dist/frontend/ts7/semantic-checker.js +221 -0
- package/dist/frontend/ts7/semantic-checker.js.map +1 -0
- package/dist/frontend/ts7/semantic-checker.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-checker.test.js +119 -0
- package/dist/frontend/ts7/semantic-checker.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-json.d.ts +5 -0
- package/dist/frontend/ts7/semantic-json.js +47 -0
- package/dist/frontend/ts7/semantic-json.js.map +1 -0
- package/dist/frontend/ts7/semantic-json.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-json.test.js +42 -0
- package/dist/frontend/ts7/semantic-json.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.d.ts +222 -0
- package/dist/frontend/ts7/semantic-model.js +423 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -0
- package/dist/frontend/ts7/semantic-model.test.d.ts +1 -0
- package/dist/frontend/ts7/semantic-model.test.js +322 -0
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -0
- package/dist/frontend/ts7/semantic-schema.generated.d.ts +283 -0
- package/dist/frontend/ts7/semantic-schema.generated.js +222 -0
- package/dist/frontend/ts7/semantic-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/semantic-types.d.ts +5 -0
- package/dist/frontend/ts7/semantic-types.js +2 -0
- package/dist/frontend/ts7/semantic-types.js.map +1 -0
- package/dist/frontend/ts7/session-cache.d.ts +17 -0
- package/dist/frontend/ts7/session-cache.js +97 -0
- package/dist/frontend/ts7/session-cache.js.map +1 -0
- package/dist/frontend/ts7/session-cache.test.d.ts +1 -0
- package/dist/frontend/ts7/session-cache.test.js +87 -0
- package/dist/frontend/ts7/session-cache.test.js.map +1 -0
- package/dist/frontend/ts7/session-path.d.ts +18 -0
- package/dist/frontend/ts7/session-path.js +203 -0
- package/dist/frontend/ts7/session-path.js.map +1 -0
- package/dist/frontend/ts7/session-path.test.d.ts +1 -0
- package/dist/frontend/ts7/session-path.test.js +34 -0
- package/dist/frontend/ts7/session-path.test.js.map +1 -0
- package/dist/frontend/ts7/session-schema.generated.d.ts +167 -0
- package/dist/frontend/ts7/session-schema.generated.js +5 -0
- package/dist/frontend/ts7/session-schema.generated.js.map +1 -0
- package/dist/frontend/ts7/session-timing.d.ts +50 -0
- package/dist/frontend/ts7/session-timing.js +61 -0
- package/dist/frontend/ts7/session-timing.js.map +1 -0
- package/dist/frontend/ts7/session-timing.test.d.ts +1 -0
- package/dist/frontend/ts7/session-timing.test.js +52 -0
- package/dist/frontend/ts7/session-timing.test.js.map +1 -0
- package/dist/frontend/ts7/session.d.ts +105 -0
- package/dist/frontend/ts7/session.js +233 -0
- package/dist/frontend/ts7/session.js.map +1 -0
- package/dist/frontend/ts7/session.test.d.ts +1 -0
- package/dist/frontend/ts7/session.test.js +215 -0
- package/dist/frontend/ts7/session.test.js.map +1 -0
- package/dist/frontend/ts7/source-parser-node.d.ts +6 -0
- package/dist/frontend/ts7/source-parser-node.js +15 -0
- package/dist/frontend/ts7/source-parser-node.js.map +1 -0
- package/dist/frontend/ts7/source-parser.d.ts +25 -0
- package/dist/frontend/ts7/source-parser.js +96 -0
- package/dist/frontend/ts7/source-parser.js.map +1 -0
- package/dist/frontend/ts7/source-parser.test.d.ts +1 -0
- package/dist/frontend/ts7/source-parser.test.js +151 -0
- package/dist/frontend/ts7/source-parser.test.js.map +1 -0
- package/dist/frontend/ts7/syntax.d.ts +3 -0
- package/dist/frontend/ts7/syntax.js +4 -0
- package/dist/frontend/ts7/syntax.js.map +1 -0
- package/dist/frontend/tsc-codes.js +3 -0
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +34 -18
- package/dist/frontend/type-mapper.js +552 -131
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.js +146 -2
- package/dist/frontend/type-mapper.test.js.map +1 -1
- package/dist/frontend/union-discriminants.d.ts +16 -0
- package/dist/frontend/union-discriminants.js +98 -0
- package/dist/frontend/union-discriminants.js.map +1 -0
- package/dist/frontend/union-discriminants.test.d.ts +1 -0
- package/dist/frontend/union-discriminants.test.js +182 -0
- package/dist/frontend/union-discriminants.test.js.map +1 -0
- package/dist/index.d.ts +7 -198
- package/dist/index.js +369 -1572
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +16 -4
- package/dist/ir/analysis.js +23 -4
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +15 -2
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/constant-tables.js +67 -49
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/control-flow.d.ts +6 -0
- package/dist/ir/control-flow.js +142 -0
- package/dist/ir/control-flow.js.map +1 -0
- package/dist/ir/control-flow.test.d.ts +1 -0
- package/dist/ir/control-flow.test.js +113 -0
- package/dist/ir/control-flow.test.js.map +1 -0
- package/dist/ir/integer-loops.js +7 -18
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-ranges.js +53 -27
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +334 -176
- package/dist/ir/ir.js +710 -903
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +162 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/scalar-records.js +165 -134
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +4 -2
- package/dist/ir/serialize.js +33 -14
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.d.ts +1 -0
- package/dist/ir/serialize.test.js +57 -0
- package/dist/ir/serialize.test.js.map +1 -0
- package/dist/ir/traverse.d.ts +41 -0
- package/dist/ir/traverse.js +660 -0
- package/dist/ir/traverse.js.map +1 -0
- package/dist/ir/traverse.test.d.ts +1 -0
- package/dist/ir/traverse.test.js +242 -0
- package/dist/ir/traverse.test.js.map +1 -0
- package/dist/ir/validate.js +2018 -1498
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +536 -2
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/cache-primitives.d.ts +2 -3
- package/dist/library/cache-primitives.js +4 -6
- package/dist/library/cache-primitives.js.map +1 -1
- package/dist/library/fence-eval.js +2 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.js +7 -6
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.d.ts +3 -2
- package/dist/library/library-cache.js +5 -17
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +54 -41
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/library-profile.d.ts +3 -1
- package/dist/library/library-profile.js +15 -6
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.d.ts +15 -0
- package/dist/library/prepare.js +584 -0
- package/dist/library/prepare.js.map +1 -0
- package/dist/library/semantic-source.d.ts +1 -1
- package/dist/library/semantic-source.js +8 -6
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/sidecar-validate.js +4 -4
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +2 -0
- package/dist/library/sidecar.js +10 -3
- package/dist/library/sidecar.js.map +1 -1
- package/dist/native/cache.d.ts +11 -0
- package/dist/native/cache.js +113 -0
- package/dist/native/cache.js.map +1 -0
- package/dist/native/cache.test.d.ts +1 -0
- package/dist/native/cache.test.js +66 -0
- package/dist/native/cache.test.js.map +1 -0
- package/dist/native/cli.d.ts +1 -0
- package/dist/native/cli.js +112 -0
- package/dist/native/cli.js.map +1 -0
- package/dist/native/compiler.d.ts +15 -0
- package/dist/native/compiler.js +336 -0
- package/dist/native/compiler.js.map +1 -0
- package/dist/native/compiler.test.d.ts +1 -0
- package/dist/native/compiler.test.js +174 -0
- package/dist/native/compiler.test.js.map +1 -0
- package/dist/native/comptime.d.ts +5 -0
- package/dist/native/comptime.js +73 -0
- package/dist/native/comptime.js.map +1 -0
- package/dist/native/comptime.test.d.ts +1 -0
- package/dist/native/comptime.test.js +65 -0
- package/dist/native/comptime.test.js.map +1 -0
- package/dist/native/executable-cache.d.ts +26 -0
- package/dist/native/executable-cache.js +228 -0
- package/dist/native/executable-cache.js.map +1 -0
- package/dist/native/executable-cache.test.d.ts +1 -0
- package/dist/native/executable-cache.test.js +151 -0
- package/dist/native/executable-cache.test.js.map +1 -0
- package/dist/native/file-identity.d.ts +4 -0
- package/dist/native/file-identity.js +14 -0
- package/dist/native/file-identity.js.map +1 -0
- package/dist/native/file-identity.test.d.ts +1 -0
- package/dist/native/file-identity.test.js +43 -0
- package/dist/native/file-identity.test.js.map +1 -0
- package/dist/native/library.d.ts +22 -0
- package/dist/native/library.js +83 -0
- package/dist/native/library.js.map +1 -0
- package/dist/native/prepare.d.ts +21 -0
- package/dist/native/prepare.js +174 -0
- package/dist/native/prepare.js.map +1 -0
- package/dist/native/prepare.test.d.ts +1 -0
- package/dist/native/prepare.test.js +70 -0
- package/dist/native/prepare.test.js.map +1 -0
- package/dist/native/sanitizer.d.ts +11 -0
- package/dist/native/sanitizer.js +137 -0
- package/dist/native/sanitizer.js.map +1 -0
- package/dist/native/sanitizer.test.d.ts +1 -0
- package/dist/native/sanitizer.test.js +58 -0
- package/dist/native/sanitizer.test.js.map +1 -0
- package/dist/native/task.d.ts +4 -0
- package/dist/native/task.js +16 -0
- package/dist/native/task.js.map +1 -0
- package/dist/native/task.test.d.ts +1 -0
- package/dist/native/task.test.js +17 -0
- package/dist/native/task.test.js.map +1 -0
- package/dist/native/toolchain.d.ts +45 -0
- package/dist/native/toolchain.js +94 -0
- package/dist/native/toolchain.js.map +1 -0
- package/dist/native/toolchain.test.d.ts +1 -0
- package/dist/native/toolchain.test.js +85 -0
- package/dist/native/toolchain.test.js.map +1 -0
- package/dist/startup-cache.d.ts +1 -1
- package/dist/startup-cache.js +2 -5
- package/dist/startup-cache.js.map +1 -1
- package/dist/timing.d.ts +4 -0
- package/dist/timing.js +19 -0
- package/dist/timing.js.map +1 -0
- package/dist/wasi-paths.js +10 -7
- package/dist/wasi-paths.js.map +1 -1
- package/package.json +28 -19
- package/surface-manifest.json +107 -98
- package/dist/backend/c/async.d.ts +0 -171
- package/dist/backend/c/async.js +0 -1317
- package/dist/backend/c/async.js.map +0 -1
- package/dist/backend/c/c-emitter.d.ts +0 -536
- package/dist/backend/c/c-emitter.js +0 -1932
- package/dist/backend/c/c-emitter.js.map +0 -1
- package/dist/backend/c/exprs.d.ts +0 -15
- package/dist/backend/c/exprs.js +0 -8847
- package/dist/backend/c/exprs.js.map +0 -1
- package/dist/backend/c/island.d.ts +0 -45
- package/dist/backend/c/island.js +0 -281
- package/dist/backend/c/island.js.map +0 -1
- package/dist/backend/c/may-throw.js.map +0 -1
- package/dist/backend/c/shapes.d.ts +0 -142
- package/dist/backend/c/shapes.js +0 -603
- package/dist/backend/c/shapes.js.map +0 -1
- package/dist/backend/c/stmts.d.ts +0 -76
- package/dist/backend/c/stmts.js +0 -1108
- package/dist/backend/c/stmts.js.map +0 -1
- package/dist/backend/c/types.d.ts +0 -71
- package/dist/backend/c/types.js +0 -459
- package/dist/backend/c/types.js.map +0 -1
- package/dist/backend/c/types.test.js +0 -32
- package/dist/backend/c/types.test.js.map +0 -1
- package/dist/backend/c/walkers.d.ts +0 -134
- package/dist/backend/c/walkers.js +0 -1772
- package/dist/backend/c/walkers.js.map +0 -1
- /package/dist/backend/{c/types.test.d.ts → cycle-analysis.test.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { compilationTiming } from "./timing.js";
|
|
2
|
+
import { prepareExecutableModule } from "./executable/prepare.js";
|
|
3
|
+
import { prepareLibrary, libraryLocalizeSymbols, libraryWasmExports, libraryWasmRefusal } from "./library/prepare.js";
|
|
4
|
+
import { analyzeWithFrontend } from "./frontend/analysis.js";
|
|
5
|
+
import { llvmRefusalDiag, targetRefusalDiag } from "./backend/target-diagnostics.js";
|
|
6
|
+
import { compilePackedLibrary } from "./backend/library-pack.js";
|
|
1
7
|
import { InternalCompilerError } from "./errors.js";
|
|
2
|
-
import { mkdir,
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
8
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
4
9
|
import { basename, dirname, join, resolve } from "node:path";
|
|
5
10
|
import { clearCcCaches, configuredTargetPlatform } from "./backend/native-toolchain.js";
|
|
6
11
|
import { buildCacheRoot, prepareBuildCacheRoot, pruneBuildCache } from "./backend/build-cache.js";
|
|
7
|
-
import {
|
|
8
|
-
import { emitCModule } from "./backend/c/c-emitter.js";
|
|
12
|
+
import { CcCompileError, compileExternalC, compileExternalCLibrary, executableNativeEnvironmentFingerprint, mobileLibraryTarget, mobileTargetRefusal, resolveCc, } from "./backend/external-c.js";
|
|
9
13
|
import { emitLlvmModule, LlvmUnsupportedError } from "./backend/llvm/emitter.js";
|
|
10
14
|
import { emitNativeArtifact, NativeCodegenError } from "./backend/native-codegen.js";
|
|
11
15
|
import { privateSiblingPath } from "./backend/build-cache.js";
|
|
@@ -16,40 +20,31 @@ import { RuntimePackError } from "./backend/runtime-pack.js";
|
|
|
16
20
|
import { createNativeLinkPlan } from "./backend/link-plan.js";
|
|
17
21
|
import { executableLinkerEnvironmentFingerprint, linkNativeExecutable, platformLinkerSupportsPersistentCache, resolvePlatformLinker, } from "./backend/linker.js";
|
|
18
22
|
import { splitLlvmLibraryProgram, splitLlvmProgram } from "./backend/llvm/split.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { buildSidecar, canonicalModuleGraph, canonicalPath, clearSidecarCaches, compilerReleaseVersion, libraryIdentityHashes, updateSidecarIdentity, } from "./library/sidecar.js";
|
|
26
|
-
import { validateSidecar } from "./library/sidecar-validate.js";
|
|
27
|
-
import { entryFunctionExports } from "./frontend/lib-exports.js";
|
|
28
|
-
import { entryContractFacts } from "./frontend/lib-contract.js";
|
|
29
|
-
import { moduleLibAsyncSurface, moduleLibNondeterministicSurface, moduleEmbedsBuiltin, moduleEmbedsCompressedNpm, moduleUsesAssert, moduleUsesCopying, moduleUsesDc, moduleUsesDgram, moduleUsesDynAsync, moduleUsesDynInvoke, moduleUsesEmitter, moduleUsesFetch, moduleUsesFileHandle, moduleUsesFsWatch, moduleUsesHttp2, moduleUsesHttpServer, moduleUsesInspect, moduleUsesLegacyTextDecoder, moduleUsesNet, moduleUsesNodeTest, moduleUsesParseArgs, moduleUsesProcessEvents, moduleUsesQs, moduleUsesRegex, moduleUsesSearchParams, moduleUsesStream, moduleUsesSymbol, moduleUsesTls, moduleUsesTlsCa, moduleUsesZlib } from "./ir/ir.js";
|
|
30
|
-
import { moduleUsesBigInt } from "./ir/ir.js";
|
|
23
|
+
import { emitLibraryIdentityLines, replaceLibraryIdentity, stripLibraryIdentity } from "./backend/library-identity-markers.js";
|
|
24
|
+
import { ffiNativeBuildDiag, iceDiag, nativeCodegenDiag } from "./diagnostics/diagnostic.js";
|
|
25
|
+
import { loadLibraryProfile } from "./library/library-profile.js";
|
|
26
|
+
import { clearFenceEvalCaches, decorateLibraryRefusals } from "./library/fence-eval.js";
|
|
27
|
+
import { canonicalModuleGraph, clearSidecarCaches, compilerReleaseVersion, libraryIdentityHashes, updateSidecarIdentity, } from "./library/sidecar.js";
|
|
28
|
+
import { moduleRuntimeFeatures } from "./ir/ir.js";
|
|
31
29
|
import { serializeModule } from "./ir/serialize.js";
|
|
32
30
|
import { validateModule } from "./ir/validate.js";
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
31
|
+
import { loadProgram } from "./frontend/program-node.js";
|
|
32
|
+
import { runFrontend } from "./frontend/pipeline.js";
|
|
35
33
|
import { provenanceSources } from "./frontend/provenance-registry.js";
|
|
36
|
-
import { clearResolveCaches
|
|
37
|
-
import { isJsSourceFileName } from "./frontend/tsc-codes.js";
|
|
38
|
-
import { isRelativeSpecifier, packageNameOfSpecifier } from "./frontend/workspace-registry.js";
|
|
39
|
-
import { lowerToIr } from "./frontend/lowering/lowerer.js";
|
|
34
|
+
import { clearResolveCaches } from "./frontend/resolve.js";
|
|
40
35
|
import { loadFfiProfile } from "./ffi/ffi-manifest.js";
|
|
41
|
-
import {
|
|
36
|
+
import { executableLinkFeatures } from "./backend/executable-features.js";
|
|
42
37
|
import { FrontendInputTracker, trackedReadFile } from "./frontend/input-tracker.js";
|
|
43
38
|
import { libraryFrontendImplementationFingerprint, publishEarlyLibraryCache, readEarlyLibraryCache, readSemanticLibraryCache } from "./library/library-cache.js";
|
|
44
|
-
import { createSourceLineRebaser } from "./library/semantic-source.js";
|
|
45
39
|
import { publishEarlyExecutableCache, publishEarlyExecutableRoute, readEarlyExecutableCache } from "./executable/executable-cache.js";
|
|
46
40
|
import { compilerImplementationIdentity } from "./library/compiler-self-identity.js";
|
|
47
41
|
export const VERSION = "0.0.1";
|
|
48
42
|
export { EXTERNAL_OBJECT_ABI_STABILITY, RUNTIME_ABI_MARKER, RUNTIME_ABI_VERSION, } from "./backend/runtime-abi.js";
|
|
49
43
|
export { InternalCompilerError } from "./errors.js";
|
|
50
|
-
export { compileExternalC as compileC, compileExternalC, runtimeSrcDir,
|
|
44
|
+
export { compileExternalC as compileC, compileExternalC, runtimeSrcDir, } from "./backend/external-c.js";
|
|
45
|
+
export { warmNativeCaches } from "./backend/warm-cache.js";
|
|
51
46
|
export { ANDROID_MIN_API, IPHONEOS_MIN_VERSION, isAndroidTarget, isIosTarget, isMobileTarget, mobileLibraryTarget, mobileTargetRefusal } from "./backend/external-c.js";
|
|
52
|
-
export {
|
|
47
|
+
export { emitLlvmModule } from "./backend/llvm/emitter.js";
|
|
53
48
|
export { renderDiagnostics, renderDiagnostics as renderAll, renderDiagnostic, } from "./diagnostics/render.js";
|
|
54
49
|
export { renderCoverage } from "./coverage/report.js";
|
|
55
50
|
export { generateSurfaceManifest, renderSurfaceManifest, MANIFEST_SCHEMA_VERSION, } from "./coverage/surface-manifest.js";
|
|
@@ -64,134 +59,11 @@ export { abiExportSuffixes, buildSidecar, canonicalModuleGraph, canonicalPath, c
|
|
|
64
59
|
export { validateSidecar } from "./library/sidecar-validate.js";
|
|
65
60
|
export { BUILD_ID_SEED, SOURCE_HASH_SEED, hex16, lengthPrefixedStream, wyhash64 } from "./library/wyhash.js";
|
|
66
61
|
export { ISLAND_SURFACE, STATIC_MATH_PROPS } from "./frontend/lowering/surfaces.js";
|
|
67
|
-
export { ambientDtsPath, isExactExternalTypeSpecifier, overridesDtsPath } from "./frontend/program.js";
|
|
62
|
+
export { ambientDtsPath, isExactExternalTypeSpecifier, overridesDtsPath } from "./frontend/program-node.js";
|
|
68
63
|
export { resolveProvenanceSources } from "./frontend/provenance.js";
|
|
69
64
|
export { wasiGuestPath } from "./wasi-paths.js";
|
|
70
65
|
export { setProvenanceSources, } from "./frontend/provenance-registry.js";
|
|
71
66
|
export * as ir from "./ir/ir.js";
|
|
72
|
-
/** The LLVM backend's tier refusal as a diagnostic. SC3xxx = backend
|
|
73
|
-
* coverage (the program is fine — this backend doesn't compile it yet);
|
|
74
|
-
* the parenthesized kind tag is machine-readable for the differential
|
|
75
|
-
* harness's histogram. */
|
|
76
|
-
function llvmRefusalDiag(err, entryPath) {
|
|
77
|
-
return {
|
|
78
|
-
code: "SC3001",
|
|
79
|
-
message: err.message,
|
|
80
|
-
loc: err.loc ?? { file: entryPath, start: 0, end: 0 },
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/** A valid IR surface the explicitly-selected code generator cannot host.
|
|
84
|
-
* SC3001 is backend coverage (as with an LLVM tier refusal), not a target
|
|
85
|
-
* capability gap: wasm32-wasi's production LLVM lane still accepts it. */
|
|
86
|
-
function backendRefusalDiag(backend, target, surface, loc) {
|
|
87
|
-
return {
|
|
88
|
-
code: "SC3001",
|
|
89
|
-
message: `${backend} backend does not support ${surface} for ${target}; use --backend llvm`,
|
|
90
|
-
loc,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
/** A valid program surface that the selected execution target cannot host.
|
|
94
|
-
* SC3xxx stays the backend/target-coverage family: source semantics are
|
|
95
|
-
* valid, but this target deliberately refuses them instead of emitting a
|
|
96
|
-
* binary that traps later. */
|
|
97
|
-
function targetRefusalDiag(target, surface, loc) {
|
|
98
|
-
return {
|
|
99
|
-
code: "SC3002",
|
|
100
|
-
message: `${target} target does not support ${surface}`,
|
|
101
|
-
loc,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
/** APIs that require host capabilities absent from portable WASI Preview 1.
|
|
105
|
-
* These are target diagnostics, not backend-tier gaps: the same language IR
|
|
106
|
-
* (including async, generators, and the dynamic island) is otherwise valid.
|
|
107
|
-
* Keep the fine-grained walk first so diagnostics point at the API use; the
|
|
108
|
-
* embedded-module checks are the entry-anchored safety net for island code. */
|
|
109
|
-
function moduleWasiUnavailableSurface(mod) {
|
|
110
|
-
const entryLoc = { file: mod.sourceFile, start: 0, end: 0 };
|
|
111
|
-
const prefixes = [
|
|
112
|
-
["cp.", "child processes (WASI Preview 1 has no process-spawning API)"],
|
|
113
|
-
["child.", "child processes (WASI Preview 1 has no process-spawning API)"],
|
|
114
|
-
["spawnRes.", "child processes (WASI Preview 1 has no process-spawning API)"],
|
|
115
|
-
["net.", "network sockets (WASI Preview 1 has no socket API)"],
|
|
116
|
-
["http.", "network sockets (WASI Preview 1 has no socket API)"],
|
|
117
|
-
["https.", "network sockets (WASI Preview 1 has no socket API)"],
|
|
118
|
-
["http2.", "network sockets (WASI Preview 1 has no socket API)"],
|
|
119
|
-
["h2.", "network sockets (WASI Preview 1 has no socket API)"],
|
|
120
|
-
["dgram.", "network sockets (WASI Preview 1 has no socket API)"],
|
|
121
|
-
["dns.", "network sockets (WASI Preview 1 has no socket API)"],
|
|
122
|
-
["tls.", "network sockets (WASI Preview 1 has no socket API)"],
|
|
123
|
-
["fetch.", "network-backed fetch (WASI Preview 1 has no socket API)"],
|
|
124
|
-
["fs.watch", "filesystem watching (WASI Preview 1 has no notification API)"],
|
|
125
|
-
["watcher.", "filesystem watching (WASI Preview 1 has no notification API)"],
|
|
126
|
-
];
|
|
127
|
-
const kinds = new Map([
|
|
128
|
-
["child", "child processes (WASI Preview 1 has no process-spawning API)"],
|
|
129
|
-
["spawnRes", "child processes (WASI Preview 1 has no process-spawning API)"],
|
|
130
|
-
["childStream", "child processes (WASI Preview 1 has no process-spawning API)"],
|
|
131
|
-
["childWriter", "child processes (WASI Preview 1 has no process-spawning API)"],
|
|
132
|
-
["netServer", "network sockets (WASI Preview 1 has no socket API)"],
|
|
133
|
-
["netSocket", "network sockets (WASI Preview 1 has no socket API)"],
|
|
134
|
-
["http2Session", "network sockets (WASI Preview 1 has no socket API)"],
|
|
135
|
-
["http2Stream", "network sockets (WASI Preview 1 has no socket API)"],
|
|
136
|
-
["dgramSocket", "network sockets (WASI Preview 1 has no socket API)"],
|
|
137
|
-
["fsWatcher", "filesystem watching (WASI Preview 1 has no notification API)"],
|
|
138
|
-
["httpReq", "network sockets (WASI Preview 1 has no socket API)"],
|
|
139
|
-
["httpRes", "network sockets (WASI Preview 1 has no socket API)"],
|
|
140
|
-
["httpClientReq", "network sockets (WASI Preview 1 has no socket API)"],
|
|
141
|
-
["secureCtx", "network sockets (WASI Preview 1 has no socket API)"],
|
|
142
|
-
]);
|
|
143
|
-
let found = null;
|
|
144
|
-
const visit = (value, inheritedLoc) => {
|
|
145
|
-
if (found !== null || value === null || typeof value !== "object")
|
|
146
|
-
return;
|
|
147
|
-
if (Array.isArray(value)) {
|
|
148
|
-
for (const item of value)
|
|
149
|
-
visit(item, inheritedLoc);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
const node = value;
|
|
153
|
-
const loc = node.loc ?? inheritedLoc;
|
|
154
|
-
if (typeof node.kind === "string") {
|
|
155
|
-
const kindSurface = kinds.get(node.kind);
|
|
156
|
-
if (kindSurface !== undefined) {
|
|
157
|
-
found = { surface: kindSurface, loc };
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (node.kind === "libCall" && typeof node.fn === "string") {
|
|
161
|
-
if (node.fn === "process.kill" || node.fn === "process.killNum" ||
|
|
162
|
-
node.fn === "process.onSignal" || node.fn === "process.offSignal") {
|
|
163
|
-
found = { surface: "OS signals (WASI Preview 1 has no signal API)", loc };
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
if (node.fn === "os.networkInterfaces") {
|
|
167
|
-
found = { surface: "network-interface enumeration (WASI Preview 1 has no interface API)", loc };
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
for (const [prefix, surface] of prefixes) {
|
|
171
|
-
if (node.fn.startsWith(prefix)) {
|
|
172
|
-
found = { surface, loc };
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
for (const key of Object.keys(value)) {
|
|
179
|
-
visit(value[key], loc);
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
visit(mod, entryLoc);
|
|
183
|
-
if (found !== null)
|
|
184
|
-
return found;
|
|
185
|
-
if (moduleUsesFetch(mod)) {
|
|
186
|
-
return { surface: "network-backed fetch (WASI Preview 1 has no socket API)", loc: entryLoc };
|
|
187
|
-
}
|
|
188
|
-
for (const builtin of ["node:http", "node:https", "node:net", "node:tls"]) {
|
|
189
|
-
if (moduleEmbedsBuiltin(mod, builtin)) {
|
|
190
|
-
return { surface: `${builtin} networking (WASI Preview 1 has no socket API)`, loc: entryLoc };
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
67
|
/** Clang may print every warning from the generated/runtime translation
|
|
196
68
|
* units before the actionable linker failure. Keep the source diagnostic
|
|
197
69
|
* precise by starting at the first portable linker marker; if the driver
|
|
@@ -204,19 +76,9 @@ function ffiNativeBuildDetail(err) {
|
|
|
204
76
|
return (`${err.driver} ${linkerMarker >= 0 ? "could not link the generated program" : "failed while building the generated program"}` +
|
|
205
77
|
(output.length > 0 ? `:\n${output}` : ""));
|
|
206
78
|
}
|
|
207
|
-
/**
|
|
208
|
-
* cross compile, the host's otherwise. The frontend needs it too (the
|
|
209
|
-
* whole program compiles for ONE platform, so path.sep / os.EOL literals
|
|
210
|
-
* and the path-module binding are compile-time constants); a malformed
|
|
211
|
-
* SCRIPTC_CC/SCRIPTC_TARGET combination reports at compileC exactly as
|
|
212
|
-
* before, so analysis falls back to the host here rather than throwing. */
|
|
79
|
+
/** Platform semantics depend on the output target, without compiler discovery. */
|
|
213
80
|
export function buildTargetPlatform(env = process.env) {
|
|
214
|
-
|
|
215
|
-
return targetPlatform(resolveCc(env));
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
return process.platform;
|
|
219
|
-
}
|
|
81
|
+
return configuredTargetPlatform(env);
|
|
220
82
|
}
|
|
221
83
|
/** Target-platform classification without compiler or SDK discovery. Source
|
|
222
84
|
* artifacts need target semantics for lowering, but do not need a native
|
|
@@ -224,429 +86,11 @@ export function buildTargetPlatform(env = process.env) {
|
|
|
224
86
|
export function sourceTargetPlatform(env = process.env) {
|
|
225
87
|
return configuredTargetPlatform(env);
|
|
226
88
|
}
|
|
227
|
-
/** --npm-static=auto (and library mode's mandatory twin): one throwaway
|
|
228
|
-
* load finds every bare npm import the program's own modules make, then
|
|
229
|
-
* the eligibility heuristics (npm-static.ts) pick the packages whose
|
|
230
|
-
* shipped JS is worth attempting. Rejected candidates report their reason
|
|
231
|
-
* so the coverage output says why auto skipped them.
|
|
232
|
-
*
|
|
233
|
-
* "lib" widens the scan to the STATIC-OR-REFUSE posture (a fallback
|
|
234
|
-
* status is a build-stopping SC4020 there, never an island note):
|
|
235
|
-
* - opted-in packages' OWN files are scanned too — import statements
|
|
236
|
-
* and top-level requires alike — so runFrontend's fixpoint loop
|
|
237
|
-
* judges every bare edge the growing graph exposes (the executable
|
|
238
|
-
* lane leaves a package's deps to the island; the library lane has
|
|
239
|
-
* no island);
|
|
240
|
-
* - a bare specifier no TYPES resolution answers but whose runtime JS
|
|
241
|
-
* resolves (a package with no own .d.ts) is judged instead of
|
|
242
|
-
* skipped — it fails the bar by name, not as a generic import fence;
|
|
243
|
-
* - `judged` dedups across fixpoint iterations and `sites` records
|
|
244
|
-
* each package's first import site, the SC4020 anchor. */
|
|
245
|
-
function detectAutoPackages(load, statuses, mode = "auto", judged, sites) {
|
|
246
|
-
// package → the resolved types file AND the file whose import found it:
|
|
247
|
-
// the runtime-JS probe below must resolve from the SAME importing file,
|
|
248
|
-
// or a package visible only to a nested package.json realm (a pnpm
|
|
249
|
-
// monorepo's packages/*/node_modules, unreachable from the entry's own
|
|
250
|
-
// walk-up) answers "no runtime JS" for perfectly ordinary installs.
|
|
251
|
-
const seen = new Map();
|
|
252
|
-
for (const sf of [...load.moduleOrder, load.entry]) {
|
|
253
|
-
if (mode === "auto" && sf.fileName.includes("/node_modules/"))
|
|
254
|
-
continue;
|
|
255
|
-
const edges = [];
|
|
256
|
-
for (const stmt of sf.statements) {
|
|
257
|
-
if (ts7IsImportWithStringSpec(stmt)) {
|
|
258
|
-
edges.push({ spec: stmt.moduleSpecifier.text, loc: locOf(stmt) });
|
|
259
|
-
}
|
|
260
|
-
else if (mode === "lib") {
|
|
261
|
-
// CJS packages spell their dep edges as top-level requires; the
|
|
262
|
-
// import-statement scan alone would miss every one of them.
|
|
263
|
-
for (const req of requiresOf(stmt))
|
|
264
|
-
edges.push({ spec: req.spec, loc: locOf(req.node) });
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
for (const { spec, loc } of edges) {
|
|
268
|
-
if (isRelativeSpecifier(spec) || spec.startsWith("node:") || spec.startsWith("#"))
|
|
269
|
-
continue;
|
|
270
|
-
// Bare builtin names ("fs", "path") are the builtin machinery's
|
|
271
|
-
// business (and the SC4005 async_free gate's, in library mode) —
|
|
272
|
-
// never npm candidates. Auto keeps its original path (the
|
|
273
|
-
// @types/node answer skips them below), byte-for-byte.
|
|
274
|
-
if (mode === "lib" && canonicalBuiltinModule(spec) !== null)
|
|
275
|
-
continue;
|
|
276
|
-
const npm = resolveNpmImport(sf.fileName, spec);
|
|
277
|
-
if (npm !== null && isNodeTypesPath(npm.typesFile))
|
|
278
|
-
continue;
|
|
279
|
-
if (npm === null) {
|
|
280
|
-
if (mode !== "lib")
|
|
281
|
-
continue;
|
|
282
|
-
const js = resolveBareModule(sf.fileName, spec, "js-only");
|
|
283
|
-
if (js === null || judged.has(js.packageName))
|
|
284
|
-
continue;
|
|
285
|
-
judged.add(js.packageName);
|
|
286
|
-
sites.set(js.packageName, loc);
|
|
287
|
-
statuses.push({ package: js.packageName, status: "fallback", detail: "it ships no own .d.ts declaration surface" });
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
if (judged?.has(npm.packageName))
|
|
291
|
-
continue;
|
|
292
|
-
if (!seen.has(npm.packageName)) {
|
|
293
|
-
seen.set(npm.packageName, { typesFile: npm.typesFile, fromFile: sf.fileName });
|
|
294
|
-
sites?.set(npm.packageName, loc);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
const chosen = [];
|
|
299
|
-
for (const [pkg, { typesFile, fromFile }] of seen) {
|
|
300
|
-
judged?.add(pkg);
|
|
301
|
-
const jsEntry = resolveBareModule(fromFile, pkg, "js-only");
|
|
302
|
-
const reason = npmStaticIneligibleReason(pkg, typesFile, jsEntry !== null && isJsSourceFileName(jsEntry.typesFile) ? jsEntry.typesFile : null);
|
|
303
|
-
if (reason === null)
|
|
304
|
-
chosen.push(pkg);
|
|
305
|
-
else
|
|
306
|
-
statuses.push({ package: pkg, status: "fallback", detail: mode === "lib" ? reason : `auto: ${reason}` });
|
|
307
|
-
}
|
|
308
|
-
return chosen;
|
|
309
|
-
}
|
|
310
|
-
/** Duck-typed import-declaration test (the ts7 AST types stay inside the
|
|
311
|
-
* frontend; this file only needs the specifier text). */
|
|
312
|
-
function ts7IsImportWithStringSpec(stmt) {
|
|
313
|
-
const s = stmt;
|
|
314
|
-
return typeof s.moduleSpecifier?.text === "string";
|
|
315
|
-
}
|
|
316
|
-
/** The opted-in packages a consumer-anchored tsc message NAMES: module
|
|
317
|
-
* specifiers in `Module '"spec"'` phrasings, and resolved file paths in
|
|
318
|
-
* `import("…")` type spellings — the two ways the checker points at an
|
|
319
|
-
* import surface from the importer's side. */
|
|
320
|
-
function packagesNamedByDiag(message, optedIn) {
|
|
321
|
-
const hits = new Set();
|
|
322
|
-
for (const m of message.matchAll(/Module '"([^"]+)"'/g)) {
|
|
323
|
-
const spec = m[1];
|
|
324
|
-
const prefix = packageNameOfSpecifier(spec);
|
|
325
|
-
if (optedIn.has(prefix))
|
|
326
|
-
hits.add(prefix);
|
|
327
|
-
}
|
|
328
|
-
for (const m of message.matchAll(/import\("([^"]+)"\)/g)) {
|
|
329
|
-
const pkg = npmStaticPackageOfPath(m[1]);
|
|
330
|
-
if (pkg !== null && optedIn.has(pkg))
|
|
331
|
-
hits.add(pkg);
|
|
332
|
-
}
|
|
333
|
-
return hits;
|
|
334
|
-
}
|
|
335
|
-
/** The one frontend, three npm postures: `undefined`/explicit package
|
|
336
|
-
* lists and `"auto"` are the executable lane's (--npm-static; fallback =
|
|
337
|
-
* island). `"lib"` is library mode's mandatory auto twin — the same
|
|
338
|
-
* eligibility bar and the same opt-in machinery, but every fallback
|
|
339
|
-
* status the shared loops record becomes compileLibrary's SC4020
|
|
340
|
-
* static-or-refuse teaching, and the detection closes over the opted-in
|
|
341
|
-
* packages' own bare edges (no island exists to serve a dep from). */
|
|
342
|
-
function runFrontend(entryPath, npmStatic, externalTypes) {
|
|
343
|
-
// Resolver package/workspace metadata is intentionally shared across the
|
|
344
|
-
// several load attempts of ONE auto-detection fixpoint, but never across
|
|
345
|
-
// separate compiles in a long-lived process. A cache miss must observe
|
|
346
|
-
// package.json edits before it can publish a new early-library entry.
|
|
347
|
-
clearResolveCaches();
|
|
348
|
-
const statuses = [];
|
|
349
|
-
const npmSites = new Map();
|
|
350
|
-
const judged = new Set();
|
|
351
|
-
let requested = [];
|
|
352
|
-
let reusableScout = null;
|
|
353
|
-
let reusablePreflight = null;
|
|
354
|
-
if (npmStatic === "auto" || npmStatic === "lib") {
|
|
355
|
-
const scout = loadProgram(entryPath, { externalTypes });
|
|
356
|
-
let retained = false;
|
|
357
|
-
try {
|
|
358
|
-
const scoutPreflight = checkPreflight(scout);
|
|
359
|
-
requested =
|
|
360
|
-
npmStatic === "lib"
|
|
361
|
-
? detectAutoPackages(scout, statuses, "lib", judged, npmSites)
|
|
362
|
-
: detectAutoPackages(scout, statuses);
|
|
363
|
-
// With no package to opt in, the scout already IS the final frontend:
|
|
364
|
-
// same roots, resolution posture, preflight, and module order. Retain it
|
|
365
|
-
// instead of spawning a second tsgo server and checking the whole graph
|
|
366
|
-
// again — the common library-mode path has no bare npm imports.
|
|
367
|
-
if (requested.length === 0) {
|
|
368
|
-
reusableScout = scout;
|
|
369
|
-
reusablePreflight = scoutPreflight;
|
|
370
|
-
retained = true;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
finally {
|
|
374
|
-
if (!retained)
|
|
375
|
-
scout.dispose();
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
else if (npmStatic !== undefined) {
|
|
379
|
-
requested = [...new Set(npmStatic)];
|
|
380
|
-
}
|
|
381
|
-
// One exact --external-types mapping makes the containing package an
|
|
382
|
-
// external host boundary, which cannot simultaneously be compiled as a
|
|
383
|
-
// package-wide --npm-static program graph. External wins; retain the
|
|
384
|
-
// ordinary npm-static fallback record so explicit and auto requests both
|
|
385
|
-
// explain why the package did not compile statically.
|
|
386
|
-
if (requested.length > 0 && externalTypes !== undefined) {
|
|
387
|
-
const externalSpecifiersByPackage = new Map();
|
|
388
|
-
for (const specifier of Object.keys(externalTypes)) {
|
|
389
|
-
const pkg = packageNameOfSpecifier(specifier);
|
|
390
|
-
const specs = externalSpecifiersByPackage.get(pkg) ?? [];
|
|
391
|
-
specs.push(specifier);
|
|
392
|
-
externalSpecifiersByPackage.set(pkg, specs);
|
|
393
|
-
}
|
|
394
|
-
requested = requested.filter((pkg) => {
|
|
395
|
-
const specs = externalSpecifiersByPackage.get(pkg);
|
|
396
|
-
if (specs === undefined)
|
|
397
|
-
return true;
|
|
398
|
-
statuses.push({
|
|
399
|
-
package: pkg,
|
|
400
|
-
status: "fallback",
|
|
401
|
-
detail: `mapped as an external host module by --external-types (${specs.map((s) => JSON.stringify(s)).join(", ")})`,
|
|
402
|
-
});
|
|
403
|
-
return false;
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
// The all-or-nothing fallback loop: a preflight diagnostic ANCHORED in
|
|
407
|
-
// an opted-in package's files (an unsupported require form, a builtin
|
|
408
|
-
// fence) — or an offender the resolution itself reported — drops that
|
|
409
|
-
// package from the set and the whole frontend reloads without it, so
|
|
410
|
-
// its import takes the ordinary island path. Static compilation of a
|
|
411
|
-
// package must never turn a working --dynamic build into a build
|
|
412
|
-
// failure.
|
|
413
|
-
//
|
|
414
|
-
// CONSUMER-anchored attribution (the second source): an opted-in
|
|
415
|
-
// package whose inferred export surface breaks the typecheck reports at
|
|
416
|
-
// its IMPORT SITES — errors in program files no path-shaped attribution
|
|
417
|
-
// reaches, but whose MESSAGES name the package ("Module '"pkg"' has no
|
|
418
|
-
// exported member", "typeof import("…/pkg/dist/index")"). Bundle-shaped
|
|
419
|
-
// dists carry surfaces inference can only partly reach (type-only
|
|
420
|
-
// re-exports have no JS value to chase), and the ratified behavior is
|
|
421
|
-
// graceful PER-PACKAGE degradation: the named package drops to the
|
|
422
|
-
// island with a note, never a failed gate. Explicit opt-ins degrade
|
|
423
|
-
// exactly like auto's — "the user asked for these packages" buys the
|
|
424
|
-
// attempt, not a broken build.
|
|
425
|
-
let load = reusableScout ?? loadProgram(entryPath, { npmStatic: requested, externalTypes });
|
|
426
|
-
let preflight = reusablePreflight ?? checkPreflight(load);
|
|
427
|
-
// Library mode's fixpoint: the opted-in packages' files joined the
|
|
428
|
-
// program just now, and THEIR bare edges (import statements and
|
|
429
|
-
// top-level requires) name packages the scout could not see. Judge each
|
|
430
|
-
// by the same bar — eligible ones join the set and the frontend
|
|
431
|
-
// reloads; ineligible ones record the fallback status compileLibrary
|
|
432
|
-
// refuses on. Bounded by the dependency count (every iteration settles
|
|
433
|
-
// at least one new package for good).
|
|
434
|
-
if (npmStatic === "lib") {
|
|
435
|
-
for (;;) {
|
|
436
|
-
const grown = detectAutoPackages(load, statuses, "lib", judged, npmSites);
|
|
437
|
-
if (grown.length === 0)
|
|
438
|
-
break;
|
|
439
|
-
requested = [...requested, ...grown];
|
|
440
|
-
load.dispose();
|
|
441
|
-
load = loadProgram(entryPath, { npmStatic: requested, externalTypes });
|
|
442
|
-
preflight = checkPreflight(load);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
const effective = new Set(requested);
|
|
446
|
-
while (effective.size > 0) {
|
|
447
|
-
const reasons = new Map(npmStaticOffenders());
|
|
448
|
-
for (const d of preflight) {
|
|
449
|
-
const pkg = npmStaticPackageOfPath(d.loc.file);
|
|
450
|
-
if (pkg !== null && !reasons.has(pkg))
|
|
451
|
-
reasons.set(pkg, `${d.code}: ${d.message}`);
|
|
452
|
-
}
|
|
453
|
-
if (![...reasons.keys()].some((p) => effective.has(p))) {
|
|
454
|
-
const named = new Map();
|
|
455
|
-
for (const d of preflight) {
|
|
456
|
-
if (d.code !== "SC0001")
|
|
457
|
-
continue;
|
|
458
|
-
for (const pkg of packagesNamedByDiag(d.message, effective)) {
|
|
459
|
-
named.set(pkg, (named.get(pkg) ?? 0) + 1);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
for (const [pkg, count] of named) {
|
|
463
|
-
reasons.set(pkg, `its inferred export surface breaks ${count} import site${count === 1 ? "" : "s"} in program files${npmStatic === "lib" ? "" : " — the package serves from the island instead"} (bundler-emitted surfaces type only as far as inference reaches)`);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
const dropping = [...reasons.keys()].filter((p) => effective.has(p));
|
|
467
|
-
if (dropping.length === 0)
|
|
468
|
-
break;
|
|
469
|
-
for (const p of dropping) {
|
|
470
|
-
effective.delete(p);
|
|
471
|
-
statuses.push({ package: p, status: "fallback", detail: reasons.get(p) });
|
|
472
|
-
}
|
|
473
|
-
load.dispose();
|
|
474
|
-
load = loadProgram(entryPath, { npmStatic: effective, externalTypes });
|
|
475
|
-
preflight = checkPreflight(load);
|
|
476
|
-
}
|
|
477
|
-
// The last resort, ALL modes: an opt-in can change the PROGRAM's OWN
|
|
478
|
-
// typecheck through errors that name no package at all (declaration
|
|
479
|
-
// shapes outside the safe overload projection — generic overloads,
|
|
480
|
-
// declaration-only members, or a .d.ts type-GUARD an inferred JS
|
|
481
|
-
// function cannot reproduce). Those SC0001s anchor in USER files no
|
|
482
|
-
// offender or
|
|
483
|
-
// message attribution reaches, so each remaining package is probed
|
|
484
|
-
// ALONE-dropped (n is the opt-in count — a handful of extra analysis
|
|
485
|
-
// loads); culprits whose removal clears the errors fall back with a
|
|
486
|
-
// note, and if no subset typechecks, everything drops. Explicit opt-ins
|
|
487
|
-
// degrade the same way — the ratified stance for bundle-shaped dists is
|
|
488
|
-
// graceful per-package degradation, never a failed gate the user cannot
|
|
489
|
-
// act on (the note carries the why).
|
|
490
|
-
if (effective.size > 0 && preflight.some((d) => d.code === "SC0001")) {
|
|
491
|
-
const dropWithNote = (p) => {
|
|
492
|
-
effective.delete(p);
|
|
493
|
-
statuses.push({
|
|
494
|
-
package: p,
|
|
495
|
-
status: "fallback",
|
|
496
|
-
detail: npmStatic === "auto"
|
|
497
|
-
? "auto: the program does not typecheck against its inferred surface"
|
|
498
|
-
: npmStatic === "lib"
|
|
499
|
-
? "the program does not typecheck against its inferred surface (type-only declarations and .d.ts type guards have no JS value inference can chase)"
|
|
500
|
-
: "the program does not typecheck against its inferred surface (type-only declarations and .d.ts type guards have no JS value inference can chase) — the package serves from the island instead",
|
|
501
|
-
});
|
|
502
|
-
};
|
|
503
|
-
// Attribute per package by probing each SOLO (culprits are almost
|
|
504
|
-
// always independent — each package's inferred surface breaks its own
|
|
505
|
-
// import sites), then reload with the survivors; interaction effects
|
|
506
|
-
// that still fail drop everything left.
|
|
507
|
-
for (const p of [...effective]) {
|
|
508
|
-
const probe = loadProgram(entryPath, { npmStatic: [p], externalTypes });
|
|
509
|
-
const probeDiags = checkPreflight(probe);
|
|
510
|
-
probe.dispose();
|
|
511
|
-
if (probeDiags.some((d) => d.code === "SC0001"))
|
|
512
|
-
dropWithNote(p);
|
|
513
|
-
}
|
|
514
|
-
load.dispose();
|
|
515
|
-
load = loadProgram(entryPath, { npmStatic: effective, externalTypes });
|
|
516
|
-
preflight = checkPreflight(load);
|
|
517
|
-
if (preflight.some((d) => d.code === "SC0001") && effective.size > 0) {
|
|
518
|
-
for (const p of [...effective])
|
|
519
|
-
dropWithNote(p);
|
|
520
|
-
load.dispose();
|
|
521
|
-
load = loadProgram(entryPath, { npmStatic: effective, externalTypes });
|
|
522
|
-
preflight = checkPreflight(load);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
for (const p of requested) {
|
|
526
|
-
if (effective.has(p))
|
|
527
|
-
statuses.push({ package: p, status: "static" });
|
|
528
|
-
}
|
|
529
|
-
const finalLoad = load;
|
|
530
|
-
return {
|
|
531
|
-
preflight,
|
|
532
|
-
entryText: () => finalLoad.entry.text,
|
|
533
|
-
entryExports: () => entryFunctionExports(finalLoad.entry),
|
|
534
|
-
// The contract scans the PROGRAM's source files, not the runtime
|
|
535
|
-
// module order: a type-only module (nothing but exported types) has no
|
|
536
|
-
// runtime edge and never joins moduleOrder, yet its declarations are
|
|
537
|
-
// contract surface. Declaration files (default libs, @types) stay out,
|
|
538
|
-
// and so do statically-compiled npm packages' files: their .d.ts is
|
|
539
|
-
// dropped by construction (inference types the bodies), so no npm
|
|
540
|
-
// declaration can name a wire-contract type — the contract vocabulary
|
|
541
|
-
// is authored program surface only, and a workspace-linked package's
|
|
542
|
-
// shipped .ts must not smuggle same-name declarations into the type
|
|
543
|
-
// table.
|
|
544
|
-
entryContract: () => entryContractFacts(finalLoad.entry, finalLoad.program.getSourceFiles().filter((sf) => !sf.isDeclarationFile && npmStaticPackageOfPath(sf.fileName) === null)),
|
|
545
|
-
// Runtime evaluation order first, then any type-only program modules
|
|
546
|
-
// (no runtime edge, so absent from moduleOrder — but they are contract
|
|
547
|
-
// surface now, and the library identity hashes cover the WHOLE module
|
|
548
|
-
// graph; the Map dedups by fileName). Statically-compiled npm modules
|
|
549
|
-
// are in moduleOrder like any program module, so their bytes join the
|
|
550
|
-
// library identity hashes (source_hash/build_id) — compiled code is
|
|
551
|
-
// identity, whatever directory it came from.
|
|
552
|
-
sourceTexts: () => new Map([finalLoad.entry, ...finalLoad.moduleOrder, ...finalLoad.program.getSourceFiles().filter((sf) => !sf.isDeclarationFile)].map((sf) => [sf.fileName, sf.text])),
|
|
553
|
-
lower: (opts) => lowerToIr(finalLoad.program, finalLoad.entry, finalLoad.moduleOrder, {
|
|
554
|
-
...opts,
|
|
555
|
-
startupCrash: finalLoad.startupCrash ?? null,
|
|
556
|
-
externalTypes: finalLoad.externalTypes,
|
|
557
|
-
externalTypeSpecifiersByFile: finalLoad.externalTypeSpecifiersByFile,
|
|
558
|
-
}),
|
|
559
|
-
npmStatic: statuses,
|
|
560
|
-
npmImportSites: npmSites,
|
|
561
|
-
dispose: finalLoad.dispose,
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
/** Analysis without codegen: how much of the program compiles statically.
|
|
565
|
-
* Unlike compile(), lowering diagnostics are data here, not failure. */
|
|
566
89
|
export function analyze(entryPath, opts = {}) {
|
|
567
|
-
|
|
568
|
-
if (opts.ffiProfilePath !== undefined) {
|
|
569
|
-
const loaded = loadFfiProfile(opts.ffiProfilePath);
|
|
570
|
-
if (!loaded.ok) {
|
|
571
|
-
return {
|
|
572
|
-
coverage: {
|
|
573
|
-
file: entryPath,
|
|
574
|
-
dynamic: opts.dynamic ?? false,
|
|
575
|
-
stats: { statementsTotal: 0, statementsFailed: 0, statementsIsland: 0, functionsSkipped: 0 },
|
|
576
|
-
diagnostics: loaded.diagnostics,
|
|
577
|
-
preflightFailed: true,
|
|
578
|
-
},
|
|
579
|
-
sourceTexts: new Map(),
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
ffi = loaded.profile;
|
|
583
|
-
}
|
|
584
|
-
const fe = runFrontend(entryPath, opts.npmStatic, opts.externalTypes);
|
|
585
|
-
try {
|
|
586
|
-
const emptyStats = { statementsTotal: 0, statementsFailed: 0, statementsIsland: 0, functionsSkipped: 0 };
|
|
587
|
-
const preflight = fe.preflight;
|
|
588
|
-
// Import-FORM fences don't stop the analysis: the module graph is still
|
|
589
|
-
// computable (a fenced import contributes no edges), the imported
|
|
590
|
-
// bindings poison at their use sites, and the fences join the blockers
|
|
591
|
-
// list beside statement-level ones — the report shows a statement
|
|
592
|
-
// percentage instead of stopping at the import lines. Everything else —
|
|
593
|
-
// tsc errors, config incompatibilities, circular imports — still stops
|
|
594
|
-
// at preflight (no trustworthy program to lower). Builds are unchanged:
|
|
595
|
-
// compile() fails on every preflight diagnostic exactly as before.
|
|
596
|
-
const IMPORT_FENCES = new Set(["SC1010", "SC1012", "SC1013", "SC1014", "SC1015"]);
|
|
597
|
-
if (preflight.some((d) => !IMPORT_FENCES.has(d.code))) {
|
|
598
|
-
return {
|
|
599
|
-
coverage: {
|
|
600
|
-
file: entryPath,
|
|
601
|
-
dynamic: opts.dynamic ?? false,
|
|
602
|
-
stats: emptyStats,
|
|
603
|
-
diagnostics: preflight,
|
|
604
|
-
...(fe.npmStatic.length > 0 ? { npmStatic: fe.npmStatic } : {}),
|
|
605
|
-
preflightFailed: true,
|
|
606
|
-
},
|
|
607
|
-
sourceTexts: fe.sourceTexts(),
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
// Coverage is whole-program by design: builds stop at what the entry
|
|
611
|
-
// reaches, but the analysis additionally lowers the unreached remainder
|
|
612
|
-
// (throwaway) so the report covers everything the source declares — with
|
|
613
|
-
// the unreached share in its own group.
|
|
614
|
-
const lowered = fe.lower({
|
|
615
|
-
dynamic: opts.dynamic ?? false,
|
|
616
|
-
coverage: true,
|
|
617
|
-
targetPlatform: buildTargetPlatform(),
|
|
618
|
-
...(ffi !== null ? { ffiImports: ffi.functions } : {}),
|
|
619
|
-
});
|
|
620
|
-
const provenance = provenanceSources();
|
|
621
|
-
return {
|
|
622
|
-
coverage: {
|
|
623
|
-
file: entryPath,
|
|
624
|
-
dynamic: opts.dynamic ?? false,
|
|
625
|
-
stats: lowered.stats,
|
|
626
|
-
// The import fences report as blockers alongside the statement-level
|
|
627
|
-
// ones (use sites of the fenced bindings emit matching diagnostics,
|
|
628
|
-
// which the report groups with these).
|
|
629
|
-
diagnostics: [...preflight, ...lowered.diagnostics],
|
|
630
|
-
...(lowered.runtimeFences.length > 0 ? { runtimeFences: lowered.runtimeFences } : {}),
|
|
631
|
-
...(lowered.unreached ? { unreached: lowered.unreached } : {}),
|
|
632
|
-
...(lowered.npmBuiltins ? { npmBuiltins: lowered.npmBuiltins } : {}),
|
|
633
|
-
...(lowered.npmLazyTraps ? { npmLazyTraps: lowered.npmLazyTraps } : {}),
|
|
634
|
-
...(fe.npmStatic.length > 0 ? { npmStatic: fe.npmStatic } : {}),
|
|
635
|
-
// --provenance-sources: the per-package attribution inputs (the
|
|
636
|
-
// report aggregates statsByFile under each package's source dir).
|
|
637
|
-
...(provenance !== null ? { provenance } : {}),
|
|
638
|
-
...(lowered.statsByFile ? { statsByFile: lowered.statsByFile } : {}),
|
|
639
|
-
...(lowered.provenanceElided ? { provenanceElided: lowered.provenanceElided } : {}),
|
|
640
|
-
preflightFailed: false,
|
|
641
|
-
},
|
|
642
|
-
sourceTexts: fe.sourceTexts(),
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
finally {
|
|
646
|
-
fe.dispose();
|
|
647
|
-
}
|
|
90
|
+
return analyzeWithFrontend(entryPath, opts, buildTargetPlatform(), nodeFrontend);
|
|
648
91
|
}
|
|
649
|
-
|
|
92
|
+
const nodeFrontend = (entry, npmStatic, externalTypes, libraryNpmStatic) => runFrontend(entry, loadProgram, npmStatic, externalTypes, libraryNpmStatic);
|
|
93
|
+
/** The whole pipeline: load → preflight → lower → validate → emit LLVM → link. */
|
|
650
94
|
function clearCompileSessionCaches() {
|
|
651
95
|
clearResolveCaches();
|
|
652
96
|
clearCcCaches();
|
|
@@ -676,55 +120,22 @@ function assertCompileResultCompatibility(result) {
|
|
|
676
120
|
}
|
|
677
121
|
}
|
|
678
122
|
void assertCompileResultCompatibility;
|
|
679
|
-
function executableNativeFeatures(mod, backend, dynamic, optimization
|
|
123
|
+
function executableNativeFeatures(mod, backend, dynamic, optimization) {
|
|
680
124
|
return {
|
|
681
125
|
backend,
|
|
682
126
|
...(optimization === "dev" ? { optimization: "dev" } : {}),
|
|
683
|
-
...(
|
|
684
|
-
dynamic,
|
|
685
|
-
regex: moduleUsesRegex(mod),
|
|
686
|
-
copying: moduleUsesCopying(mod),
|
|
687
|
-
textDecoderLegacy: moduleUsesLegacyTextDecoder(mod),
|
|
688
|
-
fileHandle: moduleUsesFileHandle(mod),
|
|
689
|
-
fetch: moduleUsesFetch(mod),
|
|
690
|
-
netIsland: moduleEmbedsBuiltin(mod, "node:http") ||
|
|
691
|
-
moduleEmbedsBuiltin(mod, "node:https") ||
|
|
692
|
-
moduleEmbedsBuiltin(mod, "node:net") ||
|
|
693
|
-
moduleEmbedsBuiltin(mod, "node:tls"),
|
|
694
|
-
zlib: moduleUsesZlib(mod) || moduleEmbedsCompressedNpm(mod),
|
|
695
|
-
assert: moduleUsesAssert(mod),
|
|
696
|
-
inspect: moduleUsesInspect(mod),
|
|
697
|
-
dynInvoke: moduleUsesDynInvoke(mod),
|
|
698
|
-
dc: moduleUsesDc(mod),
|
|
699
|
-
dynAsync: moduleUsesDynAsync(mod),
|
|
700
|
-
events: moduleUsesProcessEvents(mod),
|
|
701
|
-
emitter: moduleUsesEmitter(mod),
|
|
702
|
-
symbol: moduleUsesSymbol(mod),
|
|
703
|
-
bigint: moduleUsesBigInt(mod),
|
|
704
|
-
searchParams: moduleUsesSearchParams(mod),
|
|
705
|
-
qs: moduleUsesQs(mod),
|
|
706
|
-
parseArgs: moduleUsesParseArgs(mod),
|
|
707
|
-
stream: moduleUsesStream(mod),
|
|
708
|
-
net: moduleUsesNet(mod),
|
|
709
|
-
http: moduleUsesHttpServer(mod),
|
|
710
|
-
http2: moduleUsesHttp2(mod),
|
|
711
|
-
dgram: moduleUsesDgram(mod),
|
|
712
|
-
watch: moduleUsesFsWatch(mod),
|
|
713
|
-
foreignFfi: hasForeignFfiCallback(mod.ffiImports ?? []),
|
|
714
|
-
nodeTest: moduleUsesNodeTest(mod),
|
|
715
|
-
tls: moduleUsesTls(mod),
|
|
716
|
-
tlsCa: moduleUsesTlsCa(mod),
|
|
127
|
+
...executableLinkFeatures(mod, dynamic),
|
|
717
128
|
};
|
|
718
129
|
}
|
|
719
|
-
async function compileExecutableNative(features,
|
|
720
|
-
const programIsObject = /\.(?:o|obj)$/.test(
|
|
721
|
-
const runtimePackTarget = programIsObject && !sanitize
|
|
130
|
+
async function compileExecutableNative(features, llvmPath, outPath, sanitize, ffi, windowsSubsystem, strip, programSplit = null, programObjectDependencies = [], onArtifactReady) {
|
|
131
|
+
const programIsObject = /\.(?:o|obj)$/.test(llvmPath);
|
|
132
|
+
const runtimePackTarget = programIsObject && !sanitize
|
|
722
133
|
? nativeCodegenTarget()
|
|
723
134
|
: null;
|
|
724
135
|
if (runtimePackTarget !== null) {
|
|
725
136
|
const plan = await createNativeLinkPlan({
|
|
726
137
|
target: runtimePackTarget,
|
|
727
|
-
programObject:
|
|
138
|
+
programObject: llvmPath,
|
|
728
139
|
outPath,
|
|
729
140
|
features,
|
|
730
141
|
ffi,
|
|
@@ -746,79 +157,57 @@ async function compileExecutableNative(features, cPath, outPath, sanitize, ffi,
|
|
|
746
157
|
}
|
|
747
158
|
const effectiveProgramSplit = programSplit ??
|
|
748
159
|
(!programIsObject && features.optimization === "dev" && features.backend === "llvm" && !sanitize
|
|
749
|
-
? splitLlvmProgram(await readFile(
|
|
160
|
+
? splitLlvmProgram(await readFile(llvmPath, "utf8"))
|
|
750
161
|
: null);
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
:
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
watch: features.watch,
|
|
801
|
-
foreignFfi: features.foreignFfi,
|
|
802
|
-
nodeTest: features.nodeTest,
|
|
803
|
-
tls: features.tls,
|
|
804
|
-
tlsCa: features.tlsCa,
|
|
805
|
-
...(onArtifactReady === undefined ? {} : { onArtifactReady }),
|
|
806
|
-
...(ffi === null && !programIsObject
|
|
807
|
-
? {}
|
|
808
|
-
: {
|
|
809
|
-
linkInputs: [
|
|
810
|
-
...(programIsObject ? [cPath] : []),
|
|
811
|
-
...(ffi?.libraries ?? []),
|
|
812
|
-
],
|
|
813
|
-
...(ffi === null ? {} : { systemLibraries: ffi.systemLibraries }),
|
|
814
|
-
}),
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
finally {
|
|
818
|
-
if (objectLinkDir !== null) {
|
|
819
|
-
await rm(objectLinkDir, { recursive: true, force: true }).catch(() => undefined);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
162
|
+
if (programIsObject)
|
|
163
|
+
throw new InternalCompilerError("program objects must link against a precompiled runtime pack");
|
|
164
|
+
await compileExternalC({
|
|
165
|
+
cPath: llvmPath,
|
|
166
|
+
outPath,
|
|
167
|
+
cacheIdentity: "scriptc-generated-v1",
|
|
168
|
+
...(features.optimization === "dev" ? { optimization: "dev" } : {}),
|
|
169
|
+
...(strip ? { strip: true } : {}),
|
|
170
|
+
...(windowsSubsystem === undefined ? {} : { windowsSubsystem }),
|
|
171
|
+
...(effectiveProgramSplit === null
|
|
172
|
+
? {}
|
|
173
|
+
: {
|
|
174
|
+
programShards: effectiveProgramSplit.shards,
|
|
175
|
+
programPublicSymbols: effectiveProgramSplit.publicSymbols,
|
|
176
|
+
}),
|
|
177
|
+
sanitize,
|
|
178
|
+
dynamic: features.dynamic,
|
|
179
|
+
regex: features.regex,
|
|
180
|
+
copying: features.copying,
|
|
181
|
+
textDecoderLegacy: features.textDecoderLegacy,
|
|
182
|
+
fileHandle: features.fileHandle,
|
|
183
|
+
fetch: features.fetch,
|
|
184
|
+
netIsland: features.netIsland,
|
|
185
|
+
zlib: features.zlib,
|
|
186
|
+
assert: features.assert,
|
|
187
|
+
inspect: features.inspect,
|
|
188
|
+
dynInvoke: features.dynInvoke,
|
|
189
|
+
dc: features.dc,
|
|
190
|
+
dynAsync: features.dynAsync,
|
|
191
|
+
events: features.events,
|
|
192
|
+
emitter: features.emitter,
|
|
193
|
+
symbol: features.symbol,
|
|
194
|
+
bigint: features.bigint,
|
|
195
|
+
searchParams: features.searchParams,
|
|
196
|
+
qs: features.qs,
|
|
197
|
+
parseArgs: features.parseArgs,
|
|
198
|
+
stream: features.stream,
|
|
199
|
+
net: features.net,
|
|
200
|
+
http: features.http,
|
|
201
|
+
http2: features.http2,
|
|
202
|
+
dgram: features.dgram,
|
|
203
|
+
watch: features.watch,
|
|
204
|
+
foreignFfi: features.foreignFfi,
|
|
205
|
+
nodeTest: features.nodeTest,
|
|
206
|
+
tls: features.tls,
|
|
207
|
+
tlsCa: features.tlsCa,
|
|
208
|
+
...(onArtifactReady === undefined ? {} : { onArtifactReady }),
|
|
209
|
+
...(ffi === null ? {} : { linkInputs: ffi.libraries, systemLibraries: ffi.systemLibraries, frameworks: ffi.frameworks }),
|
|
210
|
+
});
|
|
822
211
|
}
|
|
823
212
|
async function emitNativeProgramObject(entryPath, opts, llvm) {
|
|
824
213
|
const stem = basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
@@ -845,17 +234,140 @@ async function emitNativeProgramObject(entryPath, opts, llvm) {
|
|
|
845
234
|
}
|
|
846
235
|
function usesPrecompiledRuntimePack(opts, backend) {
|
|
847
236
|
if (backend !== "llvm" || opts.sanitize === true ||
|
|
848
|
-
process.env["
|
|
849
|
-
process.env["SCRIPTC_FETCH_CURL"] === "1" || legacyCExecutablePathRequested())
|
|
237
|
+
process.env["SCRIPTC_FETCH_CURL"] === "1")
|
|
850
238
|
return false;
|
|
851
239
|
return nativeCodegenTarget() !== null;
|
|
852
240
|
}
|
|
853
241
|
function runtimePackDiagnostic(error, entryPath) {
|
|
854
242
|
return nativeCodegenDiag(error.code === "unsupported" ? "SC3002" : "SC3003", error.message, entryPath);
|
|
855
243
|
}
|
|
244
|
+
/** Finish frontend work in a separate scope so the AST, checker caches and
|
|
245
|
+
* typed IR can be reclaimed before the native optimizer needs its heap. */
|
|
246
|
+
async function prepareExecutableInput(entryPath, opts, ffi, buildPlatform, timing) {
|
|
247
|
+
const outputKind = opts.outputKind ?? "exe";
|
|
248
|
+
const prepared = prepareExecutableModule(entryPath, opts, ffi, buildPlatform, nodeFrontend, timing);
|
|
249
|
+
if (!prepared.ok)
|
|
250
|
+
return prepared;
|
|
251
|
+
const { mod, sourceTexts } = prepared;
|
|
252
|
+
const stem = basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
253
|
+
const defaultSourcePaths = {
|
|
254
|
+
ir: join(opts.outDir, `${stem}.ir.json`),
|
|
255
|
+
llvm: join(opts.outDir, `${stem}.ll`),
|
|
256
|
+
};
|
|
257
|
+
const debugOptions = opts.optimization === "dev" && !opts.strip
|
|
258
|
+
? { debugSources: sourceTexts }
|
|
259
|
+
: {};
|
|
260
|
+
if (outputKind === "ir") {
|
|
261
|
+
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
262
|
+
await writeFile(opts.outPath, serializeModule(mod, true));
|
|
263
|
+
return { ok: true, artifact: { kind: "ir", path: opts.outPath } };
|
|
264
|
+
}
|
|
265
|
+
if (outputKind === "llvm" || outputKind === "asm" || outputKind === "obj") {
|
|
266
|
+
let llvm;
|
|
267
|
+
try {
|
|
268
|
+
llvm = emitLlvmModule(mod, {
|
|
269
|
+
targetTriple: process.env["SCRIPTC_TARGET"] ?? "",
|
|
270
|
+
...debugOptions,
|
|
271
|
+
pointerBits: buildPlatform === "wasi" ? 32 : 64,
|
|
272
|
+
wasi: buildPlatform === "wasi",
|
|
273
|
+
runtimeAbiMarker: outputKind === "obj",
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
catch (err) {
|
|
277
|
+
if (!(err instanceof LlvmUnsupportedError))
|
|
278
|
+
throw err;
|
|
279
|
+
return { ok: false, diagnostics: [llvmRefusalDiag(err, entryPath)], sourceTexts };
|
|
280
|
+
}
|
|
281
|
+
if (outputKind === "llvm") {
|
|
282
|
+
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
283
|
+
await writeFile(opts.outPath, llvm);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
try {
|
|
287
|
+
await emitNativeArtifact({
|
|
288
|
+
outputPath: opts.outPath,
|
|
289
|
+
llvm,
|
|
290
|
+
outputKind,
|
|
291
|
+
sourcePath: entryPath,
|
|
292
|
+
optimization: opts.optimization === "dev" ? "0" : "2",
|
|
293
|
+
...(opts.sanitize === undefined ? {} : { sanitize: opts.sanitize }),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
catch (err) {
|
|
297
|
+
if (!(err instanceof NativeCodegenError))
|
|
298
|
+
throw err;
|
|
299
|
+
return {
|
|
300
|
+
ok: false,
|
|
301
|
+
diagnostics: [nativeCodegenDiag(err.diagnosticCode, err.message, entryPath)],
|
|
302
|
+
sourceTexts,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (outputKind === "obj" && opts.nativeLinkInfo === true) {
|
|
307
|
+
const target = nativeCodegenTarget();
|
|
308
|
+
if (target === null) {
|
|
309
|
+
throw new InternalCompilerError("native object emitted without a native target");
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
ok: true,
|
|
313
|
+
artifact: {
|
|
314
|
+
kind: "obj",
|
|
315
|
+
path: opts.outPath,
|
|
316
|
+
nativeLinkInfo: await createNativeLinkInfo({
|
|
317
|
+
programObject: opts.outPath,
|
|
318
|
+
target,
|
|
319
|
+
features: executableNativeFeatures(mod, "llvm", opts.dynamic ?? false, opts.optimization ?? "release"),
|
|
320
|
+
ffi,
|
|
321
|
+
optimization: opts.optimization ?? "release",
|
|
322
|
+
}),
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
return { ok: true, artifact: { kind: outputKind, path: opts.outPath } };
|
|
327
|
+
}
|
|
328
|
+
await mkdir(opts.outDir, { recursive: true });
|
|
329
|
+
const llvmPath = defaultSourcePaths.llvm;
|
|
330
|
+
const backend = "llvm";
|
|
331
|
+
let llvmSource;
|
|
332
|
+
try {
|
|
333
|
+
llvmSource = emitLlvmModule(mod, {
|
|
334
|
+
targetTriple: process.env["SCRIPTC_TARGET"] ?? "",
|
|
335
|
+
...debugOptions,
|
|
336
|
+
pointerBits: buildPlatform === "wasi" ? 32 : 64,
|
|
337
|
+
wasi: buildPlatform === "wasi",
|
|
338
|
+
runtimeAbiMarker: opts.nativeProgramObject === true || usesPrecompiledRuntimePack(opts, "llvm"),
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
catch (err) {
|
|
342
|
+
if (!(err instanceof LlvmUnsupportedError))
|
|
343
|
+
throw err;
|
|
344
|
+
return { ok: false, diagnostics: [llvmRefusalDiag(err, entryPath)], sourceTexts };
|
|
345
|
+
}
|
|
346
|
+
timing("llvm-emit");
|
|
347
|
+
await writeFile(llvmPath, llvmSource);
|
|
348
|
+
timing("llvm-write");
|
|
349
|
+
let irPath;
|
|
350
|
+
if (opts.emitIr) {
|
|
351
|
+
irPath = defaultSourcePaths.ir;
|
|
352
|
+
await writeFile(irPath, serializeModule(mod, true));
|
|
353
|
+
}
|
|
354
|
+
const nativeFeatures = executableNativeFeatures(mod, backend, opts.dynamic ?? false, opts.optimization ?? "release");
|
|
355
|
+
timing("link-features");
|
|
356
|
+
const programSplit = backend === "llvm" && (opts.optimization ?? "release") === "dev" &&
|
|
357
|
+
!(opts.sanitize ?? false) && llvmSource !== null
|
|
358
|
+
? splitLlvmProgram(llvmSource)
|
|
359
|
+
: null;
|
|
360
|
+
timing("llvm-split");
|
|
361
|
+
return { llvmSource, llvmPath, irPath, nativeFeatures, programSplit, sourceTexts };
|
|
362
|
+
}
|
|
856
363
|
async function compileTracked(entryPath, opts, frontendInputs) {
|
|
364
|
+
const timing = compilationTiming();
|
|
857
365
|
entryPath = resolve(entryPath);
|
|
858
366
|
const outputKind = opts.outputKind ?? "exe";
|
|
367
|
+
if ((opts.backend !== undefined && opts.backend !== "llvm") ||
|
|
368
|
+
!["ir", "llvm", "asm", "obj", "exe"].includes(outputKind)) {
|
|
369
|
+
return { ok: false, diagnostics: [nativeCodegenDiag("SC3002", "LLVM is the only backend; supported outputs are ir, llvm, asm, obj, and exe", entryPath)], sourceTexts: new Map() };
|
|
370
|
+
}
|
|
859
371
|
if (opts.windowsSubsystem !== undefined && outputKind !== "exe") {
|
|
860
372
|
return {
|
|
861
373
|
ok: false,
|
|
@@ -885,6 +397,37 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
885
397
|
sourceTexts: new Map(),
|
|
886
398
|
};
|
|
887
399
|
}
|
|
400
|
+
// Mobile triples are library-mode targets: the archive an embedding app
|
|
401
|
+
// links is the artifact, and only the library-admissible runtime surface
|
|
402
|
+
// is verified on those device classes. The executable lane refuses before
|
|
403
|
+
// any frontend work — a pure env check, so the refusal needs no toolchain.
|
|
404
|
+
if (outputKind === "exe") {
|
|
405
|
+
const entryLoc = { file: entryPath, start: 0, end: 0 };
|
|
406
|
+
const mobileTarget = mobileLibraryTarget();
|
|
407
|
+
if (mobileTarget !== null) {
|
|
408
|
+
return {
|
|
409
|
+
ok: false,
|
|
410
|
+
diagnostics: [
|
|
411
|
+
targetRefusalDiag(mobileTarget, "standalone executable builds — mobile targets produce library-mode static archives (scriptc build --lib --profile <profile.json>) for an embedding app to link", entryLoc),
|
|
412
|
+
],
|
|
413
|
+
sourceTexts: new Map(),
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
const rawTarget = process.env["SCRIPTC_TARGET"] ?? "";
|
|
417
|
+
const mobileRefusal = mobileTargetRefusal(rawTarget);
|
|
418
|
+
if (mobileRefusal !== null) {
|
|
419
|
+
return {
|
|
420
|
+
ok: false,
|
|
421
|
+
diagnostics: [{ code: "SC3002", message: mobileRefusal, loc: entryLoc }],
|
|
422
|
+
sourceTexts: new Map(),
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (outputKind === "exe" && opts.sanitize !== true && process.env["SCRIPTC_FETCH_CURL"] !== "1") {
|
|
427
|
+
const refusal = nativeCodegenTargetRefusal();
|
|
428
|
+
if (refusal !== null)
|
|
429
|
+
return { ok: false, diagnostics: [nativeCodegenDiag("SC3002", refusal, entryPath)], sourceTexts: new Map() };
|
|
430
|
+
}
|
|
888
431
|
let ffi = null;
|
|
889
432
|
let ffiProfileBytes = null;
|
|
890
433
|
if (opts.ffiProfilePath !== undefined) {
|
|
@@ -959,32 +502,6 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
959
502
|
sourceTexts: new Map(),
|
|
960
503
|
};
|
|
961
504
|
}
|
|
962
|
-
// Mobile triples are library-mode targets: the archive an embedding app
|
|
963
|
-
// links is the artifact, and only the library-admissible runtime surface
|
|
964
|
-
// is verified on those device classes. The executable lane refuses before
|
|
965
|
-
// any frontend work — a pure env check, so the refusal needs no toolchain.
|
|
966
|
-
if (outputKind === "exe") {
|
|
967
|
-
const entryLoc = { file: entryPath, start: 0, end: 0 };
|
|
968
|
-
const mobileTarget = mobileLibraryTarget();
|
|
969
|
-
if (mobileTarget !== null) {
|
|
970
|
-
return {
|
|
971
|
-
ok: false,
|
|
972
|
-
diagnostics: [
|
|
973
|
-
targetRefusalDiag(mobileTarget, "standalone executable builds — mobile targets produce library-mode static archives (SCRIPTC_CC=zigcc scriptc build --lib --profile <profile.json>) for an embedding app to link", entryLoc),
|
|
974
|
-
],
|
|
975
|
-
sourceTexts: new Map(),
|
|
976
|
-
};
|
|
977
|
-
}
|
|
978
|
-
const rawTarget = process.env["SCRIPTC_TARGET"] ?? "";
|
|
979
|
-
const mobileRefusal = mobileTargetRefusal(rawTarget);
|
|
980
|
-
if (mobileRefusal !== null) {
|
|
981
|
-
return {
|
|
982
|
-
ok: false,
|
|
983
|
-
diagnostics: [{ code: "SC3002", message: mobileRefusal, loc: entryLoc }],
|
|
984
|
-
sourceTexts: new Map(),
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
505
|
const cacheRoot = outputKind === "exe" && provenanceSources() === null
|
|
989
506
|
? await prepareBuildCacheRoot(buildCacheRoot())
|
|
990
507
|
: null;
|
|
@@ -992,7 +509,7 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
992
509
|
if (outputKind === "exe") {
|
|
993
510
|
const implementation = await compilerImplementationIdentity();
|
|
994
511
|
const helperObjectRoute = opts.nativeProgramObject === true ||
|
|
995
|
-
(
|
|
512
|
+
(usesPrecompiledRuntimePack(opts, "llvm"));
|
|
996
513
|
earlyCacheOptions = {
|
|
997
514
|
entryPath,
|
|
998
515
|
outDir: opts.outDir,
|
|
@@ -1000,7 +517,7 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1000
517
|
emitIr: opts.emitIr ?? false,
|
|
1001
518
|
sanitize: opts.sanitize ?? false,
|
|
1002
519
|
dynamic: opts.dynamic ?? false,
|
|
1003
|
-
backend:
|
|
520
|
+
backend: "llvm",
|
|
1004
521
|
...(opts.optimization === "dev" ? { optimization: "dev" } : {}),
|
|
1005
522
|
...(opts.strip ? { strip: true } : {}),
|
|
1006
523
|
...(opts.windowsSubsystem === "gui" ? { windowsSubsystem: "gui" } : {}),
|
|
@@ -1028,6 +545,7 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1028
545
|
? null
|
|
1029
546
|
: await readEarlyExecutableCache(cacheRoot, earlyCacheOptions);
|
|
1030
547
|
if (earlyHit !== null) {
|
|
548
|
+
timing("executable-cache-hit");
|
|
1031
549
|
if (earlyCacheOptions === null) {
|
|
1032
550
|
throw new InternalCompilerError("executable cache hit without executable cache options");
|
|
1033
551
|
}
|
|
@@ -1038,27 +556,22 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1038
556
|
await publishEarlyExecutableRoute(cacheRoot, executableCacheOptions).catch(() => undefined);
|
|
1039
557
|
if (earlyHit.executableRestored) {
|
|
1040
558
|
await pruneBuildCache(cacheRoot);
|
|
559
|
+
timing("complete");
|
|
1041
560
|
return {
|
|
1042
561
|
ok: true,
|
|
1043
562
|
artifact: {
|
|
1044
563
|
kind: "exe",
|
|
1045
564
|
path: opts.outPath,
|
|
1046
|
-
translationUnitPath: earlyHit.
|
|
565
|
+
translationUnitPath: earlyHit.llvmPath,
|
|
1047
566
|
backend: earlyHit.native.backend,
|
|
1048
|
-
...(earlyHit.native.llvmRefusal === undefined
|
|
1049
|
-
? {}
|
|
1050
|
-
: { llvmRefusal: earlyHit.native.llvmRefusal }),
|
|
1051
567
|
},
|
|
1052
568
|
binaryPath: opts.outPath,
|
|
1053
|
-
|
|
569
|
+
llvmPath: earlyHit.llvmPath,
|
|
1054
570
|
backend: earlyHit.native.backend,
|
|
1055
571
|
...(earlyHit.irPath === undefined ? {} : { irPath: earlyHit.irPath }),
|
|
1056
|
-
...(earlyHit.native.llvmRefusal === undefined
|
|
1057
|
-
? {}
|
|
1058
|
-
: { llvmRefusal: earlyHit.native.llvmRefusal }),
|
|
1059
572
|
};
|
|
1060
573
|
}
|
|
1061
|
-
let nativeInputPath = earlyHit.
|
|
574
|
+
let nativeInputPath = earlyHit.llvmPath;
|
|
1062
575
|
let nativeProgramObject = null;
|
|
1063
576
|
const useRuntimePack = opts.nativeProgramObject === true ||
|
|
1064
577
|
usesPrecompiledRuntimePack(opts, earlyHit.native.backend);
|
|
@@ -1067,7 +580,7 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1067
580
|
throw new InternalCompilerError("native program-object cache hit restored a non-LLVM translation unit");
|
|
1068
581
|
}
|
|
1069
582
|
try {
|
|
1070
|
-
nativeProgramObject = await emitNativeProgramObject(entryPath, opts, await readFile(earlyHit.
|
|
583
|
+
nativeProgramObject = await emitNativeProgramObject(entryPath, opts, await readFile(earlyHit.llvmPath, "utf8"));
|
|
1071
584
|
nativeInputPath = nativeProgramObject.linkPath;
|
|
1072
585
|
}
|
|
1073
586
|
catch (err) {
|
|
@@ -1117,214 +630,21 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1117
630
|
artifact: {
|
|
1118
631
|
kind: "exe",
|
|
1119
632
|
path: opts.outPath,
|
|
1120
|
-
translationUnitPath: earlyHit.
|
|
633
|
+
translationUnitPath: earlyHit.llvmPath,
|
|
1121
634
|
backend: earlyHit.native.backend,
|
|
1122
|
-
...(earlyHit.native.llvmRefusal === undefined
|
|
1123
|
-
? {}
|
|
1124
|
-
: { llvmRefusal: earlyHit.native.llvmRefusal }),
|
|
1125
635
|
},
|
|
1126
636
|
binaryPath: opts.outPath,
|
|
1127
|
-
|
|
637
|
+
llvmPath: earlyHit.llvmPath,
|
|
1128
638
|
backend: earlyHit.native.backend,
|
|
1129
639
|
...(earlyHit.irPath === undefined ? {} : { irPath: earlyHit.irPath }),
|
|
1130
|
-
...(earlyHit.native.llvmRefusal === undefined
|
|
1131
|
-
? {}
|
|
1132
|
-
: { llvmRefusal: earlyHit.native.llvmRefusal }),
|
|
1133
640
|
};
|
|
1134
641
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
try {
|
|
1142
|
-
const fail = (diagnostics) => ({
|
|
1143
|
-
ok: false,
|
|
1144
|
-
diagnostics,
|
|
1145
|
-
sourceTexts: fe.sourceTexts(),
|
|
1146
|
-
});
|
|
1147
|
-
if (fe.preflight.length > 0)
|
|
1148
|
-
return fail(fe.preflight);
|
|
1149
|
-
try {
|
|
1150
|
-
lowered = fe.lower({
|
|
1151
|
-
dynamic: opts.dynamic ?? false,
|
|
1152
|
-
targetPlatform: buildPlatform,
|
|
1153
|
-
...(ffi !== null ? { ffiImports: ffi.functions } : {}),
|
|
1154
|
-
});
|
|
1155
|
-
}
|
|
1156
|
-
catch (e) {
|
|
1157
|
-
// The last-resort panic fence: an upstream tsgo panic that crossed a
|
|
1158
|
-
// checker call no statement/collection fence wrapped still becomes a
|
|
1159
|
-
// clean failed compile (anchored at the entry), never a crashed CLI.
|
|
1160
|
-
if (!isCheckerPanic(e))
|
|
1161
|
-
throw e;
|
|
1162
|
-
return fail([
|
|
1163
|
-
checkerPanicDiag(e.message.split("\n", 1)[0], { file: entryPath, start: 0, end: 0 }),
|
|
1164
|
-
]);
|
|
1165
|
-
}
|
|
1166
|
-
if (lowered.module === null)
|
|
1167
|
-
return fail(lowered.diagnostics);
|
|
1168
|
-
const validation = validateModule(lowered.module);
|
|
1169
|
-
if (validation.length > 0) {
|
|
1170
|
-
return fail(validation.map((v) => iceDiag(v.message, v.loc)));
|
|
1171
|
-
}
|
|
1172
|
-
if (buildPlatform === "wasi") {
|
|
1173
|
-
const entryLoc = { file: entryPath, start: 0, end: 0 };
|
|
1174
|
-
if (opts.sanitize) {
|
|
1175
|
-
return fail([targetRefusalDiag("wasm32-wasi", "--sanitize", entryLoc)]);
|
|
1176
|
-
}
|
|
1177
|
-
if (ffi !== null) {
|
|
1178
|
-
return fail([targetRefusalDiag("wasm32-wasi", "native FFI manifests", entryLoc)]);
|
|
1179
|
-
}
|
|
1180
|
-
const unavailable = moduleWasiUnavailableSurface(lowered.module);
|
|
1181
|
-
if (unavailable !== null) {
|
|
1182
|
-
return fail([targetRefusalDiag("wasm32-wasi", unavailable.surface, unavailable.loc)]);
|
|
1183
|
-
}
|
|
1184
|
-
if (opts.backend === "c" || outputKind === "c") {
|
|
1185
|
-
const asyncSurface = moduleLibAsyncSurface(lowered.module);
|
|
1186
|
-
if (asyncSurface !== null) {
|
|
1187
|
-
return fail([
|
|
1188
|
-
backendRefusalDiag("c", "wasm32-wasi", asyncSurface.surface, asyncSurface.loc),
|
|
1189
|
-
]);
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
entryText = fe.entryText();
|
|
1194
|
-
sourceTexts = fe.sourceTexts();
|
|
1195
|
-
}
|
|
1196
|
-
finally {
|
|
1197
|
-
fe.dispose();
|
|
1198
|
-
}
|
|
1199
|
-
const stem = basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
1200
|
-
const defaultSourcePaths = {
|
|
1201
|
-
ir: join(opts.outDir, `${stem}.ir.json`),
|
|
1202
|
-
c: join(opts.outDir, `${stem}.c`),
|
|
1203
|
-
llvm: join(opts.outDir, `${stem}.ll`),
|
|
1204
|
-
};
|
|
1205
|
-
const debugOptions = opts.optimization === "dev" && !opts.strip
|
|
1206
|
-
? { debugSources: sourceTexts }
|
|
1207
|
-
: {};
|
|
1208
|
-
if (outputKind === "ir") {
|
|
1209
|
-
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
1210
|
-
await writeFile(opts.outPath, serializeModule(lowered.module));
|
|
1211
|
-
return { ok: true, artifact: { kind: "ir", path: opts.outPath } };
|
|
1212
|
-
}
|
|
1213
|
-
if (outputKind === "c") {
|
|
1214
|
-
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
1215
|
-
await writeFile(opts.outPath, emitCModule(lowered.module, entryText, debugOptions));
|
|
1216
|
-
return { ok: true, artifact: { kind: "c", path: opts.outPath } };
|
|
1217
|
-
}
|
|
1218
|
-
if (outputKind === "llvm" || outputKind === "asm" || outputKind === "obj") {
|
|
1219
|
-
let llvm;
|
|
1220
|
-
try {
|
|
1221
|
-
llvm = emitLlvmModule(lowered.module, {
|
|
1222
|
-
...debugOptions,
|
|
1223
|
-
pointerBits: buildPlatform === "wasi" ? 32 : 64,
|
|
1224
|
-
wasi: buildPlatform === "wasi",
|
|
1225
|
-
runtimeAbiMarker: outputKind === "obj",
|
|
1226
|
-
});
|
|
1227
|
-
}
|
|
1228
|
-
catch (err) {
|
|
1229
|
-
if (!(err instanceof LlvmUnsupportedError))
|
|
1230
|
-
throw err;
|
|
1231
|
-
return { ok: false, diagnostics: [llvmRefusalDiag(err, entryPath)], sourceTexts };
|
|
1232
|
-
}
|
|
1233
|
-
if (outputKind === "llvm") {
|
|
1234
|
-
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
1235
|
-
await writeFile(opts.outPath, llvm);
|
|
1236
|
-
}
|
|
1237
|
-
else {
|
|
1238
|
-
try {
|
|
1239
|
-
await emitNativeArtifact({
|
|
1240
|
-
outputPath: opts.outPath,
|
|
1241
|
-
llvm,
|
|
1242
|
-
outputKind,
|
|
1243
|
-
sourcePath: entryPath,
|
|
1244
|
-
optimization: opts.optimization === "dev" ? "0" : "2",
|
|
1245
|
-
...(opts.sanitize === undefined ? {} : { sanitize: opts.sanitize }),
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
catch (err) {
|
|
1249
|
-
if (!(err instanceof NativeCodegenError))
|
|
1250
|
-
throw err;
|
|
1251
|
-
return {
|
|
1252
|
-
ok: false,
|
|
1253
|
-
diagnostics: [nativeCodegenDiag(err.diagnosticCode, err.message, entryPath)],
|
|
1254
|
-
sourceTexts,
|
|
1255
|
-
};
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
if (outputKind === "obj" && opts.nativeLinkInfo === true) {
|
|
1259
|
-
const target = nativeCodegenTarget();
|
|
1260
|
-
if (target === null) {
|
|
1261
|
-
throw new InternalCompilerError("native object emitted without a native target");
|
|
1262
|
-
}
|
|
1263
|
-
return {
|
|
1264
|
-
ok: true,
|
|
1265
|
-
artifact: {
|
|
1266
|
-
kind: "obj",
|
|
1267
|
-
path: opts.outPath,
|
|
1268
|
-
nativeLinkInfo: await createNativeLinkInfo({
|
|
1269
|
-
programObject: opts.outPath,
|
|
1270
|
-
target,
|
|
1271
|
-
features: executableNativeFeatures(lowered.module, "llvm", opts.dynamic ?? false, opts.optimization ?? "release"),
|
|
1272
|
-
ffi,
|
|
1273
|
-
optimization: opts.optimization ?? "release",
|
|
1274
|
-
}),
|
|
1275
|
-
},
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
return { ok: true, artifact: { kind: outputKind, path: opts.outPath } };
|
|
1279
|
-
}
|
|
1280
|
-
await mkdir(opts.outDir, { recursive: true });
|
|
1281
|
-
// Both backends hang off the same in-memory IrModule (never the JSON
|
|
1282
|
-
// dump); the LLVM backend's .ll takes the .c's seat on the exact clang
|
|
1283
|
-
// command line below — compileC accepts either. The default lane tries
|
|
1284
|
-
// LLVM first; a tier refusal retries ONLY the emit with the C backend
|
|
1285
|
-
// (the frontend ran once, the IR is backend-agnostic — nothing recompiles).
|
|
1286
|
-
let cPath = defaultSourcePaths.c;
|
|
1287
|
-
let backend = "c";
|
|
1288
|
-
let llvmSource = null;
|
|
1289
|
-
let llvmRefusal;
|
|
1290
|
-
if (opts.backend !== "c") {
|
|
1291
|
-
try {
|
|
1292
|
-
const ll = emitLlvmModule(lowered.module, {
|
|
1293
|
-
...debugOptions,
|
|
1294
|
-
pointerBits: buildPlatform === "wasi" ? 32 : 64,
|
|
1295
|
-
wasi: buildPlatform === "wasi",
|
|
1296
|
-
runtimeAbiMarker: opts.nativeProgramObject === true ||
|
|
1297
|
-
usesPrecompiledRuntimePack(opts, "llvm"),
|
|
1298
|
-
});
|
|
1299
|
-
cPath = defaultSourcePaths.llvm;
|
|
1300
|
-
await writeFile(cPath, ll);
|
|
1301
|
-
llvmSource = ll;
|
|
1302
|
-
backend = "llvm";
|
|
1303
|
-
}
|
|
1304
|
-
catch (err) {
|
|
1305
|
-
if (!(err instanceof LlvmUnsupportedError))
|
|
1306
|
-
throw err;
|
|
1307
|
-
// Explicit backend "llvm" keeps the fail-loudly contract (the
|
|
1308
|
-
// debugging/CI pin): SC3001, never a silent lane change.
|
|
1309
|
-
if (opts.backend === "llvm" || buildPlatform === "wasi") {
|
|
1310
|
-
return { ok: false, diagnostics: [llvmRefusalDiag(err, entryPath)], sourceTexts };
|
|
1311
|
-
}
|
|
1312
|
-
llvmRefusal = err.kind;
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
if (backend === "c") {
|
|
1316
|
-
await writeFile(cPath, emitCModule(lowered.module, entryText, debugOptions));
|
|
1317
|
-
}
|
|
1318
|
-
let irPath;
|
|
1319
|
-
if (opts.emitIr) {
|
|
1320
|
-
irPath = defaultSourcePaths.ir;
|
|
1321
|
-
await writeFile(irPath, serializeModule(lowered.module));
|
|
1322
|
-
}
|
|
1323
|
-
const nativeFeatures = executableNativeFeatures(lowered.module, backend, opts.dynamic ?? false, opts.optimization ?? "release", llvmRefusal);
|
|
1324
|
-
const programSplit = backend === "llvm" && (opts.optimization ?? "release") === "dev" &&
|
|
1325
|
-
!(opts.sanitize ?? false) && llvmSource !== null
|
|
1326
|
-
? splitLlvmProgram(llvmSource)
|
|
1327
|
-
: null;
|
|
642
|
+
timing("executable-cache-miss");
|
|
643
|
+
const prepared = await prepareExecutableInput(entryPath, opts, ffi, buildPlatform, timing);
|
|
644
|
+
if ("ok" in prepared)
|
|
645
|
+
return prepared;
|
|
646
|
+
const { llvmSource, llvmPath, irPath, nativeFeatures, programSplit, sourceTexts } = prepared;
|
|
647
|
+
const backend = "llvm";
|
|
1328
648
|
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
1329
649
|
if (earlyCacheOptions === null) {
|
|
1330
650
|
throw new InternalCompilerError("executable emission without executable cache options");
|
|
@@ -1341,6 +661,7 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1341
661
|
}
|
|
1342
662
|
try {
|
|
1343
663
|
nativeProgramObject = await emitNativeProgramObject(entryPath, opts, llvmSource);
|
|
664
|
+
timing("native-object");
|
|
1344
665
|
}
|
|
1345
666
|
catch (err) {
|
|
1346
667
|
if (!(err instanceof NativeCodegenError))
|
|
@@ -1352,9 +673,9 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1352
673
|
};
|
|
1353
674
|
}
|
|
1354
675
|
}
|
|
1355
|
-
await compileExecutableNative(nativeFeatures, nativeProgramObject?.linkPath ??
|
|
676
|
+
await compileExecutableNative(nativeFeatures, nativeProgramObject?.linkPath ?? llvmPath, opts.outPath, opts.sanitize ?? false, ffi, opts.windowsSubsystem, opts.strip, programSplit, nativeProgramObject?.dependencies, opts.nativeProgramObject === true ? undefined : async ({ dependencies }) => {
|
|
1356
677
|
await publishEarlyExecutableCache(cacheRoot, executableCacheOptions, {
|
|
1357
|
-
|
|
678
|
+
llvmPath,
|
|
1358
679
|
native: nativeFeatures,
|
|
1359
680
|
executableRestored: true,
|
|
1360
681
|
nativeDependencies: dependencies,
|
|
@@ -1363,6 +684,7 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1363
684
|
});
|
|
1364
685
|
publishedExecutable = true;
|
|
1365
686
|
});
|
|
687
|
+
timing("native-link");
|
|
1366
688
|
if (nativeProgramObject !== null && opts.nativeProgramObject === true) {
|
|
1367
689
|
await rename(nativeProgramObject.linkPath, nativeProgramObject.artifactPath);
|
|
1368
690
|
}
|
|
@@ -1389,7 +711,7 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1389
711
|
}
|
|
1390
712
|
if (!publishedExecutable) {
|
|
1391
713
|
await publishEarlyExecutableCache(cacheRoot, executableCacheOptions, {
|
|
1392
|
-
|
|
714
|
+
llvmPath,
|
|
1393
715
|
native: nativeFeatures,
|
|
1394
716
|
executableRestored: false,
|
|
1395
717
|
frontend: frontendInputs.snapshot(),
|
|
@@ -1397,405 +719,87 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
1397
719
|
}).catch(() => undefined);
|
|
1398
720
|
}
|
|
1399
721
|
await pruneBuildCache(cacheRoot);
|
|
722
|
+
timing("complete");
|
|
1400
723
|
return {
|
|
1401
724
|
ok: true,
|
|
1402
725
|
artifact: {
|
|
1403
726
|
kind: "exe",
|
|
1404
727
|
path: opts.outPath,
|
|
1405
|
-
translationUnitPath:
|
|
728
|
+
translationUnitPath: llvmPath,
|
|
1406
729
|
backend,
|
|
1407
|
-
...(llvmRefusal !== undefined ? { llvmRefusal } : {}),
|
|
1408
730
|
},
|
|
1409
731
|
binaryPath: opts.outPath,
|
|
1410
|
-
|
|
732
|
+
llvmPath,
|
|
1411
733
|
backend,
|
|
1412
734
|
...(irPath !== undefined ? { irPath } : {}),
|
|
1413
|
-
...(llvmRefusal !== undefined ? { llvmRefusal } : {}),
|
|
1414
|
-
};
|
|
1415
|
-
}
|
|
1416
|
-
/** The marshalling-class fit over IR types (design §4.2 + the ratified
|
|
1417
|
-
* integer plumbing classes): number is every f64-backed class, bool/string
|
|
1418
|
-
* map directly, bytes is the u8 element kind. */
|
|
1419
|
-
function libClassFits(cls, t) {
|
|
1420
|
-
switch (cls) {
|
|
1421
|
-
case "bool":
|
|
1422
|
-
return t.kind === "bool";
|
|
1423
|
-
case "string":
|
|
1424
|
-
return t.kind === "string";
|
|
1425
|
-
case "bytes":
|
|
1426
|
-
return t.kind === "bytes" && t.elem === "u8";
|
|
1427
|
-
default: // f64 and the u8/u32/i32 plumbing classes
|
|
1428
|
-
return t.kind === "f64";
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
/** Resolve the profile's export map against the entry module — SC4002/
|
|
1432
|
-
* SC4004/SC4007 from the declaration facts, SC4003 from the lowered IR
|
|
1433
|
-
* signatures — and land the library section on the module. */
|
|
1434
|
-
function resolveLibrarySection(profile, entryInfo, mod, entryPath) {
|
|
1435
|
-
const diagnostics = [];
|
|
1436
|
-
const entryLoc = { file: entryPath, start: 0, end: 0 };
|
|
1437
|
-
const fnByName = new Map(mod.functions.map((f) => [f.name, f]));
|
|
1438
|
-
const exports = [];
|
|
1439
|
-
for (const e of profile.exports) {
|
|
1440
|
-
const info = entryInfo.get(e.export);
|
|
1441
|
-
if (info === undefined) {
|
|
1442
|
-
diagnostics.push(libExportUnresolvedDiag(e.export, "the entry module has no exported function declaration by that name", entryLoc));
|
|
1443
|
-
continue;
|
|
1444
|
-
}
|
|
1445
|
-
if (info.generic) {
|
|
1446
|
-
diagnostics.push(libGenericExportDiag(e.export, info.loc));
|
|
1447
|
-
continue;
|
|
1448
|
-
}
|
|
1449
|
-
if (info.async || info.generator) {
|
|
1450
|
-
diagnostics.push(libAsyncExportDiag(e.export, info.async ? "async" : "generator", info.loc));
|
|
1451
|
-
continue;
|
|
1452
|
-
}
|
|
1453
|
-
const fn = fnByName.get(e.export);
|
|
1454
|
-
if (fn === undefined) {
|
|
1455
|
-
diagnostics.push(libExportUnresolvedDiag(e.export, "the export did not lower to a compiled function", info.loc));
|
|
1456
|
-
continue;
|
|
1457
|
-
}
|
|
1458
|
-
if (fn.params.length !== e.params.length) {
|
|
1459
|
-
diagnostics.push(libUnmappableSignatureDiag(e.export, "signature", `has ${fn.params.length} parameter(s) but the profile declares ${e.params.length} marshalling class(es)`, info.loc));
|
|
1460
|
-
continue;
|
|
1461
|
-
}
|
|
1462
|
-
let bad = false;
|
|
1463
|
-
e.params.forEach((cls, i) => {
|
|
1464
|
-
if (!libClassFits(cls, fn.params[i].type)) {
|
|
1465
|
-
bad = true;
|
|
1466
|
-
diagnostics.push(libUnmappableSignatureDiag(e.export, `parameter ${i + 1} ('${fn.params[i].name}')`, `has IR type '${fn.params[i].type.kind}', which does not fit the declared marshalling class '${cls}'`, info.loc));
|
|
1467
|
-
}
|
|
1468
|
-
});
|
|
1469
|
-
if (e.returns === "void" ? fn.returnType.kind !== "void" : !libClassFits(e.returns, fn.returnType)) {
|
|
1470
|
-
bad = true;
|
|
1471
|
-
diagnostics.push(libUnmappableSignatureDiag(e.export, "the return", `has IR type '${fn.returnType.kind}', which does not fit the declared marshalling class '${e.returns}'`, info.loc));
|
|
1472
|
-
}
|
|
1473
|
-
if (!bad) {
|
|
1474
|
-
const resolvedExport = {
|
|
1475
|
-
symbol: e.symbol,
|
|
1476
|
-
fnName: e.export,
|
|
1477
|
-
params: e.params,
|
|
1478
|
-
returns: e.returns,
|
|
1479
|
-
};
|
|
1480
|
-
if (e.params.includes("bytes")) {
|
|
1481
|
-
// The wrapper's one host-contract trap (an inbound bytes length
|
|
1482
|
-
// past the marshalling class's range) is assembled HERE, once, as
|
|
1483
|
-
// the structured trap-teaching message: the profile's teaching for
|
|
1484
|
-
// SC4012 (or the mode's default text), the code, the trapping
|
|
1485
|
-
// export's C symbol exactly as the host linked it, and the
|
|
1486
|
-
// profile's remediation when supplied — so both backends emit the
|
|
1487
|
-
// same bytes and the sink sees one canonical message.
|
|
1488
|
-
resolvedExport.inboundBytesTrap = assembleTrapTeaching(profileTeaching(profile, LIB_INBOUND_BYTES_TRAP_CODE) ??
|
|
1489
|
-
"scriptc: library inbound bytes length out of range\n", LIB_INBOUND_BYTES_TRAP_CODE, e.symbol, profileRemediation(profile, LIB_INBOUND_BYTES_TRAP_CODE));
|
|
1490
|
-
}
|
|
1491
|
-
if (e.params.includes("i64") || e.params.includes("u64")) {
|
|
1492
|
-
// The sibling host-contract trap for inbound declared-integer
|
|
1493
|
-
// parameters (ask 4): a value past ±(2^53−1) cannot ride f64
|
|
1494
|
-
// exactly, and silent rounding is a coercion the author never
|
|
1495
|
-
// wrote. Same code (SC4012 — one host-contract story), same
|
|
1496
|
-
// assembly-once discipline.
|
|
1497
|
-
resolvedExport.inboundIntTrap = assembleTrapTeaching(profileTeaching(profile, LIB_INBOUND_BYTES_TRAP_CODE) ??
|
|
1498
|
-
"scriptc: library inbound integer parameter out of range\n", LIB_INBOUND_BYTES_TRAP_CODE, e.symbol, profileRemediation(profile, LIB_INBOUND_BYTES_TRAP_CODE));
|
|
1499
|
-
}
|
|
1500
|
-
exports.push(resolvedExport);
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
if (diagnostics.length > 0)
|
|
1504
|
-
return { diagnostics };
|
|
1505
|
-
// The runtime detected-trap overlay rows: one per family code the profile
|
|
1506
|
-
// declares teaching or remediation text for, in the registry family's
|
|
1507
|
-
// order. Both backends emit exactly these rows as the program TU's
|
|
1508
|
-
// overlay table, so the funnel-assembled sink message is
|
|
1509
|
-
// emission-invariant by construction. (SC4012 stays compile-time
|
|
1510
|
-
// assembled into the wrapper's message above and never reaches the
|
|
1511
|
-
// funnel's assembly path.)
|
|
1512
|
-
const trapOverlays = [];
|
|
1513
|
-
for (const code of LIB_RUNTIME_TRAP_CODES) {
|
|
1514
|
-
const teaching = profileTeaching(profile, code);
|
|
1515
|
-
const remediation = profileRemediation(profile, code);
|
|
1516
|
-
if (teaching !== undefined || remediation !== undefined) {
|
|
1517
|
-
trapOverlays.push({
|
|
1518
|
-
code,
|
|
1519
|
-
...(teaching !== undefined ? { teaching } : {}),
|
|
1520
|
-
...(remediation !== undefined ? { remediation } : {}),
|
|
1521
|
-
});
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
return {
|
|
1525
|
-
lib: {
|
|
1526
|
-
profileName: profile.name,
|
|
1527
|
-
prefix: profile.prefix,
|
|
1528
|
-
initSymbol: profile.initSymbol,
|
|
1529
|
-
sinkRegisterSymbol: profile.sinkRegisterSymbol,
|
|
1530
|
-
collectSymbol: profile.collectSymbol,
|
|
1531
|
-
resultResetSymbol: profile.resultResetSymbol,
|
|
1532
|
-
threadInstances: profile.instancePerThread,
|
|
1533
|
-
// Host-callback channels: declaration order is the runtime slot
|
|
1534
|
-
// assignment, and the unregistered-call trap text is assembled HERE,
|
|
1535
|
-
// once, so both backends emit identical constant bytes (a DETECTED
|
|
1536
|
-
// trap: the funnel classifies the "scriptc: library callback "
|
|
1537
|
-
// prefix as SC4025 and names the entry the host called — the entry
|
|
1538
|
-
// is runtime knowledge, so no compile-time SC4012-style assembly
|
|
1539
|
-
// can carry it). Both fields stay absent on callback-free profiles
|
|
1540
|
-
// (the byte-identity guarantee).
|
|
1541
|
-
...(profile.callbacks.length > 0
|
|
1542
|
-
? {
|
|
1543
|
-
callbackRegisterSymbol: profile.callbackRegisterSymbol,
|
|
1544
|
-
callbacks: profile.callbacks.map((cb, i) => ({
|
|
1545
|
-
name: cb.name,
|
|
1546
|
-
slot: i,
|
|
1547
|
-
params: [...cb.params],
|
|
1548
|
-
returns: cb.returns,
|
|
1549
|
-
unregisteredTrap: `scriptc: library callback '${cb.name}' invoked before registration\n`,
|
|
1550
|
-
})),
|
|
1551
|
-
}
|
|
1552
|
-
: {}),
|
|
1553
|
-
exports,
|
|
1554
|
-
trapOverlays,
|
|
1555
|
-
},
|
|
1556
|
-
};
|
|
1557
|
-
}
|
|
1558
|
-
/** The export map's integer-slot obligations (ask 4): i64/u64 params and
|
|
1559
|
-
* returns become declared boundary slots keyed `exports.<name>.params[i]`
|
|
1560
|
-
* / `exports.<name>.return`; the u8/u32/i32 plumbing classes contribute
|
|
1561
|
-
* their proven inbound shapes as parameter seeds (the wrapper's coercion
|
|
1562
|
-
* contract), tightening the intraprocedural analysis at zero declaration
|
|
1563
|
-
* cost. Sidecar-declared slots (record fields, msg arms, helper params
|
|
1564
|
-
* and returns) merge into the same config at sidecar build. */
|
|
1565
|
-
function libraryIntSlotConfig(profile) {
|
|
1566
|
-
const cfg = { fns: new Map(), records: new Map() };
|
|
1567
|
-
for (const e of profile.exports) {
|
|
1568
|
-
const params = e.params.map((c) => (c === "i64" || c === "u64" ? c : null));
|
|
1569
|
-
const ret = e.returns === "i64" || e.returns === "u64" ? e.returns : null;
|
|
1570
|
-
const paramSeeds = e.params.map((c) => (c === "u8" || c === "u32" || c === "i32" ? classSeed(c) : null));
|
|
1571
|
-
if (params.every((p) => p === null) && ret === null && paramSeeds.every((s) => s === null))
|
|
1572
|
-
continue;
|
|
1573
|
-
const slots = {
|
|
1574
|
-
fnName: e.export,
|
|
1575
|
-
params,
|
|
1576
|
-
paramPaths: e.params.map((c, i) => (c === "i64" || c === "u64" ? `exports.${e.export}.params[${i}]` : null)),
|
|
1577
|
-
ret,
|
|
1578
|
-
retPath: ret !== null ? `exports.${e.export}.return` : null,
|
|
1579
|
-
paramSeeds,
|
|
1580
|
-
};
|
|
1581
|
-
cfg.fns.set(e.export, slots);
|
|
1582
|
-
}
|
|
1583
|
-
return cfg;
|
|
1584
|
-
}
|
|
1585
|
-
/** Match the sidecar syntax's exact structural type projection against the
|
|
1586
|
-
* frontend's interned IR registries. The pattern deliberately mirrors
|
|
1587
|
-
* ShapeRegistry's identity: every field name and recursively mapped field
|
|
1588
|
-
* type participates. Tagged payload records additionally accept omission
|
|
1589
|
-
* of their `kind` field because the lowering may carry that discriminant
|
|
1590
|
-
* only in the surrounding union tag. */
|
|
1591
|
-
function sidecarRecordMatcher(mod) {
|
|
1592
|
-
const records = new Map((mod.records ?? []).map((shape) => [shape.id, shape]));
|
|
1593
|
-
const unions = new Map((mod.unions ?? []).map((union) => [union.id, union]));
|
|
1594
|
-
const recordMatches = (pattern, shape) => {
|
|
1595
|
-
if (shape.tuple === true || shape.indexValue !== undefined)
|
|
1596
|
-
return false;
|
|
1597
|
-
const variants = [pattern.fields];
|
|
1598
|
-
if (pattern.kindMayBeOmitted === true) {
|
|
1599
|
-
variants.push(pattern.fields.filter((field) => field.name !== "kind"));
|
|
1600
|
-
}
|
|
1601
|
-
return variants.some((fields) => fields.length === shape.fields.length &&
|
|
1602
|
-
fields.every((field) => {
|
|
1603
|
-
const actual = shape.fields.find((candidate) => candidate.name === field.name);
|
|
1604
|
-
return actual !== undefined && typeMatches(field.type, actual.type);
|
|
1605
|
-
}));
|
|
1606
|
-
};
|
|
1607
|
-
const unionMatches = (patterns, actual) => {
|
|
1608
|
-
if (patterns.length !== actual.length)
|
|
1609
|
-
return false;
|
|
1610
|
-
const used = new Set();
|
|
1611
|
-
const visit = (index) => {
|
|
1612
|
-
if (index === patterns.length)
|
|
1613
|
-
return true;
|
|
1614
|
-
for (let i = 0; i < actual.length; i++) {
|
|
1615
|
-
if (used.has(i) || !typeMatches(patterns[index], actual[i]))
|
|
1616
|
-
continue;
|
|
1617
|
-
used.add(i);
|
|
1618
|
-
if (visit(index + 1))
|
|
1619
|
-
return true;
|
|
1620
|
-
used.delete(i);
|
|
1621
|
-
}
|
|
1622
|
-
return false;
|
|
1623
|
-
};
|
|
1624
|
-
return visit(0);
|
|
1625
|
-
};
|
|
1626
|
-
const typeMatches = (pattern, actual) => {
|
|
1627
|
-
switch (pattern.kind) {
|
|
1628
|
-
case "f64":
|
|
1629
|
-
case "string":
|
|
1630
|
-
case "bool":
|
|
1631
|
-
case "nullT":
|
|
1632
|
-
case "undefinedT":
|
|
1633
|
-
case "dyn":
|
|
1634
|
-
return actual.kind === pattern.kind;
|
|
1635
|
-
case "bytes":
|
|
1636
|
-
return actual.kind === "bytes" && actual.elem === pattern.elem;
|
|
1637
|
-
case "array":
|
|
1638
|
-
return actual.kind === "array" && typeMatches(pattern.elem, actual.elem);
|
|
1639
|
-
case "record": {
|
|
1640
|
-
if (actual.kind !== "record")
|
|
1641
|
-
return false;
|
|
1642
|
-
const shape = records.get(actual.shapeId);
|
|
1643
|
-
return shape !== undefined && recordMatches(pattern, shape);
|
|
1644
|
-
}
|
|
1645
|
-
case "union": {
|
|
1646
|
-
if (actual.kind !== "union")
|
|
1647
|
-
return false;
|
|
1648
|
-
const union = unions.get(actual.unionId);
|
|
1649
|
-
return union !== undefined && unionMatches(pattern.arms, union.arms);
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
735
|
};
|
|
1653
|
-
return (pattern, shape) => recordMatches(pattern, shape);
|
|
1654
|
-
}
|
|
1655
|
-
/** Merge the sidecar-resolved integer slots (ask 4) into the inference
|
|
1656
|
-
* config: helper slots key by function name and IR parameter index (the
|
|
1657
|
-
* projection already shifted past the model receiver); record-field
|
|
1658
|
-
* slots map onto every interned IR shape whose complete structural field
|
|
1659
|
-
* signature matches the projected record's. Shapes intern structurally,
|
|
1660
|
-
* so a same-shaped second type shares the obligation. DECLARED paths with
|
|
1661
|
-
* the same class coalesce while retaining every source path for verdicts;
|
|
1662
|
-
* differing classes refuse because one lowered field cannot seed or check
|
|
1663
|
-
* two distinct class contracts without arm provenance. A
|
|
1664
|
-
* record fact that matches no shape binds nothing: no compiled code
|
|
1665
|
-
* constructs the type (the contract surface — init/update/subscriptions
|
|
1666
|
-
* and every helper — is force-lowered whenever integer slots are
|
|
1667
|
-
* declared, so this is genuine vacuity, not dead-stripping). */
|
|
1668
|
-
function mergeSidecarIntSlots(cfg, facts, mod) {
|
|
1669
|
-
const recordMatches = sidecarRecordMatcher(mod);
|
|
1670
|
-
for (const h of facts.helpers) {
|
|
1671
|
-
const fn = mod.functions.find((f) => f.name === h.fnName);
|
|
1672
|
-
const arity = Math.max(fn?.params.length ?? 0, (h.index ?? 0) + 1);
|
|
1673
|
-
let slots = cfg.fns.get(h.fnName);
|
|
1674
|
-
if (slots === undefined) {
|
|
1675
|
-
slots = {
|
|
1676
|
-
fnName: h.fnName,
|
|
1677
|
-
params: new Array(arity).fill(null),
|
|
1678
|
-
paramPaths: new Array(arity).fill(null),
|
|
1679
|
-
ret: null,
|
|
1680
|
-
retPath: null,
|
|
1681
|
-
paramSeeds: new Array(arity).fill(null),
|
|
1682
|
-
};
|
|
1683
|
-
cfg.fns.set(h.fnName, slots);
|
|
1684
|
-
}
|
|
1685
|
-
if (h.kind === "param") {
|
|
1686
|
-
const i = h.index;
|
|
1687
|
-
while (slots.params.length <= i) {
|
|
1688
|
-
slots.params.push(null);
|
|
1689
|
-
slots.paramPaths.push(null);
|
|
1690
|
-
slots.paramSeeds.push(null);
|
|
1691
|
-
}
|
|
1692
|
-
slots.params[i] = h.cls;
|
|
1693
|
-
slots.paramPaths[i] = h.path;
|
|
1694
|
-
}
|
|
1695
|
-
else {
|
|
1696
|
-
slots.ret = h.cls;
|
|
1697
|
-
slots.retPath = h.path;
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
for (const r of facts.records) {
|
|
1701
|
-
for (const shape of mod.records ?? []) {
|
|
1702
|
-
if (!recordMatches(r.shape, shape))
|
|
1703
|
-
continue;
|
|
1704
|
-
const target = shape.fields.find((f) => f.name === r.targetField);
|
|
1705
|
-
if (target === undefined || numberCarrierKind(target.type, mod) === null)
|
|
1706
|
-
continue;
|
|
1707
|
-
let m = cfg.records.get(shape.id);
|
|
1708
|
-
if (m === undefined) {
|
|
1709
|
-
m = new Map();
|
|
1710
|
-
cfg.records.set(shape.id, m);
|
|
1711
|
-
}
|
|
1712
|
-
const existing = m.get(r.targetField);
|
|
1713
|
-
if (existing !== undefined && existing.cls !== r.cls) {
|
|
1714
|
-
const paths = [
|
|
1715
|
-
...existing.paths.map((path) => `'${path}' (${existing.cls})`),
|
|
1716
|
-
`'${r.path}' (${r.cls})`,
|
|
1717
|
-
];
|
|
1718
|
-
return {
|
|
1719
|
-
ok: false,
|
|
1720
|
-
diagnostic: libSidecarDiag(`integer slots ${paths.join(" and ")} collapse to the same lowered record field '${r.targetField}' — their proof obligations cannot be kept distinct`, r.loc, "kind-tagged union arms and structurally identical records may share one lowered shape — same-class declarations coalesce, but differing classes require distinct structural shapes or at most one classified slot"),
|
|
1721
|
-
};
|
|
1722
|
-
}
|
|
1723
|
-
if (existing === undefined) {
|
|
1724
|
-
m.set(r.targetField, { cls: r.cls, paths: [r.path] });
|
|
1725
|
-
}
|
|
1726
|
-
else if (!existing.paths.includes(r.path)) {
|
|
1727
|
-
existing.paths.push(r.path);
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
return { ok: true, config: cfg };
|
|
1732
736
|
}
|
|
737
|
+
/* ── library emission mode ───────────────────────────────────────────────
|
|
738
|
+
* `scriptc build --lib --profile <file>`: compile the profile's ONE entry module
|
|
739
|
+
* to a linkable static archive (<name>.lib.a) exporting exactly the
|
|
740
|
+
* profile-declared C-ABI symbols — no main, no event loop, no signal
|
|
741
|
+
* handlers, traps to the host's registered sink. The profile pins the
|
|
742
|
+
* emission; there is no fallback concept on this path (an out-of-tier
|
|
743
|
+
* program under emission "llvm" is SC3001, fail-loudly). */
|
|
1733
744
|
function libraryNativeFeatures(mod, backend) {
|
|
745
|
+
const features = moduleRuntimeFeatures(mod);
|
|
1734
746
|
return {
|
|
1735
747
|
backend,
|
|
1736
|
-
regex:
|
|
1737
|
-
assert:
|
|
1738
|
-
inspect:
|
|
1739
|
-
symbol:
|
|
1740
|
-
bigint:
|
|
1741
|
-
searchParams:
|
|
1742
|
-
emitter:
|
|
1743
|
-
zlib:
|
|
1744
|
-
copying:
|
|
1745
|
-
textDecoderLegacy:
|
|
748
|
+
regex: features.regex,
|
|
749
|
+
assert: features.assert,
|
|
750
|
+
inspect: features.inspect,
|
|
751
|
+
symbol: features.symbol,
|
|
752
|
+
bigint: features.bigint,
|
|
753
|
+
searchParams: features.searchParams,
|
|
754
|
+
emitter: features.emitter,
|
|
755
|
+
zlib: features.zlib,
|
|
756
|
+
copying: features.copying,
|
|
757
|
+
textDecoderLegacy: features.legacyTextDecoder,
|
|
758
|
+
dynInvoke: features.dynInvoke,
|
|
1746
759
|
...(mod.lib?.identity !== undefined ? { buildId: mod.lib.identity.buildId } : {}),
|
|
1747
760
|
};
|
|
1748
761
|
}
|
|
1749
|
-
function
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
profile.
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
...(profile.sidecar !== null
|
|
1758
|
-
? [profile.sidecar.buildIdSymbol, profile.sidecar.abiVersionSymbol]
|
|
1759
|
-
: []),
|
|
1760
|
-
...profile.exports.map((entry) => entry.symbol),
|
|
1761
|
-
]
|
|
1762
|
-
: undefined;
|
|
1763
|
-
}
|
|
1764
|
-
async function compileLibraryNative(profile, cPath, archivePath, sanitize, features) {
|
|
762
|
+
async function compileLibraryNative(profile, llvmPath, archivePath, sanitize, features) {
|
|
763
|
+
const wasmTarget = nativeCodegenTarget();
|
|
764
|
+
if (wasmTarget?.platform === "wasi") {
|
|
765
|
+
await compilePackedLibrary({
|
|
766
|
+
cPath: llvmPath, outPath: archivePath, optimization: profile.optimization, ...features,
|
|
767
|
+
}, wasmTarget, libraryWasmExports(profile));
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
1765
770
|
const localizeSymbols = libraryLocalizeSymbols(profile);
|
|
1766
|
-
let
|
|
771
|
+
let identityLlvmSource;
|
|
1767
772
|
let programSource;
|
|
1768
|
-
if (profile.sidecar !== null ||
|
|
773
|
+
if (profile.sidecar !== null ||
|
|
1769
774
|
(profile.emission === "llvm" && profile.optimization === "dev" && !sanitize)) {
|
|
1770
|
-
const publicSource = await readFile(
|
|
775
|
+
const publicSource = await readFile(llvmPath, "utf8");
|
|
1771
776
|
programSource = publicSource;
|
|
1772
777
|
}
|
|
1773
778
|
if (profile.sidecar !== null) {
|
|
1774
779
|
if (features.buildId === undefined)
|
|
1775
780
|
throw new InternalCompilerError("library identity TU has no build id");
|
|
1776
|
-
const withoutIdentity = stripLibraryIdentity(programSource
|
|
781
|
+
const withoutIdentity = stripLibraryIdentity(programSource);
|
|
1777
782
|
if (withoutIdentity === programSource) {
|
|
1778
783
|
throw new InternalCompilerError("generated public library TU has no identity region");
|
|
1779
784
|
}
|
|
1780
785
|
programSource = withoutIdentity;
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
].join("\n");
|
|
1788
|
-
}
|
|
1789
|
-
if (profile.emission === "c") {
|
|
1790
|
-
programSource = stripLibrarySourceComments(programSource, profile.entry);
|
|
786
|
+
identityLlvmSource = emitLibraryIdentityLines({
|
|
787
|
+
buildIdSymbol: profile.sidecar.buildIdSymbol,
|
|
788
|
+
abiVersionSymbol: profile.sidecar.abiVersionSymbol,
|
|
789
|
+
buildId: features.buildId,
|
|
790
|
+
abiVersion: profile.sidecar.abiVersion,
|
|
791
|
+
}, "").join("\n");
|
|
1791
792
|
}
|
|
1792
793
|
const llvmSplit = profile.emission === "llvm" && profile.optimization === "dev" && !sanitize && programSource !== undefined
|
|
1793
794
|
? splitLlvmLibraryProgram(programSource)
|
|
1794
795
|
: null;
|
|
1795
|
-
|
|
1796
|
-
|
|
796
|
+
const packTarget = !sanitize ? nativeCodegenTarget() : null;
|
|
797
|
+
if (!sanitize && packTarget === null)
|
|
798
|
+
throw new NativeCodegenError("SC3002", nativeCodegenTargetRefusal() ?? "unsupported library target");
|
|
799
|
+
const archiveOptions = {
|
|
800
|
+
cPath: llvmPath,
|
|
1797
801
|
...(programSource !== undefined ? { programSource } : {}),
|
|
1798
|
-
...(
|
|
802
|
+
...(identityLlvmSource !== undefined ? { identityLlvmSource } : {}),
|
|
1799
803
|
...(llvmSplit !== null
|
|
1800
804
|
? {
|
|
1801
805
|
programShards: llvmSplit.shards,
|
|
@@ -1818,7 +822,12 @@ async function compileLibraryNative(profile, cPath, archivePath, sanitize, featu
|
|
|
1818
822
|
zlib: features.zlib,
|
|
1819
823
|
copying: features.copying,
|
|
1820
824
|
textDecoderLegacy: features.textDecoderLegacy,
|
|
1821
|
-
|
|
825
|
+
dynInvoke: features.dynInvoke,
|
|
826
|
+
};
|
|
827
|
+
if (packTarget !== null)
|
|
828
|
+
await compilePackedLibrary(archiveOptions, packTarget);
|
|
829
|
+
else
|
|
830
|
+
await compileExternalCLibrary(archiveOptions);
|
|
1822
831
|
}
|
|
1823
832
|
async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot, cacheOptions, timing) {
|
|
1824
833
|
const mod = hit.mod;
|
|
@@ -1844,30 +853,19 @@ async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot
|
|
|
1844
853
|
}
|
|
1845
854
|
await mkdir(opts.outDir, { recursive: true });
|
|
1846
855
|
const stem = basename(profile.entry).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
1847
|
-
const
|
|
856
|
+
const llvmPath = join(opts.outDir, `${stem}.lib.ll`);
|
|
1848
857
|
let translationUnit = hit.translationUnit;
|
|
1849
858
|
if (profile.sidecar !== null) {
|
|
1850
|
-
translationUnit = replaceLibraryIdentity(translationUnit,
|
|
1851
|
-
}
|
|
1852
|
-
if (profile.emission === "llvm") {
|
|
1853
|
-
await writeFile(cPath, translationUnit);
|
|
1854
|
-
}
|
|
1855
|
-
else {
|
|
1856
|
-
const previous = hit.previousSources.get(mod.sourceFile);
|
|
1857
|
-
const current = hit.sourceTexts.get(mod.sourceFile);
|
|
1858
|
-
if (previous === undefined || current === undefined) {
|
|
1859
|
-
throw new InternalCompilerError("semantic library cache lost the entry source text");
|
|
1860
|
-
}
|
|
1861
|
-
translationUnit = rebaseLibrarySourceComments(translationUnit, mod.sourceFile, createSourceLineRebaser(mod.sourceFile, previous, current));
|
|
1862
|
-
await writeFile(cPath, translationUnit);
|
|
859
|
+
translationUnit = replaceLibraryIdentity(translationUnit, mod.lib.identity);
|
|
1863
860
|
}
|
|
861
|
+
await writeFile(llvmPath, translationUnit);
|
|
1864
862
|
timing("semantic-tu-restore", { output_bytes: Buffer.byteLength(translationUnit) });
|
|
1865
863
|
let irPath;
|
|
1866
864
|
if (opts.emitIr) {
|
|
1867
865
|
irPath = join(opts.outDir, `${stem}.lib.ir.json`);
|
|
1868
|
-
await writeFile(irPath, serializeModule(mod));
|
|
866
|
+
await writeFile(irPath, serializeModule(mod, true));
|
|
1869
867
|
}
|
|
1870
|
-
await compileLibraryNative(profile,
|
|
868
|
+
await compileLibraryNative(profile, llvmPath, archivePath, opts.sanitize ?? false, hit.native);
|
|
1871
869
|
timing("native-archive");
|
|
1872
870
|
let sidecarPath;
|
|
1873
871
|
if (sidecarJson !== null) {
|
|
@@ -1877,7 +875,7 @@ async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot
|
|
|
1877
875
|
await writeFile(sidecarPath, sidecarJson);
|
|
1878
876
|
}
|
|
1879
877
|
await publishEarlyLibraryCache(cacheRoot, cacheOptions, {
|
|
1880
|
-
|
|
878
|
+
llvmPath,
|
|
1881
879
|
native: hit.native,
|
|
1882
880
|
frontend: hit.frontend,
|
|
1883
881
|
semantic: { mod, sources: hit.sourceTexts },
|
|
@@ -1890,7 +888,7 @@ async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot
|
|
|
1890
888
|
return {
|
|
1891
889
|
ok: true,
|
|
1892
890
|
archivePath,
|
|
1893
|
-
|
|
891
|
+
llvmPath,
|
|
1894
892
|
backend: profile.emission,
|
|
1895
893
|
...(irPath !== undefined ? { irPath } : {}),
|
|
1896
894
|
...(sidecarPath !== undefined ? { sidecarPath } : {}),
|
|
@@ -1899,7 +897,16 @@ async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot
|
|
|
1899
897
|
export async function compileLibrary(opts) {
|
|
1900
898
|
clearCompileSessionCaches();
|
|
1901
899
|
const frontendInputs = new FrontendInputTracker();
|
|
1902
|
-
|
|
900
|
+
try {
|
|
901
|
+
return await frontendInputs.run(() => compileLibraryTracked(opts, frontendInputs));
|
|
902
|
+
}
|
|
903
|
+
catch (error) {
|
|
904
|
+
if (error instanceof RuntimePackError)
|
|
905
|
+
return { ok: false, diagnostics: [runtimePackDiagnostic(error, opts.profilePath)], sourceTexts: new Map() };
|
|
906
|
+
if (error instanceof NativeCodegenError)
|
|
907
|
+
return { ok: false, diagnostics: [nativeCodegenDiag(error.diagnosticCode, error.message, opts.profilePath)], sourceTexts: new Map() };
|
|
908
|
+
throw error;
|
|
909
|
+
}
|
|
1903
910
|
}
|
|
1904
911
|
async function compileLibraryTracked(opts, frontendInputs) {
|
|
1905
912
|
const timingOn = process.env["SCRIPTC_TIMING"] === "1";
|
|
@@ -1925,7 +932,6 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1925
932
|
}
|
|
1926
933
|
const profile = loadedProfile.profile;
|
|
1927
934
|
const entryPath = profile.entry;
|
|
1928
|
-
const buildPlatform = buildTargetPlatform();
|
|
1929
935
|
const profileDir = dirname(resolve(opts.profilePath));
|
|
1930
936
|
for (let directory = dirname(entryPath);; directory = dirname(directory)) {
|
|
1931
937
|
for (const name of ["tsconfig.json", "package.json"]) {
|
|
@@ -1940,7 +946,6 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1940
946
|
if (directory === profileDir || dirname(directory) === directory)
|
|
1941
947
|
break;
|
|
1942
948
|
}
|
|
1943
|
-
const archivePath = opts.outPath ?? join(opts.outDir, `${basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "")}.lib.a`);
|
|
1944
949
|
// Mobile-target admission first — a pure env/host check, so a refused
|
|
1945
950
|
// pairing never reaches toolchain discovery. iOS targets (device and
|
|
1946
951
|
// simulator) build on darwin hosts only: the Apple SDK sysroot and the
|
|
@@ -1957,6 +962,13 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1957
962
|
};
|
|
1958
963
|
}
|
|
1959
964
|
}
|
|
965
|
+
const buildPlatform = buildTargetPlatform();
|
|
966
|
+
const archivePath = opts.outPath ?? join(opts.outDir, `${basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "")}${buildPlatform === "wasi" ? ".wasm" : ".lib.a"}`);
|
|
967
|
+
if (buildPlatform === "wasi") {
|
|
968
|
+
const refusal = libraryWasmRefusal(profile, opts.sanitize ?? false);
|
|
969
|
+
if (refusal !== null)
|
|
970
|
+
return { ok: false, diagnostics: [refusal], sourceTexts: new Map() };
|
|
971
|
+
}
|
|
1960
972
|
// Multi-instance library mode (abi.localize_runtime) localizes per
|
|
1961
973
|
// OBJECT FORMAT: ELF and COFF archives localize from any host (cross
|
|
1962
974
|
// ELF merges through the cross driver's own lld; COFF merges and
|
|
@@ -1964,11 +976,14 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1964
976
|
// localization runs the macOS host linker, so macos and ios targets
|
|
1965
977
|
// admit darwin hosts only (the mobile admission above already refused
|
|
1966
978
|
// an ios triple off darwin). Everything else refuses before frontend/
|
|
1967
|
-
// backend work, naming the pairing. WASI
|
|
1968
|
-
//
|
|
979
|
+
// backend work, naming the pairing. WASI refuses localization above:
|
|
980
|
+
// each WebAssembly.Instance already owns its runtime state.
|
|
1969
981
|
if (profile.localizeRuntime && buildPlatform !== "wasi") {
|
|
1970
|
-
const
|
|
1971
|
-
const
|
|
982
|
+
const packTarget = nativeCodegenTarget();
|
|
983
|
+
const driver = opts.sanitize ? resolveCc() : {
|
|
984
|
+
target: packTarget?.llvmTriple ?? process.env["SCRIPTC_TARGET"] ?? null,
|
|
985
|
+
};
|
|
986
|
+
const platform = buildPlatform;
|
|
1972
987
|
const targetArch = driver.target?.split("-", 1)[0] ?? null;
|
|
1973
988
|
// Native Linux retains its host-binutils implementation. Cross ELF is
|
|
1974
989
|
// rebuilt in process and currently accepts the two verified ELF64,
|
|
@@ -1991,7 +1006,7 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1991
1006
|
return {
|
|
1992
1007
|
ok: false,
|
|
1993
1008
|
diagnostics: decorateLibraryRefusals([
|
|
1994
|
-
targetRefusalDiag(driver.target
|
|
1009
|
+
targetRefusalDiag(process.env["SCRIPTC_TARGET"] || driver.target || platform, subject, { file: entryPath, start: 0, end: 0 }),
|
|
1995
1010
|
], profile),
|
|
1996
1011
|
sourceTexts: new Map(),
|
|
1997
1012
|
};
|
|
@@ -2016,13 +1031,13 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
2016
1031
|
const earlyHit = await readEarlyLibraryCache(cacheRoot, earlyCacheOptions, profile.sidecar === null ? undefined : profile.sidecar.path);
|
|
2017
1032
|
if (earlyHit !== null) {
|
|
2018
1033
|
timing("early-cache-hit");
|
|
2019
|
-
await compileLibraryNative(profile, earlyHit.
|
|
1034
|
+
await compileLibraryNative(profile, earlyHit.llvmPath, archivePath, opts.sanitize ?? false, earlyHit.native);
|
|
2020
1035
|
timing("native-archive");
|
|
2021
1036
|
timing("complete");
|
|
2022
1037
|
return {
|
|
2023
1038
|
ok: true,
|
|
2024
1039
|
archivePath,
|
|
2025
|
-
|
|
1040
|
+
llvmPath: earlyHit.llvmPath,
|
|
2026
1041
|
backend: earlyHit.native.backend,
|
|
2027
1042
|
...(earlyHit.irPath !== undefined ? { irPath: earlyHit.irPath } : {}),
|
|
2028
1043
|
...(earlyHit.sidecarPath !== undefined ? { sidecarPath: earlyHit.sidecarPath } : {}),
|
|
@@ -2035,256 +1050,38 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
2035
1050
|
return emitSemanticLibraryHit(semanticHit, profile, opts, archivePath, cacheRoot, earlyCacheOptions, timing);
|
|
2036
1051
|
}
|
|
2037
1052
|
timing("semantic-cache-miss");
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
// island/dynamic tier to offer (SC4006's ground), so eligibility needs
|
|
2043
|
-
// no flag and a miss is a refusal, never a fallback.
|
|
2044
|
-
const fe = runFrontend(entryPath, "lib");
|
|
2045
|
-
timing("frontend-load", {
|
|
2046
|
-
entry_bytes: fe.entryText().length,
|
|
2047
|
-
source_files: fe.sourceTexts().size,
|
|
2048
|
-
});
|
|
2049
|
-
let lowered;
|
|
2050
|
-
let entryText;
|
|
2051
|
-
let sourceTexts;
|
|
2052
|
-
let entryInfo;
|
|
2053
|
-
let contractFacts;
|
|
2054
|
-
try {
|
|
2055
|
-
// Every library refusal leaves through the ask-5 teaching decoration:
|
|
2056
|
-
// profile text attaches by code, manifest id, or fence coverage as the
|
|
2057
|
-
// attributed note (the SC4004/SC4005 rider generalized).
|
|
2058
|
-
const fail = (diagnostics) => ({
|
|
2059
|
-
ok: false,
|
|
2060
|
-
diagnostics: decorateLibraryRefusals(diagnostics, profile),
|
|
2061
|
-
sourceTexts: fe.sourceTexts(),
|
|
2062
|
-
});
|
|
2063
|
-
// Library mode emits a host-embedded static archive with native trap and
|
|
2064
|
-
// C-ABI contracts. wasm32-wasi executable modules are supported, but the
|
|
2065
|
-
// archive/reactor contract is not; refuse before emitting a host-width
|
|
2066
|
-
// LLVM TU or asking Zig to compile the native library runtime for WASI.
|
|
2067
|
-
if (buildPlatform === "wasi") {
|
|
2068
|
-
return fail([
|
|
2069
|
-
targetRefusalDiag("wasm32-wasi", "library-mode archive builds", { file: entryPath, start: 0, end: 0 }),
|
|
2070
|
-
]);
|
|
2071
|
-
}
|
|
2072
|
-
// The npm verdicts FIRST: whatever the shared frontend would have
|
|
2073
|
-
// served from the island — an eligibility miss, an untyped install, a
|
|
2074
|
-
// preflight offender inside a package's files, a dropped inferred
|
|
2075
|
-
// surface — refuses here with the package and the specific bar it
|
|
2076
|
-
// missed. Checked before the general preflight, whose diagnostics for
|
|
2077
|
-
// these same imports speak executable-lane teachings (SC1010/SC0001 at
|
|
2078
|
-
// the unresolvable edge); the library answer is this one.
|
|
2079
|
-
const npmRefused = fe.npmStatic.filter((s) => s.status === "fallback");
|
|
2080
|
-
if (npmRefused.length > 0) {
|
|
2081
|
-
return fail(npmRefused.map((s) => libNpmIneligibleDiag(s.package,
|
|
2082
|
-
// The one shared offender reason that narrates the executable
|
|
2083
|
-
// lane's fallback loses that clause here — no island exists on
|
|
2084
|
-
// this path to serve anything.
|
|
2085
|
-
(s.detail ?? "its static compilation was refused").replace("; the island serves the package", ""), fe.npmImportSites.get(s.package) ?? { file: entryPath, start: 0, end: 0 })));
|
|
2086
|
-
}
|
|
2087
|
-
if (fe.preflight.length > 0)
|
|
2088
|
-
return fail(fe.preflight);
|
|
2089
|
-
contractFacts = profile.sidecar !== null ? fe.entryContract() : null;
|
|
2090
|
-
// Ask 4, contract-surface reachability: when the sidecar declares ANY
|
|
2091
|
-
// integer slot, the designated init/update/subscriptions exports and
|
|
2092
|
-
// every contract helper (model-first exported function) seed lowering
|
|
2093
|
-
// too. They are attested surface — a declared record-field or msg-arm
|
|
2094
|
-
// class obligates EVERY write those bodies perform, and a declared
|
|
2095
|
-
// helper param is checked at their internal call sites — so the
|
|
2096
|
-
// attestation must cover COMPILED bodies, never a dead-stripped
|
|
2097
|
-
// vacuity (the bug this closes: a model-slot declaration whose only
|
|
2098
|
-
// writers were dead-stripped attested without any proof).
|
|
2099
|
-
const contractSurfaceRoots = [];
|
|
2100
|
-
if (profile.sidecar !== null && profile.sidecar.integerSlots.length > 0) {
|
|
2101
|
-
const sc = profile.sidecar;
|
|
2102
|
-
const fnNames = new Set(contractFacts.functions.filter((f) => !f.generic).map((f) => f.name));
|
|
2103
|
-
for (const name of [sc.initExport, sc.updateExport, sc.subscriptionsExport]) {
|
|
2104
|
-
if (fnNames.has(name))
|
|
2105
|
-
contractSurfaceRoots.push(name);
|
|
2106
|
-
}
|
|
2107
|
-
for (const fn of contractFacts.functions) {
|
|
2108
|
-
if (fn.generic)
|
|
2109
|
-
continue;
|
|
2110
|
-
const first = fn.params[0];
|
|
2111
|
-
if (first !== undefined && first.shape !== null && first.shape.k === "ref" && first.shape.name === sc.model) {
|
|
2112
|
-
contractSurfaceRoots.push(fn.name);
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
// The profile's host-callback channels ride the FFI import machinery:
|
|
2117
|
-
// each channel is a signature-only ambient binding whose direct calls
|
|
2118
|
-
// lower to ffiCall nodes (the classes are a subset of the FFI's), and
|
|
2119
|
-
// `libraryCallbacks` flips the recognition to the library flavor —
|
|
2120
|
-
// SC4024 diagnostics, unused channels legal, undeclared references
|
|
2121
|
-
// refused with the callback teaching. The library lane never loads a
|
|
2122
|
-
// native-FFI manifest, so the channel set owns the surface outright.
|
|
2123
|
-
const cbImports = profile.callbacks.map((cb) => ({
|
|
2124
|
-
name: cb.name,
|
|
2125
|
-
symbol: cb.name,
|
|
2126
|
-
params: [...cb.params],
|
|
2127
|
-
returns: cb.returns,
|
|
2128
|
-
}));
|
|
2129
|
-
try {
|
|
2130
|
-
lowered = fe.lower({
|
|
2131
|
-
dynamic: false,
|
|
2132
|
-
targetPlatform: buildPlatform,
|
|
2133
|
-
...(cbImports.length > 0 ? { ffiImports: cbImports, libraryCallbacks: true } : {}),
|
|
2134
|
-
// The profile-mapped exports are called from OUTSIDE the graph:
|
|
2135
|
-
// they seed reachability beside the entry's top level (an
|
|
2136
|
-
// executable build would dead-strip an uncalled export). A helper
|
|
2137
|
-
// with a declared integer slot (ask 4) seeds too: its attestation
|
|
2138
|
-
// must cover a COMPILED body, never a dead-stripped vacuity — the
|
|
2139
|
-
// sidecar advertises the slot's class, so the proof must exist.
|
|
2140
|
-
libRoots: [
|
|
2141
|
-
...new Set([
|
|
2142
|
-
...profile.exports.map((e) => e.export),
|
|
2143
|
-
...(profile.sidecar?.integerSlots ?? [])
|
|
2144
|
-
.map((s) => /^helpers\.([^.]+)\.(?:params\[\d+\]|return)$/.exec(s.slot)?.[1])
|
|
2145
|
-
.filter((n) => n !== undefined),
|
|
2146
|
-
...contractSurfaceRoots,
|
|
2147
|
-
]),
|
|
2148
|
-
],
|
|
2149
|
-
});
|
|
2150
|
-
timing("lower", {
|
|
2151
|
-
lib_roots: profile.exports.length + contractSurfaceRoots.length,
|
|
2152
|
-
});
|
|
2153
|
-
}
|
|
2154
|
-
catch (e) {
|
|
2155
|
-
if (!isCheckerPanic(e))
|
|
2156
|
-
throw e;
|
|
2157
|
-
return fail([checkerPanicDiag(e.message.split("\n", 1)[0], { file: entryPath, start: 0, end: 0 })]);
|
|
2158
|
-
}
|
|
2159
|
-
if (lowered.module === null)
|
|
2160
|
-
return fail(lowered.diagnostics);
|
|
2161
|
-
entryInfo = fe.entryExports();
|
|
2162
|
-
entryText = fe.entryText();
|
|
2163
|
-
sourceTexts = fe.sourceTexts();
|
|
2164
|
-
}
|
|
2165
|
-
finally {
|
|
2166
|
-
fe.dispose();
|
|
2167
|
-
}
|
|
2168
|
-
const mod = lowered.module;
|
|
2169
|
-
timing("frontend-dispose");
|
|
1053
|
+
const prepared = prepareLibrary(profile, opts.profilePath, compilerReleaseVersion(), buildPlatform, nodeFrontend, timing);
|
|
1054
|
+
if (!prepared.ok)
|
|
1055
|
+
return prepared;
|
|
1056
|
+
const { mod, sourceTexts, sidecarJson } = prepared;
|
|
2170
1057
|
const fail = (diagnostics) => ({
|
|
2171
|
-
ok: false,
|
|
2172
|
-
diagnostics: decorateLibraryRefusals(diagnostics, profile),
|
|
2173
|
-
sourceTexts,
|
|
1058
|
+
ok: false, diagnostics: decorateLibraryRefusals(diagnostics, profile), sourceTexts,
|
|
2174
1059
|
});
|
|
2175
|
-
// Export resolution first (SC4002/SC4003/SC4004/SC4007 anchor at the
|
|
2176
|
-
// mapped declaration — a mapped async export reports as SC4004, not the
|
|
2177
|
-
// graph-wide gate), then the async_free requirement (ratified, SC4005),
|
|
2178
|
-
// then the profile's determinism fences (ask 5, SC4008) over the same
|
|
2179
|
-
// compiled graph the attestation scan reads: all refused before anything
|
|
2180
|
-
// is emitted, so the narrowed library link set below is structural fact.
|
|
2181
|
-
const resolved = resolveLibrarySection(profile, entryInfo, mod, entryPath);
|
|
2182
|
-
if ("diagnostics" in resolved)
|
|
2183
|
-
return fail(resolved.diagnostics);
|
|
2184
|
-
const asyncSurface = moduleLibAsyncSurface(mod);
|
|
2185
|
-
if (asyncSurface !== null) {
|
|
2186
|
-
return fail([libAsyncSurfaceDiag(asyncSurface.surface, asyncSurface.loc)]);
|
|
2187
|
-
}
|
|
2188
|
-
const fenced = evaluateLibraryFences(mod, profile);
|
|
2189
|
-
if (fenced.length > 0)
|
|
2190
|
-
return fail(fenced);
|
|
2191
|
-
mod.lib = resolved.lib;
|
|
2192
|
-
// Ask 4's declared integer slots: the export map's i64/u64 classes
|
|
2193
|
-
// seed the config here; sidecar-declared slots (record fields, msg
|
|
2194
|
-
// arms, helper params/returns) merge in after the projection resolves
|
|
2195
|
-
// them below.
|
|
2196
|
-
let intCfg = libraryIntSlotConfig(profile);
|
|
2197
|
-
// The ask-2 contract sidecar rides the same invocation. Identity first
|
|
2198
|
-
// (schema §2's worked build_id definition over compiler version, profile
|
|
2199
|
-
// bytes, and the sorted canonical module graph; source_hash per the
|
|
2200
|
-
// profile's "module-graph" contract) — the u64 lands on the IR so native
|
|
2201
|
-
// archive assembly emits the identity getters from the ONE value the
|
|
2202
|
-
// sidecar records (V12's coherence by construction), then the projection into
|
|
2203
|
-
// the schema (declaration orders from the AST) and the V1–V14
|
|
2204
|
-
// self-check before anything is written.
|
|
2205
|
-
let sidecarJson = null;
|
|
2206
|
-
if (profile.sidecar !== null) {
|
|
2207
|
-
const rootDir = dirname(resolve(opts.profilePath));
|
|
2208
|
-
const modules = canonicalModuleGraph(rootDir, sourceTexts);
|
|
2209
|
-
const { buildId, sourceHash } = libraryIdentityHashes(compilerReleaseVersion(), profile.profileBytes, modules);
|
|
2210
|
-
mod.lib.identity = {
|
|
2211
|
-
buildIdSymbol: profile.sidecar.buildIdSymbol,
|
|
2212
|
-
abiVersionSymbol: profile.sidecar.abiVersionSymbol,
|
|
2213
|
-
buildId,
|
|
2214
|
-
abiVersion: profile.sidecar.abiVersion,
|
|
2215
|
-
};
|
|
2216
|
-
const built = buildSidecar({
|
|
2217
|
-
profile,
|
|
2218
|
-
facts: contractFacts,
|
|
2219
|
-
compilerVersion: compilerReleaseVersion(),
|
|
2220
|
-
entry: canonicalPath(rootDir, entryPath),
|
|
2221
|
-
buildId,
|
|
2222
|
-
sourceHash,
|
|
2223
|
-
deterministic: moduleLibNondeterministicSurface(mod) === null,
|
|
2224
|
-
});
|
|
2225
|
-
if (!built.ok)
|
|
2226
|
-
return fail(built.diagnostics);
|
|
2227
|
-
const violations = validateSidecar(built.doc);
|
|
2228
|
-
if (violations.length > 0) {
|
|
2229
|
-
// The projection above refuses every user-caused shape; a rule
|
|
2230
|
-
// violation surviving to here is an emitter bug.
|
|
2231
|
-
return fail(violations.map((v) => iceDiag(`sidecar self-check failed — ${v}`, { file: entryPath, start: 0, end: 0 })));
|
|
2232
|
-
}
|
|
2233
|
-
sidecarJson = built.json;
|
|
2234
|
-
const merged = mergeSidecarIntSlots(intCfg, built.integerSlotFacts, mod);
|
|
2235
|
-
if (!merged.ok)
|
|
2236
|
-
return fail([merged.diagnostic]);
|
|
2237
|
-
intCfg = merged.config;
|
|
2238
|
-
}
|
|
2239
|
-
timing("contract-sidecar", { source_files: sourceTexts.size });
|
|
2240
|
-
// Ask 4: the integer-boundary inference — every value that can reach a
|
|
2241
|
-
// profile-declared i64/u64 slot must PROVE representability, wholeness,
|
|
2242
|
-
// and range, or the build refuses with the failed obligation, the
|
|
2243
|
-
// observed evidence, and the author's fix (SC4021/SC4022/SC4023). Runs
|
|
2244
|
-
// only when at least one integer slot is declared; the sidecar (already
|
|
2245
|
-
// built above, written only on success) may then attest the classes —
|
|
2246
|
-
// §5's invariant that an attested integer class means the proof was
|
|
2247
|
-
// discharged holds because no artifact leaves this function otherwise.
|
|
2248
|
-
if (hasIntSlots(intCfg)) {
|
|
2249
|
-
const refusals = checkLibraryIntegerSlots(mod, intCfg).filter((v) => v.outcome === "refuse");
|
|
2250
|
-
if (refusals.length > 0) {
|
|
2251
|
-
return fail(refusals.map((v) => libIntBoundaryDiag(v.path, v.cls, v.obligation, v.detail, v.fix, v.loc)));
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
timing("integer-proof");
|
|
2255
|
-
const validation = validateModule(mod);
|
|
2256
|
-
if (validation.length > 0)
|
|
2257
|
-
return fail(validation.map((v) => iceDiag(v.message, v.loc)));
|
|
2258
|
-
timing("ir-validate");
|
|
2259
1060
|
await mkdir(opts.outDir, { recursive: true });
|
|
2260
1061
|
const stem = basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
if (!(err instanceof LlvmUnsupportedError))
|
|
2272
|
-
throw err;
|
|
2273
|
-
// The profile PINS the emission — fail-loudly, never a lane change.
|
|
2274
|
-
return fail([llvmRefusalDiag(err, entryPath)]);
|
|
2275
|
-
}
|
|
1062
|
+
const llvmPath = join(opts.outDir, `${stem}.lib.ll`);
|
|
1063
|
+
try {
|
|
1064
|
+
const ll = emitLlvmModule(mod, {
|
|
1065
|
+
targetTriple: process.env["SCRIPTC_TARGET"] ?? "",
|
|
1066
|
+
pointerBits: buildPlatform === "wasi" ? 32 : 64,
|
|
1067
|
+
wasi: buildPlatform === "wasi",
|
|
1068
|
+
});
|
|
1069
|
+
timing("llvm-emit", { output_bytes: Buffer.byteLength(ll) });
|
|
1070
|
+
await writeFile(llvmPath, ll);
|
|
1071
|
+
timing("llvm-write");
|
|
2276
1072
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
1073
|
+
catch (err) {
|
|
1074
|
+
if (!(err instanceof LlvmUnsupportedError))
|
|
1075
|
+
throw err;
|
|
1076
|
+
return fail([llvmRefusalDiag(err, entryPath)]);
|
|
2280
1077
|
}
|
|
2281
1078
|
let irPath;
|
|
2282
1079
|
if (opts.emitIr) {
|
|
2283
1080
|
irPath = join(opts.outDir, `${stem}.lib.ir.json`);
|
|
2284
|
-
await writeFile(irPath, serializeModule(mod));
|
|
1081
|
+
await writeFile(irPath, serializeModule(mod, true));
|
|
2285
1082
|
}
|
|
2286
1083
|
const nativeFeatures = libraryNativeFeatures(mod, profile.emission);
|
|
2287
|
-
await compileLibraryNative(profile,
|
|
1084
|
+
await compileLibraryNative(profile, llvmPath, archivePath, opts.sanitize ?? false, nativeFeatures);
|
|
2288
1085
|
timing("native-archive");
|
|
2289
1086
|
// The sidecar lands beside the compiled object, written by the same
|
|
2290
1087
|
// invocation (profile-declared name; the neutral default when the
|
|
@@ -2298,7 +1095,7 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
2298
1095
|
await writeFile(sidecarPath, sidecarJson);
|
|
2299
1096
|
}
|
|
2300
1097
|
const earlyPublish = {
|
|
2301
|
-
|
|
1098
|
+
llvmPath,
|
|
2302
1099
|
native: nativeFeatures,
|
|
2303
1100
|
frontend: frontendInputs.snapshot(),
|
|
2304
1101
|
semantic: { mod, sources: sourceTexts },
|
|
@@ -2312,7 +1109,7 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
2312
1109
|
return {
|
|
2313
1110
|
ok: true,
|
|
2314
1111
|
archivePath,
|
|
2315
|
-
|
|
1112
|
+
llvmPath,
|
|
2316
1113
|
backend: profile.emission,
|
|
2317
1114
|
...(irPath !== undefined ? { irPath } : {}),
|
|
2318
1115
|
...(sidecarPath !== undefined ? { sidecarPath } : {}),
|