@tsonic/frontend 0.0.62 → 0.0.63
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/dist/.tsbuildinfo +1 -1
- package/dist/dependency-graph.d.ts +1 -1
- package/dist/dependency-graph.d.ts.map +1 -1
- package/dist/dependency-graph.js +1 -1
- package/dist/dependency-graph.js.map +1 -1
- package/dist/dotnet-metadata.d.ts +0 -12
- package/dist/dotnet-metadata.d.ts.map +1 -1
- package/dist/dotnet-metadata.js +0 -24
- package/dist/dotnet-metadata.js.map +1 -1
- package/dist/generic-function-values.d.ts +11 -0
- package/dist/generic-function-values.d.ts.map +1 -0
- package/dist/generic-function-values.js +243 -0
- package/dist/generic-function-values.js.map +1 -0
- package/dist/generic-function-values.test.d.ts +2 -0
- package/dist/generic-function-values.test.d.ts.map +1 -0
- package/dist/generic-function-values.test.js +256 -0
- package/dist/generic-function-values.test.js.map +1 -0
- package/dist/graph/extraction/imports.d.ts +5 -0
- package/dist/graph/extraction/imports.d.ts.map +1 -1
- package/dist/graph/extraction/imports.js +30 -0
- package/dist/graph/extraction/imports.js.map +1 -1
- package/dist/graph/extraction/index.d.ts +1 -1
- package/dist/graph/extraction/index.d.ts.map +1 -1
- package/dist/graph/extraction/index.js +1 -1
- package/dist/graph/extraction/index.js.map +1 -1
- package/dist/graph/extraction/orchestrator.d.ts.map +1 -1
- package/dist/graph/extraction/orchestrator.js +16 -2
- package/dist/graph/extraction/orchestrator.js.map +1 -1
- package/dist/graph/extraction.d.ts +1 -1
- package/dist/graph/extraction.d.ts.map +1 -1
- package/dist/graph/extraction.js +1 -1
- package/dist/graph/extraction.js.map +1 -1
- package/dist/ir/binding/binding-factory.d.ts +17 -0
- package/dist/ir/binding/binding-factory.d.ts.map +1 -0
- package/dist/ir/binding/binding-factory.js +765 -0
- package/dist/ir/binding/binding-factory.js.map +1 -0
- package/dist/ir/binding/binding-helpers.d.ts +90 -0
- package/dist/ir/binding/binding-helpers.d.ts.map +1 -0
- package/dist/ir/binding/binding-helpers.js +387 -0
- package/dist/ir/binding/binding-helpers.js.map +1 -0
- package/dist/ir/binding/binding-types.d.ts +203 -0
- package/dist/ir/binding/binding-types.d.ts.map +1 -0
- package/dist/ir/binding/binding-types.js +9 -0
- package/dist/ir/binding/binding-types.js.map +1 -0
- package/dist/ir/binding/index.d.ts +4 -158
- package/dist/ir/binding/index.d.ts.map +1 -1
- package/dist/ir/binding/index.js +3 -1134
- package/dist/ir/binding/index.js.map +1 -1
- package/dist/ir/builder.test.js +223 -0
- package/dist/ir/builder.test.js.map +1 -1
- package/dist/ir/converters/anonymous-synthesis.d.ts +3 -3
- package/dist/ir/converters/anonymous-synthesis.d.ts.map +1 -1
- package/dist/ir/converters/anonymous-synthesis.js +45 -8
- package/dist/ir/converters/anonymous-synthesis.js.map +1 -1
- package/dist/ir/converters/expressions/access/access-converter.d.ts +14 -0
- package/dist/ir/converters/expressions/access/access-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/access-converter.js +141 -0
- package/dist/ir/converters/expressions/access/access-converter.js.map +1 -0
- package/dist/ir/converters/expressions/access/binding-resolution.d.ts +35 -0
- package/dist/ir/converters/expressions/access/binding-resolution.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/binding-resolution.js +384 -0
- package/dist/ir/converters/expressions/access/binding-resolution.js.map +1 -0
- package/dist/ir/converters/expressions/access/member-resolution.d.ts +67 -0
- package/dist/ir/converters/expressions/access/member-resolution.d.ts.map +1 -0
- package/dist/ir/converters/expressions/access/member-resolution.js +262 -0
- package/dist/ir/converters/expressions/access/member-resolution.js.map +1 -0
- package/dist/ir/converters/expressions/access.d.ts +1 -7
- package/dist/ir/converters/expressions/access.d.ts.map +1 -1
- package/dist/ir/converters/expressions/access.js +1 -720
- package/dist/ir/converters/expressions/access.js.map +1 -1
- package/dist/ir/converters/expressions/calls/call-converter.d.ts +23 -0
- package/dist/ir/converters/expressions/calls/call-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/call-converter.js +526 -0
- package/dist/ir/converters/expressions/calls/call-converter.js.map +1 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.d.ts +53 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.js +554 -0
- package/dist/ir/converters/expressions/calls/call-site-analysis.js.map +1 -0
- package/dist/ir/converters/expressions/calls/new-converter.d.ts +21 -0
- package/dist/ir/converters/expressions/calls/new-converter.d.ts.map +1 -0
- package/dist/ir/converters/expressions/calls/new-converter.js +182 -0
- package/dist/ir/converters/expressions/calls/new-converter.js.map +1 -0
- package/dist/ir/converters/expressions/calls.d.ts +2 -28
- package/dist/ir/converters/expressions/calls.d.ts.map +1 -1
- package/dist/ir/converters/expressions/calls.js +2 -1344
- package/dist/ir/converters/expressions/calls.js.map +1 -1
- package/dist/ir/converters/expressions/collections.d.ts.map +1 -1
- package/dist/ir/converters/expressions/collections.js +37 -6
- package/dist/ir/converters/expressions/collections.js.map +1 -1
- package/dist/ir/converters/expressions/functions.js +1 -1
- package/dist/ir/converters/expressions/functions.js.map +1 -1
- package/dist/ir/converters/expressions/helpers.d.ts.map +1 -1
- package/dist/ir/converters/expressions/helpers.js +1 -0
- package/dist/ir/converters/expressions/helpers.js.map +1 -1
- package/dist/ir/converters/expressions/other.d.ts.map +1 -1
- package/dist/ir/converters/expressions/other.js +3 -2
- package/dist/ir/converters/expressions/other.js.map +1 -1
- package/dist/ir/converters/flow-narrowing.d.ts.map +1 -1
- package/dist/ir/converters/flow-narrowing.js +3 -2
- package/dist/ir/converters/flow-narrowing.js.map +1 -1
- package/dist/ir/converters/statements/declarations/classes/methods.js +1 -1
- package/dist/ir/converters/statements/declarations/classes/methods.js.map +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.js +1 -1
- package/dist/ir/converters/statements/declarations/type-aliases.js.map +1 -1
- package/dist/ir/converters/statements/declarations/variables.d.ts +2 -2
- package/dist/ir/converters/statements/declarations/variables.d.ts.map +1 -1
- package/dist/ir/converters/statements/declarations/variables.js +289 -2
- package/dist/ir/converters/statements/declarations/variables.js.map +1 -1
- package/dist/ir/expression-converter.d.ts +0 -1
- package/dist/ir/expression-converter.d.ts.map +1 -1
- package/dist/ir/expression-converter.js +0 -2
- package/dist/ir/expression-converter.js.map +1 -1
- package/dist/ir/generic-function-value-lowering.test.d.ts +2 -0
- package/dist/ir/generic-function-value-lowering.test.d.ts.map +1 -0
- package/dist/ir/generic-function-value-lowering.test.js +312 -0
- package/dist/ir/generic-function-value-lowering.test.js.map +1 -0
- package/dist/ir/generic-validator.d.ts +3 -4
- package/dist/ir/generic-validator.d.ts.map +1 -1
- package/dist/ir/generic-validator.js +3 -35
- package/dist/ir/generic-validator.js.map +1 -1
- package/dist/ir/program-context.d.ts +7 -0
- package/dist/ir/program-context.d.ts.map +1 -1
- package/dist/ir/program-context.js +1 -0
- package/dist/ir/program-context.js.map +1 -1
- package/dist/ir/statement-converter.d.ts +0 -2
- package/dist/ir/statement-converter.d.ts.map +1 -1
- package/dist/ir/statement-converter.js +0 -3
- package/dist/ir/statement-converter.js.map +1 -1
- package/dist/ir/type-system/internal/handle-types.d.ts +16 -16
- package/dist/ir/type-system/internal/handle-types.d.ts.map +1 -1
- package/dist/ir/type-system/internal/nominal-env.d.ts +0 -2
- package/dist/ir/type-system/internal/nominal-env.d.ts.map +1 -1
- package/dist/ir/type-system/internal/nominal-env.js +2 -6
- package/dist/ir/type-system/internal/nominal-env.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/converter.d.ts +3 -1
- package/dist/ir/type-system/internal/type-converter/converter.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/converter.js +3 -1
- package/dist/ir/type-system/internal/type-converter/converter.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/objects.js +7 -1
- package/dist/ir/type-system/internal/type-converter/objects.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.d.ts +0 -2
- package/dist/ir/type-system/internal/type-converter/orchestrator.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.js +315 -23
- package/dist/ir/type-system/internal/type-converter/orchestrator.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.d.ts +2 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.d.ts.map +1 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.js +265 -0
- package/dist/ir/type-system/internal/type-converter/orchestrator.test.js.map +1 -0
- package/dist/ir/type-system/internal/type-converter/primitives.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/primitives.js +5 -0
- package/dist/ir/type-system/internal/type-converter/primitives.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/references.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/references.js +67 -29
- package/dist/ir/type-system/internal/type-converter/references.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.d.ts.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.js +145 -0
- package/dist/ir/type-system/internal/type-converter/utility-types.js.map +1 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.test.js +91 -1
- package/dist/ir/type-system/internal/type-converter/utility-types.test.js.map +1 -1
- package/dist/ir/type-system/internal/type-registry.d.ts +1 -1
- package/dist/ir/type-system/internal/type-registry.js +7 -7
- package/dist/ir/type-system/internal/type-registry.js.map +1 -1
- package/dist/ir/type-system/internal/universe/alias-table.d.ts +0 -14
- package/dist/ir/type-system/internal/universe/alias-table.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/alias-table.js +0 -17
- package/dist/ir/type-system/internal/universe/alias-table.js.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-catalog.d.ts +3 -0
- package/dist/ir/type-system/internal/universe/clr-catalog.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-catalog.js +4 -1044
- package/dist/ir/type-system/internal/universe/clr-catalog.js.map +1 -1
- package/dist/ir/type-system/internal/universe/clr-entry-converter.d.ts +51 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.js +657 -0
- package/dist/ir/type-system/internal/universe/clr-entry-converter.js.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.d.ts +52 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.d.ts.map +1 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.js +415 -0
- package/dist/ir/type-system/internal/universe/clr-type-parser.js.map +1 -0
- package/dist/ir/type-system/internal/universe/index.d.ts +1 -1
- package/dist/ir/type-system/internal/universe/index.d.ts.map +1 -1
- package/dist/ir/type-system/internal/universe/index.js +1 -3
- package/dist/ir/type-system/internal/universe/index.js.map +1 -1
- package/dist/ir/type-system/internal/universe/unified-universe.test.js +2 -0
- package/dist/ir/type-system/internal/universe/unified-universe.test.js.map +1 -1
- package/dist/ir/type-system/type-system-call-resolution.d.ts +69 -0
- package/dist/ir/type-system/type-system-call-resolution.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-call-resolution.js +1121 -0
- package/dist/ir/type-system/type-system-call-resolution.js.map +1 -0
- package/dist/ir/type-system/type-system-inference.d.ts +98 -0
- package/dist/ir/type-system/type-system-inference.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-inference.js +1083 -0
- package/dist/ir/type-system/type-system-inference.js.map +1 -0
- package/dist/ir/type-system/type-system-relations.d.ts +15 -0
- package/dist/ir/type-system/type-system-relations.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-relations.js +152 -0
- package/dist/ir/type-system/type-system-relations.js.map +1 -0
- package/dist/ir/type-system/type-system-state.d.ts +436 -0
- package/dist/ir/type-system/type-system-state.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-state.js +212 -0
- package/dist/ir/type-system/type-system-state.js.map +1 -0
- package/dist/ir/type-system/type-system-utilities.d.ts +56 -0
- package/dist/ir/type-system/type-system-utilities.d.ts.map +1 -0
- package/dist/ir/type-system/type-system-utilities.js +373 -0
- package/dist/ir/type-system/type-system-utilities.js.map +1 -0
- package/dist/ir/type-system/type-system.d.ts +17 -358
- package/dist/ir/type-system/type-system.d.ts.map +1 -1
- package/dist/ir/type-system/type-system.js +67 -2945
- package/dist/ir/type-system/type-system.js.map +1 -1
- package/dist/ir/types/index.d.ts +1 -0
- package/dist/ir/types/index.d.ts.map +1 -1
- package/dist/ir/types/index.js +1 -0
- package/dist/ir/types/index.js.map +1 -1
- package/dist/ir/types/ir-substitution.js +1 -1
- package/dist/ir/types/ir-substitution.js.map +1 -1
- package/dist/ir/types/statements.d.ts +1 -1
- package/dist/ir/types/type-ops.d.ts +9 -0
- package/dist/ir/types/type-ops.d.ts.map +1 -0
- package/dist/ir/types/type-ops.js +134 -0
- package/dist/ir/types/type-ops.js.map +1 -0
- package/dist/ir/types/type-ops.test.d.ts +2 -0
- package/dist/ir/types/type-ops.test.d.ts.map +1 -0
- package/dist/ir/types/type-ops.test.js +73 -0
- package/dist/ir/types/type-ops.test.js.map +1 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.d.ts +58 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.js +284 -0
- package/dist/ir/validation/attribute-collection/arg-extractor.js.map +1 -0
- package/dist/ir/validation/attribute-collection/marker-parser.d.ts +28 -0
- package/dist/ir/validation/attribute-collection/marker-parser.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/marker-parser.js +404 -0
- package/dist/ir/validation/attribute-collection/marker-parser.js.map +1 -0
- package/dist/ir/validation/attribute-collection/orchestrator.d.ts +28 -0
- package/dist/ir/validation/attribute-collection/orchestrator.d.ts.map +1 -0
- package/dist/ir/validation/attribute-collection/orchestrator.js +332 -0
- package/dist/ir/validation/attribute-collection/orchestrator.js.map +1 -0
- package/dist/ir/validation/attribute-collection-pass.d.ts +1 -23
- package/dist/ir/validation/attribute-collection-pass.d.ts.map +1 -1
- package/dist/ir/validation/attribute-collection-pass.js +1 -961
- package/dist/ir/validation/attribute-collection-pass.js.map +1 -1
- package/dist/ir/validation/attribute-collection-pass.test.js +12 -6
- package/dist/ir/validation/attribute-collection-pass.test.js.map +1 -1
- package/dist/ir/validation/soundness-gate.d.ts.map +1 -1
- package/dist/ir/validation/soundness-gate.js +2 -1
- package/dist/ir/validation/soundness-gate.js.map +1 -1
- package/dist/ir/validation/soundness-gate.test.js +69 -0
- package/dist/ir/validation/soundness-gate.test.js.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.d.ts +11 -5
- package/dist/ir/validation/yield-lowering-pass.d.ts.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.js +942 -48
- package/dist/ir/validation/yield-lowering-pass.js.map +1 -1
- package/dist/ir/validation/yield-lowering-pass.test.js +1333 -127
- package/dist/ir/validation/yield-lowering-pass.test.js.map +1 -1
- package/dist/program/binding-loader.d.ts +37 -0
- package/dist/program/binding-loader.d.ts.map +1 -0
- package/dist/program/binding-loader.js +155 -0
- package/dist/program/binding-loader.js.map +1 -0
- package/dist/program/binding-registry.d.ts +106 -0
- package/dist/program/binding-registry.d.ts.map +1 -0
- package/dist/program/binding-registry.js +590 -0
- package/dist/program/binding-registry.js.map +1 -0
- package/dist/program/binding-types.d.ts +166 -0
- package/dist/program/binding-types.d.ts.map +1 -0
- package/dist/program/binding-types.js +57 -0
- package/dist/program/binding-types.js.map +1 -0
- package/dist/program/bindings.d.ts +6 -271
- package/dist/program/bindings.d.ts.map +1 -1
- package/dist/program/bindings.js +7 -781
- package/dist/program/bindings.js.map +1 -1
- package/dist/resolver/clr-bindings-resolver.d.ts +0 -1
- package/dist/resolver/clr-bindings-resolver.d.ts.map +1 -1
- package/dist/resolver/clr-bindings-resolver.js +22 -32
- package/dist/resolver/clr-bindings-resolver.js.map +1 -1
- package/dist/resolver/clr-bindings-resolver.test.js +0 -27
- package/dist/resolver/clr-bindings-resolver.test.js.map +1 -1
- package/dist/resolver/import-resolution.d.ts +1 -1
- package/dist/resolver/import-resolution.d.ts.map +1 -1
- package/dist/resolver/import-resolution.js +2 -7
- package/dist/resolver/import-resolution.js.map +1 -1
- package/dist/resolver/naming.d.ts.map +1 -1
- package/dist/resolver/naming.js +1 -0
- package/dist/resolver/naming.js.map +1 -1
- package/dist/types/diagnostic.d.ts +1 -1
- package/dist/types/diagnostic.d.ts.map +1 -1
- package/dist/types/diagnostic.js.map +1 -1
- package/dist/validation/features.d.ts.map +1 -1
- package/dist/validation/features.js +38 -13
- package/dist/validation/features.js.map +1 -1
- package/dist/validation/features.test.d.ts +2 -0
- package/dist/validation/features.test.d.ts.map +1 -0
- package/dist/validation/features.test.js +273 -0
- package/dist/validation/features.test.js.map +1 -0
- package/dist/validation/generics.d.ts +1 -1
- package/dist/validation/generics.d.ts.map +1 -1
- package/dist/validation/generics.js +2 -26
- package/dist/validation/generics.js.map +1 -1
- package/dist/validation/imports.d.ts.map +1 -1
- package/dist/validation/imports.js +2 -1
- package/dist/validation/imports.js.map +1 -1
- package/dist/validation/imports.test.d.ts +2 -0
- package/dist/validation/imports.test.d.ts.map +1 -0
- package/dist/validation/imports.test.js +112 -0
- package/dist/validation/imports.test.js.map +1 -0
- package/dist/validation/static-safety.d.ts +6 -6
- package/dist/validation/static-safety.d.ts.map +1 -1
- package/dist/validation/static-safety.js +163 -109
- package/dist/validation/static-safety.js.map +1 -1
- package/dist/validation/unsupported-utility-types.d.ts +3 -3
- package/dist/validation/unsupported-utility-types.d.ts.map +1 -1
- package/dist/validation/unsupported-utility-types.js +4 -7
- package/dist/validation/unsupported-utility-types.js.map +1 -1
- package/dist/validator.maximus.test.d.ts +2 -0
- package/dist/validator.maximus.test.d.ts.map +1 -0
- package/dist/validator.maximus.test.js +1214 -0
- package/dist/validator.maximus.test.js.map +1 -0
- package/dist/validator.test.js +152 -18
- package/dist/validator.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/ir/converters/statements/declarations/registry.d.ts +0 -96
- package/dist/ir/converters/statements/declarations/registry.d.ts.map +0 -1
- package/dist/ir/converters/statements/declarations/registry.js +0 -130
- package/dist/ir/converters/statements/declarations/registry.js.map +0 -1
- package/dist/ir/this-parameter-inference.test.d.ts +0 -13
- package/dist/ir/this-parameter-inference.test.d.ts.map +0 -1
- package/dist/ir/this-parameter-inference.test.js +0 -165
- package/dist/ir/this-parameter-inference.test.js.map +0 -1
- package/dist/metadata/bindings-loader.d.ts +0 -41
- package/dist/metadata/bindings-loader.d.ts.map +0 -1
- package/dist/metadata/bindings-loader.js +0 -308
- package/dist/metadata/bindings-loader.js.map +0 -1
- package/dist/metadata/bindings-loader.test.d.ts +0 -5
- package/dist/metadata/bindings-loader.test.d.ts.map +0 -1
- package/dist/metadata/bindings-loader.test.js +0 -117
- package/dist/metadata/bindings-loader.test.js.map +0 -1
- package/dist/metadata/index.d.ts +0 -8
- package/dist/metadata/index.d.ts.map +0 -1
- package/dist/metadata/index.js +0 -7
- package/dist/metadata/index.js.map +0 -1
- package/dist/metadata/library-loader.d.ts +0 -42
- package/dist/metadata/library-loader.d.ts.map +0 -1
- package/dist/metadata/library-loader.js +0 -126
- package/dist/metadata/library-loader.js.map +0 -1
- package/dist/metadata/loader.d.ts +0 -26
- package/dist/metadata/loader.d.ts.map +0 -1
- package/dist/metadata/loader.js +0 -333
- package/dist/metadata/loader.js.map +0 -1
- package/dist/metadata/loader.test.d.ts +0 -5
- package/dist/metadata/loader.test.d.ts.map +0 -1
- package/dist/metadata/loader.test.js +0 -119
- package/dist/metadata/loader.test.js.map +0 -1
- package/dist/resolver/naming-policy.d.ts +0 -20
- package/dist/resolver/naming-policy.d.ts.map +0 -1
- package/dist/resolver/naming-policy.js +0 -40
- package/dist/resolver/naming-policy.js.map +0 -1
- package/dist/types/bindings.d.ts +0 -153
- package/dist/types/bindings.d.ts.map +0 -1
- package/dist/types/bindings.js +0 -14
- package/dist/types/bindings.js.map +0 -1
- package/dist/types/metadata.d.ts +0 -196
- package/dist/types/metadata.d.ts.map +0 -1
- package/dist/types/metadata.js +0 -10
- package/dist/types/metadata.js.map +0 -1
- package/dist/types/nested-types.d.ts +0 -111
- package/dist/types/nested-types.d.ts.map +0 -1
- package/dist/types/nested-types.js +0 -176
- package/dist/types/nested-types.js.map +0 -1
- package/dist/types/nested-types.test.d.ts +0 -5
- package/dist/types/nested-types.test.d.ts.map +0 -1
- package/dist/types/nested-types.test.js +0 -135
- package/dist/types/nested-types.test.js.map +0 -1
- package/dist/types/ref-parameters.d.ts +0 -123
- package/dist/types/ref-parameters.d.ts.map +0 -1
- package/dist/types/ref-parameters.js +0 -203
- package/dist/types/ref-parameters.js.map +0 -1
- package/dist/types/ref-parameters.test.d.ts +0 -5
- package/dist/types/ref-parameters.test.d.ts.map +0 -1
- package/dist/types/ref-parameters.test.js +0 -147
- package/dist/types/ref-parameters.test.js.map +0 -1
|
@@ -10,13 +10,19 @@
|
|
|
10
10
|
* - `x = yield expr;` → IrYieldStatement with receiveTarget = identifierPattern
|
|
11
11
|
* - `const {a, b} = yield expr;` → IrYieldStatement with receiveTarget = objectPattern
|
|
12
12
|
* - `const [a, b] = yield expr;` → IrYieldStatement with receiveTarget = arrayPattern
|
|
13
|
+
* - `return yield expr;` → IrYieldStatement + IrGeneratorReturnStatement(temp)
|
|
14
|
+
* - `throw yield expr;` → IrYieldStatement + IrThrowStatement(temp)
|
|
15
|
+
* - `for (x = yield expr; ... )` → IrYieldStatement + ForStatement(without initializer)
|
|
16
|
+
* - `for (; yield cond; ... )` → ForStatement(condition=true) + loop-body condition prelude
|
|
17
|
+
* - `for (...; ...; yield update)` → ForStatement(update=undefined) + loop-body update prelude
|
|
18
|
+
* - `for (... of yield expr)` / `for (... in yield expr)` → IrYieldStatement + loop over temp
|
|
19
|
+
* - `if (yield expr) { ... }` → IrYieldStatement + IfStatement(temp)
|
|
20
|
+
* - `switch (yield expr) { ... }` → IrYieldStatement + SwitchStatement(temp)
|
|
21
|
+
* - `while (yield expr) { ... }` → While(true) with per-iteration yield+guard
|
|
22
|
+
* - `const x = cond ? (yield a) : (yield b)` → temp + branch-lowered yields
|
|
13
23
|
*
|
|
14
24
|
* Unsupported patterns (emit TSN6101 diagnostic):
|
|
15
|
-
* -
|
|
16
|
-
* - `yield x + yield y` - multiple yields in expression
|
|
17
|
-
* - `[yield x, 1]` - yield in array literal
|
|
18
|
-
* - `{a: yield x}` - yield in object literal
|
|
19
|
-
* - `cond ? yield a : b` - yield in ternary
|
|
25
|
+
* - assignment target forms that cannot be lowered as a deterministic l-value
|
|
20
26
|
*/
|
|
21
27
|
import { createDiagnostic, } from "../../types/diagnostic.js";
|
|
22
28
|
/**
|
|
@@ -142,6 +148,17 @@ const createYieldStatement = (yieldExpr, receiveTarget, receivedType) => ({
|
|
|
142
148
|
receiveTarget,
|
|
143
149
|
receivedType,
|
|
144
150
|
});
|
|
151
|
+
const toReceivePattern = (target) => {
|
|
152
|
+
if (target.kind === "identifierPattern" ||
|
|
153
|
+
target.kind === "arrayPattern" ||
|
|
154
|
+
target.kind === "objectPattern") {
|
|
155
|
+
return target;
|
|
156
|
+
}
|
|
157
|
+
if (target.kind === "identifier") {
|
|
158
|
+
return { kind: "identifierPattern", name: target.name };
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
};
|
|
145
162
|
/**
|
|
146
163
|
* Create an IrGeneratorReturnStatement from a return statement's expression.
|
|
147
164
|
* This captures the return value for generators with TReturn.
|
|
@@ -156,6 +173,425 @@ const createGeneratorReturnStatement = (expression) => ({
|
|
|
156
173
|
const emitUnsupportedYieldDiagnostic = (ctx, position, location) => {
|
|
157
174
|
ctx.diagnostics.push(createDiagnostic("TSN6101", "error", `Yield expression in ${position} is not supported`, location ?? moduleLocation(ctx), "Extract yield to a separate statement: `const result = yield expr; use(result);`"));
|
|
158
175
|
};
|
|
176
|
+
const allocateYieldTempName = (ctx) => {
|
|
177
|
+
ctx.yieldTempCounter += 1;
|
|
178
|
+
return `__tsonic_yield_${ctx.yieldTempCounter}`;
|
|
179
|
+
};
|
|
180
|
+
const createTempVariableDeclaration = (name, initializer, inferredType) => ({
|
|
181
|
+
kind: "variableDeclaration",
|
|
182
|
+
declarationKind: "const",
|
|
183
|
+
isExported: false,
|
|
184
|
+
declarations: [
|
|
185
|
+
{
|
|
186
|
+
kind: "variableDeclarator",
|
|
187
|
+
name: { kind: "identifierPattern", name },
|
|
188
|
+
type: inferredType,
|
|
189
|
+
initializer,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
});
|
|
193
|
+
const lowerMemberAccessAssignmentWithYields = (assignment, ctx, positionLabels) => {
|
|
194
|
+
if (assignment.left.kind !== "memberAccess") {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
const loweredObject = lowerExpressionWithYields(assignment.left.object, ctx, positionLabels.object, assignment.left.object.inferredType);
|
|
198
|
+
if (!loweredObject) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
const leadingStatements = [...loweredObject.prelude];
|
|
202
|
+
const objectTempName = allocateYieldTempName(ctx);
|
|
203
|
+
leadingStatements.push(createTempVariableDeclaration(objectTempName, loweredObject.expression, loweredObject.expression.inferredType));
|
|
204
|
+
let loweredProperty = assignment.left.property;
|
|
205
|
+
if (typeof assignment.left.property !== "string") {
|
|
206
|
+
const loweredPropertyExpr = lowerExpressionWithYields(assignment.left.property, ctx, positionLabels.property, assignment.left.property.inferredType);
|
|
207
|
+
if (!loweredPropertyExpr) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
leadingStatements.push(...loweredPropertyExpr.prelude);
|
|
211
|
+
const propertyTempName = allocateYieldTempName(ctx);
|
|
212
|
+
leadingStatements.push(createTempVariableDeclaration(propertyTempName, loweredPropertyExpr.expression, loweredPropertyExpr.expression.inferredType));
|
|
213
|
+
loweredProperty = { kind: "identifier", name: propertyTempName };
|
|
214
|
+
}
|
|
215
|
+
let loweredRight = assignment.right;
|
|
216
|
+
if (assignment.right.kind === "yield" && !assignment.right.delegate) {
|
|
217
|
+
const receiveTempName = allocateYieldTempName(ctx);
|
|
218
|
+
leadingStatements.push(createYieldStatement(assignment.right, { kind: "identifierPattern", name: receiveTempName }, assignment.right.inferredType));
|
|
219
|
+
loweredRight = { kind: "identifier", name: receiveTempName };
|
|
220
|
+
}
|
|
221
|
+
else if (containsYield(assignment.right)) {
|
|
222
|
+
const loweredRightExpr = lowerExpressionWithYields(assignment.right, ctx, positionLabels.right, assignment.right.inferredType);
|
|
223
|
+
if (!loweredRightExpr) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
leadingStatements.push(...loweredRightExpr.prelude);
|
|
227
|
+
loweredRight = loweredRightExpr.expression;
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
leadingStatements,
|
|
231
|
+
loweredAssignment: {
|
|
232
|
+
...assignment,
|
|
233
|
+
left: {
|
|
234
|
+
...assignment.left,
|
|
235
|
+
object: { kind: "identifier", name: objectTempName },
|
|
236
|
+
property: loweredProperty,
|
|
237
|
+
},
|
|
238
|
+
right: loweredRight,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Lower yield expressions that appear inside larger expression trees into
|
|
244
|
+
* leading IrYieldStatement nodes plus a rewritten expression that references
|
|
245
|
+
* temp identifiers.
|
|
246
|
+
*
|
|
247
|
+
* This preserves left-to-right evaluation order for supported expression forms.
|
|
248
|
+
* Unsupported forms emit TSN6101 and return undefined.
|
|
249
|
+
*/
|
|
250
|
+
const lowerExpressionWithYields = (expression, ctx, position, expectedType) => {
|
|
251
|
+
const lower = (expr) => {
|
|
252
|
+
if (!containsYield(expr)) {
|
|
253
|
+
return { prelude: [], expression: expr };
|
|
254
|
+
}
|
|
255
|
+
switch (expr.kind) {
|
|
256
|
+
case "yield": {
|
|
257
|
+
const tempName = allocateYieldTempName(ctx);
|
|
258
|
+
return {
|
|
259
|
+
prelude: [
|
|
260
|
+
createYieldStatement(expr, { kind: "identifierPattern", name: tempName }, expr.inferredType),
|
|
261
|
+
],
|
|
262
|
+
expression: { kind: "identifier", name: tempName },
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
case "unary":
|
|
266
|
+
case "update":
|
|
267
|
+
case "await":
|
|
268
|
+
case "spread":
|
|
269
|
+
case "numericNarrowing":
|
|
270
|
+
case "typeAssertion":
|
|
271
|
+
case "asinterface":
|
|
272
|
+
case "trycast": {
|
|
273
|
+
const lowered = lower(expr.expression);
|
|
274
|
+
if (!lowered)
|
|
275
|
+
return undefined;
|
|
276
|
+
return {
|
|
277
|
+
prelude: lowered.prelude,
|
|
278
|
+
expression: {
|
|
279
|
+
...expr,
|
|
280
|
+
expression: lowered.expression,
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
case "stackalloc": {
|
|
285
|
+
const loweredSize = lower(expr.size);
|
|
286
|
+
if (!loweredSize)
|
|
287
|
+
return undefined;
|
|
288
|
+
return {
|
|
289
|
+
prelude: loweredSize.prelude,
|
|
290
|
+
expression: {
|
|
291
|
+
...expr,
|
|
292
|
+
size: loweredSize.expression,
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
case "binary":
|
|
297
|
+
case "logical": {
|
|
298
|
+
const loweredLeft = lower(expr.left);
|
|
299
|
+
if (!loweredLeft)
|
|
300
|
+
return undefined;
|
|
301
|
+
const loweredRight = lower(expr.right);
|
|
302
|
+
if (!loweredRight)
|
|
303
|
+
return undefined;
|
|
304
|
+
return {
|
|
305
|
+
prelude: [...loweredLeft.prelude, ...loweredRight.prelude],
|
|
306
|
+
expression: {
|
|
307
|
+
...expr,
|
|
308
|
+
left: loweredLeft.expression,
|
|
309
|
+
right: loweredRight.expression,
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
case "assignment": {
|
|
314
|
+
if (expr.left.kind !== "identifierPattern" &&
|
|
315
|
+
expr.left.kind !== "arrayPattern" &&
|
|
316
|
+
expr.left.kind !== "objectPattern" &&
|
|
317
|
+
containsYield(expr.left)) {
|
|
318
|
+
if (expr.left.kind !== "memberAccess") {
|
|
319
|
+
emitUnsupportedYieldDiagnostic(ctx, `${position} assignment target`);
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
const loweredObject = lower(expr.left.object);
|
|
323
|
+
if (!loweredObject)
|
|
324
|
+
return undefined;
|
|
325
|
+
let loweredProperty = expr.left.property;
|
|
326
|
+
let propertyPrelude = [];
|
|
327
|
+
if (typeof expr.left.property !== "string") {
|
|
328
|
+
const loweredPropertyExpr = lower(expr.left.property);
|
|
329
|
+
if (!loweredPropertyExpr)
|
|
330
|
+
return undefined;
|
|
331
|
+
loweredProperty = loweredPropertyExpr.expression;
|
|
332
|
+
propertyPrelude = loweredPropertyExpr.prelude;
|
|
333
|
+
}
|
|
334
|
+
const loweredRight = lower(expr.right);
|
|
335
|
+
if (!loweredRight)
|
|
336
|
+
return undefined;
|
|
337
|
+
return {
|
|
338
|
+
prelude: [
|
|
339
|
+
...loweredObject.prelude,
|
|
340
|
+
...propertyPrelude,
|
|
341
|
+
...loweredRight.prelude,
|
|
342
|
+
],
|
|
343
|
+
expression: {
|
|
344
|
+
...expr,
|
|
345
|
+
left: {
|
|
346
|
+
...expr.left,
|
|
347
|
+
object: loweredObject.expression,
|
|
348
|
+
property: loweredProperty,
|
|
349
|
+
},
|
|
350
|
+
right: loweredRight.expression,
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
const loweredRight = lower(expr.right);
|
|
355
|
+
if (!loweredRight)
|
|
356
|
+
return undefined;
|
|
357
|
+
return {
|
|
358
|
+
prelude: loweredRight.prelude,
|
|
359
|
+
expression: {
|
|
360
|
+
...expr,
|
|
361
|
+
right: loweredRight.expression,
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
case "memberAccess": {
|
|
366
|
+
const loweredObject = lower(expr.object);
|
|
367
|
+
if (!loweredObject)
|
|
368
|
+
return undefined;
|
|
369
|
+
let loweredProperty = expr.property;
|
|
370
|
+
let propertyPrelude = [];
|
|
371
|
+
if (typeof expr.property !== "string") {
|
|
372
|
+
const loweredPropExpr = lower(expr.property);
|
|
373
|
+
if (!loweredPropExpr)
|
|
374
|
+
return undefined;
|
|
375
|
+
loweredProperty = loweredPropExpr.expression;
|
|
376
|
+
propertyPrelude = loweredPropExpr.prelude;
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
prelude: [...loweredObject.prelude, ...propertyPrelude],
|
|
380
|
+
expression: {
|
|
381
|
+
...expr,
|
|
382
|
+
object: loweredObject.expression,
|
|
383
|
+
property: loweredProperty,
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
case "call":
|
|
388
|
+
case "new": {
|
|
389
|
+
const loweredCallee = lower(expr.callee);
|
|
390
|
+
if (!loweredCallee)
|
|
391
|
+
return undefined;
|
|
392
|
+
const preludes = [...loweredCallee.prelude];
|
|
393
|
+
const loweredArgs = [];
|
|
394
|
+
for (const argument of expr.arguments) {
|
|
395
|
+
if (argument.kind === "spread") {
|
|
396
|
+
const loweredSpreadExpr = lower(argument.expression);
|
|
397
|
+
if (!loweredSpreadExpr)
|
|
398
|
+
return undefined;
|
|
399
|
+
preludes.push(...loweredSpreadExpr.prelude);
|
|
400
|
+
loweredArgs.push({
|
|
401
|
+
kind: "spread",
|
|
402
|
+
expression: loweredSpreadExpr.expression,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
const loweredArg = lower(argument);
|
|
407
|
+
if (!loweredArg)
|
|
408
|
+
return undefined;
|
|
409
|
+
preludes.push(...loweredArg.prelude);
|
|
410
|
+
loweredArgs.push(loweredArg.expression);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
prelude: preludes,
|
|
415
|
+
expression: {
|
|
416
|
+
...expr,
|
|
417
|
+
callee: loweredCallee.expression,
|
|
418
|
+
arguments: loweredArgs,
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
case "array": {
|
|
423
|
+
const preludes = [];
|
|
424
|
+
const loweredElements = [];
|
|
425
|
+
for (const element of expr.elements) {
|
|
426
|
+
if (!element) {
|
|
427
|
+
loweredElements.push(undefined);
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if (element.kind === "spread") {
|
|
431
|
+
const loweredSpreadExpr = lower(element.expression);
|
|
432
|
+
if (!loweredSpreadExpr)
|
|
433
|
+
return undefined;
|
|
434
|
+
preludes.push(...loweredSpreadExpr.prelude);
|
|
435
|
+
loweredElements.push({
|
|
436
|
+
kind: "spread",
|
|
437
|
+
expression: loweredSpreadExpr.expression,
|
|
438
|
+
});
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const loweredElement = lower(element);
|
|
442
|
+
if (!loweredElement)
|
|
443
|
+
return undefined;
|
|
444
|
+
preludes.push(...loweredElement.prelude);
|
|
445
|
+
loweredElements.push(loweredElement.expression);
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
prelude: preludes,
|
|
449
|
+
expression: {
|
|
450
|
+
...expr,
|
|
451
|
+
elements: loweredElements,
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
case "object": {
|
|
456
|
+
const preludes = [];
|
|
457
|
+
const loweredProperties = [];
|
|
458
|
+
for (const property of expr.properties) {
|
|
459
|
+
if (property.kind === "spread") {
|
|
460
|
+
const loweredSpreadExpr = lower(property.expression);
|
|
461
|
+
if (!loweredSpreadExpr)
|
|
462
|
+
return undefined;
|
|
463
|
+
preludes.push(...loweredSpreadExpr.prelude);
|
|
464
|
+
loweredProperties.push({
|
|
465
|
+
kind: "spread",
|
|
466
|
+
expression: loweredSpreadExpr.expression,
|
|
467
|
+
});
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
let loweredKey = property.key;
|
|
471
|
+
if (typeof property.key !== "string") {
|
|
472
|
+
const loweredKeyExpr = lower(property.key);
|
|
473
|
+
if (!loweredKeyExpr)
|
|
474
|
+
return undefined;
|
|
475
|
+
preludes.push(...loweredKeyExpr.prelude);
|
|
476
|
+
loweredKey = loweredKeyExpr.expression;
|
|
477
|
+
}
|
|
478
|
+
const loweredValue = lower(property.value);
|
|
479
|
+
if (!loweredValue)
|
|
480
|
+
return undefined;
|
|
481
|
+
preludes.push(...loweredValue.prelude);
|
|
482
|
+
loweredProperties.push({
|
|
483
|
+
kind: "property",
|
|
484
|
+
key: loweredKey,
|
|
485
|
+
value: loweredValue.expression,
|
|
486
|
+
shorthand: property.shorthand,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
prelude: preludes,
|
|
491
|
+
expression: {
|
|
492
|
+
...expr,
|
|
493
|
+
properties: loweredProperties,
|
|
494
|
+
},
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
case "templateLiteral": {
|
|
498
|
+
const preludes = [];
|
|
499
|
+
const loweredExpressions = [];
|
|
500
|
+
for (const templateExpr of expr.expressions) {
|
|
501
|
+
const loweredTemplateExpr = lower(templateExpr);
|
|
502
|
+
if (!loweredTemplateExpr)
|
|
503
|
+
return undefined;
|
|
504
|
+
preludes.push(...loweredTemplateExpr.prelude);
|
|
505
|
+
loweredExpressions.push(loweredTemplateExpr.expression);
|
|
506
|
+
}
|
|
507
|
+
return {
|
|
508
|
+
prelude: preludes,
|
|
509
|
+
expression: {
|
|
510
|
+
...expr,
|
|
511
|
+
expressions: loweredExpressions,
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
case "conditional": {
|
|
516
|
+
const loweredCondition = lower(expr.condition);
|
|
517
|
+
if (!loweredCondition)
|
|
518
|
+
return undefined;
|
|
519
|
+
const loweredWhenTrue = lower(expr.whenTrue);
|
|
520
|
+
if (!loweredWhenTrue)
|
|
521
|
+
return undefined;
|
|
522
|
+
const loweredWhenFalse = lower(expr.whenFalse);
|
|
523
|
+
if (!loweredWhenFalse)
|
|
524
|
+
return undefined;
|
|
525
|
+
const tempType = expr.inferredType ??
|
|
526
|
+
expectedType ??
|
|
527
|
+
loweredWhenTrue.expression.inferredType ??
|
|
528
|
+
loweredWhenFalse.expression.inferredType;
|
|
529
|
+
if (!tempType) {
|
|
530
|
+
emitUnsupportedYieldDiagnostic(ctx, `${position} conditional expression`, expr.sourceSpan);
|
|
531
|
+
return undefined;
|
|
532
|
+
}
|
|
533
|
+
const tempName = allocateYieldTempName(ctx);
|
|
534
|
+
const tempPattern = {
|
|
535
|
+
kind: "identifierPattern",
|
|
536
|
+
name: tempName,
|
|
537
|
+
};
|
|
538
|
+
const assignTrueStatement = {
|
|
539
|
+
kind: "expressionStatement",
|
|
540
|
+
expression: {
|
|
541
|
+
kind: "assignment",
|
|
542
|
+
operator: "=",
|
|
543
|
+
left: tempPattern,
|
|
544
|
+
right: loweredWhenTrue.expression,
|
|
545
|
+
},
|
|
546
|
+
};
|
|
547
|
+
const assignFalseStatement = {
|
|
548
|
+
kind: "expressionStatement",
|
|
549
|
+
expression: {
|
|
550
|
+
kind: "assignment",
|
|
551
|
+
operator: "=",
|
|
552
|
+
left: tempPattern,
|
|
553
|
+
right: loweredWhenFalse.expression,
|
|
554
|
+
},
|
|
555
|
+
};
|
|
556
|
+
return {
|
|
557
|
+
prelude: [
|
|
558
|
+
...loweredCondition.prelude,
|
|
559
|
+
{
|
|
560
|
+
kind: "variableDeclaration",
|
|
561
|
+
declarationKind: "let",
|
|
562
|
+
isExported: false,
|
|
563
|
+
declarations: [
|
|
564
|
+
{
|
|
565
|
+
kind: "variableDeclarator",
|
|
566
|
+
name: tempPattern,
|
|
567
|
+
type: tempType,
|
|
568
|
+
initializer: { kind: "literal", value: undefined },
|
|
569
|
+
},
|
|
570
|
+
],
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
kind: "ifStatement",
|
|
574
|
+
condition: loweredCondition.expression,
|
|
575
|
+
thenStatement: {
|
|
576
|
+
kind: "blockStatement",
|
|
577
|
+
statements: [...loweredWhenTrue.prelude, assignTrueStatement],
|
|
578
|
+
},
|
|
579
|
+
elseStatement: {
|
|
580
|
+
kind: "blockStatement",
|
|
581
|
+
statements: [...loweredWhenFalse.prelude, assignFalseStatement],
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
],
|
|
585
|
+
expression: { kind: "identifier", name: tempName },
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
default:
|
|
589
|
+
emitUnsupportedYieldDiagnostic(ctx, position, expr.sourceSpan);
|
|
590
|
+
return undefined;
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
return lower(expression);
|
|
594
|
+
};
|
|
159
595
|
/**
|
|
160
596
|
* Process a statement in a generator function body.
|
|
161
597
|
* Returns the transformed statement(s) - may return multiple statements
|
|
@@ -174,28 +610,116 @@ const processStatement = (stmt, ctx) => {
|
|
|
174
610
|
return createYieldStatement(expr, undefined, undefined);
|
|
175
611
|
}
|
|
176
612
|
// Pattern 3: x = yield expr; (assignment with yield on right)
|
|
177
|
-
if (expr.kind === "assignment"
|
|
178
|
-
expr.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
613
|
+
if (expr.kind === "assignment") {
|
|
614
|
+
if (expr.operator === "=" &&
|
|
615
|
+
expr.left.kind === "memberAccess" &&
|
|
616
|
+
((expr.right.kind === "yield" && !expr.right.delegate) ||
|
|
617
|
+
containsYield(expr.left))) {
|
|
618
|
+
const loweredMemberAssignment = lowerMemberAccessAssignmentWithYields(expr, ctx, {
|
|
619
|
+
object: "assignment target object",
|
|
620
|
+
property: "assignment target property",
|
|
621
|
+
right: "assignment value",
|
|
622
|
+
});
|
|
623
|
+
if (!loweredMemberAssignment) {
|
|
624
|
+
return stmt;
|
|
625
|
+
}
|
|
626
|
+
return [
|
|
627
|
+
...loweredMemberAssignment.leadingStatements,
|
|
628
|
+
{
|
|
629
|
+
kind: "expressionStatement",
|
|
630
|
+
expression: loweredMemberAssignment.loweredAssignment,
|
|
631
|
+
},
|
|
632
|
+
];
|
|
184
633
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
634
|
+
if (expr.right.kind === "yield" && !expr.right.delegate) {
|
|
635
|
+
// Compound assignment (x += yield y) needs a temporary receive target,
|
|
636
|
+
// then an explicit compound update statement.
|
|
637
|
+
if (expr.operator !== "=") {
|
|
638
|
+
if (expr.left.kind !== "identifierPattern" &&
|
|
639
|
+
expr.left.kind !== "identifier" &&
|
|
640
|
+
expr.left.kind !== "memberAccess") {
|
|
641
|
+
emitUnsupportedYieldDiagnostic(ctx, "compound assignment to complex target", expr.right.sourceSpan);
|
|
642
|
+
return stmt;
|
|
643
|
+
}
|
|
644
|
+
if (expr.left.kind === "identifierPattern" ||
|
|
645
|
+
expr.left.kind === "identifier") {
|
|
646
|
+
const tempName = allocateYieldTempName(ctx);
|
|
647
|
+
const leftExpr = expr.left.kind === "identifierPattern"
|
|
648
|
+
? { kind: "identifier", name: expr.left.name }
|
|
649
|
+
: expr.left;
|
|
650
|
+
return [
|
|
651
|
+
createYieldStatement(expr.right, { kind: "identifierPattern", name: tempName }, expr.right.inferredType),
|
|
652
|
+
{
|
|
653
|
+
kind: "expressionStatement",
|
|
654
|
+
expression: {
|
|
655
|
+
...expr,
|
|
656
|
+
left: leftExpr,
|
|
657
|
+
right: { kind: "identifier", name: tempName },
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
];
|
|
661
|
+
}
|
|
662
|
+
const loweredObject = lowerExpressionWithYields(expr.left.object, ctx, "compound assignment target object", expr.left.object.inferredType);
|
|
663
|
+
if (!loweredObject) {
|
|
664
|
+
return stmt;
|
|
665
|
+
}
|
|
666
|
+
const objectTempName = allocateYieldTempName(ctx);
|
|
667
|
+
const leadingStatements = [
|
|
668
|
+
...loweredObject.prelude,
|
|
669
|
+
createTempVariableDeclaration(objectTempName, loweredObject.expression, loweredObject.expression.inferredType),
|
|
670
|
+
];
|
|
671
|
+
let propertyExpr = expr.left.property;
|
|
672
|
+
if (typeof expr.left.property !== "string") {
|
|
673
|
+
const loweredProperty = lowerExpressionWithYields(expr.left.property, ctx, "compound assignment target property", expr.left.property.inferredType);
|
|
674
|
+
if (!loweredProperty) {
|
|
675
|
+
return stmt;
|
|
676
|
+
}
|
|
677
|
+
leadingStatements.push(...loweredProperty.prelude);
|
|
678
|
+
const propertyTempName = allocateYieldTempName(ctx);
|
|
679
|
+
leadingStatements.push(createTempVariableDeclaration(propertyTempName, loweredProperty.expression, loweredProperty.expression.inferredType));
|
|
680
|
+
propertyExpr = { kind: "identifier", name: propertyTempName };
|
|
681
|
+
}
|
|
682
|
+
const receiveTempName = allocateYieldTempName(ctx);
|
|
683
|
+
return [
|
|
684
|
+
...leadingStatements,
|
|
685
|
+
createYieldStatement(expr.right, { kind: "identifierPattern", name: receiveTempName }, expr.right.inferredType),
|
|
686
|
+
{
|
|
687
|
+
kind: "expressionStatement",
|
|
688
|
+
expression: {
|
|
689
|
+
...expr,
|
|
690
|
+
left: {
|
|
691
|
+
...expr.left,
|
|
692
|
+
object: { kind: "identifier", name: objectTempName },
|
|
693
|
+
property: propertyExpr,
|
|
694
|
+
},
|
|
695
|
+
right: { kind: "identifier", name: receiveTempName },
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
];
|
|
699
|
+
}
|
|
700
|
+
// Extract the target pattern
|
|
701
|
+
const receiveTarget = toReceivePattern(expr.left);
|
|
702
|
+
if (receiveTarget) {
|
|
703
|
+
return createYieldStatement(expr.right, receiveTarget, expr.right.inferredType);
|
|
704
|
+
}
|
|
705
|
+
// Assignment to member expression or other LHS - not supported
|
|
706
|
+
emitUnsupportedYieldDiagnostic(ctx, "assignment to complex target", expr.right.sourceSpan);
|
|
707
|
+
return stmt;
|
|
191
708
|
}
|
|
192
|
-
// Assignment to member expression or other LHS - not supported
|
|
193
|
-
emitUnsupportedYieldDiagnostic(ctx, "assignment to complex target", expr.right.sourceSpan);
|
|
194
|
-
return stmt;
|
|
195
709
|
}
|
|
196
710
|
// Check for yield in unsupported positions
|
|
197
711
|
if (containsYield(expr)) {
|
|
198
|
-
|
|
712
|
+
const lowered = lowerExpressionWithYields(expr, ctx, "expression statement");
|
|
713
|
+
if (!lowered) {
|
|
714
|
+
return stmt;
|
|
715
|
+
}
|
|
716
|
+
return [
|
|
717
|
+
...lowered.prelude,
|
|
718
|
+
{
|
|
719
|
+
...stmt,
|
|
720
|
+
expression: lowered.expression,
|
|
721
|
+
},
|
|
722
|
+
];
|
|
199
723
|
}
|
|
200
724
|
return stmt;
|
|
201
725
|
}
|
|
@@ -219,12 +743,26 @@ const processStatement = (stmt, ctx) => {
|
|
|
219
743
|
transformedDeclarations.push(createYieldStatement(decl.initializer, decl.name, decl.type ?? decl.initializer.inferredType));
|
|
220
744
|
}
|
|
221
745
|
else if (decl.initializer && containsYield(decl.initializer)) {
|
|
222
|
-
|
|
223
|
-
|
|
746
|
+
const lowered = lowerExpressionWithYields(decl.initializer, ctx, "variable initializer", decl.type ?? decl.initializer.inferredType);
|
|
747
|
+
if (!lowered) {
|
|
748
|
+
transformedDeclarations.push({
|
|
749
|
+
kind: "variableDeclaration",
|
|
750
|
+
declarationKind: stmt.declarationKind,
|
|
751
|
+
declarations: [decl],
|
|
752
|
+
isExported: false,
|
|
753
|
+
});
|
|
754
|
+
continue;
|
|
755
|
+
}
|
|
756
|
+
transformedDeclarations.push(...lowered.prelude);
|
|
224
757
|
transformedDeclarations.push({
|
|
225
758
|
kind: "variableDeclaration",
|
|
226
759
|
declarationKind: stmt.declarationKind,
|
|
227
|
-
declarations: [
|
|
760
|
+
declarations: [
|
|
761
|
+
{
|
|
762
|
+
...decl,
|
|
763
|
+
initializer: lowered.expression,
|
|
764
|
+
},
|
|
765
|
+
],
|
|
228
766
|
isExported: false,
|
|
229
767
|
});
|
|
230
768
|
}
|
|
@@ -254,6 +792,29 @@ const processStatement = (stmt, ctx) => {
|
|
|
254
792
|
}),
|
|
255
793
|
};
|
|
256
794
|
case "ifStatement":
|
|
795
|
+
if (containsYield(stmt.condition)) {
|
|
796
|
+
const loweredCondition = lowerExpressionWithYields(stmt.condition, ctx, "if condition");
|
|
797
|
+
if (!loweredCondition) {
|
|
798
|
+
return {
|
|
799
|
+
...stmt,
|
|
800
|
+
thenStatement: flattenStatement(processStatement(stmt.thenStatement, ctx)),
|
|
801
|
+
elseStatement: stmt.elseStatement
|
|
802
|
+
? flattenStatement(processStatement(stmt.elseStatement, ctx))
|
|
803
|
+
: undefined,
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
return [
|
|
807
|
+
...loweredCondition.prelude,
|
|
808
|
+
{
|
|
809
|
+
...stmt,
|
|
810
|
+
condition: loweredCondition.expression,
|
|
811
|
+
thenStatement: flattenStatement(processStatement(stmt.thenStatement, ctx)),
|
|
812
|
+
elseStatement: stmt.elseStatement
|
|
813
|
+
? flattenStatement(processStatement(stmt.elseStatement, ctx))
|
|
814
|
+
: undefined,
|
|
815
|
+
},
|
|
816
|
+
];
|
|
817
|
+
}
|
|
257
818
|
return {
|
|
258
819
|
...stmt,
|
|
259
820
|
thenStatement: flattenStatement(processStatement(stmt.thenStatement, ctx)),
|
|
@@ -262,40 +823,310 @@ const processStatement = (stmt, ctx) => {
|
|
|
262
823
|
: undefined,
|
|
263
824
|
};
|
|
264
825
|
case "whileStatement":
|
|
826
|
+
if (containsYield(stmt.condition)) {
|
|
827
|
+
const loweredCondition = lowerExpressionWithYields(stmt.condition, ctx, "while condition");
|
|
828
|
+
if (!loweredCondition) {
|
|
829
|
+
return {
|
|
830
|
+
...stmt,
|
|
831
|
+
body: flattenStatement(processStatement(stmt.body, ctx)),
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
const transformedBody = flattenStatement(processStatement(stmt.body, ctx));
|
|
835
|
+
const bodyStatements = [
|
|
836
|
+
...loweredCondition.prelude,
|
|
837
|
+
{
|
|
838
|
+
kind: "ifStatement",
|
|
839
|
+
condition: {
|
|
840
|
+
kind: "unary",
|
|
841
|
+
operator: "!",
|
|
842
|
+
expression: loweredCondition.expression,
|
|
843
|
+
},
|
|
844
|
+
thenStatement: { kind: "breakStatement" },
|
|
845
|
+
},
|
|
846
|
+
];
|
|
847
|
+
if (transformedBody.kind === "blockStatement") {
|
|
848
|
+
bodyStatements.push(...transformedBody.statements);
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
bodyStatements.push(transformedBody);
|
|
852
|
+
}
|
|
853
|
+
return {
|
|
854
|
+
kind: "whileStatement",
|
|
855
|
+
condition: { kind: "literal", value: true },
|
|
856
|
+
body: {
|
|
857
|
+
kind: "blockStatement",
|
|
858
|
+
statements: bodyStatements,
|
|
859
|
+
},
|
|
860
|
+
};
|
|
861
|
+
}
|
|
265
862
|
return {
|
|
266
863
|
...stmt,
|
|
267
864
|
body: flattenStatement(processStatement(stmt.body, ctx)),
|
|
268
865
|
};
|
|
269
866
|
case "forStatement": {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
867
|
+
const leadingStatements = [];
|
|
868
|
+
let initializer = stmt.initializer;
|
|
869
|
+
if (initializer) {
|
|
870
|
+
if (initializer.kind === "assignment" &&
|
|
871
|
+
initializer.operator === "=" &&
|
|
872
|
+
((initializer.right.kind === "yield" &&
|
|
873
|
+
!initializer.right.delegate) ||
|
|
874
|
+
(initializer.left.kind === "memberAccess" &&
|
|
875
|
+
containsYield(initializer.left)))) {
|
|
876
|
+
const receiveTarget = toReceivePattern(initializer.left);
|
|
877
|
+
if (receiveTarget &&
|
|
878
|
+
initializer.right.kind === "yield" &&
|
|
879
|
+
!initializer.right.delegate) {
|
|
880
|
+
leadingStatements.push(createYieldStatement(initializer.right, receiveTarget, initializer.right.inferredType));
|
|
881
|
+
initializer = undefined;
|
|
882
|
+
}
|
|
883
|
+
else if (receiveTarget) {
|
|
884
|
+
emitUnsupportedYieldDiagnostic(ctx, "for loop initializer", initializer.right.sourceSpan);
|
|
885
|
+
}
|
|
886
|
+
else if (initializer.left.kind === "memberAccess") {
|
|
887
|
+
const loweredMemberAssignment = lowerMemberAccessAssignmentWithYields(initializer, ctx, {
|
|
888
|
+
object: "for loop initializer target object",
|
|
889
|
+
property: "for loop initializer target property",
|
|
890
|
+
right: "for loop initializer value",
|
|
891
|
+
});
|
|
892
|
+
if (!loweredMemberAssignment) {
|
|
893
|
+
emitUnsupportedYieldDiagnostic(ctx, "for loop initializer", initializer.right.sourceSpan);
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
leadingStatements.push(...loweredMemberAssignment.leadingStatements);
|
|
897
|
+
leadingStatements.push({
|
|
898
|
+
kind: "expressionStatement",
|
|
899
|
+
expression: loweredMemberAssignment.loweredAssignment,
|
|
900
|
+
});
|
|
901
|
+
initializer = undefined;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
emitUnsupportedYieldDiagnostic(ctx, "for loop initializer", initializer.right.sourceSpan);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
else if (initializer.kind === "variableDeclaration") {
|
|
909
|
+
const transformedDecls = initializer.declarations.map((decl) => {
|
|
910
|
+
if (!decl.initializer || !containsYield(decl.initializer)) {
|
|
911
|
+
return decl;
|
|
912
|
+
}
|
|
913
|
+
if (decl.initializer.kind === "yield" &&
|
|
914
|
+
!decl.initializer.delegate) {
|
|
915
|
+
const tempName = allocateYieldTempName(ctx);
|
|
916
|
+
leadingStatements.push(createYieldStatement(decl.initializer, { kind: "identifierPattern", name: tempName }, decl.type ?? decl.initializer.inferredType));
|
|
917
|
+
return {
|
|
918
|
+
...decl,
|
|
919
|
+
initializer: {
|
|
920
|
+
kind: "identifier",
|
|
921
|
+
name: tempName,
|
|
922
|
+
},
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
const loweredInitializer = lowerExpressionWithYields(decl.initializer, ctx, "for loop initializer", decl.type ?? decl.initializer.inferredType);
|
|
926
|
+
if (!loweredInitializer) {
|
|
927
|
+
return decl;
|
|
928
|
+
}
|
|
929
|
+
leadingStatements.push(...loweredInitializer.prelude);
|
|
930
|
+
return {
|
|
931
|
+
...decl,
|
|
932
|
+
initializer: loweredInitializer.expression,
|
|
933
|
+
};
|
|
934
|
+
});
|
|
935
|
+
initializer = {
|
|
936
|
+
...initializer,
|
|
937
|
+
declarations: transformedDecls,
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
else if (containsYield(initializer)) {
|
|
941
|
+
const loweredInitializer = lowerExpressionWithYields(initializer, ctx, "for loop initializer");
|
|
942
|
+
if (loweredInitializer) {
|
|
943
|
+
leadingStatements.push(...loweredInitializer.prelude);
|
|
944
|
+
initializer = loweredInitializer.expression;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
const loweredCondition = stmt.condition && containsYield(stmt.condition)
|
|
949
|
+
? lowerExpressionWithYields(stmt.condition, ctx, "for loop condition")
|
|
950
|
+
: undefined;
|
|
951
|
+
const loweredUpdate = stmt.update && containsYield(stmt.update)
|
|
952
|
+
? lowerExpressionWithYields(stmt.update, ctx, "for loop update")
|
|
953
|
+
: undefined;
|
|
954
|
+
const transformedBody = flattenStatement(processStatement(stmt.body, ctx));
|
|
955
|
+
if (!loweredCondition && !loweredUpdate) {
|
|
956
|
+
const transformedFor = {
|
|
957
|
+
...stmt,
|
|
958
|
+
initializer,
|
|
959
|
+
body: transformedBody,
|
|
960
|
+
};
|
|
961
|
+
if (leadingStatements.length === 0) {
|
|
962
|
+
return transformedFor;
|
|
275
963
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
964
|
+
return [...leadingStatements, transformedFor];
|
|
965
|
+
}
|
|
966
|
+
const bodyStatements = [];
|
|
967
|
+
let updateFirstFlagName;
|
|
968
|
+
if (loweredUpdate) {
|
|
969
|
+
updateFirstFlagName = allocateYieldTempName(ctx);
|
|
970
|
+
leadingStatements.push({
|
|
971
|
+
kind: "variableDeclaration",
|
|
972
|
+
declarationKind: "let",
|
|
973
|
+
isExported: false,
|
|
974
|
+
declarations: [
|
|
975
|
+
{
|
|
976
|
+
kind: "variableDeclarator",
|
|
977
|
+
name: { kind: "identifierPattern", name: updateFirstFlagName },
|
|
978
|
+
type: { kind: "primitiveType", name: "boolean" },
|
|
979
|
+
initializer: { kind: "literal", value: true },
|
|
980
|
+
},
|
|
981
|
+
],
|
|
982
|
+
});
|
|
983
|
+
const updateBodyStatements = [...loweredUpdate.prelude];
|
|
984
|
+
if (!stmt.update || stmt.update.kind !== "yield") {
|
|
985
|
+
updateBodyStatements.push({
|
|
986
|
+
kind: "expressionStatement",
|
|
987
|
+
expression: loweredUpdate.expression,
|
|
988
|
+
});
|
|
279
989
|
}
|
|
990
|
+
bodyStatements.push({
|
|
991
|
+
kind: "ifStatement",
|
|
992
|
+
condition: {
|
|
993
|
+
kind: "unary",
|
|
994
|
+
operator: "!",
|
|
995
|
+
expression: { kind: "identifier", name: updateFirstFlagName },
|
|
996
|
+
},
|
|
997
|
+
thenStatement: {
|
|
998
|
+
kind: "blockStatement",
|
|
999
|
+
statements: updateBodyStatements,
|
|
1000
|
+
},
|
|
1001
|
+
});
|
|
1002
|
+
bodyStatements.push({
|
|
1003
|
+
kind: "expressionStatement",
|
|
1004
|
+
expression: {
|
|
1005
|
+
kind: "assignment",
|
|
1006
|
+
operator: "=",
|
|
1007
|
+
left: { kind: "identifierPattern", name: updateFirstFlagName },
|
|
1008
|
+
right: { kind: "literal", value: false },
|
|
1009
|
+
},
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
if (loweredCondition) {
|
|
1013
|
+
bodyStatements.push(...loweredCondition.prelude);
|
|
1014
|
+
bodyStatements.push({
|
|
1015
|
+
kind: "ifStatement",
|
|
1016
|
+
condition: {
|
|
1017
|
+
kind: "unary",
|
|
1018
|
+
operator: "!",
|
|
1019
|
+
expression: loweredCondition.expression,
|
|
1020
|
+
},
|
|
1021
|
+
thenStatement: { kind: "breakStatement" },
|
|
1022
|
+
});
|
|
280
1023
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
1024
|
+
else if (loweredUpdate && stmt.condition) {
|
|
1025
|
+
bodyStatements.push({
|
|
1026
|
+
kind: "ifStatement",
|
|
1027
|
+
condition: {
|
|
1028
|
+
kind: "unary",
|
|
1029
|
+
operator: "!",
|
|
1030
|
+
expression: stmt.condition,
|
|
1031
|
+
},
|
|
1032
|
+
thenStatement: { kind: "breakStatement" },
|
|
1033
|
+
});
|
|
284
1034
|
}
|
|
285
|
-
if (
|
|
286
|
-
|
|
1035
|
+
if (transformedBody.kind === "blockStatement") {
|
|
1036
|
+
bodyStatements.push(...transformedBody.statements);
|
|
287
1037
|
}
|
|
288
|
-
|
|
1038
|
+
else {
|
|
1039
|
+
bodyStatements.push(transformedBody);
|
|
1040
|
+
}
|
|
1041
|
+
const transformedFor = {
|
|
289
1042
|
...stmt,
|
|
290
|
-
|
|
1043
|
+
initializer,
|
|
1044
|
+
condition: { kind: "literal", value: true },
|
|
1045
|
+
update: loweredUpdate ? undefined : stmt.update,
|
|
1046
|
+
body: {
|
|
1047
|
+
kind: "blockStatement",
|
|
1048
|
+
statements: bodyStatements,
|
|
1049
|
+
},
|
|
291
1050
|
};
|
|
1051
|
+
if (leadingStatements.length === 0) {
|
|
1052
|
+
return transformedFor;
|
|
1053
|
+
}
|
|
1054
|
+
return [...leadingStatements, transformedFor];
|
|
292
1055
|
}
|
|
293
1056
|
case "forOfStatement":
|
|
1057
|
+
if (containsYield(stmt.expression)) {
|
|
1058
|
+
const loweredExpression = lowerExpressionWithYields(stmt.expression, ctx, "for-of expression");
|
|
1059
|
+
if (!loweredExpression) {
|
|
1060
|
+
return {
|
|
1061
|
+
...stmt,
|
|
1062
|
+
body: flattenStatement(processStatement(stmt.body, ctx)),
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
return [
|
|
1066
|
+
...loweredExpression.prelude,
|
|
1067
|
+
{
|
|
1068
|
+
...stmt,
|
|
1069
|
+
expression: loweredExpression.expression,
|
|
1070
|
+
body: flattenStatement(processStatement(stmt.body, ctx)),
|
|
1071
|
+
},
|
|
1072
|
+
];
|
|
1073
|
+
}
|
|
1074
|
+
return {
|
|
1075
|
+
...stmt,
|
|
1076
|
+
body: flattenStatement(processStatement(stmt.body, ctx)),
|
|
1077
|
+
};
|
|
1078
|
+
case "forInStatement":
|
|
1079
|
+
if (containsYield(stmt.expression)) {
|
|
1080
|
+
const loweredExpression = lowerExpressionWithYields(stmt.expression, ctx, "for-in expression");
|
|
1081
|
+
if (!loweredExpression) {
|
|
1082
|
+
return {
|
|
1083
|
+
...stmt,
|
|
1084
|
+
body: flattenStatement(processStatement(stmt.body, ctx)),
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
return [
|
|
1088
|
+
...loweredExpression.prelude,
|
|
1089
|
+
{
|
|
1090
|
+
...stmt,
|
|
1091
|
+
expression: loweredExpression.expression,
|
|
1092
|
+
body: flattenStatement(processStatement(stmt.body, ctx)),
|
|
1093
|
+
},
|
|
1094
|
+
];
|
|
1095
|
+
}
|
|
294
1096
|
return {
|
|
295
1097
|
...stmt,
|
|
296
1098
|
body: flattenStatement(processStatement(stmt.body, ctx)),
|
|
297
1099
|
};
|
|
298
1100
|
case "switchStatement":
|
|
1101
|
+
if (containsYield(stmt.expression)) {
|
|
1102
|
+
const loweredExpression = lowerExpressionWithYields(stmt.expression, ctx, "switch expression");
|
|
1103
|
+
if (!loweredExpression) {
|
|
1104
|
+
return {
|
|
1105
|
+
...stmt,
|
|
1106
|
+
cases: stmt.cases.map((c) => ({
|
|
1107
|
+
...c,
|
|
1108
|
+
statements: c.statements.flatMap((s) => {
|
|
1109
|
+
const result = processStatement(s, ctx);
|
|
1110
|
+
return Array.isArray(result) ? result : [result];
|
|
1111
|
+
}),
|
|
1112
|
+
})),
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
return [
|
|
1116
|
+
...loweredExpression.prelude,
|
|
1117
|
+
{
|
|
1118
|
+
...stmt,
|
|
1119
|
+
expression: loweredExpression.expression,
|
|
1120
|
+
cases: stmt.cases.map((c) => ({
|
|
1121
|
+
...c,
|
|
1122
|
+
statements: c.statements.flatMap((s) => {
|
|
1123
|
+
const result = processStatement(s, ctx);
|
|
1124
|
+
return Array.isArray(result) ? result : [result];
|
|
1125
|
+
}),
|
|
1126
|
+
})),
|
|
1127
|
+
},
|
|
1128
|
+
];
|
|
1129
|
+
}
|
|
299
1130
|
return {
|
|
300
1131
|
...stmt,
|
|
301
1132
|
cases: stmt.cases.map((c) => ({
|
|
@@ -321,18 +1152,33 @@ const processStatement = (stmt, ctx) => {
|
|
|
321
1152
|
: undefined,
|
|
322
1153
|
};
|
|
323
1154
|
case "returnStatement":
|
|
324
|
-
// Check for yield in return expression
|
|
325
1155
|
if (stmt.expression && containsYield(stmt.expression)) {
|
|
326
|
-
|
|
1156
|
+
const lowered = lowerExpressionWithYields(stmt.expression, ctx, "return expression");
|
|
1157
|
+
if (!lowered) {
|
|
1158
|
+
return createGeneratorReturnStatement(stmt.expression);
|
|
1159
|
+
}
|
|
1160
|
+
return [
|
|
1161
|
+
...lowered.prelude,
|
|
1162
|
+
createGeneratorReturnStatement(lowered.expression),
|
|
1163
|
+
];
|
|
327
1164
|
}
|
|
328
1165
|
// Transform return statements in generators to IrGeneratorReturnStatement
|
|
329
1166
|
// This captures the return value for generators with TReturn
|
|
330
1167
|
// The emitter will emit: __returnValue = expr; yield break;
|
|
331
1168
|
return createGeneratorReturnStatement(stmt.expression);
|
|
332
1169
|
case "throwStatement":
|
|
333
|
-
// Check for yield in throw expression
|
|
334
1170
|
if (containsYield(stmt.expression)) {
|
|
335
|
-
|
|
1171
|
+
const lowered = lowerExpressionWithYields(stmt.expression, ctx, "throw expression");
|
|
1172
|
+
if (!lowered) {
|
|
1173
|
+
return stmt;
|
|
1174
|
+
}
|
|
1175
|
+
return [
|
|
1176
|
+
...lowered.prelude,
|
|
1177
|
+
{
|
|
1178
|
+
kind: "throwStatement",
|
|
1179
|
+
expression: lowered.expression,
|
|
1180
|
+
},
|
|
1181
|
+
];
|
|
336
1182
|
}
|
|
337
1183
|
return stmt;
|
|
338
1184
|
default:
|
|
@@ -361,6 +1207,45 @@ const flattenStatement = (result) => {
|
|
|
361
1207
|
statements: [...result],
|
|
362
1208
|
};
|
|
363
1209
|
};
|
|
1210
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
1211
|
+
const collectResidualYieldExpressions = (value, collected) => {
|
|
1212
|
+
if (Array.isArray(value)) {
|
|
1213
|
+
for (const element of value) {
|
|
1214
|
+
collectResidualYieldExpressions(element, collected);
|
|
1215
|
+
}
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
if (!isRecord(value)) {
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
if (value.kind === "yield") {
|
|
1222
|
+
collected.push(value);
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
for (const nested of Object.values(value)) {
|
|
1226
|
+
collectResidualYieldExpressions(nested, collected);
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
const locationKey = (location) => `${location.file}:${location.line}:${location.column}:${location.length}`;
|
|
1230
|
+
const addResidualYieldDiagnostics = (ctx, value) => {
|
|
1231
|
+
const residualYields = [];
|
|
1232
|
+
collectResidualYieldExpressions(value, residualYields);
|
|
1233
|
+
if (residualYields.length === 0) {
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
const existingTsn6101Locations = new Set(ctx.diagnostics
|
|
1237
|
+
.filter((d) => d.code === "TSN6101")
|
|
1238
|
+
.map((d) => locationKey(d.location ?? moduleLocation(ctx))));
|
|
1239
|
+
for (const residualYield of residualYields) {
|
|
1240
|
+
const location = residualYield.sourceSpan ?? moduleLocation(ctx);
|
|
1241
|
+
const key = locationKey(location);
|
|
1242
|
+
if (existingTsn6101Locations.has(key)) {
|
|
1243
|
+
continue;
|
|
1244
|
+
}
|
|
1245
|
+
emitUnsupportedYieldDiagnostic(ctx, "an unsupported expression form after yield lowering", location);
|
|
1246
|
+
existingTsn6101Locations.add(key);
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
364
1249
|
/**
|
|
365
1250
|
* Process statements in non-generator functions (just recurse into nested generators).
|
|
366
1251
|
*/
|
|
@@ -372,9 +1257,11 @@ const processNonGeneratorStatement = (stmt, ctx) => {
|
|
|
372
1257
|
...ctx,
|
|
373
1258
|
inGenerator: true,
|
|
374
1259
|
};
|
|
1260
|
+
const loweredBody = flattenStatement(processStatement(stmt.body, generatorCtx));
|
|
1261
|
+
addResidualYieldDiagnostics(generatorCtx, loweredBody);
|
|
375
1262
|
return {
|
|
376
1263
|
...stmt,
|
|
377
|
-
body:
|
|
1264
|
+
body: loweredBody,
|
|
378
1265
|
};
|
|
379
1266
|
}
|
|
380
1267
|
return {
|
|
@@ -451,9 +1338,11 @@ const processClassMember = (member, ctx) => {
|
|
|
451
1338
|
...ctx,
|
|
452
1339
|
inGenerator: true,
|
|
453
1340
|
};
|
|
1341
|
+
const loweredBody = flattenStatement(processStatement(member.body, generatorCtx));
|
|
1342
|
+
addResidualYieldDiagnostics(generatorCtx, loweredBody);
|
|
454
1343
|
return {
|
|
455
1344
|
...member,
|
|
456
|
-
body:
|
|
1345
|
+
body: loweredBody,
|
|
457
1346
|
};
|
|
458
1347
|
}
|
|
459
1348
|
return {
|
|
@@ -477,6 +1366,7 @@ const processModule = (module) => {
|
|
|
477
1366
|
filePath: module.filePath,
|
|
478
1367
|
diagnostics: [],
|
|
479
1368
|
inGenerator: false,
|
|
1369
|
+
yieldTempCounter: 0,
|
|
480
1370
|
};
|
|
481
1371
|
const processedBody = module.body.map((stmt) => {
|
|
482
1372
|
if (stmt.kind === "functionDeclaration" && stmt.isGenerator) {
|
|
@@ -484,9 +1374,11 @@ const processModule = (module) => {
|
|
|
484
1374
|
...ctx,
|
|
485
1375
|
inGenerator: true,
|
|
486
1376
|
};
|
|
1377
|
+
const loweredBody = flattenStatement(processStatement(stmt.body, generatorCtx));
|
|
1378
|
+
addResidualYieldDiagnostics(generatorCtx, loweredBody);
|
|
487
1379
|
return {
|
|
488
1380
|
...stmt,
|
|
489
|
-
body:
|
|
1381
|
+
body: loweredBody,
|
|
490
1382
|
};
|
|
491
1383
|
}
|
|
492
1384
|
return processNonGeneratorStatement(stmt, ctx);
|
|
@@ -499,11 +1391,13 @@ const processModule = (module) => {
|
|
|
499
1391
|
...ctx,
|
|
500
1392
|
inGenerator: true,
|
|
501
1393
|
};
|
|
1394
|
+
const loweredBody = flattenStatement(processStatement(exp.declaration.body, generatorCtx));
|
|
1395
|
+
addResidualYieldDiagnostics(generatorCtx, loweredBody);
|
|
502
1396
|
return {
|
|
503
1397
|
...exp,
|
|
504
1398
|
declaration: {
|
|
505
1399
|
...exp.declaration,
|
|
506
|
-
body:
|
|
1400
|
+
body: loweredBody,
|
|
507
1401
|
},
|
|
508
1402
|
};
|
|
509
1403
|
}
|