ember-source 6.12.0-beta.3 → 7.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blueprints/initializer-test/files/__root__/__testType__/__path__/__name__-test.ts +2 -2
- package/blueprints/instance-initializer-test/files/__root__/__testType__/__path__/__name__-test.ts +3 -3
- package/build-metadata.json +3 -3
- package/dist/{packages/shared-chunks/registry-XY5cfmbH.js → dev/packages/@ember/-internals/container/index.js} +28 -27
- package/dist/{packages → dev/packages}/@ember/-internals/deprecations/index.js +5 -16
- package/dist/{packages/shared-chunks/env-DEd6hPbj.js → dev/packages/@ember/-internals/environment/index.js} +31 -53
- package/dist/dev/packages/@ember/-internals/glimmer/index.js +42 -0
- package/dist/{packages → dev/packages}/@ember/-internals/meta/lib/meta.js +37 -38
- package/dist/dev/packages/@ember/-internals/metal/index.js +63 -0
- package/dist/{packages → dev/packages}/@ember/-internals/routing/index.js +7 -8
- package/dist/{packages → dev/packages}/@ember/-internals/runtime/lib/ext/rsvp.js +1 -2
- package/dist/{packages → dev/packages}/@ember/-internals/runtime/lib/mixins/-proxy.js +14 -15
- package/dist/{packages → dev/packages}/@ember/-internals/runtime/lib/mixins/action_handler.js +21 -9
- package/dist/{packages → dev/packages}/@ember/-internals/runtime/lib/mixins/registry_proxy.js +11 -2
- package/dist/{packages → dev/packages}/@ember/-internals/runtime/lib/mixins/target_action_support.js +22 -9
- package/dist/{packages → dev/packages}/@ember/-internals/string/index.js +1 -2
- package/dist/dev/packages/@ember/-internals/utils/index.js +34 -0
- package/dist/{packages → dev/packages}/@ember/-internals/views/lib/compat/fallback-view-registry.js +1 -2
- package/dist/{packages → dev/packages}/@ember/-internals/views/lib/mixins/action_support.js +16 -10
- package/dist/{packages → dev/packages}/@ember/-internals/views/lib/system/event_dispatcher.js +19 -20
- package/dist/{packages → dev/packages}/@ember/-internals/views/lib/system/utils.js +7 -23
- package/dist/{packages → dev/packages}/@ember/-internals/views/lib/views/core_view.js +6 -7
- package/dist/{packages → dev/packages}/@ember/-internals/views/lib/views/states.js +3 -4
- package/dist/{packages → dev/packages}/@ember/application/index.js +50 -121
- package/dist/{packages → dev/packages}/@ember/application/instance.js +17 -17
- package/dist/{packages → dev/packages}/@ember/application/namespace.js +27 -9
- package/dist/{packages → dev/packages}/@ember/array/index.js +34 -25
- package/dist/{packages → dev/packages}/@ember/array/proxy.js +19 -20
- package/dist/{packages → dev/packages}/@ember/canary-features/index.js +1 -1
- package/dist/dev/packages/@ember/component/helper.js +14 -0
- package/dist/{packages → dev/packages}/@ember/component/index.js +12 -12
- package/dist/{packages → dev/packages}/@ember/component/template-only.js +6 -6
- package/dist/{packages → dev/packages}/@ember/controller/index.js +7 -9
- package/dist/{packages → dev/packages}/@ember/debug/container-debug-adapter.js +6 -7
- package/dist/{packages → dev/packages}/@ember/debug/data-adapter.js +6 -7
- package/dist/{packages → dev/packages}/@ember/debug/index.js +4 -11
- package/dist/{packages → dev/packages}/@ember/debug/lib/assert.js +1 -3
- package/dist/{packages → dev/packages}/@ember/debug/lib/deprecate.js +7 -3
- package/dist/{packages → dev/packages}/@ember/debug/lib/handlers.js +1 -3
- package/dist/{packages → dev/packages}/@ember/debug/lib/warn.js +1 -2
- package/dist/{packages → dev/packages}/@ember/engine/index.js +22 -22
- package/dist/dev/packages/@ember/engine/instance.js +200 -0
- package/dist/{packages → dev/packages}/@ember/helper/index.js +12 -11
- package/dist/{packages → dev/packages}/@ember/instrumentation/index.js +3 -8
- package/dist/dev/packages/@ember/modifier/index.js +23 -0
- package/dist/{packages → dev/packages}/@ember/modifier/on.js +6 -6
- package/dist/dev/packages/@ember/object/-internals.js +49 -0
- package/dist/{packages → dev/packages}/@ember/object/compat.js +11 -12
- package/dist/{packages → dev/packages}/@ember/object/computed.js +7 -8
- package/dist/{packages → dev/packages}/@ember/object/core.js +28 -29
- package/dist/{packages → dev/packages}/@ember/object/evented.js +7 -8
- package/dist/dev/packages/@ember/object/events.js +11 -0
- package/dist/{packages → dev/packages}/@ember/object/index.js +18 -19
- package/dist/{packages → dev/packages}/@ember/object/internals.js +1 -1
- package/dist/{packages → dev/packages}/@ember/object/lib/computed/computed_macros.js +30 -27
- package/dist/{packages → dev/packages}/@ember/object/lib/computed/reduce_computed_macros.js +36 -37
- package/dist/{packages → dev/packages}/@ember/object/mixin.js +15 -23
- package/dist/dev/packages/@ember/object/observable.js +181 -0
- package/dist/dev/packages/@ember/object/observers.js +11 -0
- package/dist/{packages → dev/packages}/@ember/object/promise-proxy-mixin.js +7 -8
- package/dist/dev/packages/@ember/renderer/index.js +14 -0
- package/dist/dev/packages/@ember/routing/-internals.js +22 -0
- package/dist/{packages → dev/packages}/@ember/routing/hash-location.js +1 -1
- package/dist/{packages → dev/packages}/@ember/routing/history-location.js +9 -25
- package/dist/dev/packages/@ember/routing/index.js +14 -0
- package/dist/{packages → dev/packages}/@ember/routing/lib/dsl.js +5 -6
- package/dist/{packages → dev/packages}/@ember/routing/lib/generate_controller.js +22 -10
- package/dist/{packages → dev/packages}/@ember/routing/lib/location-utils.js +3 -16
- package/dist/{packages → dev/packages}/@ember/routing/lib/routing-service.js +19 -9
- package/dist/{packages → dev/packages}/@ember/routing/lib/utils.js +12 -13
- package/dist/{packages → dev/packages}/@ember/routing/none-location.js +2 -4
- package/dist/{packages → dev/packages}/@ember/routing/route.js +38 -39
- package/dist/{packages → dev/packages}/@ember/routing/router-service.js +13 -14
- package/dist/{packages → dev/packages}/@ember/routing/router.js +63 -71
- package/dist/{packages → dev/packages}/@ember/runloop/index.js +9 -8
- package/dist/{packages → dev/packages}/@ember/service/index.js +6 -7
- package/dist/dev/packages/@ember/template/index.js +14 -0
- package/dist/{packages → dev/packages}/@ember/template-compilation/index.js +3 -3
- package/dist/dev/packages/@ember/template-compiler/index.js +2 -0
- package/dist/{packages → dev/packages}/@ember/template-compiler/lib/compile-options.js +11 -6
- package/dist/{packages → dev/packages}/@ember/template-compiler/lib/dasherize-component-name.js +1 -2
- package/dist/dev/packages/@ember/template-compiler/lib/plugins/allowed-globals.js +56 -0
- package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/assert-against-attrs.js +19 -3
- package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/assert-against-named-outlets.js +11 -2
- package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/assert-input-helper-without-block.js +1 -2
- package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/assert-reserved-named-arguments.js +3 -4
- package/dist/dev/packages/@ember/template-compiler/lib/plugins/index.js +40 -0
- package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/transform-each-track-array.js +21 -2
- package/dist/dev/packages/@ember/template-compiler/lib/plugins/transform-in-element.js +50 -0
- package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/transform-resolutions.js +2 -3
- package/dist/dev/packages/@ember/template-compiler/lib/template.js +248 -0
- package/dist/dev/packages/@ember/template-factory/index.js +8 -0
- package/dist/dev/packages/@ember/test/index.js +18 -0
- package/dist/{packages → dev/packages}/@ember/utils/lib/compare.js +5 -6
- package/dist/{packages → dev/packages}/@ember/utils/lib/is_empty.js +6 -7
- package/dist/{packages → dev/packages}/@glimmer/destroyable/index.js +21 -16
- package/dist/{packages/shared-chunks/encoder-CT1wqYMF.js → dev/packages/@glimmer/encoder/index.js} +3 -4
- package/dist/{packages → dev/packages}/@glimmer/global-context/index.js +6 -5
- package/dist/{packages/shared-chunks/api-1B_9SjFR.js → dev/packages/@glimmer/manager/index.js} +17 -14
- package/dist/dev/packages/@glimmer/node/index.js +40 -0
- package/dist/{packages → dev/packages}/@glimmer/opcode-compiler/index.js +5 -6
- package/dist/dev/packages/@glimmer/program/index.js +12 -0
- package/dist/dev/packages/@glimmer/reference/index.js +208 -0
- package/dist/dev/packages/@glimmer/runtime/index.js +11 -0
- package/dist/dev/packages/@glimmer/tracking/index.js +137 -0
- package/dist/dev/packages/@glimmer/tracking/primitives/cache/index.js +11 -0
- package/dist/{packages → dev/packages}/@glimmer/util/index.js +2 -3
- package/dist/{packages → dev/packages}/@glimmer/validator/index.js +304 -372
- package/dist/{packages → dev/packages}/@glimmer/vm/index.js +1 -1
- package/dist/{packages → dev/packages}/ember/version.js +2 -2
- package/dist/dev/packages/ember-template-compiler/index.js +109 -0
- package/dist/{packages → dev/packages}/ember-testing/index.js +1 -3
- package/dist/dev/packages/ember-testing/lib/public-api.js +2 -0
- package/dist/dev/packages/ember-testing/lib/test/pending_requests.js +10 -0
- package/dist/dev/packages/ember-testing/lib/test.js +25 -0
- package/dist/{packages/shared-chunks/router-DSi8WnDi.js → dev/packages/router_js/index.js} +120 -58
- package/dist/{packages/shared-chunks/alias-BEMS3qgG.js → dev/packages/shared-chunks/alias-CSC0WIbj.js} +4 -5
- package/dist/{packages/shared-chunks/api-CkUl6KyJ.js → dev/packages/shared-chunks/api-BqXkkT0p.js} +14 -16
- package/dist/{packages/shared-chunks/args-proxy-B91L3LRK.js → dev/packages/shared-chunks/args-proxy-DgXMc9b5.js} +7 -8
- package/dist/{packages/shared-chunks/array-BqYCCatg.js → dev/packages/shared-chunks/array-D8PfjQHi.js} +3 -4
- package/dist/dev/packages/shared-chunks/capabilities-O_xc7Yqk.js +34 -0
- package/dist/{packages/shared-chunks/collections-B8me-ZlQ.js → dev/packages/shared-chunks/collections-D_nY_0UJ.js} +1 -2
- package/dist/{packages/@ember/template-compiler/lib/template.js → dev/packages/shared-chunks/compiler-CNj62pww.js} +22 -243
- package/dist/{packages/shared-chunks/constants-oDhF27qL.js → dev/packages/shared-chunks/constants-eoaL3OJQ.js} +9 -9
- package/dist/{packages/shared-chunks/debug-to-string-BsFOvUtQ.js → dev/packages/shared-chunks/debug-to-string-CFb7h0lY.js} +1 -3
- package/dist/{packages/shared-chunks/dynamic-CuBsUXX8.js → dev/packages/shared-chunks/dynamic-CFg3dljk.js} +108 -134
- package/dist/{packages/shared-chunks/element-builder-BuVym8EM.js → dev/packages/shared-chunks/element-builder-BOxP8emt.js} +4 -5
- package/dist/{packages/shared-chunks/flags-BsZlvEeR.js → dev/packages/shared-chunks/flags-B9qxc-pB.js} +1 -1
- package/dist/{packages/shared-chunks/capabilities-DHiXCCuB.js → dev/packages/shared-chunks/fragment-Cc5k9Oy4.js} +2 -33
- package/dist/{packages/shared-chunks/index-ByyoGpfz.js → dev/packages/shared-chunks/index-PxU6E7q8.js} +658 -214
- package/dist/{packages/shared-chunks/index-CQkjwqTv.js → dev/packages/shared-chunks/index-Q7JnrdBn.js} +20 -19
- package/dist/dev/packages/shared-chunks/invoke-DxRPE05O.js +67 -0
- package/dist/{packages/shared-chunks/is_proxy-C2q5rUMp.js → dev/packages/shared-chunks/is_proxy-B0smdQy8.js} +1 -1
- package/dist/{packages/shared-chunks/mandatory-setter-DLKyVs4Q.js → dev/packages/shared-chunks/mandatory-setter-DHZe7-kW.js} +47 -48
- package/dist/{packages/shared-chunks/name-DVtQREj6.js → dev/packages/shared-chunks/name-Z7dpqvzn.js} +1 -1
- package/dist/{packages/shared-chunks/namespace_search-ClQOZuFA.js → dev/packages/shared-chunks/namespace_search-uT8odThF.js} +3 -4
- package/dist/{packages/shared-chunks/observers-DhgQ6ba5.js → dev/packages/shared-chunks/observers-Bj9qLVau.js} +231 -87
- package/dist/{packages/shared-chunks/program-CcLlGnAU.js → dev/packages/shared-chunks/program-DfV0v8aa.js} +4 -6
- package/dist/{packages/shared-chunks/program-context-CZJnCFdo.js → dev/packages/shared-chunks/program-context-BRjCC_BA.js} +2 -2
- package/dist/{packages/shared-chunks/property_set-DrZnfGQ7.js → dev/packages/shared-chunks/property_set-DaoZXGM5.js} +11 -16
- package/dist/dev/packages/shared-chunks/public-api-C3KlJmEr.js +10 -0
- package/dist/{packages/shared-chunks/reference-B6HMX4y0.js → dev/packages/shared-chunks/reference-C3TKDRnP.js} +11 -12
- package/dist/{packages/@glimmer/runtime/index.js → dev/packages/shared-chunks/rehydrate-builder-DPImr9e9.js} +8 -16
- package/dist/{packages/shared-chunks/render-DTOhhssy.js → dev/packages/shared-chunks/render-sg8BuFaE.js} +16 -23
- package/dist/{packages/shared-chunks/serialize-builder-DEgRJgNQ.js → dev/packages/shared-chunks/serialize-builder-b_gSYCSS.js} +7 -7
- package/dist/{packages/shared-chunks/set_properties-Dag9Xz6u.js → dev/packages/shared-chunks/set_properties-kVGzZL_a.js} +2 -2
- package/dist/{packages/shared-chunks/setup-registry-Bbj8WQen.js → dev/packages/shared-chunks/setup-registry-DGdDOxrk.js} +12 -12
- package/dist/{packages/shared-chunks/simple-cast-BXTrayoV.js → dev/packages/shared-chunks/simple-cast-DCvJLSin.js} +1 -1
- package/dist/{packages/shared-chunks/template-CMHIG4cn.js → dev/packages/shared-chunks/template-kM-7TTcc.js} +3 -4
- package/dist/dev/packages/shared-chunks/to-string-C7M8LBLH.js +36 -0
- package/dist/{packages/shared-chunks/transform-resolutions-vHYYonpB.js → dev/packages/shared-chunks/transform-resolutions-fXGQKGsL.js} +331 -288
- package/dist/{packages/shared-chunks/unrecognized-url-error-BBMMZhBN.js → dev/packages/shared-chunks/unrecognized-url-error-B3wUTorp.js} +103 -39
- package/dist/prod/packages/@ember/-internals/browser-environment/index.js +2 -0
- package/dist/prod/packages/@ember/-internals/container/index.js +697 -0
- package/dist/prod/packages/@ember/-internals/deprecations/index.js +114 -0
- package/dist/prod/packages/@ember/-internals/environment/index.js +171 -0
- package/dist/prod/packages/@ember/-internals/error-handling/index.js +26 -0
- package/dist/prod/packages/@ember/-internals/glimmer/index.js +39 -0
- package/dist/prod/packages/@ember/-internals/meta/index.js +1 -0
- package/dist/prod/packages/@ember/-internals/meta/lib/meta.js +455 -0
- package/dist/prod/packages/@ember/-internals/metal/index.js +61 -0
- package/dist/prod/packages/@ember/-internals/owner/index.js +252 -0
- package/dist/prod/packages/@ember/-internals/routing/index.js +14 -0
- package/dist/prod/packages/@ember/-internals/runtime/index.js +9 -0
- package/dist/prod/packages/@ember/-internals/runtime/lib/ext/rsvp.js +51 -0
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +89 -0
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +187 -0
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/comparable.js +37 -0
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +44 -0
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +42 -0
- package/dist/prod/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +142 -0
- package/dist/prod/packages/@ember/-internals/string/index.js +93 -0
- package/dist/prod/packages/@ember/-internals/utility-types/index.js +12 -0
- package/dist/prod/packages/@ember/-internals/utils/index.js +75 -0
- package/dist/prod/packages/@ember/-internals/views/index.js +7 -0
- package/dist/prod/packages/@ember/-internals/views/lib/compat/attrs.js +3 -0
- package/dist/prod/packages/@ember/-internals/views/lib/compat/fallback-view-registry.js +7 -0
- package/dist/prod/packages/@ember/-internals/views/lib/component_lookup.js +14 -0
- package/dist/prod/packages/@ember/-internals/views/lib/mixins/action_support.js +35 -0
- package/dist/prod/packages/@ember/-internals/views/lib/system/event_dispatcher.js +227 -0
- package/dist/prod/packages/@ember/-internals/views/lib/system/utils.js +172 -0
- package/dist/prod/packages/@ember/-internals/views/lib/views/core_view.js +87 -0
- package/dist/prod/packages/@ember/-internals/views/lib/views/states.js +83 -0
- package/dist/prod/packages/@ember/application/index.js +899 -0
- package/dist/prod/packages/@ember/application/instance.js +438 -0
- package/dist/prod/packages/@ember/application/namespace.js +68 -0
- package/dist/prod/packages/@ember/array/-internals.js +9 -0
- package/dist/prod/packages/@ember/array/index.js +591 -0
- package/dist/prod/packages/@ember/array/lib/make-array.js +42 -0
- package/dist/prod/packages/@ember/array/make.js +1 -0
- package/dist/prod/packages/@ember/array/mutable.js +1 -0
- package/dist/prod/packages/@ember/array/proxy.js +267 -0
- package/dist/prod/packages/@ember/canary-features/index.js +67 -0
- package/dist/prod/packages/@ember/component/helper.js +12 -0
- package/dist/prod/packages/@ember/component/index.js +32 -0
- package/dist/prod/packages/@ember/component/template-only.js +39 -0
- package/dist/prod/packages/@ember/controller/index.js +177 -0
- package/dist/prod/packages/@ember/debug/container-debug-adapter.js +117 -0
- package/dist/prod/packages/@ember/debug/data-adapter.js +553 -0
- package/dist/prod/packages/@ember/debug/index.js +30 -0
- package/dist/prod/packages/@ember/debug/lib/assert.js +7 -0
- package/dist/prod/packages/@ember/debug/lib/capture-render-tree.js +28 -0
- package/dist/prod/packages/@ember/debug/lib/deprecate.js +56 -0
- package/dist/prod/packages/@ember/debug/lib/handlers.js +5 -0
- package/dist/prod/packages/@ember/debug/lib/inspect.js +120 -0
- package/dist/prod/packages/@ember/debug/lib/testing.js +9 -0
- package/dist/prod/packages/@ember/debug/lib/warn.js +6 -0
- package/dist/prod/packages/@ember/deprecated-features/index.js +7 -0
- package/dist/prod/packages/@ember/destroyable/index.js +251 -0
- package/dist/prod/packages/@ember/engine/index.js +450 -0
- package/dist/{packages → prod/packages}/@ember/engine/instance.js +24 -10
- package/dist/prod/packages/@ember/engine/lib/engine-parent.js +33 -0
- package/dist/prod/packages/@ember/engine/parent.js +1 -0
- package/dist/prod/packages/@ember/enumerable/index.js +20 -0
- package/dist/prod/packages/@ember/enumerable/mutable.js +22 -0
- package/dist/prod/packages/@ember/helper/index.js +489 -0
- package/dist/prod/packages/@ember/instrumentation/index.js +242 -0
- package/dist/prod/packages/@ember/modifier/index.js +21 -0
- package/dist/prod/packages/@ember/modifier/on.js +20 -0
- package/dist/prod/packages/@ember/object/-internals.js +28 -0
- package/dist/prod/packages/@ember/object/compat.js +128 -0
- package/dist/prod/packages/@ember/object/computed.js +10 -0
- package/dist/prod/packages/@ember/object/core.js +781 -0
- package/dist/prod/packages/@ember/object/evented.js +76 -0
- package/dist/prod/packages/@ember/object/events.js +6 -0
- package/dist/prod/packages/@ember/object/index.js +205 -0
- package/dist/prod/packages/@ember/object/internals.js +8 -0
- package/dist/prod/packages/@ember/object/lib/computed/computed_macros.js +776 -0
- package/dist/prod/packages/@ember/object/lib/computed/reduce_computed_macros.js +1032 -0
- package/dist/prod/packages/@ember/object/mixin.js +560 -0
- package/dist/{packages → prod/packages}/@ember/object/observable.js +80 -15
- package/dist/prod/packages/@ember/object/observers.js +6 -0
- package/dist/prod/packages/@ember/object/promise-proxy-mixin.js +138 -0
- package/dist/prod/packages/@ember/object/proxy.js +98 -0
- package/dist/prod/packages/@ember/owner/index.js +88 -0
- package/dist/prod/packages/@ember/reactive/collections.js +1 -0
- package/dist/prod/packages/@ember/reactive/index.js +12 -0
- package/dist/prod/packages/@ember/renderer/index.js +12 -0
- package/dist/prod/packages/@ember/routing/hash-location.js +153 -0
- package/dist/prod/packages/@ember/routing/history-location.js +250 -0
- package/dist/prod/packages/@ember/routing/index.js +12 -0
- package/dist/prod/packages/@ember/routing/lib/cache.js +37 -0
- package/dist/prod/packages/@ember/routing/lib/controller_for.js +16 -0
- package/dist/prod/packages/@ember/routing/lib/dsl.js +178 -0
- package/dist/prod/packages/@ember/routing/lib/generate_controller.js +62 -0
- package/dist/prod/packages/@ember/routing/lib/location-utils.js +48 -0
- package/dist/prod/packages/@ember/routing/lib/query_params.js +9 -0
- package/dist/prod/packages/@ember/routing/lib/router_state.js +26 -0
- package/dist/prod/packages/@ember/routing/lib/routing-service.js +125 -0
- package/dist/prod/packages/@ember/routing/lib/utils.js +236 -0
- package/dist/prod/packages/@ember/routing/none-location.js +120 -0
- package/dist/prod/packages/@ember/routing/route.js +1604 -0
- package/dist/prod/packages/@ember/routing/router-service.js +640 -0
- package/dist/prod/packages/@ember/routing/router.js +1335 -0
- package/dist/prod/packages/@ember/runloop/index.js +736 -0
- package/dist/prod/packages/@ember/service/index.js +124 -0
- package/dist/prod/packages/@ember/template/index.js +12 -0
- package/dist/prod/packages/@ember/template-compilation/index.js +20 -0
- package/dist/prod/packages/@ember/template-compiler/-internal-primitives.js +1 -0
- package/dist/prod/packages/@ember/template-compiler/-internal-utils.js +1 -0
- package/dist/prod/packages/@ember/template-compiler/index.js +2 -0
- package/dist/prod/packages/@ember/template-compiler/lib/-internal/primitives.js +1 -0
- package/dist/prod/packages/@ember/template-compiler/lib/compile-options.js +103 -0
- package/dist/prod/packages/@ember/template-compiler/lib/dasherize-component-name.js +21 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/allowed-globals.js +56 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-against-attrs.js +49 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-against-named-outlets.js +34 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-input-helper-without-block.js +22 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/assert-reserved-named-arguments.js +37 -0
- package/dist/{packages → prod/packages}/@ember/template-compiler/lib/plugins/index.js +1 -1
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-action-syntax.js +65 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-each-in-into-each.js +51 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-each-track-array.js +50 -0
- package/dist/{packages → prod/packages}/@ember/template-compiler/lib/plugins/transform-in-element.js +20 -6
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js +37 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-resolutions.js +4 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/transform-wrap-mount-and-outlet.js +57 -0
- package/dist/prod/packages/@ember/template-compiler/lib/plugins/utils.js +55 -0
- package/dist/prod/packages/@ember/template-compiler/lib/public-api.js +1 -0
- package/dist/prod/packages/@ember/template-compiler/lib/runtime.js +1 -0
- package/dist/prod/packages/@ember/template-compiler/lib/system/calculate-location-display.js +28 -0
- package/dist/prod/packages/@ember/template-compiler/lib/template.js +245 -0
- package/dist/prod/packages/@ember/template-factory/index.js +5 -0
- package/dist/prod/packages/@ember/test/adapter.js +2 -0
- package/dist/prod/packages/@ember/test/index.js +18 -0
- package/dist/prod/packages/@ember/utils/index.js +7 -0
- package/dist/prod/packages/@ember/utils/lib/compare.js +159 -0
- package/dist/prod/packages/@ember/utils/lib/is-equal.js +60 -0
- package/dist/prod/packages/@ember/utils/lib/is_blank.js +36 -0
- package/dist/prod/packages/@ember/utils/lib/is_empty.js +67 -0
- package/dist/prod/packages/@ember/utils/lib/is_none.js +28 -0
- package/dist/prod/packages/@ember/utils/lib/is_present.js +39 -0
- package/dist/prod/packages/@ember/utils/lib/type-of.js +110 -0
- package/dist/prod/packages/@ember/version/index.js +1 -0
- package/dist/prod/packages/@glimmer/destroyable/index.js +128 -0
- package/dist/prod/packages/@glimmer/encoder/index.js +28 -0
- package/dist/prod/packages/@glimmer/env/index.js +4 -0
- package/dist/prod/packages/@glimmer/global-context/index.js +138 -0
- package/dist/prod/packages/@glimmer/manager/index.js +293 -0
- package/dist/{packages/shared-chunks/node-dom-helper-BYL7Plyj.js → prod/packages/@glimmer/node/index.js} +10 -12
- package/dist/prod/packages/@glimmer/opcode-compiler/index.js +40 -0
- package/dist/prod/packages/@glimmer/owner/index.js +19 -0
- package/dist/prod/packages/@glimmer/program/index.js +12 -0
- package/dist/{packages/shared-chunks/iterable-BKS7az3P.js → prod/packages/@glimmer/reference/index.js} +13 -12
- package/dist/prod/packages/@glimmer/runtime/index.js +9 -0
- package/dist/prod/packages/@glimmer/tracking/index.js +115 -0
- package/dist/prod/packages/@glimmer/tracking/primitives/cache/index.js +6 -0
- package/dist/prod/packages/@glimmer/util/index.js +129 -0
- package/dist/prod/packages/@glimmer/validator/index.js +1027 -0
- package/dist/prod/packages/@glimmer/vm/index.js +15 -0
- package/dist/prod/packages/@glimmer/wire-format/index.js +102 -0
- package/dist/prod/packages/@simple-dom/document/index.js +355 -0
- package/dist/prod/packages/backburner.js/index.js +939 -0
- package/dist/prod/packages/dag-map/index.js +202 -0
- package/dist/prod/packages/ember/version.js +4 -0
- package/dist/prod/packages/ember-template-compiler/index.js +100 -0
- package/dist/prod/packages/ember-testing/index.js +6 -0
- package/dist/prod/packages/ember-testing/lib/adapters/adapter.js +49 -0
- package/dist/prod/packages/ember-testing/lib/public-api.js +2 -0
- package/dist/prod/packages/ember-testing/lib/test/adapter.js +32 -0
- package/dist/prod/packages/ember-testing/lib/test/pending_requests.js +10 -0
- package/dist/prod/packages/ember-testing/lib/test/waiters.js +128 -0
- package/dist/prod/packages/ember-testing/lib/test.js +25 -0
- package/dist/prod/packages/route-recognizer/index.js +671 -0
- package/dist/prod/packages/router_js/index.js +1527 -0
- package/dist/prod/packages/rsvp/index.js +1 -0
- package/dist/prod/packages/shared-chunks/alias-BkT-0B1G.js +81 -0
- package/dist/prod/packages/shared-chunks/api-Co-k4HVs.js +200 -0
- package/dist/prod/packages/shared-chunks/args-proxy-Dl0A0YWI.js +131 -0
- package/dist/prod/packages/shared-chunks/array-EwekEvId.js +117 -0
- package/dist/prod/packages/shared-chunks/array-utils-CZQxrdD3.js +45 -0
- package/dist/prod/packages/shared-chunks/assert-CUCJBR2C.js +19 -0
- package/dist/prod/packages/shared-chunks/cache-qDyqAcpg.js +35 -0
- package/dist/prod/packages/shared-chunks/capabilities-DGmQ_mz4.js +26 -0
- package/dist/prod/packages/shared-chunks/chunk-3SQBS3Y5-Cj4eryg1.js +121 -0
- package/dist/prod/packages/shared-chunks/collections-GpG8lT2g.js +75 -0
- package/dist/prod/packages/shared-chunks/compiler-Ddfo5StE.js +6806 -0
- package/dist/prod/packages/shared-chunks/computed_cache-DmYKevAP.js +12 -0
- package/dist/prod/packages/shared-chunks/constants-b-2IVErl.js +210 -0
- package/dist/prod/packages/shared-chunks/debug-brand-B1TWjOCH.js +12 -0
- package/dist/prod/packages/shared-chunks/decorator-BdDDBUd2.js +123 -0
- package/dist/prod/packages/shared-chunks/dictionary-gc5gpyOG.js +13 -0
- package/dist/prod/packages/shared-chunks/element-builder-CiLTrXD6.js +776 -0
- package/dist/prod/packages/shared-chunks/flags-B9qxc-pB.js +24 -0
- package/dist/prod/packages/shared-chunks/fragment-EpVz5Xuc.js +910 -0
- package/dist/prod/packages/shared-chunks/get-debug-name-BDxIL2Y1.js +3 -0
- package/dist/prod/packages/shared-chunks/has-dom-DdQORPzI.js +4 -0
- package/dist/prod/packages/shared-chunks/index-CSVCFS_p.js +1904 -0
- package/dist/prod/packages/shared-chunks/index-Cc8WmrB-.js +21 -0
- package/dist/prod/packages/shared-chunks/index-DZLHQAlb.js +5842 -0
- package/dist/prod/packages/shared-chunks/injected_property-DL3vQoFA.js +58 -0
- package/dist/prod/packages/shared-chunks/invoke-DxL00a1D.js +53 -0
- package/dist/prod/packages/shared-chunks/is_proxy-Cr1qlMv_.js +16 -0
- package/dist/prod/packages/shared-chunks/lookup-descriptor-CwcVgaLv.js +13 -0
- package/dist/prod/packages/shared-chunks/name-C68GLLO3.js +11 -0
- package/dist/prod/packages/shared-chunks/namespace_search-Aog9nySA.js +1070 -0
- package/dist/prod/packages/shared-chunks/object-utils-AijlD-JH.js +12 -0
- package/dist/prod/packages/shared-chunks/observers-R1ZklwWy.js +714 -0
- package/dist/prod/packages/shared-chunks/on-CrTl7JQU.js +3329 -0
- package/dist/prod/packages/shared-chunks/program-B7SJZ5NF.js +176 -0
- package/dist/prod/packages/shared-chunks/program-context-C-JdYXRA.js +146 -0
- package/dist/prod/packages/shared-chunks/property_set-O080KTKZ.js +99 -0
- package/dist/prod/packages/shared-chunks/public-api-C3KlJmEr.js +10 -0
- package/dist/prod/packages/shared-chunks/reference-BNqcwZWH.js +151 -0
- package/dist/prod/packages/shared-chunks/registers-ylirb0dq.js +35 -0
- package/dist/prod/packages/shared-chunks/rehydrate-builder-CSn1aIO1.js +459 -0
- package/dist/prod/packages/shared-chunks/render-C1ZnScKH.js +1464 -0
- package/dist/prod/packages/shared-chunks/rsvp-CnCSY930.js +2306 -0
- package/dist/prod/packages/shared-chunks/serialize-builder-CVQ3q8rJ.js +124 -0
- package/dist/prod/packages/shared-chunks/set_properties-CjsDTRey.js +101 -0
- package/dist/prod/packages/shared-chunks/setup-registry-CMNYh2jY.js +53 -0
- package/dist/prod/packages/shared-chunks/simple-cast-DCvJLSin.js +33 -0
- package/dist/prod/packages/shared-chunks/super-Cm_a_cLQ.js +275 -0
- package/dist/prod/packages/shared-chunks/template-Dc_cBOoX.js +19 -0
- package/dist/prod/packages/shared-chunks/tracked-ChVNBE2f.js +131 -0
- package/dist/prod/packages/shared-chunks/transform-resolutions-C7wq_Q_c.js +6939 -0
- package/dist/prod/packages/shared-chunks/unrecognized-url-error-DDBwfzdm.js +537 -0
- package/docs/data.json +3009 -2358
- package/lib/index.js +157 -279
- package/package.json +27 -58
- package/types/stable/@ember/-internals/deprecations/index.d.ts +0 -6
- package/types/stable/@ember/-internals/environment/index.d.ts +0 -1
- package/types/stable/@ember/-internals/environment/lib/env.d.ts +0 -3
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/curly.d.ts +3 -6
- package/types/stable/@ember/-internals/glimmer/lib/component-managers/root.d.ts +1 -2
- package/types/stable/@ember/-internals/glimmer/lib/helper.d.ts +22 -29
- package/types/stable/@ember/-internals/glimmer/lib/renderer.d.ts +2 -2
- package/types/stable/@ember/-internals/glimmer/lib/resolver.d.ts +0 -2
- package/types/stable/@ember/-internals/glimmer/lib/utils/bindings.d.ts +0 -1
- package/types/stable/@ember/-internals/meta/lib/meta.d.ts +1 -1
- package/types/stable/@ember/-internals/metal/lib/alias.d.ts +0 -11
- package/types/stable/@ember/-internals/metal/lib/decorator.d.ts +0 -1
- package/types/stable/@ember/-internals/metal/lib/each_proxy_events.d.ts +0 -1
- package/types/stable/@ember/-internals/metal/lib/observer.d.ts +0 -2
- package/types/stable/@ember/-internals/metal/lib/property_get.d.ts +4 -10
- package/types/stable/@ember/-internals/utils/index.d.ts +0 -1
- package/types/stable/@ember/-internals/views/lib/system/utils.d.ts +3 -15
- package/types/stable/@ember/application/index.d.ts +2 -63
- package/types/stable/@ember/routing/history-location.d.ts +0 -1
- package/types/stable/@ember/routing/lib/location-utils.d.ts +1 -2
- package/types/stable/@ember/routing/none-location.d.ts +1 -2
- package/types/stable/@ember/template-compiler/index.d.ts +1 -0
- package/types/stable/@ember/template-compiler/lib/plugins/allowed-globals.d.ts +26 -0
- package/types/stable/@ember/test/index.d.ts +0 -3
- package/types/stable/@glimmer/interfaces/lib/compile/wire-format/api.d.ts +1 -1
- package/types/stable/@glimmer/interfaces/lib/template.d.ts +1 -1
- package/types/stable/@glimmer/program/lib/program.d.ts +0 -1
- package/types/stable/@glimmer/validator/lib/collections/map.d.ts +1 -1
- package/types/stable/@handlebars/parser/types/ast.d.ts +148 -0
- package/types/stable/@handlebars/parser/types/index.d.ts +13 -0
- package/types/stable/ember-template-compiler/index.d.ts +0 -2
- package/types/stable/ember-template-compiler/lib/public-api.d.ts +0 -1
- package/types/stable/ember-testing/lib/public-api.d.ts +0 -6
- package/types/stable/ember-testing/lib/test/pending_requests.d.ts +0 -3
- package/types/stable/ember-testing/lib/test.d.ts +0 -23
- package/types/stable/index.d.ts +15 -32
- package/types/stable/router_js/index.d.ts +7 -0
- package/types/stable/router_js/lib/core.d.ts +9 -0
- package/types/stable/router_js/lib/route-info.d.ts +107 -0
- package/types/stable/router_js/lib/router.d.ts +245 -0
- package/types/stable/router_js/lib/transition-aborted-error.d.ts +15 -0
- package/types/stable/router_js/lib/transition-intent/named-transition-intent.d.ts +23 -0
- package/types/stable/router_js/lib/transition-intent/url-transition-intent.d.ts +12 -0
- package/types/stable/router_js/lib/transition-intent.d.ts +13 -0
- package/types/stable/router_js/lib/transition-state.d.ts +25 -0
- package/types/stable/router_js/lib/transition.d.ts +241 -0
- package/types/stable/router_js/lib/unrecognized-url-error.d.ts +11 -0
- package/types/stable/router_js/lib/utils.d.ts +41 -0
- package/dist/ember-template-compiler.js +0 -20631
- package/dist/ember-template-compiler.js.map +0 -1
- package/dist/ember-testing.js +0 -1351
- package/dist/ember-testing.js.map +0 -1
- package/dist/ember.debug.js +0 -52306
- package/dist/ember.debug.js.map +0 -1
- package/dist/ember.prod.js +0 -49369
- package/dist/ember.prod.js.map +0 -1
- package/dist/packages/@ember/-internals/container/index.js +0 -1
- package/dist/packages/@ember/-internals/environment/index.js +0 -1
- package/dist/packages/@ember/-internals/glimmer/index.js +0 -18
- package/dist/packages/@ember/-internals/metal/index.js +0 -51
- package/dist/packages/@ember/-internals/utils/index.js +0 -7
- package/dist/packages/@ember/application/lib/lazy_load.js +0 -68
- package/dist/packages/@ember/component/helper.js +0 -14
- package/dist/packages/@ember/modifier/index.js +0 -23
- package/dist/packages/@ember/object/-internals.js +0 -35
- package/dist/packages/@ember/object/events.js +0 -12
- package/dist/packages/@ember/object/observers.js +0 -12
- package/dist/packages/@ember/renderer/index.js +0 -14
- package/dist/packages/@ember/routing/index.js +0 -14
- package/dist/packages/@ember/template/index.js +0 -14
- package/dist/packages/@ember/template-factory/index.js +0 -8
- package/dist/packages/@ember/test/index.js +0 -27
- package/dist/packages/@glimmer/encoder/index.js +0 -1
- package/dist/packages/@glimmer/manager/index.js +0 -5
- package/dist/packages/@glimmer/node/index.js +0 -2
- package/dist/packages/@glimmer/program/index.js +0 -3
- package/dist/packages/@glimmer/reference/index.js +0 -2
- package/dist/packages/@glimmer/tracking/index.js +0 -48
- package/dist/packages/@glimmer/tracking/primitives/cache/index.js +0 -12
- package/dist/packages/ember/barrel.js +0 -511
- package/dist/packages/ember/index.js +0 -20
- package/dist/packages/ember-template-compiler/index.js +0 -17135
- package/dist/packages/ember-testing/lib/adapters/qunit.js +0 -53
- package/dist/packages/ember-testing/lib/ext/application.js +0 -174
- package/dist/packages/ember-testing/lib/ext/rsvp.js +0 -17
- package/dist/packages/ember-testing/lib/helpers/and_then.js +0 -11
- package/dist/packages/ember-testing/lib/helpers/current_path.js +0 -32
- package/dist/packages/ember-testing/lib/helpers/current_route_name.js +0 -32
- package/dist/packages/ember-testing/lib/helpers/current_url.js +0 -29
- package/dist/packages/ember-testing/lib/helpers/pause_test.js +0 -76
- package/dist/packages/ember-testing/lib/helpers/visit.js +0 -51
- package/dist/packages/ember-testing/lib/helpers/wait.js +0 -55
- package/dist/packages/ember-testing/lib/helpers.js +0 -17
- package/dist/packages/ember-testing/lib/initializers.js +0 -56
- package/dist/packages/ember-testing/lib/public-api.js +0 -8
- package/dist/packages/ember-testing/lib/setup_for_testing.js +0 -31
- package/dist/packages/ember-testing/lib/test/helpers.js +0 -133
- package/dist/packages/ember-testing/lib/test/on_inject_helpers.js +0 -39
- package/dist/packages/ember-testing/lib/test/pending_requests.js +0 -22
- package/dist/packages/ember-testing/lib/test/promise.js +0 -83
- package/dist/packages/ember-testing/lib/test/run.js +0 -11
- package/dist/packages/ember-testing/lib/test.js +0 -68
- package/dist/packages/router_js/index.js +0 -2
- package/dist/packages/shared-chunks/helpers-C1rIkuSd.js +0 -11
- package/dist/packages/shared-chunks/invoke-BjRgvK2V.js +0 -27
- package/dist/packages/shared-chunks/public-api-BQsJemZG.js +0 -20
- package/dist/packages/shared-chunks/template_registry-DigcUg9m.js +0 -24
- package/dist/packages/shared-chunks/to-string-CqD7_vQ4.js +0 -60
- package/types/stable/@ember/-internals/environment/lib/global.d.ts +0 -4
- package/types/stable/@ember/-internals/glimmer/lib/modifiers/internal.d.ts +0 -34
- package/types/stable/@ember/-internals/glimmer/lib/syntax/utils.d.ts +0 -5
- package/types/stable/@ember/-internals/glimmer/lib/templates/empty.d.ts +0 -4
- package/types/stable/@ember/-internals/glimmer/lib/utils/debug-render-message.d.ts +0 -4
- package/types/stable/@ember/-internals/metal/lib/dependent_keys.d.ts +0 -3
- package/types/stable/@ember/-internals/utils/lib/symbol.d.ts +0 -5
- package/types/stable/@ember/application/lib/lazy_load.d.ts +0 -38
- package/types/stable/@ember/template-compiler/lib/public-types.d.ts +0 -3
- package/types/stable/ember/barrel.d.ts +0 -358
- package/types/stable/ember/index.d.ts +0 -358
- package/types/stable/ember-template-compiler/lib/system/bootstrap.d.ts +0 -26
- package/types/stable/ember-template-compiler/lib/system/initializer.d.ts +0 -3
- package/types/stable/ember-testing/lib/adapters/qunit.d.ts +0 -22
- package/types/stable/ember-testing/lib/ext/application.d.ts +0 -12
- package/types/stable/ember-testing/lib/ext/rsvp.d.ts +0 -4
- package/types/stable/ember-testing/lib/helpers/and_then.d.ts +0 -4
- package/types/stable/ember-testing/lib/helpers/current_path.d.ts +0 -22
- package/types/stable/ember-testing/lib/helpers/current_route_name.d.ts +0 -21
- package/types/stable/ember-testing/lib/helpers/current_url.d.ts +0 -22
- package/types/stable/ember-testing/lib/helpers/pause_test.d.ts +0 -52
- package/types/stable/ember-testing/lib/helpers/visit.d.ts +0 -22
- package/types/stable/ember-testing/lib/helpers/wait.d.ts +0 -34
- package/types/stable/ember-testing/lib/helpers.d.ts +0 -3
- package/types/stable/ember-testing/lib/initializers.d.ts +0 -3
- package/types/stable/ember-testing/lib/setup_for_testing.d.ts +0 -15
- package/types/stable/ember-testing/lib/test/helpers.d.ts +0 -116
- package/types/stable/ember-testing/lib/test/on_inject_helpers.d.ts +0 -33
- package/types/stable/ember-testing/lib/test/promise.d.ts +0 -37
- package/types/stable/ember-testing/lib/test/run.d.ts +0 -3
- package/types/stable/loader/lib/index.d.ts +0 -4
- package/types/stable/require.d.ts +0 -4
- /package/dist/{packages → dev/packages}/@ember/-internals/browser-environment/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/error-handling/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/meta/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/owner/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/runtime/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/runtime/lib/mixins/comparable.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/runtime/lib/mixins/container_proxy.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/utility-types/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/views/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/views/lib/compat/attrs.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/-internals/views/lib/component_lookup.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/array/-internals.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/array/lib/make-array.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/array/make.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/array/mutable.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/debug/lib/capture-render-tree.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/debug/lib/inspect.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/debug/lib/testing.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/deprecated-features/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/destroyable/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/engine/lib/engine-parent.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/engine/parent.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/enumerable/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/enumerable/mutable.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/object/proxy.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/owner/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/reactive/collections.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/reactive/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/routing/lib/cache.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/routing/lib/controller_for.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/routing/lib/query_params.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/routing/lib/router_state.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/-internal-primitives.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/-internal-utils.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/-internal/primitives.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/transform-action-syntax.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/transform-each-in-into-each.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/transform-wrap-mount-and-outlet.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/plugins/utils.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/public-api.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/runtime.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/lib/system/calculate-location-display.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/template-compiler/runtime.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/test/adapter.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/utils/index.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/utils/lib/is-equal.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/utils/lib/is_blank.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/utils/lib/is_none.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/utils/lib/is_present.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/utils/lib/type-of.js +0 -0
- /package/dist/{packages → dev/packages}/@ember/version/index.js +0 -0
- /package/dist/{packages → dev/packages}/@glimmer/env/index.js +0 -0
- /package/dist/{packages → dev/packages}/@glimmer/owner/index.js +0 -0
- /package/dist/{packages → dev/packages}/@glimmer/wire-format/index.js +0 -0
- /package/dist/{packages → dev/packages}/@simple-dom/document/index.js +0 -0
- /package/dist/{packages → dev/packages}/backburner.js/index.js +0 -0
- /package/dist/{packages → dev/packages}/dag-map/index.js +0 -0
- /package/dist/{packages → dev/packages}/ember-testing/lib/adapters/adapter.js +0 -0
- /package/dist/{packages → dev/packages}/ember-testing/lib/test/adapter.js +0 -0
- /package/dist/{packages → dev/packages}/ember-testing/lib/test/waiters.js +0 -0
- /package/dist/{packages → dev/packages}/route-recognizer/index.js +0 -0
- /package/dist/{packages → dev/packages}/rsvp/index.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/array-utils-CZQxrdD3.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/assert-CUCJBR2C.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/cache-qDyqAcpg.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/chunk-3SQBS3Y5-Cj4eryg1.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/computed_cache-DmYKevAP.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/debug-brand-B1TWjOCH.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/dictionary-gc5gpyOG.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/index-BGP1rw3B.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/object-utils-AijlD-JH.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/present-B1rrjAVM.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/registers-ylirb0dq.js +0 -0
- /package/dist/{packages → dev/packages}/shared-chunks/rsvp-CnCSY930.js +0 -0
- /package/dist/{packages → prod/packages}/@ember/routing/-internals.js +0 -0
- /package/dist/{packages/@ember/template-compiler/index.js → prod/packages/@ember/template-compiler/runtime.js} +0 -0
|
@@ -0,0 +1,1904 @@
|
|
|
1
|
+
import { z as VM_PRIMITIVE_OP, m as VM_RETURN_OP, aP as encodeHandle, aQ as isMachineOp, aF as VM_CONCAT_OP, aw as VM_GET_VARIABLE_OP, y as VM_CONSTANT_REFERENCE_OP, aA as VM_GET_PROPERTY_OP, aD as VM_HAS_BLOCK_OP, aC as VM_SPREAD_BLOCK_OP, N as VM_COMPILE_BLOCK_OP, aE as VM_HAS_BLOCK_PARAMS_OP, aG as VM_IF_INLINE_OP, aH as VM_NOT_OP, aI as VM_GET_DYNAMIC_VAR_OP, q as VM_PUSH_FRAME_OP, aJ as VM_LOG_OP, p as VM_POP_FRAME_OP, H as VM_FETCH_OP, D as VM_PRIMITIVE_REFERENCE_OP, av as VM_HELPER_OP, E as VM_DUP_OP, at as VM_DYNAMIC_HELPER_OP, F as VM_POP_OP, a9 as VM_CAPTURE_ARGS_OP, as as VM_CURRY_OP, aR as isSmallInt, aS as encodeImmediate, u as VM_PUSH_DYNAMIC_SCOPE_OP, I as VM_BIND_DYNAMIC_SCOPE_OP, v as VM_POP_DYNAMIC_SCOPE_OP, aB as VM_GET_BLOCK_OP, O as VM_INVOKE_YIELD_OP, t as VM_POP_SCOPE_OP, s as VM_CHILD_SCOPE_OP, ax as VM_SET_VARIABLE_OP, o as VM_INVOKE_VIRTUAL_OP, w as VM_CONSTANT_OP, M as VM_PUSH_BLOCK_SCOPE_OP, L as VM_PUSH_SYMBOL_TABLE_OP, a8 as VM_PUSH_EMPTY_ARGS_OP, a7 as VM_PUSH_ARGS_OP, J as VM_ENTER_OP, R as VM_JUMP_EQ_OP, n as VM_JUMP_OP, K as VM_EXIT_OP, l as VM_RETURN_TO_OP, Q as VM_JUMP_UNLESS_OP, a5 as VM_PUSH_COMPONENT_DEFINITION_OP, G as VM_LOAD_OP, ad as VM_BEGIN_COMPONENT_TRANSACTION_OP, ab as VM_CREATE_COMPONENT_OP, ac as VM_REGISTER_COMPONENT_DESTRUCTOR_OP, ai as VM_GET_COMPONENT_SELF_OP, az as VM_ROOT_SCOPE_OP, ay as VM_SET_BLOCK_OP, aq as VM_DID_RENDER_LAYOUT_OP, ar as VM_COMMIT_COMPONENT_TRANSACTION_OP, aa as VM_PREPARE_ARGS_OP, am as VM_VIRTUAL_ROOT_SCOPE_OP, an as VM_SET_NAMED_VARIABLES_OP, ao as VM_SET_BLOCKS_OP, ap as VM_INVOKE_COMPONENT_LAYOUT_OP, ae as VM_PUT_COMPONENT_OPERATIONS_OP, X as VM_OPEN_DYNAMIC_ELEMENT_OP, ah as VM_DID_CREATE_ELEMENT_OP, _ as VM_FLUSH_ELEMENT_OP, $ as VM_CLOSE_ELEMENT_OP, f as VM_RESOLVE_CURRIED_COMPONENT_OP, a6 as VM_RESOLVE_DYNAMIC_COMPONENT_OP, g as VM_PUSH_DYNAMIC_COMPONENT_INSTANCE_OP, ak as VM_GET_COMPONENT_LAYOUT_OP, al as VM_POPULATE_LAYOUT_OP, aj as VM_GET_COMPONENT_TAG_NAME_OP, U as VM_COMMENT_OP, a0 as VM_MODIFIER_OP, a1 as VM_DYNAMIC_MODIFIER_OP, a2 as VM_STATIC_ATTR_OP, ag as VM_STATIC_COMPONENT_ATTR_OP, a3 as VM_DYNAMIC_ATTR_OP, af as VM_COMPONENT_ATTR_OP, W as VM_OPEN_ELEMENT_OP, aL as VM_DEBUGGER_OP, T as VM_TEXT_OP, k as VM_INVOKE_STATIC_OP, aK as VM_DYNAMIC_CONTENT_TYPE_OP, Y as VM_PUSH_REMOTE_ELEMENT_OP, Z as VM_POP_REMOTE_ELEMENT_OP, S as VM_TO_BOOLEAN_OP, aM as VM_ENTER_LIST_OP, aO as VM_ITERATE_OP, aN as VM_EXIT_LIST_OP } from './fragment-EpVz5Xuc.js';
|
|
2
|
+
import '../@glimmer/validator/index.js';
|
|
3
|
+
import './reference-BNqcwZWH.js';
|
|
4
|
+
import { a as assert } from './assert-CUCJBR2C.js';
|
|
5
|
+
import { e as expect, u as unwrap, S as StackImpl, a as isPresentArray, d as dict } from './collections-GpG8lT2g.js';
|
|
6
|
+
import { SexpOpcodes as opcodes } from '../@glimmer/wire-format/index.js';
|
|
7
|
+
import { e as $v0, c as $fp, $ as $s0, d as $sp, h as $s1 } from './registers-ylirb0dq.js';
|
|
8
|
+
import { b as EMPTY_STRING_ARRAY, E as EMPTY_ARRAY, e as enumerate, r as reverse } from './array-utils-CZQxrdD3.js';
|
|
9
|
+
import { ContentType } from '../@glimmer/vm/index.js';
|
|
10
|
+
import { h as hasCapability } from './capabilities-DGmQ_mz4.js';
|
|
11
|
+
import { A as ARG_SHIFT, M as MACHINE_MASK, I as InternalComponentCapabilities } from './flags-B9qxc-pB.js';
|
|
12
|
+
import { a as assign } from './object-utils-AijlD-JH.js';
|
|
13
|
+
import { InstructionEncoderImpl } from '../@glimmer/encoder/index.js';
|
|
14
|
+
|
|
15
|
+
function isGetLikeTuple(opcode) {
|
|
16
|
+
return Array.isArray(opcode) && opcode.length === 2;
|
|
17
|
+
}
|
|
18
|
+
function makeResolutionTypeVerifier(typeToVerify) {
|
|
19
|
+
return opcode => {
|
|
20
|
+
if (!isGetLikeTuple(opcode)) return false;
|
|
21
|
+
let type = opcode[0];
|
|
22
|
+
return type === opcodes.GetStrictKeyword || type === opcodes.GetLexicalSymbol || type === typeToVerify;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const isGetFreeComponent = makeResolutionTypeVerifier(opcodes.GetFreeAsComponentHead);
|
|
26
|
+
const isGetFreeModifier = makeResolutionTypeVerifier(opcodes.GetFreeAsModifierHead);
|
|
27
|
+
const isGetFreeHelper = makeResolutionTypeVerifier(opcodes.GetFreeAsHelperHead);
|
|
28
|
+
const isGetFreeComponentOrHelper = makeResolutionTypeVerifier(opcodes.GetFreeAsComponentOrHelperHead);
|
|
29
|
+
function assertResolverInvariants(meta) {
|
|
30
|
+
return meta;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* <Foo/>
|
|
35
|
+
* <Foo></Foo>
|
|
36
|
+
* <Foo @arg={{true}} />
|
|
37
|
+
*/
|
|
38
|
+
function resolveComponent(resolver, constants, meta, [, expr, then]) {
|
|
39
|
+
assert(isGetFreeComponent(expr));
|
|
40
|
+
let type = expr[0];
|
|
41
|
+
if (type === opcodes.GetLexicalSymbol) {
|
|
42
|
+
let {
|
|
43
|
+
scopeValues,
|
|
44
|
+
owner,
|
|
45
|
+
symbols: {
|
|
46
|
+
lexical
|
|
47
|
+
}
|
|
48
|
+
} = meta;
|
|
49
|
+
let definition = expect(scopeValues)[expr[1]];
|
|
50
|
+
then(constants.component(definition, expect(owner), false, lexical?.at(expr[1])));
|
|
51
|
+
} else {
|
|
52
|
+
let {
|
|
53
|
+
symbols: {
|
|
54
|
+
upvars
|
|
55
|
+
},
|
|
56
|
+
owner
|
|
57
|
+
} = assertResolverInvariants(meta);
|
|
58
|
+
let name = unwrap(upvars[expr[1]]);
|
|
59
|
+
let definition = resolver?.lookupComponent?.(name, owner) ?? null;
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
62
|
+
then(constants.resolvedComponent(definition, name));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* (helper)
|
|
68
|
+
* (helper arg)
|
|
69
|
+
*/
|
|
70
|
+
function resolveHelper(resolver, constants, meta, [, expr, then]) {
|
|
71
|
+
assert(isGetFreeHelper(expr));
|
|
72
|
+
let type = expr[0];
|
|
73
|
+
if (type === opcodes.GetLexicalSymbol) {
|
|
74
|
+
let {
|
|
75
|
+
scopeValues
|
|
76
|
+
} = meta;
|
|
77
|
+
let definition = expect(scopeValues)[expr[1]];
|
|
78
|
+
then(constants.helper(definition));
|
|
79
|
+
} else if (type === opcodes.GetStrictKeyword) {
|
|
80
|
+
then(lookupBuiltInHelper(expr, resolver, meta, constants));
|
|
81
|
+
} else {
|
|
82
|
+
let {
|
|
83
|
+
symbols: {
|
|
84
|
+
upvars
|
|
85
|
+
},
|
|
86
|
+
owner
|
|
87
|
+
} = assertResolverInvariants(meta);
|
|
88
|
+
let name = unwrap(upvars[expr[1]]);
|
|
89
|
+
let helper = resolver?.lookupHelper?.(name, owner) ?? null;
|
|
90
|
+
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
92
|
+
then(constants.helper(helper, name));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* <div {{modifier}}/>
|
|
98
|
+
* <div {{modifier arg}}/>
|
|
99
|
+
* <Foo {{modifier}}/>
|
|
100
|
+
*/
|
|
101
|
+
function resolveModifier(resolver, constants, meta, [, expr, then]) {
|
|
102
|
+
assert(isGetFreeModifier(expr));
|
|
103
|
+
let type = expr[0];
|
|
104
|
+
if (type === opcodes.GetLexicalSymbol) {
|
|
105
|
+
let {
|
|
106
|
+
scopeValues,
|
|
107
|
+
symbols: {
|
|
108
|
+
lexical
|
|
109
|
+
}
|
|
110
|
+
} = meta;
|
|
111
|
+
let definition = expect(scopeValues)[expr[1]];
|
|
112
|
+
then(constants.modifier(definition, lexical?.at(expr[1]) ?? undefined));
|
|
113
|
+
} else if (type === opcodes.GetStrictKeyword) {
|
|
114
|
+
let {
|
|
115
|
+
symbols: {
|
|
116
|
+
upvars
|
|
117
|
+
}
|
|
118
|
+
} = assertResolverInvariants(meta);
|
|
119
|
+
let name = unwrap(upvars[expr[1]]);
|
|
120
|
+
let modifier = resolver?.lookupBuiltInModifier?.(name) ?? null;
|
|
121
|
+
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
123
|
+
then(constants.modifier(modifier, name));
|
|
124
|
+
} else {
|
|
125
|
+
let {
|
|
126
|
+
symbols: {
|
|
127
|
+
upvars
|
|
128
|
+
},
|
|
129
|
+
owner
|
|
130
|
+
} = assertResolverInvariants(meta);
|
|
131
|
+
let name = unwrap(upvars[expr[1]]);
|
|
132
|
+
let modifier = resolver?.lookupModifier?.(name, owner) ?? null;
|
|
133
|
+
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
135
|
+
then(constants.modifier(modifier));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* {{component-or-helper arg}}
|
|
141
|
+
*/
|
|
142
|
+
function resolveComponentOrHelper(resolver, constants, meta, [, expr, {
|
|
143
|
+
ifComponent,
|
|
144
|
+
ifHelper
|
|
145
|
+
}]) {
|
|
146
|
+
assert(isGetFreeComponentOrHelper(expr));
|
|
147
|
+
let type = expr[0];
|
|
148
|
+
if (type === opcodes.GetLexicalSymbol) {
|
|
149
|
+
let {
|
|
150
|
+
scopeValues,
|
|
151
|
+
owner,
|
|
152
|
+
symbols: {
|
|
153
|
+
lexical
|
|
154
|
+
}
|
|
155
|
+
} = meta;
|
|
156
|
+
let definition = expect(scopeValues)[expr[1]];
|
|
157
|
+
let component = constants.component(definition, expect(owner), true, lexical?.at(expr[1]));
|
|
158
|
+
if (component !== null) {
|
|
159
|
+
ifComponent(component);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
let helper = constants.helper(definition, null, true);
|
|
163
|
+
ifHelper(expect(helper));
|
|
164
|
+
} else if (type === opcodes.GetStrictKeyword) {
|
|
165
|
+
ifHelper(lookupBuiltInHelper(expr, resolver, meta, constants));
|
|
166
|
+
} else {
|
|
167
|
+
let {
|
|
168
|
+
symbols: {
|
|
169
|
+
upvars
|
|
170
|
+
},
|
|
171
|
+
owner
|
|
172
|
+
} = assertResolverInvariants(meta);
|
|
173
|
+
let name = unwrap(upvars[expr[1]]);
|
|
174
|
+
let definition = resolver?.lookupComponent?.(name, owner) ?? null;
|
|
175
|
+
if (definition !== null) {
|
|
176
|
+
ifComponent(constants.resolvedComponent(definition, name));
|
|
177
|
+
} else {
|
|
178
|
+
let helper = resolver?.lookupHelper?.(name, owner) ?? null;
|
|
179
|
+
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
181
|
+
ifHelper(constants.helper(helper, name));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* {{maybeHelperOrComponent}}
|
|
188
|
+
*/
|
|
189
|
+
function resolveOptionalComponentOrHelper(resolver, constants, meta, [, expr, {
|
|
190
|
+
ifComponent,
|
|
191
|
+
ifHelper,
|
|
192
|
+
ifValue
|
|
193
|
+
}]) {
|
|
194
|
+
assert(isGetFreeComponentOrHelper(expr));
|
|
195
|
+
let type = expr[0];
|
|
196
|
+
if (type === opcodes.GetLexicalSymbol) {
|
|
197
|
+
let {
|
|
198
|
+
scopeValues,
|
|
199
|
+
owner,
|
|
200
|
+
symbols: {
|
|
201
|
+
lexical
|
|
202
|
+
}
|
|
203
|
+
} = meta;
|
|
204
|
+
let definition = expect(scopeValues)[expr[1]];
|
|
205
|
+
if (typeof definition !== 'function' && (typeof definition !== 'object' || definition === null)) {
|
|
206
|
+
// The value is not an object, so it can't be a component or helper.
|
|
207
|
+
ifValue(constants.value(definition));
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
let component = constants.component(definition, expect(owner), true, lexical?.at(expr[1]));
|
|
211
|
+
if (component !== null) {
|
|
212
|
+
ifComponent(component);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
let helper = constants.helper(definition, null, true);
|
|
216
|
+
if (helper !== null) {
|
|
217
|
+
ifHelper(helper);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
ifValue(constants.value(definition));
|
|
221
|
+
} else if (type === opcodes.GetStrictKeyword) {
|
|
222
|
+
ifHelper(lookupBuiltInHelper(expr, resolver, meta, constants));
|
|
223
|
+
} else {
|
|
224
|
+
let {
|
|
225
|
+
symbols: {
|
|
226
|
+
upvars
|
|
227
|
+
},
|
|
228
|
+
owner
|
|
229
|
+
} = assertResolverInvariants(meta);
|
|
230
|
+
let name = unwrap(upvars[expr[1]]);
|
|
231
|
+
let definition = resolver?.lookupComponent?.(name, owner) ?? null;
|
|
232
|
+
if (definition !== null) {
|
|
233
|
+
ifComponent(constants.resolvedComponent(definition, name));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
let helper = resolver?.lookupHelper?.(name, owner) ?? null;
|
|
237
|
+
if (helper !== null) {
|
|
238
|
+
ifHelper(constants.helper(helper, name));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function lookupBuiltInHelper(expr, resolver, meta, constants, type) {
|
|
243
|
+
let {
|
|
244
|
+
symbols: {
|
|
245
|
+
upvars
|
|
246
|
+
}
|
|
247
|
+
} = assertResolverInvariants(meta);
|
|
248
|
+
let name = unwrap(upvars[expr[1]]);
|
|
249
|
+
let helper = resolver?.lookupBuiltInHelper?.(name) ?? null;
|
|
250
|
+
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
252
|
+
return constants.helper(helper, name);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const HighLevelResolutionOpcodes = {
|
|
256
|
+
Modifier: 1003,
|
|
257
|
+
Component: 1004,
|
|
258
|
+
Helper: 1005,
|
|
259
|
+
ComponentOrHelper: 1007,
|
|
260
|
+
OptionalComponentOrHelper: 1008,
|
|
261
|
+
Local: 1010,
|
|
262
|
+
TemplateLocal: 1011
|
|
263
|
+
};
|
|
264
|
+
const HighLevelBuilderOpcodes = {
|
|
265
|
+
Label: 1000,
|
|
266
|
+
StartLabels: 1001,
|
|
267
|
+
StopLabels: 1002,
|
|
268
|
+
Start: 1000};
|
|
269
|
+
|
|
270
|
+
const HighLevelOperands = {
|
|
271
|
+
Label: 1,
|
|
272
|
+
IsStrictMode: 2,
|
|
273
|
+
DebugSymbols: 3,
|
|
274
|
+
Block: 4,
|
|
275
|
+
StdLib: 5,
|
|
276
|
+
NonSmallInt: 6,
|
|
277
|
+
SymbolTable: 7,
|
|
278
|
+
Layout: 8
|
|
279
|
+
};
|
|
280
|
+
function labelOperand(value) {
|
|
281
|
+
return {
|
|
282
|
+
type: HighLevelOperands.Label,
|
|
283
|
+
value
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function debugSymbolsOperand(locals, upvars, lexical) {
|
|
287
|
+
return {
|
|
288
|
+
type: HighLevelOperands.DebugSymbols,
|
|
289
|
+
value: {
|
|
290
|
+
locals,
|
|
291
|
+
upvars,
|
|
292
|
+
lexical
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function isStrictMode() {
|
|
297
|
+
return {
|
|
298
|
+
type: HighLevelOperands.IsStrictMode,
|
|
299
|
+
value: undefined
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function blockOperand(value) {
|
|
303
|
+
return {
|
|
304
|
+
type: HighLevelOperands.Block,
|
|
305
|
+
value
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function stdlibOperand(value) {
|
|
309
|
+
return {
|
|
310
|
+
type: HighLevelOperands.StdLib,
|
|
311
|
+
value
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function nonSmallIntOperand(value) {
|
|
315
|
+
return {
|
|
316
|
+
type: HighLevelOperands.NonSmallInt,
|
|
317
|
+
value
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function symbolTableOperand(value) {
|
|
321
|
+
return {
|
|
322
|
+
type: HighLevelOperands.SymbolTable,
|
|
323
|
+
value
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function layoutOperand(value) {
|
|
327
|
+
return {
|
|
328
|
+
type: HighLevelOperands.Layout,
|
|
329
|
+
value
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
class Labels {
|
|
334
|
+
labels = dict();
|
|
335
|
+
targets = [];
|
|
336
|
+
label(name, index) {
|
|
337
|
+
this.labels[name] = index;
|
|
338
|
+
}
|
|
339
|
+
target(at, target) {
|
|
340
|
+
this.targets.push({
|
|
341
|
+
at,
|
|
342
|
+
target
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
patch(heap) {
|
|
346
|
+
let {
|
|
347
|
+
targets,
|
|
348
|
+
labels
|
|
349
|
+
} = this;
|
|
350
|
+
for (const {
|
|
351
|
+
at,
|
|
352
|
+
target
|
|
353
|
+
} of targets) {
|
|
354
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
355
|
+
let address = labels[target] - at;
|
|
356
|
+
assert(heap.getbyaddr(at) === -1);
|
|
357
|
+
heap.setbyaddr(at, address);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function encodeOp(encoder, context, meta, op) {
|
|
362
|
+
let {
|
|
363
|
+
program: {
|
|
364
|
+
constants
|
|
365
|
+
},
|
|
366
|
+
resolver
|
|
367
|
+
} = context;
|
|
368
|
+
if (isBuilderOpcode(op[0])) {
|
|
369
|
+
let [type, ...operands] = op;
|
|
370
|
+
encoder.push(constants, type, ...operands);
|
|
371
|
+
} else {
|
|
372
|
+
switch (op[0]) {
|
|
373
|
+
case HighLevelBuilderOpcodes.Label:
|
|
374
|
+
return encoder.label(op[1]);
|
|
375
|
+
case HighLevelBuilderOpcodes.StartLabels:
|
|
376
|
+
return encoder.startLabels();
|
|
377
|
+
case HighLevelBuilderOpcodes.StopLabels:
|
|
378
|
+
return encoder.stopLabels();
|
|
379
|
+
case HighLevelResolutionOpcodes.Component:
|
|
380
|
+
return resolveComponent(resolver, constants, meta, op);
|
|
381
|
+
case HighLevelResolutionOpcodes.Modifier:
|
|
382
|
+
return resolveModifier(resolver, constants, meta, op);
|
|
383
|
+
case HighLevelResolutionOpcodes.Helper:
|
|
384
|
+
return resolveHelper(resolver, constants, meta, op);
|
|
385
|
+
case HighLevelResolutionOpcodes.ComponentOrHelper:
|
|
386
|
+
return resolveComponentOrHelper(resolver, constants, meta, op);
|
|
387
|
+
case HighLevelResolutionOpcodes.OptionalComponentOrHelper:
|
|
388
|
+
return resolveOptionalComponentOrHelper(resolver, constants, meta, op);
|
|
389
|
+
case HighLevelResolutionOpcodes.Local:
|
|
390
|
+
{
|
|
391
|
+
let [, freeVar, andThen] = op;
|
|
392
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- @fixme
|
|
393
|
+
let name = expect(meta.symbols.upvars)[freeVar];
|
|
394
|
+
andThen(name, meta.moduleName);
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
case HighLevelResolutionOpcodes.TemplateLocal:
|
|
398
|
+
{
|
|
399
|
+
let [, valueIndex, then] = op;
|
|
400
|
+
let value = expect(meta.scopeValues)[valueIndex];
|
|
401
|
+
then(constants.value(value));
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
default:
|
|
405
|
+
throw new Error(`Unexpected high level opcode ${op[0]}`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
class EncoderImpl {
|
|
410
|
+
labelsStack = new StackImpl();
|
|
411
|
+
encoder = new InstructionEncoderImpl([]);
|
|
412
|
+
errors = [];
|
|
413
|
+
handle;
|
|
414
|
+
constructor(heap, meta, stdlib) {
|
|
415
|
+
this.heap = heap;
|
|
416
|
+
this.meta = meta;
|
|
417
|
+
this.stdlib = stdlib;
|
|
418
|
+
this.handle = heap.malloc();
|
|
419
|
+
}
|
|
420
|
+
error(error) {
|
|
421
|
+
this.encoder.encode(VM_PRIMITIVE_OP, 0);
|
|
422
|
+
this.errors.push(error);
|
|
423
|
+
}
|
|
424
|
+
commit(size) {
|
|
425
|
+
let handle = this.handle;
|
|
426
|
+
this.heap.pushMachine(VM_RETURN_OP);
|
|
427
|
+
this.heap.finishMalloc(handle, size);
|
|
428
|
+
if (isPresentArray(this.errors)) {
|
|
429
|
+
return {
|
|
430
|
+
errors: this.errors,
|
|
431
|
+
handle
|
|
432
|
+
};
|
|
433
|
+
} else {
|
|
434
|
+
return handle;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
push(constants, type, ...args) {
|
|
438
|
+
let {
|
|
439
|
+
heap
|
|
440
|
+
} = this;
|
|
441
|
+
let machine = isMachineOp(type) ? MACHINE_MASK : 0;
|
|
442
|
+
let first = type | machine | args.length << ARG_SHIFT;
|
|
443
|
+
heap.pushRaw(first);
|
|
444
|
+
for (let i = 0; i < args.length; i++) {
|
|
445
|
+
let op = args[i];
|
|
446
|
+
heap.pushRaw(this.operand(constants, op));
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
operand(constants, operand) {
|
|
450
|
+
if (typeof operand === 'number') {
|
|
451
|
+
return operand;
|
|
452
|
+
}
|
|
453
|
+
if (typeof operand === 'object' && operand !== null) {
|
|
454
|
+
if (Array.isArray(operand)) {
|
|
455
|
+
return encodeHandle(constants.array(operand));
|
|
456
|
+
} else {
|
|
457
|
+
switch (operand.type) {
|
|
458
|
+
case HighLevelOperands.Label:
|
|
459
|
+
this.currentLabels.target(this.heap.offset, operand.value);
|
|
460
|
+
return -1;
|
|
461
|
+
case HighLevelOperands.IsStrictMode:
|
|
462
|
+
return encodeHandle(constants.value(this.meta.isStrictMode));
|
|
463
|
+
case HighLevelOperands.DebugSymbols:
|
|
464
|
+
return encodeHandle(constants.value(operand.value));
|
|
465
|
+
case HighLevelOperands.Block:
|
|
466
|
+
return encodeHandle(constants.value(compilableBlock(operand.value, this.meta)));
|
|
467
|
+
case HighLevelOperands.StdLib:
|
|
468
|
+
return expect(this.stdlib)[operand.value];
|
|
469
|
+
case HighLevelOperands.NonSmallInt:
|
|
470
|
+
case HighLevelOperands.SymbolTable:
|
|
471
|
+
case HighLevelOperands.Layout:
|
|
472
|
+
return constants.value(operand.value);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return encodeHandle(constants.value(operand));
|
|
477
|
+
}
|
|
478
|
+
get currentLabels() {
|
|
479
|
+
return expect(this.labelsStack.current);
|
|
480
|
+
}
|
|
481
|
+
label(name) {
|
|
482
|
+
this.currentLabels.label(name, this.heap.offset + 1);
|
|
483
|
+
}
|
|
484
|
+
startLabels() {
|
|
485
|
+
this.labelsStack.push(new Labels());
|
|
486
|
+
}
|
|
487
|
+
stopLabels() {
|
|
488
|
+
let label = expect(this.labelsStack.pop());
|
|
489
|
+
label.patch(this.heap);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function isBuilderOpcode(op) {
|
|
493
|
+
return op < HighLevelBuilderOpcodes.Start;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function templateCompilationContext(evaluation, meta) {
|
|
497
|
+
let encoder = new EncoderImpl(evaluation.program.heap, meta, evaluation.stdlib);
|
|
498
|
+
return {
|
|
499
|
+
evaluation,
|
|
500
|
+
encoder,
|
|
501
|
+
meta
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
class Compilers {
|
|
506
|
+
names = {};
|
|
507
|
+
|
|
508
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
509
|
+
funcs = [];
|
|
510
|
+
add(name, func) {
|
|
511
|
+
this.names[name] = this.funcs.push(func) - 1;
|
|
512
|
+
}
|
|
513
|
+
compile(op, sexp) {
|
|
514
|
+
let name = sexp[0];
|
|
515
|
+
let index = unwrap(this.names[name]);
|
|
516
|
+
let func = this.funcs[index];
|
|
517
|
+
assert(func, `expected an implementation for ${sexp[0]}`);
|
|
518
|
+
func(op, sexp);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
const EXPRESSIONS = new Compilers();
|
|
523
|
+
EXPRESSIONS.add(opcodes.Concat, (op, [, parts]) => {
|
|
524
|
+
for (let part of parts) {
|
|
525
|
+
expr(op, part);
|
|
526
|
+
}
|
|
527
|
+
op(VM_CONCAT_OP, parts.length);
|
|
528
|
+
});
|
|
529
|
+
EXPRESSIONS.add(opcodes.Call, (op, [, expression, positional, named]) => {
|
|
530
|
+
if (isGetFreeHelper(expression)) {
|
|
531
|
+
op(HighLevelResolutionOpcodes.Helper, expression, handle => {
|
|
532
|
+
Call(op, handle, positional, named);
|
|
533
|
+
});
|
|
534
|
+
} else {
|
|
535
|
+
expr(op, expression);
|
|
536
|
+
CallDynamic(op, positional, named);
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
EXPRESSIONS.add(opcodes.Curry, (op, [, expr, type, positional, named]) => {
|
|
540
|
+
Curry(op, type, expr, positional, named);
|
|
541
|
+
});
|
|
542
|
+
EXPRESSIONS.add(opcodes.GetSymbol, (op, [, sym, path]) => {
|
|
543
|
+
op(VM_GET_VARIABLE_OP, sym);
|
|
544
|
+
withPath(op, path);
|
|
545
|
+
});
|
|
546
|
+
EXPRESSIONS.add(opcodes.GetLexicalSymbol, (op, [, sym, path]) => {
|
|
547
|
+
op(HighLevelResolutionOpcodes.TemplateLocal, sym, handle => {
|
|
548
|
+
op(VM_CONSTANT_REFERENCE_OP, handle);
|
|
549
|
+
withPath(op, path);
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
EXPRESSIONS.add(opcodes.GetStrictKeyword, (op, expr) => {
|
|
553
|
+
op(HighLevelResolutionOpcodes.Local, expr[1], _name => {
|
|
554
|
+
op(HighLevelResolutionOpcodes.Helper, expr, handle => {
|
|
555
|
+
Call(op, handle, null, null);
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
EXPRESSIONS.add(opcodes.GetFreeAsHelperHead, (op, expr) => {
|
|
560
|
+
op(HighLevelResolutionOpcodes.Local, expr[1], _name => {
|
|
561
|
+
op(HighLevelResolutionOpcodes.Helper, expr, handle => {
|
|
562
|
+
Call(op, handle, null, null);
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
function withPath(op, path) {
|
|
567
|
+
if (path === undefined || path.length === 0) return;
|
|
568
|
+
for (let i = 0; i < path.length; i++) {
|
|
569
|
+
op(VM_GET_PROPERTY_OP, path[i]);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
EXPRESSIONS.add(opcodes.Undefined, op => PushPrimitiveReference(op, undefined));
|
|
573
|
+
EXPRESSIONS.add(opcodes.HasBlock, (op, [, block]) => {
|
|
574
|
+
expr(op, block);
|
|
575
|
+
op(VM_HAS_BLOCK_OP);
|
|
576
|
+
});
|
|
577
|
+
EXPRESSIONS.add(opcodes.HasBlockParams, (op, [, block]) => {
|
|
578
|
+
expr(op, block);
|
|
579
|
+
op(VM_SPREAD_BLOCK_OP);
|
|
580
|
+
op(VM_COMPILE_BLOCK_OP);
|
|
581
|
+
op(VM_HAS_BLOCK_PARAMS_OP);
|
|
582
|
+
});
|
|
583
|
+
EXPRESSIONS.add(opcodes.IfInline, (op, [, condition, truthy, falsy]) => {
|
|
584
|
+
// Push in reverse order
|
|
585
|
+
expr(op, falsy);
|
|
586
|
+
expr(op, truthy);
|
|
587
|
+
expr(op, condition);
|
|
588
|
+
op(VM_IF_INLINE_OP);
|
|
589
|
+
});
|
|
590
|
+
EXPRESSIONS.add(opcodes.Not, (op, [, value]) => {
|
|
591
|
+
expr(op, value);
|
|
592
|
+
op(VM_NOT_OP);
|
|
593
|
+
});
|
|
594
|
+
EXPRESSIONS.add(opcodes.GetDynamicVar, (op, [, expression]) => {
|
|
595
|
+
expr(op, expression);
|
|
596
|
+
op(VM_GET_DYNAMIC_VAR_OP);
|
|
597
|
+
});
|
|
598
|
+
EXPRESSIONS.add(opcodes.Log, (op, [, positional]) => {
|
|
599
|
+
op(VM_PUSH_FRAME_OP);
|
|
600
|
+
SimpleArgs(op, positional, null, false);
|
|
601
|
+
op(VM_LOG_OP);
|
|
602
|
+
op(VM_POP_FRAME_OP);
|
|
603
|
+
op(VM_FETCH_OP, $v0);
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
function expr(op, expression) {
|
|
607
|
+
if (Array.isArray(expression)) {
|
|
608
|
+
EXPRESSIONS.compile(op, expression);
|
|
609
|
+
} else {
|
|
610
|
+
PushPrimitive(op, expression);
|
|
611
|
+
op(VM_PRIMITIVE_REFERENCE_OP);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Push a reference onto the stack corresponding to a statically known primitive
|
|
617
|
+
* @param value A JavaScript primitive (undefined, null, boolean, number or string)
|
|
618
|
+
*/
|
|
619
|
+
function PushPrimitiveReference(op, value) {
|
|
620
|
+
PushPrimitive(op, value);
|
|
621
|
+
op(VM_PRIMITIVE_REFERENCE_OP);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Push an encoded representation of a JavaScript primitive on the stack
|
|
626
|
+
*
|
|
627
|
+
* @param value A JavaScript primitive (undefined, null, boolean, number or string)
|
|
628
|
+
*/
|
|
629
|
+
function PushPrimitive(op, primitive) {
|
|
630
|
+
let p = primitive;
|
|
631
|
+
if (typeof p === 'number') {
|
|
632
|
+
p = isSmallInt(p) ? encodeImmediate(p) : nonSmallIntOperand(p);
|
|
633
|
+
}
|
|
634
|
+
op(VM_PRIMITIVE_OP, p);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Invoke a foreign function (a "helper") based on a statically known handle
|
|
639
|
+
*
|
|
640
|
+
* @param op The op creation function
|
|
641
|
+
* @param handle A handle
|
|
642
|
+
* @param positional An optional list of expressions to compile
|
|
643
|
+
* @param named An optional list of named arguments (name + expression) to compile
|
|
644
|
+
*/
|
|
645
|
+
function Call(op, handle, positional, named) {
|
|
646
|
+
op(VM_PUSH_FRAME_OP);
|
|
647
|
+
SimpleArgs(op, positional, named, false);
|
|
648
|
+
op(VM_HELPER_OP, handle);
|
|
649
|
+
op(VM_POP_FRAME_OP);
|
|
650
|
+
op(VM_FETCH_OP, $v0);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Invoke a foreign function (a "helper") based on a dynamically loaded definition
|
|
655
|
+
*
|
|
656
|
+
* @param op The op creation function
|
|
657
|
+
* @param positional An optional list of expressions to compile
|
|
658
|
+
* @param named An optional list of named arguments (name + expression) to compile
|
|
659
|
+
*/
|
|
660
|
+
function CallDynamic(op, positional, named, append) {
|
|
661
|
+
op(VM_PUSH_FRAME_OP);
|
|
662
|
+
SimpleArgs(op, positional, named, false);
|
|
663
|
+
op(VM_DUP_OP, $fp, 1);
|
|
664
|
+
op(VM_DYNAMIC_HELPER_OP);
|
|
665
|
+
if (append) {
|
|
666
|
+
op(VM_FETCH_OP, $v0);
|
|
667
|
+
append();
|
|
668
|
+
op(VM_POP_FRAME_OP);
|
|
669
|
+
op(VM_POP_OP, 1);
|
|
670
|
+
} else {
|
|
671
|
+
op(VM_POP_FRAME_OP);
|
|
672
|
+
op(VM_POP_OP, 1);
|
|
673
|
+
op(VM_FETCH_OP, $v0);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Evaluate statements in the context of new dynamic scope entries. Move entries from the
|
|
679
|
+
* stack into named entries in the dynamic scope, then evaluate the statements, then pop
|
|
680
|
+
* the dynamic scope
|
|
681
|
+
*
|
|
682
|
+
* @param names a list of dynamic scope names
|
|
683
|
+
* @param block a function that returns a list of statements to evaluate
|
|
684
|
+
*/
|
|
685
|
+
function DynamicScope(op, names, block) {
|
|
686
|
+
op(VM_PUSH_DYNAMIC_SCOPE_OP);
|
|
687
|
+
op(VM_BIND_DYNAMIC_SCOPE_OP, names);
|
|
688
|
+
block();
|
|
689
|
+
op(VM_POP_DYNAMIC_SCOPE_OP);
|
|
690
|
+
}
|
|
691
|
+
function Curry(op, type, definition, positional, named) {
|
|
692
|
+
op(VM_PUSH_FRAME_OP);
|
|
693
|
+
SimpleArgs(op, positional, named, false);
|
|
694
|
+
op(VM_CAPTURE_ARGS_OP);
|
|
695
|
+
expr(op, definition);
|
|
696
|
+
op(VM_CURRY_OP, type, isStrictMode());
|
|
697
|
+
op(VM_POP_FRAME_OP);
|
|
698
|
+
op(VM_FETCH_OP, $v0);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Yield to a block located at a particular symbol location.
|
|
703
|
+
*
|
|
704
|
+
* @param to the symbol containing the block to yield to
|
|
705
|
+
* @param params optional block parameters to yield to the block
|
|
706
|
+
*/
|
|
707
|
+
function YieldBlock(op, to, positional) {
|
|
708
|
+
SimpleArgs(op, positional, null, true);
|
|
709
|
+
op(VM_GET_BLOCK_OP, to);
|
|
710
|
+
op(VM_SPREAD_BLOCK_OP);
|
|
711
|
+
op(VM_COMPILE_BLOCK_OP);
|
|
712
|
+
op(VM_INVOKE_YIELD_OP);
|
|
713
|
+
op(VM_POP_SCOPE_OP);
|
|
714
|
+
op(VM_POP_FRAME_OP);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Push an (optional) yieldable block onto the stack. The yieldable block must be known
|
|
719
|
+
* statically at compile time.
|
|
720
|
+
*
|
|
721
|
+
* @param block An optional Compilable block
|
|
722
|
+
*/
|
|
723
|
+
function PushYieldableBlock(op, block) {
|
|
724
|
+
PushSymbolTable(op, block && block[1]);
|
|
725
|
+
op(VM_PUSH_BLOCK_SCOPE_OP);
|
|
726
|
+
PushCompilable(op, block);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Invoke a block that is known statically at compile time.
|
|
731
|
+
*
|
|
732
|
+
* @param block a Compilable block
|
|
733
|
+
*/
|
|
734
|
+
function InvokeStaticBlock(op, block) {
|
|
735
|
+
op(VM_PUSH_FRAME_OP);
|
|
736
|
+
PushCompilable(op, block);
|
|
737
|
+
op(VM_COMPILE_BLOCK_OP);
|
|
738
|
+
op(VM_INVOKE_VIRTUAL_OP);
|
|
739
|
+
op(VM_POP_FRAME_OP);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Invoke a static block, preserving some number of stack entries for use in
|
|
744
|
+
* updating.
|
|
745
|
+
*
|
|
746
|
+
* @param block A compilable block
|
|
747
|
+
* @param callerCount A number of stack entries to preserve
|
|
748
|
+
*/
|
|
749
|
+
function InvokeStaticBlockWithStack(op, block, callerCount) {
|
|
750
|
+
let parameters = block[1];
|
|
751
|
+
let calleeCount = parameters.length;
|
|
752
|
+
let count = Math.min(callerCount, calleeCount);
|
|
753
|
+
if (count === 0) {
|
|
754
|
+
InvokeStaticBlock(op, block);
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
op(VM_PUSH_FRAME_OP);
|
|
758
|
+
if (count) {
|
|
759
|
+
op(VM_CHILD_SCOPE_OP);
|
|
760
|
+
for (let i = 0; i < count; i++) {
|
|
761
|
+
op(VM_DUP_OP, $fp, callerCount - i);
|
|
762
|
+
op(VM_SET_VARIABLE_OP, parameters[i]);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
PushCompilable(op, block);
|
|
766
|
+
op(VM_COMPILE_BLOCK_OP);
|
|
767
|
+
op(VM_INVOKE_VIRTUAL_OP);
|
|
768
|
+
if (count) {
|
|
769
|
+
op(VM_POP_SCOPE_OP);
|
|
770
|
+
}
|
|
771
|
+
op(VM_POP_FRAME_OP);
|
|
772
|
+
}
|
|
773
|
+
function PushSymbolTable(op, parameters) {
|
|
774
|
+
if (parameters !== null) {
|
|
775
|
+
op(VM_PUSH_SYMBOL_TABLE_OP, symbolTableOperand({
|
|
776
|
+
parameters
|
|
777
|
+
}));
|
|
778
|
+
} else {
|
|
779
|
+
PushPrimitive(op, null);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function PushCompilable(op, _block) {
|
|
783
|
+
if (_block === null) {
|
|
784
|
+
PushPrimitive(op, null);
|
|
785
|
+
} else {
|
|
786
|
+
op(VM_CONSTANT_OP, blockOperand(_block));
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Compile arguments, pushing an Arguments object onto the stack.
|
|
792
|
+
*
|
|
793
|
+
* @param args.params
|
|
794
|
+
* @param args.hash
|
|
795
|
+
* @param args.blocks
|
|
796
|
+
* @param args.atNames
|
|
797
|
+
*/
|
|
798
|
+
function CompileArgs(op, positional, named, blocks, atNames) {
|
|
799
|
+
let blockNames = blocks.names;
|
|
800
|
+
for (const name of blockNames) {
|
|
801
|
+
PushYieldableBlock(op, blocks.get(name));
|
|
802
|
+
}
|
|
803
|
+
let count = CompilePositional(op, positional);
|
|
804
|
+
let flags = count << 4;
|
|
805
|
+
if (atNames) flags |= 0b1000;
|
|
806
|
+
if (blocks.hasAny) {
|
|
807
|
+
flags |= 0b111;
|
|
808
|
+
}
|
|
809
|
+
let names = EMPTY_ARRAY;
|
|
810
|
+
if (named) {
|
|
811
|
+
names = named[0];
|
|
812
|
+
let val = named[1];
|
|
813
|
+
for (let i = 0; i < val.length; i++) {
|
|
814
|
+
expr(op, val[i]);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
op(VM_PUSH_ARGS_OP, names, blockNames, flags);
|
|
818
|
+
}
|
|
819
|
+
function SimpleArgs(op, positional, named, atNames) {
|
|
820
|
+
if (positional === null && named === null) {
|
|
821
|
+
op(VM_PUSH_EMPTY_ARGS_OP);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
let count = CompilePositional(op, positional);
|
|
825
|
+
let flags = count << 4;
|
|
826
|
+
if (atNames) flags |= 0b1000;
|
|
827
|
+
let names = EMPTY_STRING_ARRAY;
|
|
828
|
+
if (named) {
|
|
829
|
+
names = named[0];
|
|
830
|
+
let val = named[1];
|
|
831
|
+
for (let i = 0; i < val.length; i++) {
|
|
832
|
+
expr(op, val[i]);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
op(VM_PUSH_ARGS_OP, names, EMPTY_STRING_ARRAY, flags);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Compile an optional list of positional arguments, which pushes each argument
|
|
840
|
+
* onto the stack and returns the number of parameters compiled
|
|
841
|
+
*
|
|
842
|
+
* @param positional an optional list of positional arguments
|
|
843
|
+
*/
|
|
844
|
+
function CompilePositional(op, positional) {
|
|
845
|
+
if (positional === null) return 0;
|
|
846
|
+
for (let i = 0; i < positional.length; i++) {
|
|
847
|
+
expr(op, positional[i]);
|
|
848
|
+
}
|
|
849
|
+
return positional.length;
|
|
850
|
+
}
|
|
851
|
+
function meta(layout) {
|
|
852
|
+
let [, locals, upvars, lexicalSymbols] = layout.block;
|
|
853
|
+
let scopeRecord = layout.scope?.() ?? null;
|
|
854
|
+
return {
|
|
855
|
+
symbols: {
|
|
856
|
+
locals,
|
|
857
|
+
upvars,
|
|
858
|
+
lexical: scopeRecord ? Object.keys(scopeRecord) : lexicalSymbols
|
|
859
|
+
},
|
|
860
|
+
scopeValues: scopeRecord ? Object.values(scopeRecord) : null,
|
|
861
|
+
isStrictMode: layout.isStrictMode,
|
|
862
|
+
moduleName: layout.moduleName,
|
|
863
|
+
owner: layout.owner,
|
|
864
|
+
size: locals.length
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
class NamedBlocksImpl {
|
|
869
|
+
names;
|
|
870
|
+
constructor(blocks) {
|
|
871
|
+
this.blocks = blocks;
|
|
872
|
+
this.names = blocks ? Object.keys(blocks) : [];
|
|
873
|
+
}
|
|
874
|
+
get(name) {
|
|
875
|
+
if (!this.blocks) return null;
|
|
876
|
+
return this.blocks[name] || null;
|
|
877
|
+
}
|
|
878
|
+
has(name) {
|
|
879
|
+
let {
|
|
880
|
+
blocks
|
|
881
|
+
} = this;
|
|
882
|
+
return blocks !== null && name in blocks;
|
|
883
|
+
}
|
|
884
|
+
with(name, block) {
|
|
885
|
+
let {
|
|
886
|
+
blocks
|
|
887
|
+
} = this;
|
|
888
|
+
if (blocks) {
|
|
889
|
+
return new NamedBlocksImpl(assign({}, blocks, {
|
|
890
|
+
[name]: block
|
|
891
|
+
}));
|
|
892
|
+
} else {
|
|
893
|
+
return new NamedBlocksImpl({
|
|
894
|
+
[name]: block
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
get hasAny() {
|
|
899
|
+
return this.blocks !== null;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
const EMPTY_BLOCKS = new NamedBlocksImpl(null);
|
|
903
|
+
function namedBlocks(blocks) {
|
|
904
|
+
if (blocks === null) {
|
|
905
|
+
return EMPTY_BLOCKS;
|
|
906
|
+
}
|
|
907
|
+
let out = dict();
|
|
908
|
+
let [keys, values] = blocks;
|
|
909
|
+
for (const [i, key] of enumerate(keys)) {
|
|
910
|
+
out[key] = unwrap(values[i]);
|
|
911
|
+
}
|
|
912
|
+
return new NamedBlocksImpl(out);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
function SwitchCases(op, bootstrap, matcher) {
|
|
916
|
+
// Setup the switch DSL
|
|
917
|
+
let clauses = [];
|
|
918
|
+
let count = 0;
|
|
919
|
+
function when(match, callback) {
|
|
920
|
+
clauses.push({
|
|
921
|
+
match,
|
|
922
|
+
callback,
|
|
923
|
+
label: `CLAUSE${count++}`
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
// Call the callback
|
|
928
|
+
matcher(when);
|
|
929
|
+
|
|
930
|
+
// Emit the opcodes for the switch
|
|
931
|
+
op(VM_ENTER_OP, 1);
|
|
932
|
+
bootstrap();
|
|
933
|
+
op(HighLevelBuilderOpcodes.StartLabels);
|
|
934
|
+
|
|
935
|
+
// First, emit the jump opcodes. We don't need a jump for the last
|
|
936
|
+
// opcode, since it bleeds directly into its clause.
|
|
937
|
+
for (let clause of clauses.slice(0, -1)) {
|
|
938
|
+
op(VM_JUMP_EQ_OP, labelOperand(clause.label), clause.match);
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
// Enumerate the clauses in reverse order. Earlier matches will
|
|
942
|
+
// require fewer checks.
|
|
943
|
+
for (let i = clauses.length - 1; i >= 0; i--) {
|
|
944
|
+
let clause = unwrap(clauses[i]);
|
|
945
|
+
op(HighLevelBuilderOpcodes.Label, clause.label);
|
|
946
|
+
op(VM_POP_OP, 1);
|
|
947
|
+
clause.callback();
|
|
948
|
+
|
|
949
|
+
// The first match is special: it is placed directly before the END
|
|
950
|
+
// label, so no additional jump is needed at the end of it.
|
|
951
|
+
if (i !== 0) {
|
|
952
|
+
op(VM_JUMP_OP, labelOperand('END'));
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
op(HighLevelBuilderOpcodes.Label, 'END');
|
|
956
|
+
op(HighLevelBuilderOpcodes.StopLabels);
|
|
957
|
+
op(VM_EXIT_OP);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* A convenience for pushing some arguments on the stack and
|
|
962
|
+
* running some code if the code needs to be re-executed during
|
|
963
|
+
* updating execution if some of the arguments have changed.
|
|
964
|
+
*
|
|
965
|
+
* # Initial Execution
|
|
966
|
+
*
|
|
967
|
+
* The `args` function should push zero or more arguments onto
|
|
968
|
+
* the stack and return the number of arguments pushed.
|
|
969
|
+
*
|
|
970
|
+
* The `body` function provides the instructions to execute both
|
|
971
|
+
* during initial execution and during updating execution.
|
|
972
|
+
*
|
|
973
|
+
* Internally, this function starts by pushing a new frame, so
|
|
974
|
+
* that the body can return and sets the return point ($ra) to
|
|
975
|
+
* the ENDINITIAL label.
|
|
976
|
+
*
|
|
977
|
+
* It then executes the `args` function, which adds instructions
|
|
978
|
+
* responsible for pushing the arguments for the block to the
|
|
979
|
+
* stack. These arguments will be restored to the stack before
|
|
980
|
+
* updating execution.
|
|
981
|
+
*
|
|
982
|
+
* Next, it adds the Enter opcode, which marks the current position
|
|
983
|
+
* in the DOM, and remembers the current $pc (the next instruction)
|
|
984
|
+
* as the first instruction to execute during updating execution.
|
|
985
|
+
*
|
|
986
|
+
* Next, it runs `body`, which adds the opcodes that should
|
|
987
|
+
* execute both during initial execution and during updating execution.
|
|
988
|
+
* If the `body` wishes to finish early, it should Jump to the
|
|
989
|
+
* `FINALLY` label.
|
|
990
|
+
*
|
|
991
|
+
* Next, it adds the FINALLY label, followed by:
|
|
992
|
+
*
|
|
993
|
+
* - the Exit opcode, which finalizes the marked DOM started by the
|
|
994
|
+
* Enter opcode.
|
|
995
|
+
* - the Return opcode, which returns to the current return point
|
|
996
|
+
* ($ra).
|
|
997
|
+
*
|
|
998
|
+
* Finally, it adds the ENDINITIAL label followed by the PopFrame
|
|
999
|
+
* instruction, which restores $fp, $sp and $ra.
|
|
1000
|
+
*
|
|
1001
|
+
* # Updating Execution
|
|
1002
|
+
*
|
|
1003
|
+
* Updating execution for this `replayable` occurs if the `body` added an
|
|
1004
|
+
* assertion, via one of the `JumpIf`, `JumpUnless` or `AssertSame` opcodes.
|
|
1005
|
+
*
|
|
1006
|
+
* If, during updating executon, the assertion fails, the initial VM is
|
|
1007
|
+
* restored, and the stored arguments are pushed onto the stack. The DOM
|
|
1008
|
+
* between the starting and ending markers is cleared, and the VM's cursor
|
|
1009
|
+
* is set to the area just cleared.
|
|
1010
|
+
*
|
|
1011
|
+
* The return point ($ra) is set to -1, the exit instruction.
|
|
1012
|
+
*
|
|
1013
|
+
* Finally, the $pc is set to to the instruction saved off by the
|
|
1014
|
+
* Enter opcode during initial execution, and execution proceeds as
|
|
1015
|
+
* usual.
|
|
1016
|
+
*
|
|
1017
|
+
* The only difference is that when a `Return` instruction is
|
|
1018
|
+
* encountered, the program jumps to -1 rather than the END label,
|
|
1019
|
+
* and the PopFrame opcode is not needed.
|
|
1020
|
+
*/
|
|
1021
|
+
function Replayable(op, args, body) {
|
|
1022
|
+
// Start a new label frame, to give END and RETURN
|
|
1023
|
+
// a unique meaning.
|
|
1024
|
+
|
|
1025
|
+
op(HighLevelBuilderOpcodes.StartLabels);
|
|
1026
|
+
op(VM_PUSH_FRAME_OP);
|
|
1027
|
+
|
|
1028
|
+
// If the body invokes a block, its return will return to
|
|
1029
|
+
// END. Otherwise, the return in RETURN will return to END.
|
|
1030
|
+
op(VM_RETURN_TO_OP, labelOperand('ENDINITIAL'));
|
|
1031
|
+
|
|
1032
|
+
// Push the arguments onto the stack. The args() function
|
|
1033
|
+
// tells us how many stack elements to retain for re-execution
|
|
1034
|
+
// when updating.
|
|
1035
|
+
let count = args();
|
|
1036
|
+
|
|
1037
|
+
// Start a new updating closure, remembering `count` elements
|
|
1038
|
+
// from the stack. Everything after this point, and before END,
|
|
1039
|
+
// will execute both initially and to update the block.
|
|
1040
|
+
//
|
|
1041
|
+
// The enter and exit opcodes also track the area of the DOM
|
|
1042
|
+
// associated with this block. If an assertion inside the block
|
|
1043
|
+
// fails (for example, the test value changes from true to false
|
|
1044
|
+
// in an #if), the DOM is cleared and the program is re-executed,
|
|
1045
|
+
// restoring `count` elements to the stack and executing the
|
|
1046
|
+
// instructions between the enter and exit.
|
|
1047
|
+
op(VM_ENTER_OP, count);
|
|
1048
|
+
|
|
1049
|
+
// Evaluate the body of the block. The body of the block may
|
|
1050
|
+
// return, which will jump execution to END during initial
|
|
1051
|
+
// execution, and exit the updating routine.
|
|
1052
|
+
body();
|
|
1053
|
+
|
|
1054
|
+
// All execution paths in the body should run the FINALLY once
|
|
1055
|
+
// they are done. It is executed both during initial execution
|
|
1056
|
+
// and during updating execution.
|
|
1057
|
+
op(HighLevelBuilderOpcodes.Label, 'FINALLY');
|
|
1058
|
+
|
|
1059
|
+
// Finalize the DOM.
|
|
1060
|
+
op(VM_EXIT_OP);
|
|
1061
|
+
|
|
1062
|
+
// In initial execution, this is a noop: it returns to the
|
|
1063
|
+
// immediately following opcode. In updating execution, this
|
|
1064
|
+
// exits the updating routine.
|
|
1065
|
+
op(VM_RETURN_OP);
|
|
1066
|
+
|
|
1067
|
+
// Cleanup code for the block. Runs on initial execution
|
|
1068
|
+
// but not on updating.
|
|
1069
|
+
op(HighLevelBuilderOpcodes.Label, 'ENDINITIAL');
|
|
1070
|
+
op(VM_POP_FRAME_OP);
|
|
1071
|
+
op(HighLevelBuilderOpcodes.StopLabels);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* A specialized version of the `replayable` convenience that allows the
|
|
1076
|
+
* caller to provide different code based upon whether the item at
|
|
1077
|
+
* the top of the stack is true or false.
|
|
1078
|
+
*
|
|
1079
|
+
* As in `replayable`, the `ifTrue` and `ifFalse` code can invoke `return`.
|
|
1080
|
+
*
|
|
1081
|
+
* During the initial execution, a `return` will continue execution
|
|
1082
|
+
* in the cleanup code, which finalizes the current DOM block and pops
|
|
1083
|
+
* the current frame.
|
|
1084
|
+
*
|
|
1085
|
+
* During the updating execution, a `return` will exit the updating
|
|
1086
|
+
* routine, as it can reuse the DOM block and is always only a single
|
|
1087
|
+
* frame deep.
|
|
1088
|
+
*/
|
|
1089
|
+
function ReplayableIf(op, args, ifTrue, ifFalse) {
|
|
1090
|
+
return Replayable(op, args, () => {
|
|
1091
|
+
// If the conditional is false, jump to the ELSE label.
|
|
1092
|
+
op(VM_JUMP_UNLESS_OP, labelOperand('ELSE'));
|
|
1093
|
+
// Otherwise, execute the code associated with the true branch.
|
|
1094
|
+
ifTrue();
|
|
1095
|
+
// We're done, so return. In the initial execution, this runs
|
|
1096
|
+
// the cleanup code. In the updating VM, it exits the updating
|
|
1097
|
+
// routine.
|
|
1098
|
+
op(VM_JUMP_OP, labelOperand('FINALLY'));
|
|
1099
|
+
op(HighLevelBuilderOpcodes.Label, 'ELSE');
|
|
1100
|
+
|
|
1101
|
+
// If the conditional is false, and code associatied ith the
|
|
1102
|
+
// false branch was provided, execute it. If there was no code
|
|
1103
|
+
// associated with the false branch, jumping to the else statement
|
|
1104
|
+
// has no other behavior.
|
|
1105
|
+
if (ifFalse !== undefined) {
|
|
1106
|
+
ifFalse();
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
const ATTRS_BLOCK = '&attrs';
|
|
1112
|
+
|
|
1113
|
+
// {{component}}
|
|
1114
|
+
|
|
1115
|
+
// <Component>
|
|
1116
|
+
|
|
1117
|
+
// chokepoint
|
|
1118
|
+
|
|
1119
|
+
function InvokeComponent(op, component, _elementBlock, positional, named, _blocks) {
|
|
1120
|
+
let {
|
|
1121
|
+
compilable,
|
|
1122
|
+
capabilities,
|
|
1123
|
+
handle
|
|
1124
|
+
} = component;
|
|
1125
|
+
let elementBlock = _elementBlock ? [_elementBlock, []] : null;
|
|
1126
|
+
let blocks = namedBlocks(_blocks);
|
|
1127
|
+
if (compilable) {
|
|
1128
|
+
op(VM_PUSH_COMPONENT_DEFINITION_OP, handle);
|
|
1129
|
+
InvokeStaticComponent(op, {
|
|
1130
|
+
capabilities: capabilities,
|
|
1131
|
+
layout: compilable,
|
|
1132
|
+
elementBlock,
|
|
1133
|
+
positional,
|
|
1134
|
+
named,
|
|
1135
|
+
blocks
|
|
1136
|
+
});
|
|
1137
|
+
} else {
|
|
1138
|
+
op(VM_PUSH_COMPONENT_DEFINITION_OP, handle);
|
|
1139
|
+
InvokeNonStaticComponent(op, {
|
|
1140
|
+
capabilities: capabilities,
|
|
1141
|
+
elementBlock,
|
|
1142
|
+
positional,
|
|
1143
|
+
named,
|
|
1144
|
+
atNames: true,
|
|
1145
|
+
blocks
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
function InvokeDynamicComponent(op, definition, _elementBlock, positional, named, _blocks, atNames, curried) {
|
|
1150
|
+
let elementBlock = _elementBlock ? [_elementBlock, []] : null;
|
|
1151
|
+
let blocks = namedBlocks(_blocks);
|
|
1152
|
+
Replayable(op, () => {
|
|
1153
|
+
expr(op, definition);
|
|
1154
|
+
op(VM_DUP_OP, $sp, 0);
|
|
1155
|
+
return 2;
|
|
1156
|
+
}, () => {
|
|
1157
|
+
op(VM_JUMP_UNLESS_OP, labelOperand('ELSE'));
|
|
1158
|
+
if (curried) {
|
|
1159
|
+
op(VM_RESOLVE_CURRIED_COMPONENT_OP);
|
|
1160
|
+
} else {
|
|
1161
|
+
op(VM_RESOLVE_DYNAMIC_COMPONENT_OP, isStrictMode());
|
|
1162
|
+
}
|
|
1163
|
+
op(VM_PUSH_DYNAMIC_COMPONENT_INSTANCE_OP);
|
|
1164
|
+
InvokeNonStaticComponent(op, {
|
|
1165
|
+
capabilities: true,
|
|
1166
|
+
elementBlock,
|
|
1167
|
+
positional,
|
|
1168
|
+
named,
|
|
1169
|
+
atNames,
|
|
1170
|
+
blocks
|
|
1171
|
+
});
|
|
1172
|
+
op(HighLevelBuilderOpcodes.Label, 'ELSE');
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
function InvokeStaticComponent(op, {
|
|
1176
|
+
capabilities,
|
|
1177
|
+
layout,
|
|
1178
|
+
elementBlock,
|
|
1179
|
+
positional,
|
|
1180
|
+
named,
|
|
1181
|
+
blocks
|
|
1182
|
+
}) {
|
|
1183
|
+
let {
|
|
1184
|
+
symbolTable
|
|
1185
|
+
} = layout;
|
|
1186
|
+
let bailOut = hasCapability(capabilities, InternalComponentCapabilities.prepareArgs);
|
|
1187
|
+
if (bailOut) {
|
|
1188
|
+
InvokeNonStaticComponent(op, {
|
|
1189
|
+
capabilities,
|
|
1190
|
+
elementBlock,
|
|
1191
|
+
positional,
|
|
1192
|
+
named,
|
|
1193
|
+
atNames: true,
|
|
1194
|
+
blocks,
|
|
1195
|
+
layout
|
|
1196
|
+
});
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
op(VM_FETCH_OP, $s0);
|
|
1200
|
+
op(VM_DUP_OP, $sp, 1);
|
|
1201
|
+
op(VM_LOAD_OP, $s0);
|
|
1202
|
+
op(VM_PUSH_FRAME_OP);
|
|
1203
|
+
|
|
1204
|
+
// Setup arguments
|
|
1205
|
+
let {
|
|
1206
|
+
symbols
|
|
1207
|
+
} = symbolTable;
|
|
1208
|
+
|
|
1209
|
+
// As we push values onto the stack, we store the symbols associated with them
|
|
1210
|
+
// so that we can set them on the scope later on with SetVariable and SetBlock
|
|
1211
|
+
let blockSymbols = [];
|
|
1212
|
+
let argSymbols = [];
|
|
1213
|
+
let argNames = [];
|
|
1214
|
+
|
|
1215
|
+
// First we push the blocks onto the stack
|
|
1216
|
+
let blockNames = blocks.names;
|
|
1217
|
+
|
|
1218
|
+
// Starting with the attrs block, if it exists and is referenced in the component
|
|
1219
|
+
if (elementBlock !== null) {
|
|
1220
|
+
let symbol = symbols.indexOf(ATTRS_BLOCK);
|
|
1221
|
+
if (symbol !== -1) {
|
|
1222
|
+
PushYieldableBlock(op, elementBlock);
|
|
1223
|
+
blockSymbols.push(symbol);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// Followed by the other blocks, if they exist and are referenced in the component.
|
|
1228
|
+
// Also store the index of the associated symbol.
|
|
1229
|
+
for (const name of blockNames) {
|
|
1230
|
+
let symbol = symbols.indexOf(`&${name}`);
|
|
1231
|
+
if (symbol !== -1) {
|
|
1232
|
+
PushYieldableBlock(op, blocks.get(name));
|
|
1233
|
+
blockSymbols.push(symbol);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// Next up we have arguments. If the component has the `createArgs` capability,
|
|
1238
|
+
// then it wants access to the arguments in JavaScript. We can't know whether
|
|
1239
|
+
// or not an argument is used, so we have to give access to all of them.
|
|
1240
|
+
if (hasCapability(capabilities, InternalComponentCapabilities.createArgs)) {
|
|
1241
|
+
// First we push positional arguments
|
|
1242
|
+
let count = CompilePositional(op, positional);
|
|
1243
|
+
|
|
1244
|
+
// setup the flags with the count of positionals, and to indicate that atNames
|
|
1245
|
+
// are used
|
|
1246
|
+
let flags = count << 4;
|
|
1247
|
+
flags |= 0b1000;
|
|
1248
|
+
let names = EMPTY_STRING_ARRAY;
|
|
1249
|
+
|
|
1250
|
+
// Next, if named args exist, push them all. If they have an associated symbol
|
|
1251
|
+
// in the invoked component (e.g. they are used within its template), we push
|
|
1252
|
+
// that symbol. If not, we still push the expression as it may be used, and
|
|
1253
|
+
// we store the symbol as -1 (this is used later).
|
|
1254
|
+
if (named !== null) {
|
|
1255
|
+
names = named[0];
|
|
1256
|
+
let val = named[1];
|
|
1257
|
+
for (let i = 0; i < val.length; i++) {
|
|
1258
|
+
let symbol = symbols.indexOf(unwrap(names[i]));
|
|
1259
|
+
expr(op, val[i]);
|
|
1260
|
+
argSymbols.push(symbol);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// Finally, push the VM arguments themselves. These args won't need access
|
|
1265
|
+
// to blocks (they aren't accessible from userland anyways), so we push an
|
|
1266
|
+
// empty array instead of the actual block names.
|
|
1267
|
+
op(VM_PUSH_ARGS_OP, names, EMPTY_STRING_ARRAY, flags);
|
|
1268
|
+
|
|
1269
|
+
// And push an extra pop operation to remove the args before we begin setting
|
|
1270
|
+
// variables on the local context
|
|
1271
|
+
argSymbols.push(-1);
|
|
1272
|
+
} else if (named !== null) {
|
|
1273
|
+
// If the component does not have the `createArgs` capability, then the only
|
|
1274
|
+
// expressions we need to push onto the stack are those that are actually
|
|
1275
|
+
// referenced in the template of the invoked component (e.g. have symbols).
|
|
1276
|
+
let names = named[0];
|
|
1277
|
+
let val = named[1];
|
|
1278
|
+
for (let i = 0; i < val.length; i++) {
|
|
1279
|
+
let name = unwrap(names[i]);
|
|
1280
|
+
let symbol = symbols.indexOf(name);
|
|
1281
|
+
if (symbol !== -1) {
|
|
1282
|
+
expr(op, val[i]);
|
|
1283
|
+
argSymbols.push(symbol);
|
|
1284
|
+
argNames.push(name);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
op(VM_BEGIN_COMPONENT_TRANSACTION_OP, $s0);
|
|
1289
|
+
if (hasCapability(capabilities, InternalComponentCapabilities.dynamicScope)) {
|
|
1290
|
+
op(VM_PUSH_DYNAMIC_SCOPE_OP);
|
|
1291
|
+
}
|
|
1292
|
+
if (hasCapability(capabilities, InternalComponentCapabilities.createInstance)) {
|
|
1293
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1294
|
+
op(VM_CREATE_COMPONENT_OP, blocks.has('default') | 0);
|
|
1295
|
+
}
|
|
1296
|
+
op(VM_REGISTER_COMPONENT_DESTRUCTOR_OP, $s0);
|
|
1297
|
+
if (hasCapability(capabilities, InternalComponentCapabilities.createArgs)) {
|
|
1298
|
+
op(VM_GET_COMPONENT_SELF_OP, $s0);
|
|
1299
|
+
} else {
|
|
1300
|
+
op(VM_GET_COMPONENT_SELF_OP, $s0, argNames);
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// Setup the new root scope for the component
|
|
1304
|
+
op(VM_ROOT_SCOPE_OP, symbols.length + 1, Object.keys(blocks).length > 0 ? 1 : 0);
|
|
1305
|
+
|
|
1306
|
+
// Pop the self reference off the stack and set it to the symbol for `this`
|
|
1307
|
+
// in the new scope. This is why all subsequent symbols are increased by one.
|
|
1308
|
+
op(VM_SET_VARIABLE_OP, 0);
|
|
1309
|
+
|
|
1310
|
+
// Going in reverse, now we pop the args/blocks off the stack, starting with
|
|
1311
|
+
// arguments, and assign them to their symbols in the new scope.
|
|
1312
|
+
for (const symbol of reverse(argSymbols)) {
|
|
1313
|
+
// for (let i = argSymbols.length - 1; i >= 0; i--) {
|
|
1314
|
+
// let symbol = argSymbols[i];
|
|
1315
|
+
|
|
1316
|
+
if (symbol === -1) {
|
|
1317
|
+
// The expression was not bound to a local symbol, it was only pushed to be
|
|
1318
|
+
// used with VM args in the javascript side
|
|
1319
|
+
op(VM_POP_OP, 1);
|
|
1320
|
+
} else {
|
|
1321
|
+
op(VM_SET_VARIABLE_OP, symbol + 1);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
// if any positional params exist, pop them off the stack as well
|
|
1326
|
+
if (positional !== null) {
|
|
1327
|
+
op(VM_POP_OP, positional.length);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
// Finish up by popping off and assigning blocks
|
|
1331
|
+
for (const symbol of reverse(blockSymbols)) {
|
|
1332
|
+
op(VM_SET_BLOCK_OP, symbol + 1);
|
|
1333
|
+
}
|
|
1334
|
+
op(VM_CONSTANT_OP, layoutOperand(layout));
|
|
1335
|
+
op(VM_COMPILE_BLOCK_OP);
|
|
1336
|
+
op(VM_INVOKE_VIRTUAL_OP);
|
|
1337
|
+
op(VM_DID_RENDER_LAYOUT_OP, $s0);
|
|
1338
|
+
op(VM_POP_FRAME_OP);
|
|
1339
|
+
op(VM_POP_SCOPE_OP);
|
|
1340
|
+
if (hasCapability(capabilities, InternalComponentCapabilities.dynamicScope)) {
|
|
1341
|
+
op(VM_POP_DYNAMIC_SCOPE_OP);
|
|
1342
|
+
}
|
|
1343
|
+
op(VM_COMMIT_COMPONENT_TRANSACTION_OP);
|
|
1344
|
+
op(VM_LOAD_OP, $s0);
|
|
1345
|
+
}
|
|
1346
|
+
function InvokeNonStaticComponent(op, {
|
|
1347
|
+
capabilities,
|
|
1348
|
+
elementBlock,
|
|
1349
|
+
positional,
|
|
1350
|
+
named,
|
|
1351
|
+
atNames,
|
|
1352
|
+
blocks: namedBlocks,
|
|
1353
|
+
layout
|
|
1354
|
+
}) {
|
|
1355
|
+
let bindableBlocks = Boolean(namedBlocks);
|
|
1356
|
+
let bindableAtNames = capabilities === true || hasCapability(capabilities, InternalComponentCapabilities.prepareArgs) || named?.[0].length !== 0;
|
|
1357
|
+
let blocks = namedBlocks.with('attrs', elementBlock);
|
|
1358
|
+
op(VM_FETCH_OP, $s0);
|
|
1359
|
+
op(VM_DUP_OP, $sp, 1);
|
|
1360
|
+
op(VM_LOAD_OP, $s0);
|
|
1361
|
+
op(VM_PUSH_FRAME_OP);
|
|
1362
|
+
CompileArgs(op, positional, named, blocks, atNames);
|
|
1363
|
+
op(VM_PREPARE_ARGS_OP, $s0);
|
|
1364
|
+
invokePreparedComponent(op, blocks.has('default'), bindableBlocks, bindableAtNames, () => {
|
|
1365
|
+
if (layout) {
|
|
1366
|
+
op(VM_PUSH_SYMBOL_TABLE_OP, symbolTableOperand(layout.symbolTable));
|
|
1367
|
+
op(VM_CONSTANT_OP, layoutOperand(layout));
|
|
1368
|
+
op(VM_COMPILE_BLOCK_OP);
|
|
1369
|
+
} else {
|
|
1370
|
+
op(VM_GET_COMPONENT_LAYOUT_OP, $s0);
|
|
1371
|
+
}
|
|
1372
|
+
op(VM_POPULATE_LAYOUT_OP, $s0);
|
|
1373
|
+
});
|
|
1374
|
+
op(VM_LOAD_OP, $s0);
|
|
1375
|
+
}
|
|
1376
|
+
function WrappedComponent(op, layout, attrsBlockNumber) {
|
|
1377
|
+
op(HighLevelBuilderOpcodes.StartLabels);
|
|
1378
|
+
WithSavedRegister(op, $s1, () => {
|
|
1379
|
+
op(VM_GET_COMPONENT_TAG_NAME_OP, $s0);
|
|
1380
|
+
op(VM_PRIMITIVE_REFERENCE_OP);
|
|
1381
|
+
op(VM_DUP_OP, $sp, 0);
|
|
1382
|
+
});
|
|
1383
|
+
op(VM_JUMP_UNLESS_OP, labelOperand('BODY'));
|
|
1384
|
+
op(VM_FETCH_OP, $s1);
|
|
1385
|
+
op(VM_PUT_COMPONENT_OPERATIONS_OP);
|
|
1386
|
+
op(VM_OPEN_DYNAMIC_ELEMENT_OP);
|
|
1387
|
+
op(VM_DID_CREATE_ELEMENT_OP, $s0);
|
|
1388
|
+
YieldBlock(op, attrsBlockNumber, null);
|
|
1389
|
+
op(VM_FLUSH_ELEMENT_OP);
|
|
1390
|
+
op(HighLevelBuilderOpcodes.Label, 'BODY');
|
|
1391
|
+
InvokeStaticBlock(op, [layout.block[0], []]);
|
|
1392
|
+
op(VM_FETCH_OP, $s1);
|
|
1393
|
+
op(VM_JUMP_UNLESS_OP, labelOperand('END'));
|
|
1394
|
+
op(VM_CLOSE_ELEMENT_OP);
|
|
1395
|
+
op(HighLevelBuilderOpcodes.Label, 'END');
|
|
1396
|
+
op(VM_LOAD_OP, $s1);
|
|
1397
|
+
op(HighLevelBuilderOpcodes.StopLabels);
|
|
1398
|
+
}
|
|
1399
|
+
function invokePreparedComponent(op, hasBlock, bindableBlocks, bindableAtNames, populateLayout = null) {
|
|
1400
|
+
op(VM_BEGIN_COMPONENT_TRANSACTION_OP, $s0);
|
|
1401
|
+
op(VM_PUSH_DYNAMIC_SCOPE_OP);
|
|
1402
|
+
|
|
1403
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1404
|
+
op(VM_CREATE_COMPONENT_OP, hasBlock | 0);
|
|
1405
|
+
|
|
1406
|
+
// this has to run after createComponent to allow
|
|
1407
|
+
// for late-bound layouts, but a caller is free
|
|
1408
|
+
// to populate the layout earlier if it wants to
|
|
1409
|
+
// and do nothing here.
|
|
1410
|
+
if (populateLayout) {
|
|
1411
|
+
populateLayout();
|
|
1412
|
+
}
|
|
1413
|
+
op(VM_REGISTER_COMPONENT_DESTRUCTOR_OP, $s0);
|
|
1414
|
+
op(VM_GET_COMPONENT_SELF_OP, $s0);
|
|
1415
|
+
op(VM_VIRTUAL_ROOT_SCOPE_OP, $s0);
|
|
1416
|
+
op(VM_SET_VARIABLE_OP, 0);
|
|
1417
|
+
if (bindableAtNames) op(VM_SET_NAMED_VARIABLES_OP, $s0);
|
|
1418
|
+
if (bindableBlocks) op(VM_SET_BLOCKS_OP, $s0);
|
|
1419
|
+
op(VM_POP_OP, 1);
|
|
1420
|
+
op(VM_INVOKE_COMPONENT_LAYOUT_OP, $s0);
|
|
1421
|
+
op(VM_DID_RENDER_LAYOUT_OP, $s0);
|
|
1422
|
+
op(VM_POP_FRAME_OP);
|
|
1423
|
+
op(VM_POP_SCOPE_OP);
|
|
1424
|
+
op(VM_POP_DYNAMIC_SCOPE_OP);
|
|
1425
|
+
op(VM_COMMIT_COMPONENT_TRANSACTION_OP);
|
|
1426
|
+
}
|
|
1427
|
+
function InvokeBareComponent(op) {
|
|
1428
|
+
op(VM_FETCH_OP, $s0);
|
|
1429
|
+
op(VM_DUP_OP, $sp, 1);
|
|
1430
|
+
op(VM_LOAD_OP, $s0);
|
|
1431
|
+
op(VM_PUSH_FRAME_OP);
|
|
1432
|
+
op(VM_PUSH_EMPTY_ARGS_OP);
|
|
1433
|
+
op(VM_PREPARE_ARGS_OP, $s0);
|
|
1434
|
+
invokePreparedComponent(op, false, false, true, () => {
|
|
1435
|
+
op(VM_GET_COMPONENT_LAYOUT_OP, $s0);
|
|
1436
|
+
op(VM_POPULATE_LAYOUT_OP, $s0);
|
|
1437
|
+
});
|
|
1438
|
+
op(VM_LOAD_OP, $s0);
|
|
1439
|
+
}
|
|
1440
|
+
function WithSavedRegister(op, register, block) {
|
|
1441
|
+
op(VM_FETCH_OP, register);
|
|
1442
|
+
block();
|
|
1443
|
+
op(VM_LOAD_OP, register);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
const STATEMENTS = new Compilers();
|
|
1447
|
+
const INFLATE_ATTR_TABLE = ['class', 'id', 'value', 'name', 'type', 'style', 'href'];
|
|
1448
|
+
const INFLATE_TAG_TABLE = ['div', 'span', 'p', 'a'];
|
|
1449
|
+
function inflateTagName(tagName) {
|
|
1450
|
+
return typeof tagName === 'string' ? tagName : INFLATE_TAG_TABLE[tagName];
|
|
1451
|
+
}
|
|
1452
|
+
function inflateAttrName(attrName) {
|
|
1453
|
+
return typeof attrName === 'string' ? attrName : INFLATE_ATTR_TABLE[attrName];
|
|
1454
|
+
}
|
|
1455
|
+
STATEMENTS.add(opcodes.Comment, (op, sexp) => op(VM_COMMENT_OP, sexp[1]));
|
|
1456
|
+
STATEMENTS.add(opcodes.CloseElement, op => op(VM_CLOSE_ELEMENT_OP));
|
|
1457
|
+
STATEMENTS.add(opcodes.FlushElement, op => op(VM_FLUSH_ELEMENT_OP));
|
|
1458
|
+
STATEMENTS.add(opcodes.Modifier, (op, [, expression, positional, named]) => {
|
|
1459
|
+
if (isGetFreeModifier(expression)) {
|
|
1460
|
+
op(HighLevelResolutionOpcodes.Modifier, expression, handle => {
|
|
1461
|
+
op(VM_PUSH_FRAME_OP);
|
|
1462
|
+
SimpleArgs(op, positional, named, false);
|
|
1463
|
+
op(VM_MODIFIER_OP, handle);
|
|
1464
|
+
op(VM_POP_FRAME_OP);
|
|
1465
|
+
});
|
|
1466
|
+
} else {
|
|
1467
|
+
expr(op, expression);
|
|
1468
|
+
op(VM_PUSH_FRAME_OP);
|
|
1469
|
+
SimpleArgs(op, positional, named, false);
|
|
1470
|
+
op(VM_DUP_OP, $fp, 1);
|
|
1471
|
+
op(VM_DYNAMIC_MODIFIER_OP);
|
|
1472
|
+
op(VM_POP_FRAME_OP);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
STATEMENTS.add(opcodes.StaticAttr, (op, [, name, value, namespace]) => {
|
|
1476
|
+
op(VM_STATIC_ATTR_OP, inflateAttrName(name), value, namespace ?? null);
|
|
1477
|
+
});
|
|
1478
|
+
STATEMENTS.add(opcodes.StaticComponentAttr, (op, [, name, value, namespace]) => {
|
|
1479
|
+
op(VM_STATIC_COMPONENT_ATTR_OP, inflateAttrName(name), value, namespace ?? null);
|
|
1480
|
+
});
|
|
1481
|
+
STATEMENTS.add(opcodes.DynamicAttr, (op, [, name, value, namespace]) => {
|
|
1482
|
+
expr(op, value);
|
|
1483
|
+
op(VM_DYNAMIC_ATTR_OP, inflateAttrName(name), false, namespace ?? null);
|
|
1484
|
+
});
|
|
1485
|
+
STATEMENTS.add(opcodes.TrustingDynamicAttr, (op, [, name, value, namespace]) => {
|
|
1486
|
+
expr(op, value);
|
|
1487
|
+
op(VM_DYNAMIC_ATTR_OP, inflateAttrName(name), true, namespace ?? null);
|
|
1488
|
+
});
|
|
1489
|
+
STATEMENTS.add(opcodes.ComponentAttr, (op, [, name, value, namespace]) => {
|
|
1490
|
+
expr(op, value);
|
|
1491
|
+
op(VM_COMPONENT_ATTR_OP, inflateAttrName(name), false, namespace ?? null);
|
|
1492
|
+
});
|
|
1493
|
+
STATEMENTS.add(opcodes.TrustingComponentAttr, (op, [, name, value, namespace]) => {
|
|
1494
|
+
expr(op, value);
|
|
1495
|
+
op(VM_COMPONENT_ATTR_OP, inflateAttrName(name), true, namespace ?? null);
|
|
1496
|
+
});
|
|
1497
|
+
STATEMENTS.add(opcodes.OpenElement, (op, [, tag]) => {
|
|
1498
|
+
op(VM_OPEN_ELEMENT_OP, inflateTagName(tag));
|
|
1499
|
+
});
|
|
1500
|
+
STATEMENTS.add(opcodes.OpenElementWithSplat, (op, [, tag]) => {
|
|
1501
|
+
op(VM_PUT_COMPONENT_OPERATIONS_OP);
|
|
1502
|
+
op(VM_OPEN_ELEMENT_OP, inflateTagName(tag));
|
|
1503
|
+
});
|
|
1504
|
+
STATEMENTS.add(opcodes.Component, (op, [, expr, elementBlock, named, blocks]) => {
|
|
1505
|
+
if (isGetFreeComponent(expr)) {
|
|
1506
|
+
op(HighLevelResolutionOpcodes.Component, expr, component => {
|
|
1507
|
+
InvokeComponent(op, component, elementBlock, null, named, blocks);
|
|
1508
|
+
});
|
|
1509
|
+
} else {
|
|
1510
|
+
// otherwise, the component name was an expression, so resolve the expression
|
|
1511
|
+
// and invoke it as a dynamic component
|
|
1512
|
+
InvokeDynamicComponent(op, expr, elementBlock, null, named, blocks, true, true);
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
STATEMENTS.add(opcodes.Yield, (op, [, to, params]) => YieldBlock(op, to, params));
|
|
1516
|
+
STATEMENTS.add(opcodes.AttrSplat, (op, [, to]) => YieldBlock(op, to, null));
|
|
1517
|
+
STATEMENTS.add(opcodes.Debugger, (op, [, locals, upvars, lexical]) => {
|
|
1518
|
+
op(VM_DEBUGGER_OP, debugSymbolsOperand(locals, upvars, lexical));
|
|
1519
|
+
});
|
|
1520
|
+
STATEMENTS.add(opcodes.Append, (op, [, value]) => {
|
|
1521
|
+
// Special case for static values
|
|
1522
|
+
if (!Array.isArray(value)) {
|
|
1523
|
+
op(VM_TEXT_OP, value === null || value === undefined ? '' : String(value));
|
|
1524
|
+
} else if (isGetFreeComponentOrHelper(value)) {
|
|
1525
|
+
op(HighLevelResolutionOpcodes.OptionalComponentOrHelper, value, {
|
|
1526
|
+
ifComponent(component) {
|
|
1527
|
+
InvokeComponent(op, component, null, null, null, null);
|
|
1528
|
+
},
|
|
1529
|
+
ifHelper(handle) {
|
|
1530
|
+
op(VM_PUSH_FRAME_OP);
|
|
1531
|
+
Call(op, handle, null, null);
|
|
1532
|
+
op(VM_INVOKE_STATIC_OP, stdlibOperand('cautious-non-dynamic-append'));
|
|
1533
|
+
op(VM_POP_FRAME_OP);
|
|
1534
|
+
},
|
|
1535
|
+
ifValue(handle) {
|
|
1536
|
+
op(VM_PUSH_FRAME_OP);
|
|
1537
|
+
op(VM_CONSTANT_REFERENCE_OP, handle);
|
|
1538
|
+
op(VM_INVOKE_STATIC_OP, stdlibOperand('cautious-non-dynamic-append'));
|
|
1539
|
+
op(VM_POP_FRAME_OP);
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
} else if (value[0] === opcodes.Call) {
|
|
1543
|
+
let [, expression, positional, named] = value;
|
|
1544
|
+
if (isGetFreeComponentOrHelper(expression)) {
|
|
1545
|
+
op(HighLevelResolutionOpcodes.ComponentOrHelper, expression, {
|
|
1546
|
+
ifComponent(component) {
|
|
1547
|
+
InvokeComponent(op, component, null, positional, hashToArgs(named), null);
|
|
1548
|
+
},
|
|
1549
|
+
ifHelper(handle) {
|
|
1550
|
+
op(VM_PUSH_FRAME_OP);
|
|
1551
|
+
Call(op, handle, positional, named);
|
|
1552
|
+
op(VM_INVOKE_STATIC_OP, stdlibOperand('cautious-non-dynamic-append'));
|
|
1553
|
+
op(VM_POP_FRAME_OP);
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
} else {
|
|
1557
|
+
SwitchCases(op, () => {
|
|
1558
|
+
expr(op, expression);
|
|
1559
|
+
op(VM_DYNAMIC_CONTENT_TYPE_OP);
|
|
1560
|
+
}, when => {
|
|
1561
|
+
when(ContentType.Component, () => {
|
|
1562
|
+
op(VM_RESOLVE_CURRIED_COMPONENT_OP);
|
|
1563
|
+
op(VM_PUSH_DYNAMIC_COMPONENT_INSTANCE_OP);
|
|
1564
|
+
InvokeNonStaticComponent(op, {
|
|
1565
|
+
capabilities: true,
|
|
1566
|
+
elementBlock: null,
|
|
1567
|
+
positional,
|
|
1568
|
+
named,
|
|
1569
|
+
atNames: false,
|
|
1570
|
+
blocks: namedBlocks(null)
|
|
1571
|
+
});
|
|
1572
|
+
});
|
|
1573
|
+
when(ContentType.Helper, () => {
|
|
1574
|
+
CallDynamic(op, positional, named, () => {
|
|
1575
|
+
op(VM_INVOKE_STATIC_OP, stdlibOperand('cautious-non-dynamic-append'));
|
|
1576
|
+
});
|
|
1577
|
+
});
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
} else {
|
|
1581
|
+
op(VM_PUSH_FRAME_OP);
|
|
1582
|
+
expr(op, value);
|
|
1583
|
+
op(VM_INVOKE_STATIC_OP, stdlibOperand('cautious-append'));
|
|
1584
|
+
op(VM_POP_FRAME_OP);
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
STATEMENTS.add(opcodes.TrustingAppend, (op, [, value]) => {
|
|
1588
|
+
if (!Array.isArray(value)) {
|
|
1589
|
+
op(VM_TEXT_OP, value === null || value === undefined ? '' : String(value));
|
|
1590
|
+
} else {
|
|
1591
|
+
op(VM_PUSH_FRAME_OP);
|
|
1592
|
+
expr(op, value);
|
|
1593
|
+
op(VM_INVOKE_STATIC_OP, stdlibOperand('trusting-append'));
|
|
1594
|
+
op(VM_POP_FRAME_OP);
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
STATEMENTS.add(opcodes.Block, (op, [, expr, positional, named, blocks]) => {
|
|
1598
|
+
if (isGetFreeComponent(expr)) {
|
|
1599
|
+
op(HighLevelResolutionOpcodes.Component, expr, component => {
|
|
1600
|
+
InvokeComponent(op, component, null, positional, hashToArgs(named), blocks);
|
|
1601
|
+
});
|
|
1602
|
+
} else {
|
|
1603
|
+
InvokeDynamicComponent(op, expr, null, positional, named, blocks, false, false);
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
STATEMENTS.add(opcodes.InElement, (op, [, block, guid, destination, insertBefore]) => {
|
|
1607
|
+
ReplayableIf(op, () => {
|
|
1608
|
+
expr(op, guid);
|
|
1609
|
+
if (insertBefore === undefined) {
|
|
1610
|
+
PushPrimitiveReference(op, undefined);
|
|
1611
|
+
} else {
|
|
1612
|
+
expr(op, insertBefore);
|
|
1613
|
+
}
|
|
1614
|
+
expr(op, destination);
|
|
1615
|
+
op(VM_DUP_OP, $sp, 0);
|
|
1616
|
+
return 4;
|
|
1617
|
+
}, () => {
|
|
1618
|
+
op(VM_PUSH_REMOTE_ELEMENT_OP);
|
|
1619
|
+
InvokeStaticBlock(op, block);
|
|
1620
|
+
op(VM_POP_REMOTE_ELEMENT_OP);
|
|
1621
|
+
});
|
|
1622
|
+
});
|
|
1623
|
+
STATEMENTS.add(opcodes.If, (op, [, condition, block, inverse]) => ReplayableIf(op, () => {
|
|
1624
|
+
expr(op, condition);
|
|
1625
|
+
op(VM_TO_BOOLEAN_OP);
|
|
1626
|
+
return 1;
|
|
1627
|
+
}, () => {
|
|
1628
|
+
InvokeStaticBlock(op, block);
|
|
1629
|
+
}, inverse ? () => {
|
|
1630
|
+
InvokeStaticBlock(op, inverse);
|
|
1631
|
+
} : undefined));
|
|
1632
|
+
STATEMENTS.add(opcodes.Each, (op, [, value, key, block, inverse]) => Replayable(op, () => {
|
|
1633
|
+
if (key) {
|
|
1634
|
+
expr(op, key);
|
|
1635
|
+
} else {
|
|
1636
|
+
PushPrimitiveReference(op, null);
|
|
1637
|
+
}
|
|
1638
|
+
expr(op, value);
|
|
1639
|
+
return 2;
|
|
1640
|
+
}, () => {
|
|
1641
|
+
op(VM_ENTER_LIST_OP, labelOperand('BODY'), labelOperand('ELSE'));
|
|
1642
|
+
op(VM_PUSH_FRAME_OP);
|
|
1643
|
+
op(VM_DUP_OP, $fp, 1);
|
|
1644
|
+
op(VM_RETURN_TO_OP, labelOperand('ITER'));
|
|
1645
|
+
op(HighLevelBuilderOpcodes.Label, 'ITER');
|
|
1646
|
+
op(VM_ITERATE_OP, labelOperand('BREAK'));
|
|
1647
|
+
op(HighLevelBuilderOpcodes.Label, 'BODY');
|
|
1648
|
+
InvokeStaticBlockWithStack(op, block, 2);
|
|
1649
|
+
op(VM_POP_OP, 2);
|
|
1650
|
+
op(VM_JUMP_OP, labelOperand('FINALLY'));
|
|
1651
|
+
op(HighLevelBuilderOpcodes.Label, 'BREAK');
|
|
1652
|
+
op(VM_POP_FRAME_OP);
|
|
1653
|
+
op(VM_EXIT_LIST_OP);
|
|
1654
|
+
op(VM_JUMP_OP, labelOperand('FINALLY'));
|
|
1655
|
+
op(HighLevelBuilderOpcodes.Label, 'ELSE');
|
|
1656
|
+
if (inverse) {
|
|
1657
|
+
InvokeStaticBlock(op, inverse);
|
|
1658
|
+
}
|
|
1659
|
+
}));
|
|
1660
|
+
STATEMENTS.add(opcodes.Let, (op, [, positional, block]) => {
|
|
1661
|
+
let count = CompilePositional(op, positional);
|
|
1662
|
+
InvokeStaticBlockWithStack(op, block, count);
|
|
1663
|
+
});
|
|
1664
|
+
STATEMENTS.add(opcodes.WithDynamicVars, (op, [, named, block]) => {
|
|
1665
|
+
if (named) {
|
|
1666
|
+
let [names, expressions] = named;
|
|
1667
|
+
CompilePositional(op, expressions);
|
|
1668
|
+
DynamicScope(op, names, () => {
|
|
1669
|
+
InvokeStaticBlock(op, block);
|
|
1670
|
+
});
|
|
1671
|
+
} else {
|
|
1672
|
+
InvokeStaticBlock(op, block);
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
STATEMENTS.add(opcodes.InvokeComponent, (op, [, expr, positional, named, blocks]) => {
|
|
1676
|
+
if (isGetFreeComponent(expr)) {
|
|
1677
|
+
op(HighLevelResolutionOpcodes.Component, expr, component => {
|
|
1678
|
+
InvokeComponent(op, component, null, positional, hashToArgs(named), blocks);
|
|
1679
|
+
});
|
|
1680
|
+
} else {
|
|
1681
|
+
InvokeDynamicComponent(op, expr, null, positional, named, blocks, false, false);
|
|
1682
|
+
}
|
|
1683
|
+
});
|
|
1684
|
+
function hashToArgs(hash) {
|
|
1685
|
+
if (hash === null) return null;
|
|
1686
|
+
let names = hash[0].map(key => `@${key}`);
|
|
1687
|
+
return [names, hash[1]];
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
const PLACEHOLDER_HANDLE = -1;
|
|
1691
|
+
class CompilableTemplateImpl {
|
|
1692
|
+
static {
|
|
1693
|
+
}
|
|
1694
|
+
compiled = new WeakMap();
|
|
1695
|
+
constructor(statements, meta,
|
|
1696
|
+
// Part of CompilableTemplate
|
|
1697
|
+
symbolTable,
|
|
1698
|
+
// Used for debugging
|
|
1699
|
+
moduleName = 'plain block') {
|
|
1700
|
+
this.statements = statements;
|
|
1701
|
+
this.meta = meta;
|
|
1702
|
+
this.symbolTable = symbolTable;
|
|
1703
|
+
this.moduleName = moduleName;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
// Part of CompilableTemplate
|
|
1707
|
+
compile(context) {
|
|
1708
|
+
return maybeCompile(this, context);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
function compilable(layout, moduleName) {
|
|
1712
|
+
let [statements, symbols] = layout.block;
|
|
1713
|
+
return new CompilableTemplateImpl(statements, meta(layout), {
|
|
1714
|
+
symbols
|
|
1715
|
+
}, moduleName);
|
|
1716
|
+
}
|
|
1717
|
+
function maybeCompile(compilable, context) {
|
|
1718
|
+
if (compilable.compiled.has(context)) {
|
|
1719
|
+
return compilable.compiled.get(context);
|
|
1720
|
+
}
|
|
1721
|
+
compilable.compiled.set(context, PLACEHOLDER_HANDLE);
|
|
1722
|
+
let {
|
|
1723
|
+
statements,
|
|
1724
|
+
meta
|
|
1725
|
+
} = compilable;
|
|
1726
|
+
let result = compileStatements(statements, meta, context);
|
|
1727
|
+
compilable.compiled.set(context, result);
|
|
1728
|
+
return result;
|
|
1729
|
+
}
|
|
1730
|
+
function compileStatements(statements, meta, syntaxContext) {
|
|
1731
|
+
let sCompiler = STATEMENTS;
|
|
1732
|
+
let context = templateCompilationContext(syntaxContext, meta);
|
|
1733
|
+
let {
|
|
1734
|
+
encoder,
|
|
1735
|
+
evaluation
|
|
1736
|
+
} = context;
|
|
1737
|
+
function pushOp(...op) {
|
|
1738
|
+
encodeOp(encoder, evaluation, meta, op);
|
|
1739
|
+
}
|
|
1740
|
+
for (const statement of statements) {
|
|
1741
|
+
sCompiler.compile(pushOp, statement);
|
|
1742
|
+
}
|
|
1743
|
+
let handle = context.encoder.commit(meta.size);
|
|
1744
|
+
return handle;
|
|
1745
|
+
}
|
|
1746
|
+
function compilableBlock(block, containing) {
|
|
1747
|
+
return new CompilableTemplateImpl(block[0], containing, {
|
|
1748
|
+
parameters: block[1] || EMPTY_ARRAY
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
class WrappedBuilder {
|
|
1753
|
+
symbolTable;
|
|
1754
|
+
compiled = null;
|
|
1755
|
+
attrsBlockNumber;
|
|
1756
|
+
meta;
|
|
1757
|
+
constructor(layout, moduleName) {
|
|
1758
|
+
this.layout = layout;
|
|
1759
|
+
this.moduleName = moduleName;
|
|
1760
|
+
let {
|
|
1761
|
+
block
|
|
1762
|
+
} = layout;
|
|
1763
|
+
let [, symbols] = block;
|
|
1764
|
+
symbols = symbols.slice();
|
|
1765
|
+
|
|
1766
|
+
// ensure ATTRS_BLOCK is always included (only once) in the list of symbols
|
|
1767
|
+
let attrsBlockIndex = symbols.indexOf(ATTRS_BLOCK);
|
|
1768
|
+
if (attrsBlockIndex === -1) {
|
|
1769
|
+
this.attrsBlockNumber = symbols.push(ATTRS_BLOCK);
|
|
1770
|
+
} else {
|
|
1771
|
+
this.attrsBlockNumber = attrsBlockIndex + 1;
|
|
1772
|
+
}
|
|
1773
|
+
this.symbolTable = {
|
|
1774
|
+
symbols
|
|
1775
|
+
};
|
|
1776
|
+
this.meta = meta(layout);
|
|
1777
|
+
}
|
|
1778
|
+
compile(syntax) {
|
|
1779
|
+
if (this.compiled !== null) return this.compiled;
|
|
1780
|
+
let m = meta(this.layout);
|
|
1781
|
+
let context = templateCompilationContext(syntax, m);
|
|
1782
|
+
let {
|
|
1783
|
+
encoder,
|
|
1784
|
+
evaluation
|
|
1785
|
+
} = context;
|
|
1786
|
+
function pushOp(...op) {
|
|
1787
|
+
encodeOp(encoder, evaluation, m, op);
|
|
1788
|
+
}
|
|
1789
|
+
WrappedComponent(pushOp, this.layout, this.attrsBlockNumber);
|
|
1790
|
+
let handle = context.encoder.commit(m.size);
|
|
1791
|
+
if (typeof handle !== 'number') {
|
|
1792
|
+
return handle;
|
|
1793
|
+
}
|
|
1794
|
+
this.compiled = handle;
|
|
1795
|
+
return handle;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
let clientId = 0;
|
|
1800
|
+
let templateCacheCounters = {
|
|
1801
|
+
cacheHit: 0,
|
|
1802
|
+
cacheMiss: 0
|
|
1803
|
+
};
|
|
1804
|
+
|
|
1805
|
+
// These interfaces are for backwards compatibility, some addons use these intimate APIs
|
|
1806
|
+
|
|
1807
|
+
/**
|
|
1808
|
+
* Wraps a template js in a template module to change it into a factory
|
|
1809
|
+
* that handles lazy parsing the template and to create per env singletons
|
|
1810
|
+
* of the template.
|
|
1811
|
+
*/
|
|
1812
|
+
function templateFactory({
|
|
1813
|
+
id: templateId,
|
|
1814
|
+
moduleName,
|
|
1815
|
+
block,
|
|
1816
|
+
scope,
|
|
1817
|
+
isStrictMode
|
|
1818
|
+
}) {
|
|
1819
|
+
// TODO(template-refactors): This should be removed in the near future, as it
|
|
1820
|
+
// appears that id is unused. It is currently kept for backwards compat reasons.
|
|
1821
|
+
let id = templateId || `client-${clientId++}`;
|
|
1822
|
+
|
|
1823
|
+
// TODO: This caches JSON serialized output once in case a template is
|
|
1824
|
+
// compiled by multiple owners, but we haven't verified if this is actually
|
|
1825
|
+
// helpful. We should benchmark this in the future.
|
|
1826
|
+
let parsedBlock;
|
|
1827
|
+
let ownerlessTemplate = null;
|
|
1828
|
+
let templateCache = new WeakMap();
|
|
1829
|
+
let factory = owner => {
|
|
1830
|
+
if (parsedBlock === undefined) {
|
|
1831
|
+
parsedBlock = JSON.parse(block);
|
|
1832
|
+
}
|
|
1833
|
+
if (owner === undefined) {
|
|
1834
|
+
if (ownerlessTemplate === null) {
|
|
1835
|
+
templateCacheCounters.cacheMiss++;
|
|
1836
|
+
ownerlessTemplate = new TemplateImpl({
|
|
1837
|
+
id,
|
|
1838
|
+
block: parsedBlock,
|
|
1839
|
+
moduleName,
|
|
1840
|
+
owner: null,
|
|
1841
|
+
scope,
|
|
1842
|
+
isStrictMode
|
|
1843
|
+
});
|
|
1844
|
+
} else {
|
|
1845
|
+
templateCacheCounters.cacheHit++;
|
|
1846
|
+
}
|
|
1847
|
+
return ownerlessTemplate;
|
|
1848
|
+
}
|
|
1849
|
+
let result = templateCache.get(owner);
|
|
1850
|
+
if (result === undefined) {
|
|
1851
|
+
templateCacheCounters.cacheMiss++;
|
|
1852
|
+
result = new TemplateImpl({
|
|
1853
|
+
id,
|
|
1854
|
+
block: parsedBlock,
|
|
1855
|
+
moduleName,
|
|
1856
|
+
owner,
|
|
1857
|
+
scope,
|
|
1858
|
+
isStrictMode
|
|
1859
|
+
});
|
|
1860
|
+
templateCache.set(owner, result);
|
|
1861
|
+
} else {
|
|
1862
|
+
templateCacheCounters.cacheHit++;
|
|
1863
|
+
}
|
|
1864
|
+
return result;
|
|
1865
|
+
};
|
|
1866
|
+
factory.__id = id;
|
|
1867
|
+
factory.__meta = {
|
|
1868
|
+
moduleName
|
|
1869
|
+
};
|
|
1870
|
+
return factory;
|
|
1871
|
+
}
|
|
1872
|
+
class TemplateImpl {
|
|
1873
|
+
result = 'ok';
|
|
1874
|
+
layout = null;
|
|
1875
|
+
wrappedLayout = null;
|
|
1876
|
+
constructor(parsedLayout) {
|
|
1877
|
+
this.parsedLayout = parsedLayout;
|
|
1878
|
+
}
|
|
1879
|
+
get moduleName() {
|
|
1880
|
+
return this.parsedLayout.moduleName;
|
|
1881
|
+
}
|
|
1882
|
+
get id() {
|
|
1883
|
+
return this.parsedLayout.id;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
// TODO(template-refactors): This should be removed in the near future, it is
|
|
1887
|
+
// only being exposed for backwards compatibility
|
|
1888
|
+
get referrer() {
|
|
1889
|
+
return {
|
|
1890
|
+
moduleName: this.parsedLayout.moduleName,
|
|
1891
|
+
owner: this.parsedLayout.owner
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
asLayout() {
|
|
1895
|
+
if (this.layout) return this.layout;
|
|
1896
|
+
return this.layout = compilable(assign({}, this.parsedLayout), this.moduleName);
|
|
1897
|
+
}
|
|
1898
|
+
asWrappedLayout() {
|
|
1899
|
+
if (this.wrappedLayout) return this.wrappedLayout;
|
|
1900
|
+
return this.wrappedLayout = new WrappedBuilder(assign({}, this.parsedLayout), this.moduleName);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
export { CallDynamic as C, EMPTY_BLOCKS as E, InvokeStaticBlock as I, SwitchCases as S, WrappedBuilder as W, templateCacheCounters as a, compileStatements as b, compilable as c, InvokeStaticBlockWithStack as d, templateCompilationContext as e, EncoderImpl as f, encodeOp as g, InvokeBareComponent as h, invokePreparedComponent as i, meta as m, templateFactory as t };
|