@scriptc/compiler 0.3.4 → 0.3.6
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 +409 -42
- package/dist/backend/llvm/array-search.js +1 -1
- package/dist/backend/llvm/array-search.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.d.ts +6 -0
- package/dist/backend/llvm/call-lifetimes.js +19 -0
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +2 -21
- package/dist/backend/llvm/constant-callbacks.js +36 -219
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +22 -0
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +9 -0
- package/dist/backend/llvm/dense-array-access.js +27 -1
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +6 -0
- package/dist/backend/llvm/dyn.js +71 -7
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +120 -2
- package/dist/backend/llvm/emitter.js +820 -142
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +17 -7
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +11 -0
- package/dist/backend/llvm/expr-callbacks.js +53 -0
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +88 -2
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +50 -27
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.js +1 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +25 -1
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +20 -1
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +4 -0
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/integer-clones.d.ts +103 -0
- package/dist/backend/llvm/integer-clones.js +1336 -0
- package/dist/backend/llvm/integer-clones.js.map +1 -0
- package/dist/backend/llvm/integer-clones.test.d.ts +1 -0
- package/dist/backend/llvm/integer-clones.test.js +219 -0
- package/dist/backend/llvm/integer-clones.test.js.map +1 -0
- package/dist/backend/llvm/lib-datagram.js +14 -0
- package/dist/backend/llvm/lib-datagram.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +32 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +61 -1
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +21 -3
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +34 -0
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +77 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-test.js +16 -3
- package/dist/backend/llvm/lib-test.js.map +1 -1
- package/dist/backend/llvm/lib-tls.js +6 -0
- package/dist/backend/llvm/lib-tls.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +1 -1
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/map-entry-fusion.d.ts +28 -0
- package/dist/backend/llvm/map-entry-fusion.js +233 -0
- package/dist/backend/llvm/map-entry-fusion.js.map +1 -0
- package/dist/backend/llvm/map-entry-fusion.test.d.ts +1 -0
- package/dist/backend/llvm/map-entry-fusion.test.js +183 -0
- package/dist/backend/llvm/map-entry-fusion.test.js.map +1 -0
- package/dist/backend/llvm/map-number-lookup.d.ts +2 -0
- package/dist/backend/llvm/map-number-lookup.js +1 -1
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +10 -11
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.d.ts +2 -0
- package/dist/backend/llvm/map-read-lifetimes.js +3 -0
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +2 -2
- package/dist/backend/llvm/nullable-unions.d.ts +6 -3
- package/dist/backend/llvm/nullable-unions.js +2 -0
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +16 -0
- package/dist/backend/llvm/publish.js +81 -10
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/publish.test.d.ts +1 -0
- package/dist/backend/llvm/publish.test.js +94 -0
- package/dist/backend/llvm/publish.test.js.map +1 -0
- package/dist/backend/llvm/record-results.d.ts +1 -1
- package/dist/backend/llvm/record-results.js +78 -4
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/record-sources.d.ts +7 -0
- package/dist/backend/llvm/record-sources.js +14 -0
- package/dist/backend/llvm/record-sources.js.map +1 -0
- package/dist/backend/llvm/reference-writes.js +1 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +12 -3
- package/dist/backend/llvm/shapes.js +23 -14
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +5 -3
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +74 -0
- package/dist/backend/llvm/speculative-integers.js +571 -0
- package/dist/backend/llvm/speculative-integers.js.map +1 -0
- package/dist/backend/llvm/speculative-integers.test.d.ts +1 -0
- package/dist/backend/llvm/speculative-integers.test.js +148 -0
- package/dist/backend/llvm/speculative-integers.test.js.map +1 -0
- package/dist/backend/llvm/string-lifetimes.test.js +75 -1
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +17 -0
- package/dist/backend/llvm/walkers.js +123 -0
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +2 -0
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +2 -1
- package/dist/backend/native/executable.js +6 -1
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +1 -0
- package/dist/backend/native/runtime-inputs.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-targets.test.js +1 -1
- package/dist/backend/runtime-pack.d.ts +7 -3
- package/dist/backend/runtime-pack.js +12 -6
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +16 -7
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/contracts/check.js +1 -0
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/surface-manifest.js +3 -3
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.js +6 -2
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/builtin-calls.js +13 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +82 -8
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-async.d.ts +8 -6
- package/dist/frontend/lowering/builtins/child-process-async.js +45 -29
- package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +9 -0
- package/dist/frontend/lowering/builtins/compression.js +145 -30
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.js +12 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.js +5 -3
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +6 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +16 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +8 -0
- package/dist/frontend/lowering/builtins/filesystem.js +199 -2
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-streams.d.ts +26 -0
- package/dist/frontend/lowering/builtins/fs-streams.js +131 -0
- package/dist/frontend/lowering/builtins/fs-streams.js.map +1 -0
- package/dist/frontend/lowering/builtins/hash-stream.d.ts +12 -0
- package/dist/frontend/lowering/builtins/hash-stream.js +80 -0
- package/dist/frontend/lowering/builtins/hash-stream.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-calls.js +17 -3
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +9 -2
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +45 -13
- package/dist/frontend/lowering/builtins/readline.js +812 -47
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.d.ts +4 -0
- package/dist/frontend/lowering/builtins/workers.js +58 -0
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js +150 -8
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +55 -0
- package/dist/frontend/lowering/class-protocols.js +735 -0
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.d.ts +18 -0
- package/dist/frontend/lowering/containers/array-from-async.js +282 -0
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.js +33 -12
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.js +2 -1
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +27 -23
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/devirtualize.js +20 -7
- package/dist/frontend/lowering/devirtualize.js.map +1 -1
- package/dist/frontend/lowering/divergences.js +188 -15
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +129 -25
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +46 -1
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +55 -15
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +9 -1
- package/dist/frontend/lowering/lower-event-emitter.js +88 -1
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +4 -0
- package/dist/frontend/lowering/lower-exprs.js +239 -71
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +49 -3
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-mock.d.ts +11 -1
- package/dist/frontend/lowering/lower-mock.js +377 -61
- package/dist/frontend/lowering/lower-mock.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +1 -0
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +2 -1
- package/dist/frontend/lowering/lower-server.js +234 -21
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +60 -13
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +1 -3
- package/dist/frontend/lowering/lower-stream.js +325 -20
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.js +147 -48
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +13 -1
- package/dist/frontend/lowering/lowerer.js +10 -2
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/null-prototype.d.ts +13 -0
- package/dist/frontend/lowering/null-prototype.js +33 -0
- package/dist/frontend/lowering/null-prototype.js.map +1 -0
- package/dist/frontend/lowering/record-sources.d.ts +15 -0
- package/dist/frontend/lowering/record-sources.js +46 -0
- package/dist/frontend/lowering/record-sources.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +3 -3
- package/dist/frontend/lowering/surfaces.js +59 -5
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/mock-shapes.d.ts +5 -0
- package/dist/frontend/mock-shapes.js +27 -2
- package/dist/frontend/mock-shapes.js.map +1 -1
- package/dist/frontend/program.js +5 -4
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +3 -0
- package/dist/frontend/type-mapper.js +148 -4
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +10 -0
- package/dist/ir/analysis.js +35 -0
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +69 -1
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/builtin-effects.js +72 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +258 -13
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/capture-values.d.ts +107 -0
- package/dist/ir/capture-values.js +850 -0
- package/dist/ir/capture-values.js.map +1 -0
- package/dist/ir/capture-values.test.d.ts +1 -0
- package/dist/ir/capture-values.test.js +268 -0
- package/dist/ir/capture-values.test.js.map +1 -0
- package/dist/ir/field-values.d.ts +16 -0
- package/dist/ir/field-values.js +128 -0
- package/dist/ir/field-values.js.map +1 -0
- package/dist/ir/field-values.test.d.ts +1 -0
- package/dist/ir/field-values.test.js +160 -0
- package/dist/ir/field-values.test.js.map +1 -0
- package/dist/ir/final-fields.d.ts +4 -1
- package/dist/ir/final-fields.js +11 -3
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.test.js +2 -1
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/init-only-globals.d.ts +16 -0
- package/dist/ir/init-only-globals.js +121 -0
- package/dist/ir/init-only-globals.js.map +1 -0
- package/dist/ir/init-only-globals.test.d.ts +1 -0
- package/dist/ir/init-only-globals.test.js +115 -0
- package/dist/ir/init-only-globals.test.js.map +1 -0
- package/dist/ir/initializer-bindings.d.ts +18 -1
- package/dist/ir/initializer-bindings.js +91 -1
- package/dist/ir/initializer-bindings.js.map +1 -1
- package/dist/ir/initializer-bindings.test.js +57 -2
- package/dist/ir/initializer-bindings.test.js.map +1 -1
- package/dist/ir/int32-slots.d.ts +22 -0
- package/dist/ir/int32-slots.js +398 -13
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +119 -8
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-loop-facts.d.ts +27 -1
- package/dist/ir/integer-loop-facts.js +239 -7
- package/dist/ir/integer-loop-facts.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +8 -5
- package/dist/ir/integer-ranges.js +147 -59
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +285 -7
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +22 -1
- package/dist/ir/ir.js +4 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/property-bags.d.ts +14 -0
- package/dist/ir/property-bags.js +121 -0
- package/dist/ir/property-bags.js.map +1 -0
- package/dist/ir/receiver-readers.d.ts +21 -0
- package/dist/ir/receiver-readers.js +217 -0
- package/dist/ir/receiver-readers.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +3 -1
- package/dist/ir/runtime-features.js +102 -7
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +62 -0
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +71 -3
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +59 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/int-infer.js +3 -0
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/ir-policy.js +5 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +57 -19
|
@@ -31,7 +31,8 @@ export declare function lowerHttpResPropertyAssignment(lowerer: Lowerer, left: t
|
|
|
31
31
|
* a separate protocol concern. */
|
|
32
32
|
export declare function lowerHttpServerTimeoutAssignment(lowerer: Lowerer, left: ts.Expression, right: ts.Expression, loc: SrcLoc): IrStmt | null;
|
|
33
33
|
/** `server.maxConnections = n`: the value crosses as a dyn (undefined
|
|
34
|
-
* and null unset the cap).
|
|
34
|
+
* and null unset the cap). `server.dropMaxConnection = v` stores the
|
|
35
|
+
* value as is (Node reads it only in cluster mode). */
|
|
35
36
|
export declare function lowerNetServerMaxConnectionsAssignment(lowerer: Lowerer, left: ts.Expression, right: ts.Expression, loc: SrcLoc): IrStmt | null;
|
|
36
37
|
/** The method-call dispatch for both server-surface receiver kinds — one
|
|
37
38
|
* entry in lower-calls.ts's intrinsic chain (the lowerChildMethodCall
|
|
@@ -1045,11 +1045,13 @@ export function lowerHttpServerTimeoutAssignment(lowerer, left, right, loc) {
|
|
|
1045
1045
|
};
|
|
1046
1046
|
}
|
|
1047
1047
|
/** `server.maxConnections = n`: the value crosses as a dyn (undefined
|
|
1048
|
-
* and null unset the cap).
|
|
1048
|
+
* and null unset the cap). `server.dropMaxConnection = v` stores the
|
|
1049
|
+
* value as is (Node reads it only in cluster mode). */
|
|
1049
1050
|
export function lowerNetServerMaxConnectionsAssignment(lowerer, left, right, loc) {
|
|
1050
1051
|
if (!ts.isPropertyAccessExpression(left) || left.questionDotToken)
|
|
1051
1052
|
return null;
|
|
1052
|
-
|
|
1053
|
+
const name = left.name.text;
|
|
1054
|
+
if (name !== "maxConnections" && name !== "dropMaxConnection")
|
|
1053
1055
|
return null;
|
|
1054
1056
|
if (lowerer.mapTypeOf(lowerer.typeOf(left.expression))?.kind !== "netServer")
|
|
1055
1057
|
return null;
|
|
@@ -1061,7 +1063,9 @@ export function lowerNetServerMaxConnectionsAssignment(lowerer, left, right, loc
|
|
|
1061
1063
|
kind: "exprStmt",
|
|
1062
1064
|
expr: {
|
|
1063
1065
|
kind: "libCall",
|
|
1064
|
-
fn: "
|
|
1066
|
+
fn: name === "maxConnections"
|
|
1067
|
+
? "net.serverMaxConnectionsSet"
|
|
1068
|
+
: "net.serverDropMaxConnectionSet",
|
|
1065
1069
|
args: [receiver, value],
|
|
1066
1070
|
type: VOID,
|
|
1067
1071
|
loc,
|
|
@@ -1385,6 +1389,18 @@ function lowerNetServerMethodCall(lowerer, call, access) {
|
|
|
1385
1389
|
loc,
|
|
1386
1390
|
};
|
|
1387
1391
|
}
|
|
1392
|
+
if (event === "checkContinue" || event === "checkExpectation") {
|
|
1393
|
+
// Expect handling: these listeners take the request instead of
|
|
1394
|
+
// 'request' (checkContinue answers with res.writeContinue()).
|
|
1395
|
+
const cb = lowerRequestHandlerArg(lowerer, args[1]);
|
|
1396
|
+
return {
|
|
1397
|
+
kind: "libCall",
|
|
1398
|
+
fn: "http.serverOnCheck",
|
|
1399
|
+
args: [receiver, cb, once, boolLit(event === "checkExpectation", loc)],
|
|
1400
|
+
type: VOID,
|
|
1401
|
+
loc,
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1388
1404
|
if (event === "request") {
|
|
1389
1405
|
// The 'request' event — http.createServer(handler)'s event twin, and
|
|
1390
1406
|
// the way an http2 allowHTTP1 server (created handler-less) gets its
|
|
@@ -1518,7 +1534,7 @@ function lowerNetServerMethodCall(lowerer, call, access) {
|
|
|
1518
1534
|
loc,
|
|
1519
1535
|
};
|
|
1520
1536
|
}
|
|
1521
|
-
lowerer.noLowering(`server.${name}(${event === null ? "non-literal event" : `"${event}"`}, ...)`, args[0], '"connection", "request", "drop", "stream", "session", "upgrade", "connect", "error", "close", "listening", and "sessionError" are the supported server events (as literals)');
|
|
1537
|
+
lowerer.noLowering(`server.${name}(${event === null ? "non-literal event" : `"${event}"`}, ...)`, args[0], '"connection", "request", "checkContinue", "checkExpectation", "drop", "stream", "session", "upgrade", "connect", "error", "close", "listening", and "sessionError" are the supported server events (as literals)');
|
|
1522
1538
|
}
|
|
1523
1539
|
if (name === "emit") {
|
|
1524
1540
|
// The demux route: emit("connection", socket) hands an accepted
|
|
@@ -1851,6 +1867,50 @@ function lowerNetSocketMethodCall(lowerer, call, access) {
|
|
|
1851
1867
|
loc,
|
|
1852
1868
|
};
|
|
1853
1869
|
}
|
|
1870
|
+
if ((name === "getProtocol" || name === "getCipher") && args.length === 0) {
|
|
1871
|
+
// TLSSocket.getProtocol(): "TLSv1.2"/"TLSv1.3" or null;
|
|
1872
|
+
// getCipher(): { name, standardName, version }.
|
|
1873
|
+
const receiver = coerceToHandle(lowerer, access.expression, NETSOCKET_T);
|
|
1874
|
+
const value = {
|
|
1875
|
+
kind: "libCall",
|
|
1876
|
+
fn: name === "getProtocol" ? "tls.sockGetProtocol" : "tls.sockGetCipher",
|
|
1877
|
+
args: [receiver],
|
|
1878
|
+
type: DYN,
|
|
1879
|
+
loc,
|
|
1880
|
+
};
|
|
1881
|
+
const declared = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
1882
|
+
return declared === null || declared.kind === "dyn"
|
|
1883
|
+
? value
|
|
1884
|
+
: lowerer.coerceInto(call, value, declared);
|
|
1885
|
+
}
|
|
1886
|
+
if (name === "resetAndDestroy") {
|
|
1887
|
+
// An RST close; a connecting socket resets once it connects. Answers
|
|
1888
|
+
// the socket, Node's chaining.
|
|
1889
|
+
if (args.length !== 0) {
|
|
1890
|
+
lowerer.noLowering(`resetAndDestroy with ${args.length} arguments`, call, "the form is resetAndDestroy()");
|
|
1891
|
+
}
|
|
1892
|
+
const receiver = coerceToHandle(lowerer, access.expression, NETSOCKET_T);
|
|
1893
|
+
return {
|
|
1894
|
+
kind: "libCall",
|
|
1895
|
+
fn: "net.sockResetAndDestroy",
|
|
1896
|
+
args: [receiver],
|
|
1897
|
+
type: NETSOCKET_T,
|
|
1898
|
+
loc,
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
if (name === "address") {
|
|
1902
|
+
// { address, family, port } or {} (connecting or destroyed): the
|
|
1903
|
+
// declared AddressInfo | {} maps to a dyn value.
|
|
1904
|
+
if (args.length !== 0) {
|
|
1905
|
+
lowerer.noLowering(`address with ${args.length} arguments`, call, "address() takes no arguments");
|
|
1906
|
+
}
|
|
1907
|
+
const result = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
1908
|
+
if (result?.kind !== "dyn") {
|
|
1909
|
+
lowerer.noLowering("socket.address() where the result is not AddressInfo | {}", call, "use the declared AddressInfo | {} result, and narrow it with a type assertion");
|
|
1910
|
+
}
|
|
1911
|
+
const receiver = coerceToHandle(lowerer, access.expression, NETSOCKET_T);
|
|
1912
|
+
return { kind: "libCall", fn: "net.sockAddress", args: [receiver], type: DYN, loc };
|
|
1913
|
+
}
|
|
1854
1914
|
if (name === "destroySoon") {
|
|
1855
1915
|
// end() now, destroy once the FIN actually flushed — Node's
|
|
1856
1916
|
// 'finish'-then-destroy.
|
|
@@ -2478,11 +2538,13 @@ export function lowerServerProperty(lowerer, expr) {
|
|
|
2478
2538
|
const receiver = coerceToHandle(lowerer, expr.expression, NETSERVER_T);
|
|
2479
2539
|
return { kind: "libCall", fn: "net.serverListening", args: [receiver], type: BOOL, loc };
|
|
2480
2540
|
}
|
|
2481
|
-
if (expr.name.text === "maxConnections") {
|
|
2541
|
+
if (expr.name.text === "maxConnections" || expr.name.text === "dropMaxConnection") {
|
|
2482
2542
|
const receiver = coerceToHandle(lowerer, expr.expression, NETSERVER_T);
|
|
2483
2543
|
const value = {
|
|
2484
2544
|
kind: "libCall",
|
|
2485
|
-
fn:
|
|
2545
|
+
fn: expr.name.text === "maxConnections"
|
|
2546
|
+
? "net.serverMaxConnectionsGet"
|
|
2547
|
+
: "net.serverDropMaxConnectionGet",
|
|
2486
2548
|
args: [receiver],
|
|
2487
2549
|
type: DYN,
|
|
2488
2550
|
loc,
|
|
@@ -2647,6 +2709,24 @@ export function lowerServerProperty(lowerer, expr) {
|
|
|
2647
2709
|
const receiver = coerceToHandle(lowerer, expr.expression, NETSOCKET_T);
|
|
2648
2710
|
return { kind: "libCall", fn: "tls.sockAuthorized", args: [receiver], type: BOOL, loc };
|
|
2649
2711
|
}
|
|
2712
|
+
if (recvKind === "netSocket" &&
|
|
2713
|
+
lowerer.isStdlibMember(expr) &&
|
|
2714
|
+
expr.name.text === "alpnProtocol") {
|
|
2715
|
+
// TLSSocket.alpnProtocol: null before the handshake, then the
|
|
2716
|
+
// negotiated protocol or false.
|
|
2717
|
+
const receiver = coerceToHandle(lowerer, expr.expression, NETSOCKET_T);
|
|
2718
|
+
const value = {
|
|
2719
|
+
kind: "libCall",
|
|
2720
|
+
fn: "tls.sockAlpnProtocol",
|
|
2721
|
+
args: [receiver],
|
|
2722
|
+
type: DYN,
|
|
2723
|
+
loc,
|
|
2724
|
+
};
|
|
2725
|
+
const declared = lowerer.mapTypeOf(lowerer.typeOf(expr));
|
|
2726
|
+
return declared === null || declared.kind === "dyn"
|
|
2727
|
+
? value
|
|
2728
|
+
: lowerer.coerceInto(expr, value, declared);
|
|
2729
|
+
}
|
|
2650
2730
|
if (recvKind === "netSocket" && expr.name.text === "authorizationError") {
|
|
2651
2731
|
// TLSSocket.authorizationError — the verify-failure CODE STRING
|
|
2652
2732
|
// (DEPTH_ZERO_SELF_SIGNED_CERT, ...) or null when authorized/never
|
|
@@ -2999,6 +3079,7 @@ function lowerHttpServerOptions(lowerer, node, what) {
|
|
|
2999
3079
|
let joinDup = false;
|
|
3000
3080
|
let allowMissingHost = false;
|
|
3001
3081
|
let keepAliveTimeoutBuffer = null;
|
|
3082
|
+
let maxHeaderSize = null;
|
|
3002
3083
|
for (const prop of node.properties) {
|
|
3003
3084
|
let initializer;
|
|
3004
3085
|
if (ts.isPropertyAssignment(prop) &&
|
|
@@ -3037,6 +3118,17 @@ function lowerHttpServerOptions(lowerer, node, what) {
|
|
|
3037
3118
|
}
|
|
3038
3119
|
lowerer.noLowering(`${what} with a non-literal joinDuplicateHeaders option`, prop, 'the lowered forms are the literals joinDuplicateHeaders: true (repeats join ", ") and false (the keep-first default)');
|
|
3039
3120
|
}
|
|
3121
|
+
if (key === "maxHeaderSize") {
|
|
3122
|
+
// The header size bound (Node's validateInteger runs in the runtime).
|
|
3123
|
+
const raw = initializer !== null
|
|
3124
|
+
? lowerer.lowerExpr(initializer)
|
|
3125
|
+
: lowerer.lowerShorthandValue(prop);
|
|
3126
|
+
if (raw.type.kind !== "f64") {
|
|
3127
|
+
lowerer.noLowering(`${what} with a '${lowerer.fmt(raw.type)}' maxHeaderSize option`, prop, "maxHeaderSize is a number");
|
|
3128
|
+
}
|
|
3129
|
+
maxHeaderSize = raw;
|
|
3130
|
+
continue;
|
|
3131
|
+
}
|
|
3040
3132
|
if (key === "keepAliveTimeoutBuffer") {
|
|
3041
3133
|
if (keepAliveTimeoutBuffer !== null) {
|
|
3042
3134
|
lowerer.noLowering(`${what} with duplicate keepAliveTimeoutBuffer options`, prop, "write keepAliveTimeoutBuffer once in the options literal");
|
|
@@ -3056,10 +3148,10 @@ function lowerHttpServerOptions(lowerer, node, what) {
|
|
|
3056
3148
|
keepAliveTimeoutBuffer = value;
|
|
3057
3149
|
continue;
|
|
3058
3150
|
}
|
|
3059
|
-
fenceOrDropOptionKey(lowerer, prop, key, what, HTTP_SERVER_DOCUMENTED_OPTIONS, "requireHostHeader, joinDuplicateHeaders, and
|
|
3151
|
+
fenceOrDropOptionKey(lowerer, prop, key, what, HTTP_SERVER_DOCUMENTED_OPTIONS, "requireHostHeader, joinDuplicateHeaders, keepAliveTimeoutBuffer, and maxHeaderSize are the supported options");
|
|
3060
3152
|
// An undocumented key, dropped like Node drops it.
|
|
3061
3153
|
}
|
|
3062
|
-
return { joinDup, allowMissingHost, keepAliveTimeoutBuffer };
|
|
3154
|
+
return { joinDup, allowMissingHost, keepAliveTimeoutBuffer, maxHeaderSize };
|
|
3063
3155
|
}
|
|
3064
3156
|
/** The shared createServer([options][, handler]) shapes behind
|
|
3065
3157
|
* http.createServer, http.Server, and `new http.Server`: no arguments
|
|
@@ -3085,7 +3177,12 @@ function lowerHttpCreateServerForms(lowerer, expr, what, loc) {
|
|
|
3085
3177
|
}
|
|
3086
3178
|
const opts = optsNode !== null
|
|
3087
3179
|
? lowerHttpServerOptions(lowerer, optsNode, what)
|
|
3088
|
-
: {
|
|
3180
|
+
: {
|
|
3181
|
+
joinDup: false,
|
|
3182
|
+
allowMissingHost: false,
|
|
3183
|
+
keepAliveTimeoutBuffer: null,
|
|
3184
|
+
maxHeaderSize: null,
|
|
3185
|
+
};
|
|
3089
3186
|
const server = handlerNode !== null
|
|
3090
3187
|
? {
|
|
3091
3188
|
kind: "libCall",
|
|
@@ -3095,20 +3192,25 @@ function lowerHttpCreateServerForms(lowerer, expr, what, loc) {
|
|
|
3095
3192
|
loc,
|
|
3096
3193
|
}
|
|
3097
3194
|
: { kind: "libCall", fn: "http.createServerEmpty", args: [], type: NETSERVER_T, loc };
|
|
3098
|
-
if (!opts.joinDup &&
|
|
3195
|
+
if (!opts.joinDup &&
|
|
3196
|
+
!opts.allowMissingHost &&
|
|
3197
|
+
opts.keepAliveTimeoutBuffer === null &&
|
|
3198
|
+
opts.maxHeaderSize === null)
|
|
3099
3199
|
return server;
|
|
3100
3200
|
// The option-setting composition: an interned helper takes the option
|
|
3101
3201
|
// values first (preserving Node's options-before-handler evaluation
|
|
3102
3202
|
// order), then the fresh server, applies the modeled fields, and answers
|
|
3103
3203
|
// the server as the constructor/factory result.
|
|
3104
3204
|
const hasBuffer = opts.keepAliveTimeoutBuffer !== null;
|
|
3105
|
-
const
|
|
3205
|
+
const hasMax = opts.maxHeaderSize !== null;
|
|
3206
|
+
const key = `server.opts:${opts.joinDup ? 1 : 0}:${opts.allowMissingHost ? 1 : 0}:${hasBuffer ? 1 : 0}:${hasMax ? 1 : 0}`;
|
|
3106
3207
|
const existing = lowerer.arrHofHelpers.get(key);
|
|
3107
3208
|
const name = existing ?? `%server.opts.${lowerer.arrHofHelpers.size}`;
|
|
3108
3209
|
if (!existing) {
|
|
3109
3210
|
lowerer.arrHofHelpers.set(key, name);
|
|
3110
3211
|
const params = [
|
|
3111
3212
|
...(hasBuffer ? [{ localId: "b.0", name: "buffer", type: DYN }] : []),
|
|
3213
|
+
...(hasMax ? [{ localId: "m.0", name: "maxHeaderSize", type: F64 }] : []),
|
|
3112
3214
|
{ localId: "s.0", name: "s", type: NETSERVER_T },
|
|
3113
3215
|
];
|
|
3114
3216
|
const ref = { kind: "varRef", localId: "s.0", type: NETSERVER_T, loc };
|
|
@@ -3128,6 +3230,19 @@ function lowerHttpCreateServerForms(lowerer, expr, what, loc) {
|
|
|
3128
3230
|
loc,
|
|
3129
3231
|
});
|
|
3130
3232
|
}
|
|
3233
|
+
if (hasMax) {
|
|
3234
|
+
body.push({
|
|
3235
|
+
kind: "exprStmt",
|
|
3236
|
+
expr: {
|
|
3237
|
+
kind: "libCall",
|
|
3238
|
+
fn: "http.serverMaxHeaderSize",
|
|
3239
|
+
args: [ref, { kind: "varRef", localId: "m.0", type: F64, loc }],
|
|
3240
|
+
type: VOID,
|
|
3241
|
+
loc,
|
|
3242
|
+
},
|
|
3243
|
+
loc,
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3131
3246
|
if (opts.joinDup) {
|
|
3132
3247
|
body.push({
|
|
3133
3248
|
kind: "exprStmt",
|
|
@@ -3161,7 +3276,11 @@ function lowerHttpCreateServerForms(lowerer, expr, what, loc) {
|
|
|
3161
3276
|
return {
|
|
3162
3277
|
kind: "call",
|
|
3163
3278
|
callee: name,
|
|
3164
|
-
args: [
|
|
3279
|
+
args: [
|
|
3280
|
+
...(opts.keepAliveTimeoutBuffer !== null ? [opts.keepAliveTimeoutBuffer] : []),
|
|
3281
|
+
...(opts.maxHeaderSize !== null ? [opts.maxHeaderSize] : []),
|
|
3282
|
+
server,
|
|
3283
|
+
],
|
|
3165
3284
|
type: NETSERVER_T,
|
|
3166
3285
|
loc,
|
|
3167
3286
|
};
|
|
@@ -4437,6 +4556,12 @@ function lowerHttpClientCall(lowerer, expr, member, loc, secure = false) {
|
|
|
4437
4556
|
let agentClose = null;
|
|
4438
4557
|
/** agent: <Agent value> — the requestAgent rows thread the handle. */
|
|
4439
4558
|
let agentVal = null;
|
|
4559
|
+
/** signal: an AbortSignal (checked at runtime) that destroys the request. */
|
|
4560
|
+
let signal = null;
|
|
4561
|
+
/** servername: the TLS name for SNI and certificate verification. */
|
|
4562
|
+
let servername = null;
|
|
4563
|
+
/** maxHeaderSize: the response head's size bound. */
|
|
4564
|
+
let maxHeaderSize = null;
|
|
4440
4565
|
for (const prop of optsNode.properties) {
|
|
4441
4566
|
// Shorthand entries ({ port } for { port: port }) are the natural
|
|
4442
4567
|
// spelling at these call sites — the shorthand's VALUE lowering
|
|
@@ -4528,6 +4653,22 @@ function lowerHttpClientCall(lowerer, expr, member, loc, secure = false) {
|
|
|
4528
4653
|
case "timeout":
|
|
4529
4654
|
timeout = lowerVal("f64");
|
|
4530
4655
|
break;
|
|
4656
|
+
case "maxHeaderSize":
|
|
4657
|
+
maxHeaderSize = lowerVal("f64");
|
|
4658
|
+
break;
|
|
4659
|
+
case "servername":
|
|
4660
|
+
if (!secureish) {
|
|
4661
|
+
lowerer.noLowering(`${member} option 'servername'`, prop, "servername is an https.request option — the plain http client has no TLS layer");
|
|
4662
|
+
}
|
|
4663
|
+
servername = lowerVal("string");
|
|
4664
|
+
break;
|
|
4665
|
+
case "signal": {
|
|
4666
|
+
const v = initializer !== null
|
|
4667
|
+
? lowerer.lowerExpr(initializer)
|
|
4668
|
+
: lowerer.lowerShorthandValue(prop);
|
|
4669
|
+
signal = lowerer.coerceToExpected(v, DYN);
|
|
4670
|
+
break;
|
|
4671
|
+
}
|
|
4531
4672
|
case "headers":
|
|
4532
4673
|
if (initializer === null) {
|
|
4533
4674
|
lowerer.noLowering(`${member} with a shorthand headers option`, prop, "spell it out: headers: theHeaders");
|
|
@@ -4612,8 +4753,8 @@ function lowerHttpClientCall(lowerer, expr, member, loc, secure = false) {
|
|
|
4612
4753
|
}
|
|
4613
4754
|
default:
|
|
4614
4755
|
fenceOrDropOptionKey(lowerer, prop, key, member, secureish ? HTTPS_CLIENT_DOCUMENTED_OPTIONS : HTTP_CLIENT_DOCUMENTED_OPTIONS, secureish
|
|
4615
|
-
? "hostname/host, port, path, method, timeout, headers, agent, rejectUnauthorized, and
|
|
4616
|
-
: "hostname/host, port, path, method, timeout, headers, and
|
|
4756
|
+
? "hostname/host, port, path, method, timeout, headers, agent, signal, maxHeaderSize, rejectUnauthorized, ca, and servername are the supported options"
|
|
4757
|
+
: "hostname/host, port, path, method, timeout, headers, agent, signal, and maxHeaderSize are the supported options");
|
|
4617
4758
|
}
|
|
4618
4759
|
}
|
|
4619
4760
|
if (agentClose !== null) {
|
|
@@ -4679,19 +4820,69 @@ function lowerHttpClientCall(lowerer, expr, member, loc, secure = false) {
|
|
|
4679
4820
|
timeout ??= numLit(0, loc);
|
|
4680
4821
|
headers ??= { kind: "arrayLit", elems: [], type: arrayOf(STRING), loc };
|
|
4681
4822
|
const autoEnd = boolLit(member === "get", loc);
|
|
4823
|
+
// Options applied to the built request: servername before the TLS
|
|
4824
|
+
// handshake starts, then options.signal (an already aborted signal
|
|
4825
|
+
// destroys the request at once, like Node's constructor).
|
|
4826
|
+
const withSignal = (request) => {
|
|
4827
|
+
if (signal === null && servername === null && maxHeaderSize === null)
|
|
4828
|
+
return request;
|
|
4829
|
+
const local = lowerer.declareHiddenLocal("%requestOptions", HTTPCLIENTREQ_T);
|
|
4830
|
+
const ref = () => varRef(local.id, HTTPCLIENTREQ_T, loc);
|
|
4831
|
+
const steps = [{ kind: "varDecl", localId: local.id, init: request, loc }];
|
|
4832
|
+
if (maxHeaderSize !== null) {
|
|
4833
|
+
steps.push({
|
|
4834
|
+
kind: "exprStmt",
|
|
4835
|
+
expr: {
|
|
4836
|
+
kind: "libCall",
|
|
4837
|
+
fn: "http.clientMaxHeaderSize",
|
|
4838
|
+
args: [ref(), maxHeaderSize],
|
|
4839
|
+
type: VOID,
|
|
4840
|
+
loc,
|
|
4841
|
+
},
|
|
4842
|
+
loc,
|
|
4843
|
+
});
|
|
4844
|
+
}
|
|
4845
|
+
if (servername !== null) {
|
|
4846
|
+
steps.push({
|
|
4847
|
+
kind: "exprStmt",
|
|
4848
|
+
expr: {
|
|
4849
|
+
kind: "libCall",
|
|
4850
|
+
fn: "https.clientServername",
|
|
4851
|
+
args: [ref(), servername],
|
|
4852
|
+
type: VOID,
|
|
4853
|
+
loc,
|
|
4854
|
+
},
|
|
4855
|
+
loc,
|
|
4856
|
+
});
|
|
4857
|
+
}
|
|
4858
|
+
if (signal !== null) {
|
|
4859
|
+
steps.push({
|
|
4860
|
+
kind: "exprStmt",
|
|
4861
|
+
expr: { kind: "libCall", fn: "http.clientSignal", args: [ref(), signal], type: VOID, loc },
|
|
4862
|
+
loc,
|
|
4863
|
+
});
|
|
4864
|
+
}
|
|
4865
|
+
return { kind: "seqExpr", stmts: steps, result: ref(), type: HTTPCLIENTREQ_T, loc };
|
|
4866
|
+
};
|
|
4682
4867
|
if (connCb !== null) {
|
|
4683
4868
|
const base = [connCb, path, method, timeout, headers, autoEnd];
|
|
4684
4869
|
if (args.length === 1) {
|
|
4685
|
-
return {
|
|
4870
|
+
return withSignal({
|
|
4871
|
+
kind: "libCall",
|
|
4872
|
+
fn: "http.requestConn",
|
|
4873
|
+
args: base,
|
|
4874
|
+
type: HTTPCLIENTREQ_T,
|
|
4875
|
+
loc,
|
|
4876
|
+
});
|
|
4686
4877
|
}
|
|
4687
4878
|
const { cb } = lowerCallbackArg(lowerer, args[1], "response callbacks", 1, (p) => p.kind === "httpReq", "use (res) or ()", [HTTPREQ_T]);
|
|
4688
|
-
return {
|
|
4879
|
+
return withSignal({
|
|
4689
4880
|
kind: "libCall",
|
|
4690
4881
|
fn: "http.requestConnCb",
|
|
4691
4882
|
args: [...base, cb],
|
|
4692
4883
|
type: HTTPCLIENTREQ_T,
|
|
4693
4884
|
loc,
|
|
4694
|
-
};
|
|
4885
|
+
});
|
|
4695
4886
|
}
|
|
4696
4887
|
const base = [host, port, path, method, timeout, headers, autoEnd];
|
|
4697
4888
|
if (secureish) {
|
|
@@ -4713,7 +4904,7 @@ function lowerHttpClientCall(lowerer, expr, member, loc, secure = false) {
|
|
|
4713
4904
|
: agentVal !== null
|
|
4714
4905
|
? "http.requestAgent"
|
|
4715
4906
|
: "http.request";
|
|
4716
|
-
return { kind: "libCall", fn, args: base, type: HTTPCLIENTREQ_T, loc };
|
|
4907
|
+
return withSignal({ kind: "libCall", fn, args: base, type: HTTPCLIENTREQ_T, loc });
|
|
4717
4908
|
}
|
|
4718
4909
|
const { cb } = lowerCallbackArg(lowerer, args[1], "response callbacks", 1, (p) => p.kind === "httpReq", "use (res) or ()", [HTTPREQ_T]);
|
|
4719
4910
|
const fn = binding !== null
|
|
@@ -4725,7 +4916,7 @@ function lowerHttpClientCall(lowerer, expr, member, loc, secure = false) {
|
|
|
4725
4916
|
: agentVal !== null
|
|
4726
4917
|
? "http.requestAgentCb"
|
|
4727
4918
|
: "http.requestCb";
|
|
4728
|
-
return { kind: "libCall", fn, args: [...base, cb], type: HTTPCLIENTREQ_T, loc };
|
|
4919
|
+
return withSignal({ kind: "libCall", fn, args: [...base, cb], type: HTTPCLIENTREQ_T, loc });
|
|
4729
4920
|
}
|
|
4730
4921
|
/** The headers option of http.request: an object literal with literal
|
|
4731
4922
|
* keys and string values packs into the flat [k0, v0, k1, v1, ...] pairs
|
|
@@ -4941,6 +5132,22 @@ function lowerHttpClientMethodCall(lowerer, call, access) {
|
|
|
4941
5132
|
}
|
|
4942
5133
|
lowerer.noLowering(`${name} of '${lowerer.fmt(data.type)}' data`, args[0] ?? call, NARROW_DATA_HINT);
|
|
4943
5134
|
}
|
|
5135
|
+
if (name === "destroy" && args.length === 1) {
|
|
5136
|
+
// destroy(err): err is the request's 'error' (an Error value here).
|
|
5137
|
+
requireStatementPosition(lowerer, call, "request.destroy(err)");
|
|
5138
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
5139
|
+
const err = lowerer.lowerExpr(args[0]);
|
|
5140
|
+
if (err.type.kind !== "object") {
|
|
5141
|
+
lowerer.noLowering(`destroy with a '${lowerer.fmt(err.type)}' argument`, args[0], "pass an Error value, or call destroy() without one");
|
|
5142
|
+
}
|
|
5143
|
+
return {
|
|
5144
|
+
kind: "libCall",
|
|
5145
|
+
fn: "http.clientDestroyError",
|
|
5146
|
+
args: [receiver, lowerer.coerceToExpected(err, ERROR_T)],
|
|
5147
|
+
type: VOID,
|
|
5148
|
+
loc,
|
|
5149
|
+
};
|
|
5150
|
+
}
|
|
4944
5151
|
if (name === "destroy" || name === "abort") {
|
|
4945
5152
|
requireStatementPosition(lowerer, call, `request.${name}()`);
|
|
4946
5153
|
if (args.length !== 0) {
|
|
@@ -4991,7 +5198,11 @@ function lowerHttpClientMethodCall(lowerer, call, access) {
|
|
|
4991
5198
|
loc,
|
|
4992
5199
|
};
|
|
4993
5200
|
}
|
|
4994
|
-
if (event === "timeout" ||
|
|
5201
|
+
if (event === "timeout" ||
|
|
5202
|
+
event === "close" ||
|
|
5203
|
+
event === "finish" ||
|
|
5204
|
+
event === "abort" ||
|
|
5205
|
+
event === "continue") {
|
|
4995
5206
|
const { cb } = lowerCallbackArg(lowerer, args[1], `${event} listeners`, 0, () => false, "use ()", []);
|
|
4996
5207
|
const fn = event === "timeout"
|
|
4997
5208
|
? "http.clientOnTimeout"
|
|
@@ -4999,7 +5210,9 @@ function lowerHttpClientMethodCall(lowerer, call, access) {
|
|
|
4999
5210
|
? "http.clientOnClose"
|
|
5000
5211
|
: event === "abort"
|
|
5001
5212
|
? "http.clientOnAbort"
|
|
5002
|
-
: "
|
|
5213
|
+
: event === "continue"
|
|
5214
|
+
? "http.clientOnContinue"
|
|
5215
|
+
: "http.clientOnFinish";
|
|
5003
5216
|
return { kind: "libCall", fn, args: [receiver, cb, once], type: VOID, loc };
|
|
5004
5217
|
}
|
|
5005
5218
|
if (event === "upgrade") {
|