From 0f8a1e02ff036974f29347fa870b1f0e8e78666d Mon Sep 17 00:00:00 2001 From: lauren Date: Fri, 24 Jan 2025 14:41:25 -0500 Subject: [PATCH 1/4] [ci] Make maintainer check workflow usable from other repositories (#32215) For use in reactjs/react.dev --- .github/workflows/shared_check_maintainer.yml | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/shared_check_maintainer.yml b/.github/workflows/shared_check_maintainer.yml index cd43ffe55979a..bf2b3399e8cb8 100644 --- a/.github/workflows/shared_check_maintainer.yml +++ b/.github/workflows/shared_check_maintainer.yml @@ -6,6 +6,10 @@ on: actor: required: true type: string + is_remote: + required: false + type: boolean + default: false outputs: is_core_team: value: ${{ jobs.check_maintainer.outputs.is_core_team }} @@ -29,8 +33,30 @@ jobs: script: | const fs = require('fs'); const actor = '${{ inputs.actor }}'; - const data = await fs.readFileSync('./MAINTAINERS', { encoding: 'utf8' }); - const maintainers = new Set(data.split('\n')); + const isRemote = ${{ inputs.is_remote }}; + + let content = null; + if (isRemote === true) { + const res = await github.rest.repos.getContent({ + owner: 'facebook', + repo: 'react', + path: 'MAINTAINERS', + ref: 'main', + headers: { Accept: 'application/vnd.github+json' } + }); + if (res.status !== 200) { + console.error(res); + throw new Error('Unable to fetch MAINTAINERS file'); + } + content = Buffer.from(res.data.content, 'base64').toString(); + } else { + content = await fs.readFileSync('./MAINTAINERS', { encoding: 'utf8' }); + } + if (content === null) { + throw new Error('Unable to retrieve local or http MAINTAINERS file'); + } + + const maintainers = new Set(content.split('\n')); if (maintainers.has(actor)) { console.log(`🟢 ${actor} is a maintainer`); return true; From 5269823927e1ba0ea14a64478b28c02ba5f0de3e Mon Sep 17 00:00:00 2001 From: lauren Date: Fri, 24 Jan 2025 14:56:37 -0500 Subject: [PATCH 2/4] [ci] Parse inputs for maintainer check workflow (#32216) I forgot that workflow calls stringify their inputs --- .github/workflows/shared_check_maintainer.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/shared_check_maintainer.yml b/.github/workflows/shared_check_maintainer.yml index bf2b3399e8cb8..6ea841d56f73e 100644 --- a/.github/workflows/shared_check_maintainer.yml +++ b/.github/workflows/shared_check_maintainer.yml @@ -33,7 +33,13 @@ jobs: script: | const fs = require('fs'); const actor = '${{ inputs.actor }}'; - const isRemote = ${{ inputs.is_remote }}; + let isRemote = ${{ inputs.is_remote }}; + if (typeof isRemote === 'string') { + isRemote = isRemote === 'true'; + } + if (typeof isRemote !== 'boolean') { + throw new Error(`Invalid `isRemote` input. Expected a boolean, got: ${isRemote}`); + } let content = null; if (isRemote === true) { From a6ce56d9a9162c295ef0086762b76506534de201 Mon Sep 17 00:00:00 2001 From: lauren Date: Fri, 24 Jan 2025 15:06:15 -0500 Subject: [PATCH 3/4] [ci] Fix typo (#32217) yml was a mistake --- .github/workflows/shared_check_maintainer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shared_check_maintainer.yml b/.github/workflows/shared_check_maintainer.yml index 6ea841d56f73e..c20047d600321 100644 --- a/.github/workflows/shared_check_maintainer.yml +++ b/.github/workflows/shared_check_maintainer.yml @@ -38,7 +38,7 @@ jobs: isRemote = isRemote === 'true'; } if (typeof isRemote !== 'boolean') { - throw new Error(`Invalid `isRemote` input. Expected a boolean, got: ${isRemote}`); + throw new Error(`Invalid \`isRemote\` input. Expected a boolean, got: ${isRemote}`); } let content = null; From 9eabb37338e6bea18441dec58a4284fe00ee09ae Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Fri, 24 Jan 2025 12:19:10 -0800 Subject: [PATCH 4/4] [compiler][be] Remove unused experimental Rust port I wrote this a couple summers back as an experiment to see how easily we could translate the compiler to Rust. We make extensive use of in-place mutation of the IR, and the experiment proved that this we can get reasonable ergonomics for this in Rust which was cool. We've since ended up using some of the code here for Relay, allowing Relay Compiler to parse JS files to do more fine-grained extraction of data. For React Compiler though, we plan to continue using JavaScript and explore lightweight native wrappers for things like OXC and SWC plugins. We're also working with the Hermes team to eventually compile the compiler with Static Hermes. As Tomo always says: always bet on JavaScript. ghstack-source-id: c5770a2efce16a7153dd98702f47bc84d380c8b2 Pull Request resolved: https://github.com/facebook/react/pull/32219 --- .github/workflows/compiler_rust.yml | 77 - compiler/Cargo.lock | 1217 --- compiler/Cargo.toml | 61 - compiler/crates/react_build_hir/Cargo.toml | 21 - compiler/crates/react_build_hir/README.md | 3 - compiler/crates/react_build_hir/src/build.rs | 746 -- .../crates/react_build_hir/src/builder.rs | 322 - .../crates/react_build_hir/src/context.rs | 44 - compiler/crates/react_build_hir/src/error.rs | 63 - compiler/crates/react_build_hir/src/lib.rs | 14 - compiler/crates/react_diagnostics/Cargo.toml | 23 - compiler/crates/react_diagnostics/README.md | 10 - .../react_diagnostics/src/diagnostic.rs | 285 - compiler/crates/react_diagnostics/src/lib.rs | 19 - compiler/crates/react_estree/Cargo.toml | 22 - compiler/crates/react_estree/README.md | 17 - compiler/crates/react_estree/build.rs | 31 - compiler/crates/react_estree/src/binding.rs | 30 - .../src/fixtures/for-statement.json | 528 - .../react_estree/src/fixtures/import.json | 104 - .../react_estree/src/fixtures/simple.json | 189 - .../react_estree/src/fixtures/test.json | 351 - compiler/crates/react_estree/src/generated.rs | 9031 ----------------- .../react_estree/src/generated_extensions.rs | 149 - compiler/crates/react_estree/src/js_value.rs | 295 - compiler/crates/react_estree/src/lib.rs | 38 - compiler/crates/react_estree/src/range.rs | 31 - ...e__tests__fixtures@for-statement.json.snap | 1058 -- ...t_estree__tests__fixtures@import.json.snap | 213 - ...t_estree__tests__fixtures@simple.json.snap | 379 - ...get_estree__tests__fixtures@test.json.snap | 708 -- ...e__tests__fixtures@for-statement.json.snap | 1058 -- ...t_estree__tests__fixtures@import.json.snap | 213 - ...t_estree__tests__fixtures@simple.json.snap | 379 - ...act_estree__tests__fixtures@test.json.snap | 708 -- compiler/crates/react_estree/src/visit.rs | 537 - .../crates/react_estree_codegen/Cargo.toml | 21 - .../crates/react_estree_codegen/README.md | 4 - .../react_estree_codegen/src/codegen.rs | 969 -- .../react_estree_codegen/src/ecmascript.json | 1367 --- .../crates/react_estree_codegen/src/lib.rs | 10 - compiler/crates/react_fixtures/Cargo.toml | 24 - compiler/crates/react_fixtures/README.md | 3 - compiler/crates/react_fixtures/src/lib.rs | 6 - ...stant-propagation-constant-if-condition.js | 34 - .../tests/fixtures/constant-propagation.js | 60 - .../tests/fixtures/destructure-array.js | 5 - .../tests/fixtures/destructure-object.js | 15 - .../tests/fixtures/error.assign-to-global.js | 3 - .../tests/fixtures/for-statement.js | 7 - .../tests/fixtures/function-expressions.js | 21 - .../tests/fixtures/identifiers.js | 16 - .../tests/fixtures/if-statement.js | 8 - .../tests/fixtures/simple-function.js | 9 - .../tests/fixtures/simple-ssa.js | 9 - .../react_fixtures/tests/fixtures/simple.js | 4 - .../tests/fixtures/ssa-reassign-if.js | 16 - .../react_fixtures/tests/fixtures/use-memo.js | 8 - .../react_fixtures/tests/fixtures_test.rs | 88 - ...-propagation-constant-if-condition.js.snap | 73 - ...est__fixtures@constant-propagation.js.snap | 198 - ...s_test__fixtures@destructure-array.js.snap | 33 - ..._test__fixtures@destructure-object.js.snap | 46 - ...t__fixtures@error.assign-to-global.js.snap | 13 - ...tures_test__fixtures@for-statement.js.snap | 54 - ...est__fixtures@function-expressions.js.snap | 94 - ...ixtures_test__fixtures@identifiers.js.snap | 41 - ...xtures_test__fixtures@if-statement.js.snap | 40 - ...res_test__fixtures@simple-function.js.snap | 46 - ...fixtures_test__fixtures@simple-ssa.js.snap | 41 - .../fixtures_test__fixtures@simple.js.snap | 27 - ...res_test__fixtures@ssa-reassign-if.js.snap | 73 - .../fixtures_test__fixtures@use-memo.js.snap | 36 - .../crates/react_hermes_parser/Cargo.toml | 23 - compiler/crates/react_hermes_parser/README.md | 3 - compiler/crates/react_hermes_parser/build.rs | 31 - .../react_hermes_parser/src/generated.rs | 4158 -------- .../src/generated_extension.rs | 319 - .../crates/react_hermes_parser/src/lib.rs | 42 - ...s-capture-in-method-receiver-and-mutate.js | 11 - .../alias-capture-in-method-receiver.js | 10 - .../tests/fixtures/alias-computed-load.js | 8 - .../alias-nested-member-path-mutate.js | 9 - .../fixtures/alias-nested-member-path.js | 8 - .../tests/fixtures/alias-while.js | 18 - ...llocating-primitive-as-dep-nested-scope.js | 11 - .../fixtures/allocating-primitive-as-dep.js | 8 - .../fixtures/allow-passing-refs-as-props.js | 4 - .../tests/fixtures/array-access-assignment.js | 8 - .../tests/fixtures/array-at-closure.js | 9 - .../tests/fixtures/array-at-effect.js | 9 - .../fixtures/array-at-mutate-after-capture.js | 10 - .../tests/fixtures/array-expression-spread.js | 4 - .../tests/fixtures/array-join.js | 6 - .../tests/fixtures/array-map-frozen-array.js | 6 - ...array-map-mutable-array-mutating-lambda.js | 8 - .../tests/fixtures/array-pattern-params.js | 5 - .../tests/fixtures/array-properties.js | 6 - .../tests/fixtures/array-property-call.js | 7 - .../tests/fixtures/array-push-effect.js | 11 - .../arrow-function-expr-gating-test.js | 4 - .../assignment-expression-computed.js | 7 - .../assignment-expression-nested-path.js | 6 - .../tests/fixtures/assignment-in-nested-if.js | 11 - ...ignment-variations-complex-lvalue-array.js | 6 - .../assignment-variations-complex-lvalue.js | 6 - .../tests/fixtures/assignment-variations.js | 7 - .../fixtures/await-side-effecting-promise.js | 5 - .../tests/fixtures/await.js | 4 - .../fixtures/babel-existing-react-import.js | 15 - ...babel-existing-react-kitchensink-import.js | 16 - .../bug.useMemo-deps-array-not-cleared.js | 9 - .../tests/fixtures/bug_object-pattern.js | 5 - ...iltin-jsx-tag-lowered-between-mutations.js | 4 - .../tests/fixtures/call-args-assignment.js | 5 - .../call-args-destructuring-assignment.js | 5 - .../tests/fixtures/call-spread.js | 4 - .../call-with-independently-memoizable-arg.js | 9 - .../tests/fixtures/call.js | 10 - .../fixtures/capture-indirect-mutate-alias.js | 11 - .../tests/fixtures/capture-param-mutate.js | 37 - .../fixtures/capture_mutate-across-fns.js | 9 - .../fixtures/capturing-arrow-function-1.js | 7 - .../capturing-fun-alias-captured-mutate-2.js | 11 - ...pturing-fun-alias-captured-mutate-arr-2.js | 11 - ...apturing-func-alias-captured-mutate-arr.js | 11 - .../capturing-func-alias-captured-mutate.js | 11 - .../capturing-func-alias-computed-mutate.js | 9 - .../fixtures/capturing-func-alias-mutate.js | 9 - ...ing-func-alias-receiver-computed-mutate.js | 10 - .../capturing-func-alias-receiver-mutate.js | 10 - .../tests/fixtures/capturing-func-mutate-2.js | 10 - .../tests/fixtures/capturing-func-mutate-3.js | 9 - .../fixtures/capturing-func-mutate-nested.js | 8 - .../tests/fixtures/capturing-func-mutate.js | 10 - .../fixtures/capturing-func-simple-alias.js | 9 - .../tests/fixtures/capturing-function-1.js | 7 - ...apturing-function-alias-computed-load-2.js | 9 - ...apturing-function-alias-computed-load-3.js | 11 - ...apturing-function-alias-computed-load-4.js | 9 - .../capturing-function-alias-computed-load.js | 9 - ...ring-function-capture-ref-before-rename.js | 14 - ...ing-function-conditional-capture-mutate.js | 14 - .../tests/fixtures/capturing-function-decl.js | 8 - ...apturing-function-member-expr-arguments.js | 10 - .../capturing-function-member-expr-call.js | 11 - .../capturing-function-renamed-ref.js | 10 - .../capturing-function-runs-inference.js | 5 - .../capturing-function-shadow-captured.js | 8 - .../capturing-function-skip-computed-path.js | 4 - .../capturing-function-within-block.js | 10 - .../tests/fixtures/capturing-member-expr.js | 7 - .../fixtures/capturing-nested-member-call.js | 7 - ...uring-nested-member-expr-in-nested-func.js | 9 - .../fixtures/capturing-nested-member-expr.js | 7 - .../capturing-reference-changes-type.js | 9 - .../capturing-variable-in-nested-block.js | 9 - .../capturing-variable-in-nested-function.js | 9 - .../chained-assignment-context-variable.js | 9 - .../chained-assignment-expressions.js | 8 - .../codegen-emit-imports-same-source.js | 5 - .../fixtures/codegen-emit-make-read-only.js | 11 - .../codegen-instrument-forget-gating-test.js | 15 - .../codegen-instrument-forget-test.js | 15 - .../tests/fixtures/complex-while.js | 10 - .../tests/fixtures/component.js | 26 - .../computed-call-evaluation-order.js | 14 - .../tests/fixtures/computed-call-spread.js | 4 - .../computed-load-primitive-as-dependency.js | 9 - .../tests/fixtures/computed-store-alias.js | 7 - .../tests/fixtures/concise-arrow-expr.js | 5 - .../cond-deps-conditional-member-expr.js | 9 - .../fixtures/conditional-break-labeled.js | 15 - .../tests/fixtures/conditional-break.js | 53 - .../tests/fixtures/conditional-on-mutable.js | 26 - .../conditional-set-state-in-render.js | 14 - .../tests/fixtures/console-readonly.js | 11 - ...agation-into-function-expression-global.js | 8 - ...tion-into-function-expression-primitive.js | 8 - .../tests/fixtures/constant-computed.js | 7 - .../fixtures/constant-propagation-for.js | 7 - ...t-propagation-into-function-expressions.js | 7 - .../fixtures/constant-propagation-phi.js | 13 - .../fixtures/constant-propagation-while.js | 8 - .../tests/fixtures/constant-propagation.js | 18 - .../tests/fixtures/constructor.js | 10 - ...t-variable-reassigned-outside-of-lambda.js | 9 - .../tests/fixtures/controlled-input.js | 5 - .../tests/fixtures/dce-loop.js | 9 - .../tests/fixtures/debugger-memoized.js | 6 - .../tests/fixtures/debugger.js | 11 - .../declare-reassign-variable-in-closure.js | 9 - ...assign-variable-in-function-declaration.js | 8 - .../fixtures/delete-computed-property.js | 6 - .../tests/fixtures/delete-property.js | 5 - .../tests/fixtures/dependencies-outputs.js | 14 - .../tests/fixtures/dependencies.js | 15 - .../fixtures/destructure-capture-global.js | 5 - .../destructure-direct-reassignment.js | 7 - .../fixtures/destructuring-array-default.js | 4 - .../destructuring-array-param-default.js | 3 - .../destructuring-assignment-array-default.js | 9 - .../fixtures/destructuring-assignment.js | 18 - ...-scope-and-local-variables-with-default.js | 20 - ...ing-mixed-scope-declarations-and-locals.js | 20 - .../fixtures/destructuring-object-default.js | 4 - .../destructuring-object-param-default.js | 3 - .../destructuring-property-inference.js | 7 - .../tests/fixtures/destructuring.js | 19 - .../tests/fixtures/disable-jsx-memoization.js | 12 - .../tests/fixtures/do-while-break.js | 6 - .../tests/fixtures/do-while-compound-test.js | 9 - .../fixtures/do-while-conditional-break.js | 10 - .../tests/fixtures/do-while-continue.js | 13 - .../do-while-early-unconditional-break.js | 8 - .../tests/fixtures/do-while-simple.js | 9 - .../tests/fixtures/dominator.js | 33 - .../tests/fixtures/early-return.js | 8 - ...rror._todo.computed-lval-in-destructure.js | 6 - ...i-arrow-expr-export-default-gating-test.js | 9 - ...r.babel-existing-react-namespace-import.js | 15 - ...ot-all-mutable-range-extensions-are-bad.js | 24 - ...ll-args-destructuring-asignment-complex.js | 5 - ...or.codegen-error-on-conflicting-imports.js | 6 - .../error.hoisted-function-declaration.js | 8 - .../error.hooks-with-React-namespace.js | 4 - .../error.invalid-access-ref-during-render.js | 6 - .../error.invalid-array-push-frozen.js | 6 - .../error.invalid-assign-hook-to-local.js | 5 - ...rror.invalid-capture-func-passed-to-jsx.js | 11 - ....invalid-computed-store-to-frozen-value.js | 7 - ...elete-computed-property-of-frozen-value.js | 7 - ...invalid-delete-property-of-frozen-value.js | 7 - ...nvalid-destructure-assignment-to-global.js | 4 - ...d-destructure-to-local-global-variables.js | 6 - ...lid-freeze-conditionally-mutable-lambda.js | 16 - ...alid-freeze-mutable-lambda-mutate-local.js | 9 - ...id-freeze-mutable-lambda-reassign-local.js | 7 - ...tion-expression-mutates-immutable-value.js | 9 - ...ror.invalid-mutate-after-aliased-freeze.js | 16 - .../error.invalid-mutate-after-freeze.js | 10 - .../error.invalid-pass-hook-as-call-arg.js | 3 - .../error.invalid-pass-hook-as-prop.js | 3 - .../error.invalid-pass-ref-to-function.js | 5 - ....invalid-property-store-to-frozen-value.js | 7 - ...d-ref-in-callback-invoked-during-render.js | 9 - .../error.invalid-ref-value-as-props.js | 4 - ....invalid-set-and-read-ref-during-render.js | 5 - .../error.invalid-sketchy-code-use-forget.js | 7 - .../error.invalid-ternary-with-hook-values.js | 4 - ...valid-unconditional-set-state-in-render.js | 9 - ...-use-ref-added-to-dep-without-type-info.js | 12 - .../error.invalid-useMemo-async-callback.js | 6 - .../error.invalid-useMemo-callback-args.js | 4 - .../error.mutate-captured-arg-separately.js | 10 - ...utate-global-increment-op-invalid-react.js | 6 - .../fixtures/error.reassignment-to-global.js | 5 - .../tests/fixtures/error.todo-kitchensink.js | 70 - ...ror.todo-unconditional-set-state-lambda.js | 12 - ...o.destructure-assignment-to-context-var.js | 9 - .../error.useMemo-callback-generator.js | 9 - .../error.while-with-assignment-in-test.js | 10 - ...cape-analysis-destructured-rest-element.js | 7 - .../fixtures/escape-analysis-jsx-child.js | 11 - .../tests/fixtures/escape-analysis-logical.js | 8 - ...aping-interleaved-allocating-dependency.js | 15 - ...nterleaved-allocating-nested-dependency.js | 24 - ...caping-interleaved-primitive-dependency.js | 17 - .../escape-analysis-not-conditional-test.js | 5 - .../fixtures/escape-analysis-not-if-test.js | 10 - .../escape-analysis-not-switch-case.js | 10 - .../escape-analysis-not-switch-test.js | 10 - .../expression-with-assignment-dynamic.js | 4 - .../fixtures/expression-with-assignment.js | 4 - .../tests/fixtures/extend-scopes-if.js | 14 - .../fixtures/fbt-call-complex-param-value.js | 9 - .../tests/fixtures/fbt-call.js | 9 - .../fbt-params-complex-param-value.js | 9 - .../tests/fixtures/fbt-params.js | 9 - .../fbt-template-string-same-scope.js | 17 - .../for-empty-update-with-continue.js | 9 - .../tests/fixtures/for-empty-update.js | 10 - .../tests/fixtures/for-logical.js | 12 - .../tests/fixtures/for-of-break.js | 7 - .../fixtures/for-of-conditional-break.js | 10 - .../tests/fixtures/for-of-continue.js | 11 - .../tests/fixtures/for-of-destructure.js | 8 - .../tests/fixtures/for-of-mutate.js | 8 - .../tests/fixtures/for-of-mutate.tsx | 8 - .../tests/fixtures/for-of-simple.js | 8 - .../tests/fixtures/for-return.js | 5 - .../tests/fixtures/frozen-after-alias.js | 10 - .../fixtures/function-declaration-reassign.js | 7 - .../function-declaration-redeclare.js | 7 - .../fixtures/function-declaration-simple.js | 8 - ...ression-captures-value-later-frozen-jsx.js | 12 - ...ression-maybe-mutates-hook-return-value.js | 12 - ...tion-expression-with-store-to-parameter.js | 9 - .../function-param-assignment-pattern.js | 3 - .../gating-test-export-default-function.js | 14 - ...gating-test-export-function-and-default.js | 14 - .../fixtures/gating-test-export-function.js | 14 - .../tests/fixtures/gating-test.js | 14 - ...lobal-jsx-tag-lowered-between-mutations.js | 15 - .../tests/fixtures/globals-Boolean.js | 5 - .../tests/fixtures/globals-Number.js | 5 - .../tests/fixtures/globals-String.js | 5 - .../tests/fixtures/holey-array-expr.js | 4 - .../fixtures/holey-array-pattern-dce-2.js | 4 - .../tests/fixtures/holey-array-pattern-dce.js | 4 - .../tests/fixtures/holey-array.js | 5 - .../tests/fixtures/hook-call.js | 14 - .../hook-inside-logical-expression.js | 4 - .../tests/fixtures/hooks-freeze-arguments.js | 10 - ...hooks-freeze-possibly-mutable-arguments.js | 17 - .../tests/fixtures/immutable-hooks.js | 9 - .../inadvertent-mutability-readonly-class.js | 15 - .../inadvertent-mutability-readonly-lambda.js | 13 - .../tests/fixtures/independent-across-if.js | 28 - .../tests/fixtures/independent.js | 19 - .../independently-memoize-object-property.js | 7 - .../tests/fixtures/infer-computed-delete.js | 6 - .../tests/fixtures/infer-global-object.js | 13 - .../tests/fixtures/infer-phi-primitive.js | 11 - .../tests/fixtures/infer-property-delete.js | 5 - .../infer-types-through-type-cast.flow.js | 9 - ...lue-not-promoted-to-outer-scope-dynamic.js | 14 - ...alue-not-promoted-to-outer-scope-static.js | 11 - .../fixtures/interdependent-across-if.js | 22 - .../tests/fixtures/interdependent.js | 19 - .../tests/fixtures/inverted-if-else.js | 11 - .../tests/fixtures/inverted-if.js | 11 - .../tests/fixtures/issue852.js | 6 - .../issue933-disjoint-set-infinite-loop.js | 8 - .../tests/fixtures/jsx-empty-expression.js | 8 - .../tests/fixtures/jsx-fragment.js | 10 - .../jsx-member-expression-tag-grouping.js | 4 - .../tests/fixtures/jsx-member-expression.js | 7 - .../tests/fixtures/jsx-namespaced-name.js | 3 - .../tests/fixtures/jsx-spread.js | 5 - .../jsx-tag-evaluation-order-non-global.js | 13 - .../fixtures/jsx-tag-evaluation-order.js | 9 - .../fixtures/lambda-capture-returned-alias.js | 18 - .../fixtures/lambda-mutate-shadowed-object.js | 11 - ...lambda-mutated-non-reactive-to-reactive.js | 7 - .../lambda-mutated-ref-non-reactive.js | 8 - .../fixtures/lambda-reassign-primitive.js | 14 - .../lambda-reassign-shadowed-primitive.js | 11 - .../tests/fixtures/lambda-with-fbt.js | 30 - .../fixtures/logical-expression-object.js | 10 - .../tests/fixtures/logical-expression.js | 5 - .../tests/fixtures/method-call-computed.js | 13 - .../tests/fixtures/method-call-fn-call.js | 10 - .../tests/fixtures/method-call.js | 9 - .../multi-arrow-expr-export-gating-test.js | 9 - .../fixtures/multi-arrow-expr-gating-test.js | 11 - .../tests/fixtures/mutable-lifetime-loops.js | 34 - .../mutable-lifetime-with-aliasing.js | 30 - .../tests/fixtures/mutable-liverange-loop.js | 29 - .../nested-function-shadowed-identifiers.js | 10 - .../fixtures/nested-optional-member-expr.js | 6 - .../tests/fixtures/nested-scopes-hook-call.js | 7 - .../tests/fixtures/new-spread.js | 4 - ...noptional-load-from-optional-memberexpr.js | 8 - .../fixtures/obj-literal-cached-in-if-else.js | 10 - .../obj-literal-mutated-after-if-else.js | 11 - .../obj-mutated-after-if-else-with-alias.js | 13 - .../fixtures/obj-mutated-after-if-else.js | 11 - ...mutated-after-nested-if-else-with-alias.js | 19 - .../object-computed-access-assignment.js | 5 - .../object-expression-string-literal-key.js | 4 - .../fixtures/object-literal-spread-element.js | 4 - .../tests/fixtures/object-pattern-params.js | 5 - .../tests/fixtures/object-properties.js | 7 - .../tests/fixtures/optional-call-chained.js | 3 - .../tests/fixtures/optional-call-logical.js | 4 - .../tests/fixtures/optional-call-simple.js | 3 - ...-call-with-independently-memoizable-arg.js | 13 - ...tional-call-with-optional-property-load.js | 3 - .../tests/fixtures/optional-call.js | 6 - .../fixtures/optional-computed-load-static.js | 4 - .../optional-computed-member-expression.js | 4 - ...onal-member-expression-call-as-property.js | 4 - .../optional-member-expression-chain.js | 7 - ...n-with-optional-member-expr-as-property.js | 4 - .../fixtures/optional-member-expression.js | 7 - .../tests/fixtures/optional-method-call.js | 6 - .../fixtures/optional-receiver-method-call.js | 6 - .../optional-receiver-optional-method.js | 6 - ...rlapping-scopes-interleaved-by-terminal.js | 10 - .../overlapping-scopes-interleaved.js | 6 - .../fixtures/overlapping-scopes-shadowed.js | 6 - ...erlapping-scopes-shadowing-within-block.js | 12 - .../fixtures/overlapping-scopes-while.js | 8 - .../overlapping-scopes-within-block.js | 12 - .../tests/fixtures/primitive-alias-mutate.js | 11 - .../fixtures/primitive-as-dep-nested-scope.js | 12 - .../tests/fixtures/primitive-as-dep.js | 9 - .../fixtures/prop-capturing-function-1.js | 7 - .../tests/fixtures/property-assignment.js | 8 - .../property-call-evaluation-order.js | 13 - .../tests/fixtures/property-call-spread.js | 4 - ...tional-properties-inside-optional-chain.js | 3 - .../tests/fixtures/reactive-scope-grouping.js | 9 - .../tests/fixtures/reactive-scopes-if.js | 11 - .../tests/fixtures/reactive-scopes.js | 10 - ...ctivity-analysis-interleaved-reactivity.js | 19 - ...-reactive-via-mutation-of-computed-load.js | 8 - ...-reactive-via-mutation-of-property-load.js | 8 - .../fixtures/reassign-object-in-context.js | 8 - .../fixtures/reassign-primitive-in-context.js | 8 - ...ned-phi-in-returned-function-expression.js | 11 - .../fixtures/reassignment-conditional.js | 13 - .../fixtures/reassignment-separate-scopes.js | 25 - .../tests/fixtures/reassignment.js | 12 - .../tests/fixtures/recursive-function-expr.js | 3 - .../reduce-reactive-cond-deps-cfg-condexpr.js | 8 - .../reduce-reactive-cond-deps-cfg-ifelse.js | 13 - ...ive-cond-deps-cfg-nested-ifelse-missing.js | 14 - ...ce-reactive-cond-deps-cfg-nested-ifelse.js | 19 - ...ctive-cond-deps-cfg-switch-missing-case.js | 18 - ...ve-cond-deps-cfg-switch-missing-default.js | 15 - .../reduce-reactive-cond-deps-cfg-switch.js | 18 - .../reduce-reactive-cond-deps-no-uncond.js | 10 - ...educe-reactive-cond-deps-promote-uncond.js | 11 - ...educe-reactive-cond-deps-subpath-order1.js | 13 - ...educe-reactive-cond-deps-subpath-order2.js | 13 - ...uce-reactive-cond-deps-superpath-order1.js | 12 - ...uce-reactive-cond-deps-superpath-order2.js | 12 - .../reduce-reactive-cond-memberexpr-join.js | 17 - ...dependencies-optional-member-expression.js | 6 - .../reduce-reactive-deps-cond-scope.js | 26 - ...ctive-deps-join-uncond-scopes-cond-deps.js | 26 - ...ctive-uncond-deps-nonoverlap-descendant.js | 9 - ...-reactive-uncond-deps-nonoverlap-direct.js | 8 - ...reactive-uncond-deps-overlap-descendant.js | 9 - ...uce-reactive-uncond-deps-overlap-direct.js | 9 - ...uce-reactive-uncond-deps-subpath-order1.js | 9 - ...uce-reactive-uncond-deps-subpath-order2.js | 9 - ...uce-reactive-uncond-deps-subpath-order3.js | 9 - .../ref-current-aliased-no-added-to-dep.js | 10 - .../ref-current-aliased-not-added-to-dep-2.js | 8 - .../ref-current-field-not-added-to-dep.js | 9 - .../ref-current-not-added-to-dep-2.js | 7 - .../fixtures/ref-current-not-added-to-dep.js | 8 - ...-current-optional-field-no-added-to-dep.js | 8 - .../ref-current-write-not-added-to-dep.js | 8 - .../tests/fixtures/ref-in-effect.js | 11 - .../tests/fixtures/regexp-literal.js | 10 - .../remove-memoization-kitchen-sink.js | 12 - ...ssign-to-variable-without-mutable-range.js | 11 - .../repro-scope-missing-mutable-range.js | 10 - .../tests/fixtures/repro.js | 14 - .../tests/fixtures/return-conditional.js | 7 - .../tests/fixtures/return-undefined.js | 6 - .../tests/fixtures/reverse-postorder.js | 27 - ...iable-as-dep-and-redeclare-maybe-frozen.js | 35 - .../same-variable-as-dep-and-redeclare.js | 35 - .../tests/fixtures/sequence-expression.js | 9 - ...onstant-progagatable-if-test-conditions.js | 34 - .../tests/fixtures/simple-alias.js | 11 - .../tests/fixtures/simple-function-1.js | 6 - .../tests/fixtures/simple-scope.js | 4 - .../tests/fixtures/simple.js | 6 - .../fixtures/sketchy-code-exhaustive-deps.js | 11 - .../fixtures/sketchy-code-rules-of-hooks.js | 6 - .../tests/fixtures/ssa-arrayexpression.js | 6 - .../tests/fixtures/ssa-call-jsx-2.js | 13 - .../tests/fixtures/ssa-call-jsx.js | 10 - .../fixtures/ssa-cascading-eliminated-phis.js | 15 - .../tests/fixtures/ssa-complex-multiple-if.js | 12 - .../tests/fixtures/ssa-complex-single-if.js | 9 - .../tests/fixtures/ssa-for-of.js | 10 - .../tests/fixtures/ssa-for-trivial-update.js | 7 - .../tests/fixtures/ssa-for.js | 7 - .../tests/fixtures/ssa-if-else.js | 10 - .../tests/fixtures/ssa-leave-case.js | 14 - .../tests/fixtures/ssa-multiple-phis.js | 19 - .../fixtures/ssa-nested-loops-no-reassign.js | 12 - .../tests/fixtures/ssa-nested-partial-phi.js | 10 - .../ssa-nested-partial-reassignment.js | 11 - .../tests/fixtures/ssa-newexpression.js | 8 - .../fixtures/ssa-non-empty-initializer.js | 9 - .../fixtures/ssa-objectexpression-phi.js | 13 - .../tests/fixtures/ssa-objectexpression.js | 6 - .../ssa-property-alias-alias-mutate-if.js | 13 - .../tests/fixtures/ssa-property-alias-if.js | 11 - .../fixtures/ssa-property-alias-mutate-if.js | 12 - .../ssa-property-alias-mutate-inside-if.js | 12 - .../fixtures/ssa-property-alias-mutate.js | 10 - .../tests/fixtures/ssa-property-call.js | 6 - .../tests/fixtures/ssa-property-mutate-2.js | 7 - .../fixtures/ssa-property-mutate-alias.js | 10 - .../tests/fixtures/ssa-property-mutate.js | 7 - .../tests/fixtures/ssa-property.js | 6 - .../tests/fixtures/ssa-reassign-in-rval.js | 6 - .../tests/fixtures/ssa-reassign.js | 7 - ...aming-ternary-destruction-with-mutation.js | 7 - .../ssa-renaming-ternary-destruction.js | 6 - .../ssa-renaming-ternary-with-mutation.js | 7 - .../tests/fixtures/ssa-renaming-ternary.js | 6 - ...ing-unconditional-ternary-with-mutation.js | 9 - .../ssa-renaming-unconditional-ternary.js | 8 - ...sa-renaming-unconditional-with-mutation.js | 15 - ...enaming-via-destructuring-with-mutation.js | 11 - .../ssa-renaming-via-destructuring.js | 10 - .../fixtures/ssa-renaming-with-mutation.js | 11 - .../tests/fixtures/ssa-renaming.js | 10 - .../tests/fixtures/ssa-return.js | 8 - .../tests/fixtures/ssa-shadowing.js | 12 - .../tests/fixtures/ssa-sibling-phis.js | 19 - .../tests/fixtures/ssa-simple-phi.js | 11 - .../tests/fixtures/ssa-simple.js | 4 - .../tests/fixtures/ssa-single-if.js | 8 - .../tests/fixtures/ssa-switch.js | 19 - .../tests/fixtures/ssa-throw.js | 7 - .../tests/fixtures/ssa-while-no-reassign.js | 8 - .../tests/fixtures/ssa-while.js | 8 - .../tests/fixtures/store-via-call.js | 6 - .../tests/fixtures/store-via-new.js | 6 - .../switch-global-propertyload-case-test.js | 10 - .../fixtures/switch-non-final-default.js | 23 - .../tests/fixtures/switch-with-fallthrough.js | 27 - .../tests/fixtures/switch.js | 18 - .../tests/fixtures/tagged-template-in-hook.js | 4 - .../tests/fixtures/tagged-template-literal.js | 16 - .../tests/fixtures/template-literal.js | 10 - .../temporary-accessed-outside-scope.js | 5 - .../temporary-at-start-of-value-block.js | 5 - ...ry-property-load-accessed-outside-scope.js | 5 - .../fixtures/ternary-assignment-expression.js | 5 - .../tests/fixtures/ternary-expression.js | 5 - .../tests/fixtures/timers.js | 10 - ...-expression-captures-value-later-frozen.js | 14 - .../todo.unnecessary-lambda-memoization.js | 14 - .../tests/fixtures/transitive-alias-fields.js | 12 - .../tests/fixtures/trivial.js | 3 - .../type-args-test-binary-operator.js | 5 - .../tests/fixtures/type-binary-operator.js | 7 - .../fixtures/type-cast-expression.flow.js | 9 - .../tests/fixtures/type-field-load.js | 5 - .../type-test-field-load-binary-op.js | 11 - .../tests/fixtures/type-test-field-store.js | 7 - .../tests/fixtures/type-test-polymorphic.js | 14 - .../tests/fixtures/type-test-primitive.js | 6 - .../type-test-return-type-inference.js | 10 - .../tests/fixtures/unary-expr.js | 11 - .../fixtures/unconditional-break-label.js | 8 - ...itialized-declaration-in-reactive-scope.js | 6 - .../fixtures/unknown-hooks-do-not-assert.js | 11 - .../fixtures/unused-array-middle-element.js | 4 - .../fixtures/unused-array-rest-element.js | 4 - .../tests/fixtures/unused-conditional.js | 5 - .../unused-logical-assigned-to-variable.js | 7 - .../tests/fixtures/unused-logical.js | 5 - .../unused-object-element-with-rest.js | 5 - .../tests/fixtures/unused-object-element.js | 4 - ...ed-optional-method-assigned-to-variable.js | 6 - .../unused-ternary-assigned-to-variable.js | 6 - .../tests/fixtures/update-expression.js | 6 - .../tests/fixtures/use-callback-simple.js | 6 - .../tests/fixtures/useEffect-arg-memoized.js | 16 - .../fixtures/useEffect-nested-lambdas.js | 22 - .../useMemo-if-else-multiple-return.js | 9 - .../useMemo-independently-memoizeable.js | 9 - .../fixtures/useMemo-inlining-block-return.js | 8 - .../tests/fixtures/useMemo-inverted-if.js | 12 - ...-labeled-statement-unconditional-return.js | 8 - .../tests/fixtures/useMemo-logical.js | 4 - .../fixtures/useMemo-multiple-if-else.js | 14 - .../tests/fixtures/useMemo-named-function.js | 4 - .../tests/fixtures/useMemo-nested-ifs.js | 9 - .../tests/fixtures/useMemo-return-empty.js | 6 - .../tests/fixtures/useMemo-simple.js | 4 - .../fixtures/useMemo-switch-no-fallthrough.js | 13 - .../tests/fixtures/useMemo-switch-return.js | 19 - .../tests/fixtures/while-break.js | 6 - .../fixtures/while-conditional-continue.js | 10 - .../tests/fixtures/while-logical.js | 7 - .../tests/fixtures/while-property.js | 7 - .../react_hermes_parser/tests/parser_test.rs | 26 - ...ture-in-method-receiver-and-mutate.js.snap | 288 - ...s@alias-capture-in-method-receiver.js.snap | 248 - ...test__fixtures@alias-computed-load.js.snap | 316 - ...es@alias-nested-member-path-mutate.js.snap | 388 - ..._fixtures@alias-nested-member-path.js.snap | 310 - .../parser_test__fixtures@alias-while.js.snap | 560 - ...ting-primitive-as-dep-nested-scope.js.snap | 377 - ...xtures@allocating-primitive-as-dep.js.snap | 209 - ...xtures@allow-passing-refs-as-props.js.snap | 201 - ...__fixtures@array-access-assignment.js.snap | 482 - ...er_test__fixtures@array-at-closure.js.snap | 410 - ...ser_test__fixtures@array-at-effect.js.snap | 299 - ...ures@array-at-mutate-after-capture.js.snap | 347 - ...__fixtures@array-expression-spread.js.snap | 228 - .../parser_test__fixtures@array-join.js.snap | 331 - ...t__fixtures@array-map-frozen-array.js.snap | 329 - ...-map-mutable-array-mutating-lambda.js.snap | 332 - ...est__fixtures@array-pattern-params.js.snap | 272 - ...er_test__fixtures@array-properties.js.snap | 460 - ...test__fixtures@array-property-call.js.snap | 468 - ...r_test__fixtures@array-push-effect.js.snap | 427 - ...es@arrow-function-expr-gating-test.js.snap | 191 - ...res@assignment-expression-computed.js.snap | 309 - ...@assignment-expression-nested-path.js.snap | 420 - ...__fixtures@assignment-in-nested-if.js.snap | 269 - ...nt-variations-complex-lvalue-array.js.snap | 281 - ...signment-variations-complex-lvalue.js.snap | 389 - ...st__fixtures@assignment-variations.js.snap | 249 - ...tures@await-side-effecting-promise.js.snap | 204 - .../parser_test__fixtures@await.js.snap | 248 - ...xtures@babel-existing-react-import.js.snap | 718 -- ...-existing-react-kitchensink-import.js.snap | 756 -- ...bug.useMemo-deps-array-not-cleared.js.snap | 327 - ..._test__fixtures@bug_object-pattern.js.snap | 232 - ...-jsx-tag-lowered-between-mutations.js.snap | 211 - ...est__fixtures@call-args-assignment.js.snap | 224 - ...call-args-destructuring-assignment.js.snap | 234 - .../parser_test__fixtures@call-spread.js.snap | 220 - ...-with-independently-memoizable-arg.js.snap | 351 - .../parser_test__fixtures@call.js.snap | 478 - ...ures@capture-indirect-mutate-alias.js.snap | 352 - ...est__fixtures@capture-param-mutate.js.snap | 1381 --- ...fixtures@capture_mutate-across-fns.js.snap | 311 - ...ixtures@capturing-arrow-function-1.js.snap | 278 - ...turing-fun-alias-captured-mutate-2.js.snap | 499 - ...ng-fun-alias-captured-mutate-arr-2.js.snap | 477 - ...ing-func-alias-captured-mutate-arr.js.snap | 477 - ...pturing-func-alias-captured-mutate.js.snap | 499 - ...pturing-func-alias-computed-mutate.js.snap | 343 - ...xtures@capturing-func-alias-mutate.js.snap | 344 - ...unc-alias-receiver-computed-mutate.js.snap | 383 - ...pturing-func-alias-receiver-mutate.js.snap | 384 - ...__fixtures@capturing-func-mutate-2.js.snap | 425 - ...__fixtures@capturing-func-mutate-3.js.snap | 396 - ...tures@capturing-func-mutate-nested.js.snap | 355 - ...st__fixtures@capturing-func-mutate.js.snap | 464 - ...xtures@capturing-func-simple-alias.js.snap | 325 - ...est__fixtures@capturing-function-1.js.snap | 277 - ...ing-function-alias-computed-load-2.js.snap | 300 - ...ing-function-alias-computed-load-3.js.snap | 434 - ...ing-function-alias-computed-load-4.js.snap | 319 - ...uring-function-alias-computed-load.js.snap | 282 - ...function-capture-ref-before-rename.js.snap | 486 - ...unction-conditional-capture-mutate.js.snap | 343 - ...__fixtures@capturing-function-decl.js.snap | 286 - ...ing-function-member-expr-arguments.js.snap | 318 - ...apturing-function-member-expr-call.js.snap | 461 - ...res@capturing-function-renamed-ref.js.snap | 341 - ...@capturing-function-runs-inference.js.snap | 291 - ...capturing-function-shadow-captured.js.snap | 289 - ...turing-function-skip-computed-path.js.snap | 282 - ...es@capturing-function-within-block.js.snap | 319 - ...st__fixtures@capturing-member-expr.js.snap | 296 - ...tures@capturing-nested-member-call.js.snap | 317 - ...-nested-member-expr-in-nested-func.js.snap | 394 - ...tures@capturing-nested-member-expr.js.snap | 347 - ...s@capturing-reference-changes-type.js.snap | 325 - ...capturing-variable-in-nested-block.js.snap | 289 - ...turing-variable-in-nested-function.js.snap | 324 - ...hained-assignment-context-variable.js.snap | 311 - ...res@chained-assignment-expressions.js.snap | 518 - ...s@codegen-emit-imports-same-source.js.snap | 129 - ...xtures@codegen-emit-make-read-only.js.snap | 366 - ...egen-instrument-forget-gating-test.js.snap | 485 - ...res@codegen-instrument-forget-test.js.snap | 485 - ...arser_test__fixtures@complex-while.js.snap | 237 - .../parser_test__fixtures@component.js.snap | 1185 --- ...res@computed-call-evaluation-order.js.snap | 656 -- ...est__fixtures@computed-call-spread.js.snap | 258 - ...puted-load-primitive-as-dependency.js.snap | 330 - ...est__fixtures@computed-store-alias.js.snap | 339 - ..._test__fixtures@concise-arrow-expr.js.snap | 316 - ...@cond-deps-conditional-member-expr.js.snap | 229 - ...fixtures@conditional-break-labeled.js.snap | 463 - ...r_test__fixtures@conditional-break.js.snap | 1574 --- ...t__fixtures@conditional-on-mutable.js.snap | 1060 -- ...es@conditional-set-state-in-render.js.snap | 386 - ...er_test__fixtures@console-readonly.js.snap | 503 - ...on-into-function-expression-global.js.snap | 315 - ...into-function-expression-primitive.js.snap | 263 - ...r_test__fixtures@constant-computed.js.snap | 358 - ..._fixtures@constant-propagation-for.js.snap | 269 - ...pagation-into-function-expressions.js.snap | 300 - ..._fixtures@constant-propagation-phi.js.snap | 370 - ...ixtures@constant-propagation-while.js.snap | 241 - ...est__fixtures@constant-propagation.js.snap | 641 -- .../parser_test__fixtures@constructor.js.snap | 478 - ...iable-reassigned-outside-of-lambda.js.snap | 349 - ...er_test__fixtures@controlled-input.js.snap | 373 - .../parser_test__fixtures@dce-loop.js.snap | 294 - ...r_test__fixtures@debugger-memoized.js.snap | 214 - .../parser_test__fixtures@debugger.js.snap | 214 - ...clare-reassign-variable-in-closure.js.snap | 246 - ...n-variable-in-function-declaration.js.snap | 306 - ..._fixtures@delete-computed-property.js.snap | 318 - ...ser_test__fixtures@delete-property.js.snap | 279 - ...est__fixtures@dependencies-outputs.js.snap | 509 - ...parser_test__fixtures@dependencies.js.snap | 439 - ...ixtures@destructure-capture-global.js.snap | 231 - ...es@destructure-direct-reassignment.js.snap | 479 - ...xtures@destructuring-array-default.js.snap | 194 - ...@destructuring-array-param-default.js.snap | 115 - ...ructuring-assignment-array-default.js.snap | 342 - ..._fixtures@destructuring-assignment.js.snap | 624 -- ...e-and-local-variables-with-default.js.snap | 816 -- ...ixed-scope-declarations-and-locals.js.snap | 766 -- ...tures@destructuring-object-default.js.snap | 260 - ...destructuring-object-param-default.js.snap | 137 - ...s@destructuring-property-inference.js.snap | 337 - ...arser_test__fixtures@destructuring.js.snap | 536 - ...__fixtures@disable-jsx-memoization.js.snap | 474 - ...rser_test__fixtures@do-while-break.js.snap | 147 - ...t__fixtures@do-while-compound-test.js.snap | 426 - ...ixtures@do-while-conditional-break.js.snap | 312 - ...r_test__fixtures@do-while-continue.js.snap | 446 - ...do-while-early-unconditional-break.js.snap | 254 - ...ser_test__fixtures@do-while-simple.js.snap | 377 - .../parser_test__fixtures@dominator.js.snap | 784 -- ...parser_test__fixtures@early-return.js.snap | 208 - ..._todo.computed-lval-in-destructure.js.snap | 239 - ...ow-expr-export-default-gating-test.js.snap | 400 - ...el-existing-react-namespace-import.js.snap | 756 -- ...l-mutable-range-extensions-are-bad.js.snap | 813 -- ...gs-destructuring-asignment-complex.js.snap | 244 - ...degen-error-on-conflicting-imports.js.snap | 168 - ...error.hoisted-function-declaration.js.snap | 297 - ...s@error.hooks-with-React-namespace.js.snap | 175 - ...r.invalid-access-ref-during-render.js.snap | 206 - ...es@error.invalid-array-push-frozen.js.snap | 279 - ...error.invalid-assign-hook-to-local.js.snap | 204 - ...invalid-capture-func-passed-to-jsx.js.snap | 547 - ...lid-computed-store-to-frozen-value.js.snap | 268 - ...-computed-property-of-frozen-value.js.snap | 261 - ...id-delete-property-of-frozen-value.js.snap | 261 - ...d-destructure-assignment-to-global.js.snap | 169 - ...tructure-to-local-global-variables.js.snap | 218 - ...reeze-conditionally-mutable-lambda.js.snap | 452 - ...freeze-mutable-lambda-mutate-local.js.snap | 443 - ...eeze-mutable-lambda-reassign-local.js.snap | 364 - ...expression-mutates-immutable-value.js.snap | 515 - ...nvalid-mutate-after-aliased-freeze.js.snap | 524 - ...@error.invalid-mutate-after-freeze.js.snap | 358 - ...rror.invalid-pass-hook-as-call-arg.js.snap | 108 - ...es@error.invalid-pass-hook-as-prop.js.snap | 143 - ...error.invalid-pass-ref-to-function.js.snap | 225 - ...lid-property-store-to-frozen-value.js.snap | 269 - ...-in-callback-invoked-during-render.js.snap | 546 - ...s@error.invalid-ref-value-as-props.js.snap | 220 - ...lid-set-and-read-ref-during-render.js.snap | 242 - ...or.invalid-sketchy-code-use-forget.js.snap | 191 - ...r.invalid-ternary-with-hook-values.js.snap | 184 - ...-unconditional-set-state-in-render.js.snap | 287 - ...ref-added-to-dep-without-type-info.js.snap | 444 - ...ror.invalid-useMemo-async-callback.js.snap | 214 - ...rror.invalid-useMemo-callback-args.js.snap | 196 - ...ror.mutate-captured-arg-separately.js.snap | 300 - ...-global-increment-op-invalid-react.js.snap | 166 - ...tures@error.reassignment-to-global.js.snap | 135 - ...t__fixtures@error.todo-kitchensink.js.snap | 2367 ----- ...odo-unconditional-set-state-lambda.js.snap | 393 - ...tructure-assignment-to-context-var.js.snap | 347 - ...s@error.useMemo-callback-generator.js.snap | 217 - ...rror.while-with-assignment-in-test.js.snap | 367 - ...analysis-destructured-rest-element.js.snap | 392 - ...fixtures@escape-analysis-jsx-child.js.snap | 420 - ...__fixtures@escape-analysis-logical.js.snap | 335 - ...-interleaved-allocating-dependency.js.snap | 378 - ...eaved-allocating-nested-dependency.js.snap | 436 - ...g-interleaved-primitive-dependency.js.snap | 408 - ...cape-analysis-not-conditional-test.js.snap | 263 - ...xtures@escape-analysis-not-if-test.js.snap | 345 - ...es@escape-analysis-not-switch-case.js.snap | 347 - ...es@escape-analysis-not-switch-test.js.snap | 327 - ...expression-with-assignment-dynamic.js.snap | 184 - ...ixtures@expression-with-assignment.js.snap | 172 - ...er_test__fixtures@extend-scopes-if.js.snap | 365 - ...tures@fbt-call-complex-param-value.js.snap | 378 - .../parser_test__fixtures@fbt-call.js.snap | 358 - ...res@fbt-params-complex-param-value.js.snap | 387 - .../parser_test__fixtures@fbt-params.js.snap | 367 - ...res@fbt-template-string-same-scope.js.snap | 556 - ...res@for-empty-update-with-continue.js.snap | 321 - ...er_test__fixtures@for-empty-update.js.snap | 332 - .../parser_test__fixtures@for-logical.js.snap | 465 - ...parser_test__fixtures@for-of-break.js.snap | 205 - ..._fixtures@for-of-conditional-break.js.snap | 313 - ...ser_test__fixtures@for-of-continue.js.snap | 389 - ..._test__fixtures@for-of-destructure.js.snap | 449 - ...arser_test__fixtures@for-of-mutate.js.snap | 434 - ...arser_test__fixtures@for-of-simple.js.snap | 321 - .../parser_test__fixtures@for-return.js.snap | 205 - ..._test__fixtures@frozen-after-alias.js.snap | 320 - ...ures@function-declaration-reassign.js.snap | 212 - ...res@function-declaration-redeclare.js.snap | 210 - ...xtures@function-declaration-simple.js.snap | 297 - ...on-captures-value-later-frozen-jsx.js.snap | 501 - ...on-maybe-mutates-hook-return-value.js.snap | 296 - ...expression-with-store-to-parameter.js.snap | 393 - ...@function-param-assignment-pattern.js.snap | 162 - ...ating-test-export-default-function.js.snap | 492 - ...g-test-export-function-and-default.js.snap | 502 - ...xtures@gating-test-export-function.js.snap | 514 - .../parser_test__fixtures@gating-test.js.snap | 484 - ...-jsx-tag-lowered-between-mutations.js.snap | 222 - ...ser_test__fixtures@globals-Boolean.js.snap | 207 - ...rser_test__fixtures@globals-Number.js.snap | 207 - ...rser_test__fixtures@globals-String.js.snap | 207 - ...er_test__fixtures@holey-array-expr.js.snap | 149 - ...fixtures@holey-array-pattern-dce-2.js.snap | 149 - ...__fixtures@holey-array-pattern-dce.js.snap | 149 - .../parser_test__fixtures@holey-array.js.snap | 206 - .../parser_test__fixtures@hook-call.js.snap | 417 - ...res@hook-inside-logical-expression.js.snap | 246 - ...t__fixtures@hooks-freeze-arguments.js.snap | 331 - ...-freeze-possibly-mutable-arguments.js.snap | 570 -- ...ser_test__fixtures@immutable-hooks.js.snap | 260 - ...dvertent-mutability-readonly-class.js.snap | 350 - ...vertent-mutability-readonly-lambda.js.snap | 464 - ...st__fixtures@independent-across-if.js.snap | 625 -- .../parser_test__fixtures@independent.js.snap | 455 - ...ependently-memoize-object-property.js.snap | 260 - ...st__fixtures@infer-computed-delete.js.snap | 226 - ...test__fixtures@infer-global-object.js.snap | 554 - ...test__fixtures@infer-phi-primitive.js.snap | 287 - ...st__fixtures@infer-property-delete.js.snap | 206 - ...infer-types-through-type-cast.flow.js.snap | 233 - ...ot-promoted-to-outer-scope-dynamic.js.snap | 573 -- ...not-promoted-to-outer-scope-static.js.snap | 432 - ..._fixtures@interdependent-across-if.js.snap | 555 - ...rser_test__fixtures@interdependent.js.snap | 504 - ...er_test__fixtures@inverted-if-else.js.snap | 304 - .../parser_test__fixtures@inverted-if.js.snap | 374 - .../parser_test__fixtures@issue852.js.snap | 261 - ...ssue933-disjoint-set-infinite-loop.js.snap | 315 - ...est__fixtures@jsx-empty-expression.js.snap | 222 - ...parser_test__fixtures@jsx-fragment.js.snap | 297 - ...jsx-member-expression-tag-grouping.js.snap | 245 - ...st__fixtures@jsx-member-expression.js.snap | 279 - ...test__fixtures@jsx-namespaced-name.js.snap | 196 - .../parser_test__fixtures@jsx-spread.js.snap | 263 - ...sx-tag-evaluation-order-non-global.js.snap | 395 - ..._fixtures@jsx-tag-evaluation-order.js.snap | 304 - ...ures@lambda-capture-returned-alias.js.snap | 510 - ...ures@lambda-mutate-shadowed-object.js.snap | 294 - ...a-mutated-non-reactive-to-reactive.js.snap | 293 - ...es@lambda-mutated-ref-non-reactive.js.snap | 261 - ...fixtures@lambda-reassign-primitive.js.snap | 266 - ...lambda-reassign-shadowed-primitive.js.snap | 292 - ...ser_test__fixtures@lambda-with-fbt.js.snap | 1130 --- ...fixtures@logical-expression-object.js.snap | 503 - ..._test__fixtures@logical-expression.js.snap | 481 - ...est__fixtures@method-call-computed.js.snap | 454 - ...test__fixtures@method-call-fn-call.js.snap | 393 - .../parser_test__fixtures@method-call.js.snap | 324 - ...ulti-arrow-expr-export-gating-test.js.snap | 412 - ...tures@multi-arrow-expr-gating-test.js.snap | 422 - ...t__fixtures@mutable-lifetime-loops.js.snap | 839 -- ...res@mutable-lifetime-with-aliasing.js.snap | 700 -- ...t__fixtures@mutable-liverange-loop.js.snap | 611 -- ...sted-function-shadowed-identifiers.js.snap | 454 - ...xtures@nested-optional-member-expr.js.snap | 229 - ...__fixtures@nested-scopes-hook-call.js.snap | 323 - .../parser_test__fixtures@new-spread.js.snap | 230 - ...onal-load-from-optional-memberexpr.js.snap | 171 - ...ures@obj-literal-cached-in-if-else.js.snap | 341 - ...@obj-literal-mutated-after-if-else.js.snap | 398 - ...j-mutated-after-if-else-with-alias.js.snap | 442 - ...fixtures@obj-mutated-after-if-else.js.snap | 362 - ...ed-after-nested-if-else-with-alias.js.snap | 601 -- ...@object-computed-access-assignment.js.snap | 336 - ...ject-expression-string-literal-key.js.snap | 178 - ...ures@object-literal-spread-element.js.snap | 165 - ...st__fixtures@object-pattern-params.js.snap | 360 - ...r_test__fixtures@object-properties.js.snap | 486 - ...st__fixtures@optional-call-chained.js.snap | 208 - ...st__fixtures@optional-call-logical.js.snap | 336 - ...est__fixtures@optional-call-simple.js.snap | 109 - ...-with-independently-memoizable-arg.js.snap | 356 - ...l-call-with-optional-property-load.js.snap | 208 - ...arser_test__fixtures@optional-call.js.snap | 415 - ...ures@optional-computed-load-static.js.snap | 187 - ...ptional-computed-member-expression.js.snap | 187 - ...member-expression-call-as-property.js.snap | 196 - ...s@optional-member-expression-chain.js.snap | 414 - ...h-optional-member-expr-as-property.js.snap | 273 - ...ixtures@optional-member-expression.js.snap | 288 - ...est__fixtures@optional-method-call.js.snap | 434 - ...ures@optional-receiver-method-call.js.snap | 435 - ...@optional-receiver-optional-method.js.snap | 435 - ...ing-scopes-interleaved-by-terminal.js.snap | 317 - ...res@overlapping-scopes-interleaved.js.snap | 275 - ...xtures@overlapping-scopes-shadowed.js.snap | 275 - ...ping-scopes-shadowing-within-block.js.snap | 421 - ..._fixtures@overlapping-scopes-while.js.snap | 315 - ...es@overlapping-scopes-within-block.js.snap | 367 - ...t__fixtures@primitive-alias-mutate.js.snap | 324 - ...ures@primitive-as-dep-nested-scope.js.snap | 358 - ...er_test__fixtures@primitive-as-dep.js.snap | 190 - ...fixtures@prop-capturing-function-1.js.snap | 319 - ...test__fixtures@property-assignment.js.snap | 506 - ...res@property-call-evaluation-order.js.snap | 598 -- ...est__fixtures@property-call-spread.js.snap | 239 - ...l-properties-inside-optional-chain.js.snap | 206 - ...__fixtures@reactive-scope-grouping.js.snap | 312 - ..._test__fixtures@reactive-scopes-if.js.snap | 458 - ...ser_test__fixtures@reactive-scopes.js.snap | 350 - ...ty-analysis-interleaved-reactivity.js.snap | 381 - ...tive-via-mutation-of-computed-load.js.snap | 407 - ...tive-via-mutation-of-property-load.js.snap | 388 - ...ixtures@reassign-object-in-context.js.snap | 253 - ...ures@reassign-primitive-in-context.js.snap | 253 - ...hi-in-returned-function-expression.js.snap | 372 - ..._fixtures@reassignment-conditional.js.snap | 504 - ...tures@reassignment-separate-scopes.js.snap | 719 -- ...parser_test__fixtures@reassignment.js.snap | 549 - ...__fixtures@recursive-function-expr.js.snap | 114 - ...ce-reactive-cond-deps-cfg-condexpr.js.snap | 306 - ...duce-reactive-cond-deps-cfg-ifelse.js.snap | 394 - ...ond-deps-cfg-nested-ifelse-missing.js.snap | 433 - ...active-cond-deps-cfg-nested-ifelse.js.snap | 685 -- ...-cond-deps-cfg-switch-missing-case.js.snap | 513 - ...nd-deps-cfg-switch-missing-default.js.snap | 434 - ...duce-reactive-cond-deps-cfg-switch.js.snap | 543 - ...educe-reactive-cond-deps-no-uncond.js.snap | 401 - ...-reactive-cond-deps-promote-uncond.js.snap | 421 - ...-reactive-cond-deps-subpath-order1.js.snap | 366 - ...-reactive-cond-deps-subpath-order2.js.snap | 366 - ...eactive-cond-deps-superpath-order1.js.snap | 365 - ...eactive-cond-deps-superpath-order2.js.snap | 365 - ...duce-reactive-cond-memberexpr-join.js.snap | 352 - ...dencies-optional-member-expression.js.snap | 423 - ...es@reduce-reactive-deps-cond-scope.js.snap | 332 - ...-deps-join-uncond-scopes-cond-deps.js.snap | 410 - ...-uncond-deps-nonoverlap-descendant.js.snap | 474 - ...tive-uncond-deps-nonoverlap-direct.js.snap | 321 - ...ive-uncond-deps-overlap-descendant.js.snap | 474 - ...eactive-uncond-deps-overlap-direct.js.snap | 398 - ...eactive-uncond-deps-subpath-order1.js.snap | 417 - ...eactive-uncond-deps-subpath-order2.js.snap | 417 - ...eactive-uncond-deps-subpath-order3.js.snap | 417 - ...ef-current-aliased-no-added-to-dep.js.snap | 360 - ...current-aliased-not-added-to-dep-2.js.snap | 389 - ...ref-current-field-not-added-to-dep.js.snap | 339 - ...res@ref-current-not-added-to-dep-2.js.snap | 349 - ...tures@ref-current-not-added-to-dep.js.snap | 319 - ...ent-optional-field-no-added-to-dep.js.snap | 300 - ...ref-current-write-not-added-to-dep.js.snap | 298 - ...arser_test__fixtures@ref-in-effect.js.snap | 582 -- ...rser_test__fixtures@regexp-literal.js.snap | 368 - ...es@remove-memoization-kitchen-sink.js.snap | 751 -- ...-to-variable-without-mutable-range.js.snap | 406 - ...@repro-scope-missing-mutable-range.js.snap | 474 - .../parser_test__fixtures@repro.js.snap | 684 -- ..._test__fixtures@return-conditional.js.snap | 173 - ...er_test__fixtures@return-undefined.js.snap | 176 - ...r_test__fixtures@reverse-postorder.js.snap | 706 -- ...-as-dep-and-redeclare-maybe-frozen.js.snap | 836 -- ...same-variable-as-dep-and-redeclare.js.snap | 791 -- ...test__fixtures@sequence-expression.js.snap | 374 - ...nt-progagatable-if-test-conditions.js.snap | 767 -- ...parser_test__fixtures@simple-alias.js.snap | 397 - ...r_test__fixtures@simple-function-1.js.snap | 194 - ...parser_test__fixtures@simple-scope.js.snap | 157 - .../parser_test__fixtures@simple.js.snap | 213 - ...tures@sketchy-code-exhaustive-deps.js.snap | 321 - ...xtures@sketchy-code-rules-of-hooks.js.snap | 172 - ...test__fixtures@ssa-arrayexpression.js.snap | 226 - ...rser_test__fixtures@ssa-call-jsx-2.js.snap | 529 - ...parser_test__fixtures@ssa-call-jsx.js.snap | 488 - ...ures@ssa-cascading-eliminated-phis.js.snap | 616 -- ...__fixtures@ssa-complex-multiple-if.js.snap | 350 - ...st__fixtures@ssa-complex-single-if.js.snap | 263 - .../parser_test__fixtures@ssa-for-of.js.snap | 296 - ...t__fixtures@ssa-for-trivial-update.js.snap | 250 - .../parser_test__fixtures@ssa-for.js.snap | 260 - .../parser_test__fixtures@ssa-if-else.js.snap | 277 - ...rser_test__fixtures@ssa-leave-case.js.snap | 432 - ...r_test__fixtures@ssa-multiple-phis.js.snap | 473 - ...tures@ssa-nested-loops-no-reassign.js.snap | 276 - ...t__fixtures@ssa-nested-partial-phi.js.snap | 250 - ...es@ssa-nested-partial-reassignment.js.snap | 316 - ...r_test__fixtures@ssa-newexpression.js.snap | 273 - ...fixtures@ssa-non-empty-initializer.js.snap | 247 - ..._fixtures@ssa-objectexpression-phi.js.snap | 396 - ...est__fixtures@ssa-objectexpression.js.snap | 270 - ...ssa-property-alias-alias-mutate-if.js.snap | 442 - ...st__fixtures@ssa-property-alias-if.js.snap | 362 - ...tures@ssa-property-alias-mutate-if.js.snap | 402 - ...sa-property-alias-mutate-inside-if.js.snap | 402 - ...fixtures@ssa-property-alias-mutate.js.snap | 295 - ...r_test__fixtures@ssa-property-call.js.snap | 265 - ...st__fixtures@ssa-property-mutate-2.js.snap | 253 - ...fixtures@ssa-property-mutate-alias.js.snap | 295 - ...test__fixtures@ssa-property-mutate.js.snap | 253 - ...parser_test__fixtures@ssa-property.js.snap | 213 - ...est__fixtures@ssa-reassign-in-rval.js.snap | 244 - ...parser_test__fixtures@ssa-reassign.js.snap | 264 - ...-ternary-destruction-with-mutation.js.snap | 518 - ...s@ssa-renaming-ternary-destruction.js.snap | 478 - ...ssa-renaming-ternary-with-mutation.js.snap | 434 - ...est__fixtures@ssa-renaming-ternary.js.snap | 394 - ...nconditional-ternary-with-mutation.js.snap | 562 - ...ssa-renaming-unconditional-ternary.js.snap | 522 - ...naming-unconditional-with-mutation.js.snap | 613 -- ...ng-via-destructuring-with-mutation.js.snap | 641 -- ...res@ssa-renaming-via-destructuring.js.snap | 601 -- ...ixtures@ssa-renaming-with-mutation.js.snap | 449 - ...parser_test__fixtures@ssa-renaming.js.snap | 409 - .../parser_test__fixtures@ssa-return.js.snap | 204 - ...arser_test__fixtures@ssa-shadowing.js.snap | 343 - ...er_test__fixtures@ssa-sibling-phis.js.snap | 455 - ...rser_test__fixtures@ssa-simple-phi.js.snap | 274 - .../parser_test__fixtures@ssa-simple.js.snap | 136 - ...arser_test__fixtures@ssa-single-if.js.snap | 227 - .../parser_test__fixtures@ssa-switch.js.snap | 437 - .../parser_test__fixtures@ssa-throw.js.snap | 203 - ...st__fixtures@ssa-while-no-reassign.js.snap | 203 - .../parser_test__fixtures@ssa-while.js.snap | 222 - ...rser_test__fixtures@store-via-call.js.snap | 224 - ...arser_test__fixtures@store-via-new.js.snap | 224 - ...itch-global-propertyload-case-test.js.snap | 220 - ..._fixtures@switch-non-final-default.js.snap | 763 -- ...__fixtures@switch-with-fallthrough.js.snap | 579 -- .../parser_test__fixtures@switch.js.snap | 767 -- ...__fixtures@tagged-template-in-hook.js.snap | 228 - ...__fixtures@tagged-template-literal.js.snap | 161 - ...er_test__fixtures@template-literal.js.snap | 466 - ...s@temporary-accessed-outside-scope.js.snap | 217 - ...@temporary-at-start-of-value-block.js.snap | 304 - ...operty-load-accessed-outside-scope.js.snap | 236 - ...ures@ternary-assignment-expression.js.snap | 269 - ..._test__fixtures@ternary-expression.js.snap | 582 -- .../parser_test__fixtures@timers.js.snap | 417 - ...ession-captures-value-later-frozen.js.snap | 496 - ...odo.unnecessary-lambda-memoization.js.snap | 382 - ...__fixtures@transitive-alias-fields.js.snap | 468 - .../parser_test__fixtures@trivial.js.snap | 88 - ...res@type-args-test-binary-operator.js.snap | 168 - ...est__fixtures@type-binary-operator.js.snap | 245 - ...fixtures@type-cast-expression.flow.js.snap | 357 - ...ser_test__fixtures@type-field-load.js.snap | 207 - ...res@type-test-field-load-binary-op.js.snap | 485 - ...st__fixtures@type-test-field-store.js.snap | 272 - ...st__fixtures@type-test-polymorphic.js.snap | 480 - ...test__fixtures@type-test-primitive.js.snap | 156 - ...es@type-test-return-type-inference.js.snap | 314 - .../parser_test__fixtures@unary-expr.js.snap | 867 -- ...fixtures@unconditional-break-label.js.snap | 233 - ...ized-declaration-in-reactive-scope.js.snap | 228 - ...xtures@unknown-hooks-do-not-assert.js.snap | 214 - ...xtures@unused-array-middle-element.js.snap | 196 - ...fixtures@unused-array-rest-element.js.snap | 204 - ..._test__fixtures@unused-conditional.js.snap | 202 - ...nused-logical-assigned-to-variable.js.snap | 320 - ...rser_test__fixtures@unused-logical.js.snap | 230 - ...es@unused-object-element-with-rest.js.snap | 198 - ...st__fixtures@unused-object-element.js.snap | 229 - ...tional-method-assigned-to-variable.js.snap | 255 - ...nused-ternary-assigned-to-variable.js.snap | 261 - ...r_test__fixtures@update-expression.js.snap | 343 - ...test__fixtures@use-callback-simple.js.snap | 344 - ...t__fixtures@useEffect-arg-memoized.js.snap | 439 - ..._fixtures@useEffect-nested-lambdas.js.snap | 807 -- ...es@useMemo-if-else-multiple-return.js.snap | 333 - ...@useMemo-independently-memoizeable.js.snap | 443 - ...ures@useMemo-inlining-block-return.js.snap | 289 - ...test__fixtures@useMemo-inverted-if.js.snap | 342 - ...led-statement-unconditional-return.js.snap | 235 - ...ser_test__fixtures@useMemo-logical.js.snap | 223 - ..._fixtures@useMemo-multiple-if-else.js.snap | 500 - ...t__fixtures@useMemo-named-function.js.snap | 157 - ..._test__fixtures@useMemo-nested-ifs.js.snap | 305 - ...est__fixtures@useMemo-return-empty.js.snap | 216 - ...rser_test__fixtures@useMemo-simple.js.snap | 267 - ...ures@useMemo-switch-no-fallthrough.js.snap | 338 - ...st__fixtures@useMemo-switch-return.js.snap | 467 - .../parser_test__fixtures@while-break.js.snap | 138 - ...ixtures@while-conditional-continue.js.snap | 238 - ...arser_test__fixtures@while-logical.js.snap | 290 - ...rser_test__fixtures@while-property.js.snap | 244 - compiler/crates/react_hir/Cargo.toml | 22 - compiler/crates/react_hir/README.md | 32 - compiler/crates/react_hir/src/basic_block.rs | 67 - compiler/crates/react_hir/src/environment.rs | 134 - compiler/crates/react_hir/src/features.rs | 19 - compiler/crates/react_hir/src/function.rs | 290 - compiler/crates/react_hir/src/id_types.rs | 117 - compiler/crates/react_hir/src/initialize.rs | 194 - .../crates/react_hir/src/inline_use_memo.rs | 267 - compiler/crates/react_hir/src/instruction.rs | 502 - compiler/crates/react_hir/src/lib.rs | 38 - .../react_hir/src/merge_consecutive_blocks.rs | 166 - compiler/crates/react_hir/src/print.rs | 401 - compiler/crates/react_hir/src/registry.rs | 11 - compiler/crates/react_hir/src/terminal.rs | 167 - compiler/crates/react_hir/src/types.rs | 24 - compiler/crates/react_napi/Cargo.toml | 26 - compiler/crates/react_napi/README.md | 13 - compiler/crates/react_napi/build.rs | 10 - compiler/crates/react_napi/package.json | 20 - compiler/crates/react_napi/src/lib.rs | 121 - compiler/crates/react_napi/yarn.lock | 8 - compiler/crates/react_optimization/Cargo.toml | 24 - compiler/crates/react_optimization/README.md | 3 - .../src/constant_propagation.rs | 294 - compiler/crates/react_optimization/src/lib.rs | 10 - .../crates/react_semantic_analysis/Cargo.toml | 24 - .../crates/react_semantic_analysis/README.md | 6 - .../react_semantic_analysis/src/analyzer.rs | 870 -- .../crates/react_semantic_analysis/src/lib.rs | 14 - .../src/scope_manager.rs | 560 - .../react_semantic_analysis/src/scope_view.rs | 260 - .../tests/analysis_test.rs | 51 - .../tests/fixtures/block-item-duplication.js | 25 - .../tests/fixtures/function-hoisting.js | 22 - .../tests/fixtures/globals-and-imports.js | 17 - .../tests/fixtures/labels.js | 13 - .../tests/fixtures/let-const-hoisting.js | 8 - .../tests/fixtures/simple-function.js | 9 - .../tests/fixtures/tdz.js | 14 - .../tests/fixtures/var-duplication.js | 29 - .../tests/fixtures/var-hoisting.js | 19 - ...t__fixtures@block-item-duplication.js.snap | 366 - ...s_test__fixtures@function-hoisting.js.snap | 295 - ...test__fixtures@globals-and-imports.js.snap | 407 - .../analysis_test__fixtures@labels.js.snap | 272 - ..._test__fixtures@let-const-hoisting.js.snap | 170 - ...sis_test__fixtures@simple-function.js.snap | 252 - .../analysis_test__fixtures@tdz.js.snap | 234 - ...sis_test__fixtures@var-duplication.js.snap | 372 - ...alysis_test__fixtures@var-hoisting.js.snap | 298 - compiler/crates/react_ssa/Cargo.toml | 21 - compiler/crates/react_ssa/README.md | 3 - .../react_ssa/src/eliminate_redundant_phis.rs | 108 - compiler/crates/react_ssa/src/enter.rs | 299 - compiler/crates/react_ssa/src/leave.rs | 11 - compiler/crates/react_ssa/src/lib.rs | 14 - compiler/crates/react_utils/Cargo.toml | 16 - compiler/crates/react_utils/README.md | 6 - .../src/ensure_sufficient_stack.rs | 10 - compiler/crates/react_utils/src/lib.rs | 12 - .../crates/react_utils/src/pointer_address.rs | 32 - compiler/docs/DEVELOPMENT_GUIDE.md | 83 - compiler/rust-toolchain.toml | 2 - compiler/rustfmt.toml | 8 - 1146 files changed, 223571 deletions(-) delete mode 100644 .github/workflows/compiler_rust.yml delete mode 100644 compiler/Cargo.lock delete mode 100644 compiler/Cargo.toml delete mode 100644 compiler/crates/react_build_hir/Cargo.toml delete mode 100644 compiler/crates/react_build_hir/README.md delete mode 100644 compiler/crates/react_build_hir/src/build.rs delete mode 100644 compiler/crates/react_build_hir/src/builder.rs delete mode 100644 compiler/crates/react_build_hir/src/context.rs delete mode 100644 compiler/crates/react_build_hir/src/error.rs delete mode 100644 compiler/crates/react_build_hir/src/lib.rs delete mode 100644 compiler/crates/react_diagnostics/Cargo.toml delete mode 100644 compiler/crates/react_diagnostics/README.md delete mode 100644 compiler/crates/react_diagnostics/src/diagnostic.rs delete mode 100644 compiler/crates/react_diagnostics/src/lib.rs delete mode 100644 compiler/crates/react_estree/Cargo.toml delete mode 100644 compiler/crates/react_estree/README.md delete mode 100644 compiler/crates/react_estree/build.rs delete mode 100644 compiler/crates/react_estree/src/binding.rs delete mode 100644 compiler/crates/react_estree/src/fixtures/for-statement.json delete mode 100644 compiler/crates/react_estree/src/fixtures/import.json delete mode 100644 compiler/crates/react_estree/src/fixtures/simple.json delete mode 100644 compiler/crates/react_estree/src/fixtures/test.json delete mode 100644 compiler/crates/react_estree/src/generated.rs delete mode 100644 compiler/crates/react_estree/src/generated_extensions.rs delete mode 100644 compiler/crates/react_estree/src/js_value.rs delete mode 100644 compiler/crates/react_estree/src/lib.rs delete mode 100644 compiler/crates/react_estree/src/range.rs delete mode 100644 compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@for-statement.json.snap delete mode 100644 compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@import.json.snap delete mode 100644 compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@simple.json.snap delete mode 100644 compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@test.json.snap delete mode 100644 compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@for-statement.json.snap delete mode 100644 compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@import.json.snap delete mode 100644 compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@simple.json.snap delete mode 100644 compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@test.json.snap delete mode 100644 compiler/crates/react_estree/src/visit.rs delete mode 100644 compiler/crates/react_estree_codegen/Cargo.toml delete mode 100644 compiler/crates/react_estree_codegen/README.md delete mode 100644 compiler/crates/react_estree_codegen/src/codegen.rs delete mode 100644 compiler/crates/react_estree_codegen/src/ecmascript.json delete mode 100644 compiler/crates/react_estree_codegen/src/lib.rs delete mode 100644 compiler/crates/react_fixtures/Cargo.toml delete mode 100644 compiler/crates/react_fixtures/README.md delete mode 100644 compiler/crates/react_fixtures/src/lib.rs delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/constant-propagation-constant-if-condition.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/constant-propagation.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/destructure-array.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/destructure-object.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/error.assign-to-global.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/for-statement.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/function-expressions.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/identifiers.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/if-statement.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/simple-function.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/simple-ssa.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/simple.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/ssa-reassign-if.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures/use-memo.js delete mode 100644 compiler/crates/react_fixtures/tests/fixtures_test.rs delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@constant-propagation-constant-if-condition.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@constant-propagation.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@destructure-array.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@destructure-object.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@error.assign-to-global.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@for-statement.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@function-expressions.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@identifiers.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@if-statement.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple-function.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple-ssa.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@ssa-reassign-if.js.snap delete mode 100644 compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@use-memo.js.snap delete mode 100644 compiler/crates/react_hermes_parser/Cargo.toml delete mode 100644 compiler/crates/react_hermes_parser/README.md delete mode 100644 compiler/crates/react_hermes_parser/build.rs delete mode 100644 compiler/crates/react_hermes_parser/src/generated.rs delete mode 100644 compiler/crates/react_hermes_parser/src/generated_extension.rs delete mode 100644 compiler/crates/react_hermes_parser/src/lib.rs delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/alias-capture-in-method-receiver-and-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/alias-capture-in-method-receiver.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/alias-computed-load.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/alias-nested-member-path-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/alias-nested-member-path.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/alias-while.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/allocating-primitive-as-dep-nested-scope.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/allocating-primitive-as-dep.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/allow-passing-refs-as-props.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-access-assignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-at-closure.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-at-effect.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-at-mutate-after-capture.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-expression-spread.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-join.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-map-frozen-array.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-map-mutable-array-mutating-lambda.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-pattern-params.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-properties.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-property-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/array-push-effect.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/arrow-function-expr-gating-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/assignment-expression-computed.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/assignment-expression-nested-path.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/assignment-in-nested-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations-complex-lvalue-array.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations-complex-lvalue.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/await-side-effecting-promise.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/await.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/babel-existing-react-import.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/babel-existing-react-kitchensink-import.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/bug.useMemo-deps-array-not-cleared.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/bug_object-pattern.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/builtin-jsx-tag-lowered-between-mutations.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/call-args-assignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/call-args-destructuring-assignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/call-spread.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/call-with-independently-memoizable-arg.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capture-indirect-mutate-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capture-param-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capture_mutate-across-fns.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-arrow-function-1.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-fun-alias-captured-mutate-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-fun-alias-captured-mutate-arr-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-captured-mutate-arr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-captured-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-computed-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-receiver-computed-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-receiver-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-3.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-nested.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-simple-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-1.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-3.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-4.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-capture-ref-before-rename.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-conditional-capture-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-decl.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-member-expr-arguments.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-member-expr-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-renamed-ref.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-runs-inference.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-shadow-captured.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-skip-computed-path.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-within-block.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-member-expr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-expr-in-nested-func.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-expr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-reference-changes-type.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-variable-in-nested-block.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/capturing-variable-in-nested-function.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/chained-assignment-context-variable.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/chained-assignment-expressions.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/codegen-emit-imports-same-source.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/codegen-emit-make-read-only.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/codegen-instrument-forget-gating-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/codegen-instrument-forget-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/complex-while.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/component.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/computed-call-evaluation-order.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/computed-call-spread.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/computed-load-primitive-as-dependency.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/computed-store-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/concise-arrow-expr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/cond-deps-conditional-member-expr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/conditional-break-labeled.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/conditional-break.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/conditional-on-mutable.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/conditional-set-state-in-render.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/console-readonly.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/const-propagation-into-function-expression-global.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/const-propagation-into-function-expression-primitive.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/constant-computed.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-for.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-into-function-expressions.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-phi.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-while.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/constructor.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/context-variable-reassigned-outside-of-lambda.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/controlled-input.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/dce-loop.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/debugger-memoized.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/debugger.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/declare-reassign-variable-in-closure.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/declare-reassign-variable-in-function-declaration.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/delete-computed-property.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/delete-property.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/dependencies-outputs.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/dependencies.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructure-capture-global.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructure-direct-reassignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-array-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-array-param-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-assignment-array-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-assignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-mixed-scope-and-local-variables-with-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-mixed-scope-declarations-and-locals.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-object-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-object-param-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring-property-inference.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/destructuring.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/disable-jsx-memoization.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/do-while-break.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/do-while-compound-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/do-while-conditional-break.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/do-while-continue.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/do-while-early-unconditional-break.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/do-while-simple.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/dominator.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/early-return.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error._todo.computed-lval-in-destructure.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error._todo.multi-arrow-expr-export-default-gating-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.babel-existing-react-namespace-import.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.bug-validate-no-set-state-not-all-mutable-range-extensions-are-bad.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.call-args-destructuring-asignment-complex.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.codegen-error-on-conflicting-imports.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.hoisted-function-declaration.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.hooks-with-React-namespace.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-access-ref-during-render.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-array-push-frozen.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-assign-hook-to-local.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-capture-func-passed-to-jsx.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-computed-store-to-frozen-value.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-delete-computed-property-of-frozen-value.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-delete-property-of-frozen-value.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-destructure-assignment-to-global.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-destructure-to-local-global-variables.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-conditionally-mutable-lambda.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-mutable-lambda-mutate-local.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-mutable-lambda-reassign-local.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-function-expression-mutates-immutable-value.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-mutate-after-aliased-freeze.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-mutate-after-freeze.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-hook-as-call-arg.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-hook-as-prop.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-ref-to-function.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-property-store-to-frozen-value.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ref-in-callback-invoked-during-render.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ref-value-as-props.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-set-and-read-ref-during-render.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-sketchy-code-use-forget.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ternary-with-hook-values.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-unconditional-set-state-in-render.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-use-ref-added-to-dep-without-type-info.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-useMemo-async-callback.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-useMemo-callback-args.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.mutate-captured-arg-separately.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.mutate-global-increment-op-invalid-react.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.reassignment-to-global.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.todo-kitchensink.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.todo-unconditional-set-state-lambda.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.todo.destructure-assignment-to-context-var.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.useMemo-callback-generator.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/error.while-with-assignment-in-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-destructured-rest-element.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-jsx-child.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-logical.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-dependency.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-primitive-dependency.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-conditional-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-if-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-case.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/expression-with-assignment-dynamic.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/expression-with-assignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/extend-scopes-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/fbt-call-complex-param-value.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/fbt-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/fbt-params-complex-param-value.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/fbt-params.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/fbt-template-string-same-scope.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-empty-update-with-continue.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-empty-update.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-logical.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-of-break.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-of-conditional-break.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-of-continue.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-of-destructure.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-of-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-of-mutate.tsx delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-of-simple.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/for-return.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/frozen-after-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-reassign.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-redeclare.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-simple.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/function-expression-captures-value-later-frozen-jsx.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/function-expression-maybe-mutates-hook-return-value.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/function-expression-with-store-to-parameter.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/function-param-assignment-pattern.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-default-function.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-function-and-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-function.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/gating-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/global-jsx-tag-lowered-between-mutations.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/globals-Boolean.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/globals-Number.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/globals-String.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/holey-array-expr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/holey-array.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/hook-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/hook-inside-logical-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/hooks-freeze-arguments.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/hooks-freeze-possibly-mutable-arguments.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/immutable-hooks.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-class.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-lambda.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/independent-across-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/independent.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/independently-memoize-object-property.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/infer-computed-delete.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/infer-global-object.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/infer-phi-primitive.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/infer-property-delete.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/infer-types-through-type-cast.flow.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-dynamic.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-static.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/interdependent-across-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/interdependent.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/inverted-if-else.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/inverted-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/issue852.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/issue933-disjoint-set-infinite-loop.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/jsx-empty-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/jsx-fragment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/jsx-member-expression-tag-grouping.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/jsx-member-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/jsx-namespaced-name.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/jsx-spread.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order-non-global.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/lambda-capture-returned-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutate-shadowed-object.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutated-non-reactive-to-reactive.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutated-ref-non-reactive.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/lambda-reassign-primitive.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/lambda-reassign-shadowed-primitive.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/lambda-with-fbt.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/logical-expression-object.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/logical-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/method-call-computed.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/method-call-fn-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/method-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/multi-arrow-expr-export-gating-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/multi-arrow-expr-gating-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/mutable-lifetime-loops.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/mutable-lifetime-with-aliasing.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/mutable-liverange-loop.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/nested-function-shadowed-identifiers.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/nested-optional-member-expr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/nested-scopes-hook-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/new-spread.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/nonoptional-load-from-optional-memberexpr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/obj-literal-cached-in-if-else.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/obj-literal-mutated-after-if-else.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/obj-mutated-after-if-else-with-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/obj-mutated-after-if-else.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/obj-mutated-after-nested-if-else-with-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/object-computed-access-assignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/object-expression-string-literal-key.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/object-literal-spread-element.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/object-pattern-params.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/object-properties.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-call-chained.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-call-logical.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-call-simple.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-call-with-independently-memoizable-arg.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-call-with-optional-property-load.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-computed-load-static.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-computed-member-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-member-expression-call-as-property.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-member-expression-chain.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-member-expression-with-optional-member-expr-as-property.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-member-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-method-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-receiver-method-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/optional-receiver-optional-method.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/overlapping-scopes-interleaved-by-terminal.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/overlapping-scopes-interleaved.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/overlapping-scopes-shadowed.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/overlapping-scopes-shadowing-within-block.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/overlapping-scopes-while.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/overlapping-scopes-within-block.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/primitive-alias-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/primitive-as-dep-nested-scope.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/primitive-as-dep.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/prop-capturing-function-1.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/property-assignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/property-call-evaluation-order.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/property-call-spread.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reactive-dependencies-non-optional-properties-inside-optional-chain.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reactive-scope-grouping.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reactive-scopes-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reactive-scopes.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reactivity-analysis-interleaved-reactivity.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reactivity-analysis-reactive-via-mutation-of-computed-load.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reactivity-analysis-reactive-via-mutation-of-property-load.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reassign-object-in-context.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reassign-primitive-in-context.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reassigned-phi-in-returned-function-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reassignment-conditional.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reassignment-separate-scopes.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reassignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/recursive-function-expr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-cfg-condexpr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-cfg-ifelse.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-cfg-nested-ifelse-missing.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-cfg-nested-ifelse.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-cfg-switch-missing-case.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-cfg-switch-missing-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-cfg-switch.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-no-uncond.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-promote-uncond.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-subpath-order1.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-subpath-order2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-superpath-order1.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-deps-superpath-order2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-cond-memberexpr-join.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-dependencies-optional-member-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-deps-cond-scope.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-deps-join-uncond-scopes-cond-deps.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-uncond-deps-nonoverlap-descendant.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-uncond-deps-nonoverlap-direct.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-uncond-deps-overlap-descendant.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-uncond-deps-overlap-direct.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-uncond-deps-subpath-order1.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-uncond-deps-subpath-order2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reduce-reactive-uncond-deps-subpath-order3.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ref-current-aliased-no-added-to-dep.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ref-current-aliased-not-added-to-dep-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ref-current-field-not-added-to-dep.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ref-current-not-added-to-dep-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ref-current-not-added-to-dep.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ref-current-optional-field-no-added-to-dep.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ref-current-write-not-added-to-dep.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ref-in-effect.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/regexp-literal.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/remove-memoization-kitchen-sink.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/repro-reassign-to-variable-without-mutable-range.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/repro-scope-missing-mutable-range.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/repro.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/return-conditional.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/return-undefined.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/reverse-postorder.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/same-variable-as-dep-and-redeclare-maybe-frozen.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/same-variable-as-dep-and-redeclare.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/sequence-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/sequentially-constant-progagatable-if-test-conditions.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/simple-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/simple-function-1.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/simple-scope.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/simple.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/sketchy-code-exhaustive-deps.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/sketchy-code-rules-of-hooks.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-arrayexpression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-call-jsx-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-call-jsx.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-cascading-eliminated-phis.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-complex-multiple-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-complex-single-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-for-of.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-for-trivial-update.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-for.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-if-else.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-leave-case.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-multiple-phis.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-nested-loops-no-reassign.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-nested-partial-phi.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-nested-partial-reassignment.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-newexpression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-non-empty-initializer.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-objectexpression-phi.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-objectexpression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-alias-alias-mutate-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-alias-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-alias-mutate-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-alias-mutate-inside-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-alias-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-mutate-2.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-mutate-alias.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property-mutate.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-property.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-reassign-in-rval.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-reassign.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-ternary-destruction-with-mutation.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-ternary-destruction.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-ternary-with-mutation.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-ternary.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-unconditional-ternary-with-mutation.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-unconditional-ternary.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-unconditional-with-mutation.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-via-destructuring-with-mutation.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-via-destructuring.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming-with-mutation.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-renaming.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-return.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-shadowing.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-sibling-phis.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-simple-phi.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-simple.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-single-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-switch.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-throw.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-while-no-reassign.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ssa-while.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/store-via-call.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/store-via-new.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/switch-global-propertyload-case-test.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/switch-non-final-default.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/switch-with-fallthrough.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/switch.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/tagged-template-in-hook.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/tagged-template-literal.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/template-literal.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/temporary-accessed-outside-scope.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/temporary-at-start-of-value-block.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/temporary-property-load-accessed-outside-scope.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ternary-assignment-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/ternary-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/timers.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/todo-function-expression-captures-value-later-frozen.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/todo.unnecessary-lambda-memoization.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/transitive-alias-fields.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/trivial.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-args-test-binary-operator.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-binary-operator.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-cast-expression.flow.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-field-load.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-test-field-load-binary-op.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-test-field-store.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-test-polymorphic.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-test-primitive.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/type-test-return-type-inference.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unary-expr.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unconditional-break-label.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/uninitialized-declaration-in-reactive-scope.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unknown-hooks-do-not-assert.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-array-middle-element.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-array-rest-element.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-conditional.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-logical-assigned-to-variable.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-logical.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-object-element-with-rest.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-object-element.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-optional-method-assigned-to-variable.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/unused-ternary-assigned-to-variable.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/update-expression.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/use-callback-simple.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useEffect-arg-memoized.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useEffect-nested-lambdas.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-if-else-multiple-return.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-independently-memoizeable.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-inlining-block-return.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-inverted-if.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-labeled-statement-unconditional-return.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-logical.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-multiple-if-else.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-named-function.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-nested-ifs.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-return-empty.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-simple.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-switch-no-fallthrough.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/useMemo-switch-return.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/while-break.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/while-conditional-continue.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/while-logical.js delete mode 100644 compiler/crates/react_hermes_parser/tests/fixtures/while-property.js delete mode 100644 compiler/crates/react_hermes_parser/tests/parser_test.rs delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@alias-capture-in-method-receiver-and-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@alias-capture-in-method-receiver.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@alias-computed-load.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@alias-nested-member-path-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@alias-nested-member-path.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@alias-while.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@allocating-primitive-as-dep-nested-scope.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@allocating-primitive-as-dep.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@allow-passing-refs-as-props.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-access-assignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-at-closure.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-at-effect.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-at-mutate-after-capture.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-expression-spread.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-join.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-map-frozen-array.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-map-mutable-array-mutating-lambda.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-pattern-params.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-properties.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-property-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@array-push-effect.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@arrow-function-expr-gating-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@assignment-expression-computed.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@assignment-expression-nested-path.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@assignment-in-nested-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@assignment-variations-complex-lvalue-array.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@assignment-variations-complex-lvalue.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@assignment-variations.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@await-side-effecting-promise.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@await.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@babel-existing-react-import.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@babel-existing-react-kitchensink-import.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@bug.useMemo-deps-array-not-cleared.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@bug_object-pattern.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@builtin-jsx-tag-lowered-between-mutations.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@call-args-assignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@call-args-destructuring-assignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@call-spread.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@call-with-independently-memoizable-arg.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capture-indirect-mutate-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capture-param-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capture_mutate-across-fns.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-arrow-function-1.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-fun-alias-captured-mutate-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-fun-alias-captured-mutate-arr-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-alias-captured-mutate-arr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-alias-captured-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-alias-computed-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-alias-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-alias-receiver-computed-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-alias-receiver-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-mutate-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-mutate-3.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-mutate-nested.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-func-simple-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-1.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-alias-computed-load-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-alias-computed-load-3.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-alias-computed-load-4.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-alias-computed-load.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-capture-ref-before-rename.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-conditional-capture-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-decl.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-member-expr-arguments.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-member-expr-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-renamed-ref.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-runs-inference.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-shadow-captured.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-skip-computed-path.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-function-within-block.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-member-expr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-nested-member-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-nested-member-expr-in-nested-func.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-nested-member-expr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-reference-changes-type.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-variable-in-nested-block.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@capturing-variable-in-nested-function.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@chained-assignment-context-variable.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@chained-assignment-expressions.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@codegen-emit-imports-same-source.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@codegen-emit-make-read-only.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@codegen-instrument-forget-gating-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@codegen-instrument-forget-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@complex-while.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@component.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@computed-call-evaluation-order.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@computed-call-spread.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@computed-load-primitive-as-dependency.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@computed-store-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@concise-arrow-expr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@cond-deps-conditional-member-expr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@conditional-break-labeled.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@conditional-break.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@conditional-on-mutable.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@conditional-set-state-in-render.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@console-readonly.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@const-propagation-into-function-expression-global.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@const-propagation-into-function-expression-primitive.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@constant-computed.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@constant-propagation-for.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@constant-propagation-into-function-expressions.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@constant-propagation-phi.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@constant-propagation-while.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@constant-propagation.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@constructor.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@context-variable-reassigned-outside-of-lambda.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@controlled-input.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@dce-loop.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@debugger-memoized.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@debugger.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@declare-reassign-variable-in-closure.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@declare-reassign-variable-in-function-declaration.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@delete-computed-property.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@delete-property.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@dependencies-outputs.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@dependencies.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructure-capture-global.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructure-direct-reassignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-array-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-array-param-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-assignment-array-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-assignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-mixed-scope-and-local-variables-with-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-mixed-scope-declarations-and-locals.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-object-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-object-param-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring-property-inference.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@destructuring.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@disable-jsx-memoization.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@do-while-break.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@do-while-compound-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@do-while-conditional-break.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@do-while-continue.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@do-while-early-unconditional-break.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@do-while-simple.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@dominator.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@early-return.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error._todo.computed-lval-in-destructure.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error._todo.multi-arrow-expr-export-default-gating-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.babel-existing-react-namespace-import.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.bug-validate-no-set-state-not-all-mutable-range-extensions-are-bad.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.call-args-destructuring-asignment-complex.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.codegen-error-on-conflicting-imports.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.hoisted-function-declaration.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.hooks-with-React-namespace.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-access-ref-during-render.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-array-push-frozen.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-assign-hook-to-local.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-capture-func-passed-to-jsx.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-computed-store-to-frozen-value.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-delete-computed-property-of-frozen-value.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-delete-property-of-frozen-value.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-destructure-assignment-to-global.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-destructure-to-local-global-variables.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-freeze-conditionally-mutable-lambda.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-freeze-mutable-lambda-mutate-local.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-freeze-mutable-lambda-reassign-local.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-function-expression-mutates-immutable-value.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-mutate-after-aliased-freeze.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-mutate-after-freeze.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-pass-hook-as-call-arg.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-pass-hook-as-prop.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-pass-ref-to-function.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-property-store-to-frozen-value.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-ref-in-callback-invoked-during-render.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-ref-value-as-props.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-set-and-read-ref-during-render.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-sketchy-code-use-forget.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-ternary-with-hook-values.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-unconditional-set-state-in-render.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-use-ref-added-to-dep-without-type-info.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-useMemo-async-callback.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.invalid-useMemo-callback-args.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.mutate-captured-arg-separately.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.mutate-global-increment-op-invalid-react.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.reassignment-to-global.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo-kitchensink.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo-unconditional-set-state-lambda.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo.destructure-assignment-to-context-var.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.useMemo-callback-generator.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.while-with-assignment-in-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-destructured-rest-element.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-jsx-child.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-logical.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-allocating-dependency.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-primitive-dependency.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-conditional-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-if-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-switch-case.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-switch-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@expression-with-assignment-dynamic.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@expression-with-assignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@extend-scopes-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-call-complex-param-value.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-params-complex-param-value.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-params.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-template-string-same-scope.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-empty-update-with-continue.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-empty-update.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-logical.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-break.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-conditional-break.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-continue.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-destructure.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-simple.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-return.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@frozen-after-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-reassign.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-redeclare.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-simple.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-captures-value-later-frozen-jsx.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-maybe-mutates-hook-return-value.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-with-store-to-parameter.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-param-assignment-pattern.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-default-function.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-function-and-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-function.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@global-jsx-tag-lowered-between-mutations.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-Boolean.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-Number.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-String.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-expr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-pattern-dce-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-pattern-dce.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hook-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hook-inside-logical-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hooks-freeze-arguments.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hooks-freeze-possibly-mutable-arguments.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@immutable-hooks.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inadvertent-mutability-readonly-class.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inadvertent-mutability-readonly-lambda.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independent-across-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independent.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independently-memoize-object-property.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-computed-delete.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-global-object.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-phi-primitive.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-property-delete.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-types-through-type-cast.flow.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inner-memo-value-not-promoted-to-outer-scope-dynamic.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inner-memo-value-not-promoted-to-outer-scope-static.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@interdependent-across-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@interdependent.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inverted-if-else.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inverted-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@issue852.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@issue933-disjoint-set-infinite-loop.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-empty-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-fragment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-member-expression-tag-grouping.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-member-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-namespaced-name.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-spread.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-tag-evaluation-order-non-global.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-tag-evaluation-order.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-capture-returned-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutate-shadowed-object.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutated-non-reactive-to-reactive.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutated-ref-non-reactive.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-reassign-primitive.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-reassign-shadowed-primitive.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-with-fbt.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@logical-expression-object.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@logical-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@method-call-computed.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@method-call-fn-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@method-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@multi-arrow-expr-export-gating-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@multi-arrow-expr-gating-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@mutable-lifetime-loops.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@mutable-lifetime-with-aliasing.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@mutable-liverange-loop.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@nested-function-shadowed-identifiers.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@nested-optional-member-expr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@nested-scopes-hook-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@new-spread.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@nonoptional-load-from-optional-memberexpr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@obj-literal-cached-in-if-else.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@obj-literal-mutated-after-if-else.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@obj-mutated-after-if-else-with-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@obj-mutated-after-if-else.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@obj-mutated-after-nested-if-else-with-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@object-computed-access-assignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@object-expression-string-literal-key.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@object-literal-spread-element.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@object-pattern-params.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@object-properties.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-call-chained.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-call-logical.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-call-simple.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-call-with-independently-memoizable-arg.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-call-with-optional-property-load.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-computed-load-static.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-computed-member-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-member-expression-call-as-property.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-member-expression-chain.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-member-expression-with-optional-member-expr-as-property.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-member-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-method-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-receiver-method-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@optional-receiver-optional-method.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@overlapping-scopes-interleaved-by-terminal.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@overlapping-scopes-interleaved.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@overlapping-scopes-shadowed.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@overlapping-scopes-shadowing-within-block.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@overlapping-scopes-while.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@overlapping-scopes-within-block.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@primitive-alias-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@primitive-as-dep-nested-scope.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@primitive-as-dep.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@prop-capturing-function-1.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@property-assignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@property-call-evaluation-order.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@property-call-spread.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reactive-dependencies-non-optional-properties-inside-optional-chain.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reactive-scope-grouping.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reactive-scopes-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reactive-scopes.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reactivity-analysis-interleaved-reactivity.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reactivity-analysis-reactive-via-mutation-of-computed-load.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reactivity-analysis-reactive-via-mutation-of-property-load.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reassign-object-in-context.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reassign-primitive-in-context.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reassigned-phi-in-returned-function-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reassignment-conditional.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reassignment-separate-scopes.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reassignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@recursive-function-expr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-cfg-condexpr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-cfg-ifelse.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-cfg-nested-ifelse-missing.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-cfg-nested-ifelse.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-cfg-switch-missing-case.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-cfg-switch-missing-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-cfg-switch.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-no-uncond.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-promote-uncond.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-subpath-order1.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-subpath-order2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-superpath-order1.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-deps-superpath-order2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-cond-memberexpr-join.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-dependencies-optional-member-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-deps-cond-scope.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-deps-join-uncond-scopes-cond-deps.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-uncond-deps-nonoverlap-descendant.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-uncond-deps-nonoverlap-direct.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-uncond-deps-overlap-descendant.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-uncond-deps-overlap-direct.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-uncond-deps-subpath-order1.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-uncond-deps-subpath-order2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reduce-reactive-uncond-deps-subpath-order3.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ref-current-aliased-no-added-to-dep.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ref-current-aliased-not-added-to-dep-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ref-current-field-not-added-to-dep.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ref-current-not-added-to-dep-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ref-current-not-added-to-dep.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ref-current-optional-field-no-added-to-dep.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ref-current-write-not-added-to-dep.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ref-in-effect.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@regexp-literal.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@remove-memoization-kitchen-sink.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@repro-reassign-to-variable-without-mutable-range.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@repro-scope-missing-mutable-range.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@repro.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@return-conditional.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@return-undefined.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@reverse-postorder.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@same-variable-as-dep-and-redeclare-maybe-frozen.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@same-variable-as-dep-and-redeclare.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@sequence-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@sequentially-constant-progagatable-if-test-conditions.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@simple-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@simple-function-1.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@simple-scope.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@simple.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@sketchy-code-exhaustive-deps.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@sketchy-code-rules-of-hooks.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-arrayexpression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-call-jsx-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-call-jsx.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-cascading-eliminated-phis.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-complex-multiple-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-complex-single-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-for-of.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-for-trivial-update.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-for.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-if-else.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-leave-case.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-multiple-phis.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-nested-loops-no-reassign.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-nested-partial-phi.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-nested-partial-reassignment.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-newexpression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-non-empty-initializer.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-objectexpression-phi.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-objectexpression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-alias-alias-mutate-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-alias-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-alias-mutate-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-alias-mutate-inside-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-alias-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-mutate-2.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-mutate-alias.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property-mutate.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-property.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-reassign-in-rval.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-reassign.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-ternary-destruction-with-mutation.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-ternary-destruction.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-ternary-with-mutation.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-ternary.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-unconditional-ternary-with-mutation.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-unconditional-ternary.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-unconditional-with-mutation.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-via-destructuring-with-mutation.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-via-destructuring.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming-with-mutation.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-renaming.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-return.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-shadowing.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-sibling-phis.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-simple-phi.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-simple.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-single-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-switch.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-throw.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-while-no-reassign.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ssa-while.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@store-via-call.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@store-via-new.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@switch-global-propertyload-case-test.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@switch-non-final-default.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@switch-with-fallthrough.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@switch.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@tagged-template-in-hook.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@tagged-template-literal.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@template-literal.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@temporary-accessed-outside-scope.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@temporary-at-start-of-value-block.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@temporary-property-load-accessed-outside-scope.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ternary-assignment-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@ternary-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@timers.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@todo-function-expression-captures-value-later-frozen.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@todo.unnecessary-lambda-memoization.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@transitive-alias-fields.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@trivial.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-args-test-binary-operator.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-binary-operator.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-cast-expression.flow.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-field-load.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-test-field-load-binary-op.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-test-field-store.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-test-polymorphic.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-test-primitive.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@type-test-return-type-inference.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unary-expr.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unconditional-break-label.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@uninitialized-declaration-in-reactive-scope.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unknown-hooks-do-not-assert.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-array-middle-element.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-array-rest-element.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-conditional.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-logical-assigned-to-variable.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-logical.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-object-element-with-rest.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-object-element.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-optional-method-assigned-to-variable.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@unused-ternary-assigned-to-variable.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@update-expression.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@use-callback-simple.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useEffect-arg-memoized.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useEffect-nested-lambdas.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-if-else-multiple-return.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-independently-memoizeable.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-inlining-block-return.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-inverted-if.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-labeled-statement-unconditional-return.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-logical.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-multiple-if-else.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-named-function.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-nested-ifs.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-return-empty.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-simple.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-switch-no-fallthrough.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@useMemo-switch-return.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@while-break.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@while-conditional-continue.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@while-logical.js.snap delete mode 100644 compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@while-property.js.snap delete mode 100644 compiler/crates/react_hir/Cargo.toml delete mode 100644 compiler/crates/react_hir/README.md delete mode 100644 compiler/crates/react_hir/src/basic_block.rs delete mode 100644 compiler/crates/react_hir/src/environment.rs delete mode 100644 compiler/crates/react_hir/src/features.rs delete mode 100644 compiler/crates/react_hir/src/function.rs delete mode 100644 compiler/crates/react_hir/src/id_types.rs delete mode 100644 compiler/crates/react_hir/src/initialize.rs delete mode 100644 compiler/crates/react_hir/src/inline_use_memo.rs delete mode 100644 compiler/crates/react_hir/src/instruction.rs delete mode 100644 compiler/crates/react_hir/src/lib.rs delete mode 100644 compiler/crates/react_hir/src/merge_consecutive_blocks.rs delete mode 100644 compiler/crates/react_hir/src/print.rs delete mode 100644 compiler/crates/react_hir/src/registry.rs delete mode 100644 compiler/crates/react_hir/src/terminal.rs delete mode 100644 compiler/crates/react_hir/src/types.rs delete mode 100644 compiler/crates/react_napi/Cargo.toml delete mode 100644 compiler/crates/react_napi/README.md delete mode 100644 compiler/crates/react_napi/build.rs delete mode 100644 compiler/crates/react_napi/package.json delete mode 100644 compiler/crates/react_napi/src/lib.rs delete mode 100644 compiler/crates/react_napi/yarn.lock delete mode 100644 compiler/crates/react_optimization/Cargo.toml delete mode 100644 compiler/crates/react_optimization/README.md delete mode 100644 compiler/crates/react_optimization/src/constant_propagation.rs delete mode 100644 compiler/crates/react_optimization/src/lib.rs delete mode 100644 compiler/crates/react_semantic_analysis/Cargo.toml delete mode 100644 compiler/crates/react_semantic_analysis/README.md delete mode 100644 compiler/crates/react_semantic_analysis/src/analyzer.rs delete mode 100644 compiler/crates/react_semantic_analysis/src/lib.rs delete mode 100644 compiler/crates/react_semantic_analysis/src/scope_manager.rs delete mode 100644 compiler/crates/react_semantic_analysis/src/scope_view.rs delete mode 100644 compiler/crates/react_semantic_analysis/tests/analysis_test.rs delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/block-item-duplication.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/function-hoisting.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/globals-and-imports.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/labels.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/let-const-hoisting.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/simple-function.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/tdz.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/var-duplication.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/fixtures/var-hoisting.js delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@block-item-duplication.js.snap delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@function-hoisting.js.snap delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@globals-and-imports.js.snap delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@labels.js.snap delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@let-const-hoisting.js.snap delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@simple-function.js.snap delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@tdz.js.snap delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@var-duplication.js.snap delete mode 100644 compiler/crates/react_semantic_analysis/tests/snapshots/analysis_test__fixtures@var-hoisting.js.snap delete mode 100644 compiler/crates/react_ssa/Cargo.toml delete mode 100644 compiler/crates/react_ssa/README.md delete mode 100644 compiler/crates/react_ssa/src/eliminate_redundant_phis.rs delete mode 100644 compiler/crates/react_ssa/src/enter.rs delete mode 100644 compiler/crates/react_ssa/src/leave.rs delete mode 100644 compiler/crates/react_ssa/src/lib.rs delete mode 100644 compiler/crates/react_utils/Cargo.toml delete mode 100644 compiler/crates/react_utils/README.md delete mode 100644 compiler/crates/react_utils/src/ensure_sufficient_stack.rs delete mode 100644 compiler/crates/react_utils/src/lib.rs delete mode 100644 compiler/crates/react_utils/src/pointer_address.rs delete mode 100644 compiler/rust-toolchain.toml delete mode 100644 compiler/rustfmt.toml diff --git a/.github/workflows/compiler_rust.yml b/.github/workflows/compiler_rust.yml deleted file mode 100644 index 3937f92355d02..0000000000000 --- a/.github/workflows/compiler_rust.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: (Compiler) Rust - -on: - push: - branches: ["main"] - paths: - - .github/workflows/** - - compiler/crates/** - - compiler/Cargo.* - - compiler/*.toml - pull_request: - paths: - - .github/workflows/** - - compiler/crates/** - - compiler/Cargo.* - - compiler/*.toml - -concurrency: - group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.run_id }} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - RUSTFLAGS: -Dwarnings - TZ: /usr/share/zoneinfo/America/Los_Angeles - -defaults: - run: - working-directory: compiler - -jobs: - test: - name: Rust Test (${{ matrix.target.os }}) - strategy: - matrix: - target: - - target: ubuntu-latest - os: ubuntu-latest - # TODO: run on more platforms - # - target: macos-latest - # os: macos-latest - # - target: windows-latest - # os: windows-latest - runs-on: ${{ matrix.target.os }} - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - - name: cargo test - run: cargo test --manifest-path=Cargo.toml --locked ${{ matrix.target.features && '--features' }} ${{ matrix.target.features }} - - lint: - name: Rust Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - # NOTE: use `rustup run ` in commands below - # with this exact same toolchain value - toolchain: nightly-2023-08-01 - override: true - components: rustfmt, clippy - - uses: Swatinem/rust-cache@v2 - - name: rustfmt - run: grep -r --include "*.rs" --files-without-match "@generated" crates | xargs rustup run nightly-2023-08-01 rustfmt --check --config="skip_children=true" - # - name: cargo clippy - # run: rustup run nightly-2023-08-01 cargo clippy -- -Dclippy::correctness - - build: - name: Rust Build - runs-on: ubuntu-latest - # TODO: build on more platforms, deploy, etc - steps: - - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - - name: cargo build - run: cargo build --release diff --git a/compiler/Cargo.lock b/compiler/Cargo.lock deleted file mode 100644 index a565ff1574e6a..0000000000000 --- a/compiler/Cargo.lock +++ /dev/null @@ -1,1217 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "aho-corasick" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" - -[[package]] -name = "backtrace" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "backtrace-ext" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50" -dependencies = [ - "backtrace", -] - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - -[[package]] -name = "bstr" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" -dependencies = [ - "memchr", - "serde", -] - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - -[[package]] -name = "console" -version = "0.15.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "windows-sys 0.45.0", -] - -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "ctor" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" -dependencies = [ - "quote", - "syn 2.0.23", -] - -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - -[[package]] -name = "equivalent" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" - -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "form_urlencoded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" - -[[package]] -name = "globset" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" -dependencies = [ - "aho-corasick 0.7.20", - "bstr", - "fnv", - "log", - "regex", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - -[[package]] -name = "hermes" -version = "0.1.0" -source = "git+https://github.com/facebook/hermes.git#b2618410b4093e780a04228a2ce87a3626983506" -dependencies = [ - "cmake", - "juno_support", - "libc", - "libcplusplus", - "thiserror", -] - -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - -[[package]] -name = "idna" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" -dependencies = [ - "equivalent", - "hashbrown 0.14.0", - "serde", -] - -[[package]] -name = "insta" -version = "1.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28491f7753051e5704d4d0ae7860d45fae3238d7d235bc4289dcd45c48d3cec3" -dependencies = [ - "console", - "globset", - "lazy_static", - "linked-hash-map", - "similar", - "walkdir", - "yaml-rust", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "is-terminal" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" -dependencies = [ - "hermit-abi", - "io-lifetimes", - "rustix", - "windows-sys 0.48.0", -] - -[[package]] -name = "is_ci" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" - -[[package]] -name = "itoa" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" - -[[package]] -name = "juno_support" -version = "0.1.0" -source = "git+https://github.com/facebook/hermes.git#b2618410b4093e780a04228a2ce87a3626983506" -dependencies = [ - "anyhow", - "base64", - "cmake", - "libcplusplus", - "thiserror", - "url", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - -[[package]] -name = "libcplusplus" -version = "0.1.0" -source = "git+https://github.com/facebook/hermes.git#b2618410b4093e780a04228a2ce87a3626983506" - -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "log" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "miette" -version = "5.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a236ff270093b0b67451bc50a509bd1bad302cb1d3c7d37d5efe931238581fa9" -dependencies = [ - "backtrace", - "backtrace-ext", - "is-terminal", - "miette-derive", - "once_cell", - "owo-colors", - "supports-color", - "supports-hyperlinks", - "supports-unicode", - "terminal_size", - "textwrap", - "thiserror", - "unicode-width", -] - -[[package]] -name = "miette-derive" -version = "5.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4901771e1d44ddb37964565c654a3223ba41a594d02b8da471cc4464912b5cfa" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", -] - -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", -] - -[[package]] -name = "napi" -version = "2.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd063c93b900149304e3ba96ce5bf210cd4f81ef5eb80ded0d100df3e85a3ac0" -dependencies = [ - "bitflags 2.4.0", - "ctor", - "napi-derive", - "napi-sys", - "once_cell", - "serde", - "serde_json", - "tokio", -] - -[[package]] -name = "napi-build" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882a73d9ef23e8dc2ebbffb6a6ae2ef467c0f18ac10711e4cc59c5485d41df0e" - -[[package]] -name = "napi-derive" -version = "2.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da1c6a8fa84d549aa8708fcd062372bf8ec6e849de39016ab921067d21bde367" -dependencies = [ - "cfg-if", - "convert_case", - "napi-derive-backend", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "napi-derive-backend" -version = "1.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20bbc7c69168d06a848f925ec5f0e0997f98e8c8d4f2cc30157f0da51c009e17" -dependencies = [ - "convert_case", - "once_cell", - "proc-macro2", - "quote", - "regex", - "semver", - "syn 1.0.109", -] - -[[package]] -name = "napi-sys" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "166b5ef52a3ab5575047a9fe8d4a030cdd0f63c96f071cd6907674453b07bae3" -dependencies = [ - "libloading", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - -[[package]] -name = "percent-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - -[[package]] -name = "pin-project-lite" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" - -[[package]] -name = "prettyplease" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92139198957b410250d43fad93e630d956499a625c527eda65175c8680f83387" -dependencies = [ - "proc-macro2", - "syn 2.0.23", -] - -[[package]] -name = "proc-macro2" -version = "1.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "psm" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" -dependencies = [ - "cc", -] - -[[package]] -name = "quote" -version = "1.0.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "react_build_hir" -version = "0.1.0" -dependencies = [ - "indexmap", - "react_diagnostics", - "react_estree", - "react_hir", - "react_semantic_analysis", - "thiserror", -] - -[[package]] -name = "react_diagnostics" -version = "0.1.0" -dependencies = [ - "miette", - "react_estree", - "static_assertions", - "thiserror", -] - -[[package]] -name = "react_estree" -version = "0.1.0" -dependencies = [ - "insta", - "react_estree_codegen", - "serde", - "serde_json", - "static_assertions", -] - -[[package]] -name = "react_estree_codegen" -version = "0.1.0" -dependencies = [ - "indexmap", - "prettyplease", - "quote", - "serde", - "serde_json", - "syn 2.0.23", -] - -[[package]] -name = "react_fixtures" -version = "0.1.0" -dependencies = [ - "insta", - "miette", - "react_build_hir", - "react_estree", - "react_hermes_parser", - "react_hir", - "react_optimization", - "react_semantic_analysis", - "react_ssa", -] - -[[package]] -name = "react_hermes_parser" -version = "0.1.0" -dependencies = [ - "hermes", - "insta", - "juno_support", - "react_diagnostics", - "react_estree", - "react_estree_codegen", - "serde_json", -] - -[[package]] -name = "react_hir" -version = "0.1.0" -dependencies = [ - "indexmap", - "react_diagnostics", - "react_estree", - "react_semantic_analysis", - "react_utils", - "serde", - "thiserror", -] - -[[package]] -name = "react_napi" -version = "0.1.0" -dependencies = [ - "napi", - "napi-build", - "napi-derive", - "react_diagnostics", - "react_estree", - "react_hermes_parser", - "react_semantic_analysis", - "serde_json", -] - -[[package]] -name = "react_optimization" -version = "0.1.0" -dependencies = [ - "indexmap", - "miette", - "react_build_hir", - "react_diagnostics", - "react_estree", - "react_hir", - "react_ssa", - "react_utils", - "thiserror", -] - -[[package]] -name = "react_semantic_analysis" -version = "0.1.0" -dependencies = [ - "indexmap", - "insta", - "miette", - "react_diagnostics", - "react_estree", - "react_hermes_parser", - "react_utils", - "serde_json", -] - -[[package]] -name = "react_ssa" -version = "0.1.0" -dependencies = [ - "indexmap", - "miette", - "react_diagnostics", - "react_hir", - "react_utils", - "thiserror", -] - -[[package]] -name = "react_utils" -version = "0.1.0" -dependencies = [ - "stacker", -] - -[[package]] -name = "regex" -version = "1.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" -dependencies = [ - "aho-corasick 1.0.2", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustix" -version = "0.37.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys 0.48.0", -] - -[[package]] -name = "ryu" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "semver" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" - -[[package]] -name = "serde" -version = "1.0.167" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daf513456463b42aa1d94cff7e0c24d682b429f020b9afa4f5ba5c40a22b237" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.167" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69b106b68bc8054f0e974e70d19984040f8a5cf9215ca82626ea4853f82c4b9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", -] - -[[package]] -name = "serde_json" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "similar" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" - -[[package]] -name = "smawk" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" - -[[package]] -name = "stacker" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" -dependencies = [ - "cc", - "cfg-if", - "libc", - "psm", - "winapi", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "supports-color" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4950e7174bffabe99455511c39707310e7e9b440364a2fcb1cc21521be57b354" -dependencies = [ - "is-terminal", - "is_ci", -] - -[[package]] -name = "supports-hyperlinks" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84231692eb0d4d41e4cdd0cabfdd2e6cd9e255e65f80c9aa7c98dd502b4233d" -dependencies = [ - "is-terminal", -] - -[[package]] -name = "supports-unicode" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6c2cb240ab5dd21ed4906895ee23fe5a48acdbd15a3ce388e7b62a9b66baf7" -dependencies = [ - "is-terminal", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "textwrap" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" -dependencies = [ - "smawk", - "unicode-linebreak", - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c16a64ba9387ef3fdae4f9c1a7f07a0997fce91985c0336f1ddc1822b3b37802" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d14928354b01c4d6a4f0e549069adef399a284e7995c7ccca94e8a07a5346c59" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" -dependencies = [ - "backtrace", - "num_cpus", - "pin-project-lite", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - -[[package]] -name = "unicode-ident" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" - -[[package]] -name = "unicode-linebreak" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" -dependencies = [ - "hashbrown 0.12.3", - "regex", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - -[[package]] -name = "url" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "walkdir" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.1", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml deleted file mode 100644 index db4e1fc4c3a59..0000000000000 --- a/compiler/Cargo.toml +++ /dev/null @@ -1,61 +0,0 @@ -[workspace] -resolver = "2" -members = ["crates/*"] - -[workspace.package] -authors = ["The React Team https://react.dev/community/team"] -description = "React Compiler" -edition = "2021" -homepage = "https://github.com/facebook/react" -keywords = ["JavaScript", "TypeScript", "React", "React Compiler", "Compiler"] -license = "MIT" -repository = "https://github.com/facebook/react" - -[workspace.dependencies] -# workspace crates -react_build_hir = { path = "crates/react_build_hir" } -react_diagnostics = { path = "crates/react_diagnostics" } -react_estree = { path = "crates/react_estree" } -react_estree_codegen = { path = "crates/react_estree_codegen" } -react_fixtures = { path = "crates/react_fixtures" } -react_hermes_parser = { path = "crates/react_hermes_parser" } -react_hir = { path = "crates/react_hir" } -react_optimization = { path = "crates/react_optimization" } -react_semantic_analysis = { path = "crates/react_semantic_analysis" } -react_ssa = { path = "crates/react_ssa" } -react_utils = { path = "crates/react_utils" } - -# dependencies -indexmap = { version = "2.0.0", features = ["serde"] } -insta = { version = "1.30.0", features = ["glob"] } -miette = { version = "5.9.0" } -prettyplease = "0.2.10" -quote = "1.0.29" -serde = { version = "1.0.167", features = ["serde_derive"] } -serde_json = "1.0.100" -stacker = "0.1.15" -static_assertions = "1.1.0" -syn = "2.0.23" -thiserror = "1.0.41" -hermes = { git = "https://github.com/facebook/hermes.git" } -juno_support = { git = "https://github.com/facebook/hermes.git" } - -[profile.release] -# configuration adapted from oxc -# https://github.com/Boshen/oxc/blob/ea85ee9f2d64dd284c5b7410f491d81fb879abae/Cargo.toml#L89-L97 -opt-level = 3 -lto = "fat" -codegen-units = 1 -strip = "symbols" -debug = false -panic = "abort" # Let it crash and force ourselves to write safe Rust. - -# Make insta run faster by compiling with release mode optimizations -# https://docs.rs/insta/latest/insta/#optional-faster-runs -[profile.dev.package.insta] -opt-level = 3 - -# Make insta diffing libary faster by compiling with release mode optimizations -# https://docs.rs/insta/latest/insta/#optional-faster-runs -[profile.dev.package.similar] -opt-level = 3 \ No newline at end of file diff --git a/compiler/crates/react_build_hir/Cargo.toml b/compiler/crates/react_build_hir/Cargo.toml deleted file mode 100644 index 55fdeccaa4544..0000000000000 --- a/compiler/crates/react_build_hir/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "react_build_hir" -version = "0.1.0" -publish = false -authors.workspace = true -description.workspace = true -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -react_hir = { workspace = true } -react_estree = { workspace = true} -indexmap = { workspace = true } -react_diagnostics = { workspace = true } -react_semantic_analysis = { workspace = true } -thiserror = { workspace = true } diff --git a/compiler/crates/react_build_hir/README.md b/compiler/crates/react_build_hir/README.md deleted file mode 100644 index 15fb1681f844d..0000000000000 --- a/compiler/crates/react_build_hir/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Build-HIR - -This crate converts from `react_estree` into React Compiler's HIR format as the first phase of compilation. \ No newline at end of file diff --git a/compiler/crates/react_build_hir/src/build.rs b/compiler/crates/react_build_hir/src/build.rs deleted file mode 100644 index f2641af96ba1c..0000000000000 --- a/compiler/crates/react_build_hir/src/build.rs +++ /dev/null @@ -1,746 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use std::collections::HashSet; - -use react_diagnostics::Diagnostic; -use react_estree::{ - AssignmentPropertyOrRestElement, AssignmentTarget, BlockStatement, Expression, - ExpressionOrSpread, ExpressionOrSuper, ForInit, Function, IntoFunction, JsValue, Pattern, - Statement, VariableDeclaration, VariableDeclarationKind, -}; -use react_hir::{ - ArrayDestructureItem, BlockKind, BranchTerminal, Destructure, DestructurePattern, Environment, - ForTerminal, GotoKind, Identifier, IdentifierOperand, InstructionKind, InstructionValue, - JSXAttribute, JSXElement, LValue, LoadGlobal, LoadLocal, ObjectDestructureItem, - ObjectDestructureProperty, PlaceOrSpread, TerminalValue, -}; - -use crate::builder::{Builder, LoopScope}; -use crate::context::get_context_identifiers; -use crate::error::BuildHIRError; - -/// Converts a React function in ESTree format into HIR. Returns the HIR -/// if it was constructed sucessfully, otherwise a list of diagnostics -/// if the input could be not be converted to HIR. -/// -/// Failures generally include nonsensical input (`delete 1`) or syntax -/// that is not yet supported. -pub fn build(env: &Environment, fun: &Function) -> Result, Diagnostic> { - let mut builder = Builder::new(env); - - let mut params = Vec::with_capacity(fun.params.len()); - for param in &fun.params { - match param { - Pattern::Identifier(param) => { - let identifier = lower_identifier_for_assignment( - env, - &mut builder, - InstructionKind::Let, - param, - )?; - params.push(identifier); - } - _ => { - return Err(Diagnostic::todo( - "Support non-identifier params", - param.range(), - )); - } - } - } - - match &fun.body { - Some(react_estree::FunctionBody::BlockStatement(body)) => { - lower_block_statement(env, &mut builder, body)? - } - Some(react_estree::FunctionBody::Expression(body)) => { - lower_expression(env, &mut builder, body)?; - } - None => { - return Err(Diagnostic::invalid_syntax( - BuildHIRError::EmptyFunction, - fun.range, - )); - } - } - - // In case the function did not explicitly return, terminate the final - // block with an explicit `return undefined`. If the function *did* return, - // this will be unreachable and get pruned later. - let implicit_return_value = builder.push(InstructionValue::Primitive(react_hir::Primitive { - value: JsValue::Undefined, - })); - builder.terminate( - TerminalValue::Return(react_hir::ReturnTerminal { - value: implicit_return_value, - }), - react_hir::BlockKind::Block, - ); - - let body = builder.build()?; - Ok(Box::new(react_hir::Function { - id: fun.id.as_ref().map(|id| id.name.clone()), - body, - params, - // TODO: populate context! - context: Default::default(), - is_async: fun.is_async, - is_generator: fun.is_generator, - })) -} - -fn lower_block_statement( - env: &Environment, - builder: &mut Builder, - stmt: &BlockStatement, -) -> Result<(), Diagnostic> { - for stmt in &stmt.body { - lower_statement(env, builder, stmt, None)?; - } - Ok(()) -} - -/// Convert a statement to HIR. This will often result in multiple instructions and blocks -/// being created as statements often describe control flow. -fn lower_statement( - env: &Environment, - builder: &mut Builder, - stmt: &Statement, - label: Option, -) -> Result<(), Diagnostic> { - match stmt { - Statement::BlockStatement(stmt) => { - lower_block_statement(env, builder, stmt)?; - } - Statement::BreakStatement(stmt) => { - let block = builder.resolve_break(stmt.label.as_ref())?; - builder.terminate( - TerminalValue::Goto(react_hir::GotoTerminal { - block, - kind: GotoKind::Break, - }), - BlockKind::Block, - ); - } - Statement::ContinueStatement(stmt) => { - let block = builder.resolve_continue(stmt.label.as_ref())?; - builder.terminate( - TerminalValue::Goto(react_hir::GotoTerminal { - block, - kind: GotoKind::Continue, - }), - BlockKind::Block, - ); - } - Statement::ReturnStatement(stmt) => { - let value = match &stmt.argument { - Some(argument) => lower_expression(env, builder, argument)?, - None => builder.push(InstructionValue::Primitive(react_hir::Primitive { - value: JsValue::Undefined, - })), - }; - builder.terminate( - TerminalValue::Return(react_hir::ReturnTerminal { value }), - BlockKind::Block, - ); - } - Statement::ExpressionStatement(stmt) => { - lower_expression(env, builder, &stmt.expression)?; - } - Statement::EmptyStatement(_) => { - // no-op - } - Statement::VariableDeclaration(stmt) => { - lower_variable_declaration(env, builder, stmt)?; - } - Statement::IfStatement(stmt) => { - // block for what follows the if statement, though this may - // not be reachable - let fallthrough_block = builder.reserve(BlockKind::Block); - - let consequent_block = builder.enter(BlockKind::Block, |builder| { - lower_statement(env, builder, &stmt.consequent, None)?; - Ok(TerminalValue::Goto(react_hir::GotoTerminal { - block: fallthrough_block.id, - kind: GotoKind::Break, - })) - })?; - - let alternate_block = builder.enter(BlockKind::Block, |builder| { - if let Some(alternate) = &stmt.alternate { - lower_statement(env, builder, alternate, None)?; - } - Ok(TerminalValue::Goto(react_hir::GotoTerminal { - block: fallthrough_block.id, - kind: GotoKind::Break, - })) - })?; - - let test = lower_expression(env, builder, &stmt.test)?; - let terminal = TerminalValue::If(react_hir::IfTerminal { - test, - consequent: consequent_block, - alternate: alternate_block, - fallthrough: Some(fallthrough_block.id), - }); - builder.terminate_with_fallthrough(terminal, fallthrough_block); - } - Statement::ForStatement(stmt) => { - // Block for the loop's test condition - let test_block = builder.reserve(BlockKind::Loop); - - // Block for code following the loop - let fallthrough_block = builder.reserve(BlockKind::Block); - - let init_block = builder.enter(BlockKind::Loop, |builder| { - if let Some(ForInit::VariableDeclaration(decl)) = &stmt.init { - lower_variable_declaration(env, builder, decl)?; - Ok(TerminalValue::Goto(react_hir::GotoTerminal { - block: test_block.id, - kind: GotoKind::Break, - })) - } else { - Err(Diagnostic::todo( - BuildHIRError::ForStatementIsMissingInitializer, - None, - )) - } - })?; - - let update_block = stmt - .update - .as_ref() - .map(|update| { - builder.enter(BlockKind::Loop, |builder| { - lower_expression(env, builder, update)?; - Ok(TerminalValue::Goto(react_hir::GotoTerminal { - block: test_block.id, - kind: GotoKind::Break, - })) - }) - }) - .transpose()?; - - let body_block = builder.enter(BlockKind::Block, |builder| { - let loop_ = LoopScope { - label, - continue_block: update_block.unwrap_or(test_block.id), - break_block: fallthrough_block.id, - }; - builder.enter_loop(loop_, |builder| { - lower_statement(env, builder, &stmt.body, None)?; - Ok(TerminalValue::Goto(react_hir::GotoTerminal { - block: update_block.unwrap_or(test_block.id), - kind: GotoKind::Continue, - })) - }) - })?; - - let terminal = TerminalValue::For(ForTerminal { - body: body_block, - init: init_block, - test: test_block.id, - fallthrough: fallthrough_block.id, - update: update_block, - }); - builder.terminate_with_fallthrough(terminal, test_block); - - if let Some(test) = &stmt.test { - let test_value = lower_expression(env, builder, test)?; - let terminal = TerminalValue::Branch(BranchTerminal { - test: test_value, - consequent: body_block, - alternate: fallthrough_block.id, - }); - builder.terminate_with_fallthrough(terminal, fallthrough_block); - } else { - return Err(Diagnostic::todo( - BuildHIRError::ForStatementIsMissingTest, - stmt.range, - )); - } - } - _ => todo!("Lower {stmt:#?}"), - } - Ok(()) -} - -fn lower_variable_declaration( - env: &Environment, - builder: &mut Builder, - stmt: &VariableDeclaration, -) -> Result<(), Diagnostic> { - let kind = match stmt.kind { - VariableDeclarationKind::Const => InstructionKind::Const, - VariableDeclarationKind::Let => InstructionKind::Let, - VariableDeclarationKind::Var => { - return Err(Diagnostic::unsupported( - BuildHIRError::VariableDeclarationKindIsVar, - stmt.range, - )); - } - }; - for declaration in &stmt.declarations { - if let Some(init) = &declaration.init { - let value = lower_expression(env, builder, init)?; - lower_assignment_pattern(env, builder, kind, &declaration.id, value)?; - } else { - match &declaration.id { - Pattern::Identifier(id) => { - let identifier = env.resolve_variable_declaration(id.as_ref(), &id.name); - if let Some(identifier) = identifier { - builder.push(InstructionValue::DeclareLocal(react_hir::DeclareLocal { - lvalue: LValue { - identifier: IdentifierOperand { - identifier, - effect: None, - }, - kind, - }, - })); - } else { - return Err(Diagnostic::invariant( - BuildHIRError::VariableDeclarationBindingIsNonLocal, - id.range, - )); - } - } - _ => { - return Err(Diagnostic::invalid_syntax( - "Expected an identifier for variable declaration without an intializer. Destructuring requires an initial value", - declaration.range, - )); - } - } - } - } - Ok(()) -} - -/// Converts an ESTree Expression into an HIR InstructionValue. Note that while only a single -/// InstructionValue is returned, this function is recursive and may cause multiple instructions -/// to be emitted, possibly across multiple basic blocks (in the case of expressions with control -/// flow semenatics such as logical, conditional, and optional expressions). -fn lower_expression( - env: &Environment, - builder: &mut Builder, - expr: &Expression, -) -> Result { - let value = match expr { - Expression::Identifier(expr) => { - let identifier = env.resolve_variable_reference(expr.as_ref()); - if let Some(identifier) = identifier { - let place = IdentifierOperand { - effect: None, - identifier, - }; - InstructionValue::LoadLocal(LoadLocal { place }) - } else { - InstructionValue::LoadGlobal(LoadGlobal { - name: expr.name.clone(), - }) - } - } - Expression::Literal(expr) => InstructionValue::Primitive(react_hir::Primitive { - value: expr.value.clone(), - }), - Expression::NumericLiteral(expr) => InstructionValue::Primitive(react_hir::Primitive { - value: JsValue::Number(expr.value), - }), - Expression::BooleanLiteral(expr) => InstructionValue::Primitive(react_hir::Primitive { - value: JsValue::Boolean(expr.value), - }), - Expression::StringLiteral(expr) => InstructionValue::Primitive(react_hir::Primitive { - value: JsValue::String(expr.value.clone()), - }), - Expression::NullLiteral(_expr) => InstructionValue::Primitive(react_hir::Primitive { - value: JsValue::Null, - }), - Expression::ArrayExpression(expr) => { - let mut elements = Vec::with_capacity(expr.elements.len()); - for expr in &expr.elements { - let element = match expr { - Some(react_estree::ExpressionOrSpread::SpreadElement(expr)) => Some( - PlaceOrSpread::Spread(lower_expression(env, builder, &expr.argument)?), - ), - Some(react_estree::ExpressionOrSpread::Expression(expr)) => { - Some(PlaceOrSpread::Place(lower_expression(env, builder, expr)?)) - } - None => None, - }; - elements.push(element); - } - InstructionValue::Array(react_hir::Array { elements }) - } - - Expression::AssignmentExpression(expr) => match expr.operator { - react_estree::AssignmentOperator::Equals => { - let right = lower_expression(env, builder, &expr.right)?; - return lower_assignment( - env, - builder, - InstructionKind::Reassign, - &expr.left, - right, - ); - } - _ => todo!("lower assignment expr {:#?}", expr), - }, - - Expression::BinaryExpression(expr) => { - let left = lower_expression(env, builder, &expr.left)?; - let right = lower_expression(env, builder, &expr.right)?; - InstructionValue::Binary(react_hir::Binary { - left, - operator: expr.operator, - right, - }) - } - - Expression::FunctionExpression(expr) => { - InstructionValue::Function(lower_function(env, builder, expr.as_ref())?) - } - - Expression::ArrowFunctionExpression(expr) => { - InstructionValue::Function(lower_function(env, builder, expr.as_ref())?) - } - - Expression::CallExpression(expr) => { - let callee_expr = match &expr.callee { - ExpressionOrSuper::Super(callee) => { - return Err(Diagnostic::unsupported( - BuildHIRError::UnsupportedSuperExpression, - callee.range, - )); - } - ExpressionOrSuper::Expression(callee) => callee, - }; - - if matches!(&callee_expr, Expression::MemberExpression(_)) { - return Err(Diagnostic::todo("Support method calls", expr.range)); - } - - let callee = lower_expression(env, builder, callee_expr)?; - let arguments = lower_arguments(env, builder, &expr.arguments)?; - InstructionValue::Call(react_hir::Call { callee, arguments }) - } - - Expression::JSXElement(expr) => { - InstructionValue::JSXElement(lower_jsx_element(env, builder, expr)?) - } - - _ => todo!("Lower expr {expr:#?}"), - }; - Ok(builder.push(value)) -} - -fn lower_arguments( - env: &Environment, - builder: &mut Builder, - args: &[ExpressionOrSpread], -) -> Result, Diagnostic> { - let mut arguments = Vec::with_capacity(args.len()); - for arg in args { - let element = match arg { - react_estree::ExpressionOrSpread::SpreadElement(arg) => { - PlaceOrSpread::Spread(lower_expression(env, builder, &arg.argument)?) - } - react_estree::ExpressionOrSpread::Expression(arg) => { - PlaceOrSpread::Place(lower_expression(env, builder, arg)?) - } - }; - arguments.push(element); - } - Ok(arguments) -} - -fn lower_function( - env: &Environment, - _builder: &mut Builder, - function: &T, -) -> Result { - let context_identifiers = get_context_identifiers(env, function); - let mut context = Vec::new(); - let mut seen = HashSet::new(); - for declaration_id in context_identifiers { - if let Some(identifier) = env.resolve_declaration_id(declaration_id) { - if !seen.insert(identifier.id) { - continue; - } - context.push(IdentifierOperand { - effect: None, - identifier, - }); - } - } - let mut fun = build(env, function.function())?; - fun.context = context; - Ok(react_hir::FunctionExpression { - // TODO: collect dependencies! - dependencies: Default::default(), - lowered_function: fun, - }) -} - -fn lower_jsx_element( - env: &Environment, - builder: &mut Builder, - expr: &react_estree::JSXElement, -) -> Result { - let props: Result, Diagnostic> = expr - .opening_element - .attributes - .iter() - .map(|attr| lower_jsx_attribute(env, builder, attr)) - .collect(); - let _props = props?; - let children: Result, Diagnostic> = expr - .children - .iter() - .map(|child| { - let child = lower_jsx_child(env, builder, child)?; - Ok(child) - }) - .collect(); - let _children = children?; - todo!("lower jsx element"); - // Ok(JSXElement { - // tag: todo!(), - // props, - // children: if children.is_empty() { - // None - // } else { - // Some(children) - // }, - // }) -} - -fn lower_jsx_attribute( - _env: &Environment, - _builder: &mut Builder, - _attr: &react_estree::JSXAttributeOrSpread, -) -> Result { - todo!("lower jsx attribute") -} - -fn lower_jsx_child( - _env: &Environment, - _builder: &mut Builder, - _child: &react_estree::JSXChildItem, -) -> Result { - todo!("lower jsx child") -} - -fn lower_assignment( - env: &Environment, - builder: &mut Builder, - kind: InstructionKind, - lvalue: &AssignmentTarget, - value: IdentifierOperand, -) -> Result { - Ok(match lvalue { - AssignmentTarget::Pattern(lvalue) => { - lower_assignment_pattern(env, builder, kind, lvalue, value)? - } - _ => todo!("lower assignment for {:#?}", lvalue), - }) -} - -// TODO: change the success type to void, no caller uses it -fn lower_assignment_pattern( - env: &Environment, - builder: &mut Builder, - kind: InstructionKind, - lvalue: &Pattern, - value: IdentifierOperand, -) -> Result { - Ok(match lvalue { - Pattern::Identifier(lvalue) => { - let identifier = lower_identifier_for_assignment(env, builder, kind, lvalue)?; - builder.push(InstructionValue::StoreLocal(react_hir::StoreLocal { - lvalue: LValue { identifier, kind }, - value, - })) - } - Pattern::ArrayPattern(lvalue) => { - let mut items = Vec::with_capacity(lvalue.elements.len()); - let mut followups: Vec<(Identifier, &Pattern)> = Vec::new(); - for element in &lvalue.elements { - match element { - None => items.push(ArrayDestructureItem::Hole), - Some(Pattern::Identifier(element)) => { - let identifier = - lower_identifier_for_assignment(env, builder, kind, element)?; - items.push(ArrayDestructureItem::Value(identifier)); - } - Some(Pattern::RestElement(element)) => { - if let Pattern::Identifier(element) = &element.argument { - let identifier = lower_identifier_for_assignment( - env, - builder, - kind, - element.as_ref(), - )?; - items.push(ArrayDestructureItem::Spread(identifier)); - } else { - let temporary = env.new_temporary(); - items.push(ArrayDestructureItem::Spread(IdentifierOperand { - identifier: temporary.clone(), - effect: None, - })); - followups.push((temporary, &element.argument)); - } - } - Some(element) => { - let temporary = env.new_temporary(); - items.push(ArrayDestructureItem::Value(IdentifierOperand { - identifier: temporary.clone(), - effect: None, - })); - followups.push((temporary, element)); - } - } - } - let temporary = builder.push(InstructionValue::Destructure(Destructure { - kind, - pattern: DestructurePattern::Array(items), - value, - })); - for (temporary, pattern) in followups { - lower_assignment_pattern( - env, - builder, - kind, - pattern, - IdentifierOperand { - identifier: temporary, - effect: None, - }, - )?; - } - temporary - } - Pattern::ObjectPattern(lvalue) => { - let mut properties = Vec::with_capacity(lvalue.properties.len()); - let mut followups: Vec<(Identifier, &Pattern)> = Vec::new(); - - for property in &lvalue.properties { - match property { - AssignmentPropertyOrRestElement::RestElement(property) => { - if let Pattern::Identifier(element) = &property.argument { - let identifier = lower_identifier_for_assignment( - env, - builder, - kind, - element.as_ref(), - )?; - properties.push(ObjectDestructureItem::Spread(identifier)); - } else { - let temporary = env.new_temporary(); - properties.push(ObjectDestructureItem::Spread(IdentifierOperand { - identifier: temporary.clone(), - effect: None, - })); - followups.push((temporary, &property.argument)); - } - } - AssignmentPropertyOrRestElement::AssignmentProperty(property) => { - if property.is_computed { - return Err(Diagnostic::todo( - "Handle computed properties in ObjectPattern", - property.range, - )); - } - let key = if let Expression::Identifier(key) = &property.key { - key.name.as_str() - } else { - return Err(Diagnostic::todo( - "Support non-identifier object keys in non-computed ObjectPattern", - property.range, - )); - }; - if let Pattern::Identifier(value) = &property.value { - let value = lower_identifier_for_assignment(env, builder, kind, value)?; - properties.push(ObjectDestructureItem::Property( - ObjectDestructureProperty { - name: key.to_string(), - value, - }, - )); - } else { - let temporary = env.new_temporary(); - properties.push(ObjectDestructureItem::Property( - ObjectDestructureProperty { - name: key.to_string(), - value: IdentifierOperand { - identifier: temporary.clone(), - effect: None, - }, - }, - )); - followups.push((temporary, &property.value)); - } - } - } - } - - let temporary = builder.push(InstructionValue::Destructure(Destructure { - kind, - pattern: DestructurePattern::Object(properties), - value, - })); - for (temporary, pattern) in followups { - lower_assignment_pattern( - env, - builder, - kind, - pattern, - IdentifierOperand { - identifier: temporary, - effect: None, - }, - )?; - } - temporary - } - _ => todo!("lower assignment pattern for {:#?}", lvalue), - }) -} - -fn lower_identifier_for_assignment( - env: &Environment, - _builder: &mut Builder, - kind: InstructionKind, - node: &react_estree::Identifier, -) -> Result { - match kind { - InstructionKind::Reassign => { - let identifier = env.resolve_variable_reference(node); - if let Some(identifier) = identifier { - Ok(IdentifierOperand { - identifier, - effect: None, - }) - } else { - // Reassigning a global - Err( - Diagnostic::invalid_react(BuildHIRError::ReassignedGlobal, node.range) - .annotate(format!("Cannot reassign `{}`", &node.name), node.range), - ) - } - } - _ => { - // Declaration - let identifier = env.resolve_variable_declaration(node, &node.name).unwrap(); - Ok(IdentifierOperand { - identifier, - effect: None, - }) - } - } -} diff --git a/compiler/crates/react_build_hir/src/builder.rs b/compiler/crates/react_build_hir/src/builder.rs deleted file mode 100644 index 3deff7d2f77ef..0000000000000 --- a/compiler/crates/react_build_hir/src/builder.rs +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use std::cell::RefCell; -use std::rc::Rc; - -use react_diagnostics::Diagnostic; -use react_hir::{ - initialize_hir, BasicBlock, BlockId, BlockKind, Blocks, Environment, GotoKind, IdentifierData, - IdentifierOperand, InstrIx, Instruction, InstructionIdGenerator, InstructionValue, Terminal, - TerminalValue, Type, HIR, -}; - -use crate::BuildHIRError; - -/// Helper struct used when converting from ESTree to HIR. Includes: -/// - Variable resolution -/// - Label resolution (for labeled statements and break/continue) -/// - Access to the environment -/// -/// As well as representing the incomplete form of the HIR. Usage -/// generally involves driving calls to enter/exit blocks, resolve -/// labels and variables, and then calling `build()` when the HIR -/// is complete. -pub(crate) struct Builder<'e> { - #[allow(dead_code)] - environment: &'e Environment, - - completed: Blocks, - - instructions: Vec, - - entry: BlockId, - - wip: WipBlock, - - id_gen: InstructionIdGenerator, - - scopes: Vec, -} - -pub(crate) struct WipBlock { - pub id: BlockId, - pub kind: BlockKind, - pub instructions: Vec, -} - -#[derive(Clone, PartialEq, Eq, Debug)] -enum ControlFlowScope { - Loop(LoopScope), - - // Switch(SwitchScope), - #[allow(dead_code)] - Label(LabelScope), -} - -#[derive(Clone, PartialEq, Eq, Debug)] -pub(crate) struct LoopScope { - pub label: Option, - pub continue_block: BlockId, - pub break_block: BlockId, -} - -#[derive(Clone, PartialEq, Eq, Debug)] -pub(crate) struct LabelScope { - pub label: String, - pub block: BlockId, -} - -impl ControlFlowScope { - fn label(&self) -> Option<&String> { - match self { - Self::Loop(scope) => scope.label.as_ref(), - Self::Label(scope) => Some(&scope.label), - } - } - - fn break_block(&self) -> BlockId { - match self { - Self::Loop(scope) => scope.break_block, - Self::Label(scope) => scope.block, - } - } -} - -impl<'e> Builder<'e> { - pub(crate) fn new(environment: &'e Environment) -> Self { - let entry = environment.next_block_id(); - let current = WipBlock { - id: entry, - kind: BlockKind::Block, - instructions: Default::default(), - }; - Self { - environment, - completed: Default::default(), - instructions: Default::default(), - entry, - wip: current, - id_gen: InstructionIdGenerator::new(), - scopes: Default::default(), - } - } - - /// Completes the builder and returns the HIR if it was valid, - /// or a Diagnostic if a validation error occured. - /// - /// TODO: refine the type, only invariants should be possible here, - /// not other types of errors - pub(crate) fn build(self) -> Result { - let mut hir = HIR { - entry: self.entry, - blocks: self.completed, - instructions: self.instructions, - }; - // Run all the initialization passes - initialize_hir(&mut hir)?; - Ok(hir) - } - - /// Adds a new instruction to the end of the work in progress block - pub(crate) fn push(&mut self, value: InstructionValue) -> IdentifierOperand { - let lvalue = IdentifierOperand { - identifier: self.environment.new_temporary(), - effect: None, - }; - let instr = Instruction { - id: self.id_gen.next(), - lvalue: lvalue.clone(), - value, - }; - let ix = InstrIx::new(self.instructions.len() as u32); - self.instructions.push(instr); - self.wip.instructions.push(ix); - lvalue - } - - /// Terminates the work in progress block with the given terminal, and starts a new - /// work in progress block with the given kind - pub(crate) fn terminate(&mut self, terminal: TerminalValue, next_kind: BlockKind) { - let next_wip = WipBlock { - id: self.environment.next_block_id(), - kind: next_kind, - instructions: Default::default(), - }; - self.terminate_with_fallthrough(terminal, next_wip) - } - - pub(crate) fn terminate_with_fallthrough( - &mut self, - terminal: TerminalValue, - fallthrough: WipBlock, - ) { - let prev_wip = std::mem::replace(&mut self.wip, fallthrough); - self.completed.insert(Box::new(BasicBlock { - id: prev_wip.id, - kind: prev_wip.kind, - instructions: prev_wip.instructions, - terminal: Terminal { - id: self.id_gen.next(), - value: terminal, - }, - predecessors: Default::default(), - phis: Default::default(), - })); - } - - pub(crate) fn reserve(&mut self, kind: BlockKind) -> WipBlock { - WipBlock { - id: self.environment.next_block_id(), - kind, - instructions: Default::default(), - } - } - - pub(crate) fn enter(&mut self, kind: BlockKind, f: F) -> Result - where - F: FnOnce(&mut Self) -> Result, - { - let wip = self.reserve(kind); - let id = wip.id; - self.enter_reserved(wip, f)?; - Ok(id) - } - - fn enter_reserved(&mut self, wip: WipBlock, f: F) -> Result<(), Diagnostic> - where - F: FnOnce(&mut Self) -> Result, - { - let current = std::mem::replace(&mut self.wip, wip); - - let (result, terminal) = match f(self) { - Ok(terminal) => (Ok(()), terminal), - Err(error) => ( - Err(error), - // TODO: add a `Terminal::Error` variant - TerminalValue::Goto(react_hir::GotoTerminal { - block: current.id, - kind: GotoKind::Break, - }), - ), - }; - - let completed = std::mem::replace(&mut self.wip, current); - self.completed.insert(Box::new(BasicBlock { - id: completed.id, - kind: completed.kind, - instructions: completed.instructions, - terminal: Terminal { - id: self.id_gen.next(), - value: terminal, - }, - predecessors: Default::default(), - phis: Default::default(), - })); - result - } - - pub(crate) fn enter_loop( - &mut self, - scope: LoopScope, - f: F, - ) -> Result - where - F: FnOnce(&mut Self) -> Result, - { - self.scopes.push(ControlFlowScope::Loop(scope.clone())); - let terminal = f(self); - let last = self.scopes.pop().unwrap(); - assert_eq!(last, ControlFlowScope::Loop(scope)); - terminal - } - - /// Returns a new temporary identifier - /// This may be necessary for destructuring with default values. there - /// we synthesize a temporary identifier to store the possibly-missing value - /// into, and emit a later StoreLocal for the original identifier - #[allow(dead_code)] - pub(crate) fn make_temporary(&self) -> react_hir::Identifier { - react_hir::Identifier { - id: self.environment.next_identifier_id(), - name: None, - data: Rc::new(RefCell::new(IdentifierData { - mutable_range: Default::default(), - scope: None, - type_: Type::Var(self.environment.next_type_var_id()), - })), - } - } - - /// Resolves the target for the given break label (if present), or returns the default - /// break target given the current context. Returns a diagnostic if the label is - /// provided but cannot be resolved. - pub(crate) fn resolve_break( - &self, - label: Option<&react_estree::Identifier>, - ) -> Result { - for scope in self.scopes.iter().rev() { - match (label, scope.label()) { - // If this is an unlabeled break, return the most recent break target - (None, _) => return Ok(scope.break_block()), - // If the break is labeled and matches the current scope, return its break target - (Some(label), Some(scope_label)) if &label.name == scope_label => { - return Ok(scope.break_block()); - } - // Otherwise keep searching - _ => continue, - } - } - Err(Diagnostic::invalid_syntax( - BuildHIRError::UnresolvedBreakTarget, - None, - )) - } - - /// Resolves the target for the given continue label (if present), or returns the default - /// continue target given the current context. Returns a diagnostic if the label is - /// provided but cannot be resolved. - pub(crate) fn resolve_continue( - &self, - label: Option<&react_estree::Identifier>, - ) -> Result { - for scope in self.scopes.iter().rev() { - match scope { - ControlFlowScope::Loop(scope) => { - match (label, &scope.label) { - // If this is an unlabeled continue, return the first matching loop - (None, _) => return Ok(scope.continue_block), - // If the continue is labeled and matches the current scope, return its continue target - (Some(label), Some(scope_label)) - if label.name.as_str() == scope_label.as_str() => - { - return Ok(scope.continue_block); - } - // Otherwise keep searching - _ => continue, - } - } - _ => { - match (label, scope.label()) { - (Some(label), Some(scope_label)) if label.name.as_str() == scope_label => { - // Error, the continue referred to a label that is not a loop - return Err(Diagnostic::invalid_syntax( - BuildHIRError::ContinueTargetIsNotALoop, - None, - )); - } - _ => continue, - } - } - } - } - Err(Diagnostic::invalid_syntax( - BuildHIRError::UnresolvedContinueTarget, - None, - )) - } -} diff --git a/compiler/crates/react_build_hir/src/context.rs b/compiler/crates/react_build_hir/src/context.rs deleted file mode 100644 index 76f7a38789b09..0000000000000 --- a/compiler/crates/react_build_hir/src/context.rs +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use std::collections::HashSet; - -use react_estree::IntoFunction; -use react_hir::Environment; -use react_semantic_analysis::{DeclarationId, ScopeView}; - -pub(crate) fn get_context_identifiers( - env: &Environment, - node: &T, -) -> Vec { - let function_scope = env.scope(node.function()).unwrap(); - let mut free = FreeVariables::default(); - let mut seen = HashSet::new(); - populate_free_variable_references(&mut free, &mut seen, function_scope); - free -} - -type FreeVariables = Vec; - -fn populate_free_variable_references( - free: &mut FreeVariables, - seen: &mut HashSet, - scope: ScopeView<'_>, -) { - for reference in scope.references() { - if !seen.insert(reference.declaration().id()) { - continue; - } - let declaration_scope = reference.declaration().scope(); - if !declaration_scope.is_descendant_of(scope) { - free.push(reference.declaration().id()) - } - } - for child in scope.children() { - populate_free_variable_references(free, seen, child); - } -} diff --git a/compiler/crates/react_build_hir/src/error.rs b/compiler/crates/react_build_hir/src/error.rs deleted file mode 100644 index 0235c2f90e9ab..0000000000000 --- a/compiler/crates/react_build_hir/src/error.rs +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use thiserror::Error; - -/// Errors which can occur during HIR construction -#[derive(Error, Debug)] -pub enum BuildHIRError { - /// ErrorSeverity::Unsupported - #[error( - "Variable declarations must be `let` or `const`, `var` declarations are not supported" - )] - VariableDeclarationKindIsVar, - - /// ErrorSeverity::Invariant - #[error("Invariant: Expected variable declaration to declare a fresh binding")] - VariableDeclarationBindingIsNonLocal, - - /// ErrorSeverity::Todo - #[error("`for` statements must have an initializer, eg `for (**let i = 0**; ...)`")] - ForStatementIsMissingInitializer, - - /// ErrorSeverity::Todo - #[error( - "`for` statements must have a test condition, eg `for (let i = 0; **i < count**; ...)`" - )] - ForStatementIsMissingTest, - - /// ErrorSeverity::Invariant - #[error("Invariant: Expected an expression node")] - NonExpressionInExpressionPosition, - - /// ErrorSeverity::InvalidReact - #[error("React functions may not reassign variables defined outside of the component or hook")] - ReassignedGlobal, - - /// ErrorSeverity::InvalidSyntax - #[error("Could not resolve a target for `break` statement")] - UnresolvedBreakTarget, - - /// ErrorSeverity::InvalidSyntax - #[error("Could not resolve a target for `continue` statement")] - UnresolvedContinueTarget, - - /// ErrorSeverity::InvalidSyntax - #[error("Labeled `continue` statements must use the label of a loop statement")] - ContinueTargetIsNotALoop, - - /// ErrorSeverity::Invariant - #[error("Invariant: Identifier was not resolved (did name resolution run successfully?)")] - UnknownIdentifier, - - /// ErrorSeverity::InvalidSyntax - #[error("Expected function to have a body")] - EmptyFunction, - - #[error("`super` is not suppported")] - UnsupportedSuperExpression, -} diff --git a/compiler/crates/react_build_hir/src/lib.rs b/compiler/crates/react_build_hir/src/lib.rs deleted file mode 100644 index 0f8e6196ffd7d..0000000000000 --- a/compiler/crates/react_build_hir/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -mod build; -mod builder; -mod context; -mod error; - -pub use build::build; -pub use error::*; diff --git a/compiler/crates/react_diagnostics/Cargo.toml b/compiler/crates/react_diagnostics/Cargo.toml deleted file mode 100644 index 3d09c98b797c9..0000000000000 --- a/compiler/crates/react_diagnostics/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "react_diagnostics" -version = "0.1.0" -publish = false -authors.workspace = true -description.workspace = true -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# TODO: extract SourceRange into a separate crate so that -# we don't depend on full estree here -react_estree = { workspace = true } -# TODO: consider extracting a separate react_miette crate which does -# the translation from react_diagnostics::Diagnostic to miette::Diagnostic -miette = { workspace = true } -thiserror = { workspace = true } -static_assertions = { workspace = true } \ No newline at end of file diff --git a/compiler/crates/react_diagnostics/README.md b/compiler/crates/react_diagnostics/README.md deleted file mode 100644 index 121301fd4cc92..0000000000000 --- a/compiler/crates/react_diagnostics/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# react_diagnostics - -Types for representing compiler diagnostics. Includes a general-purpose representation -of diagnostics with related information which can be converted into `miette::Diagnostic` to exploit miette's pretty printing of errors. - -Unlike miette, lsp_types, and other diagnostic libraries, the error severities match -React Compiler's semantics. The intent is that a given diagnostic may be displayed as -an error, warning, or not displayed at all depending on the context in which the -compiler is being used. For example, an ESLint plugin powered by React Compiler may ignore -InvalidSyntax diagnostics, whereas the regular compiler may report them as errors. diff --git a/compiler/crates/react_diagnostics/src/diagnostic.rs b/compiler/crates/react_diagnostics/src/diagnostic.rs deleted file mode 100644 index 8816b62170713..0000000000000 --- a/compiler/crates/react_diagnostics/src/diagnostic.rs +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use std::error::Error; -use std::fmt::{Debug, Display, Write}; - -use miette::SourceSpan; -use react_estree::SourceRange; -use static_assertions::assert_impl_all; -use thiserror::Error; - -pub type Diagnostics = Vec; -pub type DiagnosticsResult = Result; - -#[derive(Debug)] -pub struct WithDiagnostics { - pub item: T, - pub diagnostics: Vec, -} - -impl From> for Result { - fn from(s: WithDiagnostics) -> Result { - if s.diagnostics.is_empty() { - Ok(s.item) - } else { - Err(s.diagnostics) - } - } -} - -pub fn diagnostics_result(result: T, diagnostics: Diagnostics) -> DiagnosticsResult { - if diagnostics.is_empty() { - Ok(result) - } else { - Err(diagnostics) - } -} - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Error)] -pub enum DiagnosticSeverity { - /// A feature that is intended to work but not yet implemented - #[error("Not implemented")] - Todo, - - /// Syntax that is valid but intentionally not supported - #[error("Unsupported")] - Unsupported, - - /// Invalid syntax - #[error("Invalid JavaScript")] - InvalidSyntax, - - /// Valid syntax, but invalid React - #[error("Invalid React")] - InvalidReact, - - /// Internal compiler error (ICE) - #[error("Internal error")] - Invariant, -} - -/// A diagnostic message as a result of validating some code. This struct is -/// modeled after the LSP Diagnostic type: -/// https://microsoft.github.io/language-server-protocol/specification#diagnostic -/// -/// Changes from LSP: -/// - `location` is different from LSP in that it's a file + span instead of -/// just a span. -/// - Unused fields are omitted. -/// - Severity is a custom enum that represents React-specific categories of error. -/// The translation to an LSP error/warning/etc depends on compiler settings and -/// invocation context. -#[derive(Debug)] -pub struct Diagnostic(Box); - -impl Diagnostic { - fn with_severity( - severity: DiagnosticSeverity, - message: T, - range: Option, - ) -> Self { - Self(Box::new(DiagnosticData { - message: Box::new(message), - span: range.map(source_span_from_range), - related_information: Vec::new(), - severity, - data: Vec::new(), - })) - } - - /// Creates a new Todo Diagnostic. - /// Additional locations can be added with the `.annotate()` function. - pub fn todo(message: T, range: Option) -> Self { - Diagnostic::with_severity(DiagnosticSeverity::Todo, message, range) - } - - /// Creates a new Unsupported Diagnostic. - /// Additional locations can be added with the `.annotate()` function. - pub fn unsupported( - message: T, - range: Option, - ) -> Self { - Diagnostic::with_severity(DiagnosticSeverity::Unsupported, message, range) - } - - /// Creates a new InvalidSyntax Diagnostic. - /// Additional locations can be added with the `.annotate()` function. - pub fn invalid_syntax( - message: T, - range: Option, - ) -> Self { - Diagnostic::with_severity(DiagnosticSeverity::InvalidSyntax, message, range) - } - - /// Creates a new InvalidReact Diagnostic. - /// Additional locations can be added with the `.annotate()` function. - pub fn invalid_react( - message: T, - range: Option, - ) -> Self { - Diagnostic::with_severity(DiagnosticSeverity::InvalidReact, message, range) - } - - /// Creates a new InvalidReact Diagnostic. - /// Additional locations can be added with the `.annotate()` function. - pub fn invariant( - message: T, - range: Option, - ) -> Self { - Diagnostic::with_severity(DiagnosticSeverity::Invariant, message, range) - } - - /// Annotates this error with an additional location and associated message. - pub fn annotate( - mut self, - message: T, - range: Option, - ) -> Self { - self.0 - .related_information - .push(DiagnosticRelatedInformation { - message: Box::new(message), - span: range.map(source_span_from_range), - }); - self - } - - pub fn message(&self) -> &impl DiagnosticDisplay { - &self.0.message - } - - pub fn span(&self) -> Option { - self.0.span - } - - pub fn get_data(&self) -> &[impl DiagnosticDisplay] { - &self.0.data - } - - pub fn severity(&self) -> DiagnosticSeverity { - self.0.severity - } - - pub fn related_information(&self) -> &[DiagnosticRelatedInformation] { - &self.0.related_information - } - - pub fn print_without_source(&self) -> String { - let mut result = String::new(); - writeln!( - result, - "{message}:{span:?}", - message = &self.0.message, - span = self.0.span - ) - .unwrap(); - if !self.0.related_information.is_empty() { - for (ix, related) in self.0.related_information.iter().enumerate() { - writeln!( - result, - "[related {ix}] {message}:{span:?}", - ix = ix + 1, - message = related.message, - span = related.span - ) - .unwrap(); - } - }; - result - } -} - -impl Display for Diagnostic { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.0.message) - } -} - -impl Error for Diagnostic {} - -impl miette::Diagnostic for Diagnostic { - fn help<'a>(&'a self) -> Option> { - Some(Box::new(self.0.message.to_string())) - } - - fn labels(&self) -> Option + '_>> { - let related_items = &self.0.related_information; - let mut spans: Vec = Vec::new(); - for related in related_items { - if let Some(span) = related.span { - spans.push(miette::LabeledSpan::new_with_span( - Some(related.message.to_string()), - span, - )) - } - } - if spans.is_empty() { - if let Some(span) = self.0.span { - spans.push(miette::LabeledSpan::new_with_span( - Some(self.0.message.to_string()), - span, - )) - } - } - Some(Box::new(spans.into_iter())) - } -} - -// Ensure Diagnostic is thread-safe -assert_impl_all!(Diagnostic: Send, Sync); - -#[derive(Debug)] -struct DiagnosticData { - /// Human readable error message. - message: Box, - - /// The primary location of this diagnostic. - span: Option, - - /// Related diagnostic information, such as other definitions in the case of - /// a duplicate definition error. - related_information: Vec, - - severity: DiagnosticSeverity, - - /// A list with data that can be passed to the code actions - /// `data` is used in the LSP protocol: - /// @see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#diagnostic - data: Vec>, -} - -/// Secondary locations attached to a diagnostic. -#[derive(Debug)] -pub struct DiagnosticRelatedInformation { - /// The message of this related diagnostic information. - pub message: Box, - - /// The location of this related diagnostic information. - pub span: Option, -} - -/// Trait for diagnostic messages to allow structs that capture -/// some data and can lazily convert it to a message. -pub trait DiagnosticDisplay: Debug + Display + Send + Sync {} - -/// Automatically implement the trait if constraints are met, so that -/// implementors don't need to. -impl DiagnosticDisplay for T where T: Debug + Display + Send + Sync {} - -impl From for Diagnostics { - fn from(diagnostic: Diagnostic) -> Self { - vec![diagnostic] - } -} - -fn source_span_from_range(range: SourceRange) -> SourceSpan { - SourceSpan::new( - (range.start as usize).into(), - ((u32::from(range.end) - range.start) as usize).into(), - ) -} diff --git a/compiler/crates/react_diagnostics/src/lib.rs b/compiler/crates/react_diagnostics/src/lib.rs deleted file mode 100644 index 1ce36f9095522..0000000000000 --- a/compiler/crates/react_diagnostics/src/lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -mod diagnostic; - -pub use diagnostic::*; - -/// Returns Ok(()) if the condition is true, otherwise returns Err() -/// with the diagnostic produced by the provided callback -pub fn invariant(cond: bool, f: F) -> Result<(), Diagnostic> -where - F: Fn() -> Diagnostic, -{ - if cond { Ok(()) } else { Err(f()) } -} diff --git a/compiler/crates/react_estree/Cargo.toml b/compiler/crates/react_estree/Cargo.toml deleted file mode 100644 index ef9598ab06e59..0000000000000 --- a/compiler/crates/react_estree/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "react_estree" -version = "0.1.0" -publish = false -authors.workspace = true -description.workspace = true -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -insta = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -static_assertions = { workspace = true } - -[build-dependencies] -react_estree_codegen = { workspace = true } \ No newline at end of file diff --git a/compiler/crates/react_estree/README.md b/compiler/crates/react_estree/README.md deleted file mode 100644 index ec37705b9d16c..0000000000000 --- a/compiler/crates/react_estree/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# react_estree - -This crate is a Rust representation of the [ESTree format](https://github.com/estree/estree/tree/master) and -popular extenions including JSX and (eventually) Flow and TypeScript. - -This crate is intended as the main interchange format with outside code. A typical integration with React Compiler -will look as follows: - -1. Host Compiler parses into the host AST format. -2. Host Compiler converts into `react_estree`. -3. Host Compiler invokes React Compiler to compile the input, which (conceptually) - returns the resulting code in `react_estree` format. -4. Host Compiler convert back from `react_estree` to its host AST format. - -Because React Compiler is intended to support JavaScript-based toolchains, `react_estree` is designed to support -accurate serialization to/from estree-compatible JSON. We may also support the Babel AST format -(a variant of ESTree) as well, depending on demand. \ No newline at end of file diff --git a/compiler/crates/react_estree/build.rs b/compiler/crates/react_estree/build.rs deleted file mode 100644 index f9687df6ad386..0000000000000 --- a/compiler/crates/react_estree/build.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use react_estree_codegen::estree; - -// Example custom build script. -fn main() { - // Re-run if the codegen files change - println!("cargo:rerun-if-changed=../react_estree_codegen/src/codegen.rs"); - println!("cargo:rerun-if-changed=../react_estree_codegen/src/lib.rs"); - println!("cargo:rerun-if-changed=../react_estree_codegen/src/ecmascript.json"); - println!("cargo:rerun-if-changed=../react_estree_codegen"); - - let src = estree(); - let copyright = " -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - " - .to_string(); - let trimmed_copyright = copyright.trim(); - let contents = format!("{trimmed_copyright}\n{src}"); - std::fs::write("src/generated.rs", contents).unwrap(); -} diff --git a/compiler/crates/react_estree/src/binding.rs b/compiler/crates/react_estree/src/binding.rs deleted file mode 100644 index 20a791c15742c..0000000000000 --- a/compiler/crates/react_estree/src/binding.rs +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq, Hash)] -pub enum Binding { - Global, - Module(BindingId), - Local(BindingId), -} - -#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq, Hash)] -pub struct BindingId(u32); - -impl BindingId { - pub fn new(value: u32) -> Self { - Self(value) - } -} - -impl From for u32 { - fn from(value: BindingId) -> Self { - value.0 - } -} diff --git a/compiler/crates/react_estree/src/fixtures/for-statement.json b/compiler/crates/react_estree/src/fixtures/for-statement.json deleted file mode 100644 index e45691e530094..0000000000000 --- a/compiler/crates/react_estree/src/fixtures/for-statement.json +++ /dev/null @@ -1,528 +0,0 @@ -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "name": "Component", - "typeAnnotation": null, - "optional": false, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "name": "props", - "typeAnnotation": null, - "optional": false, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "body": [ - { - "type": "VariableDeclaration", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "init": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "value": 0, - "range": [ - 38, - 39 - ], - "raw": "0" - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 7 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 34, - 35 - ] - }, - "range": [ - 34, - 39 - ] - } - ], - "range": [ - 30, - 40 - ] - }, - { - "type": "ForStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "init": { - "type": "VariableDeclaration", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 7 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "init": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "value": 0, - "range": [ - 56, - 57 - ], - "raw": "0" - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 12 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 52, - 53 - ] - }, - "range": [ - 52, - 57 - ] - } - ], - "range": [ - 48, - 57 - ] - }, - "test": { - "type": "BinaryExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "left": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 59, - 60 - ] - }, - "right": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 22 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "value": 10, - "range": [ - 63, - 65 - ], - "raw": "10" - }, - "operator": "<", - "range": [ - 59, - 65 - ] - }, - "update": { - "type": "UpdateExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "operator": "++", - "argument": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 27 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 67, - 68 - ] - }, - "prefix": false, - "range": [ - 67, - 70 - ] - }, - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 31 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "body": [ - { - "type": "ExpressionStatement", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 11 - } - }, - "expression": { - "type": "AssignmentExpression", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "operator": "+=", - "left": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 78, - 79 - ] - }, - "right": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 83, - 84 - ] - }, - "range": [ - 78, - 84 - ] - }, - "directive": null, - "range": [ - 78, - 85 - ] - } - ], - "range": [ - 72, - 89 - ] - }, - "range": [ - 43, - 89 - ] - }, - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 6, - "column": 2 - }, - "end": { - "line": 6, - "column": 11 - } - }, - "argument": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 10 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 99, - 100 - ] - }, - "range": [ - 92, - 101 - ] - } - ], - "range": [ - 26, - 103 - ] - }, - "typeParameters": null, - "returnType": null, - "predicate": null, - "generator": false, - "async": false, - "range": [ - 0, - 103 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 0, - 103 - ], - "sourceType": "script" - } \ No newline at end of file diff --git a/compiler/crates/react_estree/src/fixtures/import.json b/compiler/crates/react_estree/src/fixtures/import.json deleted file mode 100644 index 78997e87bd8b0..0000000000000 --- a/compiler/crates/react_estree/src/fixtures/import.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "body": [ - { - "type": "ImportDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "local": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "name": "React", - "typeAnnotation": null, - "optional": false, - "range": [ - 7, - 12 - ] - }, - "range": [ - 7, - 12 - ] - } - ], - "source": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 25 - } - }, - "value": "react", - "range": [ - 18, - 25 - ], - "raw": "'react'" - }, - "attributes": [], - "importKind": "value", - "range": [ - 0, - 26 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 0, - 26 - ], - "sourceType": "module" - } \ No newline at end of file diff --git a/compiler/crates/react_estree/src/fixtures/simple.json b/compiler/crates/react_estree/src/fixtures/simple.json deleted file mode 100644 index 4a1de32d5de24..0000000000000 --- a/compiler/crates/react_estree/src/fixtures/simple.json +++ /dev/null @@ -1,189 +0,0 @@ -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ], - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ], - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "range": [ - 9, - 18 - ], - "name": "Component", - "typeAnnotation": null, - "optional": false - }, - "params": [ - { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "range": [ - 19, - 24 - ], - "name": "props", - "typeAnnotation": null, - "optional": false - } - ], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 26, - 51 - ], - "body": [ - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 21 - } - }, - "range": [ - 30, - 49 - ], - "argument": { - "type": "MemberExpression", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 37, - 48 - ], - "object": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 14 - } - }, - "range": [ - 37, - 42 - ], - "name": "props", - "typeAnnotation": null, - "optional": false - }, - "property": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 43, - 48 - ], - "name": "value", - "typeAnnotation": null, - "optional": false - }, - "computed": false - } - } - ] - }, - "async": false, - "generator": false, - "predicate": null, - "expression": false, - "returnType": null, - "typeParameters": null - } - ], - "comments": [], - "errors": [] - } \ No newline at end of file diff --git a/compiler/crates/react_estree/src/fixtures/test.json b/compiler/crates/react_estree/src/fixtures/test.json deleted file mode 100644 index 8804bc20d9d9a..0000000000000 --- a/compiler/crates/react_estree/src/fixtures/test.json +++ /dev/null @@ -1,351 +0,0 @@ -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "name": "foo", - "typeAnnotation": null, - "optional": false, - "range": [ - 10, - 13 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "body": [ - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "argument": { - "type": "JSXElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "openingElement": { - "type": "JSXOpeningElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 26 - } - }, - "name": { - "type": "JSXMemberExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "object": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "name": "Foo", - "range": [ - 28, - 31 - ] - }, - "property": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 14 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "name": "Bar", - "range": [ - 32, - 35 - ] - }, - "range": [ - 28, - 35 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "name": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "name": "a", - "range": [ - 36, - 37 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "expression": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 21 - }, - "end": { - "line": 3, - "column": 23 - } - }, - "value": 10, - "range": [ - 39, - 41 - ], - "raw": "10" - }, - "range": [ - 38, - 42 - ] - }, - "range": [ - 36, - 42 - ] - } - ], - "selfClosing": false, - "range": [ - 27, - 44 - ] - }, - "children": [], - "closingElement": { - "type": "JSXClosingElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "name": { - "type": "JSXMemberExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "object": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 31 - } - }, - "name": "Foo", - "range": [ - 46, - 49 - ] - }, - "property": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "name": "Bar", - "range": [ - 50, - 53 - ] - }, - "range": [ - 46, - 53 - ] - }, - "range": [ - 44, - 54 - ] - }, - "range": [ - 27, - 54 - ] - }, - "range": [ - 20, - 54 - ] - } - ], - "range": [ - 16, - 56 - ] - }, - "typeParameters": null, - "returnType": null, - "predicate": null, - "generator": false, - "async": false, - "range": [ - 1, - 56 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 1, - 56 - ], - "sourceType": "script" - } \ No newline at end of file diff --git a/compiler/crates/react_estree/src/generated.rs b/compiler/crates/react_estree/src/generated.rs deleted file mode 100644 index 1b9bacfea9443..0000000000000 --- a/compiler/crates/react_estree/src/generated.rs +++ /dev/null @@ -1,9031 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -// @generated -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(dead_code)] -#![allow(unused_variables)] -#![allow(non_snake_case)] -#![allow(clippy::enum_variant_names)] -use std::num::NonZeroU32; -use serde::ser::{Serializer, SerializeMap}; -use serde::{Serialize, Deserialize}; -use crate::{JsValue, Binding, SourceRange, Number, ESTreeNode}; -#[derive(Serialize, Deserialize, Clone, Debug)] -#[serde(deny_unknown_fields)] -pub struct SourceLocation { - pub source: Option, - pub start: Position, - pub end: Position, -} -#[derive(Serialize, Deserialize, Clone, Debug)] -#[serde(deny_unknown_fields)] -pub struct Position { - pub line: NonZeroU32, - pub column: u32, -} -#[derive(Serialize, Deserialize, Clone, Debug)] -#[serde(deny_unknown_fields)] -pub struct Class { - pub id: Option, - #[serde(rename = "superClass")] - pub super_class: Option, - pub body: ClassBody, -} -#[derive(Serialize, Deserialize, Clone, Debug)] -#[serde(deny_unknown_fields)] -pub struct Function { - pub id: Option, - pub params: Vec, - pub body: Option, - #[serde(rename = "generator")] - #[serde(default)] - pub is_generator: bool, - #[serde(rename = "async")] - #[serde(default)] - pub is_async: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -#[derive(Serialize, Deserialize, Clone, Debug)] -#[serde(deny_unknown_fields)] -pub struct RegExpValue { - pub pattern: String, - pub flags: String, -} -#[derive(Serialize, Deserialize, Clone, Debug)] -#[serde(deny_unknown_fields)] -pub struct TemplateElementValue { - pub cooked: Option, - pub raw: String, -} -#[derive(Deserialize, Clone, Debug)] -pub struct Identifier { - pub name: String, - #[serde(skip)] - #[serde(default)] - pub binding: Option, - #[serde(rename = "typeAnnotation")] - #[serde(default)] - pub type_annotation: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for Identifier {} -impl Serialize for Identifier { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "Identifier")?; - state.serialize_entry("name", &self.name)?; - state.serialize_entry("typeAnnotation", &self.type_annotation)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct Literal { - pub value: JsValue, - #[serde(default)] - pub raw: Option, - #[serde(default)] - pub regex: Option, - #[serde(default)] - pub bigint: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for Literal {} -impl Serialize for Literal { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "Literal")?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("raw", &self.raw)?; - state.serialize_entry("regex", &self.regex)?; - state.serialize_entry("bigint", &self.bigint)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct NumericLiteral { - pub value: Number, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for NumericLiteral {} -impl Serialize for NumericLiteral { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "NumericLiteral")?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct BooleanLiteral { - pub value: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for BooleanLiteral {} -impl Serialize for BooleanLiteral { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "BooleanLiteral")?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct NullLiteral { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for NullLiteral {} -impl Serialize for NullLiteral { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "NullLiteral")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct StringLiteral { - pub value: String, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for StringLiteral {} -impl Serialize for StringLiteral { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "StringLiteral")?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct RegExpLiteral { - pub pattern: String, - pub flags: String, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for RegExpLiteral {} -impl Serialize for RegExpLiteral { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "RegExpLiteral")?; - state.serialize_entry("pattern", &self.pattern)?; - state.serialize_entry("flags", &self.flags)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct Program { - pub body: Vec, - #[serde(rename = "sourceType")] - #[serde(default)] - pub source_type: SourceType, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for Program {} -impl Serialize for Program { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "Program")?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("sourceType", &self.source_type)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ExpressionStatement { - pub expression: Expression, - #[serde(default)] - pub directive: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ExpressionStatement {} -impl Serialize for ExpressionStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ExpressionStatement")?; - state.serialize_entry("expression", &self.expression)?; - state.serialize_entry("directive", &self.directive)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct BlockStatement { - pub body: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for BlockStatement {} -impl Serialize for BlockStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "BlockStatement")?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct EmptyStatement { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for EmptyStatement {} -impl Serialize for EmptyStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "EmptyStatement")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct DebuggerStatement { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for DebuggerStatement {} -impl Serialize for DebuggerStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "DebuggerStatement")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct WithStatement { - pub object: Expression, - pub body: Statement, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for WithStatement {} -impl Serialize for WithStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "WithStatement")?; - state.serialize_entry("object", &self.object)?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ReturnStatement { - pub argument: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ReturnStatement {} -impl Serialize for ReturnStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ReturnStatement")?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct LabeledStatement { - pub label: Identifier, - pub body: Statement, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for LabeledStatement {} -impl Serialize for LabeledStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "LabeledStatement")?; - state.serialize_entry("label", &self.label)?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct BreakStatement { - pub label: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for BreakStatement {} -impl Serialize for BreakStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "BreakStatement")?; - state.serialize_entry("label", &self.label)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ContinueStatement { - pub label: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ContinueStatement {} -impl Serialize for ContinueStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ContinueStatement")?; - state.serialize_entry("label", &self.label)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct IfStatement { - pub test: Expression, - pub consequent: Statement, - pub alternate: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for IfStatement {} -impl Serialize for IfStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "IfStatement")?; - state.serialize_entry("test", &self.test)?; - state.serialize_entry("consequent", &self.consequent)?; - state.serialize_entry("alternate", &self.alternate)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct SwitchStatement { - pub discriminant: Expression, - pub cases: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for SwitchStatement {} -impl Serialize for SwitchStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "SwitchStatement")?; - state.serialize_entry("discriminant", &self.discriminant)?; - state.serialize_entry("cases", &self.cases)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct SwitchCase { - pub test: Option, - pub consequent: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for SwitchCase {} -impl Serialize for SwitchCase { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "SwitchCase")?; - state.serialize_entry("test", &self.test)?; - state.serialize_entry("consequent", &self.consequent)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ThrowStatement { - pub argument: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ThrowStatement {} -impl Serialize for ThrowStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ThrowStatement")?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct TryStatement { - pub block: BlockStatement, - pub handler: Option, - pub finalizer: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for TryStatement {} -impl Serialize for TryStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "TryStatement")?; - state.serialize_entry("block", &self.block)?; - state.serialize_entry("handler", &self.handler)?; - state.serialize_entry("finalizer", &self.finalizer)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct CatchClause { - pub param: Option, - pub body: BlockStatement, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for CatchClause {} -impl Serialize for CatchClause { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "CatchClause")?; - state.serialize_entry("param", &self.param)?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct WhileStatement { - pub test: Expression, - pub body: Statement, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for WhileStatement {} -impl Serialize for WhileStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "WhileStatement")?; - state.serialize_entry("test", &self.test)?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct DoWhileStatement { - pub body: Statement, - pub test: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for DoWhileStatement {} -impl Serialize for DoWhileStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "DoWhileStatement")?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("test", &self.test)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ForStatement { - pub init: Option, - pub test: Option, - pub update: Option, - pub body: Statement, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ForStatement {} -impl Serialize for ForStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ForStatement")?; - state.serialize_entry("init", &self.init)?; - state.serialize_entry("test", &self.test)?; - state.serialize_entry("update", &self.update)?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ForInStatement { - pub left: ForInInit, - pub right: Expression, - pub body: Statement, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ForInStatement {} -impl Serialize for ForInStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ForInStatement")?; - state.serialize_entry("left", &self.left)?; - state.serialize_entry("right", &self.right)?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ForOfStatement { - #[serde(rename = "await")] - #[serde(default)] - pub is_await: bool, - pub left: ForInInit, - pub right: Expression, - pub body: Statement, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ForOfStatement {} -impl Serialize for ForOfStatement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ForOfStatement")?; - state.serialize_entry("await", &self.is_await)?; - state.serialize_entry("left", &self.left)?; - state.serialize_entry("right", &self.right)?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct FunctionDeclaration { - #[serde(flatten)] - pub function: Function, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for FunctionDeclaration {} -impl Serialize for FunctionDeclaration { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "FunctionDeclaration")?; - Serialize::serialize( - &self.function, - serde::__private::ser::FlatMapSerializer(&mut state), - )?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ClassDeclaration { - #[serde(flatten)] - pub class: Class, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ClassDeclaration {} -impl Serialize for ClassDeclaration { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ClassDeclaration")?; - Serialize::serialize( - &self.class, - serde::__private::ser::FlatMapSerializer(&mut state), - )?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ClassExpression { - #[serde(flatten)] - pub class: Class, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ClassExpression {} -impl Serialize for ClassExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ClassExpression")?; - Serialize::serialize( - &self.class, - serde::__private::ser::FlatMapSerializer(&mut state), - )?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ClassBody { - pub body: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ClassBody {} -impl Serialize for ClassBody { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ClassBody")?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct MethodDefinition { - pub key: Expression, - pub value: FunctionExpression, - pub kind: MethodKind, - #[serde(rename = "computed")] - pub is_computed: bool, - #[serde(rename = "static")] - pub is_static: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for MethodDefinition {} -impl Serialize for MethodDefinition { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "MethodDefinition")?; - state.serialize_entry("key", &self.key)?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("kind", &self.kind)?; - state.serialize_entry("computed", &self.is_computed)?; - state.serialize_entry("static", &self.is_static)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct VariableDeclaration { - pub kind: VariableDeclarationKind, - pub declarations: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for VariableDeclaration {} -impl Serialize for VariableDeclaration { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "VariableDeclaration")?; - state.serialize_entry("kind", &self.kind)?; - state.serialize_entry("declarations", &self.declarations)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct VariableDeclarator { - pub id: Pattern, - pub init: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for VariableDeclarator {} -impl Serialize for VariableDeclarator { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "VariableDeclarator")?; - state.serialize_entry("id", &self.id)?; - state.serialize_entry("init", &self.init)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ThisExpression { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ThisExpression {} -impl Serialize for ThisExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ThisExpression")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ArrayExpression { - pub elements: Vec>, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ArrayExpression {} -impl Serialize for ArrayExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ArrayExpression")?; - state.serialize_entry("elements", &self.elements)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ObjectExpression { - pub properties: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ObjectExpression {} -impl Serialize for ObjectExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ObjectExpression")?; - state.serialize_entry("properties", &self.properties)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct Property { - pub key: Expression, - pub value: Expression, - pub kind: PropertyKind, - #[serde(rename = "method")] - pub is_method: bool, - #[serde(rename = "shorthand")] - pub is_shorthand: bool, - #[serde(rename = "computed")] - pub is_computed: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for Property {} -impl Serialize for Property { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "Property")?; - state.serialize_entry("key", &self.key)?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("kind", &self.kind)?; - state.serialize_entry("method", &self.is_method)?; - state.serialize_entry("shorthand", &self.is_shorthand)?; - state.serialize_entry("computed", &self.is_computed)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct FunctionExpression { - #[serde(flatten)] - pub function: Function, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for FunctionExpression {} -impl Serialize for FunctionExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "FunctionExpression")?; - Serialize::serialize( - &self.function, - serde::__private::ser::FlatMapSerializer(&mut state), - )?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ArrowFunctionExpression { - #[serde(flatten)] - pub function: Function, - #[serde(rename = "expression")] - pub is_expression: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ArrowFunctionExpression {} -impl Serialize for ArrowFunctionExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ArrowFunctionExpression")?; - Serialize::serialize( - &self.function, - serde::__private::ser::FlatMapSerializer(&mut state), - )?; - state.serialize_entry("expression", &self.is_expression)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct UnaryExpression { - pub operator: UnaryOperator, - pub prefix: bool, - pub argument: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for UnaryExpression {} -impl Serialize for UnaryExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "UnaryExpression")?; - state.serialize_entry("operator", &self.operator)?; - state.serialize_entry("prefix", &self.prefix)?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct UpdateExpression { - pub operator: UpdateOperator, - pub argument: Expression, - pub prefix: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for UpdateExpression {} -impl Serialize for UpdateExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "UpdateExpression")?; - state.serialize_entry("operator", &self.operator)?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("prefix", &self.prefix)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct BinaryExpression { - pub left: Expression, - pub operator: BinaryOperator, - pub right: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for BinaryExpression {} -impl Serialize for BinaryExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "BinaryExpression")?; - state.serialize_entry("left", &self.left)?; - state.serialize_entry("operator", &self.operator)?; - state.serialize_entry("right", &self.right)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct AssignmentExpression { - pub operator: AssignmentOperator, - pub left: AssignmentTarget, - pub right: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for AssignmentExpression {} -impl Serialize for AssignmentExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "AssignmentExpression")?; - state.serialize_entry("operator", &self.operator)?; - state.serialize_entry("left", &self.left)?; - state.serialize_entry("right", &self.right)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct LogicalExpression { - pub operator: LogicalOperator, - pub left: Expression, - pub right: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for LogicalExpression {} -impl Serialize for LogicalExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "LogicalExpression")?; - state.serialize_entry("operator", &self.operator)?; - state.serialize_entry("left", &self.left)?; - state.serialize_entry("right", &self.right)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct MemberExpression { - pub object: ExpressionOrSuper, - pub property: ExpressionOrPrivateIdentifier, - #[serde(rename = "computed")] - pub is_computed: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for MemberExpression {} -impl Serialize for MemberExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "MemberExpression")?; - state.serialize_entry("object", &self.object)?; - state.serialize_entry("property", &self.property)?; - state.serialize_entry("computed", &self.is_computed)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ConditionalExpression { - pub test: Expression, - pub alternate: Expression, - pub consequent: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ConditionalExpression {} -impl Serialize for ConditionalExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ConditionalExpression")?; - state.serialize_entry("test", &self.test)?; - state.serialize_entry("alternate", &self.alternate)?; - state.serialize_entry("consequent", &self.consequent)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct CallExpression { - pub callee: ExpressionOrSuper, - pub arguments: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for CallExpression {} -impl Serialize for CallExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "CallExpression")?; - state.serialize_entry("callee", &self.callee)?; - state.serialize_entry("arguments", &self.arguments)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct NewExpression { - pub callee: Expression, - pub arguments: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for NewExpression {} -impl Serialize for NewExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "NewExpression")?; - state.serialize_entry("callee", &self.callee)?; - state.serialize_entry("arguments", &self.arguments)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct SequenceExpression { - pub expressions: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for SequenceExpression {} -impl Serialize for SequenceExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "SequenceExpression")?; - state.serialize_entry("expressions", &self.expressions)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct Super { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for Super {} -impl Serialize for Super { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "Super")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct SpreadElement { - pub argument: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for SpreadElement {} -impl Serialize for SpreadElement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "SpreadElement")?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct YieldExpression { - #[serde(default)] - pub argument: Option, - #[serde(rename = "delegate")] - pub is_delegate: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for YieldExpression {} -impl Serialize for YieldExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "YieldExpression")?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("delegate", &self.is_delegate)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ImportDeclaration { - pub specifiers: Vec, - pub source: _Literal, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ImportDeclaration {} -impl Serialize for ImportDeclaration { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ImportDeclaration")?; - state.serialize_entry("specifiers", &self.specifiers)?; - state.serialize_entry("source", &self.source)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ImportSpecifier { - pub imported: Identifier, - pub local: Identifier, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ImportSpecifier {} -impl Serialize for ImportSpecifier { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ImportSpecifier")?; - state.serialize_entry("imported", &self.imported)?; - state.serialize_entry("local", &self.local)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ImportDefaultSpecifier { - pub local: Identifier, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ImportDefaultSpecifier {} -impl Serialize for ImportDefaultSpecifier { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ImportDefaultSpecifier")?; - state.serialize_entry("local", &self.local)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ImportNamespaceSpecifier { - pub local: Identifier, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ImportNamespaceSpecifier {} -impl Serialize for ImportNamespaceSpecifier { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ImportNamespaceSpecifier")?; - state.serialize_entry("local", &self.local)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ExportNamedDeclaration { - pub declaration: Option, - pub specifiers: Vec, - pub source: Option<_Literal>, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ExportNamedDeclaration {} -impl Serialize for ExportNamedDeclaration { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ExportNamedDeclaration")?; - state.serialize_entry("declaration", &self.declaration)?; - state.serialize_entry("specifiers", &self.specifiers)?; - state.serialize_entry("source", &self.source)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ExportSpecifier { - pub exported: Identifier, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ExportSpecifier {} -impl Serialize for ExportSpecifier { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ExportSpecifier")?; - state.serialize_entry("exported", &self.exported)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ExportDefaultDeclaration { - pub declaration: DeclarationOrExpression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ExportDefaultDeclaration {} -impl Serialize for ExportDefaultDeclaration { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ExportDefaultDeclaration")?; - state.serialize_entry("declaration", &self.declaration)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ExportAllDeclaration { - pub source: _Literal, - #[serde(default)] - pub exported: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ExportAllDeclaration {} -impl Serialize for ExportAllDeclaration { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ExportAllDeclaration")?; - state.serialize_entry("source", &self.source)?; - state.serialize_entry("exported", &self.exported)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXIdentifier { - pub name: String, - #[serde(skip)] - #[serde(default)] - pub binding: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXIdentifier {} -impl Serialize for JSXIdentifier { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXIdentifier")?; - state.serialize_entry("name", &self.name)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXNamespacedName { - pub namespace: JSXIdentifier, - pub name: JSXIdentifier, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXNamespacedName {} -impl Serialize for JSXNamespacedName { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXNamespacedName")?; - state.serialize_entry("namespace", &self.namespace)?; - state.serialize_entry("name", &self.name)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXMemberExpression { - pub object: JSXMemberExpressionOrIdentifier, - pub property: JSXIdentifier, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXMemberExpression {} -impl Serialize for JSXMemberExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXMemberExpression")?; - state.serialize_entry("object", &self.object)?; - state.serialize_entry("property", &self.property)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXEmptyExpression { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXEmptyExpression {} -impl Serialize for JSXEmptyExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXEmptyExpression")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXExpressionContainer { - pub expression: JSXExpressionOrEmpty, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXExpressionContainer {} -impl Serialize for JSXExpressionContainer { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXExpressionContainer")?; - state.serialize_entry("expression", &self.expression)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXSpreadChild { - pub expression: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXSpreadChild {} -impl Serialize for JSXSpreadChild { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXSpreadChild")?; - state.serialize_entry("expression", &self.expression)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXOpeningElement { - pub name: JSXElementName, - pub attributes: Vec, - #[serde(rename = "selfClosing")] - pub self_closing: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXOpeningElement {} -impl Serialize for JSXOpeningElement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXOpeningElement")?; - state.serialize_entry("name", &self.name)?; - state.serialize_entry("attributes", &self.attributes)?; - state.serialize_entry("selfClosing", &self.self_closing)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXClosingElement { - pub name: JSXElementName, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXClosingElement {} -impl Serialize for JSXClosingElement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXClosingElement")?; - state.serialize_entry("name", &self.name)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXAttribute { - pub name: JSXIdentifierOrNamespacedName, - pub value: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXAttribute {} -impl Serialize for JSXAttribute { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXAttribute")?; - state.serialize_entry("name", &self.name)?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXSpreadAttribute { - pub argument: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXSpreadAttribute {} -impl Serialize for JSXSpreadAttribute { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXSpreadAttribute")?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXText { - pub value: String, - pub raw: String, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXText {} -impl Serialize for JSXText { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXText")?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("raw", &self.raw)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXStringLiteral { - pub value: String, - pub raw: String, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXStringLiteral {} -impl Serialize for JSXStringLiteral { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXStringLiteral")?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("raw", &self.raw)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXElement { - #[serde(rename = "openingElement")] - pub opening_element: JSXOpeningElement, - pub children: Vec, - #[serde(rename = "closingElement")] - pub closing_element: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXElement {} -impl Serialize for JSXElement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXElement")?; - state.serialize_entry("openingElement", &self.opening_element)?; - state.serialize_entry("children", &self.children)?; - state.serialize_entry("closingElement", &self.closing_element)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXFragment { - #[serde(rename = "openingFragment")] - pub opening_fragment: JSXOpeningFragment, - pub children: Vec, - #[serde(rename = "closingFragment")] - pub closing_fragment: JSXClosingFragment, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXFragment {} -impl Serialize for JSXFragment { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXFragment")?; - state.serialize_entry("openingFragment", &self.opening_fragment)?; - state.serialize_entry("children", &self.children)?; - state.serialize_entry("closingFragment", &self.closing_fragment)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXOpeningFragment { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXOpeningFragment {} -impl Serialize for JSXOpeningFragment { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXOpeningFragment")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct JSXClosingFragment { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for JSXClosingFragment {} -impl Serialize for JSXClosingFragment { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "JSXClosingFragment")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ArrayPattern { - pub elements: Vec>, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ArrayPattern {} -impl Serialize for ArrayPattern { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ArrayPattern")?; - state.serialize_entry("elements", &self.elements)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ObjectPattern { - pub properties: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ObjectPattern {} -impl Serialize for ObjectPattern { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ObjectPattern")?; - state.serialize_entry("properties", &self.properties)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct AssignmentProperty { - pub key: Expression, - pub value: Pattern, - pub kind: PropertyKind, - #[serde(rename = "computed")] - pub is_computed: bool, - #[serde(rename = "shorthand")] - pub is_shorthand: bool, - #[serde(rename = "method")] - pub is_method: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for AssignmentProperty {} -impl Serialize for AssignmentProperty { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "Property")?; - state.serialize_entry("key", &self.key)?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("kind", &self.kind)?; - state.serialize_entry("computed", &self.is_computed)?; - state.serialize_entry("shorthand", &self.is_shorthand)?; - state.serialize_entry("method", &self.is_method)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct RestElement { - pub argument: Pattern, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for RestElement {} -impl Serialize for RestElement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "RestElement")?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct AssignmentPattern { - pub left: Pattern, - pub right: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for AssignmentPattern {} -impl Serialize for AssignmentPattern { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "AssignmentPattern")?; - state.serialize_entry("left", &self.left)?; - state.serialize_entry("right", &self.right)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct TemplateLiteral { - pub quasis: Vec, - pub expressions: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for TemplateLiteral {} -impl Serialize for TemplateLiteral { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "TemplateLiteral")?; - state.serialize_entry("quasis", &self.quasis)?; - state.serialize_entry("expressions", &self.expressions)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct TemplateElement { - pub tail: bool, - pub value: TemplateElementValue, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for TemplateElement {} -impl Serialize for TemplateElement { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "TemplateElement")?; - state.serialize_entry("tail", &self.tail)?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct TaggedTemplateExpression { - pub tag: Expression, - pub quasi: TemplateLiteral, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for TaggedTemplateExpression {} -impl Serialize for TaggedTemplateExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "TaggedTemplateExpression")?; - state.serialize_entry("tag", &self.tag)?; - state.serialize_entry("quasi", &self.quasi)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct MetaProperty { - pub meta: Identifier, - pub property: Identifier, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for MetaProperty {} -impl Serialize for MetaProperty { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "MetaProperty")?; - state.serialize_entry("meta", &self.meta)?; - state.serialize_entry("property", &self.property)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct AwaitExpression { - pub argument: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for AwaitExpression {} -impl Serialize for AwaitExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "AwaitExpression")?; - state.serialize_entry("argument", &self.argument)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ChainExpression { - pub expression: ChainElement, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ChainExpression {} -impl Serialize for ChainExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ChainExpression")?; - state.serialize_entry("expression", &self.expression)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct OptionalMemberExpression { - pub object: Expression, - pub property: Expression, - #[serde(rename = "computed")] - pub is_computed: bool, - #[serde(rename = "optional")] - #[serde(default)] - pub is_optional: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for OptionalMemberExpression {} -impl Serialize for OptionalMemberExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "OptionalMemberExpression")?; - state.serialize_entry("object", &self.object)?; - state.serialize_entry("property", &self.property)?; - state.serialize_entry("computed", &self.is_computed)?; - state.serialize_entry("optional", &self.is_optional)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct OptionalCallExpression { - pub callee: ExpressionOrSuper, - pub arguments: Vec, - #[serde(rename = "optional")] - #[serde(default)] - pub is_optional: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for OptionalCallExpression {} -impl Serialize for OptionalCallExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "OptionalCallExpression")?; - state.serialize_entry("callee", &self.callee)?; - state.serialize_entry("arguments", &self.arguments)?; - state.serialize_entry("optional", &self.is_optional)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ImportExpression { - pub source: Expression, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ImportExpression {} -impl Serialize for ImportExpression { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ImportExpression")?; - state.serialize_entry("source", &self.source)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ClassProperty { - pub key: Expression, - #[serde(default)] - pub value: Option, - #[serde(rename = "computed")] - pub is_computed: bool, - #[serde(rename = "static")] - pub is_static: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ClassProperty {} -impl Serialize for ClassProperty { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ClassProperty")?; - state.serialize_entry("key", &self.key)?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("computed", &self.is_computed)?; - state.serialize_entry("static", &self.is_static)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct ClassPrivateProperty { - pub key: ExpressionOrPrivateIdentifier, - #[serde(default)] - pub value: Option, - #[serde(rename = "static")] - pub is_static: bool, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for ClassPrivateProperty {} -impl Serialize for ClassPrivateProperty { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "ClassPrivateProperty")?; - state.serialize_entry("key", &self.key)?; - state.serialize_entry("value", &self.value)?; - state.serialize_entry("static", &self.is_static)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct PrivateName { - pub id: Identifier, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for PrivateName {} -impl Serialize for PrivateName { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "PrivateName")?; - state.serialize_entry("id", &self.id)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct PrivateIdentifier { - pub name: String, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for PrivateIdentifier {} -impl Serialize for PrivateIdentifier { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "PrivateIdentifier")?; - state.serialize_entry("name", &self.name)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct StaticBlock { - pub body: Vec, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for StaticBlock {} -impl Serialize for StaticBlock { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "StaticBlock")?; - state.serialize_entry("body", &self.body)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct CoverTypedIdentifier { - pub left: Identifier, - pub right: Option, - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for CoverTypedIdentifier {} -impl Serialize for CoverTypedIdentifier { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "CoverTypedIdentifier")?; - state.serialize_entry("left", &self.left)?; - state.serialize_entry("right", &self.right)?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct TSTypeAnnotation { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for TSTypeAnnotation {} -impl Serialize for TSTypeAnnotation { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "TSTypeAnnotation")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Deserialize, Clone, Debug)] -pub struct TSTypeAliasDeclaration { - #[serde(default)] - pub loc: Option, - #[serde(default)] - pub range: Option, -} -impl ESTreeNode for TSTypeAliasDeclaration {} -impl Serialize for TSTypeAliasDeclaration { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - state.serialize_entry("type", "TSTypeAliasDeclaration")?; - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum Statement { - BlockStatement(Box), - BreakStatement(Box), - ClassDeclaration(Box), - ContinueStatement(Box), - DebuggerStatement(Box), - DoWhileStatement(Box), - EmptyStatement(Box), - ExpressionStatement(Box), - ForInStatement(Box), - ForOfStatement(Box), - ForStatement(Box), - FunctionDeclaration(Box), - IfStatement(Box), - LabeledStatement(Box), - ReturnStatement(Box), - SwitchStatement(Box), - TSTypeAliasDeclaration(Box), - ThrowStatement(Box), - TryStatement(Box), - VariableDeclaration(Box), - WhileStatement(Box), - WithStatement(Box), -} -#[derive(Deserialize, Debug)] -enum __StatementTag { - BlockStatement, - BreakStatement, - ClassDeclaration, - ContinueStatement, - DebuggerStatement, - DoWhileStatement, - EmptyStatement, - ExpressionStatement, - ForInStatement, - ForOfStatement, - ForStatement, - FunctionDeclaration, - IfStatement, - LabeledStatement, - ReturnStatement, - SwitchStatement, - ThrowStatement, - TryStatement, - TSTypeAliasDeclaration, - VariableDeclaration, - WhileStatement, - WithStatement, -} -impl<'de> serde::Deserialize<'de> for Statement { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __StatementTag, - >::new("type", "Statement"), - )?; - match tagged.0 { - __StatementTag::BlockStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::BlockStatement(node)) - } - __StatementTag::BreakStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::BreakStatement(node)) - } - __StatementTag::ClassDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::ClassDeclaration(node)) - } - __StatementTag::ContinueStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::ContinueStatement(node)) - } - __StatementTag::DebuggerStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::DebuggerStatement(node)) - } - __StatementTag::DoWhileStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::DoWhileStatement(node)) - } - __StatementTag::EmptyStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::EmptyStatement(node)) - } - __StatementTag::ExpressionStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::ExpressionStatement(node)) - } - __StatementTag::ForInStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::ForInStatement(node)) - } - __StatementTag::ForOfStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::ForOfStatement(node)) - } - __StatementTag::ForStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::ForStatement(node)) - } - __StatementTag::FunctionDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::FunctionDeclaration(node)) - } - __StatementTag::IfStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::IfStatement(node)) - } - __StatementTag::LabeledStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::LabeledStatement(node)) - } - __StatementTag::ReturnStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::ReturnStatement(node)) - } - __StatementTag::SwitchStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::SwitchStatement(node)) - } - __StatementTag::ThrowStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::ThrowStatement(node)) - } - __StatementTag::TryStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::TryStatement(node)) - } - __StatementTag::TSTypeAliasDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::TSTypeAliasDeclaration(node)) - } - __StatementTag::VariableDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::VariableDeclaration(node)) - } - __StatementTag::WhileStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::WhileStatement(node)) - } - __StatementTag::WithStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Statement::WithStatement(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum Expression { - ArrayExpression(Box), - ArrowFunctionExpression(Box), - AssignmentExpression(Box), - AwaitExpression(Box), - BinaryExpression(Box), - BooleanLiteral(Box), - CallExpression(Box), - ChainExpression(Box), - ClassExpression(Box), - ConditionalExpression(Box), - CoverTypedIdentifier(Box), - FunctionExpression(Box), - Identifier(Box), - ImportExpression(Box), - JSXElement(Box), - JSXFragment(Box), - Literal(Box), - LogicalExpression(Box), - MemberExpression(Box), - MetaProperty(Box), - NewExpression(Box), - NullLiteral(Box), - NumericLiteral(Box), - ObjectExpression(Box), - OptionalCallExpression(Box), - OptionalMemberExpression(Box), - RegExpLiteral(Box), - SequenceExpression(Box), - StringLiteral(Box), - TaggedTemplateExpression(Box), - TemplateLiteral(Box), - ThisExpression(Box), - UnaryExpression(Box), - UpdateExpression(Box), - YieldExpression(Box), -} -#[derive(Deserialize, Debug)] -enum __ExpressionTag { - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - Identifier, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, -} -impl<'de> serde::Deserialize<'de> for Expression { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ExpressionTag, - >::new("type", "Expression"), - )?; - match tagged.0 { - __ExpressionTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::ArrayExpression(node)) - } - __ExpressionTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::ArrowFunctionExpression(node)) - } - __ExpressionTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::AssignmentExpression(node)) - } - __ExpressionTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::AwaitExpression(node)) - } - __ExpressionTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::BinaryExpression(node)) - } - __ExpressionTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::BooleanLiteral(node)) - } - __ExpressionTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::CallExpression(node)) - } - __ExpressionTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::ChainExpression(node)) - } - __ExpressionTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::ClassExpression(node)) - } - __ExpressionTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::ConditionalExpression(node)) - } - __ExpressionTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::CoverTypedIdentifier(node)) - } - __ExpressionTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::FunctionExpression(node)) - } - __ExpressionTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::Identifier(node)) - } - __ExpressionTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::ImportExpression(node)) - } - __ExpressionTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::JSXElement(node)) - } - __ExpressionTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::JSXFragment(node)) - } - __ExpressionTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::Literal(node)) - } - __ExpressionTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::LogicalExpression(node)) - } - __ExpressionTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::MemberExpression(node)) - } - __ExpressionTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::MetaProperty(node)) - } - __ExpressionTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::NewExpression(node)) - } - __ExpressionTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::NullLiteral(node)) - } - __ExpressionTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::NumericLiteral(node)) - } - __ExpressionTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::ObjectExpression(node)) - } - __ExpressionTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::OptionalCallExpression(node)) - } - __ExpressionTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::OptionalMemberExpression(node)) - } - __ExpressionTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::RegExpLiteral(node)) - } - __ExpressionTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::SequenceExpression(node)) - } - __ExpressionTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::StringLiteral(node)) - } - __ExpressionTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::TaggedTemplateExpression(node)) - } - __ExpressionTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::TemplateLiteral(node)) - } - __ExpressionTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::ThisExpression(node)) - } - __ExpressionTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::UnaryExpression(node)) - } - __ExpressionTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::UpdateExpression(node)) - } - __ExpressionTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Expression::YieldExpression(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum _Literal { - BooleanLiteral(Box), - Literal(Box), - NullLiteral(Box), - NumericLiteral(Box), - StringLiteral(Box), -} -#[derive(Deserialize, Debug)] -enum ___LiteralTag { - Literal, - BooleanLiteral, - NullLiteral, - StringLiteral, - NumericLiteral, -} -impl<'de> serde::Deserialize<'de> for _Literal { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - ___LiteralTag, - >::new("type", "_Literal"), - )?; - match tagged.0 { - ___LiteralTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(_Literal::Literal(node)) - } - ___LiteralTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(_Literal::BooleanLiteral(node)) - } - ___LiteralTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(_Literal::NullLiteral(node)) - } - ___LiteralTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(_Literal::StringLiteral(node)) - } - ___LiteralTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(_Literal::NumericLiteral(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum Declaration { - ClassDeclaration(Box), - FunctionDeclaration(Box), - TSTypeAliasDeclaration(Box), - VariableDeclaration(Box), -} -#[derive(Deserialize, Debug)] -enum __DeclarationTag { - ClassDeclaration, - FunctionDeclaration, - VariableDeclaration, - TSTypeAliasDeclaration, -} -impl<'de> serde::Deserialize<'de> for Declaration { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __DeclarationTag, - >::new("type", "Declaration"), - )?; - match tagged.0 { - __DeclarationTag::ClassDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Declaration::ClassDeclaration(node)) - } - __DeclarationTag::FunctionDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Declaration::FunctionDeclaration(node)) - } - __DeclarationTag::VariableDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Declaration::VariableDeclaration(node)) - } - __DeclarationTag::TSTypeAliasDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Declaration::TSTypeAliasDeclaration(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ImportDeclarationSpecifier { - ImportDefaultSpecifier(Box), - ImportNamespaceSpecifier(Box), - ImportSpecifier(Box), -} -#[derive(Deserialize, Debug)] -enum __ImportDeclarationSpecifierTag { - ImportSpecifier, - ImportDefaultSpecifier, - ImportNamespaceSpecifier, -} -impl<'de> serde::Deserialize<'de> for ImportDeclarationSpecifier { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ImportDeclarationSpecifierTag, - >::new("type", "ImportDeclarationSpecifier"), - )?; - match tagged.0 { - __ImportDeclarationSpecifierTag::ImportSpecifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ImportDeclarationSpecifier::ImportSpecifier(node)) - } - __ImportDeclarationSpecifierTag::ImportDefaultSpecifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ImportDeclarationSpecifier::ImportDefaultSpecifier(node)) - } - __ImportDeclarationSpecifierTag::ImportNamespaceSpecifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ImportDeclarationSpecifier::ImportNamespaceSpecifier(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ModuleItem { - ImportOrExportDeclaration(ImportOrExportDeclaration), - Statement(Statement), -} -#[derive(Deserialize, Debug)] -enum __ModuleItemTag { - ImportDeclaration, - ExportNamedDeclaration, - ExportDefaultDeclaration, - ExportAllDeclaration, - BlockStatement, - BreakStatement, - ClassDeclaration, - ContinueStatement, - DebuggerStatement, - DoWhileStatement, - EmptyStatement, - ExpressionStatement, - ForInStatement, - ForOfStatement, - ForStatement, - FunctionDeclaration, - IfStatement, - LabeledStatement, - ReturnStatement, - SwitchStatement, - ThrowStatement, - TryStatement, - TSTypeAliasDeclaration, - VariableDeclaration, - WhileStatement, - WithStatement, -} -impl<'de> serde::Deserialize<'de> for ModuleItem { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ModuleItemTag, - >::new("type", "ModuleItem"), - )?; - match tagged.0 { - __ModuleItemTag::ImportDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ModuleItem::ImportOrExportDeclaration( - ImportOrExportDeclaration::ImportDeclaration(node), - ), - ) - } - __ModuleItemTag::ExportNamedDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ModuleItem::ImportOrExportDeclaration( - ImportOrExportDeclaration::ExportNamedDeclaration(node), - ), - ) - } - __ModuleItemTag::ExportDefaultDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ModuleItem::ImportOrExportDeclaration( - ImportOrExportDeclaration::ExportDefaultDeclaration(node), - ), - ) - } - __ModuleItemTag::ExportAllDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ModuleItem::ImportOrExportDeclaration( - ImportOrExportDeclaration::ExportAllDeclaration(node), - ), - ) - } - __ModuleItemTag::BlockStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::BlockStatement(node))) - } - __ModuleItemTag::BreakStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::BreakStatement(node))) - } - __ModuleItemTag::ClassDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::ClassDeclaration(node))) - } - __ModuleItemTag::ContinueStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::ContinueStatement(node))) - } - __ModuleItemTag::DebuggerStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::DebuggerStatement(node))) - } - __ModuleItemTag::DoWhileStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::DoWhileStatement(node))) - } - __ModuleItemTag::EmptyStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::EmptyStatement(node))) - } - __ModuleItemTag::ExpressionStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::ExpressionStatement(node))) - } - __ModuleItemTag::ForInStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::ForInStatement(node))) - } - __ModuleItemTag::ForOfStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::ForOfStatement(node))) - } - __ModuleItemTag::ForStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::ForStatement(node))) - } - __ModuleItemTag::FunctionDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::FunctionDeclaration(node))) - } - __ModuleItemTag::IfStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::IfStatement(node))) - } - __ModuleItemTag::LabeledStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::LabeledStatement(node))) - } - __ModuleItemTag::ReturnStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::ReturnStatement(node))) - } - __ModuleItemTag::SwitchStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::SwitchStatement(node))) - } - __ModuleItemTag::ThrowStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::ThrowStatement(node))) - } - __ModuleItemTag::TryStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::TryStatement(node))) - } - __ModuleItemTag::TSTypeAliasDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::TSTypeAliasDeclaration(node))) - } - __ModuleItemTag::VariableDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::VariableDeclaration(node))) - } - __ModuleItemTag::WhileStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::WhileStatement(node))) - } - __ModuleItemTag::WithStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ModuleItem::Statement(Statement::WithStatement(node))) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ImportOrExportDeclaration { - ExportAllDeclaration(Box), - ExportDefaultDeclaration(Box), - ExportNamedDeclaration(Box), - ImportDeclaration(Box), -} -#[derive(Deserialize, Debug)] -enum __ImportOrExportDeclarationTag { - ImportDeclaration, - ExportNamedDeclaration, - ExportDefaultDeclaration, - ExportAllDeclaration, -} -impl<'de> serde::Deserialize<'de> for ImportOrExportDeclaration { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ImportOrExportDeclarationTag, - >::new("type", "ImportOrExportDeclaration"), - )?; - match tagged.0 { - __ImportOrExportDeclarationTag::ImportDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ImportOrExportDeclaration::ImportDeclaration(node)) - } - __ImportOrExportDeclarationTag::ExportNamedDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ImportOrExportDeclaration::ExportNamedDeclaration(node)) - } - __ImportOrExportDeclarationTag::ExportDefaultDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ImportOrExportDeclaration::ExportDefaultDeclaration(node)) - } - __ImportOrExportDeclarationTag::ExportAllDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ImportOrExportDeclaration::ExportAllDeclaration(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ExpressionOrSuper { - Expression(Expression), - Super(Box), -} -#[derive(Deserialize, Debug)] -enum __ExpressionOrSuperTag { - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - Identifier, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, - Super, -} -impl<'de> serde::Deserialize<'de> for ExpressionOrSuper { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ExpressionOrSuperTag, - >::new("type", "ExpressionOrSuper"), - )?; - match tagged.0 { - __ExpressionOrSuperTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::ArrayExpression(node))) - } - __ExpressionOrSuperTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSuper::Expression( - Expression::ArrowFunctionExpression(node), - ), - ) - } - __ExpressionOrSuperTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::AssignmentExpression(node))) - } - __ExpressionOrSuperTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::AwaitExpression(node))) - } - __ExpressionOrSuperTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::BinaryExpression(node))) - } - __ExpressionOrSuperTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::BooleanLiteral(node))) - } - __ExpressionOrSuperTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::CallExpression(node))) - } - __ExpressionOrSuperTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::ChainExpression(node))) - } - __ExpressionOrSuperTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::ClassExpression(node))) - } - __ExpressionOrSuperTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSuper::Expression( - Expression::ConditionalExpression(node), - ), - ) - } - __ExpressionOrSuperTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::CoverTypedIdentifier(node))) - } - __ExpressionOrSuperTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::FunctionExpression(node))) - } - __ExpressionOrSuperTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::Identifier(node))) - } - __ExpressionOrSuperTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::ImportExpression(node))) - } - __ExpressionOrSuperTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::JSXElement(node))) - } - __ExpressionOrSuperTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::JSXFragment(node))) - } - __ExpressionOrSuperTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::Literal(node))) - } - __ExpressionOrSuperTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::LogicalExpression(node))) - } - __ExpressionOrSuperTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::MemberExpression(node))) - } - __ExpressionOrSuperTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::MetaProperty(node))) - } - __ExpressionOrSuperTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::NewExpression(node))) - } - __ExpressionOrSuperTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::NullLiteral(node))) - } - __ExpressionOrSuperTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::NumericLiteral(node))) - } - __ExpressionOrSuperTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::ObjectExpression(node))) - } - __ExpressionOrSuperTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSuper::Expression( - Expression::OptionalCallExpression(node), - ), - ) - } - __ExpressionOrSuperTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSuper::Expression( - Expression::OptionalMemberExpression(node), - ), - ) - } - __ExpressionOrSuperTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::RegExpLiteral(node))) - } - __ExpressionOrSuperTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::SequenceExpression(node))) - } - __ExpressionOrSuperTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::StringLiteral(node))) - } - __ExpressionOrSuperTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSuper::Expression( - Expression::TaggedTemplateExpression(node), - ), - ) - } - __ExpressionOrSuperTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::TemplateLiteral(node))) - } - __ExpressionOrSuperTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::ThisExpression(node))) - } - __ExpressionOrSuperTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::UnaryExpression(node))) - } - __ExpressionOrSuperTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::UpdateExpression(node))) - } - __ExpressionOrSuperTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Expression(Expression::YieldExpression(node))) - } - __ExpressionOrSuperTag::Super => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSuper::Super(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ExpressionOrSpread { - Expression(Expression), - SpreadElement(Box), -} -#[derive(Deserialize, Debug)] -enum __ExpressionOrSpreadTag { - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - Identifier, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, - SpreadElement, -} -impl<'de> serde::Deserialize<'de> for ExpressionOrSpread { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ExpressionOrSpreadTag, - >::new("type", "ExpressionOrSpread"), - )?; - match tagged.0 { - __ExpressionOrSpreadTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::ArrayExpression(node))) - } - __ExpressionOrSpreadTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSpread::Expression( - Expression::ArrowFunctionExpression(node), - ), - ) - } - __ExpressionOrSpreadTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSpread::Expression( - Expression::AssignmentExpression(node), - ), - ) - } - __ExpressionOrSpreadTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::AwaitExpression(node))) - } - __ExpressionOrSpreadTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::BinaryExpression(node))) - } - __ExpressionOrSpreadTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::BooleanLiteral(node))) - } - __ExpressionOrSpreadTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::CallExpression(node))) - } - __ExpressionOrSpreadTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::ChainExpression(node))) - } - __ExpressionOrSpreadTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::ClassExpression(node))) - } - __ExpressionOrSpreadTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSpread::Expression( - Expression::ConditionalExpression(node), - ), - ) - } - __ExpressionOrSpreadTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSpread::Expression( - Expression::CoverTypedIdentifier(node), - ), - ) - } - __ExpressionOrSpreadTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::FunctionExpression(node))) - } - __ExpressionOrSpreadTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::Identifier(node))) - } - __ExpressionOrSpreadTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::ImportExpression(node))) - } - __ExpressionOrSpreadTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::JSXElement(node))) - } - __ExpressionOrSpreadTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::JSXFragment(node))) - } - __ExpressionOrSpreadTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::Literal(node))) - } - __ExpressionOrSpreadTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::LogicalExpression(node))) - } - __ExpressionOrSpreadTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::MemberExpression(node))) - } - __ExpressionOrSpreadTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::MetaProperty(node))) - } - __ExpressionOrSpreadTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::NewExpression(node))) - } - __ExpressionOrSpreadTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::NullLiteral(node))) - } - __ExpressionOrSpreadTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::NumericLiteral(node))) - } - __ExpressionOrSpreadTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::ObjectExpression(node))) - } - __ExpressionOrSpreadTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSpread::Expression( - Expression::OptionalCallExpression(node), - ), - ) - } - __ExpressionOrSpreadTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSpread::Expression( - Expression::OptionalMemberExpression(node), - ), - ) - } - __ExpressionOrSpreadTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::RegExpLiteral(node))) - } - __ExpressionOrSpreadTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::SequenceExpression(node))) - } - __ExpressionOrSpreadTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::StringLiteral(node))) - } - __ExpressionOrSpreadTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrSpread::Expression( - Expression::TaggedTemplateExpression(node), - ), - ) - } - __ExpressionOrSpreadTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::TemplateLiteral(node))) - } - __ExpressionOrSpreadTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::ThisExpression(node))) - } - __ExpressionOrSpreadTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::UnaryExpression(node))) - } - __ExpressionOrSpreadTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::UpdateExpression(node))) - } - __ExpressionOrSpreadTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::Expression(Expression::YieldExpression(node))) - } - __ExpressionOrSpreadTag::SpreadElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrSpread::SpreadElement(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum FunctionBody { - BlockStatement(Box), - Expression(Expression), -} -#[derive(Deserialize, Debug)] -enum __FunctionBodyTag { - BlockStatement, - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - Identifier, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, -} -impl<'de> serde::Deserialize<'de> for FunctionBody { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __FunctionBodyTag, - >::new("type", "FunctionBody"), - )?; - match tagged.0 { - __FunctionBodyTag::BlockStatement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::BlockStatement(node)) - } - __FunctionBodyTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::ArrayExpression(node))) - } - __FunctionBodyTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::ArrowFunctionExpression(node))) - } - __FunctionBodyTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::AssignmentExpression(node))) - } - __FunctionBodyTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::AwaitExpression(node))) - } - __FunctionBodyTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::BinaryExpression(node))) - } - __FunctionBodyTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::BooleanLiteral(node))) - } - __FunctionBodyTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::CallExpression(node))) - } - __FunctionBodyTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::ChainExpression(node))) - } - __FunctionBodyTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::ClassExpression(node))) - } - __FunctionBodyTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::ConditionalExpression(node))) - } - __FunctionBodyTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::CoverTypedIdentifier(node))) - } - __FunctionBodyTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::FunctionExpression(node))) - } - __FunctionBodyTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::Identifier(node))) - } - __FunctionBodyTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::ImportExpression(node))) - } - __FunctionBodyTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::JSXElement(node))) - } - __FunctionBodyTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::JSXFragment(node))) - } - __FunctionBodyTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::Literal(node))) - } - __FunctionBodyTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::LogicalExpression(node))) - } - __FunctionBodyTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::MemberExpression(node))) - } - __FunctionBodyTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::MetaProperty(node))) - } - __FunctionBodyTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::NewExpression(node))) - } - __FunctionBodyTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::NullLiteral(node))) - } - __FunctionBodyTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::NumericLiteral(node))) - } - __FunctionBodyTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::ObjectExpression(node))) - } - __FunctionBodyTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::OptionalCallExpression(node))) - } - __FunctionBodyTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::OptionalMemberExpression(node))) - } - __FunctionBodyTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::RegExpLiteral(node))) - } - __FunctionBodyTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::SequenceExpression(node))) - } - __FunctionBodyTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::StringLiteral(node))) - } - __FunctionBodyTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::TaggedTemplateExpression(node))) - } - __FunctionBodyTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::TemplateLiteral(node))) - } - __FunctionBodyTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::ThisExpression(node))) - } - __FunctionBodyTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::UnaryExpression(node))) - } - __FunctionBodyTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::UpdateExpression(node))) - } - __FunctionBodyTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(FunctionBody::Expression(Expression::YieldExpression(node))) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum Pattern { - ArrayPattern(Box), - AssignmentPattern(Box), - Identifier(Box), - ObjectPattern(Box), - RestElement(Box), -} -#[derive(Deserialize, Debug)] -enum __PatternTag { - Identifier, - ArrayPattern, - ObjectPattern, - RestElement, - AssignmentPattern, -} -impl<'de> serde::Deserialize<'de> for Pattern { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __PatternTag, - >::new("type", "Pattern"), - )?; - match tagged.0 { - __PatternTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Pattern::Identifier(node)) - } - __PatternTag::ArrayPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Pattern::ArrayPattern(node)) - } - __PatternTag::ObjectPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Pattern::ObjectPattern(node)) - } - __PatternTag::RestElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Pattern::RestElement(node)) - } - __PatternTag::AssignmentPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(Pattern::AssignmentPattern(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ForInit { - Expression(Expression), - VariableDeclaration(Box), -} -#[derive(Deserialize, Debug)] -enum __ForInitTag { - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - Identifier, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, - VariableDeclaration, -} -impl<'de> serde::Deserialize<'de> for ForInit { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ForInitTag, - >::new("type", "ForInit"), - )?; - match tagged.0 { - __ForInitTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::ArrayExpression(node))) - } - __ForInitTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::ArrowFunctionExpression(node))) - } - __ForInitTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::AssignmentExpression(node))) - } - __ForInitTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::AwaitExpression(node))) - } - __ForInitTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::BinaryExpression(node))) - } - __ForInitTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::BooleanLiteral(node))) - } - __ForInitTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::CallExpression(node))) - } - __ForInitTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::ChainExpression(node))) - } - __ForInitTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::ClassExpression(node))) - } - __ForInitTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::ConditionalExpression(node))) - } - __ForInitTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::CoverTypedIdentifier(node))) - } - __ForInitTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::FunctionExpression(node))) - } - __ForInitTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::Identifier(node))) - } - __ForInitTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::ImportExpression(node))) - } - __ForInitTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::JSXElement(node))) - } - __ForInitTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::JSXFragment(node))) - } - __ForInitTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::Literal(node))) - } - __ForInitTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::LogicalExpression(node))) - } - __ForInitTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::MemberExpression(node))) - } - __ForInitTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::MetaProperty(node))) - } - __ForInitTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::NewExpression(node))) - } - __ForInitTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::NullLiteral(node))) - } - __ForInitTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::NumericLiteral(node))) - } - __ForInitTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::ObjectExpression(node))) - } - __ForInitTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::OptionalCallExpression(node))) - } - __ForInitTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::OptionalMemberExpression(node))) - } - __ForInitTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::RegExpLiteral(node))) - } - __ForInitTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::SequenceExpression(node))) - } - __ForInitTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::StringLiteral(node))) - } - __ForInitTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::TaggedTemplateExpression(node))) - } - __ForInitTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::TemplateLiteral(node))) - } - __ForInitTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::ThisExpression(node))) - } - __ForInitTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::UnaryExpression(node))) - } - __ForInitTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::UpdateExpression(node))) - } - __ForInitTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::Expression(Expression::YieldExpression(node))) - } - __ForInitTag::VariableDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInit::VariableDeclaration(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ForInInit { - Pattern(Pattern), - VariableDeclaration(Box), -} -#[derive(Deserialize, Debug)] -enum __ForInInitTag { - Identifier, - ArrayPattern, - ObjectPattern, - RestElement, - AssignmentPattern, - VariableDeclaration, -} -impl<'de> serde::Deserialize<'de> for ForInInit { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ForInInitTag, - >::new("type", "ForInInit"), - )?; - match tagged.0 { - __ForInInitTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInInit::Pattern(Pattern::Identifier(node))) - } - __ForInInitTag::ArrayPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInInit::Pattern(Pattern::ArrayPattern(node))) - } - __ForInInitTag::ObjectPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInInit::Pattern(Pattern::ObjectPattern(node))) - } - __ForInInitTag::RestElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInInit::Pattern(Pattern::RestElement(node))) - } - __ForInInitTag::AssignmentPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInInit::Pattern(Pattern::AssignmentPattern(node))) - } - __ForInInitTag::VariableDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ForInInit::VariableDeclaration(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum PropertyOrSpreadElement { - Property(Box), - SpreadElement(Box), -} -#[derive(Deserialize, Debug)] -enum __PropertyOrSpreadElementTag { - Property, - SpreadElement, -} -impl<'de> serde::Deserialize<'de> for PropertyOrSpreadElement { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __PropertyOrSpreadElementTag, - >::new("type", "PropertyOrSpreadElement"), - )?; - match tagged.0 { - __PropertyOrSpreadElementTag::Property => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(PropertyOrSpreadElement::Property(node)) - } - __PropertyOrSpreadElementTag::SpreadElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(PropertyOrSpreadElement::SpreadElement(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum AssignmentPropertyOrRestElement { - AssignmentProperty(Box), - RestElement(Box), -} -#[derive(Deserialize, Debug)] -enum __AssignmentPropertyOrRestElementTag { - AssignmentProperty, - RestElement, -} -impl<'de> serde::Deserialize<'de> for AssignmentPropertyOrRestElement { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __AssignmentPropertyOrRestElementTag, - >::new("type", "AssignmentPropertyOrRestElement"), - )?; - match tagged.0 { - __AssignmentPropertyOrRestElementTag::AssignmentProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentPropertyOrRestElement::AssignmentProperty(node)) - } - __AssignmentPropertyOrRestElementTag::RestElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentPropertyOrRestElement::RestElement(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum AssignmentTarget { - Expression(Expression), - Pattern(Pattern), -} -#[derive(Deserialize, Debug)] -enum __AssignmentTargetTag { - Identifier, - ArrayPattern, - ObjectPattern, - RestElement, - AssignmentPattern, - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, -} -impl<'de> serde::Deserialize<'de> for AssignmentTarget { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __AssignmentTargetTag, - >::new("type", "AssignmentTarget"), - )?; - match tagged.0 { - __AssignmentTargetTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Pattern(Pattern::Identifier(node))) - } - __AssignmentTargetTag::ArrayPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Pattern(Pattern::ArrayPattern(node))) - } - __AssignmentTargetTag::ObjectPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Pattern(Pattern::ObjectPattern(node))) - } - __AssignmentTargetTag::RestElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Pattern(Pattern::RestElement(node))) - } - __AssignmentTargetTag::AssignmentPattern => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Pattern(Pattern::AssignmentPattern(node))) - } - __AssignmentTargetTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::ArrayExpression(node))) - } - __AssignmentTargetTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - AssignmentTarget::Expression( - Expression::ArrowFunctionExpression(node), - ), - ) - } - __AssignmentTargetTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::AssignmentExpression(node))) - } - __AssignmentTargetTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::AwaitExpression(node))) - } - __AssignmentTargetTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::BinaryExpression(node))) - } - __AssignmentTargetTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::BooleanLiteral(node))) - } - __AssignmentTargetTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::CallExpression(node))) - } - __AssignmentTargetTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::ChainExpression(node))) - } - __AssignmentTargetTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::ClassExpression(node))) - } - __AssignmentTargetTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::ConditionalExpression(node))) - } - __AssignmentTargetTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::CoverTypedIdentifier(node))) - } - __AssignmentTargetTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::FunctionExpression(node))) - } - __AssignmentTargetTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::ImportExpression(node))) - } - __AssignmentTargetTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::JSXElement(node))) - } - __AssignmentTargetTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::JSXFragment(node))) - } - __AssignmentTargetTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::Literal(node))) - } - __AssignmentTargetTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::LogicalExpression(node))) - } - __AssignmentTargetTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::MemberExpression(node))) - } - __AssignmentTargetTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::MetaProperty(node))) - } - __AssignmentTargetTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::NewExpression(node))) - } - __AssignmentTargetTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::NullLiteral(node))) - } - __AssignmentTargetTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::NumericLiteral(node))) - } - __AssignmentTargetTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::ObjectExpression(node))) - } - __AssignmentTargetTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - AssignmentTarget::Expression( - Expression::OptionalCallExpression(node), - ), - ) - } - __AssignmentTargetTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - AssignmentTarget::Expression( - Expression::OptionalMemberExpression(node), - ), - ) - } - __AssignmentTargetTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::RegExpLiteral(node))) - } - __AssignmentTargetTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::SequenceExpression(node))) - } - __AssignmentTargetTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::StringLiteral(node))) - } - __AssignmentTargetTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - AssignmentTarget::Expression( - Expression::TaggedTemplateExpression(node), - ), - ) - } - __AssignmentTargetTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::TemplateLiteral(node))) - } - __AssignmentTargetTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::ThisExpression(node))) - } - __AssignmentTargetTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::UnaryExpression(node))) - } - __AssignmentTargetTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::UpdateExpression(node))) - } - __AssignmentTargetTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(AssignmentTarget::Expression(Expression::YieldExpression(node))) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ChainElement { - CallExpression(Box), - MemberExpression(Box), -} -#[derive(Deserialize, Debug)] -enum __ChainElementTag { - CallExpression, - MemberExpression, -} -impl<'de> serde::Deserialize<'de> for ChainElement { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ChainElementTag, - >::new("type", "ChainElement"), - )?; - match tagged.0 { - __ChainElementTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ChainElement::CallExpression(node)) - } - __ChainElementTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ChainElement::MemberExpression(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum JSXMemberExpressionOrIdentifier { - JSXIdentifier(Box), - JSXMemberExpression(Box), -} -#[derive(Deserialize, Debug)] -enum __JSXMemberExpressionOrIdentifierTag { - JSXMemberExpression, - JSXIdentifier, -} -impl<'de> serde::Deserialize<'de> for JSXMemberExpressionOrIdentifier { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __JSXMemberExpressionOrIdentifierTag, - >::new("type", "JSXMemberExpressionOrIdentifier"), - )?; - match tagged.0 { - __JSXMemberExpressionOrIdentifierTag::JSXMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXMemberExpressionOrIdentifier::JSXMemberExpression(node)) - } - __JSXMemberExpressionOrIdentifierTag::JSXIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXMemberExpressionOrIdentifier::JSXIdentifier(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum JSXExpressionOrEmpty { - Expression(Expression), - JSXEmptyExpression(Box), -} -#[derive(Deserialize, Debug)] -enum __JSXExpressionOrEmptyTag { - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - Identifier, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, - JSXEmptyExpression, -} -impl<'de> serde::Deserialize<'de> for JSXExpressionOrEmpty { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __JSXExpressionOrEmptyTag, - >::new("type", "JSXExpressionOrEmpty"), - )?; - match tagged.0 { - __JSXExpressionOrEmptyTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::ArrayExpression(node))) - } - __JSXExpressionOrEmptyTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::ArrowFunctionExpression(node), - ), - ) - } - __JSXExpressionOrEmptyTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::AssignmentExpression(node), - ), - ) - } - __JSXExpressionOrEmptyTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::AwaitExpression(node))) - } - __JSXExpressionOrEmptyTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::BinaryExpression(node))) - } - __JSXExpressionOrEmptyTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::BooleanLiteral(node))) - } - __JSXExpressionOrEmptyTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::CallExpression(node))) - } - __JSXExpressionOrEmptyTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::ChainExpression(node))) - } - __JSXExpressionOrEmptyTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::ClassExpression(node))) - } - __JSXExpressionOrEmptyTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::ConditionalExpression(node), - ), - ) - } - __JSXExpressionOrEmptyTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::CoverTypedIdentifier(node), - ), - ) - } - __JSXExpressionOrEmptyTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::FunctionExpression(node), - ), - ) - } - __JSXExpressionOrEmptyTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::Identifier(node))) - } - __JSXExpressionOrEmptyTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::ImportExpression(node))) - } - __JSXExpressionOrEmptyTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::JSXElement(node))) - } - __JSXExpressionOrEmptyTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::JSXFragment(node))) - } - __JSXExpressionOrEmptyTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::Literal(node))) - } - __JSXExpressionOrEmptyTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::LogicalExpression(node))) - } - __JSXExpressionOrEmptyTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::MemberExpression(node))) - } - __JSXExpressionOrEmptyTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::MetaProperty(node))) - } - __JSXExpressionOrEmptyTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::NewExpression(node))) - } - __JSXExpressionOrEmptyTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::NullLiteral(node))) - } - __JSXExpressionOrEmptyTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::NumericLiteral(node))) - } - __JSXExpressionOrEmptyTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::ObjectExpression(node))) - } - __JSXExpressionOrEmptyTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::OptionalCallExpression(node), - ), - ) - } - __JSXExpressionOrEmptyTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::OptionalMemberExpression(node), - ), - ) - } - __JSXExpressionOrEmptyTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::RegExpLiteral(node))) - } - __JSXExpressionOrEmptyTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::SequenceExpression(node), - ), - ) - } - __JSXExpressionOrEmptyTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::StringLiteral(node))) - } - __JSXExpressionOrEmptyTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - JSXExpressionOrEmpty::Expression( - Expression::TaggedTemplateExpression(node), - ), - ) - } - __JSXExpressionOrEmptyTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::TemplateLiteral(node))) - } - __JSXExpressionOrEmptyTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::ThisExpression(node))) - } - __JSXExpressionOrEmptyTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::UnaryExpression(node))) - } - __JSXExpressionOrEmptyTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::UpdateExpression(node))) - } - __JSXExpressionOrEmptyTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::Expression(Expression::YieldExpression(node))) - } - __JSXExpressionOrEmptyTag::JSXEmptyExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXExpressionOrEmpty::JSXEmptyExpression(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum JSXAttributeOrSpread { - JSXAttribute(Box), - JSXSpreadAttribute(Box), -} -#[derive(Deserialize, Debug)] -enum __JSXAttributeOrSpreadTag { - JSXAttribute, - JSXSpreadAttribute, -} -impl<'de> serde::Deserialize<'de> for JSXAttributeOrSpread { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __JSXAttributeOrSpreadTag, - >::new("type", "JSXAttributeOrSpread"), - )?; - match tagged.0 { - __JSXAttributeOrSpreadTag::JSXAttribute => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXAttributeOrSpread::JSXAttribute(node)) - } - __JSXAttributeOrSpreadTag::JSXSpreadAttribute => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXAttributeOrSpread::JSXSpreadAttribute(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum JSXAttributeValue { - JSXElement(Box), - JSXExpressionContainer(Box), - JSXFragment(Box), - JSXStringLiteral(Box), - Literal(Box), -} -#[derive(Deserialize, Debug)] -enum __JSXAttributeValueTag { - Literal, - JSXExpressionContainer, - JSXElement, - JSXFragment, - JSXStringLiteral, -} -impl<'de> serde::Deserialize<'de> for JSXAttributeValue { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __JSXAttributeValueTag, - >::new("type", "JSXAttributeValue"), - )?; - match tagged.0 { - __JSXAttributeValueTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXAttributeValue::Literal(node)) - } - __JSXAttributeValueTag::JSXExpressionContainer => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXAttributeValue::JSXExpressionContainer(node)) - } - __JSXAttributeValueTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXAttributeValue::JSXElement(node)) - } - __JSXAttributeValueTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXAttributeValue::JSXFragment(node)) - } - __JSXAttributeValueTag::JSXStringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXAttributeValue::JSXStringLiteral(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum JSXElementName { - JSXIdentifier(Box), - JSXMemberExpression(Box), - JSXNamespacedName(Box), -} -#[derive(Deserialize, Debug)] -enum __JSXElementNameTag { - JSXIdentifier, - JSXMemberExpression, - JSXNamespacedName, -} -impl<'de> serde::Deserialize<'de> for JSXElementName { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __JSXElementNameTag, - >::new("type", "JSXElementName"), - )?; - match tagged.0 { - __JSXElementNameTag::JSXIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXElementName::JSXIdentifier(node)) - } - __JSXElementNameTag::JSXMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXElementName::JSXMemberExpression(node)) - } - __JSXElementNameTag::JSXNamespacedName => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXElementName::JSXNamespacedName(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum JSXIdentifierOrNamespacedName { - JSXIdentifier(Box), - JSXNamespacedName(Box), -} -#[derive(Deserialize, Debug)] -enum __JSXIdentifierOrNamespacedNameTag { - JSXIdentifier, - JSXNamespacedName, -} -impl<'de> serde::Deserialize<'de> for JSXIdentifierOrNamespacedName { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __JSXIdentifierOrNamespacedNameTag, - >::new("type", "JSXIdentifierOrNamespacedName"), - )?; - match tagged.0 { - __JSXIdentifierOrNamespacedNameTag::JSXIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXIdentifierOrNamespacedName::JSXIdentifier(node)) - } - __JSXIdentifierOrNamespacedNameTag::JSXNamespacedName => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXIdentifierOrNamespacedName::JSXNamespacedName(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum JSXChildItem { - JSXElement(Box), - JSXExpressionContainer(Box), - JSXFragment(Box), - JSXSpreadChild(Box), - JSXStringLiteral(Box), - JSXText(Box), -} -#[derive(Deserialize, Debug)] -enum __JSXChildItemTag { - JSXText, - JSXStringLiteral, - JSXExpressionContainer, - JSXSpreadChild, - JSXElement, - JSXFragment, -} -impl<'de> serde::Deserialize<'de> for JSXChildItem { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __JSXChildItemTag, - >::new("type", "JSXChildItem"), - )?; - match tagged.0 { - __JSXChildItemTag::JSXText => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXChildItem::JSXText(node)) - } - __JSXChildItemTag::JSXStringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXChildItem::JSXStringLiteral(node)) - } - __JSXChildItemTag::JSXExpressionContainer => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXChildItem::JSXExpressionContainer(node)) - } - __JSXChildItemTag::JSXSpreadChild => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXChildItem::JSXSpreadChild(node)) - } - __JSXChildItemTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXChildItem::JSXElement(node)) - } - __JSXChildItemTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(JSXChildItem::JSXFragment(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum DeclarationOrExpression { - Declaration(Declaration), - Expression(Expression), -} -#[derive(Deserialize, Debug)] -enum __DeclarationOrExpressionTag { - ClassDeclaration, - FunctionDeclaration, - VariableDeclaration, - TSTypeAliasDeclaration, - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - Identifier, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, -} -impl<'de> serde::Deserialize<'de> for DeclarationOrExpression { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __DeclarationOrExpressionTag, - >::new("type", "DeclarationOrExpression"), - )?; - match tagged.0 { - __DeclarationOrExpressionTag::ClassDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Declaration( - Declaration::ClassDeclaration(node), - ), - ) - } - __DeclarationOrExpressionTag::FunctionDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Declaration( - Declaration::FunctionDeclaration(node), - ), - ) - } - __DeclarationOrExpressionTag::VariableDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Declaration( - Declaration::VariableDeclaration(node), - ), - ) - } - __DeclarationOrExpressionTag::TSTypeAliasDeclaration => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Declaration( - Declaration::TSTypeAliasDeclaration(node), - ), - ) - } - __DeclarationOrExpressionTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::ArrayExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::ArrowFunctionExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::AssignmentExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::AwaitExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::BinaryExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::BooleanLiteral(node))) - } - __DeclarationOrExpressionTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::CallExpression(node))) - } - __DeclarationOrExpressionTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::ChainExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::ClassExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::ConditionalExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::CoverTypedIdentifier(node), - ), - ) - } - __DeclarationOrExpressionTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::FunctionExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::Identifier(node))) - } - __DeclarationOrExpressionTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::ImportExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::JSXElement(node))) - } - __DeclarationOrExpressionTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::JSXFragment(node))) - } - __DeclarationOrExpressionTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::Literal(node))) - } - __DeclarationOrExpressionTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::LogicalExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::MemberExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::MetaProperty(node))) - } - __DeclarationOrExpressionTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::NewExpression(node))) - } - __DeclarationOrExpressionTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::NullLiteral(node))) - } - __DeclarationOrExpressionTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::NumericLiteral(node))) - } - __DeclarationOrExpressionTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::ObjectExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::OptionalCallExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::OptionalMemberExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::RegExpLiteral(node))) - } - __DeclarationOrExpressionTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::SequenceExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::StringLiteral(node))) - } - __DeclarationOrExpressionTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::TaggedTemplateExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::TemplateLiteral(node), - ), - ) - } - __DeclarationOrExpressionTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(DeclarationOrExpression::Expression(Expression::ThisExpression(node))) - } - __DeclarationOrExpressionTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::UnaryExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::UpdateExpression(node), - ), - ) - } - __DeclarationOrExpressionTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - DeclarationOrExpression::Expression( - Expression::YieldExpression(node), - ), - ) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ClassItem { - ClassPrivateProperty(Box), - ClassProperty(Box), - MethodDefinition(Box), - StaticBlock(Box), -} -#[derive(Deserialize, Debug)] -enum __ClassItemTag { - MethodDefinition, - ClassProperty, - ClassPrivateProperty, - StaticBlock, -} -impl<'de> serde::Deserialize<'de> for ClassItem { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ClassItemTag, - >::new("type", "ClassItem"), - )?; - match tagged.0 { - __ClassItemTag::MethodDefinition => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ClassItem::MethodDefinition(node)) - } - __ClassItemTag::ClassProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ClassItem::ClassProperty(node)) - } - __ClassItemTag::ClassPrivateProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ClassItem::ClassPrivateProperty(node)) - } - __ClassItemTag::StaticBlock => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ClassItem::StaticBlock(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum ExpressionOrPrivateIdentifier { - Expression(Expression), - PrivateIdentifier(Box), - PrivateName(Box), -} -#[derive(Deserialize, Debug)] -enum __ExpressionOrPrivateIdentifierTag { - ArrayExpression, - ArrowFunctionExpression, - AssignmentExpression, - AwaitExpression, - BinaryExpression, - BooleanLiteral, - CallExpression, - ChainExpression, - ClassExpression, - ConditionalExpression, - CoverTypedIdentifier, - FunctionExpression, - Identifier, - ImportExpression, - JSXElement, - JSXFragment, - Literal, - LogicalExpression, - MemberExpression, - MetaProperty, - NewExpression, - NullLiteral, - NumericLiteral, - ObjectExpression, - OptionalCallExpression, - OptionalMemberExpression, - RegExpLiteral, - SequenceExpression, - StringLiteral, - TaggedTemplateExpression, - TemplateLiteral, - ThisExpression, - UnaryExpression, - UpdateExpression, - YieldExpression, - PrivateIdentifier, - PrivateName, -} -impl<'de> serde::Deserialize<'de> for ExpressionOrPrivateIdentifier { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __ExpressionOrPrivateIdentifierTag, - >::new("type", "ExpressionOrPrivateIdentifier"), - )?; - match tagged.0 { - __ExpressionOrPrivateIdentifierTag::ArrayExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::ArrayExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::ArrowFunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::ArrowFunctionExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::AssignmentExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::AssignmentExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::AwaitExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::AwaitExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::BinaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::BinaryExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::BooleanLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::BooleanLiteral(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::CallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::CallExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::ChainExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::ChainExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::ClassExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::ClassExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::ConditionalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::ConditionalExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::CoverTypedIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::CoverTypedIdentifier(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::FunctionExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::FunctionExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::Identifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::Identifier(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::ImportExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::ImportExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::JSXElement => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::JSXElement(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::JSXFragment => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::JSXFragment(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::Literal => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrPrivateIdentifier::Expression(Expression::Literal(node))) - } - __ExpressionOrPrivateIdentifierTag::LogicalExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::LogicalExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::MemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::MemberExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::MetaProperty => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::MetaProperty(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::NewExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::NewExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::NullLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::NullLiteral(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::NumericLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::NumericLiteral(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::ObjectExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::ObjectExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::OptionalCallExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::OptionalCallExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::OptionalMemberExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::OptionalMemberExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::RegExpLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::RegExpLiteral(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::SequenceExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::SequenceExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::StringLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::StringLiteral(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::TaggedTemplateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::TaggedTemplateExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::TemplateLiteral => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::TemplateLiteral(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::ThisExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::ThisExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::UnaryExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::UnaryExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::UpdateExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::UpdateExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::YieldExpression => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok( - ExpressionOrPrivateIdentifier::Expression( - Expression::YieldExpression(node), - ), - ) - } - __ExpressionOrPrivateIdentifierTag::PrivateIdentifier => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrPrivateIdentifier::PrivateIdentifier(node)) - } - __ExpressionOrPrivateIdentifierTag::PrivateName => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(ExpressionOrPrivateIdentifier::PrivateName(node)) - } - } - } -} -#[derive(Serialize, Clone, Debug)] -#[serde(untagged)] -pub enum TypeAnnotation { - TSTypeAnnotation(Box), -} -#[derive(Deserialize, Debug)] -enum __TypeAnnotationTag { - TSTypeAnnotation, -} -impl<'de> serde::Deserialize<'de> for TypeAnnotation { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::< - __TypeAnnotationTag, - >::new("type", "TypeAnnotation"), - )?; - match tagged.0 { - __TypeAnnotationTag::TSTypeAnnotation => { - let node: Box = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(TypeAnnotation::TSTypeAnnotation(node)) - } - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum VariableDeclarationKind { - /// const - #[serde(rename = "const")] - Const, - /// let - #[serde(rename = "let")] - Let, - /// var - #[serde(rename = "var")] - Var, -} -impl std::fmt::Display for VariableDeclarationKind { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::Const => "const", - Self::Let => "let", - Self::Var => "var", - }; - f.write_str(name) - } -} -impl std::str::FromStr for VariableDeclarationKind { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "const" => Ok(Self::Const), - "let" => Ok(Self::Let), - "var" => Ok(Self::Var), - _ => Err(()), - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum PropertyKind { - /// get - #[serde(rename = "get")] - Get, - /// init - #[serde(rename = "init")] - Init, - /// set - #[serde(rename = "set")] - Set, -} -impl std::fmt::Display for PropertyKind { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::Get => "get", - Self::Init => "init", - Self::Set => "set", - }; - f.write_str(name) - } -} -impl std::str::FromStr for PropertyKind { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "get" => Ok(Self::Get), - "init" => Ok(Self::Init), - "set" => Ok(Self::Set), - _ => Err(()), - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum UnaryOperator { - /// delete - #[serde(rename = "delete")] - Delete, - /// - - #[serde(rename = "-")] - Minus, - /// ! - #[serde(rename = "!")] - Negation, - /// + - #[serde(rename = "+")] - Plus, - /// ~ - #[serde(rename = "~")] - Tilde, - /// typeof - #[serde(rename = "typeof")] - Typeof, - /// void - #[serde(rename = "void")] - Void, -} -impl std::fmt::Display for UnaryOperator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::Delete => "delete", - Self::Minus => "-", - Self::Negation => "!", - Self::Plus => "+", - Self::Tilde => "~", - Self::Typeof => "typeof", - Self::Void => "void", - }; - f.write_str(name) - } -} -impl std::str::FromStr for UnaryOperator { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "delete" => Ok(Self::Delete), - "-" => Ok(Self::Minus), - "!" => Ok(Self::Negation), - "+" => Ok(Self::Plus), - "~" => Ok(Self::Tilde), - "typeof" => Ok(Self::Typeof), - "void" => Ok(Self::Void), - _ => Err(()), - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum UpdateOperator { - /// -- - #[serde(rename = "--")] - Decrement, - /// ++ - #[serde(rename = "++")] - Increment, -} -impl std::fmt::Display for UpdateOperator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::Decrement => "--", - Self::Increment => "++", - }; - f.write_str(name) - } -} -impl std::str::FromStr for UpdateOperator { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "--" => Ok(Self::Decrement), - "++" => Ok(Self::Increment), - _ => Err(()), - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum BinaryOperator { - /// + - #[serde(rename = "+")] - Add, - /// & - #[serde(rename = "&")] - BinaryAnd, - /// | - #[serde(rename = "|")] - BinaryOr, - /// ^ - #[serde(rename = "^")] - BinaryXor, - /// / - #[serde(rename = "/")] - Divide, - /// == - #[serde(rename = "==")] - Equals, - /// ** - #[serde(rename = "**")] - Exponent, - /// > - #[serde(rename = ">")] - GreaterThan, - /// >= - #[serde(rename = ">=")] - GreaterThanOrEqual, - /// in - #[serde(rename = "in")] - In, - /// instanceof - #[serde(rename = "instanceof")] - Instanceof, - /// < - #[serde(rename = "<")] - LessThan, - /// <= - #[serde(rename = "<=")] - LessThanOrEqual, - /// % - #[serde(rename = "%")] - Modulo, - /// * - #[serde(rename = "*")] - Multiply, - /// != - #[serde(rename = "!=")] - NotEquals, - /// !== - #[serde(rename = "!==")] - NotStrictEquals, - /// << - #[serde(rename = "<<")] - ShiftLeft, - /// >> - #[serde(rename = ">>")] - ShiftRight, - /// === - #[serde(rename = "===")] - StrictEquals, - /// - - #[serde(rename = "-")] - Subtract, - /// >>> - #[serde(rename = ">>>")] - UnsignedShiftRight, -} -impl std::fmt::Display for BinaryOperator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::Add => "+", - Self::BinaryAnd => "&", - Self::BinaryOr => "|", - Self::BinaryXor => "^", - Self::Divide => "/", - Self::Equals => "==", - Self::Exponent => "**", - Self::GreaterThan => ">", - Self::GreaterThanOrEqual => ">=", - Self::In => "in", - Self::Instanceof => "instanceof", - Self::LessThan => "<", - Self::LessThanOrEqual => "<=", - Self::Modulo => "%", - Self::Multiply => "*", - Self::NotEquals => "!=", - Self::NotStrictEquals => "!==", - Self::ShiftLeft => "<<", - Self::ShiftRight => ">>", - Self::StrictEquals => "===", - Self::Subtract => "-", - Self::UnsignedShiftRight => ">>>", - }; - f.write_str(name) - } -} -impl std::str::FromStr for BinaryOperator { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "+" => Ok(Self::Add), - "&" => Ok(Self::BinaryAnd), - "|" => Ok(Self::BinaryOr), - "^" => Ok(Self::BinaryXor), - "/" => Ok(Self::Divide), - "==" => Ok(Self::Equals), - "**" => Ok(Self::Exponent), - ">" => Ok(Self::GreaterThan), - ">=" => Ok(Self::GreaterThanOrEqual), - "in" => Ok(Self::In), - "instanceof" => Ok(Self::Instanceof), - "<" => Ok(Self::LessThan), - "<=" => Ok(Self::LessThanOrEqual), - "%" => Ok(Self::Modulo), - "*" => Ok(Self::Multiply), - "!=" => Ok(Self::NotEquals), - "!==" => Ok(Self::NotStrictEquals), - "<<" => Ok(Self::ShiftLeft), - ">>" => Ok(Self::ShiftRight), - "===" => Ok(Self::StrictEquals), - "-" => Ok(Self::Subtract), - ">>>" => Ok(Self::UnsignedShiftRight), - _ => Err(()), - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum AssignmentOperator { - /// &&= - #[serde(rename = "&&=")] - AndEquals, - /// &= - #[serde(rename = "&=")] - BinaryAndEquals, - /// |= - #[serde(rename = "|=")] - BinaryOrEquals, - /// ^= - #[serde(rename = "^=")] - BinaryXorEquals, - /// /= - #[serde(rename = "/=")] - DivideEquals, - /// = - #[serde(rename = "=")] - Equals, - /// **= - #[serde(rename = "**=")] - Exponent, - /// -= - #[serde(rename = "-=")] - MinusEquals, - /// %= - #[serde(rename = "%=")] - ModuloEquals, - /// *= - #[serde(rename = "*=")] - MultiplyEquals, - /// ??= - #[serde(rename = "??=")] - NullCoalescingEquals, - /// ||= - #[serde(rename = "||=")] - OrEquals, - /// += - #[serde(rename = "+=")] - PlusEquals, - /// <<= - #[serde(rename = "<<=")] - ShiftLeftEquals, - /// >>= - #[serde(rename = ">>=")] - ShiftRightEquals, - /// >>>= - #[serde(rename = ">>>=")] - UnsignedShiftRightEquals, -} -impl std::fmt::Display for AssignmentOperator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::AndEquals => "&&=", - Self::BinaryAndEquals => "&=", - Self::BinaryOrEquals => "|=", - Self::BinaryXorEquals => "^=", - Self::DivideEquals => "/=", - Self::Equals => "=", - Self::Exponent => "**=", - Self::MinusEquals => "-=", - Self::ModuloEquals => "%=", - Self::MultiplyEquals => "*=", - Self::NullCoalescingEquals => "??=", - Self::OrEquals => "||=", - Self::PlusEquals => "+=", - Self::ShiftLeftEquals => "<<=", - Self::ShiftRightEquals => ">>=", - Self::UnsignedShiftRightEquals => ">>>=", - }; - f.write_str(name) - } -} -impl std::str::FromStr for AssignmentOperator { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "&&=" => Ok(Self::AndEquals), - "&=" => Ok(Self::BinaryAndEquals), - "|=" => Ok(Self::BinaryOrEquals), - "^=" => Ok(Self::BinaryXorEquals), - "/=" => Ok(Self::DivideEquals), - "=" => Ok(Self::Equals), - "**=" => Ok(Self::Exponent), - "-=" => Ok(Self::MinusEquals), - "%=" => Ok(Self::ModuloEquals), - "*=" => Ok(Self::MultiplyEquals), - "??=" => Ok(Self::NullCoalescingEquals), - "||=" => Ok(Self::OrEquals), - "+=" => Ok(Self::PlusEquals), - "<<=" => Ok(Self::ShiftLeftEquals), - ">>=" => Ok(Self::ShiftRightEquals), - ">>>=" => Ok(Self::UnsignedShiftRightEquals), - _ => Err(()), - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum LogicalOperator { - /// && - #[serde(rename = "&&")] - And, - /// ?? - #[serde(rename = "??")] - NullCoalescing, - /// || - #[serde(rename = "||")] - Or, -} -impl std::fmt::Display for LogicalOperator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::And => "&&", - Self::NullCoalescing => "??", - Self::Or => "||", - }; - f.write_str(name) - } -} -impl std::str::FromStr for LogicalOperator { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "&&" => Ok(Self::And), - "??" => Ok(Self::NullCoalescing), - "||" => Ok(Self::Or), - _ => Err(()), - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum SourceType { - /// module - #[serde(rename = "module")] - Module, - /// script - #[serde(rename = "script")] - Script, -} -impl std::fmt::Display for SourceType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::Module => "module", - Self::Script => "script", - }; - f.write_str(name) - } -} -impl std::str::FromStr for SourceType { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "module" => Ok(Self::Module), - "script" => Ok(Self::Script), - _ => Err(()), - } - } -} -#[derive( - Serialize, - Deserialize, - Clone, - Copy, - Eq, - PartialEq, - Ord, - PartialOrd, - Hash, - Debug -)] -pub enum MethodKind { - /// constructor - #[serde(rename = "constructor")] - Constructor, - /// get - #[serde(rename = "get")] - Get, - /// method - #[serde(rename = "method")] - Method, - /// set - #[serde(rename = "set")] - Set, -} -impl std::fmt::Display for MethodKind { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - Self::Constructor => "constructor", - Self::Get => "get", - Self::Method => "method", - Self::Set => "set", - }; - f.write_str(name) - } -} -impl std::str::FromStr for MethodKind { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "constructor" => Ok(Self::Constructor), - "get" => Ok(Self::Get), - "method" => Ok(Self::Method), - "set" => Ok(Self::Set), - _ => Err(()), - } - } -} -pub trait Visitor { - fn visit_class(&mut self, ast: &Class) { - if let Some(id) = &ast.id { - self.visit_identifier(id); - } - if let Some(super_class) = &ast.super_class { - self.visit_expression(super_class); - } - self.visit_class_body(&ast.body); - } - fn visit_function(&mut self, ast: &Function) { - if let Some(id) = &ast.id { - self.visit_identifier(id); - } - for params in &ast.params { - self.visit_pattern(params); - } - if let Some(body) = &ast.body { - self.visit_function_body(body); - } - } - fn visit_identifier(&mut self, ast: &Identifier) { - if let Some(type_annotation) = &ast.type_annotation { - self.visit_type_annotation(type_annotation); - } - } - fn visit_literal(&mut self, ast: &Literal) {} - fn visit_numeric_literal(&mut self, ast: &NumericLiteral) {} - fn visit_boolean_literal(&mut self, ast: &BooleanLiteral) {} - fn visit_null_literal(&mut self, ast: &NullLiteral) {} - fn visit_string_literal(&mut self, ast: &StringLiteral) {} - fn visit_reg_exp_literal(&mut self, ast: &RegExpLiteral) {} - fn visit_program(&mut self, ast: &Program) { - for body in &ast.body { - self.visit_module_item(body); - } - } - fn visit_expression_statement(&mut self, ast: &ExpressionStatement) { - self.visit_expression(&ast.expression); - } - fn visit_block_statement(&mut self, ast: &BlockStatement) { - for body in &ast.body { - self.visit_statement(body); - } - } - fn visit_empty_statement(&mut self, ast: &EmptyStatement) {} - fn visit_debugger_statement(&mut self, ast: &DebuggerStatement) {} - fn visit_with_statement(&mut self, ast: &WithStatement) { - self.visit_expression(&ast.object); - self.visit_statement(&ast.body); - } - fn visit_return_statement(&mut self, ast: &ReturnStatement) { - if let Some(argument) = &ast.argument { - self.visit_expression(argument); - } - } - fn visit_labeled_statement(&mut self, ast: &LabeledStatement) { - self.visit_identifier(&ast.label); - self.visit_statement(&ast.body); - } - fn visit_break_statement(&mut self, ast: &BreakStatement) { - if let Some(label) = &ast.label { - self.visit_identifier(label); - } - } - fn visit_continue_statement(&mut self, ast: &ContinueStatement) { - if let Some(label) = &ast.label { - self.visit_identifier(label); - } - } - fn visit_if_statement(&mut self, ast: &IfStatement) { - self.visit_expression(&ast.test); - self.visit_statement(&ast.consequent); - if let Some(alternate) = &ast.alternate { - self.visit_statement(alternate); - } - } - fn visit_switch_statement(&mut self, ast: &SwitchStatement) { - self.visit_expression(&ast.discriminant); - for cases in &ast.cases { - self.visit_switch_case(cases); - } - } - fn visit_switch_case(&mut self, ast: &SwitchCase) { - if let Some(test) = &ast.test { - self.visit_expression(test); - } - for consequent in &ast.consequent { - self.visit_statement(consequent); - } - } - fn visit_throw_statement(&mut self, ast: &ThrowStatement) { - self.visit_expression(&ast.argument); - } - fn visit_try_statement(&mut self, ast: &TryStatement) { - self.visit_block_statement(&ast.block); - if let Some(handler) = &ast.handler { - self.visit_catch_clause(handler); - } - if let Some(finalizer) = &ast.finalizer { - self.visit_block_statement(finalizer); - } - } - fn visit_catch_clause(&mut self, ast: &CatchClause) { - if let Some(param) = &ast.param { - self.visit_pattern(param); - } - self.visit_block_statement(&ast.body); - } - fn visit_while_statement(&mut self, ast: &WhileStatement) { - self.visit_expression(&ast.test); - self.visit_statement(&ast.body); - } - fn visit_do_while_statement(&mut self, ast: &DoWhileStatement) { - self.visit_statement(&ast.body); - self.visit_expression(&ast.test); - } - fn visit_for_statement(&mut self, ast: &ForStatement) { - if let Some(init) = &ast.init { - self.visit_for_init(init); - } - if let Some(test) = &ast.test { - self.visit_expression(test); - } - if let Some(update) = &ast.update { - self.visit_expression(update); - } - self.visit_statement(&ast.body); - } - fn visit_for_in_statement(&mut self, ast: &ForInStatement) { - self.visit_for_in_init(&ast.left); - self.visit_expression(&ast.right); - self.visit_statement(&ast.body); - } - fn visit_for_of_statement(&mut self, ast: &ForOfStatement) { - self.visit_for_in_init(&ast.left); - self.visit_expression(&ast.right); - self.visit_statement(&ast.body); - } - fn visit_function_declaration(&mut self, ast: &FunctionDeclaration) { - self.visit_function(&ast.function); - } - fn visit_class_declaration(&mut self, ast: &ClassDeclaration) { - self.visit_class(&ast.class); - } - fn visit_class_expression(&mut self, ast: &ClassExpression) { - self.visit_class(&ast.class); - } - fn visit_class_body(&mut self, ast: &ClassBody) { - for body in &ast.body { - self.visit_class_item(body); - } - } - fn visit_method_definition(&mut self, ast: &MethodDefinition) { - self.visit_expression(&ast.key); - self.visit_function_expression(&ast.value); - } - fn visit_variable_declaration(&mut self, ast: &VariableDeclaration) { - for declarations in &ast.declarations { - self.visit_variable_declarator(declarations); - } - } - fn visit_variable_declarator(&mut self, ast: &VariableDeclarator) { - self.visit_pattern(&ast.id); - if let Some(init) = &ast.init { - self.visit_expression(init); - } - } - fn visit_this_expression(&mut self, ast: &ThisExpression) {} - fn visit_array_expression(&mut self, ast: &ArrayExpression) { - for elements in &ast.elements { - if let Some(elements) = elements { - self.visit_expression_or_spread(elements); - } - } - } - fn visit_object_expression(&mut self, ast: &ObjectExpression) { - for properties in &ast.properties { - self.visit_property_or_spread_element(properties); - } - } - fn visit_property(&mut self, ast: &Property) { - self.visit_expression(&ast.key); - self.visit_expression(&ast.value); - } - fn visit_function_expression(&mut self, ast: &FunctionExpression) { - self.visit_function(&ast.function); - } - fn visit_arrow_function_expression(&mut self, ast: &ArrowFunctionExpression) { - self.visit_function(&ast.function); - } - fn visit_unary_expression(&mut self, ast: &UnaryExpression) { - self.visit_expression(&ast.argument); - } - fn visit_update_expression(&mut self, ast: &UpdateExpression) { - self.visit_expression(&ast.argument); - } - fn visit_binary_expression(&mut self, ast: &BinaryExpression) { - self.visit_expression(&ast.left); - self.visit_expression(&ast.right); - } - fn visit_assignment_expression(&mut self, ast: &AssignmentExpression) { - self.visit_assignment_target(&ast.left); - self.visit_expression(&ast.right); - } - fn visit_logical_expression(&mut self, ast: &LogicalExpression) { - self.visit_expression(&ast.left); - self.visit_expression(&ast.right); - } - fn visit_member_expression(&mut self, ast: &MemberExpression) { - self.visit_expression_or_super(&ast.object); - self.visit_expression_or_private_identifier(&ast.property); - } - fn visit_conditional_expression(&mut self, ast: &ConditionalExpression) { - self.visit_expression(&ast.test); - self.visit_expression(&ast.alternate); - self.visit_expression(&ast.consequent); - } - fn visit_call_expression(&mut self, ast: &CallExpression) { - self.visit_expression_or_super(&ast.callee); - for arguments in &ast.arguments { - self.visit_expression_or_spread(arguments); - } - } - fn visit_new_expression(&mut self, ast: &NewExpression) { - self.visit_expression(&ast.callee); - for arguments in &ast.arguments { - self.visit_expression_or_spread(arguments); - } - } - fn visit_sequence_expression(&mut self, ast: &SequenceExpression) { - for expressions in &ast.expressions { - self.visit_expression(expressions); - } - } - fn visit_super(&mut self, ast: &Super) {} - fn visit_spread_element(&mut self, ast: &SpreadElement) { - self.visit_expression(&ast.argument); - } - fn visit_yield_expression(&mut self, ast: &YieldExpression) { - if let Some(argument) = &ast.argument { - self.visit_expression(argument); - } - } - fn visit_import_declaration(&mut self, ast: &ImportDeclaration) { - for specifiers in &ast.specifiers { - self.visit_import_declaration_specifier(specifiers); - } - self.visit___literal(&ast.source); - } - fn visit_import_specifier(&mut self, ast: &ImportSpecifier) { - self.visit_identifier(&ast.imported); - self.visit_identifier(&ast.local); - } - fn visit_import_default_specifier(&mut self, ast: &ImportDefaultSpecifier) { - self.visit_identifier(&ast.local); - } - fn visit_import_namespace_specifier(&mut self, ast: &ImportNamespaceSpecifier) { - self.visit_identifier(&ast.local); - } - fn visit_export_named_declaration(&mut self, ast: &ExportNamedDeclaration) { - if let Some(declaration) = &ast.declaration { - self.visit_declaration(declaration); - } - for specifiers in &ast.specifiers { - self.visit_export_specifier(specifiers); - } - if let Some(source) = &ast.source { - self.visit___literal(source); - } - } - fn visit_export_specifier(&mut self, ast: &ExportSpecifier) { - self.visit_identifier(&ast.exported); - } - fn visit_export_default_declaration(&mut self, ast: &ExportDefaultDeclaration) { - self.visit_declaration_or_expression(&ast.declaration); - } - fn visit_export_all_declaration(&mut self, ast: &ExportAllDeclaration) { - self.visit___literal(&ast.source); - if let Some(exported) = &ast.exported { - self.visit_identifier(exported); - } - } - fn visit_jsxidentifier(&mut self, ast: &JSXIdentifier) {} - fn visit_jsxnamespaced_name(&mut self, ast: &JSXNamespacedName) { - self.visit_jsxidentifier(&ast.namespace); - self.visit_jsxidentifier(&ast.name); - } - fn visit_jsxmember_expression(&mut self, ast: &JSXMemberExpression) { - self.visit_jsxmember_expression_or_identifier(&ast.object); - self.visit_jsxidentifier(&ast.property); - } - fn visit_jsxempty_expression(&mut self, ast: &JSXEmptyExpression) {} - fn visit_jsxexpression_container(&mut self, ast: &JSXExpressionContainer) { - self.visit_jsxexpression_or_empty(&ast.expression); - } - fn visit_jsxspread_child(&mut self, ast: &JSXSpreadChild) { - self.visit_expression(&ast.expression); - } - fn visit_jsxopening_element(&mut self, ast: &JSXOpeningElement) { - self.visit_jsxelement_name(&ast.name); - for attributes in &ast.attributes { - self.visit_jsxattribute_or_spread(attributes); - } - } - fn visit_jsxclosing_element(&mut self, ast: &JSXClosingElement) { - self.visit_jsxelement_name(&ast.name); - } - fn visit_jsxattribute(&mut self, ast: &JSXAttribute) { - self.visit_jsxidentifier_or_namespaced_name(&ast.name); - if let Some(value) = &ast.value { - self.visit_jsxattribute_value(value); - } - } - fn visit_jsxspread_attribute(&mut self, ast: &JSXSpreadAttribute) { - self.visit_expression(&ast.argument); - } - fn visit_jsxtext(&mut self, ast: &JSXText) {} - fn visit_jsxstring_literal(&mut self, ast: &JSXStringLiteral) {} - fn visit_jsxelement(&mut self, ast: &JSXElement) { - self.visit_jsxopening_element(&ast.opening_element); - for children in &ast.children { - self.visit_jsxchild_item(children); - } - if let Some(closing_element) = &ast.closing_element { - self.visit_jsxclosing_element(closing_element); - } - } - fn visit_jsxfragment(&mut self, ast: &JSXFragment) { - self.visit_jsxopening_fragment(&ast.opening_fragment); - for children in &ast.children { - self.visit_jsxchild_item(children); - } - self.visit_jsxclosing_fragment(&ast.closing_fragment); - } - fn visit_jsxopening_fragment(&mut self, ast: &JSXOpeningFragment) {} - fn visit_jsxclosing_fragment(&mut self, ast: &JSXClosingFragment) {} - fn visit_array_pattern(&mut self, ast: &ArrayPattern) { - for elements in &ast.elements { - if let Some(elements) = elements { - self.visit_pattern(elements); - } - } - } - fn visit_object_pattern(&mut self, ast: &ObjectPattern) { - for properties in &ast.properties { - self.visit_assignment_property_or_rest_element(properties); - } - } - fn visit_assignment_property(&mut self, ast: &AssignmentProperty) { - self.visit_expression(&ast.key); - self.visit_pattern(&ast.value); - } - fn visit_rest_element(&mut self, ast: &RestElement) { - self.visit_pattern(&ast.argument); - } - fn visit_assignment_pattern(&mut self, ast: &AssignmentPattern) { - self.visit_pattern(&ast.left); - self.visit_expression(&ast.right); - } - fn visit_template_literal(&mut self, ast: &TemplateLiteral) { - for quasis in &ast.quasis { - self.visit_template_element(quasis); - } - for expressions in &ast.expressions { - self.visit_expression(expressions); - } - } - fn visit_template_element(&mut self, ast: &TemplateElement) {} - fn visit_tagged_template_expression(&mut self, ast: &TaggedTemplateExpression) { - self.visit_expression(&ast.tag); - self.visit_template_literal(&ast.quasi); - } - fn visit_meta_property(&mut self, ast: &MetaProperty) { - self.visit_identifier(&ast.meta); - self.visit_identifier(&ast.property); - } - fn visit_await_expression(&mut self, ast: &AwaitExpression) { - self.visit_expression(&ast.argument); - } - fn visit_chain_expression(&mut self, ast: &ChainExpression) { - self.visit_chain_element(&ast.expression); - } - fn visit_optional_member_expression(&mut self, ast: &OptionalMemberExpression) { - self.visit_expression(&ast.object); - self.visit_expression(&ast.property); - } - fn visit_optional_call_expression(&mut self, ast: &OptionalCallExpression) { - self.visit_expression_or_super(&ast.callee); - for arguments in &ast.arguments { - self.visit_expression_or_spread(arguments); - } - } - fn visit_import_expression(&mut self, ast: &ImportExpression) { - self.visit_expression(&ast.source); - } - fn visit_class_property(&mut self, ast: &ClassProperty) { - self.visit_expression(&ast.key); - if let Some(value) = &ast.value { - self.visit_expression(value); - } - } - fn visit_class_private_property(&mut self, ast: &ClassPrivateProperty) { - self.visit_expression_or_private_identifier(&ast.key); - if let Some(value) = &ast.value { - self.visit_expression(value); - } - } - fn visit_private_name(&mut self, ast: &PrivateName) { - self.visit_identifier(&ast.id); - } - fn visit_private_identifier(&mut self, ast: &PrivateIdentifier) {} - fn visit_static_block(&mut self, ast: &StaticBlock) { - for body in &ast.body { - self.visit_statement(body); - } - } - fn visit_cover_typed_identifier(&mut self, ast: &CoverTypedIdentifier) { - self.visit_identifier(&ast.left); - if let Some(right) = &ast.right { - self.visit_type_annotation(right); - } - } - fn visit_tstype_annotation(&mut self, ast: &TSTypeAnnotation) {} - fn visit_tstype_alias_declaration(&mut self, ast: &TSTypeAliasDeclaration) {} - fn visit_statement(&mut self, ast: &Statement) { - match ast { - Statement::BlockStatement(ast) => { - self.visit_block_statement(ast); - } - Statement::BreakStatement(ast) => { - self.visit_break_statement(ast); - } - Statement::ClassDeclaration(ast) => { - self.visit_class_declaration(ast); - } - Statement::ContinueStatement(ast) => { - self.visit_continue_statement(ast); - } - Statement::DebuggerStatement(ast) => { - self.visit_debugger_statement(ast); - } - Statement::DoWhileStatement(ast) => { - self.visit_do_while_statement(ast); - } - Statement::EmptyStatement(ast) => { - self.visit_empty_statement(ast); - } - Statement::ExpressionStatement(ast) => { - self.visit_expression_statement(ast); - } - Statement::ForInStatement(ast) => { - self.visit_for_in_statement(ast); - } - Statement::ForOfStatement(ast) => { - self.visit_for_of_statement(ast); - } - Statement::ForStatement(ast) => { - self.visit_for_statement(ast); - } - Statement::FunctionDeclaration(ast) => { - self.visit_function_declaration(ast); - } - Statement::IfStatement(ast) => { - self.visit_if_statement(ast); - } - Statement::LabeledStatement(ast) => { - self.visit_labeled_statement(ast); - } - Statement::ReturnStatement(ast) => { - self.visit_return_statement(ast); - } - Statement::SwitchStatement(ast) => { - self.visit_switch_statement(ast); - } - Statement::ThrowStatement(ast) => { - self.visit_throw_statement(ast); - } - Statement::TryStatement(ast) => { - self.visit_try_statement(ast); - } - Statement::TSTypeAliasDeclaration(ast) => { - self.visit_tstype_alias_declaration(ast); - } - Statement::VariableDeclaration(ast) => { - self.visit_variable_declaration(ast); - } - Statement::WhileStatement(ast) => { - self.visit_while_statement(ast); - } - Statement::WithStatement(ast) => { - self.visit_with_statement(ast); - } - } - } - fn visit_expression(&mut self, ast: &Expression) { - match ast { - Expression::ArrayExpression(ast) => { - self.visit_array_expression(ast); - } - Expression::ArrowFunctionExpression(ast) => { - self.visit_arrow_function_expression(ast); - } - Expression::AssignmentExpression(ast) => { - self.visit_assignment_expression(ast); - } - Expression::AwaitExpression(ast) => { - self.visit_await_expression(ast); - } - Expression::BinaryExpression(ast) => { - self.visit_binary_expression(ast); - } - Expression::BooleanLiteral(ast) => { - self.visit_boolean_literal(ast); - } - Expression::CallExpression(ast) => { - self.visit_call_expression(ast); - } - Expression::ChainExpression(ast) => { - self.visit_chain_expression(ast); - } - Expression::ClassExpression(ast) => { - self.visit_class_expression(ast); - } - Expression::ConditionalExpression(ast) => { - self.visit_conditional_expression(ast); - } - Expression::CoverTypedIdentifier(ast) => { - self.visit_cover_typed_identifier(ast); - } - Expression::FunctionExpression(ast) => { - self.visit_function_expression(ast); - } - Expression::Identifier(ast) => { - self.visit_identifier(ast); - } - Expression::ImportExpression(ast) => { - self.visit_import_expression(ast); - } - Expression::JSXElement(ast) => { - self.visit_jsxelement(ast); - } - Expression::JSXFragment(ast) => { - self.visit_jsxfragment(ast); - } - Expression::Literal(ast) => { - self.visit_literal(ast); - } - Expression::LogicalExpression(ast) => { - self.visit_logical_expression(ast); - } - Expression::MemberExpression(ast) => { - self.visit_member_expression(ast); - } - Expression::MetaProperty(ast) => { - self.visit_meta_property(ast); - } - Expression::NewExpression(ast) => { - self.visit_new_expression(ast); - } - Expression::NullLiteral(ast) => { - self.visit_null_literal(ast); - } - Expression::NumericLiteral(ast) => { - self.visit_numeric_literal(ast); - } - Expression::ObjectExpression(ast) => { - self.visit_object_expression(ast); - } - Expression::OptionalCallExpression(ast) => { - self.visit_optional_call_expression(ast); - } - Expression::OptionalMemberExpression(ast) => { - self.visit_optional_member_expression(ast); - } - Expression::RegExpLiteral(ast) => { - self.visit_reg_exp_literal(ast); - } - Expression::SequenceExpression(ast) => { - self.visit_sequence_expression(ast); - } - Expression::StringLiteral(ast) => { - self.visit_string_literal(ast); - } - Expression::TaggedTemplateExpression(ast) => { - self.visit_tagged_template_expression(ast); - } - Expression::TemplateLiteral(ast) => { - self.visit_template_literal(ast); - } - Expression::ThisExpression(ast) => { - self.visit_this_expression(ast); - } - Expression::UnaryExpression(ast) => { - self.visit_unary_expression(ast); - } - Expression::UpdateExpression(ast) => { - self.visit_update_expression(ast); - } - Expression::YieldExpression(ast) => { - self.visit_yield_expression(ast); - } - } - } - fn visit___literal(&mut self, ast: &_Literal) { - match ast { - _Literal::Literal(ast) => { - self.visit_literal(ast); - } - _Literal::BooleanLiteral(ast) => { - self.visit_boolean_literal(ast); - } - _Literal::NullLiteral(ast) => { - self.visit_null_literal(ast); - } - _Literal::StringLiteral(ast) => { - self.visit_string_literal(ast); - } - _Literal::NumericLiteral(ast) => { - self.visit_numeric_literal(ast); - } - } - } - fn visit_declaration(&mut self, ast: &Declaration) { - match ast { - Declaration::ClassDeclaration(ast) => { - self.visit_class_declaration(ast); - } - Declaration::FunctionDeclaration(ast) => { - self.visit_function_declaration(ast); - } - Declaration::VariableDeclaration(ast) => { - self.visit_variable_declaration(ast); - } - Declaration::TSTypeAliasDeclaration(ast) => { - self.visit_tstype_alias_declaration(ast); - } - } - } - fn visit_import_declaration_specifier(&mut self, ast: &ImportDeclarationSpecifier) { - match ast { - ImportDeclarationSpecifier::ImportSpecifier(ast) => { - self.visit_import_specifier(ast); - } - ImportDeclarationSpecifier::ImportDefaultSpecifier(ast) => { - self.visit_import_default_specifier(ast); - } - ImportDeclarationSpecifier::ImportNamespaceSpecifier(ast) => { - self.visit_import_namespace_specifier(ast); - } - } - } - fn visit_module_item(&mut self, ast: &ModuleItem) { - match ast { - ModuleItem::ImportOrExportDeclaration(ast) => { - self.visit_import_or_export_declaration(ast); - } - ModuleItem::Statement(ast) => { - self.visit_statement(ast); - } - } - } - fn visit_import_or_export_declaration(&mut self, ast: &ImportOrExportDeclaration) { - match ast { - ImportOrExportDeclaration::ImportDeclaration(ast) => { - self.visit_import_declaration(ast); - } - ImportOrExportDeclaration::ExportNamedDeclaration(ast) => { - self.visit_export_named_declaration(ast); - } - ImportOrExportDeclaration::ExportDefaultDeclaration(ast) => { - self.visit_export_default_declaration(ast); - } - ImportOrExportDeclaration::ExportAllDeclaration(ast) => { - self.visit_export_all_declaration(ast); - } - } - } - fn visit_expression_or_super(&mut self, ast: &ExpressionOrSuper) { - match ast { - ExpressionOrSuper::Expression(ast) => { - self.visit_expression(ast); - } - ExpressionOrSuper::Super(ast) => { - self.visit_super(ast); - } - } - } - fn visit_expression_or_spread(&mut self, ast: &ExpressionOrSpread) { - match ast { - ExpressionOrSpread::Expression(ast) => { - self.visit_expression(ast); - } - ExpressionOrSpread::SpreadElement(ast) => { - self.visit_spread_element(ast); - } - } - } - fn visit_function_body(&mut self, ast: &FunctionBody) { - match ast { - FunctionBody::BlockStatement(ast) => { - self.visit_block_statement(ast); - } - FunctionBody::Expression(ast) => { - self.visit_expression(ast); - } - } - } - fn visit_pattern(&mut self, ast: &Pattern) { - match ast { - Pattern::Identifier(ast) => { - self.visit_identifier(ast); - } - Pattern::ArrayPattern(ast) => { - self.visit_array_pattern(ast); - } - Pattern::ObjectPattern(ast) => { - self.visit_object_pattern(ast); - } - Pattern::RestElement(ast) => { - self.visit_rest_element(ast); - } - Pattern::AssignmentPattern(ast) => { - self.visit_assignment_pattern(ast); - } - } - } - fn visit_for_init(&mut self, ast: &ForInit) { - match ast { - ForInit::Expression(ast) => { - self.visit_expression(ast); - } - ForInit::VariableDeclaration(ast) => { - self.visit_variable_declaration(ast); - } - } - } - fn visit_for_in_init(&mut self, ast: &ForInInit) { - match ast { - ForInInit::Pattern(ast) => { - self.visit_pattern(ast); - } - ForInInit::VariableDeclaration(ast) => { - self.visit_variable_declaration(ast); - } - } - } - fn visit_property_or_spread_element(&mut self, ast: &PropertyOrSpreadElement) { - match ast { - PropertyOrSpreadElement::Property(ast) => { - self.visit_property(ast); - } - PropertyOrSpreadElement::SpreadElement(ast) => { - self.visit_spread_element(ast); - } - } - } - fn visit_assignment_property_or_rest_element( - &mut self, - ast: &AssignmentPropertyOrRestElement, - ) { - match ast { - AssignmentPropertyOrRestElement::AssignmentProperty(ast) => { - self.visit_assignment_property(ast); - } - AssignmentPropertyOrRestElement::RestElement(ast) => { - self.visit_rest_element(ast); - } - } - } - fn visit_assignment_target(&mut self, ast: &AssignmentTarget) { - match ast { - AssignmentTarget::Pattern(ast) => { - self.visit_pattern(ast); - } - AssignmentTarget::Expression(ast) => { - self.visit_expression(ast); - } - } - } - fn visit_chain_element(&mut self, ast: &ChainElement) { - match ast { - ChainElement::CallExpression(ast) => { - self.visit_call_expression(ast); - } - ChainElement::MemberExpression(ast) => { - self.visit_member_expression(ast); - } - } - } - fn visit_jsxmember_expression_or_identifier( - &mut self, - ast: &JSXMemberExpressionOrIdentifier, - ) { - match ast { - JSXMemberExpressionOrIdentifier::JSXMemberExpression(ast) => { - self.visit_jsxmember_expression(ast); - } - JSXMemberExpressionOrIdentifier::JSXIdentifier(ast) => { - self.visit_jsxidentifier(ast); - } - } - } - fn visit_jsxexpression_or_empty(&mut self, ast: &JSXExpressionOrEmpty) { - match ast { - JSXExpressionOrEmpty::Expression(ast) => { - self.visit_expression(ast); - } - JSXExpressionOrEmpty::JSXEmptyExpression(ast) => { - self.visit_jsxempty_expression(ast); - } - } - } - fn visit_jsxattribute_or_spread(&mut self, ast: &JSXAttributeOrSpread) { - match ast { - JSXAttributeOrSpread::JSXAttribute(ast) => { - self.visit_jsxattribute(ast); - } - JSXAttributeOrSpread::JSXSpreadAttribute(ast) => { - self.visit_jsxspread_attribute(ast); - } - } - } - fn visit_jsxattribute_value(&mut self, ast: &JSXAttributeValue) { - match ast { - JSXAttributeValue::Literal(ast) => { - self.visit_literal(ast); - } - JSXAttributeValue::JSXExpressionContainer(ast) => { - self.visit_jsxexpression_container(ast); - } - JSXAttributeValue::JSXElement(ast) => { - self.visit_jsxelement(ast); - } - JSXAttributeValue::JSXFragment(ast) => { - self.visit_jsxfragment(ast); - } - JSXAttributeValue::JSXStringLiteral(ast) => { - self.visit_jsxstring_literal(ast); - } - } - } - fn visit_jsxelement_name(&mut self, ast: &JSXElementName) { - match ast { - JSXElementName::JSXIdentifier(ast) => { - self.visit_jsxidentifier(ast); - } - JSXElementName::JSXMemberExpression(ast) => { - self.visit_jsxmember_expression(ast); - } - JSXElementName::JSXNamespacedName(ast) => { - self.visit_jsxnamespaced_name(ast); - } - } - } - fn visit_jsxidentifier_or_namespaced_name( - &mut self, - ast: &JSXIdentifierOrNamespacedName, - ) { - match ast { - JSXIdentifierOrNamespacedName::JSXIdentifier(ast) => { - self.visit_jsxidentifier(ast); - } - JSXIdentifierOrNamespacedName::JSXNamespacedName(ast) => { - self.visit_jsxnamespaced_name(ast); - } - } - } - fn visit_jsxchild_item(&mut self, ast: &JSXChildItem) { - match ast { - JSXChildItem::JSXText(ast) => { - self.visit_jsxtext(ast); - } - JSXChildItem::JSXStringLiteral(ast) => { - self.visit_jsxstring_literal(ast); - } - JSXChildItem::JSXExpressionContainer(ast) => { - self.visit_jsxexpression_container(ast); - } - JSXChildItem::JSXSpreadChild(ast) => { - self.visit_jsxspread_child(ast); - } - JSXChildItem::JSXElement(ast) => { - self.visit_jsxelement(ast); - } - JSXChildItem::JSXFragment(ast) => { - self.visit_jsxfragment(ast); - } - } - } - fn visit_declaration_or_expression(&mut self, ast: &DeclarationOrExpression) { - match ast { - DeclarationOrExpression::Declaration(ast) => { - self.visit_declaration(ast); - } - DeclarationOrExpression::Expression(ast) => { - self.visit_expression(ast); - } - } - } - fn visit_class_item(&mut self, ast: &ClassItem) { - match ast { - ClassItem::MethodDefinition(ast) => { - self.visit_method_definition(ast); - } - ClassItem::ClassProperty(ast) => { - self.visit_class_property(ast); - } - ClassItem::ClassPrivateProperty(ast) => { - self.visit_class_private_property(ast); - } - ClassItem::StaticBlock(ast) => { - self.visit_static_block(ast); - } - } - } - fn visit_expression_or_private_identifier( - &mut self, - ast: &ExpressionOrPrivateIdentifier, - ) { - match ast { - ExpressionOrPrivateIdentifier::Expression(ast) => { - self.visit_expression(ast); - } - ExpressionOrPrivateIdentifier::PrivateIdentifier(ast) => { - self.visit_private_identifier(ast); - } - ExpressionOrPrivateIdentifier::PrivateName(ast) => { - self.visit_private_name(ast); - } - } - } - fn visit_type_annotation(&mut self, ast: &TypeAnnotation) { - match ast { - TypeAnnotation::TSTypeAnnotation(ast) => { - self.visit_tstype_annotation(ast); - } - } - } -} diff --git a/compiler/crates/react_estree/src/generated_extensions.rs b/compiler/crates/react_estree/src/generated_extensions.rs deleted file mode 100644 index 8bb944cfe5429..0000000000000 --- a/compiler/crates/react_estree/src/generated_extensions.rs +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// Manual extensions to generated types -use crate::{ - ArrowFunctionExpression, Class, ClassDeclaration, ClassExpression, Function, - FunctionDeclaration, FunctionExpression, ImportDeclarationSpecifier, JSXElementName, - JSXMemberExpression, JSXMemberExpressionOrIdentifier, Pattern, SourceRange, SourceType, -}; - -/// Sentinel trait to distinguish AST *node* types -pub trait ESTreeNode {} - -impl Default for SourceType { - fn default() -> Self { - Self::Module - } -} - -impl Pattern { - pub fn range(&self) -> Option { - match self { - Self::ArrayPattern(pattern) => pattern.range, - Self::AssignmentPattern(pattern) => pattern.range, - Self::Identifier(pattern) => pattern.range, - Self::ObjectPattern(pattern) => pattern.range, - Self::RestElement(pattern) => pattern.range, - } - } -} - -impl ImportDeclarationSpecifier { - pub fn range(&self) -> Option { - match self { - Self::ImportDefaultSpecifier(specifier) => specifier.range, - Self::ImportNamespaceSpecifier(specifier) => specifier.range, - Self::ImportSpecifier(specifier) => specifier.range, - } - } -} - -impl JSXElementName { - pub fn root_name(&self) -> &str { - match self { - Self::JSXIdentifier(name) => &name.name, - Self::JSXMemberExpression(name) => name.root_name(), - Self::JSXNamespacedName(name) => &name.namespace.name, - } - } -} - -impl JSXMemberExpression { - pub fn root_name(&self) -> &str { - match &self.object { - JSXMemberExpressionOrIdentifier::JSXMemberExpression(object) => object.root_name(), - JSXMemberExpressionOrIdentifier::JSXIdentifier(object) => &object.name, - } - } -} - -pub trait IntoFunction: ESTreeNode { - fn function(&self) -> &Function; - - fn into_function(self) -> Function; -} - -impl IntoFunction for FunctionDeclaration { - fn function(&self) -> &Function { - &self.function - } - - fn into_function(self) -> Function { - self.function - } -} - -impl IntoFunction for FunctionExpression { - fn function(&self) -> &Function { - &self.function - } - - fn into_function(self) -> Function { - self.function - } -} - -impl IntoFunction for ArrowFunctionExpression { - fn function(&self) -> &Function { - &self.function - } - - fn into_function(self) -> Function { - self.function - } -} - -impl ESTreeNode for Function {} - -impl IntoFunction for Function { - fn function(&self) -> &Function { - self - } - - fn into_function(self) -> Function { - self - } -} - -pub trait IntoClass: ESTreeNode { - fn class(&self) -> &Class; - - fn into_class(self) -> Class; -} - -impl IntoClass for ClassDeclaration { - fn class(&self) -> &Class { - &self.class - } - - fn into_class(self) -> Class { - self.class - } -} - -impl IntoClass for ClassExpression { - fn class(&self) -> &Class { - &self.class - } - - fn into_class(self) -> Class { - self.class - } -} - -impl ESTreeNode for Class {} - -impl IntoClass for Class { - fn class(&self) -> &Class { - self - } - - fn into_class(self) -> Class { - self - } -} diff --git a/compiler/crates/react_estree/src/js_value.rs b/compiler/crates/react_estree/src/js_value.rs deleted file mode 100644 index 5b642da939057..0000000000000 --- a/compiler/crates/react_estree/src/js_value.rs +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use serde::de::Visitor; -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum JsValue { - Boolean(bool), - Null, - Number(Number), - String(String), - Undefined, -} - -impl JsValue { - pub fn is_truthy(&self) -> bool { - match &self { - JsValue::Boolean(value) => *value, - JsValue::Number(value) => value.is_truthy(), - JsValue::String(value) => !value.is_empty(), - JsValue::Null => false, - JsValue::Undefined => false, - } - } - - // Partial implementation of loose equality for javascript, returns Some for supported - // cases w the equality result, and None for unsupported cases - pub fn loosely_equals(&self, other: &Self) -> Option { - // https://tc39.es/ecma262/multipage/abstract-operations.html#sec-islooselyequal - match (&self, &other) { - // 1. If Type(x) is Type(y), then - // a. Return IsStrictlyEqual(x, y). - (JsValue::Number(left), JsValue::Number(right)) => Some(left.equals(*right)), - (JsValue::Null, JsValue::Null) => Some(true), - (JsValue::Undefined, JsValue::Undefined) => Some(true), - (JsValue::Boolean(left), JsValue::Boolean(right)) => Some(left == right), - (JsValue::String(left), JsValue::String(right)) => Some(left == right), - - // 2. If x is null and y is undefined, return true. - (JsValue::Null, JsValue::Undefined) => Some(true), - - // 3. If x is undefined and y is null, return true. - (JsValue::Undefined, JsValue::Null) => Some(true), - _ => None, - } - } - - pub fn not_loosely_equals(&self, other: &Self) -> Option { - self.loosely_equals(other).map(|value| !value) - } - - // Complete implementation of strict equality for javascript - pub fn strictly_equals(&self, other: &Self) -> bool { - // https://tc39.es/ecma262/multipage/abstract-operations.html#sec-isstrictlyequal - match (&self, &other) { - (JsValue::Number(left), JsValue::Number(right)) => left.equals(*right), - (JsValue::Null, JsValue::Null) => true, - (JsValue::Undefined, JsValue::Undefined) => true, - (JsValue::Boolean(left), JsValue::Boolean(right)) => left == right, - (JsValue::String(left), JsValue::String(right)) => left == right, - _ => false, - } - } - - pub fn not_strictly_equals(&self, other: &Self) -> bool { - !self.strictly_equals(other) - } -} - -impl Serialize for JsValue { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - match self { - Self::Boolean(b) => serializer.serialize_bool(*b), - Self::Null => serializer.serialize_none(), - Self::Number(n) => serializer.serialize_f64(n.into()), - Self::String(s) => serializer.serialize_str(s), - Self::Undefined => serializer.serialize_unit(), - } - } -} - -impl<'de> Deserialize<'de> for JsValue { - #[inline] - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - struct ValueVisitor; - - impl<'de> Visitor<'de> for ValueVisitor { - type Value = JsValue; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("valid primitive JSON value (null, boolean, number, or string") - } - - #[inline] - fn visit_bool(self, value: bool) -> Result { - Ok(JsValue::Boolean(value)) - } - - #[inline] - fn visit_i64(self, value: i64) -> Result { - if (MIN_SAFE_INT..=MAX_SAFE_INT).contains(&value) { - Ok(JsValue::Number((value as f64).into())) - } else { - panic!("Invalid number") - } - } - - #[inline] - fn visit_u64(self, value: u64) -> Result { - if value as i64 <= MAX_SAFE_INT { - Ok(JsValue::Number((value as f64).into())) - } else { - panic!("Invalid number") - } - } - - #[inline] - fn visit_f64(self, value: f64) -> Result { - Ok(JsValue::Number(value.into())) - } - - #[inline] - fn visit_str(self, value: &str) -> Result - where - E: serde::de::Error, - { - self.visit_string(String::from(value)) - } - - #[inline] - fn visit_string(self, value: String) -> Result { - Ok(JsValue::String(value)) - } - - #[inline] - fn visit_none(self) -> Result { - Ok(JsValue::Null) - } - - #[inline] - fn visit_some(self, deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - Deserialize::deserialize(deserializer) - } - - #[inline] - fn visit_unit(self) -> Result { - Ok(JsValue::Undefined) - } - } - - deserializer.deserialize_any(ValueVisitor) - } -} - -/// Represents a JavaScript Number as its binary representation so that -/// -1 == -1, NaN == Nan etc. -/// Note: NaN is *always* represented as the f64::NAN constant to allow -/// comparison of NaNs. -#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Debug, Hash)] -pub struct Number(u64); - -pub const MAX_SAFE_INT: i64 = 9007199254740991; -pub const MIN_SAFE_INT: i64 = -9007199254740991; - -impl From for Number { - fn from(value: f64) -> Self { - if value.is_nan() { - Self(f64::NAN.to_bits()) - } else { - Self(value.to_bits()) - } - } -} - -impl From for Number { - fn from(value: u32) -> Self { - f64::from(value).into() - } -} - -impl From for f64 { - fn from(number: Number) -> Self { - let value = f64::from_bits(number.0); - assert!(!f64::is_nan(value) || number.0 == f64::NAN.to_bits()); - value - } -} - -impl From<&Number> for f64 { - fn from(number: &Number) -> Self { - let value = f64::from_bits(number.0); - assert!(!f64::is_nan(value) || number.0 == f64::NAN.to_bits()); - value - } -} - -impl Number { - pub fn equals(self, other: Self) -> bool { - f64::from(self) == f64::from(other) - } - - pub fn not_equals(self, other: Self) -> bool { - !self.equals(other) - } - - pub fn is_truthy(self) -> bool { - let value = f64::from(self); - !(self.0 == f64::NAN.to_bits() || value == 0.0 || value == -0.0) - } -} - -impl std::ops::Add for Number { - type Output = Number; - - fn add(self, rhs: Self) -> Self::Output { - let result = f64::from(self) + f64::from(rhs); - Self::from(result) - } -} - -impl std::ops::Sub for Number { - type Output = Number; - - fn sub(self, rhs: Self) -> Self::Output { - let result = f64::from(self) - f64::from(rhs); - Self::from(result) - } -} - -impl std::ops::Mul for Number { - type Output = Number; - - fn mul(self, rhs: Self) -> Self::Output { - let result = f64::from(self) * f64::from(rhs); - Self::from(result) - } -} - -impl std::ops::Div for Number { - type Output = Number; - - fn div(self, rhs: Self) -> Self::Output { - let result = f64::from(self) / f64::from(rhs); - Self::from(result) - } -} - -impl Serialize for Number { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - serializer.serialize_f64(self.into()) - } -} - -impl<'de> Deserialize<'de> for Number { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - struct ValueVisitor; - - impl<'de> Visitor<'de> for ValueVisitor { - type Value = Number; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("value JavaScript number value") - } - - fn visit_f64(self, v: f64) -> Result - where - E: serde::de::Error, - { - Ok(v.into()) - } - } - - deserializer.deserialize_any(ValueVisitor) - } -} diff --git a/compiler/crates/react_estree/src/lib.rs b/compiler/crates/react_estree/src/lib.rs deleted file mode 100644 index 9cc1c3d9c3b33..0000000000000 --- a/compiler/crates/react_estree/src/lib.rs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -mod binding; -mod generated; -mod generated_extensions; -mod js_value; -mod range; -mod visit; - -pub use binding::{Binding, BindingId}; -pub use generated::*; -pub use generated_extensions::*; -pub use js_value::{JsValue, Number}; -pub use range::SourceRange; -pub use visit::*; - -#[cfg(test)] -mod tests { - use insta::{assert_snapshot, glob}; - - use super::*; - - #[test] - fn fixtures() { - glob!("fixtures/**.json", |path| { - println!("{:?}", path); - let input = std::fs::read_to_string(path).unwrap(); - let ast: Program = serde_json::from_str(&input).unwrap(); - let serialized = serde_json::to_string_pretty(&ast).unwrap(); - assert_snapshot!(format!("Input:\n{input}\n\nOutput:\n{serialized}")); - }); - } -} diff --git a/compiler/crates/react_estree/src/range.rs b/compiler/crates/react_estree/src/range.rs deleted file mode 100644 index 02887b70f3892..0000000000000 --- a/compiler/crates/react_estree/src/range.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use std::num::NonZeroU32; - -use serde::ser::SerializeTuple; -use serde::{Deserialize, Serialize}; - -#[derive(Deserialize, Copy, Clone, Debug, PartialEq, PartialOrd, Hash)] -pub struct SourceRange { - pub start: u32, - pub end: NonZeroU32, -} - -// ESTree and Babel store the `range` as `[start, end]`, so we customize -// the serialization to use a tuple representation. -impl Serialize for SourceRange { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - let mut tuple = serializer.serialize_tuple(2)?; - tuple.serialize_element(&self.start)?; - tuple.serialize_element(&self.end)?; - tuple.end() - } -} diff --git a/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@for-statement.json.snap b/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@for-statement.json.snap deleted file mode 100644 index 862492034eb62..0000000000000 --- a/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@for-statement.json.snap +++ /dev/null @@ -1,1058 +0,0 @@ ---- -source: crates/react_estree/src/lib.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{serialized}\")" -input_file: crates/react_estree/src/fixtures/for-statement.json ---- -Input: -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "name": "Component", - "typeAnnotation": null, - "optional": false, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "name": "props", - "typeAnnotation": null, - "optional": false, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "body": [ - { - "type": "VariableDeclaration", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "init": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "value": 0, - "range": [ - 38, - 39 - ], - "raw": "0" - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 7 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 34, - 35 - ] - }, - "range": [ - 34, - 39 - ] - } - ], - "range": [ - 30, - 40 - ] - }, - { - "type": "ForStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "init": { - "type": "VariableDeclaration", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 7 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "init": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "value": 0, - "range": [ - 56, - 57 - ], - "raw": "0" - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 12 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 52, - 53 - ] - }, - "range": [ - 52, - 57 - ] - } - ], - "range": [ - 48, - 57 - ] - }, - "test": { - "type": "BinaryExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "left": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 59, - 60 - ] - }, - "right": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 22 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "value": 10, - "range": [ - 63, - 65 - ], - "raw": "10" - }, - "operator": "<", - "range": [ - 59, - 65 - ] - }, - "update": { - "type": "UpdateExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "operator": "++", - "argument": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 27 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 67, - 68 - ] - }, - "prefix": false, - "range": [ - 67, - 70 - ] - }, - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 31 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "body": [ - { - "type": "ExpressionStatement", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 11 - } - }, - "expression": { - "type": "AssignmentExpression", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "operator": "+=", - "left": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 78, - 79 - ] - }, - "right": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 83, - 84 - ] - }, - "range": [ - 78, - 84 - ] - }, - "directive": null, - "range": [ - 78, - 85 - ] - } - ], - "range": [ - 72, - 89 - ] - }, - "range": [ - 43, - 89 - ] - }, - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 6, - "column": 2 - }, - "end": { - "line": 6, - "column": 11 - } - }, - "argument": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 10 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 99, - 100 - ] - }, - "range": [ - 92, - 101 - ] - } - ], - "range": [ - 26, - 103 - ] - }, - "typeParameters": null, - "returnType": null, - "predicate": null, - "generator": false, - "async": false, - "range": [ - 0, - 103 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 0, - 103 - ], - "sourceType": "script" - } - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 7 - } - }, - "range": [ - 34, - 35 - ] - }, - "init": { - "type": "Literal", - "value": 0.0, - "raw": "0", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "range": [ - 38, - 39 - ] - }, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "range": [ - 34, - 39 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "range": [ - 30, - 40 - ] - }, - { - "type": "ForStatement", - "init": { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 12 - } - }, - "range": [ - 52, - 53 - ] - }, - "init": { - "type": "Literal", - "value": 0.0, - "raw": "0", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "range": [ - 56, - 57 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "range": [ - 52, - 57 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 3, - "column": 7 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "range": [ - 48, - 57 - ] - }, - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "range": [ - 59, - 60 - ] - }, - "operator": "<", - "right": { - "type": "Literal", - "value": 10.0, - "raw": "10", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 22 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "range": [ - 63, - 65 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "range": [ - 59, - 65 - ] - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 27 - } - }, - "range": [ - 67, - 68 - ] - }, - "prefix": false, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ - 67, - 70 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "range": [ - 78, - 79 - ] - }, - "right": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "range": [ - 83, - 84 - ] - }, - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "range": [ - 78, - 84 - ] - }, - "directive": null, - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 11 - } - }, - "range": [ - 78, - 85 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 3, - "column": 31 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "range": [ - 72, - 89 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "range": [ - 43, - 89 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 10 - } - }, - "range": [ - 99, - 100 - ] - }, - "loc": { - "source": null, - "start": { - "line": 6, - "column": 2 - }, - "end": { - "line": 6, - "column": 11 - } - }, - "range": [ - 92, - 101 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "range": [ - 26, - 103 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "range": [ - 0, - 103 - ] - } - ], - "sourceType": "script", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "range": [ - 0, - 103 - ] -} diff --git a/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@import.json.snap b/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@import.json.snap deleted file mode 100644 index df265cf5472a0..0000000000000 --- a/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@import.json.snap +++ /dev/null @@ -1,213 +0,0 @@ ---- -source: crates/react_estree/src/lib.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{serialized}\")" -input_file: crates/react_estree/src/fixtures/import.json ---- -Input: -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "body": [ - { - "type": "ImportDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "local": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "name": "React", - "typeAnnotation": null, - "optional": false, - "range": [ - 7, - 12 - ] - }, - "range": [ - 7, - 12 - ] - } - ], - "source": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 25 - } - }, - "value": "react", - "range": [ - 18, - 25 - ], - "raw": "'react'" - }, - "attributes": [], - "importKind": "value", - "range": [ - 0, - 26 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 0, - 26 - ], - "sourceType": "module" - } - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ImportDeclaration", - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "local": { - "type": "Identifier", - "name": "React", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "range": [ - 7, - 12 - ] - }, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "range": [ - 7, - 12 - ] - } - ], - "source": { - "type": "Literal", - "value": "react", - "raw": "'react'", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 25 - } - }, - "range": [ - 18, - 25 - ] - }, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "range": [ - 0, - 26 - ] - } - ], - "sourceType": "module", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "range": [ - 0, - 26 - ] -} diff --git a/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@simple.json.snap b/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@simple.json.snap deleted file mode 100644 index 5acf6080f139f..0000000000000 --- a/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@simple.json.snap +++ /dev/null @@ -1,379 +0,0 @@ ---- -source: crates/react_estree/src/lib.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{serialized}\")" -input_file: crates/react_estree/src/fixtures/simple.json ---- -Input: -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ], - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ], - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "range": [ - 9, - 18 - ], - "name": "Component", - "typeAnnotation": null, - "optional": false - }, - "params": [ - { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "range": [ - 19, - 24 - ], - "name": "props", - "typeAnnotation": null, - "optional": false - } - ], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 26, - 51 - ], - "body": [ - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 21 - } - }, - "range": [ - 30, - 49 - ], - "argument": { - "type": "MemberExpression", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 37, - 48 - ], - "object": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 14 - } - }, - "range": [ - 37, - 42 - ], - "name": "props", - "typeAnnotation": null, - "optional": false - }, - "property": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 43, - 48 - ], - "name": "value", - "typeAnnotation": null, - "optional": false - }, - "computed": false - } - } - ] - }, - "async": false, - "generator": false, - "predicate": null, - "expression": false, - "returnType": null, - "typeParameters": null - } - ], - "comments": [], - "errors": [] - } - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 14 - } - }, - "range": [ - 37, - 42 - ] - }, - "property": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 43, - 48 - ] - }, - "computed": false, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 37, - 48 - ] - }, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 21 - } - }, - "range": [ - 30, - 49 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 26, - 51 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ] - } - ], - "sourceType": "module", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ] -} diff --git a/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@test.json.snap b/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@test.json.snap deleted file mode 100644 index cb260b180b190..0000000000000 --- a/compiler/crates/react_estree/src/snapshots/forget_estree__tests__fixtures@test.json.snap +++ /dev/null @@ -1,708 +0,0 @@ ---- -source: crates/react_estree/src/lib.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{serialized}\")" -input_file: crates/react_estree/src/fixtures/test.json ---- -Input: -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "name": "foo", - "typeAnnotation": null, - "optional": false, - "range": [ - 10, - 13 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "body": [ - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "argument": { - "type": "JSXElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "openingElement": { - "type": "JSXOpeningElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 26 - } - }, - "name": { - "type": "JSXMemberExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "object": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "name": "Foo", - "range": [ - 28, - 31 - ] - }, - "property": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 14 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "name": "Bar", - "range": [ - 32, - 35 - ] - }, - "range": [ - 28, - 35 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "name": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "name": "a", - "range": [ - 36, - 37 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "expression": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 21 - }, - "end": { - "line": 3, - "column": 23 - } - }, - "value": 10, - "range": [ - 39, - 41 - ], - "raw": "10" - }, - "range": [ - 38, - 42 - ] - }, - "range": [ - 36, - 42 - ] - } - ], - "selfClosing": false, - "range": [ - 27, - 44 - ] - }, - "children": [], - "closingElement": { - "type": "JSXClosingElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "name": { - "type": "JSXMemberExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "object": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 31 - } - }, - "name": "Foo", - "range": [ - 46, - 49 - ] - }, - "property": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "name": "Bar", - "range": [ - 50, - 53 - ] - }, - "range": [ - 46, - 53 - ] - }, - "range": [ - 44, - 54 - ] - }, - "range": [ - 27, - 54 - ] - }, - "range": [ - 20, - 54 - ] - } - ], - "range": [ - 16, - 56 - ] - }, - "typeParameters": null, - "returnType": null, - "predicate": null, - "generator": false, - "async": false, - "range": [ - 1, - 56 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 1, - 56 - ], - "sourceType": "script" - } - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "range": [ - 10, - 13 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "range": [ - 28, - 31 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 14 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "range": [ - 32, - 35 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "range": [ - 28, - 35 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "a", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "range": [ - 36, - 37 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Literal", - "value": 10.0, - "raw": "10", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 21 - }, - "end": { - "line": 3, - "column": 23 - } - }, - "range": [ - 39, - 41 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "range": [ - 38, - 42 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "range": [ - 36, - 42 - ] - } - ], - "selfClosing": false, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 26 - } - }, - "range": [ - 27, - 44 - ] - }, - "children": [], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 31 - } - }, - "range": [ - 46, - 49 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "range": [ - 50, - 53 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "range": [ - 46, - 53 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "range": [ - 44, - 54 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "range": [ - 27, - 54 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "range": [ - 20, - 54 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "range": [ - 16, - 56 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "range": [ - 1, - 56 - ] - } - ], - "sourceType": "script", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "range": [ - 1, - 56 - ] -} diff --git a/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@for-statement.json.snap b/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@for-statement.json.snap deleted file mode 100644 index 862492034eb62..0000000000000 --- a/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@for-statement.json.snap +++ /dev/null @@ -1,1058 +0,0 @@ ---- -source: crates/react_estree/src/lib.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{serialized}\")" -input_file: crates/react_estree/src/fixtures/for-statement.json ---- -Input: -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "name": "Component", - "typeAnnotation": null, - "optional": false, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "name": "props", - "typeAnnotation": null, - "optional": false, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "body": [ - { - "type": "VariableDeclaration", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "init": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "value": 0, - "range": [ - 38, - 39 - ], - "raw": "0" - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 7 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 34, - 35 - ] - }, - "range": [ - 34, - 39 - ] - } - ], - "range": [ - 30, - 40 - ] - }, - { - "type": "ForStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "init": { - "type": "VariableDeclaration", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 7 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "init": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "value": 0, - "range": [ - 56, - 57 - ], - "raw": "0" - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 12 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 52, - 53 - ] - }, - "range": [ - 52, - 57 - ] - } - ], - "range": [ - 48, - 57 - ] - }, - "test": { - "type": "BinaryExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "left": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 59, - 60 - ] - }, - "right": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 22 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "value": 10, - "range": [ - 63, - 65 - ], - "raw": "10" - }, - "operator": "<", - "range": [ - 59, - 65 - ] - }, - "update": { - "type": "UpdateExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "operator": "++", - "argument": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 27 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 67, - 68 - ] - }, - "prefix": false, - "range": [ - 67, - 70 - ] - }, - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 31 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "body": [ - { - "type": "ExpressionStatement", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 11 - } - }, - "expression": { - "type": "AssignmentExpression", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "operator": "+=", - "left": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 78, - 79 - ] - }, - "right": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "name": "i", - "typeAnnotation": null, - "optional": false, - "range": [ - 83, - 84 - ] - }, - "range": [ - 78, - 84 - ] - }, - "directive": null, - "range": [ - 78, - 85 - ] - } - ], - "range": [ - 72, - 89 - ] - }, - "range": [ - 43, - 89 - ] - }, - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 6, - "column": 2 - }, - "end": { - "line": 6, - "column": 11 - } - }, - "argument": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 10 - } - }, - "name": "x", - "typeAnnotation": null, - "optional": false, - "range": [ - 99, - 100 - ] - }, - "range": [ - 92, - 101 - ] - } - ], - "range": [ - 26, - 103 - ] - }, - "typeParameters": null, - "returnType": null, - "predicate": null, - "generator": false, - "async": false, - "range": [ - 0, - 103 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 0, - 103 - ], - "sourceType": "script" - } - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 7 - } - }, - "range": [ - 34, - 35 - ] - }, - "init": { - "type": "Literal", - "value": 0.0, - "raw": "0", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "range": [ - 38, - 39 - ] - }, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 2, - "column": 11 - } - }, - "range": [ - 34, - 39 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "range": [ - 30, - 40 - ] - }, - { - "type": "ForStatement", - "init": { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 12 - } - }, - "range": [ - 52, - 53 - ] - }, - "init": { - "type": "Literal", - "value": 0.0, - "raw": "0", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "range": [ - 56, - 57 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "range": [ - 52, - 57 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 3, - "column": 7 - }, - "end": { - "line": 3, - "column": 16 - } - }, - "range": [ - 48, - 57 - ] - }, - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "range": [ - 59, - 60 - ] - }, - "operator": "<", - "right": { - "type": "Literal", - "value": 10.0, - "raw": "10", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 22 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "range": [ - 63, - 65 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "range": [ - 59, - 65 - ] - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 27 - } - }, - "range": [ - 67, - 68 - ] - }, - "prefix": false, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 29 - } - }, - "range": [ - 67, - 70 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 5 - } - }, - "range": [ - 78, - 79 - ] - }, - "right": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 4, - "column": 9 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "range": [ - 83, - 84 - ] - }, - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 10 - } - }, - "range": [ - 78, - 84 - ] - }, - "directive": null, - "loc": { - "source": null, - "start": { - "line": 4, - "column": 4 - }, - "end": { - "line": 4, - "column": 11 - } - }, - "range": [ - 78, - 85 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 3, - "column": 31 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "range": [ - 72, - 89 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - }, - "range": [ - 43, - 89 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 10 - } - }, - "range": [ - 99, - 100 - ] - }, - "loc": { - "source": null, - "start": { - "line": 6, - "column": 2 - }, - "end": { - "line": 6, - "column": 11 - } - }, - "range": [ - 92, - 101 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "range": [ - 26, - 103 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "range": [ - 0, - 103 - ] - } - ], - "sourceType": "script", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 7, - "column": 1 - } - }, - "range": [ - 0, - 103 - ] -} diff --git a/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@import.json.snap b/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@import.json.snap deleted file mode 100644 index df265cf5472a0..0000000000000 --- a/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@import.json.snap +++ /dev/null @@ -1,213 +0,0 @@ ---- -source: crates/react_estree/src/lib.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{serialized}\")" -input_file: crates/react_estree/src/fixtures/import.json ---- -Input: -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "body": [ - { - "type": "ImportDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "local": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "name": "React", - "typeAnnotation": null, - "optional": false, - "range": [ - 7, - 12 - ] - }, - "range": [ - 7, - 12 - ] - } - ], - "source": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 25 - } - }, - "value": "react", - "range": [ - 18, - 25 - ], - "raw": "'react'" - }, - "attributes": [], - "importKind": "value", - "range": [ - 0, - 26 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 0, - 26 - ], - "sourceType": "module" - } - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ImportDeclaration", - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "local": { - "type": "Identifier", - "name": "React", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "range": [ - 7, - 12 - ] - }, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "range": [ - 7, - 12 - ] - } - ], - "source": { - "type": "Literal", - "value": "react", - "raw": "'react'", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 25 - } - }, - "range": [ - 18, - 25 - ] - }, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "range": [ - 0, - 26 - ] - } - ], - "sourceType": "module", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "range": [ - 0, - 26 - ] -} diff --git a/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@simple.json.snap b/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@simple.json.snap deleted file mode 100644 index 5acf6080f139f..0000000000000 --- a/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@simple.json.snap +++ /dev/null @@ -1,379 +0,0 @@ ---- -source: crates/react_estree/src/lib.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{serialized}\")" -input_file: crates/react_estree/src/fixtures/simple.json ---- -Input: -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ], - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ], - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "range": [ - 9, - 18 - ], - "name": "Component", - "typeAnnotation": null, - "optional": false - }, - "params": [ - { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "range": [ - 19, - 24 - ], - "name": "props", - "typeAnnotation": null, - "optional": false - } - ], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 26, - 51 - ], - "body": [ - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 21 - } - }, - "range": [ - 30, - 49 - ], - "argument": { - "type": "MemberExpression", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 37, - 48 - ], - "object": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 14 - } - }, - "range": [ - 37, - 42 - ], - "name": "props", - "typeAnnotation": null, - "optional": false - }, - "property": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 43, - 48 - ], - "name": "value", - "typeAnnotation": null, - "optional": false - }, - "computed": false - } - } - ] - }, - "async": false, - "generator": false, - "predicate": null, - "expression": false, - "returnType": null, - "typeParameters": null - } - ], - "comments": [], - "errors": [] - } - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 24 - } - }, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 14 - } - }, - "range": [ - 37, - 42 - ] - }, - "property": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 43, - 48 - ] - }, - "computed": false, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 20 - } - }, - "range": [ - 37, - 48 - ] - }, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 21 - } - }, - "range": [ - 30, - 49 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 26, - 51 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": null, - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ] - } - ], - "sourceType": "module", - "loc": { - "source": null, - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 3, - "column": 1 - } - }, - "range": [ - 0, - 51 - ] -} diff --git a/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@test.json.snap b/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@test.json.snap deleted file mode 100644 index cb260b180b190..0000000000000 --- a/compiler/crates/react_estree/src/snapshots/react_estree__tests__fixtures@test.json.snap +++ /dev/null @@ -1,708 +0,0 @@ ---- -source: crates/react_estree/src/lib.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{serialized}\")" -input_file: crates/react_estree/src/fixtures/test.json ---- -Input: -{ - "type": "Program", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "body": [ - { - "type": "FunctionDeclaration", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "id": { - "type": "Identifier", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "name": "foo", - "typeAnnotation": null, - "optional": false, - "range": [ - 10, - 13 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "body": [ - { - "type": "ReturnStatement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "argument": { - "type": "JSXElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "openingElement": { - "type": "JSXOpeningElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 26 - } - }, - "name": { - "type": "JSXMemberExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "object": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "name": "Foo", - "range": [ - 28, - 31 - ] - }, - "property": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 14 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "name": "Bar", - "range": [ - 32, - 35 - ] - }, - "range": [ - 28, - 35 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "name": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "name": "a", - "range": [ - 36, - 37 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "expression": { - "type": "Literal", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 21 - }, - "end": { - "line": 3, - "column": 23 - } - }, - "value": 10, - "range": [ - 39, - 41 - ], - "raw": "10" - }, - "range": [ - 38, - 42 - ] - }, - "range": [ - 36, - 42 - ] - } - ], - "selfClosing": false, - "range": [ - 27, - 44 - ] - }, - "children": [], - "closingElement": { - "type": "JSXClosingElement", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "name": { - "type": "JSXMemberExpression", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "object": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 31 - } - }, - "name": "Foo", - "range": [ - 46, - 49 - ] - }, - "property": { - "type": "JSXIdentifier", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "name": "Bar", - "range": [ - 50, - 53 - ] - }, - "range": [ - 46, - 53 - ] - }, - "range": [ - 44, - 54 - ] - }, - "range": [ - 27, - 54 - ] - }, - "range": [ - 20, - 54 - ] - } - ], - "range": [ - 16, - 56 - ] - }, - "typeParameters": null, - "returnType": null, - "predicate": null, - "generator": false, - "async": false, - "range": [ - 1, - 56 - ] - } - ], - "comments": [], - "interpreter": null, - "range": [ - 1, - 56 - ], - "sourceType": "script" - } - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 2, - "column": 12 - } - }, - "range": [ - 10, - 13 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "range": [ - 28, - 31 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 14 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "range": [ - 32, - 35 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 10 - }, - "end": { - "line": 3, - "column": 17 - } - }, - "range": [ - 28, - 35 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "a", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 19 - } - }, - "range": [ - 36, - 37 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Literal", - "value": 10.0, - "raw": "10", - "regex": null, - "bigint": null, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 21 - }, - "end": { - "line": 3, - "column": 23 - } - }, - "range": [ - 39, - 41 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "range": [ - 38, - 42 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 24 - } - }, - "range": [ - 36, - 42 - ] - } - ], - "selfClosing": false, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 26 - } - }, - "range": [ - 27, - 44 - ] - }, - "children": [], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 31 - } - }, - "range": [ - 46, - 49 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": { - "source": null, - "start": { - "line": 3, - "column": 32 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "range": [ - 50, - 53 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 28 - }, - "end": { - "line": 3, - "column": 35 - } - }, - "range": [ - 46, - 53 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "range": [ - 44, - 54 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "range": [ - 27, - 54 - ] - }, - "loc": { - "source": null, - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 36 - } - }, - "range": [ - 20, - 54 - ] - } - ], - "loc": { - "source": null, - "start": { - "line": 2, - "column": 15 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "range": [ - 16, - 56 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": null, - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "range": [ - 1, - 56 - ] - } - ], - "sourceType": "script", - "loc": { - "source": null, - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "range": [ - 1, - 56 - ] -} diff --git a/compiler/crates/react_estree/src/visit.rs b/compiler/crates/react_estree/src/visit.rs deleted file mode 100644 index a29df5c01910c..0000000000000 --- a/compiler/crates/react_estree/src/visit.rs +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use crate::{ - AssignmentPropertyOrRestElement, AssignmentTarget, Class, ClassItem, ClassPrivateProperty, - ClassProperty, Declaration, DeclarationOrExpression, ExportAllDeclaration, - ExportDefaultDeclaration, ExportNamedDeclaration, Expression, ExpressionOrPrivateIdentifier, - ExpressionOrSpread, ExpressionOrSuper, ForInInit, ForInit, Function, FunctionBody, - FunctionDeclaration, Identifier, ImportDeclaration, ImportDeclarationSpecifier, - ImportOrExportDeclaration, Literal, MethodDefinition, ModuleItem, Pattern, PrivateIdentifier, - PrivateName, Program, Statement, StaticBlock, Super, SwitchCase, VariableDeclarator, _Literal, -}; - -/// Trait for visiting an estree -#[allow(non_camel_case_types)] -#[deprecated] -pub trait Visitor_DEPRECATED<'ast> { - fn visit_lvalue(&mut self, f: F) - where - F: FnOnce(&mut Self), - { - f(self); - } - - fn visit_rvalue(&mut self, f: F) - where - F: FnOnce(&mut Self), - { - f(self); - } - - fn visit_program(&mut self, program: &'ast Program) { - self.default_visit_program(program) - } - - fn default_visit_program(&mut self, program: &'ast Program) { - for item in &program.body { - self.visit_module_item(item); - } - } - - fn visit_function(&mut self, function: &'ast Function) { - self.default_visit_function(function); - } - - fn default_visit_function(&mut self, function: &'ast Function) { - self.visit_lvalue(|visitor| { - for param in &function.params { - visitor.visit_pattern(param); - } - }); - match &function.body { - Some(FunctionBody::BlockStatement(body)) => { - for stmt in &body.body { - self.visit_statement(stmt) - } - } - Some(FunctionBody::Expression(body)) => self.visit_expression(body), - None => {} - } - } - - fn visit_module_item(&mut self, item: &'ast ModuleItem) { - match item { - ModuleItem::Statement(item) => self.visit_statement(item), - ModuleItem::ImportOrExportDeclaration(item) => { - self.visit_import_or_export_declaration(item) - } - } - } - - fn visit_import_or_export_declaration(&mut self, declaration: &'ast ImportOrExportDeclaration) { - match declaration { - ImportOrExportDeclaration::ImportDeclaration(declaration) => { - self.visit_import_declaration(declaration); - } - ImportOrExportDeclaration::ExportAllDeclaration(declaration) => { - self.visit_export_all_declaration(declaration); - } - ImportOrExportDeclaration::ExportDefaultDeclaration(declaration) => { - self.visit_export_default_declaration(declaration); - } - ImportOrExportDeclaration::ExportNamedDeclaration(declaration) => { - self.visit_export_named_declaration(declaration); - } - } - } - - fn visit_import_declaration(&mut self, declaration: &'ast ImportDeclaration) { - self.visit_lvalue(|visitor| { - for specifier in &declaration.specifiers { - visitor.visit_import_declaration_specifier(specifier); - } - }); - self.visit_import_source(&declaration.source); - } - - fn visit_export_all_declaration(&mut self, declaration: &'ast ExportAllDeclaration) { - self.visit_export_source(&declaration.source); - } - - fn visit_export_default_declaration(&mut self, declaration: &'ast ExportDefaultDeclaration) { - match &declaration.declaration { - DeclarationOrExpression::Declaration(declaration) => { - self.visit_declaration(declaration) - } - DeclarationOrExpression::Expression(declaration) => self.visit_expression(declaration), - } - } - - fn visit_export_named_declaration(&mut self, declaration: &'ast ExportNamedDeclaration) { - if let Some(declaration) = &declaration.declaration { - self.visit_declaration(declaration) - } - if let Some(source) = &declaration.source { - self.visit_export_source(source); - } - } - - fn visit_import_declaration_specifier(&mut self, specifier: &'ast ImportDeclarationSpecifier) { - match specifier { - ImportDeclarationSpecifier::ImportSpecifier(specifier) => { - self.visit_identifier(&specifier.local); - } - ImportDeclarationSpecifier::ImportDefaultSpecifier(specifier) => { - self.visit_identifier(&specifier.local); - } - ImportDeclarationSpecifier::ImportNamespaceSpecifier(specifier) => { - self.visit_identifier(&specifier.local); - } - } - } - - fn visit_declaration(&mut self, declaration: &'ast Declaration) { - self.default_visit_declaration(declaration); - } - - fn default_visit_declaration(&mut self, declaration: &'ast Declaration) { - match declaration { - Declaration::ClassDeclaration(declaration) => { - self.visit_class(&declaration.class); - } - Declaration::FunctionDeclaration(declaration) => { - self.visit_function_declaration(declaration); - } - Declaration::VariableDeclaration(declaration) => { - for declarator in &declaration.declarations { - self.visit_variable_declarator(declarator) - } - } - Declaration::TSTypeAliasDeclaration(_declaration) => { - todo!("visit TSTypeAliasDeclaration") - } - } - } - - fn visit_function_declaration(&mut self, declaration: &'ast FunctionDeclaration) { - self.visit_function(&declaration.function); - } - - fn visit_statement(&mut self, stmt: &'ast Statement) { - self.default_visit_statement(stmt); - } - - fn default_visit_statement(&mut self, stmt: &'ast Statement) { - match stmt { - Statement::BlockStatement(stmt) => { - for stmt in &stmt.body { - self.visit_statement(stmt) - } - } - Statement::BreakStatement(_stmt) => { - // todo - } - Statement::ContinueStatement(_stmt) => { - // todo - } - Statement::DebuggerStatement(_stmt) => { - // todo - } - Statement::ClassDeclaration(stmt) => { - self.visit_class(&stmt.class); - } - Statement::DoWhileStatement(stmt) => { - self.visit_statement(&stmt.body); - self.visit_expression(&stmt.test); - } - Statement::EmptyStatement(_stmt) => { - // nothing to do - } - Statement::ExpressionStatement(stmt) => { - self.visit_expression(&stmt.expression); - } - Statement::ForInStatement(stmt) => { - self.visit_for_in_init(&stmt.left); - self.visit_expression(&stmt.right); - self.visit_statement(&stmt.body); - } - Statement::ForOfStatement(stmt) => { - self.visit_for_in_init(&stmt.left); - self.visit_expression(&stmt.right); - self.visit_statement(&stmt.body); - } - Statement::ForStatement(stmt) => { - if let Some(init) = &stmt.init { - self.visit_for_init(init); - } - if let Some(test) = &stmt.test { - self.visit_expression(test); - } - if let Some(update) = &stmt.update { - self.visit_expression(update); - } - self.visit_statement(&stmt.body); - } - Statement::FunctionDeclaration(stmt) => { - self.visit_function_declaration(stmt); - } - Statement::IfStatement(stmt) => { - self.visit_expression(&stmt.test); - self.visit_statement(&stmt.consequent); - if let Some(alternate) = &stmt.alternate { - self.visit_statement(alternate); - } - } - Statement::LabeledStatement(stmt) => { - self.visit_statement(&stmt.body); - } - Statement::ReturnStatement(stmt) => { - if let Some(argument) = &stmt.argument { - self.visit_expression(argument); - } - } - Statement::SwitchStatement(stmt) => { - self.visit_expression(&stmt.discriminant); - for case_ in &stmt.cases { - self.visit_case(case_); - } - } - Statement::ThrowStatement(stmt) => { - self.visit_expression(&stmt.argument); - } - Statement::TryStatement(stmt) => { - for item in &stmt.block.body { - self.visit_statement(item); - } - if let Some(handler) = &stmt.handler { - if let Some(param) = &handler.param { - self.visit_lvalue(|visitor| visitor.visit_pattern(param)); - } - for item in &handler.body.body { - self.visit_statement(item); - } - } - if let Some(finalizer) = &stmt.finalizer { - for item in &finalizer.body { - self.visit_statement(item); - } - } - } - Statement::VariableDeclaration(stmt) => { - for decl in &stmt.declarations { - self.visit_variable_declarator(decl); - } - } - Statement::WhileStatement(stmt) => { - self.visit_expression(&stmt.test); - self.visit_statement(&stmt.body); - } - Statement::WithStatement(stmt) => { - self.visit_expression(&stmt.object); - self.visit_statement(&stmt.body); - } - Statement::TSTypeAliasDeclaration(_stmt) => { - todo!("visit TSTypeAliasDeclaration") - } - } - } - - fn visit_class(&mut self, class: &'ast Class) { - if let Some(id) = &class.id { - self.visit_identifier(id) - } - if let Some(super_class) = &class.super_class { - self.visit_expression(super_class); - } - for item in &class.body.body { - match item { - ClassItem::MethodDefinition(item) => self.visit_method_definition(item), - ClassItem::ClassProperty(item) => { - self.visit_class_property(item); - } - ClassItem::ClassPrivateProperty(item) => { - self.visit_class_private_property(item); - } - ClassItem::StaticBlock(item) => { - self.visit_static_block(item); - } - } - } - } - - fn visit_class_property(&mut self, property: &'ast ClassProperty) { - self.visit_expression(&property.key); - if let Some(value) = &property.value { - self.visit_expression(value) - } - } - - fn visit_class_private_property(&mut self, property: &'ast ClassPrivateProperty) { - match &property.key { - ExpressionOrPrivateIdentifier::Expression(key) => self.visit_expression(key), - ExpressionOrPrivateIdentifier::PrivateIdentifier(key) => { - self.visit_private_identifier(key) - } - ExpressionOrPrivateIdentifier::PrivateName(key) => self.visit_private_name(key), - } - if let Some(value) = &property.value { - self.visit_expression(value) - } - } - - fn visit_static_block(&mut self, property: &'ast StaticBlock) { - for stmt in &property.body { - self.visit_statement(stmt) - } - } - - fn visit_method_definition(&mut self, method: &'ast MethodDefinition) { - self.default_visit_method_definition(method); - } - - fn default_visit_method_definition(&mut self, method: &'ast MethodDefinition) { - self.visit_expression(&method.key); - self.visit_function(&method.value.function); - } - - fn visit_case(&mut self, case_: &'ast SwitchCase) { - if let Some(test) = &case_.test { - self.visit_expression(test); - } - for stmt in &case_.consequent { - self.visit_statement(stmt) - } - } - - fn visit_for_init(&mut self, init: &'ast ForInit) { - match init { - ForInit::Expression(init) => { - self.visit_expression(init); - } - ForInit::VariableDeclaration(init) => { - for decl in &init.declarations { - self.visit_variable_declarator(decl); - } - } - } - } - - fn visit_for_in_init(&mut self, init: &'ast ForInInit) { - match init { - ForInInit::Pattern(init) => { - self.visit_pattern(init); - } - ForInInit::VariableDeclaration(init) => { - for decl in &init.declarations { - self.visit_variable_declarator(decl); - } - } - } - } - - fn visit_pattern(&mut self, pattern: &'ast Pattern) { - match pattern { - Pattern::Identifier(pattern) => self.visit_identifier(pattern), - Pattern::ArrayPattern(pattern) => { - for element in &pattern.elements { - if let Some(element) = element { - self.visit_pattern(element); - } - } - } - Pattern::ObjectPattern(pattern) => { - for property in &pattern.properties { - match property { - AssignmentPropertyOrRestElement::AssignmentProperty(property) => { - self.visit_pattern(&property.value); - } - AssignmentPropertyOrRestElement::RestElement(property) => { - self.visit_pattern(&property.argument); - } - } - } - } - Pattern::RestElement(pattern) => self.visit_pattern(&pattern.argument), - Pattern::AssignmentPattern(pattern) => { - self.visit_pattern(&pattern.left); - self.visit_rvalue(|visitor| { - visitor.visit_expression(&pattern.right); - }); - } - } - } - - fn visit_variable_declarator(&mut self, decl: &'ast VariableDeclarator) { - self.visit_lvalue(|visitor| { - visitor.visit_pattern(&decl.id); - }); - if let Some(init) = &decl.init { - self.visit_expression(init); - } - } - - fn visit_assignment_target(&mut self, target: &'ast AssignmentTarget) { - match target { - AssignmentTarget::Expression(target) => { - self.visit_expression(target); - } - AssignmentTarget::Pattern(target) => self.visit_pattern(target), - } - } - - fn visit_expression(&mut self, expr: &'ast Expression) { - self.default_visit_expression(expr); - } - - fn default_visit_expression(&mut self, expr: &'ast Expression) { - match expr { - Expression::ArrayExpression(expr) => { - for item in &expr.elements { - match item { - Some(ExpressionOrSpread::SpreadElement(item)) => { - self.visit_expression(&item.argument) - } - Some(ExpressionOrSpread::Expression(item)) => self.visit_expression(item), - _ => {} - } - } - } - Expression::AssignmentExpression(expr) => { - self.visit_lvalue(|visitor| visitor.visit_assignment_target(&expr.left)); - self.visit_expression(&expr.right); - } - Expression::BinaryExpression(expr) => { - self.visit_expression(&expr.left); - self.visit_expression(&expr.right); - } - Expression::Identifier(expr) => { - self.visit_identifier(expr); - } - Expression::Literal(expr) => self.visit_literal(expr), - Expression::FunctionExpression(expr) => self.visit_function(&expr.function), - Expression::ArrowFunctionExpression(expr) => self.visit_function(&expr.function), - Expression::MemberExpression(expr) => { - match &expr.object { - ExpressionOrSuper::Super(object) => self.visit_super(object), - ExpressionOrSuper::Expression(object) => self.visit_expression(object), - }; - if !expr.is_computed { - match &expr.property { - ExpressionOrPrivateIdentifier::Expression(property) => { - self.visit_expression(property) - } - ExpressionOrPrivateIdentifier::PrivateIdentifier(property) => { - self.visit_private_identifier(property); - } - ExpressionOrPrivateIdentifier::PrivateName(property) => { - self.visit_private_name(property); - } - } - } - } - Expression::CallExpression(expr) => { - match &expr.callee { - ExpressionOrSuper::Expression(callee) => self.visit_expression(callee), - ExpressionOrSuper::Super(callee) => self.visit_super(callee), - } - for arg in &expr.arguments { - match arg { - ExpressionOrSpread::Expression(arg) => self.visit_expression(arg), - ExpressionOrSpread::SpreadElement(arg) => { - self.visit_expression(&arg.argument) - } - } - } - } - Expression::UpdateExpression(expr) => { - self.visit_expression(&expr.argument); - } - Expression::BooleanLiteral(_) - | Expression::NullLiteral(_) - | Expression::StringLiteral(_) - | Expression::NumericLiteral(_) => { - // no-op - } - _ => { - todo!("{:#?}", expr) - } - } - } - - fn visit_super(&mut self, _super: &'ast Super) { - todo!("Implement visit_super") - } - - fn visit_private_identifier(&mut self, _identifier: &'ast PrivateIdentifier) { - todo!("Implement visit_private_identifier()") - } - - fn visit_private_name(&mut self, _identifier: &'ast PrivateName) { - todo!("Implement visit_private_name()") - } - - fn visit_identifier(&mut self, _identifier: &'ast Identifier) { - todo!("Implement visit_identifier()") - } - - fn visit_import_source(&mut self, literal: &'ast _Literal) { - self.visit_any_literal(literal); - } - - fn visit_export_source(&mut self, literal: &'ast _Literal) { - self.visit_any_literal(literal); - } - - fn visit_any_literal(&mut self, _literal: &'ast _Literal) { - todo!("Implement visit_any_literal()") - } - - fn visit_literal(&mut self, _literal: &'ast Literal) { - todo!("Implement visit_literal()") - } -} diff --git a/compiler/crates/react_estree_codegen/Cargo.toml b/compiler/crates/react_estree_codegen/Cargo.toml deleted file mode 100644 index b147de8ebf140..0000000000000 --- a/compiler/crates/react_estree_codegen/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "react_estree_codegen" -version = "0.1.0" -publish = false -authors.workspace = true -description.workspace = true -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -indexmap = { workspace = true } -prettyplease = { workspace = true } -quote = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -syn = { workspace = true } diff --git a/compiler/crates/react_estree_codegen/README.md b/compiler/crates/react_estree_codegen/README.md deleted file mode 100644 index 2ece9f7dc5ab5..0000000000000 --- a/compiler/crates/react_estree_codegen/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# react_estree_codegen - -This crate is a build dependency for `react_estree`, and contains codegen logic to produce Rust code to describe the ESTree format -given a JSON schema. \ No newline at end of file diff --git a/compiler/crates/react_estree_codegen/src/codegen.rs b/compiler/crates/react_estree_codegen/src/codegen.rs deleted file mode 100644 index ed06fd27ff1e7..0000000000000 --- a/compiler/crates/react_estree_codegen/src/codegen.rs +++ /dev/null @@ -1,969 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use std::collections::HashSet; - -use indexmap::IndexMap; -use quote::__private::TokenStream; -use quote::{format_ident, quote}; -use serde::{Deserialize, Serialize}; -use syn::Type; - -/// Returns prettyplease-formatted Rust source for estree -pub fn estree() -> String { - let src = include_str!("./ecmascript.json"); - let grammar: Grammar = serde_json::from_str(src).unwrap(); - let raw = grammar.codegen().to_string(); - - let parsed = syn::parse_file(&raw).unwrap(); - format!( - "// {}generated\n#![cfg_attr(rustfmt, rustfmt_skip)]\n{}", - '\u{0040}', - prettyplease::unparse(&parsed) - ) -} - -/// Returns prettyplease-formatted Rust source for converting HermesParser results -/// into estree -pub fn estree_hermes() -> String { - let src = include_str!("./ecmascript.json"); - let grammar: Grammar = serde_json::from_str(src).unwrap(); - let raw = grammar.codegen_hermes().to_string(); - - let parsed = syn::parse_file(&raw).unwrap(); - format!( - "// {}generated\n#![cfg_attr(rustfmt, rustfmt_skip)]\n{}", - '\u{0040}', - prettyplease::unparse(&parsed) - ) -} - -#[derive(Serialize, Deserialize, Debug)] -#[serde(deny_unknown_fields)] -pub struct Grammar { - pub objects: IndexMap, - pub nodes: IndexMap, - pub enums: IndexMap, - pub operators: IndexMap, -} - -impl Grammar { - pub fn codegen(self) -> TokenStream { - let object_defs: Vec<_> = self - .objects - .iter() - .map(|(name, object)| object.codegen(name)) - .collect(); - let object_visitors: Vec<_> = self - .objects - .iter() - .filter_map(|(name, object)| { - if object.visitor { - Some(object.codegen_visitor(name, &self)) - } else { - None - } - }) - .collect(); - let node_defs: Vec<_> = self - .nodes - .iter() - .map(|(name, node)| node.codegen(name)) - .collect(); - let node_visitors: Vec<_> = self - .nodes - .iter() - .map(|(name, node)| node.codegen_visitor(name, &self)) - .collect(); - let enum_defs: Vec<_> = self - .enums - .iter() - .map(|(name, enum_)| enum_.codegen(name, &self.enums)) - .collect(); - let enum_visitors: Vec<_> = self - .enums - .iter() - .map(|(name, enum_)| enum_.codegen_visitor(name)) - .collect(); - let operator_defs: Vec<_> = self - .operators - .iter() - .map(|(name, operator)| operator.codegen(name)) - .collect(); - - quote! { - #![allow(dead_code)] - #![allow(unused_variables)] - #![allow(non_snake_case)] - #![allow(clippy::enum_variant_names)] - - use std::num::NonZeroU32; - use serde::ser::{Serializer, SerializeMap}; - use serde::{Serialize,Deserialize}; - use crate::{JsValue, Binding, SourceRange, Number, ESTreeNode}; - - #(#object_defs)* - - #(#node_defs)* - - #(#enum_defs)* - - #(#operator_defs)* - - pub trait Visitor { - #(#object_visitors)* - - #(#node_visitors)* - - #(#enum_visitors)* - } - } - } - - pub fn codegen_hermes(self) -> TokenStream { - let nodes: Vec<_> = self - .nodes - .iter() - .filter(|(_, node)| !node.skip_hermes_codegen) - .map(|(name, node)| node.codegen_hermes(name)) - .collect(); - let enums: Vec<_> = self - .enums - .iter() - .map(|(name, enum_)| enum_.codegen_hermes(name, &self)) - .collect(); - let operators: Vec<_> = self - .operators - .iter() - .map(|(name, operator)| operator.codegen_hermes(name)) - .collect(); - - quote! { - #![allow(dead_code)] - #![allow(unused_variables)] - #![allow(clippy::enum_variant_names)] - - use react_estree::*; - use hermes::parser::{NodePtr, NodeKind, NodeLabel }; - use hermes::utf::{utf8_with_surrogates_to_string}; - use crate::generated_extension::*; - - #(#nodes)* - - #(#enums)* - - #(#operators)* - } - } -} - -#[derive(Serialize, Deserialize, Debug)] -#[serde(deny_unknown_fields)] -pub struct Object { - #[serde(default)] - pub fields: IndexMap, - - #[serde(default)] - pub visitor: bool, -} - -impl Object { - pub fn codegen(&self, name: &str) -> TokenStream { - let name = format_ident!("{}", name); - let fields: Vec<_> = self - .fields - .iter() - .map(|(name, field)| field.codegen(name)) - .collect(); - - quote! { - #[derive(Serialize, Deserialize, Clone, Debug)] - #[serde(deny_unknown_fields)] - pub struct #name { - #(#fields),* - } - } - } - - pub fn codegen_visitor(&self, name: &str, grammar: &Grammar) -> TokenStream { - let visitor_name = format_ident!("visit_{}", to_lower_snake_case(name)); - let name = format_ident!("{}", name); - let field_visitors: Vec<_> = self - .fields - .iter() - .filter_map(|(name, field)| { - let (type_name_str, type_kind) = parse_type(&field.type_).unwrap(); - if !grammar.nodes.contains_key(&type_name_str) - && !grammar.enums.contains_key(&type_name_str) - { - return None; - } - let visitor_name = format_ident!("visit_{}", to_lower_snake_case(&type_name_str)); - let field_name = format_ident!("{}", name); - Some(match type_kind { - TypeKind::Named => { - quote! { - self.#visitor_name(&ast.#field_name); - } - } - TypeKind::Option => { - quote! { - if let Some(#field_name) = &ast.#field_name { - self.#visitor_name(#field_name); - } - } - } - TypeKind::Vec => { - quote! { - for #field_name in &ast.#field_name { - self.#visitor_name(#field_name); - } - } - } - TypeKind::VecOfOption => { - quote! { - for #field_name in &ast.#field_name { - if let Some(#field_name) = #field_name { - self.#visitor_name(#field_name); - } - } - } - } - }) - }) - .collect(); - quote! { - fn #visitor_name(&mut self, ast: &#name) { - #(#field_visitors)* - } - } - } -} - -#[derive(Serialize, Deserialize, Debug)] -#[serde(deny_unknown_fields)] -pub struct Node { - #[serde(default)] - #[serde(rename = "type")] - pub type_: Option, - - #[serde(default)] - pub fields: IndexMap, - - #[serde(default)] - pub skip_hermes_codegen: bool, - - #[serde(default)] - pub skip_hermes_enum_variant: bool, - - #[serde(default)] - #[serde(rename = "TODO")] - pub todo: Option, -} - -impl Node { - pub fn codegen(&self, name: &str) -> TokenStream { - let name_str = name; - let name = format_ident!("{}", name); - let fields: Vec<_> = self - .fields - .iter() - .map(|(name, field)| field.codegen_node(name)) - .collect(); - - let type_serializer = if let Some(type_) = &self.type_ { - quote! { - state.serialize_entry("type", #type_)?; - } - } else { - quote! { - state.serialize_entry("type", #name_str)?; - } - }; - - let mut field_serializers = Vec::with_capacity(self.fields.len()); // type, loc, range - for (field_name_str, field) in &self.fields { - if field.skip { - continue; - } - let field_name = format_ident!("{}", field_name_str); - let serialized_field_name = field.rename.as_ref().unwrap_or(field_name_str); - let serializer = if field.flatten { - quote! { - Serialize::serialize(&self.#field_name, serde::__private::ser::FlatMapSerializer(&mut state))?; - } - } else { - quote! { - state.serialize_entry(#serialized_field_name, &self.#field_name)?; - } - }; - field_serializers.push(serializer); - } - - quote! { - #[derive(Deserialize, Clone, Debug)] - pub struct #name { - #(#fields,)* - - #[serde(default)] - pub loc: Option, - - #[serde(default)] - pub range: Option, - } - - impl ESTreeNode for #name {} - - impl Serialize for #name { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut state = serializer.serialize_map(None)?; - #type_serializer - #(#field_serializers)* - state.serialize_entry("loc", &self.loc)?; - state.serialize_entry("range", &self.range)?; - state.end() - } - } - } - } - - pub fn codegen_visitor(&self, name: &str, grammar: &Grammar) -> TokenStream { - let visitor_name = format_ident!("visit_{}", to_lower_snake_case(name)); - let name = format_ident!("{}", name); - let field_visitors: Vec<_> = self - .fields - .iter() - .filter_map(|(name, field)| { - let (type_name_str, type_kind) = parse_type(&field.type_).unwrap(); - if (!grammar.objects.contains_key(&type_name_str) - || !grammar.objects.get(&type_name_str).unwrap().visitor) - && !grammar.nodes.contains_key(&type_name_str) - && !grammar.enums.contains_key(&type_name_str) - { - return None; - } - let visitor_name = format_ident!("visit_{}", to_lower_snake_case(&type_name_str)); - let field_name = format_ident!("{}", name); - Some(match type_kind { - TypeKind::Named => { - quote! { - self.#visitor_name(&ast.#field_name); - } - } - TypeKind::Option => { - quote! { - if let Some(#field_name) = &ast.#field_name { - self.#visitor_name(#field_name); - } - } - } - TypeKind::Vec => { - quote! { - for #field_name in &ast.#field_name { - self.#visitor_name(#field_name); - } - } - } - TypeKind::VecOfOption => { - quote! { - for #field_name in &ast.#field_name { - if let Some(#field_name) = #field_name { - self.#visitor_name(#field_name); - } - } - } - } - }) - }) - .collect(); - quote! { - fn #visitor_name(&mut self, ast: &#name) { - #(#field_visitors)* - } - } - } - - pub fn codegen_hermes(&self, name: &str) -> TokenStream { - let name_str = name; - let name = format_ident!("{}", name); - let field_names: Vec<_> = self - .fields - .iter() - .map(|(name, _field)| format_ident!("{}", name)) - .collect(); - let fields: Vec<_> = self - .fields - .iter() - .map(|(name, field)| { - let (type_name_str, type_kind) = parse_type(&field.type_).unwrap(); - let camelcase_name = field.rename.as_ref().unwrap_or(name); - let field_name = format_ident!("{}", name); - let helper = format_ident!("hermes_get_{}_{}", name_str, camelcase_name); - let type_name = format_ident!("{}", type_name_str); - if field.skip || field.hermes_default { - return quote! { - let #field_name = Default::default(); - }; - } - if let Some(convert_with) = &field.hermes_convert_with { - let convert_with = format_ident!("{}", convert_with); - return quote! { - let #field_name = #convert_with(cx, unsafe { hermes::parser::#helper(node) } ); - } - } - match type_kind { - TypeKind::Named => { - match type_name_str.as_ref() { - "bool" => { - quote! { - let #field_name = unsafe { hermes::parser::#helper(node) }; - } - } - "Number" => { - quote! { - let #field_name = convert_number(unsafe { hermes::parser::#helper(node) }); - } - } - "String" => { - quote! { - let #field_name = convert_string(cx, unsafe { hermes::parser::#helper(node) }); - } - } - _ => { - quote! { - let #field_name = #type_name::convert(cx, unsafe { hermes::parser::#helper(node) }); - } - } - } - } - TypeKind::Option => { - match type_name_str.as_ref() { - "String" => { - quote! { - let #field_name = convert_option_string(cx, unsafe { hermes::parser::#helper(node) }); - } - } - _ => { - quote! { - let #field_name = convert_option(unsafe { hermes::parser::#helper(node) }, |node| #type_name::convert(cx, node)); - } - } - } - } - TypeKind::Vec => { - quote! { - let #field_name = convert_vec(unsafe { hermes::parser::#helper(node) }, |node| #type_name::convert(cx, node)); - } - } - TypeKind::VecOfOption => { - quote! { - let #field_name = convert_vec_of_option(unsafe { hermes::parser::#helper(node) }, |node| #type_name::convert(cx, node)); - } - } - } - }) - .collect(); - - let type_ = format_ident!("{}", self.type_.as_ref().unwrap_or(&name_str.to_string())); - quote! { - impl FromHermes for #name { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::#type_); - let range = convert_range(cx, node); - #(#fields)* - Self { - #(#field_names,)* - loc: None, - range: Some(range), - } - } - } - } - } -} - -#[derive(Serialize, Deserialize, Debug)] -#[serde(deny_unknown_fields)] -pub struct Field { - // TODO: deserialize with `parse_type` into a custom type - #[serde(rename = "type")] - pub type_: String, - - #[serde(default)] - pub optional: bool, - - #[serde(default)] - pub flatten: bool, - - #[serde(default)] - pub rename: Option, - - #[serde(default)] - pub skip: bool, - - #[serde(default)] - #[serde(rename = "TODO")] - pub todo: Option, - - #[serde(default)] - pub hermes_convert_with: Option, - - #[serde(default)] - pub hermes_default: bool, -} - -impl Field { - pub fn codegen(&self, name: &str) -> TokenStream { - let name = format_ident!("{}", name); - parse_type(&self.type_).unwrap(); - let type_name: Type = syn::parse_str(&self.type_) - .unwrap_or_else(|_| panic!("Expected a type name, got `{}`", &self.type_)); - - let type_ = quote!(#type_name); - let mut field = quote!(pub #name: #type_); - if self.optional { - field = quote! { - #[serde(default)] - #field - } - } - if self.flatten { - field = quote! { - #[serde(flatten)] - #field - } - } - if self.skip { - field = quote! { - #[serde(skip)] - #field - } - } - if let Some(rename) = &self.rename { - field = quote! { - #[serde(rename = #rename)] - #field - } - } - field - } - - pub fn codegen_node(&self, name: &str) -> TokenStream { - let name = format_ident!("{}", name); - parse_type(&self.type_).unwrap(); - let type_name: Type = syn::parse_str(&self.type_) - .unwrap_or_else(|_| panic!("Expected a type name, got `{}`", &self.type_)); - let type_ = quote!(#type_name); - let mut field = quote!(pub #name: #type_); - if self.optional { - field = quote! { - #[serde(default)] - #field - } - } - if self.flatten { - field = quote! { - #[serde(flatten)] - #field - } - } - if self.skip { - field = quote! { - #[serde(skip)] - #field - } - } - if let Some(rename) = &self.rename { - field = quote! { - #[serde(rename = #rename)] - #field - } - } - field - } -} - -#[derive(Serialize, Deserialize, Debug)] -#[serde(transparent)] -#[serde(deny_unknown_fields)] -pub struct Enum { - pub variants: Vec, -} - -impl Enum { - pub fn codegen(&self, name: &str, enums: &IndexMap) -> TokenStream { - let mut sorted_variants: Vec<_> = self.variants.iter().collect(); - sorted_variants.sort(); - - let name_str = name; - let name = format_ident!("{}", name); - let variants: Vec<_> = sorted_variants - .iter() - .map(|name| { - let variant = format_ident!("{}", name); - if enums.contains_key(*name) { - quote!(#variant(#variant)) - } else { - quote!(#variant(Box<#variant>)) - } - }) - .collect(); - - let enum_tag = format_ident!("__{}Tag", name); - let mut seen = HashSet::new(); - - // tag_variants is used to generate an enum of all the possible type tags (`type` values) - // that can appear in this enum. we emit this enum and derive a deserializer for it so that - // our enum deserializer can first decode the tag in order to know how to decode the data - let mut tag_variants = Vec::new(); - - // once the tag is decoded, we need to match against it and deserialize according the tag (`type`) - // tag_matches are the match arms for each type. - let mut tag_matches = Vec::new(); - - // Imagine a case like: - // enum ModuleItem { - // ImportDeclaration, // struct - // Statement // another enum - // } - // We need to generate matches for all the possible *concrete* `type` values, which means - // we have to expand nested enums such as `Statement` - for variant in self.variants.iter() { - if let Some(nested_enum) = enums.get(variant) { - let outer_variant = format_ident!("{}", variant); - for variant in nested_enum.variants.iter() { - // Skip variants that appear in multiple nested enums, we deserialize - // as the first listed outer variant - if !seen.insert(variant.to_string()) { - continue; - } - // Modeling ESTree only requires a single level of nested enums, - // so that's all we support. Though in theory we could support arbitrary nesting, - // since ultimately we're matching based on the final concrete types. - assert!(!enums.contains_key(variant)); - - let inner_variant = format_ident!("{}", variant); - tag_variants.push(quote!(#inner_variant)); - - tag_matches.push(quote! { - #enum_tag::#inner_variant => { - let node: Box<#inner_variant> = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(#name::#outer_variant(#outer_variant::#inner_variant(node))) - } - }); - } - } else { - if !seen.insert(variant.to_string()) { - panic!( - "Concrete variant {} was already added by a nested enum", - variant - ); - } - let variant_name = format_ident!("{}", variant); - tag_variants.push(quote!(#variant_name)); - - tag_matches.push(quote! { - #enum_tag::#variant_name => { - let node: Box<#variant_name> = as Deserialize>::deserialize( - serde::__private::de::ContentDeserializer::::new(tagged.1), - )?; - Ok(#name::#variant_name(node)) - } - }) - } - } - quote! { - #[derive(Serialize, Clone, Debug)] - #[serde(untagged)] - pub enum #name { - #(#variants),* - } - - #[derive(Deserialize, Debug)] - enum #enum_tag { - #(#tag_variants),* - } - - impl <'de> serde::Deserialize<'de> for #name { - fn deserialize(deserializer: D) -> Result - where D: serde::Deserializer<'de> { - let tagged = serde::Deserializer::deserialize_any( - deserializer, - serde::__private::de::TaggedContentVisitor::<#enum_tag>::new("type", #name_str) - )?; - match tagged.0 { - #(#tag_matches),* - } - } - } - } - } - - pub fn codegen_visitor(&self, name: &str) -> TokenStream { - let visitor_name = format_ident!("visit_{}", to_lower_snake_case(name)); - let name = format_ident!("{}", name); - let mut tag_matches = Vec::new(); - - for variant in self.variants.iter() { - let node_variant = format_ident!("{}", variant); - let visitor_name = format_ident!("visit_{}", to_lower_snake_case(variant)); - - tag_matches.push(quote! { - #name::#node_variant(ast) => { - self.#visitor_name(ast); - } - }) - } - quote! { - fn #visitor_name(&mut self, ast: &#name) { - match ast { - #(#tag_matches),* - } - } - } - } - - pub fn codegen_hermes(&self, name: &str, grammar: &Grammar) -> TokenStream { - let name_str = name; - let name = format_ident!("{}", name); - - let mut tag_matches = Vec::new(); - let mut seen = HashSet::new(); - - // Imagine a case like: - // enum ModuleItem { - // ImportDeclaration, // struct - // Statement // another enum - // } - // We need to generate matches for all the possible *concrete* `type` values, which means - // we have to expand nested enums such as `Statement` - for variant in self.variants.iter() { - if let Some(nested_enum) = grammar.enums.get(variant) { - let outer_variant = format_ident!("{}", variant); - for variant in nested_enum.variants.iter() { - // Skip variants that appear in multiple nested enums, we deserialize - // as the first listed outer variant - if !seen.insert(variant.to_string()) { - continue; - } - // Modeling ESTree only requires a single level of nested enums, - // so that's all we support. Though in theory we could support arbitrary nesting, - // since ultimately we're matching based on the final concrete types. - assert!(!grammar.enums.contains_key(variant)); - let node = grammar.nodes.get(variant).unwrap(); - if node.skip_hermes_enum_variant { - continue; - } - - let inner_variant = format_ident!("{}", variant); - let node_variant_name = node.type_.as_ref().unwrap_or(variant); - let node_variant = format_ident!("{}", node_variant_name); - - tag_matches.push(quote! { - NodeKind::#node_variant => { - let node = #inner_variant::convert(cx, node); - #name::#outer_variant(#outer_variant::#inner_variant(Box::new(node))) - } - }); - } - } else { - if !seen.insert(variant.to_string()) { - panic!( - "Concrete variant {} was already added by a nested enum", - variant - ); - } - let variant_name = format_ident!("{}", variant); - let node = grammar.nodes.get(variant).unwrap(); - if node.skip_hermes_enum_variant { - continue; - } - - let node_variant_name = node.type_.as_ref().unwrap_or(variant); - let node_variant = format_ident!("{}", node_variant_name); - - tag_matches.push(quote! { - NodeKind::#node_variant => { - let node = #variant_name::convert(cx, node); - #name::#variant_name(Box::new(node)) - } - }) - } - } - - quote! { - impl FromHermes for #name { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - #(#tag_matches),* - _ => panic!("Unexpected node kind `{:?}` for `{}`", node_ref.kind, #name_str) - } - } - } - } - } -} - -#[derive(Serialize, Deserialize, Debug)] -#[serde(transparent)] -#[serde(deny_unknown_fields)] -pub struct Operator { - pub variants: IndexMap, -} - -impl Operator { - pub fn codegen(&self, name: &str) -> TokenStream { - let mut sorted_variants: Vec<_> = self.variants.iter().collect(); - sorted_variants.sort(); - - let name = format_ident!("{}", name); - let variants: Vec<_> = sorted_variants - .iter() - .map(|(name, operator)| { - let name = format_ident!("{}", name); - let comment = format!(" {}", &operator); - quote! { - #[doc = #comment] - #[serde(rename = #operator)] - #name - } - }) - .collect(); - - let display_matches: Vec<_> = sorted_variants - .iter() - .map(|(name, operator)| { - let name = format_ident!("{}", name); - quote!(Self::#name => #operator) - }) - .collect(); - - let fromstr_matches: Vec<_> = sorted_variants - .iter() - .map(|(name, operator)| { - let name = format_ident!("{}", name); - quote!(#operator => Ok(Self::#name)) - }) - .collect(); - - quote! { - #[derive(Serialize, Deserialize, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] - pub enum #name { - #(#variants),* - } - - impl std::fmt::Display for #name { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let name = match self { - #(#display_matches),* - }; - f.write_str(name) - } - } - - impl std::str::FromStr for #name { - type Err = (); - - fn from_str(s: &str) -> Result { - match s { - #(#fromstr_matches,)* - _ => Err(()), - } - } - } - } - } - - pub fn codegen_hermes(&self, name: &str) -> TokenStream { - let mut sorted_variants: Vec<_> = self.variants.iter().collect(); - sorted_variants.sort(); - - let name = format_ident!("{}", name); - - quote! { - impl FromHermesLabel for #name { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } - } - } - } -} - -enum TypeKind { - /// T - Named, - - /// Option - Option, - - /// Vec - Vec, - - /// Vec> - VecOfOption, -} - -/// Parses a given type into the underlying type name plus a descriptor of the -/// kind of type. Only a subset of Rust types are supported: -/// - T -/// - Option -/// - Vec -/// - Vec> -fn parse_type(type_: &str) -> Result<(String, TypeKind), String> { - let mut current = type_; - let mut is_list = false; - let mut is_option = false; - if current.starts_with("Vec<") { - current = ¤t[4..current.len() - 1]; - is_list = true; - } - if current.starts_with("Option<") { - current = ¤t[7..current.len() - 1]; - is_option = true; - } - if current.contains('<') { - Err(format!( - "Unsupported type `{current}` expected named type (`Identifier`), optional type (`Option`), list type (`Vec`), or optional list (`Vec>`)" - )) - } else { - let kind = match (is_list, is_option) { - (true, true) => TypeKind::VecOfOption, - (true, false) => TypeKind::Vec, - (false, true) => TypeKind::Option, - (false, false) => TypeKind::Named, - }; - Ok((current.to_string(), kind)) - } -} - -// from https://github.com/rust-lang/rust-analyzer/blob/4105378dc7479a3dbd39a4afb3eba67d083bd7f8/xtask/src/codegen/gen_syntax.rs#L406C1-L418C2 -fn to_lower_snake_case(s: &str) -> String { - let mut buf = String::with_capacity(s.len()); - let mut prev = false; - for c in s.chars() { - if c.is_ascii_uppercase() { - if prev { - buf.push('_') - } - prev = false; - } else { - prev = true; - } - - buf.push(c.to_ascii_lowercase()); - } - buf -} diff --git a/compiler/crates/react_estree_codegen/src/ecmascript.json b/compiler/crates/react_estree_codegen/src/ecmascript.json deleted file mode 100644 index f88f3e2e606f2..0000000000000 --- a/compiler/crates/react_estree_codegen/src/ecmascript.json +++ /dev/null @@ -1,1367 +0,0 @@ -{ - "objects": { - "SourceLocation": { - "fields": { - "source": { - "type": "Option" - }, - "start": { - "type": "Position" - }, - "end": { - "type": "Position" - } - } - }, - "Position": { - "fields": { - "line": { - "type": "NonZeroU32" - }, - "column": { - "type": "u32" - } - } - }, - "Class": { - "visitor": true, - "fields": { - "id": { - "type": "Option" - }, - "super_class": { - "type": "Option", - "rename": "superClass" - }, - "body": { - "type": "ClassBody" - } - } - }, - "Function": { - "visitor": true, - "fields": { - "id": { - "type": "Option" - }, - "params": { - "type": "Vec" - }, - "body": { - "type": "Option" - }, - "is_generator": { - "type": "bool", - "optional": true, - "rename": "generator" - }, - "is_async": { - "type": "bool", - "optional": true, - "rename": "async" - }, - "loc": { - "type": "Option", - "optional": true - }, - "range": { - "type": "Option", - "optional": true - } - } - }, - "RegExpValue": { - "fields": { - "pattern": { - "type": "String" - }, - "flags": { - "type": "String" - } - } - }, - "TemplateElementValue": { - "fields": { - "cooked": { - "type": "Option" - }, - "raw": { - "type": "String" - } - } - } - }, - "nodes": { - "Identifier": { - "fields": { - "name": { - "type": "String" - }, - "binding": { - "type": "Option", - "optional": true, - "skip": true - }, - "type_annotation": { - "type": "Option", - "optional": true, - "rename": "typeAnnotation", - "hermes_default": true, - "TODO": "support HermesParser" - } - } - }, - "Literal": { - "skip_hermes_codegen": true, - "skip_hermes_enum_variant": true, - "fields": { - "value": { - "type": "JsValue" - }, - "raw": { - "type": "Option", - "optional": true - }, - "regex": { - "type": "Option", - "optional": true - }, - "bigint": { - "type": "Option", - "optional": true - } - } - }, - "NumericLiteral": { - "fields": { - "value": { - "type": "Number" - } - } - }, - "BooleanLiteral": { - "fields": { - "value": { - "type": "bool" - } - } - }, - "NullLiteral": {}, - "StringLiteral": { - "fields": { - "value": { - "type": "String", - "hermes_convert_with": "convert_string_value" - } - } - }, - "RegExpLiteral": { - "fields": { - "pattern": { - "type": "String" - }, - "flags": { - "type": "String" - } - } - }, - "Program": { - "fields": { - "body": { - "type": "Vec" - }, - "source_type": { - "type": "SourceType", - "optional": true, - "rename": "sourceType", - "hermes_default": true - } - } - }, - "ExpressionStatement": { - "fields": { - "expression": { - "type": "Expression" - }, - "directive": { - "type": "Option", - "optional": true, - "hermes_default": true - } - } - }, - "BlockStatement": { - "fields": { - "body": { - "type": "Vec" - } - } - }, - "EmptyStatement": {}, - "DebuggerStatement": {}, - "WithStatement": { - "fields": { - "object": { - "type": "Expression" - }, - "body": { - "type": "Statement" - } - } - }, - "ReturnStatement": { - "fields": { - "argument": { - "type": "Option" - } - } - }, - "LabeledStatement": { - "fields": { - "label": { - "type": "Identifier" - }, - "body": { - "type": "Statement" - } - } - }, - "BreakStatement": { - "fields": { - "label": { - "type": "Option" - } - } - }, - "ContinueStatement": { - "fields": { - "label": { - "type": "Option" - } - } - }, - "IfStatement": { - "fields": { - "test": { - "type": "Expression" - }, - "consequent": { - "type": "Statement" - }, - "alternate": { - "type": "Option" - } - } - }, - "SwitchStatement": { - "fields": { - "discriminant": { - "type": "Expression" - }, - "cases": { - "type": "Vec" - } - } - }, - "SwitchCase": { - "fields": { - "test": { - "type": "Option" - }, - "consequent": { - "type": "Vec" - } - } - }, - "ThrowStatement": { - "fields": { - "argument": { - "type": "Expression" - } - } - }, - "TryStatement": { - "fields": { - "block": { - "type": "BlockStatement" - }, - "handler": { - "type": "Option" - }, - "finalizer": { - "type": "Option" - } - } - }, - "CatchClause": { - "fields": { - "param": { - "type": "Option" - }, - "body": { - "type": "BlockStatement" - } - } - }, - "WhileStatement": { - "fields": { - "test": { - "type": "Expression" - }, - "body": { - "type": "Statement" - } - } - }, - "DoWhileStatement": { - "fields": { - "body": { - "type": "Statement" - }, - "test": { - "type": "Expression" - } - } - }, - "ForStatement": { - "fields": { - "init": { - "type": "Option" - }, - "test": { - "type": "Option" - }, - "update": { - "type": "Option" - }, - "body": { - "type": "Statement" - } - } - }, - "ForInStatement": { - "fields": { - "left": { - "type": "ForInInit" - }, - "right": { - "type": "Expression" - }, - "body": { - "type": "Statement" - } - } - }, - "ForOfStatement": { - "fields": { - "is_await": { - "type": "bool", - "optional": true, - "rename": "await" - }, - "left": { - "type": "ForInInit" - }, - "right": { - "type": "Expression" - }, - "body": { - "type": "Statement" - } - } - }, - "FunctionDeclaration": { - "skip_hermes_codegen": true, - "fields": { - "function": { - "type": "Function", - "flatten": true - } - } - }, - "ClassDeclaration": { - "skip_hermes_codegen": true, - "fields": { - "class": { - "type": "Class", - "flatten": true - } - } - }, - "ClassExpression": { - "skip_hermes_codegen": true, - "fields": { - "class": { - "type": "Class", - "flatten": true - } - } - }, - "ClassBody": { - "fields": { - "body": { - "type": "Vec" - } - } - }, - "MethodDefinition": { - "fields": { - "key": { - "type": "Expression" - }, - "value": { - "type": "FunctionExpression" - }, - "kind": { - "type": "MethodKind" - }, - "is_computed": { - "type": "bool", - "rename": "computed" - }, - "is_static": { - "type": "bool", - "rename": "static" - } - } - }, - "VariableDeclaration": { - "fields": { - "kind": { - "type": "VariableDeclarationKind" - }, - "declarations": { - "type": "Vec" - } - } - }, - "VariableDeclarator": { - "fields": { - "id": { - "type": "Pattern" - }, - "init": { - "type": "Option" - } - } - }, - "ThisExpression": {}, - "ArrayExpression": { - "fields": { - "elements": { - "type": "Vec>", - "hermes_convert_with": "convert_array_expression_elements" - } - } - }, - "ObjectExpression": { - "fields": { - "properties": { - "type": "Vec" - } - } - }, - "Property": { - "fields": { - "key": { - "type": "Expression" - }, - "value": { - "type": "Expression" - }, - "kind": { - "type": "PropertyKind" - }, - "is_method": { - "type": "bool", - "rename": "method" - }, - "is_shorthand": { - "type": "bool", - "rename": "shorthand" - }, - "is_computed": { - "type": "bool", - "rename": "computed" - } - } - }, - "FunctionExpression": { - "skip_hermes_codegen": true, - "fields": { - "function": { - "type": "Function", - "flatten": true - } - } - }, - "ArrowFunctionExpression": { - "skip_hermes_codegen": true, - "fields": { - "function": { - "type": "Function", - "flatten": true - }, - "is_expression": { - "type": "bool", - "rename": "expression" - } - } - }, - "UnaryExpression": { - "fields": { - "operator": { - "type": "UnaryOperator" - }, - "prefix": { - "type": "bool" - }, - "argument": { - "type": "Expression" - } - } - }, - "UpdateExpression": { - "fields": { - "operator": { - "type": "UpdateOperator" - }, - "argument": { - "type": "Expression" - }, - "prefix": { - "type": "bool" - } - } - }, - "BinaryExpression": { - "fields": { - "left": { - "type": "Expression" - }, - "operator": { - "type": "BinaryOperator" - }, - "right": { - "type": "Expression" - } - } - }, - "AssignmentExpression": { - "fields": { - "operator": { - "type": "AssignmentOperator" - }, - "left": { - "type": "AssignmentTarget" - }, - "right": { - "type": "Expression" - } - } - }, - "LogicalExpression": { - "fields": { - "operator": { - "type": "LogicalOperator" - }, - "left": { - "type": "Expression" - }, - "right": { - "type": "Expression" - } - } - }, - "MemberExpression": { - "fields": { - "object": { - "type": "ExpressionOrSuper" - }, - "property": { - "type": "ExpressionOrPrivateIdentifier" - }, - "is_computed": { - "type": "bool", - "rename": "computed" - } - } - }, - "ConditionalExpression": { - "fields": { - "test": { - "type": "Expression" - }, - "alternate": { - "type": "Expression" - }, - "consequent": { - "type": "Expression" - } - } - }, - "CallExpression": { - "fields": { - "callee": { - "type": "ExpressionOrSuper" - }, - "arguments": { - "type": "Vec" - } - } - }, - "NewExpression": { - "fields": { - "callee": { - "type": "Expression" - }, - "arguments": { - "type": "Vec" - } - } - }, - "SequenceExpression": { - "fields": { - "expressions": { - "type": "Vec" - } - } - }, - "Super": {}, - "SpreadElement": { - "fields": { - "argument": { - "type": "Expression" - } - } - }, - "YieldExpression": { - "fields": { - "argument": { - "type": "Option", - "optional": true - }, - "is_delegate": { - "type": "bool", - "rename": "delegate" - } - } - }, - "ImportDeclaration": { - "fields": { - "specifiers": { - "type": "Vec" - }, - "source": { - "type": "_Literal" - } - } - }, - "ImportSpecifier": { - "fields": { - "imported": { - "type": "Identifier" - }, - "local": { - "type": "Identifier" - } - } - }, - "ImportDefaultSpecifier": { - "fields": { - "local": { - "type": "Identifier" - } - } - }, - "ImportNamespaceSpecifier": { - "fields": { - "local": { - "type": "Identifier" - } - } - }, - "ExportNamedDeclaration": { - "fields": { - "declaration": { - "type": "Option" - }, - "specifiers": { - "type": "Vec" - }, - "source": { - "type": "Option<_Literal>" - } - } - }, - "ExportSpecifier": { - "fields": { - "exported": { - "type": "Identifier" - } - } - }, - "ExportDefaultDeclaration": { - "fields": { - "declaration": { - "type": "DeclarationOrExpression" - } - } - }, - "ExportAllDeclaration": { - "fields": { - "source": { - "type": "_Literal" - }, - "exported": { - "type": "Option", - "optional": true, - "hermes_default": true - } - } - }, - "JSXIdentifier": { - "fields": { - "name": { - "type": "String" - }, - "binding": { - "type": "Option", - "optional": true, - "skip": true - } - } - }, - "JSXNamespacedName": { - "fields": { - "namespace": { - "type": "JSXIdentifier" - }, - "name": { - "type": "JSXIdentifier" - } - } - }, - "JSXMemberExpression": { - "fields": { - "object": { - "type": "JSXMemberExpressionOrIdentifier" - }, - "property": { - "type": "JSXIdentifier" - } - } - }, - "JSXEmptyExpression": {}, - "JSXExpressionContainer": { - "fields": { - "expression": { - "type": "JSXExpressionOrEmpty" - } - } - }, - "JSXSpreadChild": { - "fields": { - "expression": { - "type": "Expression" - } - } - }, - "JSXOpeningElement": { - "fields": { - "name": { - "type": "JSXElementName" - }, - "attributes": { - "type": "Vec" - }, - "self_closing": { - "type": "bool", - "rename": "selfClosing" - } - } - }, - "JSXClosingElement": { - "fields": { - "name": { - "type": "JSXElementName" - } - } - }, - "JSXAttribute": { - "fields": { - "name": { - "type": "JSXIdentifierOrNamespacedName" - }, - "value": { - "type": "Option" - } - } - }, - "JSXSpreadAttribute": { - "fields": { - "argument": { - "type": "Expression" - } - } - }, - "JSXText": { - "fields": { - "value": { - "type": "String", - "hermes_convert_with": "convert_string_value" - }, - "raw": { - "type": "String" - } - } - }, - "JSXStringLiteral": { - "fields": { - "value": { - "type": "String", - "hermes_convert_with": "convert_string_value" - }, - "raw": { - "type": "String" - } - }, - "TODO": "Non-standard HermesParser node" - }, - "JSXElement": { - "fields": { - "opening_element": { - "type": "JSXOpeningElement", - "rename": "openingElement" - }, - "children": { - "type": "Vec" - }, - "closing_element": { - "type": "Option", - "rename": "closingElement" - } - } - }, - "JSXFragment": { - "fields": { - "opening_fragment": { - "type": "JSXOpeningFragment", - "rename": "openingFragment" - }, - "children": { - "type": "Vec" - }, - "closing_fragment": { - "type": "JSXClosingFragment", - "rename": "closingFragment" - } - } - }, - "JSXOpeningFragment": {}, - "JSXClosingFragment": {}, - "ArrayPattern": { - "fields": { - "elements": { - "type": "Vec>" - } - } - }, - "ObjectPattern": { - "fields": { - "properties": { - "type": "Vec" - } - } - }, - "AssignmentProperty": { - "skip_hermes_codegen": true, - "type": "Property", - "fields": { - "key": { - "type": "Expression" - }, - "value": { - "type": "Pattern" - }, - "kind": { - "type": "PropertyKind", - "TODO": "fixed value `init`" - }, - "is_computed": { - "type": "bool", - "rename": "computed" - }, - "is_shorthand": { - "type": "bool", - "rename": "shorthand" - }, - "is_method": { - "type": "bool", - "rename": "method", - "TODO": "fixed value `false`" - } - } - }, - "RestElement": { - "fields": { - "argument": { - "type": "Pattern" - } - } - }, - "AssignmentPattern": { - "fields": { - "left": { - "type": "Pattern" - }, - "right": { - "type": "Expression" - } - } - }, - "TemplateLiteral": { - "fields": { - "quasis": { - "type": "Vec" - }, - "expressions": { - "type": "Vec" - } - } - }, - "TemplateElement": { - "skip_hermes_codegen": true, - "fields": { - "tail": { - "type": "bool" - }, - "value": { - "type": "TemplateElementValue" - } - } - }, - "TaggedTemplateExpression": { - "fields": { - "tag": { - "type": "Expression" - }, - "quasi": { - "type": "TemplateLiteral" - } - } - }, - "MetaProperty": { - "fields": { - "meta": { - "type": "Identifier" - }, - "property": { - "type": "Identifier" - } - } - }, - "AwaitExpression": { - "fields": { - "argument": { - "type": "Expression" - } - } - }, - "ChainExpression": { - "skip_hermes_codegen": true, - "skip_hermes_enum_variant": true, - "fields": { - "expression": { - "type": "ChainElement" - } - } - }, - "OptionalMemberExpression": { - "fields": { - "object": { - "type": "Expression" - }, - "property": { - "type": "Expression" - }, - "is_computed": { - "type": "bool", - "rename": "computed" - }, - "is_optional": { - "type": "bool", - "optional": true, - "rename": "optional" - } - } - }, - "OptionalCallExpression": { - "fields": { - "callee": { - "type": "ExpressionOrSuper" - }, - "arguments": { - "type": "Vec" - }, - "is_optional": { - "type": "bool", - "optional": true, - "rename": "optional" - } - } - }, - "ImportExpression": { - "fields": { - "source": { - "type": "Expression" - } - } - }, - "ClassProperty": { - "fields": { - "key": { - "type": "Expression" - }, - "value": { - "type": "Option", - "optional": true - }, - "is_computed": { - "type": "bool", - "rename": "computed" - }, - "is_static": { - "type": "bool", - "rename": "static" - } - } - }, - "ClassPrivateProperty": { - "fields": { - "key": { - "type": "ExpressionOrPrivateIdentifier" - }, - "value": { - "type": "Option", - "optional": true - }, - "is_static": { - "type": "bool", - "rename": "static" - } - }, - "TODO": "Non-standard HermesParser node" - }, - "PrivateName": { - "fields": { - "id": { - "type": "Identifier" - } - }, - "TODO": "Non-standard HermesParser node" - }, - "PrivateIdentifier": { - "skip_hermes_codegen": true, - "skip_hermes_enum_variant": true, - "fields": { - "name": { - "type": "String" - } - } - }, - "StaticBlock": { - "skip_hermes_codegen": true, - "skip_hermes_enum_variant": true, - "fields": { - "body": { - "type": "Vec" - } - }, - "TODO": "not yet supported in HermesParser" - }, - "CoverTypedIdentifier": { - "fields": { - "left": { - "type": "Identifier" - }, - "right": { - "type": "Option" - } - }, - "TODO": "Non-standard HermesParser node" - }, - "TSTypeAnnotation": {}, - "TSTypeAliasDeclaration": {} - }, - "enums": { - "Statement": [ - "BlockStatement", - "BreakStatement", - "ClassDeclaration", - "ContinueStatement", - "DebuggerStatement", - "DoWhileStatement", - "EmptyStatement", - "ExpressionStatement", - "ForInStatement", - "ForOfStatement", - "ForStatement", - "FunctionDeclaration", - "IfStatement", - "LabeledStatement", - "ReturnStatement", - "SwitchStatement", - "ThrowStatement", - "TryStatement", - "TSTypeAliasDeclaration", - "VariableDeclaration", - "WhileStatement", - "WithStatement" - ], - "Expression": [ - "ArrayExpression", - "ArrowFunctionExpression", - "AssignmentExpression", - "AwaitExpression", - "BinaryExpression", - "BooleanLiteral", - "CallExpression", - "ChainExpression", - "ClassExpression", - "ConditionalExpression", - "CoverTypedIdentifier", - "FunctionExpression", - "Identifier", - "ImportExpression", - "JSXElement", - "JSXFragment", - "Literal", - "LogicalExpression", - "MemberExpression", - "MetaProperty", - "NewExpression", - "NullLiteral", - "NumericLiteral", - "ObjectExpression", - "OptionalCallExpression", - "OptionalMemberExpression", - "RegExpLiteral", - "SequenceExpression", - "StringLiteral", - "TaggedTemplateExpression", - "TemplateLiteral", - "ThisExpression", - "UnaryExpression", - "UpdateExpression", - "YieldExpression" - ], - "_Literal": [ - "Literal", - "BooleanLiteral", - "NullLiteral", - "StringLiteral", - "NumericLiteral" - ], - "Declaration": [ - "ClassDeclaration", - "FunctionDeclaration", - "VariableDeclaration", - "TSTypeAliasDeclaration" - ], - "ImportDeclarationSpecifier": [ - "ImportSpecifier", - "ImportDefaultSpecifier", - "ImportNamespaceSpecifier" - ], - "ModuleItem": [ - "ImportOrExportDeclaration", - "Statement" - ], - "ImportOrExportDeclaration": [ - "ImportDeclaration", - "ExportNamedDeclaration", - "ExportDefaultDeclaration", - "ExportAllDeclaration" - ], - "ExpressionOrSuper": [ - "Expression", - "Super" - ], - "ExpressionOrSpread": [ - "Expression", - "SpreadElement" - ], - "FunctionBody": [ - "BlockStatement", - "Expression" - ], - "Pattern": [ - "Identifier", - "ArrayPattern", - "ObjectPattern", - "RestElement", - "AssignmentPattern" - ], - "ForInit": [ - "Expression", - "VariableDeclaration" - ], - "ForInInit": [ - "Pattern", - "VariableDeclaration" - ], - "PropertyOrSpreadElement": [ - "Property", - "SpreadElement" - ], - "AssignmentPropertyOrRestElement": [ - "AssignmentProperty", - "RestElement" - ], - "AssignmentTarget": [ - "Pattern", - "Expression" - ], - "ChainElement": [ - "CallExpression", - "MemberExpression" - ], - "JSXMemberExpressionOrIdentifier": [ - "JSXMemberExpression", - "JSXIdentifier" - ], - "JSXExpressionOrEmpty": [ - "Expression", - "JSXEmptyExpression" - ], - "JSXAttributeOrSpread": [ - "JSXAttribute", - "JSXSpreadAttribute" - ], - "JSXAttributeValue": [ - "Literal", - "JSXExpressionContainer", - "JSXElement", - "JSXFragment", - "JSXStringLiteral" - ], - "JSXElementName": [ - "JSXIdentifier", - "JSXMemberExpression", - "JSXNamespacedName" - ], - "JSXIdentifierOrNamespacedName": [ - "JSXIdentifier", - "JSXNamespacedName" - ], - "JSXChildItem": [ - "JSXText", - "JSXStringLiteral", - "JSXExpressionContainer", - "JSXSpreadChild", - "JSXElement", - "JSXFragment" - ], - "DeclarationOrExpression": [ - "Declaration", - "Expression" - ], - "ClassItem": [ - "MethodDefinition", - "ClassProperty", - "ClassPrivateProperty", - "StaticBlock" - ], - "ExpressionOrPrivateIdentifier": [ - "Expression", - "PrivateIdentifier", - "PrivateName" - ], - "TypeAnnotation": [ - "TSTypeAnnotation" - ] - }, - "operators": { - "VariableDeclarationKind": { - "Const": "const", - "Let": "let", - "Var": "var" - }, - "PropertyKind": { - "Get": "get", - "Init": "init", - "Set": "set" - }, - "UnaryOperator": { - "Delete": "delete", - "Minus": "-", - "Negation": "!", - "Plus": "+", - "Tilde": "~", - "Typeof": "typeof", - "Void": "void" - }, - "UpdateOperator": { - "Decrement": "--", - "Increment": "++" - }, - "BinaryOperator": { - "Add": "+", - "BinaryAnd": "&", - "BinaryOr": "|", - "BinaryXor": "^", - "Divide": "/", - "Equals": "==", - "Exponent": "**", - "GreaterThan": ">", - "GreaterThanOrEqual": ">=", - "In": "in", - "Instanceof": "instanceof", - "LessThan": "<", - "LessThanOrEqual": "<=", - "Modulo": "%", - "Multiply": "*", - "NotEquals": "!=", - "NotStrictEquals": "!==", - "ShiftLeft": "<<", - "ShiftRight": ">>", - "StrictEquals": "===", - "Subtract": "-", - "UnsignedShiftRight": ">>>" - }, - "AssignmentOperator": { - "BinaryAndEquals": "&=", - "BinaryOrEquals": "|=", - "BinaryXorEquals": "^=", - "DivideEquals": "/=", - "Equals": "=", - "Exponent": "**=", - "MinusEquals": "-=", - "ModuloEquals": "%=", - "MultiplyEquals": "*=", - "PlusEquals": "+=", - "ShiftLeftEquals": "<<=", - "ShiftRightEquals": ">>=", - "UnsignedShiftRightEquals": ">>>=", - "AndEquals": "&&=", - "OrEquals": "||=", - "NullCoalescingEquals": "??=" - }, - "LogicalOperator": { - "And": "&&", - "NullCoalescing": "??", - "Or": "||" - }, - "SourceType": { - "Script": "script", - "Module": "module" - }, - "MethodKind": { - "Constructor": "constructor", - "Method": "method", - "Get": "get", - "Set": "set" - } - } -} \ No newline at end of file diff --git a/compiler/crates/react_estree_codegen/src/lib.rs b/compiler/crates/react_estree_codegen/src/lib.rs deleted file mode 100644 index 614f5765ab3b3..0000000000000 --- a/compiler/crates/react_estree_codegen/src/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -mod codegen; - -pub use codegen::{estree, estree_hermes}; diff --git a/compiler/crates/react_fixtures/Cargo.toml b/compiler/crates/react_fixtures/Cargo.toml deleted file mode 100644 index 269465feb1e13..0000000000000 --- a/compiler/crates/react_fixtures/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "react_fixtures" -version = "0.1.0" -publish = false -authors.workspace = true -description.workspace = true -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dev-dependencies] -insta = { workspace = true } -react_estree = { workspace = true } -react_hermes_parser = { workspace = true } -react_hir = { workspace = true } -react_optimization = { workspace = true } -react_semantic_analysis = { workspace = true } -react_ssa = { workspace = true } -react_build_hir = { workspace = true } -miette = { workspace = true, features = ["backtrace", "fancy"] } diff --git a/compiler/crates/react_fixtures/README.md b/compiler/crates/react_fixtures/README.md deleted file mode 100644 index b930e96f56eca..0000000000000 --- a/compiler/crates/react_fixtures/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# fixtures - -This crate is for tests only, and runs the suite of compiler fixture tests. \ No newline at end of file diff --git a/compiler/crates/react_fixtures/src/lib.rs b/compiler/crates/react_fixtures/src/lib.rs deleted file mode 100644 index 22a77615600d8..0000000000000 --- a/compiler/crates/react_fixtures/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ diff --git a/compiler/crates/react_fixtures/tests/fixtures/constant-propagation-constant-if-condition.js b/compiler/crates/react_fixtures/tests/fixtures/constant-propagation-constant-if-condition.js deleted file mode 100644 index 8b293b8ee58d4..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/constant-propagation-constant-if-condition.js +++ /dev/null @@ -1,34 +0,0 @@ -function Component() { - let a = 1; - - let b; - if (a === 1) { - b = true; - } else { - b = false; - } - - let c; - if (b) { - c = "hello"; - } else { - c = null; - } - - let d; - if (c === "hello") { - d = 42.0; - } else { - d = 42.001; - } - - let e; - if (d === 42.0) { - e = "ok"; - } else { - e = "nope"; - } - - // should constant-propagate to "ok" - return e; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/constant-propagation.js b/compiler/crates/react_fixtures/tests/fixtures/constant-propagation.js deleted file mode 100644 index c7500c103b126..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/constant-propagation.js +++ /dev/null @@ -1,60 +0,0 @@ -function Component(props) { - // global propagation - let a; - a = Math; - a; // Math - - // primitive propagation w phi - let b; - if (props) { - b = true; - } else { - b = true; - } - b; // true - - // primitive propagation fails if different values - let c; - if (props) { - c = true; - } else { - c = 42; - } - c; // - - // constant evaluation - 42 + 1; // 43 - 42 - 1; // 41 - 42 * 2; // 84 - 42 / 2; // 21 - 0 == 1; // false - 0 != 1; // true - 0 === 1; // false - 0 !== 1; // true - 0 == 0; // true - // TODO: unary operators - // 0 == -0; // false - // 0 != -0; // true - // 0 === -0; // false - // 0 !== -0; // true - NaN == NaN; // false - NaN != NaN; // true - NaN !== NaN; // true - NaN !== NaN; // true - "hello" == "hello"; // true - "hello" != "hello"; // false - "hello" === "hello"; // true - "hello" !== "hello"; // false - "hello" == "world"; // false - "hello" != "world"; // true - "hello" === "world"; // false - "hello" !== "world"; // true - true == true; // true - true != true; // false - true === true; // true - true !== true; // false - - // constant evaluation through variable - let x = 5 * 60 * 60 * 1000; // 5 hours in milliseconds - x; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/destructure-array.js b/compiler/crates/react_fixtures/tests/fixtures/destructure-array.js deleted file mode 100644 index 680fb5daec4c1..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/destructure-array.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(a, b) { - const [c, , ...d] = a; - const [[[e]], ...[f]] = b; - return [c, d, e, f]; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/destructure-object.js b/compiler/crates/react_fixtures/tests/fixtures/destructure-object.js deleted file mode 100644 index 9b3a45e4d4bf9..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/destructure-object.js +++ /dev/null @@ -1,15 +0,0 @@ -function Component(a, b) { - const { - c, - d, - e: { e }, - f: { _f: f }, - g: { - g: { - g: { g, ...h }, - }, - }, - ...i - } = a; - return [c, d, e, f, g, h, i]; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/error.assign-to-global.js b/compiler/crates/react_fixtures/tests/fixtures/error.assign-to-global.js deleted file mode 100644 index 0434032d6f6b4..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/error.assign-to-global.js +++ /dev/null @@ -1,3 +0,0 @@ -function foo() { - x = true; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/for-statement.js b/compiler/crates/react_fixtures/tests/fixtures/for-statement.js deleted file mode 100644 index 180dd4d759d2e..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/for-statement.js +++ /dev/null @@ -1,7 +0,0 @@ -function foo() { - let x = 0; - for (let i = 0; i < 10; i = i + 1) { - x = x + i; - } - return x; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/function-expressions.js b/compiler/crates/react_fixtures/tests/fixtures/function-expressions.js deleted file mode 100644 index f9ee01b9e3b68..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/function-expressions.js +++ /dev/null @@ -1,21 +0,0 @@ -function Component(props) { - const x = 2; - const foo = function foo(y) { - let a = 1; - let b; - if (a === 1) { - b = 5 + 3; - } else { - b = false; - } - x + y + a + b; - const bar = function bar(z) { - let c = 2; - let d; - d = 3; - x + y + a + b + z + c + d; - }; - bar; - foo; - }; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/identifiers.js b/compiler/crates/react_fixtures/tests/fixtures/identifiers.js deleted file mode 100644 index def546ffd389d..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/identifiers.js +++ /dev/null @@ -1,16 +0,0 @@ -// import React from "react"; - -// const FOO = false; - -function id(x) { - // React; - // FOO; - Math; - id; - let y = true; - y = false; - y; - let z; - z; - return x; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/if-statement.js b/compiler/crates/react_fixtures/tests/fixtures/if-statement.js deleted file mode 100644 index 12e5f19ba346c..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/if-statement.js +++ /dev/null @@ -1,8 +0,0 @@ -function foo(a, b, c, d) { - if (a) { - return b; - } else { - c; - } - d; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/simple-function.js b/compiler/crates/react_fixtures/tests/fixtures/simple-function.js deleted file mode 100644 index ef9d16bb14f67..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/simple-function.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(a) { - Math; - let b = 0; - const foo = function foo_(c) { - let d = 1; - return a + b + c + d; - }; - return foo(); -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/simple-ssa.js b/compiler/crates/react_fixtures/tests/fixtures/simple-ssa.js deleted file mode 100644 index 75bb57b96710a..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/simple-ssa.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - let a; - if (props) { - a = 1; - } else { - a = 2; - } - return a; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/simple.js b/compiler/crates/react_fixtures/tests/fixtures/simple.js deleted file mode 100644 index a26662756cae0..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/simple.js +++ /dev/null @@ -1,4 +0,0 @@ -function test() { - [true, false, null, 1, 3.14, ...["hello world!"]]; - return 2; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/ssa-reassign-if.js b/compiler/crates/react_fixtures/tests/fixtures/ssa-reassign-if.js deleted file mode 100644 index 6c8029f8403af..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/ssa-reassign-if.js +++ /dev/null @@ -1,16 +0,0 @@ -function Component(a, b) { - let x; - let y = 0; - let z = 10; - if (a) { - x = 1; - if (b) { - z = 20; - } else { - z = 30; - } - } else { - x = 2; - } - return x + y + z; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures/use-memo.js b/compiler/crates/react_fixtures/tests/fixtures/use-memo.js deleted file mode 100644 index 27bc81a2f5ba2..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures/use-memo.js +++ /dev/null @@ -1,8 +0,0 @@ -import { useMemo } from "react"; - -function Component(x) { - const y = useMemo(() => { - return x; - }); - return y; -} diff --git a/compiler/crates/react_fixtures/tests/fixtures_test.rs b/compiler/crates/react_fixtures/tests/fixtures_test.rs deleted file mode 100644 index a3da273e718cb..0000000000000 --- a/compiler/crates/react_fixtures/tests/fixtures_test.rs +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use std::env; -use std::fmt::Write; - -use insta::{assert_snapshot, glob}; -use miette::{NamedSource, Report}; -use react_build_hir::build; -use react_estree::{ModuleItem, Statement}; -use react_hermes_parser::parse; -use react_hir::{inline_use_memo, Environment, Features, Print, Registry}; -use react_optimization::constant_propagation; -use react_semantic_analysis::analyze; -use react_ssa::{eliminate_redundant_phis, enter_ssa}; - -#[test] -fn fixtures() { - glob!("fixtures/**.js", |path| { - println!("fixture {}", path.to_str().unwrap()); - let input = std::fs::read_to_string(path).unwrap(); - let ast = parse(&input, path.to_str().unwrap()).unwrap(); - println!("ok parse"); - - let mut output = String::new(); - - let mut analysis = analyze(&ast, Default::default()); - let diagnostics = analysis.diagnostics(); - if !diagnostics.is_empty() { - for diagnostic in diagnostics { - eprintln!( - "{:?}", - Report::new(diagnostic) - .with_source_code(NamedSource::new(path.to_string_lossy(), input.clone(),)) - ); - } - } - let environment = Environment::new( - Features { - validate_frozen_lambdas: true, - }, - Registry, - analysis, - ); - for (ix, item) in ast.body.iter().enumerate() { - if let ModuleItem::Statement(stmt) = item { - if let Statement::FunctionDeclaration(fun) = stmt { - if ix != 0 { - output.push_str("\n\n"); - } - match build(&environment, &fun.function) { - Ok(mut fun) => { - println!("ok build"); - enter_ssa(&environment, &mut fun).unwrap(); - println!("ok enter_ssa"); - eliminate_redundant_phis(&environment, &mut fun); - println!("ok eliminate_redundant_phis"); - constant_propagation(&environment, &mut fun).unwrap(); - println!("ok constant_propagation"); - inline_use_memo(&environment, &mut fun).unwrap(); - println!("ok inline_use_memo"); - fun.print(&fun.body, &mut output).unwrap(); - println!("ok print"); - } - Err(error) => { - write!(&mut output, "{}", error,).unwrap(); - eprintln!( - "{:?}", - Report::new(error).with_source_code(NamedSource::new( - path.to_string_lossy(), - input.clone(), - )) - ); - continue; - } - }; - } - } - } - - let output = output.trim(); - assert_snapshot!(format!("Input:\n{input}\n\nOutput:\n{output}")); - }); -} diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@constant-propagation-constant-if-condition.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@constant-propagation-constant-if-condition.js.snap deleted file mode 100644 index dd9e2fb2528c6..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@constant-propagation-constant-if-condition.js.snap +++ /dev/null @@ -1,73 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/constant-propagation-constant-if-condition.js ---- -Input: -function Component() { - let a = 1; - - let b; - if (a === 1) { - b = true; - } else { - b = false; - } - - let c; - if (b) { - c = "hello"; - } else { - c = null; - } - - let d; - if (c === "hello") { - d = 42.0; - } else { - d = 42.001; - } - - let e; - if (d === 42.0) { - e = "ok"; - } else { - e = "nope"; - } - - // should constant-propagate to "ok" - return e; -} - - -Output: -function Component( -) -entry bb0 -bb0 (block) - [0] unknown $39 = 1 - [1] unknown $41 = StoreLocal Let unknown a$40 = unknown $39 - [2] unknown $43 = DeclareLocal Let unknown b$42 - [3] unknown $44 = 1 - [4] unknown $45 = 1 - [5] unknown $46 = true - [6] unknown $47 = true - [7] unknown $49 = StoreLocal Reassign unknown b$48 = unknown $47 - [8] unknown $54 = DeclareLocal Let unknown c$53 - [9] unknown $56 = true - [10] unknown $57 = "hello" - [11] unknown $59 = StoreLocal Reassign unknown c$58 = unknown $57 - [12] unknown $64 = DeclareLocal Let unknown d$63 - [13] unknown $66 = "hello" - [14] unknown $67 = "hello" - [15] unknown $68 = true - [16] unknown $69 = 42 - [17] unknown $71 = StoreLocal Reassign unknown d$70 = unknown $69 - [18] unknown $76 = DeclareLocal Let unknown e$75 - [19] unknown $78 = 42 - [20] unknown $79 = 42 - [21] unknown $80 = true - [22] unknown $81 = "ok" - [23] unknown $83 = StoreLocal Reassign unknown e$82 = unknown $81 - [24] unknown $88 = "ok" - [25] Return unknown $88 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@constant-propagation.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@constant-propagation.js.snap deleted file mode 100644 index a20caca2e6272..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@constant-propagation.js.snap +++ /dev/null @@ -1,198 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/constant-propagation.js ---- -Input: -function Component(props) { - // global propagation - let a; - a = Math; - a; // Math - - // primitive propagation w phi - let b; - if (props) { - b = true; - } else { - b = true; - } - b; // true - - // primitive propagation fails if different values - let c; - if (props) { - c = true; - } else { - c = 42; - } - c; // - - // constant evaluation - 42 + 1; // 43 - 42 - 1; // 41 - 42 * 2; // 84 - 42 / 2; // 21 - 0 == 1; // false - 0 != 1; // true - 0 === 1; // false - 0 !== 1; // true - 0 == 0; // true - // TODO: unary operators - // 0 == -0; // false - // 0 != -0; // true - // 0 === -0; // false - // 0 !== -0; // true - NaN == NaN; // false - NaN != NaN; // true - NaN !== NaN; // true - NaN !== NaN; // true - "hello" == "hello"; // true - "hello" != "hello"; // false - "hello" === "hello"; // true - "hello" !== "hello"; // false - "hello" == "world"; // false - "hello" != "world"; // true - "hello" === "world"; // false - "hello" !== "world"; // true - true == true; // true - true != true; // false - true === true; // true - true !== true; // false - - // constant evaluation through variable - let x = 5 * 60 * 60 * 1000; // 5 hours in milliseconds - x; -} - - -Output: -function Component( - unknown props$108, -) -entry bb0 -bb0 (block) - [0] unknown $110 = DeclareLocal Let unknown a$109 - [1] unknown $111 = LoadGlobal Math - [2] unknown $113 = StoreLocal Reassign unknown a$112 = unknown $111 - [3] unknown $114 = LoadGlobal Math - [4] unknown $116 = DeclareLocal Let unknown b$115 - [5] unknown $117 = LoadLocal unknown props$108 - [6] If unknown $117 consequent=bb2 alternate=bb3 fallthrough=bb1 -bb2 (block) - predecessors: bb0 - [7] unknown $118 = true - [8] unknown $120 = StoreLocal Reassign unknown b$119 = unknown $118 - [9] Goto bb1 -bb3 (block) - predecessors: bb0 - [10] unknown $121 = true - [11] unknown $123 = StoreLocal Reassign unknown b$122 = unknown $121 - [12] Goto bb1 -bb1 (block) - predecessors: bb2, bb3 - b$124: phi(bb2: b$119, bb3: b$122) - [13] unknown $125 = true - [14] unknown $127 = DeclareLocal Let unknown c$126 - [15] unknown $129 = LoadLocal unknown props$108 - [16] If unknown $129 consequent=bb5 alternate=bb6 fallthrough=bb4 -bb5 (block) - predecessors: bb1 - [17] unknown $130 = true - [18] unknown $132 = StoreLocal Reassign unknown c$131 = unknown $130 - [19] Goto bb4 -bb6 (block) - predecessors: bb1 - [20] unknown $133 = 42 - [21] unknown $135 = StoreLocal Reassign unknown c$134 = unknown $133 - [22] Goto bb4 -bb4 (block) - predecessors: bb5, bb6 - c$136: phi(bb5: c$131, bb6: c$134) - [23] unknown $137 = LoadLocal unknown c$136 - [24] unknown $138 = 42 - [25] unknown $139 = 1 - [26] unknown $140 = 43 - [27] unknown $141 = 42 - [28] unknown $142 = 1 - [29] unknown $143 = 41 - [30] unknown $144 = 42 - [31] unknown $145 = 2 - [32] unknown $146 = 84 - [33] unknown $147 = 42 - [34] unknown $148 = 2 - [35] unknown $149 = 21 - [36] unknown $150 = 0 - [37] unknown $151 = 1 - [38] unknown $152 = false - [39] unknown $153 = 0 - [40] unknown $154 = 1 - [41] unknown $155 = true - [42] unknown $156 = 0 - [43] unknown $157 = 1 - [44] unknown $158 = false - [45] unknown $159 = 0 - [46] unknown $160 = 1 - [47] unknown $161 = true - [48] unknown $162 = 0 - [49] unknown $163 = 0 - [50] unknown $164 = true - [51] unknown $165 = LoadGlobal NaN - [52] unknown $166 = LoadGlobal NaN - [53] unknown $167 = Binary unknown $165 == unknown $166 - [54] unknown $168 = LoadGlobal NaN - [55] unknown $169 = LoadGlobal NaN - [56] unknown $170 = Binary unknown $168 != unknown $169 - [57] unknown $171 = LoadGlobal NaN - [58] unknown $172 = LoadGlobal NaN - [59] unknown $173 = Binary unknown $171 !== unknown $172 - [60] unknown $174 = LoadGlobal NaN - [61] unknown $175 = LoadGlobal NaN - [62] unknown $176 = Binary unknown $174 !== unknown $175 - [63] unknown $177 = "hello" - [64] unknown $178 = "hello" - [65] unknown $179 = true - [66] unknown $180 = "hello" - [67] unknown $181 = "hello" - [68] unknown $182 = false - [69] unknown $183 = "hello" - [70] unknown $184 = "hello" - [71] unknown $185 = true - [72] unknown $186 = "hello" - [73] unknown $187 = "hello" - [74] unknown $188 = false - [75] unknown $189 = "hello" - [76] unknown $190 = "world" - [77] unknown $191 = false - [78] unknown $192 = "hello" - [79] unknown $193 = "world" - [80] unknown $194 = true - [81] unknown $195 = "hello" - [82] unknown $196 = "world" - [83] unknown $197 = false - [84] unknown $198 = "hello" - [85] unknown $199 = "world" - [86] unknown $200 = true - [87] unknown $201 = true - [88] unknown $202 = true - [89] unknown $203 = true - [90] unknown $204 = true - [91] unknown $205 = true - [92] unknown $206 = false - [93] unknown $207 = true - [94] unknown $208 = true - [95] unknown $209 = true - [96] unknown $210 = true - [97] unknown $211 = true - [98] unknown $212 = false - [99] unknown $213 = 5 - [100] unknown $214 = 60 - [101] unknown $215 = 300 - [102] unknown $216 = 60 - [103] unknown $217 = 18000 - [104] unknown $218 = 1000 - [105] unknown $219 = 18000000 - [106] unknown $221 = StoreLocal Let unknown x$220 = unknown $219 - [107] unknown $222 = 18000000 - [108] unknown $223 = - [109] Return unknown $223 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@destructure-array.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@destructure-array.js.snap deleted file mode 100644 index 7d23aedac10a4..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@destructure-array.js.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/destructure-array.js ---- -Input: -function Component(a, b) { - const [c, , ...d] = a; - const [[[e]], ...[f]] = b; - return [c, d, e, f]; -} - - -Output: -function Component( - unknown a$22, - unknown b$23, -) -entry bb0 -bb0 (block) - [0] unknown $24 = LoadLocal unknown a$22 - [1] unknown $27 = Destructure [ unknown c$25, , ...unknown d$26 ] = unknown $24 - [2] unknown $28 = LoadLocal unknown b$23 - [3] unknown $31 = Destructure [ unknown $29, ...unknown $30 ] = unknown $28 - [4] unknown $33 = Destructure [ unknown $32 ] = unknown $29 - [5] unknown $35 = Destructure [ unknown e$34 ] = unknown $32 - [6] unknown $37 = Destructure [ unknown f$36 ] = unknown $30 - [7] unknown $38 = LoadLocal unknown c$25 - [8] unknown $39 = LoadLocal unknown d$26 - [9] unknown $40 = LoadLocal unknown e$34 - [10] unknown $41 = LoadLocal unknown f$36 - [11] unknown $42 = Array [unknown $38, unknown $39, unknown $40, unknown $41] - [12] Return unknown $42 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@destructure-object.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@destructure-object.js.snap deleted file mode 100644 index 9d4dba953dcf4..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@destructure-object.js.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/destructure-object.js ---- -Input: -function Component(a, b) { - const { - c, - d, - e: { e }, - f: { _f: f }, - g: { - g: { - g: { g, ...h }, - }, - }, - ...i - } = a; - return [c, d, e, f, g, h, i]; -} - - -Output: -function Component( - unknown a$30, - unknown b$31, -) -entry bb0 -bb0 (block) - [0] unknown $32 = LoadLocal unknown a$30 - [1] unknown $39 = Destructure { c: unknown c$33, d: unknown d$34, e: unknown $35, f: unknown $36, g: unknown $37, ...unknown i$38 } = unknown $32 - [2] unknown $41 = Destructure { e: unknown e$40 } = unknown $35 - [3] unknown $43 = Destructure { _f: unknown f$42 } = unknown $36 - [4] unknown $45 = Destructure { g: unknown $44 } = unknown $37 - [5] unknown $47 = Destructure { g: unknown $46 } = unknown $44 - [6] unknown $50 = Destructure { g: unknown g$48, ...unknown h$49 } = unknown $46 - [7] unknown $51 = LoadLocal unknown c$33 - [8] unknown $52 = LoadLocal unknown d$34 - [9] unknown $53 = LoadLocal unknown e$40 - [10] unknown $54 = LoadLocal unknown f$42 - [11] unknown $55 = LoadLocal unknown g$48 - [12] unknown $56 = LoadLocal unknown h$49 - [13] unknown $57 = LoadLocal unknown i$38 - [14] unknown $58 = Array [unknown $51, unknown $52, unknown $53, unknown $54, unknown $55, unknown $56, unknown $57] - [15] Return unknown $58 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@error.assign-to-global.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@error.assign-to-global.js.snap deleted file mode 100644 index 465a44be960da..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@error.assign-to-global.js.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/error.assign-to-global.js ---- -Input: -function foo() { - x = true; -} - - -Output: -React functions may not reassign variables defined outside of the component or hook diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@for-statement.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@for-statement.js.snap deleted file mode 100644 index 6ce402d856d52..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@for-statement.js.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/for-statement.js ---- -Input: -function foo() { - let x = 0; - for (let i = 0; i < 10; i = i + 1) { - x = x + i; - } - return x; -} - - -Output: -function foo( -) -entry bb0 -bb0 (block) - [0] unknown $19 = 0 - [1] unknown $21 = StoreLocal Let unknown x$20 = unknown $19 - [2] For init=bb3 test=bb1 update=bb4 body=bb5 fallthrough=bb2 -bb3 (loop) - predecessors: bb0 - [3] unknown $22 = 0 - [4] unknown $24 = StoreLocal Let unknown i$23 = unknown $22 - [5] Goto bb1 -bb1 (loop) - predecessors: bb3, bb4 - i$25: phi(bb3: i$23, bb4: i$38) - x$29: phi(bb3: x$20, bb4: x$33) - [6] unknown $26 = LoadLocal unknown i$25 - [7] unknown $27 = 10 - [8] unknown $28 = Binary unknown $26 < unknown $27 - [9] Branch unknown $28 consequent=bb5 alternate=bb2 -bb5 (block) - predecessors: bb1 - [10] unknown $30 = LoadLocal unknown x$29 - [11] unknown $31 = LoadLocal unknown i$25 - [12] unknown $32 = Binary unknown $30 + unknown $31 - [13] unknown $34 = StoreLocal Reassign unknown x$33 = unknown $32 - [14] Goto bb4 -bb4 (loop) - predecessors: bb5 - [15] unknown $35 = LoadLocal unknown i$25 - [16] unknown $36 = 1 - [17] unknown $37 = Binary unknown $35 + unknown $36 - [18] unknown $39 = StoreLocal Reassign unknown i$38 = unknown $37 - [19] Goto bb1 -bb2 (block) - predecessors: bb1 - [20] unknown $40 = LoadLocal unknown x$29 - [21] Return unknown $40 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@function-expressions.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@function-expressions.js.snap deleted file mode 100644 index 8e67e9a4c708e..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@function-expressions.js.snap +++ /dev/null @@ -1,94 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/function-expressions.js ---- -Input: -function Component(props) { - const x = 2; - const foo = function foo(y) { - let a = 1; - let b; - if (a === 1) { - b = 5 + 3; - } else { - b = false; - } - x + y + a + b; - const bar = function bar(z) { - let c = 2; - let d; - d = 3; - x + y + a + b + z + c + d; - }; - bar; - foo; - }; -} - - -Output: -function Component( - unknown props$58, -) -entry bb0 -bb0 (block) - [0] unknown $59 = 2 - [1] unknown $61 = StoreLocal Const unknown x$60 = unknown $59 - [2] unknown $62 = Function @deps[] @context[unknown x$60]: - function foo( - unknown y$63, - ) - entry bb1 - bb1 (block) - [0] unknown $64 = 1 - [1] unknown $66 = StoreLocal Let unknown a$65 = unknown $64 - [2] unknown $68 = DeclareLocal Let unknown b$67 - [3] unknown $69 = 1 - [4] unknown $70 = 1 - [5] unknown $71 = true - [6] unknown $72 = 5 - [7] unknown $73 = 3 - [8] unknown $74 = 8 - [9] unknown $76 = StoreLocal Reassign unknown b$75 = unknown $74 - [10] unknown $81 = 2 - [11] unknown $83 = LoadLocal unknown y$63 - [12] unknown $84 = Binary unknown $81 + unknown $83 - [13] unknown $86 = 1 - [14] unknown $87 = Binary unknown $84 + unknown $86 - [15] unknown $89 = 8 - [16] unknown $90 = Binary unknown $87 + unknown $89 - [17] unknown $91 = Function @deps[] @context[unknown x$60, unknown y$63, unknown a$65, unknown b$75]: - function bar( - unknown z$92, - ) - entry bb5 - bb5 (block) - [0] unknown $93 = 2 - [1] unknown $95 = StoreLocal Let unknown c$94 = unknown $93 - [2] unknown $97 = DeclareLocal Let unknown d$96 - [3] unknown $98 = 3 - [4] unknown $100 = StoreLocal Reassign unknown d$99 = unknown $98 - [5] unknown $101 = LoadLocal unknown x$80 - [6] unknown $102 = LoadLocal unknown y$82 - [7] unknown $103 = Binary unknown $101 + unknown $102 - [8] unknown $104 = LoadLocal unknown a$85 - [9] unknown $105 = Binary unknown $103 + unknown $104 - [10] unknown $106 = LoadLocal unknown b$88 - [11] unknown $107 = Binary unknown $105 + unknown $106 - [12] unknown $108 = LoadLocal unknown z$92 - [13] unknown $109 = Binary unknown $107 + unknown $108 - [14] unknown $110 = 2 - [15] unknown $111 = Binary unknown $109 + unknown $110 - [16] unknown $112 = 3 - [17] unknown $113 = Binary unknown $111 + unknown $112 - [18] unknown $114 = - [19] Return unknown $114 - [18] unknown $116 = StoreLocal Const unknown bar$115 = unknown $91 - [19] unknown $117 = LoadLocal unknown bar$115 - [20] unknown $118 = LoadGlobal foo - [21] unknown $119 = - [22] Return unknown $119 - [3] unknown $121 = StoreLocal Const unknown foo$120 = unknown $62 - [4] unknown $122 = - [5] Return unknown $122 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@identifiers.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@identifiers.js.snap deleted file mode 100644 index d90aa38cd17a5..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@identifiers.js.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/identifiers.js ---- -Input: -// import React from "react"; - -// const FOO = false; - -function id(x) { - // React; - // FOO; - Math; - id; - let y = true; - y = false; - y; - let z; - z; - return x; -} - - -Output: -function id( - unknown x$14, -) -entry bb0 -bb0 (block) - [0] unknown $15 = LoadGlobal Math - [1] unknown $16 = LoadGlobal id - [2] unknown $17 = true - [3] unknown $19 = StoreLocal Let unknown y$18 = unknown $17 - [4] unknown $20 = false - [5] unknown $22 = StoreLocal Reassign unknown y$21 = unknown $20 - [6] unknown $23 = false - [7] unknown $25 = DeclareLocal Let unknown z$24 - [8] unknown $26 = LoadLocal unknown z$24 - [9] unknown $27 = LoadLocal unknown x$14 - [10] Return unknown $27 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@if-statement.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@if-statement.js.snap deleted file mode 100644 index 25a785e314156..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@if-statement.js.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/if-statement.js ---- -Input: -function foo(a, b, c, d) { - if (a) { - return b; - } else { - c; - } - d; -} - - -Output: -function foo( - unknown a$9, - unknown b$10, - unknown c$11, - unknown d$12, -) -entry bb0 -bb0 (block) - [0] unknown $13 = LoadLocal unknown a$9 - [1] If unknown $13 consequent=bb2 alternate=bb4 fallthrough=bb1 -bb2 (block) - predecessors: bb0 - [2] unknown $14 = LoadLocal unknown b$10 - [3] Return unknown $14 -bb4 (block) - predecessors: bb0 - [4] unknown $15 = LoadLocal unknown c$11 - [5] Goto bb1 -bb1 (block) - predecessors: bb4 - [6] unknown $16 = LoadLocal unknown d$12 - [7] unknown $17 = - [8] Return unknown $17 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple-function.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple-function.js.snap deleted file mode 100644 index b5b0db1f98a10..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple-function.js.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/simple-function.js ---- -Input: -function Component(a) { - Math; - let b = 0; - const foo = function foo_(c) { - let d = 1; - return a + b + c + d; - }; - return foo(); -} - - -Output: -function Component( - unknown a$23, -) -entry bb0 -bb0 (block) - [0] unknown $24 = LoadGlobal Math - [1] unknown $25 = 0 - [2] unknown $27 = StoreLocal Let unknown b$26 = unknown $25 - [3] unknown $28 = Function @deps[] @context[unknown a$23, unknown b$26]: - function foo_( - unknown c$29, - ) - entry bb1 - bb1 (block) - [0] unknown $30 = 1 - [1] unknown $32 = StoreLocal Let unknown d$31 = unknown $30 - [2] unknown $33 = LoadLocal unknown a$23 - [3] unknown $34 = 0 - [4] unknown $35 = Binary unknown $33 + unknown $34 - [5] unknown $36 = LoadLocal unknown c$29 - [6] unknown $37 = Binary unknown $35 + unknown $36 - [7] unknown $38 = 1 - [8] unknown $39 = Binary unknown $37 + unknown $38 - [9] Return unknown $39 - [4] unknown $41 = StoreLocal Const unknown foo$40 = unknown $28 - [5] unknown $42 = LoadLocal unknown foo$40 - [6] unknown $43 = Call unknown $42() - [7] Return unknown $43 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple-ssa.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple-ssa.js.snap deleted file mode 100644 index ba4d4ab2e0a52..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple-ssa.js.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/simple-ssa.js ---- -Input: -function Component(props) { - let a; - if (props) { - a = 1; - } else { - a = 2; - } - return a; -} - - -Output: -function Component( - unknown props$10, -) -entry bb0 -bb0 (block) - [0] unknown $12 = DeclareLocal Let unknown a$11 - [1] unknown $13 = LoadLocal unknown props$10 - [2] If unknown $13 consequent=bb2 alternate=bb3 fallthrough=bb1 -bb2 (block) - predecessors: bb0 - [3] unknown $14 = 1 - [4] unknown $16 = StoreLocal Reassign unknown a$15 = unknown $14 - [5] Goto bb1 -bb3 (block) - predecessors: bb0 - [6] unknown $17 = 2 - [7] unknown $19 = StoreLocal Reassign unknown a$18 = unknown $17 - [8] Goto bb1 -bb1 (block) - predecessors: bb2, bb3 - a$20: phi(bb2: a$15, bb3: a$18) - [9] unknown $21 = LoadLocal unknown a$20 - [10] Return unknown $21 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple.js.snap deleted file mode 100644 index c96ba1ba037e3..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@simple.js.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/simple.js ---- -Input: -function test() { - [true, false, null, 1, 3.14, ...["hello world!"]]; - return 2; -} - - -Output: -function test( -) -entry bb0 -bb0 (block) - [0] unknown $10 = true - [1] unknown $11 = false - [2] unknown $12 = null - [3] unknown $13 = 1 - [4] unknown $14 = 3.14 - [5] unknown $15 = "hello world!" - [6] unknown $16 = Array [unknown $15] - [7] unknown $17 = Array [unknown $10, unknown $11, unknown $12, unknown $13, unknown $14, ...unknown $16] - [8] unknown $18 = 2 - [9] Return unknown $18 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@ssa-reassign-if.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@ssa-reassign-if.js.snap deleted file mode 100644 index 30dad01ad8ab3..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@ssa-reassign-if.js.snap +++ /dev/null @@ -1,73 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/ssa-reassign-if.js ---- -Input: -function Component(a, b) { - let x; - let y = 0; - let z = 10; - if (a) { - x = 1; - if (b) { - z = 20; - } else { - z = 30; - } - } else { - x = 2; - } - return x + y + z; -} - - -Output: -function Component( - unknown a$26, - unknown b$27, -) -entry bb0 -bb0 (block) - [0] unknown $29 = DeclareLocal Let unknown x$28 - [1] unknown $30 = 0 - [2] unknown $32 = StoreLocal Let unknown y$31 = unknown $30 - [3] unknown $33 = 10 - [4] unknown $35 = StoreLocal Let unknown z$34 = unknown $33 - [5] unknown $36 = LoadLocal unknown a$26 - [6] If unknown $36 consequent=bb2 alternate=bb6 fallthrough=bb1 -bb2 (block) - predecessors: bb0 - [7] unknown $37 = 1 - [8] unknown $39 = StoreLocal Reassign unknown x$38 = unknown $37 - [9] unknown $40 = LoadLocal unknown b$27 - [10] If unknown $40 consequent=bb4 alternate=bb5 fallthrough=bb3 -bb4 (block) - predecessors: bb2 - [11] unknown $41 = 20 - [12] unknown $43 = StoreLocal Reassign unknown z$42 = unknown $41 - [13] Goto bb3 -bb5 (block) - predecessors: bb2 - [14] unknown $44 = 30 - [15] unknown $46 = StoreLocal Reassign unknown z$45 = unknown $44 - [16] Goto bb3 -bb3 (block) - predecessors: bb4, bb5 - z$58: phi(bb4: z$42, bb5: z$45) - [17] Goto bb1 -bb6 (block) - predecessors: bb0 - [18] unknown $47 = 2 - [19] unknown $49 = StoreLocal Reassign unknown x$48 = unknown $47 - [20] Goto bb1 -bb1 (block) - predecessors: bb3, bb6 - x$50: phi(bb3: x$38, bb6: x$48) - z$57: phi(bb3: z$58, bb6: z$34) - [21] unknown $52 = LoadLocal unknown x$50 - [22] unknown $55 = 0 - [23] unknown $56 = Binary unknown $52 + unknown $55 - [24] unknown $59 = LoadLocal unknown z$57 - [25] unknown $60 = Binary unknown $56 + unknown $59 - [26] Return unknown $60 diff --git a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@use-memo.js.snap b/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@use-memo.js.snap deleted file mode 100644 index aa0e1376a15d7..0000000000000 --- a/compiler/crates/react_fixtures/tests/snapshots/fixtures_test__fixtures@use-memo.js.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: crates/react_fixtures/tests/fixtures_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_fixtures/tests/fixtures/use-memo.js ---- -Input: -import { useMemo } from "react"; - -function Component(x) { - const y = useMemo(() => { - return x; - }); - return y; -} - - -Output: -function Component( - unknown x$10, -) -entry bb0 -bb0 (block) - [0] unknown $11 = LoadGlobal useMemo - [1] unknown $20 = DeclareLocal Let unknown t$18 - [2] Label block=bb1 fallthrough=bb6 -bb1 (block) - predecessors: bb0 - [3] unknown $13 = LoadLocal unknown x$10 - [4] unknown $19 = StoreLocal Reassign unknown t$18 = unknown $13 - [5] Goto bb6 -bb6 (block) - predecessors: bb1 - [6] unknown $14 = LoadLocal unknown t$18 - [7] unknown $16 = StoreLocal Const unknown y$15 = unknown $14 - [8] unknown $17 = LoadLocal unknown y$15 - [9] Return unknown $17 diff --git a/compiler/crates/react_hermes_parser/Cargo.toml b/compiler/crates/react_hermes_parser/Cargo.toml deleted file mode 100644 index 3bf24fe93daf9..0000000000000 --- a/compiler/crates/react_hermes_parser/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "react_hermes_parser" -version = "0.1.0" -authors.workspace = true -description.workspace = true -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -insta = { workspace = true } -react_diagnostics = { workspace = true } -react_estree = { workspace = true } -hermes = { workspace = true } -juno_support = { workspace = true } -serde_json = { workspace = true } - -[build-dependencies] -react_estree_codegen = { workspace = true } \ No newline at end of file diff --git a/compiler/crates/react_hermes_parser/README.md b/compiler/crates/react_hermes_parser/README.md deleted file mode 100644 index 36c1049a075e4..0000000000000 --- a/compiler/crates/react_hermes_parser/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# react_hermes_parser - -Wrapper around the Hermes parser that exposes parse results as a `react_estree` AST. \ No newline at end of file diff --git a/compiler/crates/react_hermes_parser/build.rs b/compiler/crates/react_hermes_parser/build.rs deleted file mode 100644 index 03d58924090e1..0000000000000 --- a/compiler/crates/react_hermes_parser/build.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use react_estree_codegen::estree_hermes; - -// Example custom build script. -fn main() { - // Re-run if the codegen files change - println!("cargo:rerun-if-changed=../react_estree_codegen/src/codegen.rs"); - println!("cargo:rerun-if-changed=../react_estree_codegen/src/lib.rs"); - println!("cargo:rerun-if-changed=../react_estree_codegen/src/ecmascript.json"); - println!("cargo:rerun-if-changed=../react_estree_codegen"); - - let src = estree_hermes(); - let copyright = " -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - " - .to_string(); - let trimmed_copyright = copyright.trim(); - let contents = format!("{trimmed_copyright}\n{src}"); - std::fs::write("src/generated.rs", contents).unwrap(); -} diff --git a/compiler/crates/react_hermes_parser/src/generated.rs b/compiler/crates/react_hermes_parser/src/generated.rs deleted file mode 100644 index 718f5ab3819cd..0000000000000 --- a/compiler/crates/react_hermes_parser/src/generated.rs +++ /dev/null @@ -1,4158 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -// @generated -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(dead_code)] -#![allow(unused_variables)] -#![allow(clippy::enum_variant_names)] -use react_estree::*; -use hermes::parser::{NodePtr, NodeKind, NodeLabel}; -use hermes::utf::utf8_with_surrogates_to_string; -use crate::generated_extension::*; -impl FromHermes for Identifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::Identifier); - let range = convert_range(cx, node); - let name = convert_string( - cx, - unsafe { hermes::parser::hermes_get_Identifier_name(node) }, - ); - let binding = Default::default(); - let type_annotation = Default::default(); - Self { - name, - binding, - type_annotation, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for NumericLiteral { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::NumericLiteral); - let range = convert_range(cx, node); - let value = convert_number(unsafe { - hermes::parser::hermes_get_NumericLiteral_value(node) - }); - Self { - value, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for BooleanLiteral { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::BooleanLiteral); - let range = convert_range(cx, node); - let value = unsafe { hermes::parser::hermes_get_BooleanLiteral_value(node) }; - Self { - value, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for NullLiteral { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::NullLiteral); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for StringLiteral { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::StringLiteral); - let range = convert_range(cx, node); - let value = convert_string_value( - cx, - unsafe { hermes::parser::hermes_get_StringLiteral_value(node) }, - ); - Self { - value, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for RegExpLiteral { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::RegExpLiteral); - let range = convert_range(cx, node); - let pattern = convert_string( - cx, - unsafe { hermes::parser::hermes_get_RegExpLiteral_pattern(node) }, - ); - let flags = convert_string( - cx, - unsafe { hermes::parser::hermes_get_RegExpLiteral_flags(node) }, - ); - Self { - pattern, - flags, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for Program { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::Program); - let range = convert_range(cx, node); - let body = convert_vec( - unsafe { hermes::parser::hermes_get_Program_body(node) }, - |node| ModuleItem::convert(cx, node), - ); - let source_type = Default::default(); - Self { - body, - source_type, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ExpressionStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ExpressionStatement); - let range = convert_range(cx, node); - let expression = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ExpressionStatement_expression(node) }, - ); - let directive = Default::default(); - Self { - expression, - directive, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for BlockStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::BlockStatement); - let range = convert_range(cx, node); - let body = convert_vec( - unsafe { hermes::parser::hermes_get_BlockStatement_body(node) }, - |node| Statement::convert(cx, node), - ); - Self { - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for EmptyStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::EmptyStatement); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for DebuggerStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::DebuggerStatement); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for WithStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::WithStatement); - let range = convert_range(cx, node); - let object = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_WithStatement_object(node) }, - ); - let body = Statement::convert( - cx, - unsafe { hermes::parser::hermes_get_WithStatement_body(node) }, - ); - Self { - object, - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ReturnStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ReturnStatement); - let range = convert_range(cx, node); - let argument = convert_option( - unsafe { hermes::parser::hermes_get_ReturnStatement_argument(node) }, - |node| Expression::convert(cx, node), - ); - Self { - argument, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for LabeledStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::LabeledStatement); - let range = convert_range(cx, node); - let label = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_LabeledStatement_label(node) }, - ); - let body = Statement::convert( - cx, - unsafe { hermes::parser::hermes_get_LabeledStatement_body(node) }, - ); - Self { - label, - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for BreakStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::BreakStatement); - let range = convert_range(cx, node); - let label = convert_option( - unsafe { hermes::parser::hermes_get_BreakStatement_label(node) }, - |node| Identifier::convert(cx, node), - ); - Self { - label, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ContinueStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ContinueStatement); - let range = convert_range(cx, node); - let label = convert_option( - unsafe { hermes::parser::hermes_get_ContinueStatement_label(node) }, - |node| Identifier::convert(cx, node), - ); - Self { - label, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for IfStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::IfStatement); - let range = convert_range(cx, node); - let test = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_IfStatement_test(node) }, - ); - let consequent = Statement::convert( - cx, - unsafe { hermes::parser::hermes_get_IfStatement_consequent(node) }, - ); - let alternate = convert_option( - unsafe { hermes::parser::hermes_get_IfStatement_alternate(node) }, - |node| Statement::convert(cx, node), - ); - Self { - test, - consequent, - alternate, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for SwitchStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::SwitchStatement); - let range = convert_range(cx, node); - let discriminant = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_SwitchStatement_discriminant(node) }, - ); - let cases = convert_vec( - unsafe { hermes::parser::hermes_get_SwitchStatement_cases(node) }, - |node| SwitchCase::convert(cx, node), - ); - Self { - discriminant, - cases, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for SwitchCase { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::SwitchCase); - let range = convert_range(cx, node); - let test = convert_option( - unsafe { hermes::parser::hermes_get_SwitchCase_test(node) }, - |node| Expression::convert(cx, node), - ); - let consequent = convert_vec( - unsafe { hermes::parser::hermes_get_SwitchCase_consequent(node) }, - |node| Statement::convert(cx, node), - ); - Self { - test, - consequent, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ThrowStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ThrowStatement); - let range = convert_range(cx, node); - let argument = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ThrowStatement_argument(node) }, - ); - Self { - argument, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for TryStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::TryStatement); - let range = convert_range(cx, node); - let block = BlockStatement::convert( - cx, - unsafe { hermes::parser::hermes_get_TryStatement_block(node) }, - ); - let handler = convert_option( - unsafe { hermes::parser::hermes_get_TryStatement_handler(node) }, - |node| CatchClause::convert(cx, node), - ); - let finalizer = convert_option( - unsafe { hermes::parser::hermes_get_TryStatement_finalizer(node) }, - |node| BlockStatement::convert(cx, node), - ); - Self { - block, - handler, - finalizer, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for CatchClause { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::CatchClause); - let range = convert_range(cx, node); - let param = convert_option( - unsafe { hermes::parser::hermes_get_CatchClause_param(node) }, - |node| Pattern::convert(cx, node), - ); - let body = BlockStatement::convert( - cx, - unsafe { hermes::parser::hermes_get_CatchClause_body(node) }, - ); - Self { - param, - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for WhileStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::WhileStatement); - let range = convert_range(cx, node); - let test = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_WhileStatement_test(node) }, - ); - let body = Statement::convert( - cx, - unsafe { hermes::parser::hermes_get_WhileStatement_body(node) }, - ); - Self { - test, - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for DoWhileStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::DoWhileStatement); - let range = convert_range(cx, node); - let body = Statement::convert( - cx, - unsafe { hermes::parser::hermes_get_DoWhileStatement_body(node) }, - ); - let test = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_DoWhileStatement_test(node) }, - ); - Self { - body, - test, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ForStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ForStatement); - let range = convert_range(cx, node); - let init = convert_option( - unsafe { hermes::parser::hermes_get_ForStatement_init(node) }, - |node| ForInit::convert(cx, node), - ); - let test = convert_option( - unsafe { hermes::parser::hermes_get_ForStatement_test(node) }, - |node| Expression::convert(cx, node), - ); - let update = convert_option( - unsafe { hermes::parser::hermes_get_ForStatement_update(node) }, - |node| Expression::convert(cx, node), - ); - let body = Statement::convert( - cx, - unsafe { hermes::parser::hermes_get_ForStatement_body(node) }, - ); - Self { - init, - test, - update, - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ForInStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ForInStatement); - let range = convert_range(cx, node); - let left = ForInInit::convert( - cx, - unsafe { hermes::parser::hermes_get_ForInStatement_left(node) }, - ); - let right = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ForInStatement_right(node) }, - ); - let body = Statement::convert( - cx, - unsafe { hermes::parser::hermes_get_ForInStatement_body(node) }, - ); - Self { - left, - right, - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ForOfStatement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ForOfStatement); - let range = convert_range(cx, node); - let is_await = unsafe { hermes::parser::hermes_get_ForOfStatement_await(node) }; - let left = ForInInit::convert( - cx, - unsafe { hermes::parser::hermes_get_ForOfStatement_left(node) }, - ); - let right = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ForOfStatement_right(node) }, - ); - let body = Statement::convert( - cx, - unsafe { hermes::parser::hermes_get_ForOfStatement_body(node) }, - ); - Self { - is_await, - left, - right, - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ClassBody { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ClassBody); - let range = convert_range(cx, node); - let body = convert_vec( - unsafe { hermes::parser::hermes_get_ClassBody_body(node) }, - |node| ClassItem::convert(cx, node), - ); - Self { - body, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for MethodDefinition { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::MethodDefinition); - let range = convert_range(cx, node); - let key = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_MethodDefinition_key(node) }, - ); - let value = FunctionExpression::convert( - cx, - unsafe { hermes::parser::hermes_get_MethodDefinition_value(node) }, - ); - let kind = MethodKind::convert( - cx, - unsafe { hermes::parser::hermes_get_MethodDefinition_kind(node) }, - ); - let is_computed = unsafe { - hermes::parser::hermes_get_MethodDefinition_computed(node) - }; - let is_static = unsafe { - hermes::parser::hermes_get_MethodDefinition_static(node) - }; - Self { - key, - value, - kind, - is_computed, - is_static, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for VariableDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::VariableDeclaration); - let range = convert_range(cx, node); - let kind = VariableDeclarationKind::convert( - cx, - unsafe { hermes::parser::hermes_get_VariableDeclaration_kind(node) }, - ); - let declarations = convert_vec( - unsafe { hermes::parser::hermes_get_VariableDeclaration_declarations(node) }, - |node| VariableDeclarator::convert(cx, node), - ); - Self { - kind, - declarations, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for VariableDeclarator { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::VariableDeclarator); - let range = convert_range(cx, node); - let id = Pattern::convert( - cx, - unsafe { hermes::parser::hermes_get_VariableDeclarator_id(node) }, - ); - let init = convert_option( - unsafe { hermes::parser::hermes_get_VariableDeclarator_init(node) }, - |node| Expression::convert(cx, node), - ); - Self { - id, - init, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ThisExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ThisExpression); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ArrayExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ArrayExpression); - let range = convert_range(cx, node); - let elements = convert_array_expression_elements( - cx, - unsafe { hermes::parser::hermes_get_ArrayExpression_elements(node) }, - ); - Self { - elements, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ObjectExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ObjectExpression); - let range = convert_range(cx, node); - let properties = convert_vec( - unsafe { hermes::parser::hermes_get_ObjectExpression_properties(node) }, - |node| PropertyOrSpreadElement::convert(cx, node), - ); - Self { - properties, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for Property { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::Property); - let range = convert_range(cx, node); - let key = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_Property_key(node) }, - ); - let value = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_Property_value(node) }, - ); - let kind = PropertyKind::convert( - cx, - unsafe { hermes::parser::hermes_get_Property_kind(node) }, - ); - let is_method = unsafe { hermes::parser::hermes_get_Property_method(node) }; - let is_shorthand = unsafe { - hermes::parser::hermes_get_Property_shorthand(node) - }; - let is_computed = unsafe { hermes::parser::hermes_get_Property_computed(node) }; - Self { - key, - value, - kind, - is_method, - is_shorthand, - is_computed, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for UnaryExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::UnaryExpression); - let range = convert_range(cx, node); - let operator = UnaryOperator::convert( - cx, - unsafe { hermes::parser::hermes_get_UnaryExpression_operator(node) }, - ); - let prefix = unsafe { hermes::parser::hermes_get_UnaryExpression_prefix(node) }; - let argument = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_UnaryExpression_argument(node) }, - ); - Self { - operator, - prefix, - argument, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for UpdateExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::UpdateExpression); - let range = convert_range(cx, node); - let operator = UpdateOperator::convert( - cx, - unsafe { hermes::parser::hermes_get_UpdateExpression_operator(node) }, - ); - let argument = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_UpdateExpression_argument(node) }, - ); - let prefix = unsafe { hermes::parser::hermes_get_UpdateExpression_prefix(node) }; - Self { - operator, - argument, - prefix, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for BinaryExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::BinaryExpression); - let range = convert_range(cx, node); - let left = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_BinaryExpression_left(node) }, - ); - let operator = BinaryOperator::convert( - cx, - unsafe { hermes::parser::hermes_get_BinaryExpression_operator(node) }, - ); - let right = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_BinaryExpression_right(node) }, - ); - Self { - left, - operator, - right, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for AssignmentExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::AssignmentExpression); - let range = convert_range(cx, node); - let operator = AssignmentOperator::convert( - cx, - unsafe { hermes::parser::hermes_get_AssignmentExpression_operator(node) }, - ); - let left = AssignmentTarget::convert( - cx, - unsafe { hermes::parser::hermes_get_AssignmentExpression_left(node) }, - ); - let right = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_AssignmentExpression_right(node) }, - ); - Self { - operator, - left, - right, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for LogicalExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::LogicalExpression); - let range = convert_range(cx, node); - let operator = LogicalOperator::convert( - cx, - unsafe { hermes::parser::hermes_get_LogicalExpression_operator(node) }, - ); - let left = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_LogicalExpression_left(node) }, - ); - let right = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_LogicalExpression_right(node) }, - ); - Self { - operator, - left, - right, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for MemberExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::MemberExpression); - let range = convert_range(cx, node); - let object = ExpressionOrSuper::convert( - cx, - unsafe { hermes::parser::hermes_get_MemberExpression_object(node) }, - ); - let property = ExpressionOrPrivateIdentifier::convert( - cx, - unsafe { hermes::parser::hermes_get_MemberExpression_property(node) }, - ); - let is_computed = unsafe { - hermes::parser::hermes_get_MemberExpression_computed(node) - }; - Self { - object, - property, - is_computed, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ConditionalExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ConditionalExpression); - let range = convert_range(cx, node); - let test = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ConditionalExpression_test(node) }, - ); - let alternate = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ConditionalExpression_alternate(node) }, - ); - let consequent = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ConditionalExpression_consequent(node) }, - ); - Self { - test, - alternate, - consequent, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for CallExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::CallExpression); - let range = convert_range(cx, node); - let callee = ExpressionOrSuper::convert( - cx, - unsafe { hermes::parser::hermes_get_CallExpression_callee(node) }, - ); - let arguments = convert_vec( - unsafe { hermes::parser::hermes_get_CallExpression_arguments(node) }, - |node| ExpressionOrSpread::convert(cx, node), - ); - Self { - callee, - arguments, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for NewExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::NewExpression); - let range = convert_range(cx, node); - let callee = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_NewExpression_callee(node) }, - ); - let arguments = convert_vec( - unsafe { hermes::parser::hermes_get_NewExpression_arguments(node) }, - |node| ExpressionOrSpread::convert(cx, node), - ); - Self { - callee, - arguments, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for SequenceExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::SequenceExpression); - let range = convert_range(cx, node); - let expressions = convert_vec( - unsafe { hermes::parser::hermes_get_SequenceExpression_expressions(node) }, - |node| Expression::convert(cx, node), - ); - Self { - expressions, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for Super { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::Super); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for SpreadElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::SpreadElement); - let range = convert_range(cx, node); - let argument = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_SpreadElement_argument(node) }, - ); - Self { - argument, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for YieldExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::YieldExpression); - let range = convert_range(cx, node); - let argument = convert_option( - unsafe { hermes::parser::hermes_get_YieldExpression_argument(node) }, - |node| Expression::convert(cx, node), - ); - let is_delegate = unsafe { - hermes::parser::hermes_get_YieldExpression_delegate(node) - }; - Self { - argument, - is_delegate, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ImportDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ImportDeclaration); - let range = convert_range(cx, node); - let specifiers = convert_vec( - unsafe { hermes::parser::hermes_get_ImportDeclaration_specifiers(node) }, - |node| ImportDeclarationSpecifier::convert(cx, node), - ); - let source = _Literal::convert( - cx, - unsafe { hermes::parser::hermes_get_ImportDeclaration_source(node) }, - ); - Self { - specifiers, - source, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ImportSpecifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ImportSpecifier); - let range = convert_range(cx, node); - let imported = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_ImportSpecifier_imported(node) }, - ); - let local = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_ImportSpecifier_local(node) }, - ); - Self { - imported, - local, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ImportDefaultSpecifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ImportDefaultSpecifier); - let range = convert_range(cx, node); - let local = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_ImportDefaultSpecifier_local(node) }, - ); - Self { - local, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ImportNamespaceSpecifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ImportNamespaceSpecifier); - let range = convert_range(cx, node); - let local = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_ImportNamespaceSpecifier_local(node) }, - ); - Self { - local, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ExportNamedDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ExportNamedDeclaration); - let range = convert_range(cx, node); - let declaration = convert_option( - unsafe { - hermes::parser::hermes_get_ExportNamedDeclaration_declaration(node) - }, - |node| Declaration::convert(cx, node), - ); - let specifiers = convert_vec( - unsafe { - hermes::parser::hermes_get_ExportNamedDeclaration_specifiers(node) - }, - |node| ExportSpecifier::convert(cx, node), - ); - let source = convert_option( - unsafe { hermes::parser::hermes_get_ExportNamedDeclaration_source(node) }, - |node| _Literal::convert(cx, node), - ); - Self { - declaration, - specifiers, - source, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ExportSpecifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ExportSpecifier); - let range = convert_range(cx, node); - let exported = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_ExportSpecifier_exported(node) }, - ); - Self { - exported, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ExportDefaultDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ExportDefaultDeclaration); - let range = convert_range(cx, node); - let declaration = DeclarationOrExpression::convert( - cx, - unsafe { - hermes::parser::hermes_get_ExportDefaultDeclaration_declaration(node) - }, - ); - Self { - declaration, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ExportAllDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ExportAllDeclaration); - let range = convert_range(cx, node); - let source = _Literal::convert( - cx, - unsafe { hermes::parser::hermes_get_ExportAllDeclaration_source(node) }, - ); - let exported = Default::default(); - Self { - source, - exported, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXIdentifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXIdentifier); - let range = convert_range(cx, node); - let name = convert_string( - cx, - unsafe { hermes::parser::hermes_get_JSXIdentifier_name(node) }, - ); - let binding = Default::default(); - Self { - name, - binding, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXNamespacedName { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXNamespacedName); - let range = convert_range(cx, node); - let namespace = JSXIdentifier::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXNamespacedName_namespace(node) }, - ); - let name = JSXIdentifier::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXNamespacedName_name(node) }, - ); - Self { - namespace, - name, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXMemberExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXMemberExpression); - let range = convert_range(cx, node); - let object = JSXMemberExpressionOrIdentifier::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXMemberExpression_object(node) }, - ); - let property = JSXIdentifier::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXMemberExpression_property(node) }, - ); - Self { - object, - property, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXEmptyExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXEmptyExpression); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXExpressionContainer { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXExpressionContainer); - let range = convert_range(cx, node); - let expression = JSXExpressionOrEmpty::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXExpressionContainer_expression(node) }, - ); - Self { - expression, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXSpreadChild { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXSpreadChild); - let range = convert_range(cx, node); - let expression = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXSpreadChild_expression(node) }, - ); - Self { - expression, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXOpeningElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXOpeningElement); - let range = convert_range(cx, node); - let name = JSXElementName::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXOpeningElement_name(node) }, - ); - let attributes = convert_vec( - unsafe { hermes::parser::hermes_get_JSXOpeningElement_attributes(node) }, - |node| JSXAttributeOrSpread::convert(cx, node), - ); - let self_closing = unsafe { - hermes::parser::hermes_get_JSXOpeningElement_selfClosing(node) - }; - Self { - name, - attributes, - self_closing, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXClosingElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXClosingElement); - let range = convert_range(cx, node); - let name = JSXElementName::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXClosingElement_name(node) }, - ); - Self { - name, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXAttribute { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXAttribute); - let range = convert_range(cx, node); - let name = JSXIdentifierOrNamespacedName::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXAttribute_name(node) }, - ); - let value = convert_option( - unsafe { hermes::parser::hermes_get_JSXAttribute_value(node) }, - |node| JSXAttributeValue::convert(cx, node), - ); - Self { - name, - value, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXSpreadAttribute { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXSpreadAttribute); - let range = convert_range(cx, node); - let argument = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXSpreadAttribute_argument(node) }, - ); - Self { - argument, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXText { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXText); - let range = convert_range(cx, node); - let value = convert_string_value( - cx, - unsafe { hermes::parser::hermes_get_JSXText_value(node) }, - ); - let raw = convert_string( - cx, - unsafe { hermes::parser::hermes_get_JSXText_raw(node) }, - ); - Self { - value, - raw, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXStringLiteral { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXStringLiteral); - let range = convert_range(cx, node); - let value = convert_string_value( - cx, - unsafe { hermes::parser::hermes_get_JSXStringLiteral_value(node) }, - ); - let raw = convert_string( - cx, - unsafe { hermes::parser::hermes_get_JSXStringLiteral_raw(node) }, - ); - Self { - value, - raw, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXElement); - let range = convert_range(cx, node); - let opening_element = JSXOpeningElement::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXElement_openingElement(node) }, - ); - let children = convert_vec( - unsafe { hermes::parser::hermes_get_JSXElement_children(node) }, - |node| JSXChildItem::convert(cx, node), - ); - let closing_element = convert_option( - unsafe { hermes::parser::hermes_get_JSXElement_closingElement(node) }, - |node| JSXClosingElement::convert(cx, node), - ); - Self { - opening_element, - children, - closing_element, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXFragment { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXFragment); - let range = convert_range(cx, node); - let opening_fragment = JSXOpeningFragment::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXFragment_openingFragment(node) }, - ); - let children = convert_vec( - unsafe { hermes::parser::hermes_get_JSXFragment_children(node) }, - |node| JSXChildItem::convert(cx, node), - ); - let closing_fragment = JSXClosingFragment::convert( - cx, - unsafe { hermes::parser::hermes_get_JSXFragment_closingFragment(node) }, - ); - Self { - opening_fragment, - children, - closing_fragment, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXOpeningFragment { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXOpeningFragment); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for JSXClosingFragment { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::JSXClosingFragment); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ArrayPattern { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ArrayPattern); - let range = convert_range(cx, node); - let elements = convert_vec_of_option( - unsafe { hermes::parser::hermes_get_ArrayPattern_elements(node) }, - |node| Pattern::convert(cx, node), - ); - Self { - elements, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ObjectPattern { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ObjectPattern); - let range = convert_range(cx, node); - let properties = convert_vec( - unsafe { hermes::parser::hermes_get_ObjectPattern_properties(node) }, - |node| AssignmentPropertyOrRestElement::convert(cx, node), - ); - Self { - properties, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for RestElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::RestElement); - let range = convert_range(cx, node); - let argument = Pattern::convert( - cx, - unsafe { hermes::parser::hermes_get_RestElement_argument(node) }, - ); - Self { - argument, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for AssignmentPattern { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::AssignmentPattern); - let range = convert_range(cx, node); - let left = Pattern::convert( - cx, - unsafe { hermes::parser::hermes_get_AssignmentPattern_left(node) }, - ); - let right = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_AssignmentPattern_right(node) }, - ); - Self { - left, - right, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for TemplateLiteral { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::TemplateLiteral); - let range = convert_range(cx, node); - let quasis = convert_vec( - unsafe { hermes::parser::hermes_get_TemplateLiteral_quasis(node) }, - |node| TemplateElement::convert(cx, node), - ); - let expressions = convert_vec( - unsafe { hermes::parser::hermes_get_TemplateLiteral_expressions(node) }, - |node| Expression::convert(cx, node), - ); - Self { - quasis, - expressions, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for TaggedTemplateExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::TaggedTemplateExpression); - let range = convert_range(cx, node); - let tag = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_TaggedTemplateExpression_tag(node) }, - ); - let quasi = TemplateLiteral::convert( - cx, - unsafe { hermes::parser::hermes_get_TaggedTemplateExpression_quasi(node) }, - ); - Self { - tag, - quasi, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for MetaProperty { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::MetaProperty); - let range = convert_range(cx, node); - let meta = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_MetaProperty_meta(node) }, - ); - let property = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_MetaProperty_property(node) }, - ); - Self { - meta, - property, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for AwaitExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::AwaitExpression); - let range = convert_range(cx, node); - let argument = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_AwaitExpression_argument(node) }, - ); - Self { - argument, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for OptionalMemberExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::OptionalMemberExpression); - let range = convert_range(cx, node); - let object = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_OptionalMemberExpression_object(node) }, - ); - let property = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_OptionalMemberExpression_property(node) }, - ); - let is_computed = unsafe { - hermes::parser::hermes_get_OptionalMemberExpression_computed(node) - }; - let is_optional = unsafe { - hermes::parser::hermes_get_OptionalMemberExpression_optional(node) - }; - Self { - object, - property, - is_computed, - is_optional, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for OptionalCallExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::OptionalCallExpression); - let range = convert_range(cx, node); - let callee = ExpressionOrSuper::convert( - cx, - unsafe { hermes::parser::hermes_get_OptionalCallExpression_callee(node) }, - ); - let arguments = convert_vec( - unsafe { hermes::parser::hermes_get_OptionalCallExpression_arguments(node) }, - |node| ExpressionOrSpread::convert(cx, node), - ); - let is_optional = unsafe { - hermes::parser::hermes_get_OptionalCallExpression_optional(node) - }; - Self { - callee, - arguments, - is_optional, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ImportExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ImportExpression); - let range = convert_range(cx, node); - let source = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ImportExpression_source(node) }, - ); - Self { - source, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ClassProperty { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ClassProperty); - let range = convert_range(cx, node); - let key = Expression::convert( - cx, - unsafe { hermes::parser::hermes_get_ClassProperty_key(node) }, - ); - let value = convert_option( - unsafe { hermes::parser::hermes_get_ClassProperty_value(node) }, - |node| Expression::convert(cx, node), - ); - let is_computed = unsafe { - hermes::parser::hermes_get_ClassProperty_computed(node) - }; - let is_static = unsafe { hermes::parser::hermes_get_ClassProperty_static(node) }; - Self { - key, - value, - is_computed, - is_static, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for ClassPrivateProperty { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::ClassPrivateProperty); - let range = convert_range(cx, node); - let key = ExpressionOrPrivateIdentifier::convert( - cx, - unsafe { hermes::parser::hermes_get_ClassPrivateProperty_key(node) }, - ); - let value = convert_option( - unsafe { hermes::parser::hermes_get_ClassPrivateProperty_value(node) }, - |node| Expression::convert(cx, node), - ); - let is_static = unsafe { - hermes::parser::hermes_get_ClassPrivateProperty_static(node) - }; - Self { - key, - value, - is_static, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for PrivateName { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::PrivateName); - let range = convert_range(cx, node); - let id = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_PrivateName_id(node) }, - ); - Self { - id, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for CoverTypedIdentifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::CoverTypedIdentifier); - let range = convert_range(cx, node); - let left = Identifier::convert( - cx, - unsafe { hermes::parser::hermes_get_CoverTypedIdentifier_left(node) }, - ); - let right = convert_option( - unsafe { hermes::parser::hermes_get_CoverTypedIdentifier_right(node) }, - |node| TypeAnnotation::convert(cx, node), - ); - Self { - left, - right, - loc: None, - range: Some(range), - } - } -} -impl FromHermes for TSTypeAnnotation { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::TSTypeAnnotation); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for TSTypeAliasDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - assert_eq!(node_ref.kind, NodeKind::TSTypeAliasDeclaration); - let range = convert_range(cx, node); - Self { - loc: None, - range: Some(range), - } - } -} -impl FromHermes for Statement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::BlockStatement => { - let node = BlockStatement::convert(cx, node); - Statement::BlockStatement(Box::new(node)) - } - NodeKind::BreakStatement => { - let node = BreakStatement::convert(cx, node); - Statement::BreakStatement(Box::new(node)) - } - NodeKind::ClassDeclaration => { - let node = ClassDeclaration::convert(cx, node); - Statement::ClassDeclaration(Box::new(node)) - } - NodeKind::ContinueStatement => { - let node = ContinueStatement::convert(cx, node); - Statement::ContinueStatement(Box::new(node)) - } - NodeKind::DebuggerStatement => { - let node = DebuggerStatement::convert(cx, node); - Statement::DebuggerStatement(Box::new(node)) - } - NodeKind::DoWhileStatement => { - let node = DoWhileStatement::convert(cx, node); - Statement::DoWhileStatement(Box::new(node)) - } - NodeKind::EmptyStatement => { - let node = EmptyStatement::convert(cx, node); - Statement::EmptyStatement(Box::new(node)) - } - NodeKind::ExpressionStatement => { - let node = ExpressionStatement::convert(cx, node); - Statement::ExpressionStatement(Box::new(node)) - } - NodeKind::ForInStatement => { - let node = ForInStatement::convert(cx, node); - Statement::ForInStatement(Box::new(node)) - } - NodeKind::ForOfStatement => { - let node = ForOfStatement::convert(cx, node); - Statement::ForOfStatement(Box::new(node)) - } - NodeKind::ForStatement => { - let node = ForStatement::convert(cx, node); - Statement::ForStatement(Box::new(node)) - } - NodeKind::FunctionDeclaration => { - let node = FunctionDeclaration::convert(cx, node); - Statement::FunctionDeclaration(Box::new(node)) - } - NodeKind::IfStatement => { - let node = IfStatement::convert(cx, node); - Statement::IfStatement(Box::new(node)) - } - NodeKind::LabeledStatement => { - let node = LabeledStatement::convert(cx, node); - Statement::LabeledStatement(Box::new(node)) - } - NodeKind::ReturnStatement => { - let node = ReturnStatement::convert(cx, node); - Statement::ReturnStatement(Box::new(node)) - } - NodeKind::SwitchStatement => { - let node = SwitchStatement::convert(cx, node); - Statement::SwitchStatement(Box::new(node)) - } - NodeKind::ThrowStatement => { - let node = ThrowStatement::convert(cx, node); - Statement::ThrowStatement(Box::new(node)) - } - NodeKind::TryStatement => { - let node = TryStatement::convert(cx, node); - Statement::TryStatement(Box::new(node)) - } - NodeKind::TSTypeAliasDeclaration => { - let node = TSTypeAliasDeclaration::convert(cx, node); - Statement::TSTypeAliasDeclaration(Box::new(node)) - } - NodeKind::VariableDeclaration => { - let node = VariableDeclaration::convert(cx, node); - Statement::VariableDeclaration(Box::new(node)) - } - NodeKind::WhileStatement => { - let node = WhileStatement::convert(cx, node); - Statement::WhileStatement(Box::new(node)) - } - NodeKind::WithStatement => { - let node = WithStatement::convert(cx, node); - Statement::WithStatement(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "Statement" - ) - } - } - } -} -impl FromHermes for Expression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - Expression::ArrayExpression(Box::new(node)) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - Expression::ArrowFunctionExpression(Box::new(node)) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - Expression::AssignmentExpression(Box::new(node)) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - Expression::AwaitExpression(Box::new(node)) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - Expression::BinaryExpression(Box::new(node)) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - Expression::BooleanLiteral(Box::new(node)) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - Expression::CallExpression(Box::new(node)) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - Expression::ClassExpression(Box::new(node)) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - Expression::ConditionalExpression(Box::new(node)) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - Expression::CoverTypedIdentifier(Box::new(node)) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - Expression::FunctionExpression(Box::new(node)) - } - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - Expression::Identifier(Box::new(node)) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - Expression::ImportExpression(Box::new(node)) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - Expression::JSXElement(Box::new(node)) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - Expression::JSXFragment(Box::new(node)) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - Expression::LogicalExpression(Box::new(node)) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - Expression::MemberExpression(Box::new(node)) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - Expression::MetaProperty(Box::new(node)) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - Expression::NewExpression(Box::new(node)) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - Expression::NullLiteral(Box::new(node)) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - Expression::NumericLiteral(Box::new(node)) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - Expression::ObjectExpression(Box::new(node)) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - Expression::OptionalCallExpression(Box::new(node)) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - Expression::OptionalMemberExpression(Box::new(node)) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - Expression::RegExpLiteral(Box::new(node)) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - Expression::SequenceExpression(Box::new(node)) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - Expression::StringLiteral(Box::new(node)) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - Expression::TaggedTemplateExpression(Box::new(node)) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - Expression::TemplateLiteral(Box::new(node)) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - Expression::ThisExpression(Box::new(node)) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - Expression::UnaryExpression(Box::new(node)) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - Expression::UpdateExpression(Box::new(node)) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - Expression::YieldExpression(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "Expression" - ) - } - } - } -} -impl FromHermes for _Literal { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - _Literal::BooleanLiteral(Box::new(node)) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - _Literal::NullLiteral(Box::new(node)) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - _Literal::StringLiteral(Box::new(node)) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - _Literal::NumericLiteral(Box::new(node)) - } - _ => { - panic!("Unexpected node kind `{:?}` for `{}`", node_ref.kind, "_Literal") - } - } - } -} -impl FromHermes for Declaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ClassDeclaration => { - let node = ClassDeclaration::convert(cx, node); - Declaration::ClassDeclaration(Box::new(node)) - } - NodeKind::FunctionDeclaration => { - let node = FunctionDeclaration::convert(cx, node); - Declaration::FunctionDeclaration(Box::new(node)) - } - NodeKind::VariableDeclaration => { - let node = VariableDeclaration::convert(cx, node); - Declaration::VariableDeclaration(Box::new(node)) - } - NodeKind::TSTypeAliasDeclaration => { - let node = TSTypeAliasDeclaration::convert(cx, node); - Declaration::TSTypeAliasDeclaration(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "Declaration" - ) - } - } - } -} -impl FromHermes for ImportDeclarationSpecifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ImportSpecifier => { - let node = ImportSpecifier::convert(cx, node); - ImportDeclarationSpecifier::ImportSpecifier(Box::new(node)) - } - NodeKind::ImportDefaultSpecifier => { - let node = ImportDefaultSpecifier::convert(cx, node); - ImportDeclarationSpecifier::ImportDefaultSpecifier(Box::new(node)) - } - NodeKind::ImportNamespaceSpecifier => { - let node = ImportNamespaceSpecifier::convert(cx, node); - ImportDeclarationSpecifier::ImportNamespaceSpecifier(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "ImportDeclarationSpecifier" - ) - } - } - } -} -impl FromHermes for ModuleItem { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ImportDeclaration => { - let node = ImportDeclaration::convert(cx, node); - ModuleItem::ImportOrExportDeclaration( - ImportOrExportDeclaration::ImportDeclaration(Box::new(node)), - ) - } - NodeKind::ExportNamedDeclaration => { - let node = ExportNamedDeclaration::convert(cx, node); - ModuleItem::ImportOrExportDeclaration( - ImportOrExportDeclaration::ExportNamedDeclaration(Box::new(node)), - ) - } - NodeKind::ExportDefaultDeclaration => { - let node = ExportDefaultDeclaration::convert(cx, node); - ModuleItem::ImportOrExportDeclaration( - ImportOrExportDeclaration::ExportDefaultDeclaration(Box::new(node)), - ) - } - NodeKind::ExportAllDeclaration => { - let node = ExportAllDeclaration::convert(cx, node); - ModuleItem::ImportOrExportDeclaration( - ImportOrExportDeclaration::ExportAllDeclaration(Box::new(node)), - ) - } - NodeKind::BlockStatement => { - let node = BlockStatement::convert(cx, node); - ModuleItem::Statement(Statement::BlockStatement(Box::new(node))) - } - NodeKind::BreakStatement => { - let node = BreakStatement::convert(cx, node); - ModuleItem::Statement(Statement::BreakStatement(Box::new(node))) - } - NodeKind::ClassDeclaration => { - let node = ClassDeclaration::convert(cx, node); - ModuleItem::Statement(Statement::ClassDeclaration(Box::new(node))) - } - NodeKind::ContinueStatement => { - let node = ContinueStatement::convert(cx, node); - ModuleItem::Statement(Statement::ContinueStatement(Box::new(node))) - } - NodeKind::DebuggerStatement => { - let node = DebuggerStatement::convert(cx, node); - ModuleItem::Statement(Statement::DebuggerStatement(Box::new(node))) - } - NodeKind::DoWhileStatement => { - let node = DoWhileStatement::convert(cx, node); - ModuleItem::Statement(Statement::DoWhileStatement(Box::new(node))) - } - NodeKind::EmptyStatement => { - let node = EmptyStatement::convert(cx, node); - ModuleItem::Statement(Statement::EmptyStatement(Box::new(node))) - } - NodeKind::ExpressionStatement => { - let node = ExpressionStatement::convert(cx, node); - ModuleItem::Statement(Statement::ExpressionStatement(Box::new(node))) - } - NodeKind::ForInStatement => { - let node = ForInStatement::convert(cx, node); - ModuleItem::Statement(Statement::ForInStatement(Box::new(node))) - } - NodeKind::ForOfStatement => { - let node = ForOfStatement::convert(cx, node); - ModuleItem::Statement(Statement::ForOfStatement(Box::new(node))) - } - NodeKind::ForStatement => { - let node = ForStatement::convert(cx, node); - ModuleItem::Statement(Statement::ForStatement(Box::new(node))) - } - NodeKind::FunctionDeclaration => { - let node = FunctionDeclaration::convert(cx, node); - ModuleItem::Statement(Statement::FunctionDeclaration(Box::new(node))) - } - NodeKind::IfStatement => { - let node = IfStatement::convert(cx, node); - ModuleItem::Statement(Statement::IfStatement(Box::new(node))) - } - NodeKind::LabeledStatement => { - let node = LabeledStatement::convert(cx, node); - ModuleItem::Statement(Statement::LabeledStatement(Box::new(node))) - } - NodeKind::ReturnStatement => { - let node = ReturnStatement::convert(cx, node); - ModuleItem::Statement(Statement::ReturnStatement(Box::new(node))) - } - NodeKind::SwitchStatement => { - let node = SwitchStatement::convert(cx, node); - ModuleItem::Statement(Statement::SwitchStatement(Box::new(node))) - } - NodeKind::ThrowStatement => { - let node = ThrowStatement::convert(cx, node); - ModuleItem::Statement(Statement::ThrowStatement(Box::new(node))) - } - NodeKind::TryStatement => { - let node = TryStatement::convert(cx, node); - ModuleItem::Statement(Statement::TryStatement(Box::new(node))) - } - NodeKind::TSTypeAliasDeclaration => { - let node = TSTypeAliasDeclaration::convert(cx, node); - ModuleItem::Statement(Statement::TSTypeAliasDeclaration(Box::new(node))) - } - NodeKind::VariableDeclaration => { - let node = VariableDeclaration::convert(cx, node); - ModuleItem::Statement(Statement::VariableDeclaration(Box::new(node))) - } - NodeKind::WhileStatement => { - let node = WhileStatement::convert(cx, node); - ModuleItem::Statement(Statement::WhileStatement(Box::new(node))) - } - NodeKind::WithStatement => { - let node = WithStatement::convert(cx, node); - ModuleItem::Statement(Statement::WithStatement(Box::new(node))) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "ModuleItem" - ) - } - } - } -} -impl FromHermes for ImportOrExportDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ImportDeclaration => { - let node = ImportDeclaration::convert(cx, node); - ImportOrExportDeclaration::ImportDeclaration(Box::new(node)) - } - NodeKind::ExportNamedDeclaration => { - let node = ExportNamedDeclaration::convert(cx, node); - ImportOrExportDeclaration::ExportNamedDeclaration(Box::new(node)) - } - NodeKind::ExportDefaultDeclaration => { - let node = ExportDefaultDeclaration::convert(cx, node); - ImportOrExportDeclaration::ExportDefaultDeclaration(Box::new(node)) - } - NodeKind::ExportAllDeclaration => { - let node = ExportAllDeclaration::convert(cx, node); - ImportOrExportDeclaration::ExportAllDeclaration(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "ImportOrExportDeclaration" - ) - } - } - } -} -impl FromHermes for ExpressionOrSuper { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::ArrayExpression(Box::new(node)), - ) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::ArrowFunctionExpression(Box::new(node)), - ) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::AssignmentExpression(Box::new(node)), - ) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::AwaitExpression(Box::new(node)), - ) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::BinaryExpression(Box::new(node)), - ) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - ExpressionOrSuper::Expression(Expression::BooleanLiteral(Box::new(node))) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - ExpressionOrSuper::Expression(Expression::CallExpression(Box::new(node))) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::ClassExpression(Box::new(node)), - ) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::ConditionalExpression(Box::new(node)), - ) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::CoverTypedIdentifier(Box::new(node)), - ) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::FunctionExpression(Box::new(node)), - ) - } - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - ExpressionOrSuper::Expression(Expression::Identifier(Box::new(node))) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::ImportExpression(Box::new(node)), - ) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - ExpressionOrSuper::Expression(Expression::JSXElement(Box::new(node))) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - ExpressionOrSuper::Expression(Expression::JSXFragment(Box::new(node))) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::LogicalExpression(Box::new(node)), - ) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::MemberExpression(Box::new(node)), - ) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - ExpressionOrSuper::Expression(Expression::MetaProperty(Box::new(node))) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - ExpressionOrSuper::Expression(Expression::NewExpression(Box::new(node))) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - ExpressionOrSuper::Expression(Expression::NullLiteral(Box::new(node))) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - ExpressionOrSuper::Expression(Expression::NumericLiteral(Box::new(node))) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::ObjectExpression(Box::new(node)), - ) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::OptionalCallExpression(Box::new(node)), - ) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::OptionalMemberExpression(Box::new(node)), - ) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - ExpressionOrSuper::Expression(Expression::RegExpLiteral(Box::new(node))) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::SequenceExpression(Box::new(node)), - ) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - ExpressionOrSuper::Expression(Expression::StringLiteral(Box::new(node))) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::TaggedTemplateExpression(Box::new(node)), - ) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::TemplateLiteral(Box::new(node)), - ) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - ExpressionOrSuper::Expression(Expression::ThisExpression(Box::new(node))) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::UnaryExpression(Box::new(node)), - ) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::UpdateExpression(Box::new(node)), - ) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - ExpressionOrSuper::Expression( - Expression::YieldExpression(Box::new(node)), - ) - } - NodeKind::Super => { - let node = Super::convert(cx, node); - ExpressionOrSuper::Super(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "ExpressionOrSuper" - ) - } - } - } -} -impl FromHermes for ExpressionOrSpread { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::ArrayExpression(Box::new(node)), - ) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::ArrowFunctionExpression(Box::new(node)), - ) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::AssignmentExpression(Box::new(node)), - ) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::AwaitExpression(Box::new(node)), - ) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::BinaryExpression(Box::new(node)), - ) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::BooleanLiteral(Box::new(node)), - ) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::CallExpression(Box::new(node)), - ) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::ClassExpression(Box::new(node)), - ) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::ConditionalExpression(Box::new(node)), - ) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::CoverTypedIdentifier(Box::new(node)), - ) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::FunctionExpression(Box::new(node)), - ) - } - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - ExpressionOrSpread::Expression(Expression::Identifier(Box::new(node))) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::ImportExpression(Box::new(node)), - ) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - ExpressionOrSpread::Expression(Expression::JSXElement(Box::new(node))) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - ExpressionOrSpread::Expression(Expression::JSXFragment(Box::new(node))) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::LogicalExpression(Box::new(node)), - ) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::MemberExpression(Box::new(node)), - ) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - ExpressionOrSpread::Expression(Expression::MetaProperty(Box::new(node))) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - ExpressionOrSpread::Expression(Expression::NewExpression(Box::new(node))) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - ExpressionOrSpread::Expression(Expression::NullLiteral(Box::new(node))) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::NumericLiteral(Box::new(node)), - ) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::ObjectExpression(Box::new(node)), - ) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::OptionalCallExpression(Box::new(node)), - ) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::OptionalMemberExpression(Box::new(node)), - ) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - ExpressionOrSpread::Expression(Expression::RegExpLiteral(Box::new(node))) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::SequenceExpression(Box::new(node)), - ) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - ExpressionOrSpread::Expression(Expression::StringLiteral(Box::new(node))) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::TaggedTemplateExpression(Box::new(node)), - ) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::TemplateLiteral(Box::new(node)), - ) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::ThisExpression(Box::new(node)), - ) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::UnaryExpression(Box::new(node)), - ) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::UpdateExpression(Box::new(node)), - ) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - ExpressionOrSpread::Expression( - Expression::YieldExpression(Box::new(node)), - ) - } - NodeKind::SpreadElement => { - let node = SpreadElement::convert(cx, node); - ExpressionOrSpread::SpreadElement(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "ExpressionOrSpread" - ) - } - } - } -} -impl FromHermes for FunctionBody { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::BlockStatement => { - let node = BlockStatement::convert(cx, node); - FunctionBody::BlockStatement(Box::new(node)) - } - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - FunctionBody::Expression(Expression::ArrayExpression(Box::new(node))) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - FunctionBody::Expression( - Expression::ArrowFunctionExpression(Box::new(node)), - ) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - FunctionBody::Expression( - Expression::AssignmentExpression(Box::new(node)), - ) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - FunctionBody::Expression(Expression::AwaitExpression(Box::new(node))) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - FunctionBody::Expression(Expression::BinaryExpression(Box::new(node))) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - FunctionBody::Expression(Expression::BooleanLiteral(Box::new(node))) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - FunctionBody::Expression(Expression::CallExpression(Box::new(node))) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - FunctionBody::Expression(Expression::ClassExpression(Box::new(node))) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - FunctionBody::Expression( - Expression::ConditionalExpression(Box::new(node)), - ) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - FunctionBody::Expression( - Expression::CoverTypedIdentifier(Box::new(node)), - ) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - FunctionBody::Expression(Expression::FunctionExpression(Box::new(node))) - } - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - FunctionBody::Expression(Expression::Identifier(Box::new(node))) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - FunctionBody::Expression(Expression::ImportExpression(Box::new(node))) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - FunctionBody::Expression(Expression::JSXElement(Box::new(node))) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - FunctionBody::Expression(Expression::JSXFragment(Box::new(node))) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - FunctionBody::Expression(Expression::LogicalExpression(Box::new(node))) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - FunctionBody::Expression(Expression::MemberExpression(Box::new(node))) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - FunctionBody::Expression(Expression::MetaProperty(Box::new(node))) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - FunctionBody::Expression(Expression::NewExpression(Box::new(node))) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - FunctionBody::Expression(Expression::NullLiteral(Box::new(node))) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - FunctionBody::Expression(Expression::NumericLiteral(Box::new(node))) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - FunctionBody::Expression(Expression::ObjectExpression(Box::new(node))) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - FunctionBody::Expression( - Expression::OptionalCallExpression(Box::new(node)), - ) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - FunctionBody::Expression( - Expression::OptionalMemberExpression(Box::new(node)), - ) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - FunctionBody::Expression(Expression::RegExpLiteral(Box::new(node))) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - FunctionBody::Expression(Expression::SequenceExpression(Box::new(node))) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - FunctionBody::Expression(Expression::StringLiteral(Box::new(node))) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - FunctionBody::Expression( - Expression::TaggedTemplateExpression(Box::new(node)), - ) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - FunctionBody::Expression(Expression::TemplateLiteral(Box::new(node))) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - FunctionBody::Expression(Expression::ThisExpression(Box::new(node))) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - FunctionBody::Expression(Expression::UnaryExpression(Box::new(node))) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - FunctionBody::Expression(Expression::UpdateExpression(Box::new(node))) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - FunctionBody::Expression(Expression::YieldExpression(Box::new(node))) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "FunctionBody" - ) - } - } - } -} -impl FromHermes for Pattern { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - Pattern::Identifier(Box::new(node)) - } - NodeKind::ArrayPattern => { - let node = ArrayPattern::convert(cx, node); - Pattern::ArrayPattern(Box::new(node)) - } - NodeKind::ObjectPattern => { - let node = ObjectPattern::convert(cx, node); - Pattern::ObjectPattern(Box::new(node)) - } - NodeKind::RestElement => { - let node = RestElement::convert(cx, node); - Pattern::RestElement(Box::new(node)) - } - NodeKind::AssignmentPattern => { - let node = AssignmentPattern::convert(cx, node); - Pattern::AssignmentPattern(Box::new(node)) - } - _ => panic!("Unexpected node kind `{:?}` for `{}`", node_ref.kind, "Pattern"), - } - } -} -impl FromHermes for ForInit { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - ForInit::Expression(Expression::ArrayExpression(Box::new(node))) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - ForInit::Expression(Expression::ArrowFunctionExpression(Box::new(node))) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - ForInit::Expression(Expression::AssignmentExpression(Box::new(node))) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - ForInit::Expression(Expression::AwaitExpression(Box::new(node))) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - ForInit::Expression(Expression::BinaryExpression(Box::new(node))) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - ForInit::Expression(Expression::BooleanLiteral(Box::new(node))) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - ForInit::Expression(Expression::CallExpression(Box::new(node))) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - ForInit::Expression(Expression::ClassExpression(Box::new(node))) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - ForInit::Expression(Expression::ConditionalExpression(Box::new(node))) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - ForInit::Expression(Expression::CoverTypedIdentifier(Box::new(node))) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - ForInit::Expression(Expression::FunctionExpression(Box::new(node))) - } - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - ForInit::Expression(Expression::Identifier(Box::new(node))) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - ForInit::Expression(Expression::ImportExpression(Box::new(node))) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - ForInit::Expression(Expression::JSXElement(Box::new(node))) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - ForInit::Expression(Expression::JSXFragment(Box::new(node))) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - ForInit::Expression(Expression::LogicalExpression(Box::new(node))) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - ForInit::Expression(Expression::MemberExpression(Box::new(node))) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - ForInit::Expression(Expression::MetaProperty(Box::new(node))) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - ForInit::Expression(Expression::NewExpression(Box::new(node))) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - ForInit::Expression(Expression::NullLiteral(Box::new(node))) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - ForInit::Expression(Expression::NumericLiteral(Box::new(node))) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - ForInit::Expression(Expression::ObjectExpression(Box::new(node))) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - ForInit::Expression(Expression::OptionalCallExpression(Box::new(node))) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - ForInit::Expression(Expression::OptionalMemberExpression(Box::new(node))) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - ForInit::Expression(Expression::RegExpLiteral(Box::new(node))) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - ForInit::Expression(Expression::SequenceExpression(Box::new(node))) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - ForInit::Expression(Expression::StringLiteral(Box::new(node))) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - ForInit::Expression(Expression::TaggedTemplateExpression(Box::new(node))) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - ForInit::Expression(Expression::TemplateLiteral(Box::new(node))) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - ForInit::Expression(Expression::ThisExpression(Box::new(node))) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - ForInit::Expression(Expression::UnaryExpression(Box::new(node))) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - ForInit::Expression(Expression::UpdateExpression(Box::new(node))) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - ForInit::Expression(Expression::YieldExpression(Box::new(node))) - } - NodeKind::VariableDeclaration => { - let node = VariableDeclaration::convert(cx, node); - ForInit::VariableDeclaration(Box::new(node)) - } - _ => panic!("Unexpected node kind `{:?}` for `{}`", node_ref.kind, "ForInit"), - } - } -} -impl FromHermes for ForInInit { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - ForInInit::Pattern(Pattern::Identifier(Box::new(node))) - } - NodeKind::ArrayPattern => { - let node = ArrayPattern::convert(cx, node); - ForInInit::Pattern(Pattern::ArrayPattern(Box::new(node))) - } - NodeKind::ObjectPattern => { - let node = ObjectPattern::convert(cx, node); - ForInInit::Pattern(Pattern::ObjectPattern(Box::new(node))) - } - NodeKind::RestElement => { - let node = RestElement::convert(cx, node); - ForInInit::Pattern(Pattern::RestElement(Box::new(node))) - } - NodeKind::AssignmentPattern => { - let node = AssignmentPattern::convert(cx, node); - ForInInit::Pattern(Pattern::AssignmentPattern(Box::new(node))) - } - NodeKind::VariableDeclaration => { - let node = VariableDeclaration::convert(cx, node); - ForInInit::VariableDeclaration(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "ForInInit" - ) - } - } - } -} -impl FromHermes for PropertyOrSpreadElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::Property => { - let node = Property::convert(cx, node); - PropertyOrSpreadElement::Property(Box::new(node)) - } - NodeKind::SpreadElement => { - let node = SpreadElement::convert(cx, node); - PropertyOrSpreadElement::SpreadElement(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "PropertyOrSpreadElement" - ) - } - } - } -} -impl FromHermes for AssignmentPropertyOrRestElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::Property => { - let node = AssignmentProperty::convert(cx, node); - AssignmentPropertyOrRestElement::AssignmentProperty(Box::new(node)) - } - NodeKind::RestElement => { - let node = RestElement::convert(cx, node); - AssignmentPropertyOrRestElement::RestElement(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "AssignmentPropertyOrRestElement" - ) - } - } - } -} -impl FromHermes for AssignmentTarget { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - AssignmentTarget::Pattern(Pattern::Identifier(Box::new(node))) - } - NodeKind::ArrayPattern => { - let node = ArrayPattern::convert(cx, node); - AssignmentTarget::Pattern(Pattern::ArrayPattern(Box::new(node))) - } - NodeKind::ObjectPattern => { - let node = ObjectPattern::convert(cx, node); - AssignmentTarget::Pattern(Pattern::ObjectPattern(Box::new(node))) - } - NodeKind::RestElement => { - let node = RestElement::convert(cx, node); - AssignmentTarget::Pattern(Pattern::RestElement(Box::new(node))) - } - NodeKind::AssignmentPattern => { - let node = AssignmentPattern::convert(cx, node); - AssignmentTarget::Pattern(Pattern::AssignmentPattern(Box::new(node))) - } - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - AssignmentTarget::Expression(Expression::ArrayExpression(Box::new(node))) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::ArrowFunctionExpression(Box::new(node)), - ) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::AssignmentExpression(Box::new(node)), - ) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - AssignmentTarget::Expression(Expression::AwaitExpression(Box::new(node))) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::BinaryExpression(Box::new(node)), - ) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - AssignmentTarget::Expression(Expression::BooleanLiteral(Box::new(node))) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - AssignmentTarget::Expression(Expression::CallExpression(Box::new(node))) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - AssignmentTarget::Expression(Expression::ClassExpression(Box::new(node))) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::ConditionalExpression(Box::new(node)), - ) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - AssignmentTarget::Expression( - Expression::CoverTypedIdentifier(Box::new(node)), - ) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::FunctionExpression(Box::new(node)), - ) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::ImportExpression(Box::new(node)), - ) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - AssignmentTarget::Expression(Expression::JSXElement(Box::new(node))) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - AssignmentTarget::Expression(Expression::JSXFragment(Box::new(node))) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::LogicalExpression(Box::new(node)), - ) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::MemberExpression(Box::new(node)), - ) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - AssignmentTarget::Expression(Expression::MetaProperty(Box::new(node))) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - AssignmentTarget::Expression(Expression::NewExpression(Box::new(node))) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - AssignmentTarget::Expression(Expression::NullLiteral(Box::new(node))) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - AssignmentTarget::Expression(Expression::NumericLiteral(Box::new(node))) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::ObjectExpression(Box::new(node)), - ) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::OptionalCallExpression(Box::new(node)), - ) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::OptionalMemberExpression(Box::new(node)), - ) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - AssignmentTarget::Expression(Expression::RegExpLiteral(Box::new(node))) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::SequenceExpression(Box::new(node)), - ) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - AssignmentTarget::Expression(Expression::StringLiteral(Box::new(node))) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::TaggedTemplateExpression(Box::new(node)), - ) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - AssignmentTarget::Expression(Expression::TemplateLiteral(Box::new(node))) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - AssignmentTarget::Expression(Expression::ThisExpression(Box::new(node))) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - AssignmentTarget::Expression(Expression::UnaryExpression(Box::new(node))) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - AssignmentTarget::Expression( - Expression::UpdateExpression(Box::new(node)), - ) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - AssignmentTarget::Expression(Expression::YieldExpression(Box::new(node))) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "AssignmentTarget" - ) - } - } - } -} -impl FromHermes for ChainElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - ChainElement::CallExpression(Box::new(node)) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - ChainElement::MemberExpression(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "ChainElement" - ) - } - } - } -} -impl FromHermes for JSXMemberExpressionOrIdentifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::JSXMemberExpression => { - let node = JSXMemberExpression::convert(cx, node); - JSXMemberExpressionOrIdentifier::JSXMemberExpression(Box::new(node)) - } - NodeKind::JSXIdentifier => { - let node = JSXIdentifier::convert(cx, node); - JSXMemberExpressionOrIdentifier::JSXIdentifier(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "JSXMemberExpressionOrIdentifier" - ) - } - } - } -} -impl FromHermes for JSXExpressionOrEmpty { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::ArrayExpression(Box::new(node)), - ) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::ArrowFunctionExpression(Box::new(node)), - ) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::AssignmentExpression(Box::new(node)), - ) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::AwaitExpression(Box::new(node)), - ) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::BinaryExpression(Box::new(node)), - ) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::BooleanLiteral(Box::new(node)), - ) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::CallExpression(Box::new(node)), - ) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::ClassExpression(Box::new(node)), - ) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::ConditionalExpression(Box::new(node)), - ) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::CoverTypedIdentifier(Box::new(node)), - ) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::FunctionExpression(Box::new(node)), - ) - } - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - JSXExpressionOrEmpty::Expression(Expression::Identifier(Box::new(node))) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::ImportExpression(Box::new(node)), - ) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - JSXExpressionOrEmpty::Expression(Expression::JSXElement(Box::new(node))) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - JSXExpressionOrEmpty::Expression(Expression::JSXFragment(Box::new(node))) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::LogicalExpression(Box::new(node)), - ) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::MemberExpression(Box::new(node)), - ) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::MetaProperty(Box::new(node)), - ) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::NewExpression(Box::new(node)), - ) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - JSXExpressionOrEmpty::Expression(Expression::NullLiteral(Box::new(node))) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::NumericLiteral(Box::new(node)), - ) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::ObjectExpression(Box::new(node)), - ) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::OptionalCallExpression(Box::new(node)), - ) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::OptionalMemberExpression(Box::new(node)), - ) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::RegExpLiteral(Box::new(node)), - ) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::SequenceExpression(Box::new(node)), - ) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::StringLiteral(Box::new(node)), - ) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::TaggedTemplateExpression(Box::new(node)), - ) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::TemplateLiteral(Box::new(node)), - ) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::ThisExpression(Box::new(node)), - ) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::UnaryExpression(Box::new(node)), - ) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::UpdateExpression(Box::new(node)), - ) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - JSXExpressionOrEmpty::Expression( - Expression::YieldExpression(Box::new(node)), - ) - } - NodeKind::JSXEmptyExpression => { - let node = JSXEmptyExpression::convert(cx, node); - JSXExpressionOrEmpty::JSXEmptyExpression(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "JSXExpressionOrEmpty" - ) - } - } - } -} -impl FromHermes for JSXAttributeOrSpread { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::JSXAttribute => { - let node = JSXAttribute::convert(cx, node); - JSXAttributeOrSpread::JSXAttribute(Box::new(node)) - } - NodeKind::JSXSpreadAttribute => { - let node = JSXSpreadAttribute::convert(cx, node); - JSXAttributeOrSpread::JSXSpreadAttribute(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "JSXAttributeOrSpread" - ) - } - } - } -} -impl FromHermes for JSXAttributeValue { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::JSXExpressionContainer => { - let node = JSXExpressionContainer::convert(cx, node); - JSXAttributeValue::JSXExpressionContainer(Box::new(node)) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - JSXAttributeValue::JSXElement(Box::new(node)) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - JSXAttributeValue::JSXFragment(Box::new(node)) - } - NodeKind::JSXStringLiteral => { - let node = JSXStringLiteral::convert(cx, node); - JSXAttributeValue::JSXStringLiteral(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "JSXAttributeValue" - ) - } - } - } -} -impl FromHermes for JSXElementName { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::JSXIdentifier => { - let node = JSXIdentifier::convert(cx, node); - JSXElementName::JSXIdentifier(Box::new(node)) - } - NodeKind::JSXMemberExpression => { - let node = JSXMemberExpression::convert(cx, node); - JSXElementName::JSXMemberExpression(Box::new(node)) - } - NodeKind::JSXNamespacedName => { - let node = JSXNamespacedName::convert(cx, node); - JSXElementName::JSXNamespacedName(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "JSXElementName" - ) - } - } - } -} -impl FromHermes for JSXIdentifierOrNamespacedName { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::JSXIdentifier => { - let node = JSXIdentifier::convert(cx, node); - JSXIdentifierOrNamespacedName::JSXIdentifier(Box::new(node)) - } - NodeKind::JSXNamespacedName => { - let node = JSXNamespacedName::convert(cx, node); - JSXIdentifierOrNamespacedName::JSXNamespacedName(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "JSXIdentifierOrNamespacedName" - ) - } - } - } -} -impl FromHermes for JSXChildItem { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::JSXText => { - let node = JSXText::convert(cx, node); - JSXChildItem::JSXText(Box::new(node)) - } - NodeKind::JSXStringLiteral => { - let node = JSXStringLiteral::convert(cx, node); - JSXChildItem::JSXStringLiteral(Box::new(node)) - } - NodeKind::JSXExpressionContainer => { - let node = JSXExpressionContainer::convert(cx, node); - JSXChildItem::JSXExpressionContainer(Box::new(node)) - } - NodeKind::JSXSpreadChild => { - let node = JSXSpreadChild::convert(cx, node); - JSXChildItem::JSXSpreadChild(Box::new(node)) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - JSXChildItem::JSXElement(Box::new(node)) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - JSXChildItem::JSXFragment(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "JSXChildItem" - ) - } - } - } -} -impl FromHermes for DeclarationOrExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ClassDeclaration => { - let node = ClassDeclaration::convert(cx, node); - DeclarationOrExpression::Declaration( - Declaration::ClassDeclaration(Box::new(node)), - ) - } - NodeKind::FunctionDeclaration => { - let node = FunctionDeclaration::convert(cx, node); - DeclarationOrExpression::Declaration( - Declaration::FunctionDeclaration(Box::new(node)), - ) - } - NodeKind::VariableDeclaration => { - let node = VariableDeclaration::convert(cx, node); - DeclarationOrExpression::Declaration( - Declaration::VariableDeclaration(Box::new(node)), - ) - } - NodeKind::TSTypeAliasDeclaration => { - let node = TSTypeAliasDeclaration::convert(cx, node); - DeclarationOrExpression::Declaration( - Declaration::TSTypeAliasDeclaration(Box::new(node)), - ) - } - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::ArrayExpression(Box::new(node)), - ) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::ArrowFunctionExpression(Box::new(node)), - ) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::AssignmentExpression(Box::new(node)), - ) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::AwaitExpression(Box::new(node)), - ) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::BinaryExpression(Box::new(node)), - ) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::BooleanLiteral(Box::new(node)), - ) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::CallExpression(Box::new(node)), - ) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::ClassExpression(Box::new(node)), - ) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::ConditionalExpression(Box::new(node)), - ) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::CoverTypedIdentifier(Box::new(node)), - ) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::FunctionExpression(Box::new(node)), - ) - } - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::Identifier(Box::new(node)), - ) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::ImportExpression(Box::new(node)), - ) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::JSXElement(Box::new(node)), - ) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::JSXFragment(Box::new(node)), - ) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::LogicalExpression(Box::new(node)), - ) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::MemberExpression(Box::new(node)), - ) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::MetaProperty(Box::new(node)), - ) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::NewExpression(Box::new(node)), - ) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::NullLiteral(Box::new(node)), - ) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::NumericLiteral(Box::new(node)), - ) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::ObjectExpression(Box::new(node)), - ) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::OptionalCallExpression(Box::new(node)), - ) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::OptionalMemberExpression(Box::new(node)), - ) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::RegExpLiteral(Box::new(node)), - ) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::SequenceExpression(Box::new(node)), - ) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::StringLiteral(Box::new(node)), - ) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::TaggedTemplateExpression(Box::new(node)), - ) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::TemplateLiteral(Box::new(node)), - ) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::ThisExpression(Box::new(node)), - ) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::UnaryExpression(Box::new(node)), - ) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::UpdateExpression(Box::new(node)), - ) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - DeclarationOrExpression::Expression( - Expression::YieldExpression(Box::new(node)), - ) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "DeclarationOrExpression" - ) - } - } - } -} -impl FromHermes for ClassItem { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::MethodDefinition => { - let node = MethodDefinition::convert(cx, node); - ClassItem::MethodDefinition(Box::new(node)) - } - NodeKind::ClassProperty => { - let node = ClassProperty::convert(cx, node); - ClassItem::ClassProperty(Box::new(node)) - } - NodeKind::ClassPrivateProperty => { - let node = ClassPrivateProperty::convert(cx, node); - ClassItem::ClassPrivateProperty(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, "ClassItem" - ) - } - } - } -} -impl FromHermes for ExpressionOrPrivateIdentifier { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::ArrayExpression => { - let node = ArrayExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::ArrayExpression(Box::new(node)), - ) - } - NodeKind::ArrowFunctionExpression => { - let node = ArrowFunctionExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::ArrowFunctionExpression(Box::new(node)), - ) - } - NodeKind::AssignmentExpression => { - let node = AssignmentExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::AssignmentExpression(Box::new(node)), - ) - } - NodeKind::AwaitExpression => { - let node = AwaitExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::AwaitExpression(Box::new(node)), - ) - } - NodeKind::BinaryExpression => { - let node = BinaryExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::BinaryExpression(Box::new(node)), - ) - } - NodeKind::BooleanLiteral => { - let node = BooleanLiteral::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::BooleanLiteral(Box::new(node)), - ) - } - NodeKind::CallExpression => { - let node = CallExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::CallExpression(Box::new(node)), - ) - } - NodeKind::ClassExpression => { - let node = ClassExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::ClassExpression(Box::new(node)), - ) - } - NodeKind::ConditionalExpression => { - let node = ConditionalExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::ConditionalExpression(Box::new(node)), - ) - } - NodeKind::CoverTypedIdentifier => { - let node = CoverTypedIdentifier::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::CoverTypedIdentifier(Box::new(node)), - ) - } - NodeKind::FunctionExpression => { - let node = FunctionExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::FunctionExpression(Box::new(node)), - ) - } - NodeKind::Identifier => { - let node = Identifier::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::Identifier(Box::new(node)), - ) - } - NodeKind::ImportExpression => { - let node = ImportExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::ImportExpression(Box::new(node)), - ) - } - NodeKind::JSXElement => { - let node = JSXElement::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::JSXElement(Box::new(node)), - ) - } - NodeKind::JSXFragment => { - let node = JSXFragment::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::JSXFragment(Box::new(node)), - ) - } - NodeKind::LogicalExpression => { - let node = LogicalExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::LogicalExpression(Box::new(node)), - ) - } - NodeKind::MemberExpression => { - let node = MemberExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::MemberExpression(Box::new(node)), - ) - } - NodeKind::MetaProperty => { - let node = MetaProperty::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::MetaProperty(Box::new(node)), - ) - } - NodeKind::NewExpression => { - let node = NewExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::NewExpression(Box::new(node)), - ) - } - NodeKind::NullLiteral => { - let node = NullLiteral::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::NullLiteral(Box::new(node)), - ) - } - NodeKind::NumericLiteral => { - let node = NumericLiteral::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::NumericLiteral(Box::new(node)), - ) - } - NodeKind::ObjectExpression => { - let node = ObjectExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::ObjectExpression(Box::new(node)), - ) - } - NodeKind::OptionalCallExpression => { - let node = OptionalCallExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::OptionalCallExpression(Box::new(node)), - ) - } - NodeKind::OptionalMemberExpression => { - let node = OptionalMemberExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::OptionalMemberExpression(Box::new(node)), - ) - } - NodeKind::RegExpLiteral => { - let node = RegExpLiteral::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::RegExpLiteral(Box::new(node)), - ) - } - NodeKind::SequenceExpression => { - let node = SequenceExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::SequenceExpression(Box::new(node)), - ) - } - NodeKind::StringLiteral => { - let node = StringLiteral::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::StringLiteral(Box::new(node)), - ) - } - NodeKind::TaggedTemplateExpression => { - let node = TaggedTemplateExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::TaggedTemplateExpression(Box::new(node)), - ) - } - NodeKind::TemplateLiteral => { - let node = TemplateLiteral::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::TemplateLiteral(Box::new(node)), - ) - } - NodeKind::ThisExpression => { - let node = ThisExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::ThisExpression(Box::new(node)), - ) - } - NodeKind::UnaryExpression => { - let node = UnaryExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::UnaryExpression(Box::new(node)), - ) - } - NodeKind::UpdateExpression => { - let node = UpdateExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::UpdateExpression(Box::new(node)), - ) - } - NodeKind::YieldExpression => { - let node = YieldExpression::convert(cx, node); - ExpressionOrPrivateIdentifier::Expression( - Expression::YieldExpression(Box::new(node)), - ) - } - NodeKind::PrivateName => { - let node = PrivateName::convert(cx, node); - ExpressionOrPrivateIdentifier::PrivateName(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "ExpressionOrPrivateIdentifier" - ) - } - } - } -} -impl FromHermes for TypeAnnotation { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::TSTypeAnnotation => { - let node = TSTypeAnnotation::convert(cx, node); - TypeAnnotation::TSTypeAnnotation(Box::new(node)) - } - _ => { - panic!( - "Unexpected node kind `{:?}` for `{}`", node_ref.kind, - "TypeAnnotation" - ) - } - } - } -} -impl FromHermesLabel for VariableDeclarationKind { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} -impl FromHermesLabel for PropertyKind { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} -impl FromHermesLabel for UnaryOperator { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} -impl FromHermesLabel for UpdateOperator { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} -impl FromHermesLabel for BinaryOperator { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} -impl FromHermesLabel for AssignmentOperator { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} -impl FromHermesLabel for LogicalOperator { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} -impl FromHermesLabel for SourceType { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} -impl FromHermesLabel for MethodKind { - fn convert(cx: &mut Context, label: NodeLabel) -> Self { - let utf_str = utf8_with_surrogates_to_string(label.as_slice()).unwrap(); - utf_str.parse().unwrap() - } -} diff --git a/compiler/crates/react_hermes_parser/src/generated_extension.rs b/compiler/crates/react_hermes_parser/src/generated_extension.rs deleted file mode 100644 index bf9ac87a99074..0000000000000 --- a/compiler/crates/react_hermes_parser/src/generated_extension.rs +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -use std::num::NonZeroU32; - -use hermes::parser::{ - hermes_get_ArrowFunctionExpression_async, hermes_get_ArrowFunctionExpression_body, - hermes_get_ArrowFunctionExpression_expression, hermes_get_ArrowFunctionExpression_id, - hermes_get_ArrowFunctionExpression_params, hermes_get_ClassDeclaration_body, - hermes_get_ClassDeclaration_id, hermes_get_ClassDeclaration_superClass, - hermes_get_ClassExpression_body, hermes_get_ClassExpression_id, - hermes_get_ClassExpression_superClass, hermes_get_FunctionDeclaration_async, - hermes_get_FunctionDeclaration_body, hermes_get_FunctionDeclaration_generator, - hermes_get_FunctionDeclaration_id, hermes_get_FunctionDeclaration_params, - hermes_get_FunctionExpression_async, hermes_get_FunctionExpression_body, - hermes_get_FunctionExpression_generator, hermes_get_FunctionExpression_id, - hermes_get_FunctionExpression_params, hermes_get_Property_computed, hermes_get_Property_key, - hermes_get_Property_kind, hermes_get_Property_method, hermes_get_Property_shorthand, - hermes_get_Property_value, NodeKind, NodeLabel, NodeLabelOpt, NodeListRef, NodePtr, NodePtrOpt, - NodeString, NodeStringOpt, SMRange, -}; -use hermes::utf::utf8_with_surrogates_to_string; -use juno_support::NullTerminatedBuf; -use react_estree::{ - ArrowFunctionExpression, AssignmentProperty, Class, ClassBody, ClassDeclaration, - ClassExpression, Expression, ExpressionOrSpread, Function, FunctionBody, FunctionDeclaration, - FunctionExpression, Identifier, Number, Pattern, SourceRange, TemplateElement, - TemplateElementValue, -}; - -pub struct Context { - start: usize, -} - -impl Context { - pub fn new(parser: &NullTerminatedBuf) -> Self { - // SAFETY: This function returns a pointer to the underlying - // buffer. It is safe to get the pointer, it is only unsafe to - // use that pointer in unsafe ways. We only use the value to - // calculate offsets (and only use safe APIs to access the string - // based on those offsets). - let ptr = unsafe { parser.as_ptr() }; - let start = ptr as usize; - Self { start } - } -} - -pub trait FromHermes { - fn convert(cx: &mut Context, node: NodePtr) -> Self; -} -pub trait FromHermesLabel { - fn convert(cx: &mut Context, label: NodeLabel) -> Self; -} - -pub fn convert_option(node: NodePtrOpt, f: F) -> Option -where - F: FnMut(NodePtr) -> T, -{ - node.as_node_ptr().map(f) -} - -pub fn convert_vec(node: NodeListRef, mut f: F) -> Vec -where - F: FnMut(NodePtr) -> T, -{ - node.iter().map(|node| f(NodePtr::new(node))).collect() -} - -pub fn convert_vec_of_option(node: NodeListRef, mut f: F) -> Vec> -where - F: FnMut(NodePtr) -> T, -{ - node.iter() - .map(|node| { - let node = NodePtr::new(node); - let node_ref = node.as_ref(); - match node_ref.kind { - NodeKind::Empty => None, - _ => Some(f(node)), - } - }) - .collect() -} - -pub fn convert_range(cx: &Context, node: NodePtr) -> SourceRange { - let range = node.as_ref().source_range; - let absolute_start: usize = range.start.as_ptr() as usize; - let start = absolute_start - cx.start; - let absolute_end: usize = range.end.as_ptr() as usize; - let end = absolute_end - cx.start; - SourceRange { - start: start as u32, - end: NonZeroU32::new(end as u32).unwrap(), - } -} - -#[allow(dead_code)] -pub fn convert_smrange(_range: SMRange) -> SourceRange { - todo!() -} - -pub fn convert_string(_cx: &mut Context, label: NodeLabel) -> String { - utf8_with_surrogates_to_string(label.as_slice()).unwrap() -} - -#[allow(dead_code)] -pub fn convert_option_string(cx: &mut Context, label: NodeLabelOpt) -> Option { - label.as_node_label().map(|label| convert_string(cx, label)) -} - -pub fn convert_string_value(_cx: &mut Context, label: NodeString) -> String { - utf8_with_surrogates_to_string(label.as_slice()).unwrap() -} - -pub fn convert_option_string_value(_cx: &mut Context, label: NodeStringOpt) -> Option { - label - .as_node_string() - .map(|label| utf8_with_surrogates_to_string(label.as_slice()).unwrap()) -} - -pub fn convert_number(value: f64) -> Number { - value.into() -} - -pub fn convert_array_expression_elements( - cx: &mut Context, - node: NodeListRef, -) -> Vec> { - convert_vec_of_option(node, |node| ExpressionOrSpread::convert(cx, node)) -} - -impl FromHermes for TemplateElement { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let range = convert_range(cx, node); - let tail = unsafe { hermes::parser::hermes_get_TemplateElement_tail(node) }; - let value = TemplateElementValue { - cooked: convert_option_string_value(cx, unsafe { - hermes::parser::hermes_get_TemplateElement_cooked(node) - }), - raw: convert_string(cx, unsafe { - hermes::parser::hermes_get_TemplateElement_raw(node) - }), - }; - Self { - tail, - value, - loc: None, - range: Some(range), - } - } -} - -impl FromHermes for AssignmentProperty { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let key = FromHermes::convert(cx, unsafe { hermes_get_Property_key(node) }); - let value = FromHermes::convert(cx, unsafe { hermes_get_Property_value(node) }); - let kind = FromHermesLabel::convert(cx, unsafe { hermes_get_Property_kind(node) }); - let is_method = unsafe { hermes_get_Property_method(node) }; - let is_computed = unsafe { hermes_get_Property_computed(node) }; - let is_shorthand = unsafe { hermes_get_Property_shorthand(node) }; - let loc = None; - let range = convert_range(cx, node); - AssignmentProperty { - key, - value, - kind, - is_method, - is_computed, - is_shorthand, - loc, - range: Some(range), - } - } -} - -impl FromHermes for FunctionDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let id = convert_option(unsafe { hermes_get_FunctionDeclaration_id(node) }, |node| { - Identifier::convert(cx, node) - }); - let params = convert_vec( - unsafe { hermes_get_FunctionDeclaration_params(node) }, - |node| Pattern::convert(cx, node), - ); - let body = FunctionBody::convert(cx, unsafe { hermes_get_FunctionDeclaration_body(node) }); - let is_generator = unsafe { hermes_get_FunctionDeclaration_generator(node) }; - let is_async = unsafe { hermes_get_FunctionDeclaration_async(node) }; - let loc = None; - let range = convert_range(cx, node); - FunctionDeclaration { - function: Function { - id, - params, - body: Some(body), - is_generator, - is_async, - loc: loc.clone(), - range: Some(range), - }, - loc, - range: Some(range), - } - } -} - -impl FromHermes for FunctionExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let id = convert_option(unsafe { hermes_get_FunctionExpression_id(node) }, |node| { - Identifier::convert(cx, node) - }); - let params = convert_vec( - unsafe { hermes_get_FunctionExpression_params(node) }, - |node| Pattern::convert(cx, node), - ); - let body = FunctionBody::convert(cx, unsafe { hermes_get_FunctionExpression_body(node) }); - let is_generator = unsafe { hermes_get_FunctionExpression_generator(node) }; - let is_async = unsafe { hermes_get_FunctionExpression_async(node) }; - let loc = None; - let range = convert_range(cx, node); - FunctionExpression { - function: Function { - id, - params, - body: Some(body), - is_generator, - is_async, - loc: loc.clone(), - range: Some(range), - }, - loc, - range: Some(range), - } - } -} - -impl FromHermes for ArrowFunctionExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let id = convert_option( - unsafe { hermes_get_ArrowFunctionExpression_id(node) }, - |node| Identifier::convert(cx, node), - ); - let params = convert_vec( - unsafe { hermes_get_ArrowFunctionExpression_params(node) }, - |node| Pattern::convert(cx, node), - ); - let body = - FunctionBody::convert(cx, unsafe { hermes_get_ArrowFunctionExpression_body(node) }); - let is_generator = unsafe { hermes_get_FunctionExpression_generator(node) }; - let is_async = unsafe { hermes_get_ArrowFunctionExpression_async(node) }; - let is_expression = unsafe { hermes_get_ArrowFunctionExpression_expression(node) }; - let loc = None; - let range = convert_range(cx, node); - ArrowFunctionExpression { - function: Function { - id, - params, - body: Some(body), - is_generator, - is_async, - loc: loc.clone(), - range: Some(range), - }, - is_expression, - loc, - range: Some(range), - } - } -} - -impl FromHermes for ClassDeclaration { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let id = convert_option(unsafe { hermes_get_ClassDeclaration_id(node) }, |node| { - Identifier::convert(cx, node) - }); - let super_class = convert_option( - unsafe { hermes_get_ClassDeclaration_superClass(node) }, - |node| Expression::convert(cx, node), - ); - let body = ClassBody::convert(cx, unsafe { hermes_get_ClassDeclaration_body(node) }); - let loc = None; - let range = convert_range(cx, node); - ClassDeclaration { - class: Class { - id, - super_class, - body, - }, - loc, - range: Some(range), - } - } -} -impl FromHermes for ClassExpression { - fn convert(cx: &mut Context, node: NodePtr) -> Self { - let id = convert_option(unsafe { hermes_get_ClassExpression_id(node) }, |node| { - Identifier::convert(cx, node) - }); - let super_class = convert_option( - unsafe { hermes_get_ClassExpression_superClass(node) }, - |node| Expression::convert(cx, node), - ); - let body = ClassBody::convert(cx, unsafe { hermes_get_ClassExpression_body(node) }); - let loc = None; - let range = convert_range(cx, node); - ClassExpression { - class: Class { - id, - super_class, - body, - }, - loc, - range: Some(range), - } - } -} diff --git a/compiler/crates/react_hermes_parser/src/lib.rs b/compiler/crates/react_hermes_parser/src/lib.rs deleted file mode 100644 index 8524d4571f0d5..0000000000000 --- a/compiler/crates/react_hermes_parser/src/lib.rs +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -mod generated; -mod generated_extension; - -use generated_extension::{Context, FromHermes}; -use hermes::parser::{HermesParser, ParserDialect, ParserFlags}; -use hermes::utf::utf8_with_surrogates_to_string; -use juno_support::NullTerminatedBuf; -use react_diagnostics::Diagnostic; -use react_estree::Program; - -pub fn parse(source: &str, _file: &str) -> Result> { - let buf = NullTerminatedBuf::from_str_check(source); - let result = HermesParser::parse( - ParserFlags { - dialect: ParserDialect::TypeScript, - enable_jsx: true, - store_doc_block: true, - strict_mode: true, - }, - &buf, - ); - let mut cx = Context::new(&buf); - if result.has_errors() { - let error_messages = result.messages(); - return Err(error_messages - .iter() - .map(|diag| { - let message = utf8_with_surrogates_to_string(diag.message.as_slice()).unwrap(); - Diagnostic::invalid_syntax(message, None) - }) - .collect()); - } - - Ok(FromHermes::convert(&mut cx, result.root().unwrap())) -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/alias-capture-in-method-receiver-and-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/alias-capture-in-method-receiver-and-mutate.js deleted file mode 100644 index 13470813eb3b0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/alias-capture-in-method-receiver-and-mutate.js +++ /dev/null @@ -1,11 +0,0 @@ -function Component() { - // a's mutable range should be the same as x's mutable range, - // since a is captured into x (which gets mutated later) - let a = someObj(); - - let x = []; - x.push(a); - - mutate(x); - return [x, a]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/alias-capture-in-method-receiver.js b/compiler/crates/react_hermes_parser/tests/fixtures/alias-capture-in-method-receiver.js deleted file mode 100644 index 9b2dbbdd1bc51..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/alias-capture-in-method-receiver.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component() { - // a's mutable range should be limited - // the following line - let a = someObj(); - - let x = []; - x.push(a); - - return [x, a]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/alias-computed-load.js b/compiler/crates/react_hermes_parser/tests/fixtures/alias-computed-load.js deleted file mode 100644 index 1bd930dbcf19c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/alias-computed-load.js +++ /dev/null @@ -1,8 +0,0 @@ -function component(a) { - let x = { a }; - let y = {}; - - y.x = x["a"]; - mutate(y); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/alias-nested-member-path-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/alias-nested-member-path-mutate.js deleted file mode 100644 index fb356300382f9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/alias-nested-member-path-mutate.js +++ /dev/null @@ -1,9 +0,0 @@ -function component() { - let z = []; - let y = {}; - y.z = z; - let x = {}; - x.y = y; - mutate(x.y.z); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/alias-nested-member-path.js b/compiler/crates/react_hermes_parser/tests/fixtures/alias-nested-member-path.js deleted file mode 100644 index 11ab613cb7b3b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/alias-nested-member-path.js +++ /dev/null @@ -1,8 +0,0 @@ -function component() { - let z = []; - let y = {}; - y.z = z; - let x = {}; - x.y = y; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/alias-while.js b/compiler/crates/react_hermes_parser/tests/fixtures/alias-while.js deleted file mode 100644 index 34aa4c93aaab3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/alias-while.js +++ /dev/null @@ -1,18 +0,0 @@ -function foo(cond) { - let a = {}; - let b = {}; - let c = {}; - while (cond) { - let z = a; - a = b; - b = c; - c = z; - mutate(a, b); - } - a; - b; - c; - return a; -} - -function mutate(x, y) {} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/allocating-primitive-as-dep-nested-scope.js b/compiler/crates/react_hermes_parser/tests/fixtures/allocating-primitive-as-dep-nested-scope.js deleted file mode 100644 index 765c7ef79f0ee..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/allocating-primitive-as-dep-nested-scope.js +++ /dev/null @@ -1,11 +0,0 @@ -// bar(props.b) is an allocating expression that produces a primitive, which means -// that Forget should memoize it. -// Correctness: -// - y depends on either bar(props.b) or bar(props.b) + 1 -function AllocatingPrimitiveAsDepNested(props) { - let x = {}; - mutate(x); - let y = foo(bar(props.b) + 1); - mutate(x, props.a); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/allocating-primitive-as-dep.js b/compiler/crates/react_hermes_parser/tests/fixtures/allocating-primitive-as-dep.js deleted file mode 100644 index c7ef86f7c222c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/allocating-primitive-as-dep.js +++ /dev/null @@ -1,8 +0,0 @@ -// bar(props.b) is an allocating expression that produces a primitive, which means -// that Forget should memoize it. -// Correctness: -// - y depends on either bar(props.b) or bar(props.b) + 1 -function AllocatingPrimitiveAsDep(props) { - let y = foo(bar(props).b + 1); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/allow-passing-refs-as-props.js b/compiler/crates/react_hermes_parser/tests/fixtures/allow-passing-refs-as-props.js deleted file mode 100644 index a820b0d60ec32..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/allow-passing-refs-as-props.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const ref = useRef(null); - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-access-assignment.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-access-assignment.js deleted file mode 100644 index 10e52dd8f0ce1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-access-assignment.js +++ /dev/null @@ -1,8 +0,0 @@ -function foo(a, b, c) { - const x = [a]; - const y = [null, b]; - const z = [[], [], [c]]; - x[0] = y[1]; - z[0][0] = x[0]; - return [x, z]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-at-closure.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-at-closure.js deleted file mode 100644 index 244b834756e7c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-at-closure.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - const x = foo(props.x); - const fn = function () { - const arr = [...bar(props)]; - return arr.at(x); - }; - const fnResult = fn(); - return fnResult; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-at-effect.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-at-effect.js deleted file mode 100644 index 2e2e78e50e9fc..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-at-effect.js +++ /dev/null @@ -1,9 +0,0 @@ -// arrayInstance.at should have the following effects: -// - read on arg0 -// - read on receiver -// - mutate on lvalue -function ArrayAtTest(props) { - const arr = [foo(props.x)]; - const result = arr.at(bar(props.y)); - return result; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-at-mutate-after-capture.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-at-mutate-after-capture.js deleted file mode 100644 index 9553132e1a79b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-at-mutate-after-capture.js +++ /dev/null @@ -1,10 +0,0 @@ -// x's mutable range should extend to `mutate(y)` - -function Component(props) { - let x = [42, {}]; - const idx = foo(props.b); - let y = x.at(idx); - mutate(y); - - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-expression-spread.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-expression-spread.js deleted file mode 100644 index 74a101b11d39b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-expression-spread.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const x = [0, ...props.foo, null, ...props.bar, "z"]; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-join.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-join.js deleted file mode 100644 index 2637db4ec8327..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-join.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - const x = [{}, [], props.value]; - const y = x.join(() => "this closure gets stringified, not called"); - foo(y); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-map-frozen-array.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-map-frozen-array.js deleted file mode 100644 index a236657cb4ed5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-map-frozen-array.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - const x = []; - {x}; - const y = x.map((item) => item); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-map-mutable-array-mutating-lambda.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-map-mutable-array-mutating-lambda.js deleted file mode 100644 index e893b8d518da3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-map-mutable-array-mutating-lambda.js +++ /dev/null @@ -1,8 +0,0 @@ -function Component(props) { - const x = []; - const y = x.map((item) => { - item.updated = true; - return item; - }); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-pattern-params.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-pattern-params.js deleted file mode 100644 index 5444d984056a0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-pattern-params.js +++ /dev/null @@ -1,5 +0,0 @@ -function component([a, b]) { - let y = { a }; - let z = { b }; - return [y, z]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-properties.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-properties.js deleted file mode 100644 index 8d314feb33b7f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-properties.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - const a = [props.a, props.b, "hello"]; - const x = a.length; - const y = a.push; - return { a, x, y, z: a.concat }; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-property-call.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-property-call.js deleted file mode 100644 index 3356a23cd6f8c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-property-call.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const a = [props.a, props.b, "hello"]; - const x = a.push(42); - const y = a.at(props.c); - - return { a, x, y }; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/array-push-effect.js b/compiler/crates/react_hermes_parser/tests/fixtures/array-push-effect.js deleted file mode 100644 index b91eff86427c5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/array-push-effect.js +++ /dev/null @@ -1,11 +0,0 @@ -// arrayInstance.push should have the following effects: -// - read on all args (rest parameter) -// - mutate on receiver -function Component(props) { - const x = foo(props.x); - const y = { y: props.y }; - const arr = []; - arr.push({}); - arr.push(x, y); - return arr; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/arrow-function-expr-gating-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/arrow-function-expr-gating-test.js deleted file mode 100644 index 3debc725be2bd..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/arrow-function-expr-gating-test.js +++ /dev/null @@ -1,4 +0,0 @@ -// @gating -const ErrorView = (error, _retry) => ; - -export default ErrorView; diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-expression-computed.js b/compiler/crates/react_hermes_parser/tests/fixtures/assignment-expression-computed.js deleted file mode 100644 index da5881a6c8974..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-expression-computed.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const x = [props.x]; - const index = 0; - x[index] *= 2; - x["0"] += 3; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-expression-nested-path.js b/compiler/crates/react_hermes_parser/tests/fixtures/assignment-expression-nested-path.js deleted file mode 100644 index 7a6a3041857dd..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-expression-nested-path.js +++ /dev/null @@ -1,6 +0,0 @@ -function g(props) { - const a = { b: { c: props.c } }; - a.b.c = a.b.c + 1; - a.b.c *= 2; - return a; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-in-nested-if.js b/compiler/crates/react_hermes_parser/tests/fixtures/assignment-in-nested-if.js deleted file mode 100644 index b55579a36dee5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-in-nested-if.js +++ /dev/null @@ -1,11 +0,0 @@ -function useBar(props) { - let z; - - if (props.a) { - if (props.b) { - z = baz(); - } - } - - return z; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations-complex-lvalue-array.js b/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations-complex-lvalue-array.js deleted file mode 100644 index c396f86547e67..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations-complex-lvalue-array.js +++ /dev/null @@ -1,6 +0,0 @@ -function foo() { - const a = [[1]]; - const first = a.at(0); - first.set(0, 2); - return a; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations-complex-lvalue.js b/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations-complex-lvalue.js deleted file mode 100644 index 44db6c38f58e9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations-complex-lvalue.js +++ /dev/null @@ -1,6 +0,0 @@ -function g() { - const x = { y: { z: 1 } }; - x.y.z = x.y.z + 1; - x.y.z *= 2; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations.js b/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations.js deleted file mode 100644 index af39d33a9bc4e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/assignment-variations.js +++ /dev/null @@ -1,7 +0,0 @@ -function f() { - let x = 1; - x = x + 1; - x += 1; - x >>>= 1; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/await-side-effecting-promise.js b/compiler/crates/react_hermes_parser/tests/fixtures/await-side-effecting-promise.js deleted file mode 100644 index 8b5a45e608175..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/await-side-effecting-promise.js +++ /dev/null @@ -1,5 +0,0 @@ -async function Component(props) { - const x = []; - await populateData(props.id, x); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/await.js b/compiler/crates/react_hermes_parser/tests/fixtures/await.js deleted file mode 100644 index 3d021138fe47a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/await.js +++ /dev/null @@ -1,4 +0,0 @@ -async function Component(props) { - const user = await load(props.id); - return
{user.name}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/babel-existing-react-import.js b/compiler/crates/react_hermes_parser/tests/fixtures/babel-existing-react-import.js deleted file mode 100644 index 007f4bdfe1f70..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/babel-existing-react-import.js +++ /dev/null @@ -1,15 +0,0 @@ -import { useState, useMemo } from "react"; - -function Component(props) { - const [x] = useState(0); - const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]); - - return
{expensiveNumber}
; -} - -function Component2(props) { - const [x] = useState(0); - const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]); - - return
{expensiveNumber}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/babel-existing-react-kitchensink-import.js b/compiler/crates/react_hermes_parser/tests/fixtures/babel-existing-react-kitchensink-import.js deleted file mode 100644 index 39bcae9d69a3b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/babel-existing-react-kitchensink-import.js +++ /dev/null @@ -1,16 +0,0 @@ -import * as React from "react"; -import { useState, useMemo } from "react"; - -function Component(props) { - const [x] = useState(0); - const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]); - - return
{expensiveNumber}
; -} - -function Component2(props) { - const [x] = useState(0); - const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]); - - return
{expensiveNumber}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/bug.useMemo-deps-array-not-cleared.js b/compiler/crates/react_hermes_parser/tests/fixtures/bug.useMemo-deps-array-not-cleared.js deleted file mode 100644 index 711783d4f92ea..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/bug.useMemo-deps-array-not-cleared.js +++ /dev/null @@ -1,9 +0,0 @@ -function App({ text, hasDeps }) { - const resolvedText = useMemo( - () => { - return text.toUpperCase(); - }, - hasDeps ? null : [text] // should be DCE'd - ); - return resolvedText; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/bug_object-pattern.js b/compiler/crates/react_hermes_parser/tests/fixtures/bug_object-pattern.js deleted file mode 100644 index dd7ac9f415a4c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/bug_object-pattern.js +++ /dev/null @@ -1,5 +0,0 @@ -function component(t) { - let { a } = t; - let y = { a }; - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/builtin-jsx-tag-lowered-between-mutations.js b/compiler/crates/react_hermes_parser/tests/fixtures/builtin-jsx-tag-lowered-between-mutations.js deleted file mode 100644 index 8b3fd76ca6c2b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/builtin-jsx-tag-lowered-between-mutations.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const maybeMutable = new MaybeMutable(); - return
{maybeMutate(maybeMutable)}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/call-args-assignment.js b/compiler/crates/react_hermes_parser/tests/fixtures/call-args-assignment.js deleted file mode 100644 index dc686eea9e209..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/call-args-assignment.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - let x = makeObject(); - x.foo((x = makeObject())); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/call-args-destructuring-assignment.js b/compiler/crates/react_hermes_parser/tests/fixtures/call-args-destructuring-assignment.js deleted file mode 100644 index e87fb49c347c6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/call-args-destructuring-assignment.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - let x = makeObject(); - x.foo(([x] = makeObject())); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/call-spread.js b/compiler/crates/react_hermes_parser/tests/fixtures/call-spread.js deleted file mode 100644 index 5e73773bd1d24..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/call-spread.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const x = foo(...props.a, null, ...props.b); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/call-with-independently-memoizable-arg.js b/compiler/crates/react_hermes_parser/tests/fixtures/call-with-independently-memoizable-arg.js deleted file mode 100644 index 0675b442875bb..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/call-with-independently-memoizable-arg.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - const x = makeFunction(props); - const y = x( -
- {props.text} -
- ); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/call.js b/compiler/crates/react_hermes_parser/tests/fixtures/call.js deleted file mode 100644 index d0c79ac7663ac..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/call.js +++ /dev/null @@ -1,10 +0,0 @@ -function foo() {} - -function Component(props) { - const a = []; - const b = {}; - foo(a, b); - let _ =
; - foo(b); - return
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capture-indirect-mutate-alias.js b/compiler/crates/react_hermes_parser/tests/fixtures/capture-indirect-mutate-alias.js deleted file mode 100644 index 9123c960ad9db..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capture-indirect-mutate-alias.js +++ /dev/null @@ -1,11 +0,0 @@ -function component(a) { - let x = { a }; - (function () { - let q = x; - (function () { - q.b = 1; - })(); - })(); - - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capture-param-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/capture-param-mutate.js deleted file mode 100644 index 4ffdaa410ff27..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capture-param-mutate.js +++ /dev/null @@ -1,37 +0,0 @@ -function getNativeLogFunction(level) { - return function () { - let str; - if (arguments.length === 1 && typeof arguments[0] === "string") { - str = arguments[0]; - } else { - str = Array.prototype.map - .call(arguments, function (arg) { - return inspect(arg, { - depth: 10, - }); - }) - .join(", "); - } - const firstArg = arguments[0]; - let logLevel = level; - if ( - typeof firstArg === "string" && - firstArg.slice(0, 9) === "Warning: " && - logLevel >= LOG_LEVELS.error - ) { - logLevel = LOG_LEVELS.warn; - } - if (global.__inspectorLog) { - global.__inspectorLog( - INSPECTOR_LEVELS[logLevel], - str, - [].slice.call(arguments), - INSPECTOR_FRAMES_TO_SKIP - ); - } - if (groupStack.length) { - str = groupFormat("", str); - } - global.nativeLoggingHook(str, logLevel); - }; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capture_mutate-across-fns.js b/compiler/crates/react_hermes_parser/tests/fixtures/capture_mutate-across-fns.js deleted file mode 100644 index 295d7434e8161..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capture_mutate-across-fns.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a) { - let z = { a }; - (function () { - (function () { - z.b = 1; - })(); - })(); - return z; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-arrow-function-1.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-arrow-function-1.js deleted file mode 100644 index 1974b68dd62b6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-arrow-function-1.js +++ /dev/null @@ -1,7 +0,0 @@ -function component(a) { - let z = { a }; - let x = () => { - console.log(z); - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-fun-alias-captured-mutate-2.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-fun-alias-captured-mutate-2.js deleted file mode 100644 index d00593e420f04..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-fun-alias-captured-mutate-2.js +++ /dev/null @@ -1,11 +0,0 @@ -function component(foo, bar) { - let x = { foo }; - let y = { bar }; - (function () { - let a = { y }; - let b = x; - a.x = b; - })(); - mutate(y); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-fun-alias-captured-mutate-arr-2.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-fun-alias-captured-mutate-arr-2.js deleted file mode 100644 index de0c6bce45ca0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-fun-alias-captured-mutate-arr-2.js +++ /dev/null @@ -1,11 +0,0 @@ -function component(foo, bar) { - let x = { foo }; - let y = { bar }; - (function () { - let a = [y]; - let b = x; - a.x = b; - })(); - mutate(y); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-captured-mutate-arr.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-captured-mutate-arr.js deleted file mode 100644 index 91dd760b6f270..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-captured-mutate-arr.js +++ /dev/null @@ -1,11 +0,0 @@ -function component(foo, bar) { - let x = { foo }; - let y = { bar }; - (function () { - let a = [y]; - let b = x; - a.x = b; - })(); - mutate(y); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-captured-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-captured-mutate.js deleted file mode 100644 index fc1954b5545e6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-captured-mutate.js +++ /dev/null @@ -1,11 +0,0 @@ -function component(foo, bar) { - let x = { foo }; - let y = { bar }; - (function () { - let a = { y }; - let b = x; - a.x = b; - })(); - mutate(y); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-computed-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-computed-mutate.js deleted file mode 100644 index f8a365a283434..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-computed-mutate.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a) { - let x = { a }; - let y = {}; - (function () { - y["x"] = x; - })(); - mutate(y); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-mutate.js deleted file mode 100644 index 8ea83e13bc735..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-mutate.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a) { - let x = { a }; - let y = {}; - (function () { - y.x = x; - })(); - mutate(y); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-receiver-computed-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-receiver-computed-mutate.js deleted file mode 100644 index dba7a25cf1573..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-receiver-computed-mutate.js +++ /dev/null @@ -1,10 +0,0 @@ -function component(a) { - let x = { a }; - let y = {}; - (function () { - let a = y; - a["x"] = x; - })(); - mutate(y); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-receiver-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-receiver-mutate.js deleted file mode 100644 index 0599917f1b5b0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-alias-receiver-mutate.js +++ /dev/null @@ -1,10 +0,0 @@ -function component(a) { - let x = { a }; - let y = {}; - (function () { - let a = y; - a.x = x; - })(); - mutate(y); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-2.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-2.js deleted file mode 100644 index 91b600968d64b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-2.js +++ /dev/null @@ -1,10 +0,0 @@ -function component(a, b) { - let y = { b }; - let z = { a }; - let x = function () { - z.a = 2; - y.b; - }; - x(); - return z; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-3.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-3.js deleted file mode 100644 index 92d43436424eb..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-3.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a, b) { - let y = { b }; - let z = { a }; - let x = function () { - z.a = 2; - y.b; - }; - return z; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-nested.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-nested.js deleted file mode 100644 index 8d01fd0c107e2..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate-nested.js +++ /dev/null @@ -1,8 +0,0 @@ -function component(a) { - let y = { b: { a } }; - let x = function () { - y.b.a = 2; - }; - x(); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate.js deleted file mode 100644 index 84e88a0328e08..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-mutate.js +++ /dev/null @@ -1,10 +0,0 @@ -function component(a, b) { - let z = { a }; - let y = { b }; - let x = function () { - z.a = 2; - console.log(y.b); - }; - x(); - return z; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-simple-alias.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-simple-alias.js deleted file mode 100644 index 68848ba7e3aac..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-func-simple-alias.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a) { - let x = { a }; - let y = {}; - (function () { - y = x; - })(); - mutate(y); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-1.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-1.js deleted file mode 100644 index c885885069e82..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-1.js +++ /dev/null @@ -1,7 +0,0 @@ -function component(a) { - let z = { a }; - let x = function () { - console.log(z); - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-2.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-2.js deleted file mode 100644 index e2de4e1be4e0a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-2.js +++ /dev/null @@ -1,9 +0,0 @@ -function bar(a) { - let x = [a]; - let y = {}; - (function () { - y = x[0][1]; - })(); - - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-3.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-3.js deleted file mode 100644 index c9ecd39960b79..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-3.js +++ /dev/null @@ -1,11 +0,0 @@ -function bar(a, b) { - let x = [a, b]; - let y = {}; - let t = {}; - (function () { - y = x[0][1]; - t = x[1][0]; - })(); - - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-4.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-4.js deleted file mode 100644 index ef52aa19e82d2..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load-4.js +++ /dev/null @@ -1,9 +0,0 @@ -function bar(a) { - let x = [a]; - let y = {}; - (function () { - y = x[0].a[1]; - })(); - - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load.js deleted file mode 100644 index 1811e870816ac..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-alias-computed-load.js +++ /dev/null @@ -1,9 +0,0 @@ -function bar(a) { - let x = [a]; - let y = {}; - (function () { - y = x[0]; - })(); - - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-capture-ref-before-rename.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-capture-ref-before-rename.js deleted file mode 100644 index 6abd7c8612423..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-capture-ref-before-rename.js +++ /dev/null @@ -1,14 +0,0 @@ -function component(a, b) { - let z = { a }; - (function () { - mutate(z); - })(); - let y = z; - - { - // z is shadowed & renamed but the lambda is unaffected. - let z = { b }; - y = { y, z }; - } - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-conditional-capture-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-conditional-capture-mutate.js deleted file mode 100644 index 5e9234b1fca2e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-conditional-capture-mutate.js +++ /dev/null @@ -1,14 +0,0 @@ -// @debug -function component(a, b) { - let z = { a }; - let y = b; - let x = function () { - if (y) { - // we don't know for sure this mutates, so we should assume - // that there is no mutation so long as `x` isn't called - // during render - maybeMutate(z); - } - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-decl.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-decl.js deleted file mode 100644 index e7cb39a153bd5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-decl.js +++ /dev/null @@ -1,8 +0,0 @@ -function component(a) { - let t = { a }; - function x() { - t.foo(); - } - x(t); - return t; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-member-expr-arguments.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-member-expr-arguments.js deleted file mode 100644 index 5eeb6bf8f2c0c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-member-expr-arguments.js +++ /dev/null @@ -1,10 +0,0 @@ -function Foo(props) { - const onFoo = useCallback( - (reason) => { - log(props.router.location); - }, - [props.router.location] - ); - - return onFoo; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-member-expr-call.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-member-expr-call.js deleted file mode 100644 index 1b58c578bcb7f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-member-expr-call.js +++ /dev/null @@ -1,11 +0,0 @@ -function component({ mutator }) { - const poke = () => { - mutator.poke(); - }; - - const hide = () => { - mutator.user.hide(); - }; - - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-renamed-ref.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-renamed-ref.js deleted file mode 100644 index 5ad8300381bef..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-renamed-ref.js +++ /dev/null @@ -1,10 +0,0 @@ -function component(a, b) { - let z = { a }; - { - let z = { b }; - (function () { - mutate(z); - })(); - } - return z; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-runs-inference.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-runs-inference.js deleted file mode 100644 index 1482ae4594de7..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-runs-inference.js +++ /dev/null @@ -1,5 +0,0 @@ -function component(a, b) { - let z = { a }; - let p = () => {z}; - return p(); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-shadow-captured.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-shadow-captured.js deleted file mode 100644 index 1249264e8bb25..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-shadow-captured.js +++ /dev/null @@ -1,8 +0,0 @@ -function component(a) { - let z = { a }; - let x = function () { - let z; - mutate(z); - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-skip-computed-path.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-skip-computed-path.js deleted file mode 100644 index 75a5bc0473109..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-skip-computed-path.js +++ /dev/null @@ -1,4 +0,0 @@ -function StoreLandingUnseenGiftModalContainer(a) { - const giftsSeen = { a }; - return ((gift) => (gift.id ? giftsSeen[gift.id] : false))(); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-within-block.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-within-block.js deleted file mode 100644 index 4c0975595f913..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-function-within-block.js +++ /dev/null @@ -1,10 +0,0 @@ -function component(a) { - let z = { a }; - let x; - { - x = function () { - console.log(z); - }; - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-member-expr.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-member-expr.js deleted file mode 100644 index 07f5a90ce52b4..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-member-expr.js +++ /dev/null @@ -1,7 +0,0 @@ -function component(a) { - let z = { a }; - let x = function () { - console.log(z.a); - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-call.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-call.js deleted file mode 100644 index 5d0c8325568e6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-call.js +++ /dev/null @@ -1,7 +0,0 @@ -function component(a) { - let z = { a: { a } }; - let x = function () { - z.a.a(); - }; - return z; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-expr-in-nested-func.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-expr-in-nested-func.js deleted file mode 100644 index aa03be2d34404..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-expr-in-nested-func.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a) { - let z = { a: { a } }; - let x = function () { - (function () { - console.log(z.a.a); - })(); - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-expr.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-expr.js deleted file mode 100644 index f8366207457f4..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-nested-member-expr.js +++ /dev/null @@ -1,7 +0,0 @@ -function component(a) { - let z = { a: { a } }; - let x = function () { - console.log(z.a.a); - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-reference-changes-type.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-reference-changes-type.js deleted file mode 100644 index 7c56dde4be4ee..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-reference-changes-type.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a) { - let x = { a }; - let y = 1; - (function () { - y = x; - })(); - mutate(y); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-variable-in-nested-block.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-variable-in-nested-block.js deleted file mode 100644 index 0c95eaf09356d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-variable-in-nested-block.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a) { - let z = { a }; - let x = function () { - { - console.log(z); - } - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-variable-in-nested-function.js b/compiler/crates/react_hermes_parser/tests/fixtures/capturing-variable-in-nested-function.js deleted file mode 100644 index b4e3379f95cc1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/capturing-variable-in-nested-function.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a) { - let z = { a }; - let x = function () { - (function () { - console.log(z); - })(); - }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/chained-assignment-context-variable.js b/compiler/crates/react_hermes_parser/tests/fixtures/chained-assignment-context-variable.js deleted file mode 100644 index 24a48fb378347..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/chained-assignment-context-variable.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component() { - let x, - y = (x = {}); - const foo = () => { - x = getObject(); - }; - foo(); - return [y, x]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/chained-assignment-expressions.js b/compiler/crates/react_hermes_parser/tests/fixtures/chained-assignment-expressions.js deleted file mode 100644 index fb4f27844c99a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/chained-assignment-expressions.js +++ /dev/null @@ -1,8 +0,0 @@ -function foo() { - const x = { x: 0 }; - const y = { z: 0 }; - const z = { z: 0 }; - x.x += y.y *= 1; - z.z += y.y *= x.x &= 3; - return z; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/codegen-emit-imports-same-source.js b/compiler/crates/react_hermes_parser/tests/fixtures/codegen-emit-imports-same-source.js deleted file mode 100644 index 4edff1c3fcaeb..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/codegen-emit-imports-same-source.js +++ /dev/null @@ -1,5 +0,0 @@ -// @enableEmitFreeze @instrumentForget - -function useFoo(props) { - return foo(props.x); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/codegen-emit-make-read-only.js b/compiler/crates/react_hermes_parser/tests/fixtures/codegen-emit-make-read-only.js deleted file mode 100644 index 8ad3e859e6ea7..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/codegen-emit-make-read-only.js +++ /dev/null @@ -1,11 +0,0 @@ -// @enableEmitFreeze true - -function MyComponentName(props) { - let x = {}; - foo(x, props.a); - foo(x, props.b); - - let y = []; - y.push(x); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/codegen-instrument-forget-gating-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/codegen-instrument-forget-gating-test.js deleted file mode 100644 index c4d4fba3d1223..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/codegen-instrument-forget-gating-test.js +++ /dev/null @@ -1,15 +0,0 @@ -// @instrumentForget @compilationMode(annotation) @gating - -function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -function NoForget(props) { - return {props.noForget}; -} - -function Foo(props) { - "use forget"; - return {props.bar}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/codegen-instrument-forget-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/codegen-instrument-forget-test.js deleted file mode 100644 index 5fa334ad78300..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/codegen-instrument-forget-test.js +++ /dev/null @@ -1,15 +0,0 @@ -// @instrumentForget @compilationMode(annotation) - -function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -function NoForget(props) { - return {props.noForget}; -} - -function Foo(props) { - "use forget"; - return {props.bar}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/complex-while.js b/compiler/crates/react_hermes_parser/tests/fixtures/complex-while.js deleted file mode 100644 index 50a77acc49417..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/complex-while.js +++ /dev/null @@ -1,10 +0,0 @@ -function foo(a, b, c) { - label: if (a) { - while (b) { - if (c) { - break label; - } - } - } - return c; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/component.js b/compiler/crates/react_hermes_parser/tests/fixtures/component.js deleted file mode 100644 index 86336ff14f767..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/component.js +++ /dev/null @@ -1,26 +0,0 @@ -function Component(props) { - const items = props.items; - const maxItems = props.maxItems; - - const renderedItems = []; - const seen = new Set(); - const max = Math.max(0, maxItems); - for (let i = 0; i < items.length; i += 1) { - const item = items.at(i); - if (item == null || seen.has(item)) { - continue; - } - seen.add(item); - renderedItems.push(
{item}
); - if (renderedItems.length >= max) { - break; - } - } - const count = renderedItems.length; - return ( -
-

{count} Items

- {renderedItems} -
- ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/computed-call-evaluation-order.js b/compiler/crates/react_hermes_parser/tests/fixtures/computed-call-evaluation-order.js deleted file mode 100644 index 1d0a31b46cd59..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/computed-call-evaluation-order.js +++ /dev/null @@ -1,14 +0,0 @@ -// Should print A, B, arg, original -function Component() { - const changeF = (o) => { - o.f = () => console.log("new"); - }; - const x = { - f: () => console.log("original"), - }; - - (console.log("A"), x)[(console.log("B"), "f")]( - (changeF(x), console.log("arg"), 1) - ); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/computed-call-spread.js b/compiler/crates/react_hermes_parser/tests/fixtures/computed-call-spread.js deleted file mode 100644 index b933b65d4ea6a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/computed-call-spread.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const x = foo[props.method](...props.a, null, ...props.b); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/computed-load-primitive-as-dependency.js b/compiler/crates/react_hermes_parser/tests/fixtures/computed-load-primitive-as-dependency.js deleted file mode 100644 index e6d2c795c378a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/computed-load-primitive-as-dependency.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - let a = foo(); - // freeze `a` so we know the next line cannot mutate it -
{a}
; - - // b should be dependent on `props.a` - let b = bar(a[props.a] + 1); - return b; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/computed-store-alias.js b/compiler/crates/react_hermes_parser/tests/fixtures/computed-store-alias.js deleted file mode 100644 index 66dc3e4943f20..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/computed-store-alias.js +++ /dev/null @@ -1,7 +0,0 @@ -function component(a, b) { - let y = { a }; - let x = { b }; - x["y"] = y; - mutate(x); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/concise-arrow-expr.js b/compiler/crates/react_hermes_parser/tests/fixtures/concise-arrow-expr.js deleted file mode 100644 index d04270e3ac4e0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/concise-arrow-expr.js +++ /dev/null @@ -1,5 +0,0 @@ -function component() { - let [x, setX] = useState(0); - const handler = (v) => setX(v); - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/cond-deps-conditional-member-expr.js b/compiler/crates/react_hermes_parser/tests/fixtures/cond-deps-conditional-member-expr.js deleted file mode 100644 index c7bb2cd3c0561..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/cond-deps-conditional-member-expr.js +++ /dev/null @@ -1,9 +0,0 @@ -// To preserve the nullthrows behavior and reactive deps of this code, -// Forget needs to add `props.a` as a dependency (since `props.a.b` is -// a conditional dependency, i.e. gated behind control flow) - -function Component(props) { - let x = []; - x.push(props.a?.b); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/conditional-break-labeled.js b/compiler/crates/react_hermes_parser/tests/fixtures/conditional-break-labeled.js deleted file mode 100644 index 0028ebbc9a723..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/conditional-break-labeled.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * props.b *does* influence `a` - */ -function Component(props) { - const a = []; - a.push(props.a); - label: { - if (props.b) { - break label; - } - a.push(props.c); - } - a.push(props.d); - return a; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/conditional-break.js b/compiler/crates/react_hermes_parser/tests/fixtures/conditional-break.js deleted file mode 100644 index 7b5baa9ea52da..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/conditional-break.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * props.b does *not* influence `a` - */ -function ComponentA(props) { - const a_DEBUG = []; - a_DEBUG.push(props.a); - if (props.b) { - return null; - } - a_DEBUG.push(props.d); - return a_DEBUG; -} - -/** - * props.b *does* influence `a` - */ -function ComponentB(props) { - const a = []; - a.push(props.a); - if (props.b) { - a.push(props.c); - } - a.push(props.d); - return a; -} - -/** - * props.b *does* influence `a`, but only in a way that is never observable - */ -function ComponentC(props) { - const a = []; - a.push(props.a); - if (props.b) { - a.push(props.c); - return null; - } - a.push(props.d); - return a; -} - -/** - * props.b *does* influence `a` - */ -function ComponentD(props) { - const a = []; - a.push(props.a); - if (props.b) { - a.push(props.c); - return a; - } - a.push(props.d); - return a; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/conditional-on-mutable.js b/compiler/crates/react_hermes_parser/tests/fixtures/conditional-on-mutable.js deleted file mode 100644 index 0378ab655c1ef..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/conditional-on-mutable.js +++ /dev/null @@ -1,26 +0,0 @@ -function ComponentA(props) { - const a = []; - const b = []; - if (b) { - a.push(props.p0); - } - if (props.p1) { - b.push(props.p2); - } - return ; -} - -function ComponentB(props) { - const a = []; - const b = []; - if (mayMutate(b)) { - a.push(props.p0); - } - if (props.p1) { - b.push(props.p2); - } - return ; -} - -function Foo() {} -function mayMutate() {} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/conditional-set-state-in-render.js b/compiler/crates/react_hermes_parser/tests/fixtures/conditional-set-state-in-render.js deleted file mode 100644 index 772649c1f938c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/conditional-set-state-in-render.js +++ /dev/null @@ -1,14 +0,0 @@ -function Component(props) { - const [x, setX] = useState(0); - - const foo = () => { - setX(1); - }; - - if (props.cond) { - setX(2); - foo(); - } - - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/console-readonly.js b/compiler/crates/react_hermes_parser/tests/fixtures/console-readonly.js deleted file mode 100644 index e2486ba7fe6bb..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/console-readonly.js +++ /dev/null @@ -1,11 +0,0 @@ -function Component(props) { - const x = makeObject(props); - // These calls should view x as readonly and be grouped outside of the reactive scope for x: - console.log(x); - console.info(x); - console.warn(x); - console.error(x); - console.trace(x); - console.table(x); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/const-propagation-into-function-expression-global.js b/compiler/crates/react_hermes_parser/tests/fixtures/const-propagation-into-function-expression-global.js deleted file mode 100644 index ca1f4023ac534..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/const-propagation-into-function-expression-global.js +++ /dev/null @@ -1,8 +0,0 @@ -function foo() { - const isX = GLOBAL_IS_X; - const getJSX = () => { - return ; - }; - const result = getJSX(); - return result; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/const-propagation-into-function-expression-primitive.js b/compiler/crates/react_hermes_parser/tests/fixtures/const-propagation-into-function-expression-primitive.js deleted file mode 100644 index c50ddfc6fb727..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/const-propagation-into-function-expression-primitive.js +++ /dev/null @@ -1,8 +0,0 @@ -function foo() { - const x = 42; - const f = () => { - console.log(x); - }; - f(); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/constant-computed.js b/compiler/crates/react_hermes_parser/tests/fixtures/constant-computed.js deleted file mode 100644 index 2ffe50fef5ba5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/constant-computed.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const index = "foo"; - const x = {}; - x[index] = x[index] + x["bar"]; - x[index](props.foo); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-for.js b/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-for.js deleted file mode 100644 index e7822c5c43cd6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-for.js +++ /dev/null @@ -1,7 +0,0 @@ -function foo() { - let y = 0; - for (const x = 100; x < 10; x) { - y = y + 1; - } - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-into-function-expressions.js b/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-into-function-expressions.js deleted file mode 100644 index c98bd9b670056..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-into-function-expressions.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const x = 42; - const onEvent = () => { - console.log(x); - }; - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-phi.js b/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-phi.js deleted file mode 100644 index e2d7c9114cef4..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-phi.js +++ /dev/null @@ -1,13 +0,0 @@ -function foo(a, b, c) { - let x; - if (a) { - x = 2 - 1; - } else { - x = 0 + 1; - } - if (x === 1) { - return b; - } else { - return c; - } -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-while.js b/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-while.js deleted file mode 100644 index 1a4d3bf6ecb91..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation-while.js +++ /dev/null @@ -1,8 +0,0 @@ -function foo() { - let x = 100; - let y = 0; - while (x < 10) { - y += 1; - } - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation.js b/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation.js deleted file mode 100644 index ff370584bdc16..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/constant-propagation.js +++ /dev/null @@ -1,18 +0,0 @@ -function foo() { - const a = 1; - const b = 2; - const c = 3; - const d = a + b; - const e = d * c; - const f = e / d; - const g = f - e; - - if (g) { - console.log("foo"); - } - - const h = g; - const i = h; - const j = i; - return j; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/constructor.js b/compiler/crates/react_hermes_parser/tests/fixtures/constructor.js deleted file mode 100644 index ed1df01d2aa32..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/constructor.js +++ /dev/null @@ -1,10 +0,0 @@ -function Foo() {} - -function Component(props) { - const a = []; - const b = {}; - new Foo(a, b); - let _ =
; - new Foo(b); - return
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/context-variable-reassigned-outside-of-lambda.js b/compiler/crates/react_hermes_parser/tests/fixtures/context-variable-reassigned-outside-of-lambda.js deleted file mode 100644 index 2624dc562f061..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/context-variable-reassigned-outside-of-lambda.js +++ /dev/null @@ -1,9 +0,0 @@ -// @debug -function Component(props) { - let x = null; - const onChange = (e) => { - console.log(x); - }; - x = {}; - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/controlled-input.js b/compiler/crates/react_hermes_parser/tests/fixtures/controlled-input.js deleted file mode 100644 index 6a18b2d0ea575..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/controlled-input.js +++ /dev/null @@ -1,5 +0,0 @@ -function component() { - let [x, setX] = useState(0); - const handler = (event) => setX(event.target.value); - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/dce-loop.js b/compiler/crates/react_hermes_parser/tests/fixtures/dce-loop.js deleted file mode 100644 index 6e43595e4daa8..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/dce-loop.js +++ /dev/null @@ -1,9 +0,0 @@ -function foo(props) { - let x = 0; - let y = 0; - while (y < props.max) { - x++; - y++; - } - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/debugger-memoized.js b/compiler/crates/react_hermes_parser/tests/fixtures/debugger-memoized.js deleted file mode 100644 index bf8923dce0a10..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/debugger-memoized.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - const x = []; - debugger; - x.push(props.value); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/debugger.js b/compiler/crates/react_hermes_parser/tests/fixtures/debugger.js deleted file mode 100644 index a5779466e77e3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/debugger.js +++ /dev/null @@ -1,11 +0,0 @@ -function Component(props) { - debugger; - if (props.cond) { - debugger; - } else { - while (props.cond) { - debugger; - } - } - debugger; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/declare-reassign-variable-in-closure.js b/compiler/crates/react_hermes_parser/tests/fixtures/declare-reassign-variable-in-closure.js deleted file mode 100644 index 52eb7c5bdca9c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/declare-reassign-variable-in-closure.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(p) { - let x; - const foo = () => { - x = {}; - }; - foo(); - - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/declare-reassign-variable-in-function-declaration.js b/compiler/crates/react_hermes_parser/tests/fixtures/declare-reassign-variable-in-function-declaration.js deleted file mode 100644 index ca3ff478605c2..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/declare-reassign-variable-in-function-declaration.js +++ /dev/null @@ -1,8 +0,0 @@ -function Component() { - let x = null; - function foo() { - x = 9; - } - const y = bar(foo); - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/delete-computed-property.js b/compiler/crates/react_hermes_parser/tests/fixtures/delete-computed-property.js deleted file mode 100644 index 79bfdfd237cd9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/delete-computed-property.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - const x = { a: props.a, b: props.b }; - const key = "b"; - delete x[key]; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/delete-property.js b/compiler/crates/react_hermes_parser/tests/fixtures/delete-property.js deleted file mode 100644 index 84d0de961d704..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/delete-property.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const x = { a: props.a, b: props.b }; - delete x.b; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/dependencies-outputs.js b/compiler/crates/react_hermes_parser/tests/fixtures/dependencies-outputs.js deleted file mode 100644 index a5e6152c8aba1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/dependencies-outputs.js +++ /dev/null @@ -1,14 +0,0 @@ -function foo(a, b) { - const x = []; - x.push(a); -
{x}
; - - const y = []; - if (x.length) { - y.push(x); - } - if (b) { - y.push(b); - } - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/dependencies.js b/compiler/crates/react_hermes_parser/tests/fixtures/dependencies.js deleted file mode 100644 index c93c3b0d24c94..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/dependencies.js +++ /dev/null @@ -1,15 +0,0 @@ -function foo(x, y, z) { - const items = [z]; - items.push(x); - - const items2 = []; - if (x) { - items2.push(y); - } - - if (y) { - items.push(x); - } - - return items2; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructure-capture-global.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructure-capture-global.js deleted file mode 100644 index 1d0e4ce350a90..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructure-capture-global.js +++ /dev/null @@ -1,5 +0,0 @@ -let someGlobal = {}; -function component(a) { - let x = { a, someGlobal }; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructure-direct-reassignment.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructure-direct-reassignment.js deleted file mode 100644 index 8d9f9851a44f8..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructure-direct-reassignment.js +++ /dev/null @@ -1,7 +0,0 @@ -function foo(props) { - let x, y; - ({ x, y } = { x: props.a, y: props.b }); - console.log(x); // prevent DCE from eliminating `x` altogether - x = props.c; - return x + y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-array-default.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-array-default.js deleted file mode 100644 index a15539f441db1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-array-default.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const [[x] = ["default"]] = props.y; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-array-param-default.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-array-param-default.js deleted file mode 100644 index f28a0fb7b2cb8..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-array-param-default.js +++ /dev/null @@ -1,3 +0,0 @@ -function Component([a = 2]) { - return a; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-assignment-array-default.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-assignment-array-default.js deleted file mode 100644 index 331ece2dc24de..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-assignment-array-default.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - let x; - if (props.cond) { - [[x] = ["default"]] = props.y; - } else { - x = props.fallback; - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-assignment.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-assignment.js deleted file mode 100644 index ebc2289107bad..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-assignment.js +++ /dev/null @@ -1,18 +0,0 @@ -function foo(a, b, c) { - let d, g, n, o; - [ - d, - [ - { - e: { f: g }, - }, - ], - ] = a; - ({ - l: { - m: [[n]], - }, - o, - } = b); - return { d, g, n, o }; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-mixed-scope-and-local-variables-with-default.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-mixed-scope-and-local-variables-with-default.js deleted file mode 100644 index 38e5546954b82..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-mixed-scope-and-local-variables-with-default.js +++ /dev/null @@ -1,20 +0,0 @@ -function Component(props) { - const post = useFragment(graphql`...`, props.post); - const allUrls = []; - // `media` and `urls` are exported from the scope that will wrap this code, - // but `comments` is not (it doesn't need to be memoized, bc the callback - // only checks `comments.length`) - // because of the scope, the let declaration for media and urls are lifted - // out of the scope, and the destructure statement ends up turning into - // a reassignment, instead of a const declaration. this means we try to - // reassign `comments` when there's no declaration for it. - const { media = null, comments = [], urls = [] } = post; - const onClick = (e) => { - if (!comments.length) { - return; - } - console.log(comments.length); - }; - allUrls.push(...urls); - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-mixed-scope-declarations-and-locals.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-mixed-scope-declarations-and-locals.js deleted file mode 100644 index 5204e36e761c0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-mixed-scope-declarations-and-locals.js +++ /dev/null @@ -1,20 +0,0 @@ -function Component(props) { - const post = useFragment(graphql`...`, props.post); - const allUrls = []; - // `media` and `urls` are exported from the scope that will wrap this code, - // but `comments` is not (it doesn't need to be memoized, bc the callback - // only checks `comments.length`) - // because of the scope, the let declaration for media and urls are lifted - // out of the scope, and the destructure statement ends up turning into - // a reassignment, instead of a const declaration. this means we try to - // reassign `comments` when there's no declaration for it. - const { media, comments, urls } = post; - const onClick = (e) => { - if (!comments.length) { - return; - } - console.log(comments.length); - }; - allUrls.push(...urls); - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-object-default.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-object-default.js deleted file mode 100644 index f380862d34974..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-object-default.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const { x: { y } = { y: "default" } } = props.y; - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-object-param-default.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-object-param-default.js deleted file mode 100644 index 66712fe5ff5d1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-object-param-default.js +++ /dev/null @@ -1,3 +0,0 @@ -function Component({ a = 2 }) { - return a; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-property-inference.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-property-inference.js deleted file mode 100644 index 47cba2aa68473..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring-property-inference.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const x = []; - x.push(props.value); - const { length: y } = x; - foo(y); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring.js b/compiler/crates/react_hermes_parser/tests/fixtures/destructuring.js deleted file mode 100644 index 1e226e3e72a82..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/destructuring.js +++ /dev/null @@ -1,19 +0,0 @@ -function foo(a, b, c) { - const [ - d, - [ - { - e: { f }, - ...g - }, - ], - ...h - ] = a; - const { - l: { - m: [[n], ...o], - }, - p, - } = b; - return [d, f, g, h, n, o, p]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/disable-jsx-memoization.js b/compiler/crates/react_hermes_parser/tests/fixtures/disable-jsx-memoization.js deleted file mode 100644 index 42125e01a7b63..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/disable-jsx-memoization.js +++ /dev/null @@ -1,12 +0,0 @@ -// @memoizeJsxElements false -function Component(props) { - const [name, setName] = useState(null); - const onChange = function (e) { - setName(e.target.value); - }; - return ( -
- -
- ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-break.js b/compiler/crates/react_hermes_parser/tests/fixtures/do-while-break.js deleted file mode 100644 index 5a311fe9a383d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-break.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - do { - break; - } while (props.cond); - return props; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-compound-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/do-while-compound-test.js deleted file mode 100644 index 3588f94706bcf..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-compound-test.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - let x = [1, 2, 3]; - let ret = []; - do { - let item = x.pop(); - ret.push(item * 2); - } while (x.length && props.cond); - return ret; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-conditional-break.js b/compiler/crates/react_hermes_parser/tests/fixtures/do-while-conditional-break.js deleted file mode 100644 index c64286efc349e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-conditional-break.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component(props) { - let x = [0, 1, 2, 3]; - do { - if (x === 0) { - break; - } - mutate(x); - } while (props.cond); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-continue.js b/compiler/crates/react_hermes_parser/tests/fixtures/do-while-continue.js deleted file mode 100644 index a4792f7891e49..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-continue.js +++ /dev/null @@ -1,13 +0,0 @@ -function Component() { - const x = [0, 1, 2, 3]; - const ret = []; - do { - const item = x.pop(); - if (item === 0) { - continue; - } - ret.push(item / 2); - } while (x.length); - - return ret; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-early-unconditional-break.js b/compiler/crates/react_hermes_parser/tests/fixtures/do-while-early-unconditional-break.js deleted file mode 100644 index 764f2d4be9f13..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-early-unconditional-break.js +++ /dev/null @@ -1,8 +0,0 @@ -function Component(props) { - let x = [1, 2, 3]; - do { - mutate(x); - break; - } while (props.cond); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-simple.js b/compiler/crates/react_hermes_parser/tests/fixtures/do-while-simple.js deleted file mode 100644 index b1d79aaaf5066..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/do-while-simple.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component() { - let x = [1, 2, 3]; - let ret = []; - do { - let item = x.pop(); - ret.push(item * 2); - } while (x.length); - return ret; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/dominator.js b/compiler/crates/react_hermes_parser/tests/fixtures/dominator.js deleted file mode 100644 index 488f1bee85cad..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/dominator.js +++ /dev/null @@ -1,33 +0,0 @@ -function Component(props) { - let x = 0; - label: if (props.a) { - x = 1; - } else { - if (props.b) { - x = 2; - } else { - break label; - } - x = 3; - } - label2: switch (props.c) { - case "a": { - x = 4; - break; - } - case "b": { - break label2; - } - case "c": { - x = 5; - // intentional fallthrough - } - default: { - x = 6; - } - } - if (props.d) { - return null; - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/early-return.js b/compiler/crates/react_hermes_parser/tests/fixtures/early-return.js deleted file mode 100644 index deefb5d7f08f0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/early-return.js +++ /dev/null @@ -1,8 +0,0 @@ -function MyApp(props) { - let res; - if (props.cond) { - return; - } else { - res = 1; - } -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error._todo.computed-lval-in-destructure.js b/compiler/crates/react_hermes_parser/tests/fixtures/error._todo.computed-lval-in-destructure.js deleted file mode 100644 index f663f5520701f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error._todo.computed-lval-in-destructure.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - const computedKey = props.key; - const { [computedKey]: x } = props.val; - - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error._todo.multi-arrow-expr-export-default-gating-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/error._todo.multi-arrow-expr-export-default-gating-test.js deleted file mode 100644 index 6d20710d2b572..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error._todo.multi-arrow-expr-export-default-gating-test.js +++ /dev/null @@ -1,9 +0,0 @@ -// @gating -const ErrorView = (error, _retry) => ; - -export default Renderer = (props) => ( - - - - -); diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.babel-existing-react-namespace-import.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.babel-existing-react-namespace-import.js deleted file mode 100644 index 231a979838132..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.babel-existing-react-namespace-import.js +++ /dev/null @@ -1,15 +0,0 @@ -import * as React from "react"; - -function Component(props) { - const [x] = React.useState(0); - const expensiveNumber = React.useMemo(() => calculateExpensiveNumber(x), [x]); - - return
{expensiveNumber}
; -} - -function Component2(props) { - const [x] = React.useState(0); - const expensiveNumber = React.useMemo(() => calculateExpensiveNumber(x), [x]); - - return
{expensiveNumber}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.bug-validate-no-set-state-not-all-mutable-range-extensions-are-bad.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.bug-validate-no-set-state-not-all-mutable-range-extensions-are-bad.js deleted file mode 100644 index e8301cfd6e422..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.bug-validate-no-set-state-not-all-mutable-range-extensions-are-bad.js +++ /dev/null @@ -1,24 +0,0 @@ -function Component(props) { - const logEvent = useLogging(props.appId); - const [currentStep, setCurrentStep] = useState(0); - - const onSubmit = (errorEvent) => { - // 2. onSubmit inherits the mutable range of logEvent - logEvent(errorEvent); - // 3. this call then triggers the ValidateNoSetStateInRender check incorrectly, even though - // onSubmit is not called during render (although it _could_ be, if OtherComponent does so. - // but we can't tell without x-file analysis) - setCurrentStep(1); - }; - - switch (currentStep) { - case 0: - return ; - case 1: - return ; - default: - // 1. logEvent's mutable range is extended to this instruction - logEvent("Invalid step"); - return ; - } -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.call-args-destructuring-asignment-complex.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.call-args-destructuring-asignment-complex.js deleted file mode 100644 index 6f5dd4ea4af69..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.call-args-destructuring-asignment-complex.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - let x = makeObject(); - x.foo(([[x]] = makeObject())); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.codegen-error-on-conflicting-imports.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.codegen-error-on-conflicting-imports.js deleted file mode 100644 index a275e6671f958..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.codegen-error-on-conflicting-imports.js +++ /dev/null @@ -1,6 +0,0 @@ -// @enableEmitFreeze @instrumentForget - -let makeReadOnly = "conflicting identifier"; -function useFoo(props) { - return foo(props.x); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.hoisted-function-declaration.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.hoisted-function-declaration.js deleted file mode 100644 index 9e5fec3f361e5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.hoisted-function-declaration.js +++ /dev/null @@ -1,8 +0,0 @@ -function component(a) { - let t = { a }; - x(t); // hoisted call - function x(p) { - p.foo(); - } - return t; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.hooks-with-React-namespace.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.hooks-with-React-namespace.js deleted file mode 100644 index 41a3271cee2ce..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.hooks-with-React-namespace.js +++ /dev/null @@ -1,4 +0,0 @@ -function Foo() { - const [x, setX] = React.useState(1); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-access-ref-during-render.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-access-ref-during-render.js deleted file mode 100644 index 0be1f1047a518..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-access-ref-during-render.js +++ /dev/null @@ -1,6 +0,0 @@ -// @debug -function Component(props) { - const ref = useRef(null); - const value = ref.current; - return value; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-array-push-frozen.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-array-push-frozen.js deleted file mode 100644 index 3ede9c0463c69..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-array-push-frozen.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - const x = []; -
{x}
; - x.push(props.value); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-assign-hook-to-local.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-assign-hook-to-local.js deleted file mode 100644 index 886860e4de5c6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-assign-hook-to-local.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const x = useState; - const state = x(null); - return state[0]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-capture-func-passed-to-jsx.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-capture-func-passed-to-jsx.js deleted file mode 100644 index 35357391f942b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-capture-func-passed-to-jsx.js +++ /dev/null @@ -1,11 +0,0 @@ -function component(a, b) { - let y = { b }; - let z = { a }; - let x = function () { - z.a = 2; - y.b; - }; - let t = ; - mutate(x); // x should be frozen here - return t; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-computed-store-to-frozen-value.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-computed-store-to-frozen-value.js deleted file mode 100644 index a0741c5a5813f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-computed-store-to-frozen-value.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const x = makeObject(); - // freeze -
{x}
; - x[0] = true; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-delete-computed-property-of-frozen-value.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-delete-computed-property-of-frozen-value.js deleted file mode 100644 index d9b47447d3885..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-delete-computed-property-of-frozen-value.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const x = makeObject(); - // freeze -
{x}
; - delete x[y]; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-delete-property-of-frozen-value.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-delete-property-of-frozen-value.js deleted file mode 100644 index f4239d7f8ac8b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-delete-property-of-frozen-value.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const x = makeObject(); - // freeze -
{x}
; - delete x.y; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-destructure-assignment-to-global.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-destructure-assignment-to-global.js deleted file mode 100644 index 9bd077cdef0e8..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-destructure-assignment-to-global.js +++ /dev/null @@ -1,4 +0,0 @@ -function useFoo(props) { - [x] = props; - return { x }; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-destructure-to-local-global-variables.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-destructure-to-local-global-variables.js deleted file mode 100644 index 0bee2274ae3dc..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-destructure-to-local-global-variables.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(props) { - let a; - [a, b] = props.value; - - return [a, b]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-conditionally-mutable-lambda.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-conditionally-mutable-lambda.js deleted file mode 100644 index 0ffb689787dce..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-conditionally-mutable-lambda.js +++ /dev/null @@ -1,16 +0,0 @@ -function Component(props) { - const x = {}; - let fn; - if (props.cond) { - // mutable - fn = () => { - x.value = props.value; - }; - } else { - // immutable - fn = () => { - x.value; - }; - } - return fn; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-mutable-lambda-mutate-local.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-mutable-lambda-mutate-local.js deleted file mode 100644 index 846b9df81a9c5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-mutable-lambda-mutate-local.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - const x = {}; - const onChange = (e) => { - // INVALID! should use copy-on-write and pass the new value - x.value = e.target.value; - setX(x); - }; - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-mutable-lambda-reassign-local.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-mutable-lambda-reassign-local.js deleted file mode 100644 index b13ea05c67b42..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-freeze-mutable-lambda-reassign-local.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - let x = ""; - const onChange = (e) => { - x = e.target.value; - }; - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-function-expression-mutates-immutable-value.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-function-expression-mutates-immutable-value.js deleted file mode 100644 index c4d62da44c9a8..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-function-expression-mutates-immutable-value.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - const [x, setX] = useState({ value: "" }); - const onChange = (e) => { - // INVALID! should use copy-on-write and pass the new value - x.value = e.target.value; - setX(x); - }; - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-mutate-after-aliased-freeze.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-mutate-after-aliased-freeze.js deleted file mode 100644 index 8b08aaa2156f9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-mutate-after-aliased-freeze.js +++ /dev/null @@ -1,16 +0,0 @@ -function Component(props) { - let x = []; - let y = x; - - if (props.p1) { - x = []; - } - - let _ = ; - - // y is MaybeFrozen at this point, since it may alias to x - // (which is the above line freezes) - y.push(props.p2); - - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-mutate-after-freeze.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-mutate-after-freeze.js deleted file mode 100644 index a40fbcb31e3e9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-mutate-after-freeze.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component(props) { - let x = []; - - let _ = ; - - // x is Frozen at this point - x.push(props.p2); - - return
{_}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-hook-as-call-arg.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-hook-as-call-arg.js deleted file mode 100644 index b53bcb8181450..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-hook-as-call-arg.js +++ /dev/null @@ -1,3 +0,0 @@ -function Component(props) { - return foo(useFoo); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-hook-as-prop.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-hook-as-prop.js deleted file mode 100644 index 4b3ea52d74b04..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-hook-as-prop.js +++ /dev/null @@ -1,3 +0,0 @@ -function Component(props) { - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-ref-to-function.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-ref-to-function.js deleted file mode 100644 index ce93fc174c261..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-pass-ref-to-function.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const ref = useRef(null); - const x = foo(ref); - return x.current; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-property-store-to-frozen-value.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-property-store-to-frozen-value.js deleted file mode 100644 index ff54bb789a869..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-property-store-to-frozen-value.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - const x = makeObject(); - // freeze -
{x}
; - x.y = true; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ref-in-callback-invoked-during-render.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ref-in-callback-invoked-during-render.js deleted file mode 100644 index f400b30286efc..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ref-in-callback-invoked-during-render.js +++ /dev/null @@ -1,9 +0,0 @@ -// @debug -function Component(props) { - const ref = useRef(null); - const renderItem = (item) => { - const current = ref.current; - return ; - }; - return {props.items.map((item) => renderItem(item))}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ref-value-as-props.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ref-value-as-props.js deleted file mode 100644 index 3cf0b2aaf884b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ref-value-as-props.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const ref = useRef(null); - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-set-and-read-ref-during-render.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-set-and-read-ref-during-render.js deleted file mode 100644 index 97ce6931dbb0e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-set-and-read-ref-during-render.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const ref = useRef(null); - ref.current = props.value; - return ref.current; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-sketchy-code-use-forget.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-sketchy-code-use-forget.js deleted file mode 100644 index 08f080632c38a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-sketchy-code-use-forget.js +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable react-hooks/rules-of-hooks */ -function lowercasecomponent() { - "use forget"; - const x = []; - return
{x}
; -} -/* eslint-enable react-hooks/rules-of-hooks */ diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ternary-with-hook-values.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ternary-with-hook-values.js deleted file mode 100644 index 3a47b73e1c721..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-ternary-with-hook-values.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const x = props.cond ? useA : useB; - return x(); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-unconditional-set-state-in-render.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-unconditional-set-state-in-render.js deleted file mode 100644 index afef24308bccb..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-unconditional-set-state-in-render.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - const [x, setX] = useState(0); - const aliased = setX; - - setX(1); - aliased(2); - - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-use-ref-added-to-dep-without-type-info.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-use-ref-added-to-dep-without-type-info.js deleted file mode 100644 index bbf5facc4a41d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-use-ref-added-to-dep-without-type-info.js +++ /dev/null @@ -1,12 +0,0 @@ -function Foo({ a }) { - const ref = useRef(); - // type information is lost here as we don't track types of fields - const val = { ref }; - // without type info, we don't know that val.ref.current is a ref value so we - // *would* end up depending on val.ref.current - // however, this is an instance of accessing a ref during render and is disallowed - // under React's rules, so we reject this input - const x = { a, val: val.ref.current }; - - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-useMemo-async-callback.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-useMemo-async-callback.js deleted file mode 100644 index e9da86149cc5f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-useMemo-async-callback.js +++ /dev/null @@ -1,6 +0,0 @@ -function component(a, b) { - let x = useMemo(async () => { - await a; - }, []); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-useMemo-callback-args.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-useMemo-callback-args.js deleted file mode 100644 index ae3c3379e15fe..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.invalid-useMemo-callback-args.js +++ /dev/null @@ -1,4 +0,0 @@ -function component(a, b) { - let x = useMemo((c) => a, []); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.mutate-captured-arg-separately.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.mutate-captured-arg-separately.js deleted file mode 100644 index 3545a21849492..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.mutate-captured-arg-separately.js +++ /dev/null @@ -1,10 +0,0 @@ -// Let's not support identifiers defined after use for now. -function component(a) { - let y = function () { - m(x); - }; - - let x = { a }; - m(x); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.mutate-global-increment-op-invalid-react.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.mutate-global-increment-op-invalid-react.js deleted file mode 100644 index 6d754345cf6e6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.mutate-global-increment-op-invalid-react.js +++ /dev/null @@ -1,6 +0,0 @@ -let renderCount = 0; - -function NoHooks() { - renderCount++; - return
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.reassignment-to-global.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.reassignment-to-global.js deleted file mode 100644 index d0509a3d52a16..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.reassignment-to-global.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component() { - // Cannot assign to globals - someUnknownGlobal = true; - moduleLocal = true; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.todo-kitchensink.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.todo-kitchensink.js deleted file mode 100644 index 111f9b25b1d8a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.todo-kitchensink.js +++ /dev/null @@ -1,70 +0,0 @@ -function foo([a, b], { c, d, e = "e" }, f = "f", ...args) { - let i = 0; - var x = []; - - class Bar { - #secretSauce = 42; - constructor() { - console.log(this.#secretSauce); - } - } - - const g = { b() {}, c: () => {} }; - const { z, aa = "aa" } = useCustom(); - - ; - ; - - const j = function bar([quz, qux], ...args) {}; - - for (; i < 3; i += 1) { - x.push(i); - } - for (; i < 3; ) { - break; - } - for (;;) { - break; - } - - graphql` - ${g} - `; - - graphql`\\t\n`; - - for (c of [1, 2]) { - } - for ([v] of [[1], [2]]) { - } - for ({ v } of [{ v: 1 }, { v: 2 }]) { - } - - for (let x in { a: 1 }) { - } - - let updateIdentifier = 0; - --updateIdentifier; - ++updateIdentifier; - updateIdentifier.y++; - updateIdentifier.y--; - - switch (i) { - case 1 + 1: { - } - case foo(): { - } - case x.y: { - } - default: { - } - } - - function component(a) { - // Add support for function declarations once we support `var` hoisting. - function t() {} - t(); - } -} - -let moduleLocal = false; diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.todo-unconditional-set-state-lambda.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.todo-unconditional-set-state-lambda.js deleted file mode 100644 index 8a89c2cbb11a5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.todo-unconditional-set-state-lambda.js +++ /dev/null @@ -1,12 +0,0 @@ -function Component(props) { - let y = 0; - const [x, setX] = useState(0); - - const foo = () => { - setX(1); - y = 1; // TODO: force foo's mutable range to extend, but ideally we can just remove this line - }; - foo(); - - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.todo.destructure-assignment-to-context-var.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.todo.destructure-assignment-to-context-var.js deleted file mode 100644 index 6e2a09649dc48..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.todo.destructure-assignment-to-context-var.js +++ /dev/null @@ -1,9 +0,0 @@ -function useFoo(props) { - let x; - [x] = props; - const foo = () => { - x = getX(props); - }; - foo(); - return { x }; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.useMemo-callback-generator.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.useMemo-callback-generator.js deleted file mode 100644 index 2a4739a0dbe1e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.useMemo-callback-generator.js +++ /dev/null @@ -1,9 +0,0 @@ -function component(a, b) { - // we don't handle generators at all so this test isn't - // useful for now, but adding this test in case we do - // add support for generators in the future. - let x = useMemo(function* () { - yield a; - }, []); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/error.while-with-assignment-in-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/error.while-with-assignment-in-test.js deleted file mode 100644 index 0ad8369a39903..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/error.while-with-assignment-in-test.js +++ /dev/null @@ -1,10 +0,0 @@ -function f(reader) { - const queue = [1, 2, 3]; - let value = 0; - let sum = 0; - // BUG: we need to codegen the complex test expression - while ((value = queue.pop()) != null) { - sum += value; - } - return sum; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-destructured-rest-element.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-destructured-rest-element.js deleted file mode 100644 index cdfce1b2581e3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-destructured-rest-element.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - // b is an object, must be memoized even though the input is not memoized - const { a, ...b } = props.a; - // d is an array, mut be memoized even though the input is not memoized - const [c, ...d] = props.c; - return
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-jsx-child.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-jsx-child.js deleted file mode 100644 index 7df580429c661..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-jsx-child.js +++ /dev/null @@ -1,11 +0,0 @@ -function foo(a, b, c) { - const x = []; - if (a) { - const y = []; - if (b) { - y.push(c); - } - x.push(
{y}
); - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-logical.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-logical.js deleted file mode 100644 index 4582a56fa98a3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-logical.js +++ /dev/null @@ -1,8 +0,0 @@ -function Component(props) { - const a = [props.a]; - const b = [props.b]; - const c = [props.c]; - // We don't do constant folding for non-primitive values (yet) so we consider - // that any of a, b, or c could return here - return (a && b) || c; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-dependency.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-dependency.js deleted file mode 100644 index a7646fcc95c3d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-dependency.js +++ /dev/null @@ -1,15 +0,0 @@ -function Component(props) { - // a can be independently memoized, is not mutated later - const a = [props.a]; - - // b and c are interleaved and grouped into a single scope, - // but they are independent values. c does not escape, but - // we need to ensure that a is memoized or else b will invalidate - // on every render since a is a dependency. - const b = []; - const c = {}; - c.a = a; - b.push(props.b); - - return b; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js deleted file mode 100644 index 21e3cd07f6bf1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js +++ /dev/null @@ -1,24 +0,0 @@ -function Component(props) { - // a can be independently memoized, is not mutated later - // but a is a dependnecy of b, which is a dependency of c. - // we have to memoize a to avoid breaking memoization of b, - // to avoid breaking memoization of c. - const a = [props.a]; - - // a can be independently memoized, is not mutated later, - // but is a dependency of d which is part of c's scope. - // we have to memoize b to avoid breaking memoization of c. - const b = [a]; - - // c and d are interleaved and grouped into a single scope, - // but they are independent values. d does not escape, but - // we need to ensure that b is memoized or else b will invalidate - // on every render since a is a dependency. we also need to - // ensure that a is memoized, since it's a dependency of b. - const c = []; - const d = {}; - d.b = b; - c.push(props.b); - - return c; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-primitive-dependency.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-primitive-dependency.js deleted file mode 100644 index b8d3bd280cd40..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-primitive-dependency.js +++ /dev/null @@ -1,17 +0,0 @@ -function Component(props) { - // a does not need to be memoized ever, even though it's a - // dependency of c, which exists in a scope that has a memoized - // output. it doesn't need to be memoized bc the value is a primitive type. - const a = props.a + props.b; - - // b and c are interleaved and grouped into a single scope, - // but they are independent values. c does not escape, but - // we need to ensure that a is memoized or else b will invalidate - // on every render since a is a dependency. - const b = []; - const c = {}; - c.a = a; - b.push(props.c); - - return b; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-conditional-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-conditional-test.js deleted file mode 100644 index d59b67810fc9b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-conditional-test.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const x = [props.a]; - const y = x ? props.b : props.c; - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-if-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-if-test.js deleted file mode 100644 index e999f4e143da5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-if-test.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component(props) { - const x = [props.a]; - let y; - if (x) { - y = props.b; - } else { - y = props.c; - } - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-case.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-case.js deleted file mode 100644 index bf577624e459b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-case.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component(props) { - const a = [props.a]; - let x = props.b; - switch (props.c) { - case a: { - x = props.d; - } - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-test.js deleted file mode 100644 index 58ceaff461642..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-test.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component(props) { - const a = [props.a]; - let x = props.b; - switch (a) { - case true: { - x = props.c; - } - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/expression-with-assignment-dynamic.js b/compiler/crates/react_hermes_parser/tests/fixtures/expression-with-assignment-dynamic.js deleted file mode 100644 index e3a58967b4147..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/expression-with-assignment-dynamic.js +++ /dev/null @@ -1,4 +0,0 @@ -function f(y) { - let x = y; - return x + (x = 2) + x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/expression-with-assignment.js b/compiler/crates/react_hermes_parser/tests/fixtures/expression-with-assignment.js deleted file mode 100644 index 5d4ec4c51b3b5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/expression-with-assignment.js +++ /dev/null @@ -1,4 +0,0 @@ -function f() { - let x = 1; - return x + (x = 2) + x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/extend-scopes-if.js b/compiler/crates/react_hermes_parser/tests/fixtures/extend-scopes-if.js deleted file mode 100644 index fd3b25358591c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/extend-scopes-if.js +++ /dev/null @@ -1,14 +0,0 @@ -function foo(a, b, c) { - let x = []; - if (a) { - if (b) { - if (c) { - x.push(0); - } - } - } - if (x.length) { - return x; - } - return null; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-call-complex-param-value.js b/compiler/crates/react_hermes_parser/tests/fixtures/fbt-call-complex-param-value.js deleted file mode 100644 index 0683c1aa5353e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-call-complex-param-value.js +++ /dev/null @@ -1,9 +0,0 @@ -import fbt from "fbt"; - -function Component(props) { - const text = fbt( - `Hello, ${fbt.param("(key) name", capitalize(props.name))}!`, - "(description) Greeting" - ); - return
{text}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-call.js b/compiler/crates/react_hermes_parser/tests/fixtures/fbt-call.js deleted file mode 100644 index f0719d10f7992..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-call.js +++ /dev/null @@ -1,9 +0,0 @@ -import fbt from "fbt"; - -function Component(props) { - const text = fbt( - `${fbt.param("(key) count", props.count)} items`, - "(description) Number of items" - ); - return
{text}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-params-complex-param-value.js b/compiler/crates/react_hermes_parser/tests/fixtures/fbt-params-complex-param-value.js deleted file mode 100644 index 31ef0115d113a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-params-complex-param-value.js +++ /dev/null @@ -1,9 +0,0 @@ -import fbt from "fbt"; - -function Component(props) { - return ( - - Hello {capitalize(props.name)} - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-params.js b/compiler/crates/react_hermes_parser/tests/fixtures/fbt-params.js deleted file mode 100644 index c2a32077705bb..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-params.js +++ /dev/null @@ -1,9 +0,0 @@ -import fbt from "fbt"; - -function Component(props) { - return ( - - Hello {props.name} - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-template-string-same-scope.js b/compiler/crates/react_hermes_parser/tests/fixtures/fbt-template-string-same-scope.js deleted file mode 100644 index 09c531c33b2a0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/fbt-template-string-same-scope.js +++ /dev/null @@ -1,17 +0,0 @@ -import fbt from "fbt"; - -export function Component(props) { - let count = 0; - if (props.items) { - count = props.items.length; - } - return ( - - {fbt( - `for ${fbt.param("count", count)} experiences`, - `Label for the number of items`, - { project: "public" } - )} - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-empty-update-with-continue.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-empty-update-with-continue.js deleted file mode 100644 index 8ad3eeeb1655b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-empty-update-with-continue.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - let x = 0; - for (let i = 0; i < props.count; ) { - x += i; - i += 1; - continue; - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-empty-update.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-empty-update.js deleted file mode 100644 index d1411e8498f30..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-empty-update.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component(props) { - let x = 0; - for (let i = 0; i < props.count; ) { - x += i; - if (x > 10) { - break; - } - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-logical.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-logical.js deleted file mode 100644 index b0e5a09face4f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-logical.js +++ /dev/null @@ -1,12 +0,0 @@ -function foo(props) { - let y = 0; - for ( - let x = 0; - x > props.min && x < props.max; - x += props.cond ? props.increment : 2 - ) { - x *= 2; - y += x; - } - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-break.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-of-break.js deleted file mode 100644 index 1248bc8306e98..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-break.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component() { - const x = []; - for (const item of [1, 2]) { - break; - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-conditional-break.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-of-conditional-break.js deleted file mode 100644 index 23ebd337a8124..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-conditional-break.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component() { - const x = []; - for (const item of [1, 2]) { - if (item === 1) { - break; - } - x.push(item); - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-continue.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-of-continue.js deleted file mode 100644 index 4f5e878ba3125..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-continue.js +++ /dev/null @@ -1,11 +0,0 @@ -function Component() { - const x = [0, 1, 2, 3]; - const ret = []; - for (const item of x) { - if (item === 0) { - continue; - } - ret.push(item / 2); - } - return ret; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-destructure.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-of-destructure.js deleted file mode 100644 index 480bb662dd60a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-destructure.js +++ /dev/null @@ -1,8 +0,0 @@ -function Component() { - let x = []; - let items = [{ v: 0 }, { v: 1 }, { v: 2 }]; - for (const { v } of items) { - x.push(v * 2); - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-mutate.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-of-mutate.js deleted file mode 100644 index ea7d16c938d80..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-mutate.js +++ /dev/null @@ -1,8 +0,0 @@ -function Component(props) { - const collection = [makeObject()]; - const results = []; - for (const item of collection) { - results.push(
{mutate(item)}
); - } - return
{results}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-mutate.tsx b/compiler/crates/react_hermes_parser/tests/fixtures/for-of-mutate.tsx deleted file mode 100644 index ea7d16c938d80..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-mutate.tsx +++ /dev/null @@ -1,8 +0,0 @@ -function Component(props) { - const collection = [makeObject()]; - const results = []; - for (const item of collection) { - results.push(
{mutate(item)}
); - } - return
{results}
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-simple.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-of-simple.js deleted file mode 100644 index b708b1b3b92f0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-of-simple.js +++ /dev/null @@ -1,8 +0,0 @@ -function Component() { - let x = []; - let items = [0, 1, 2]; - for (const ii of items) { - x.push(ii * 2); - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/for-return.js b/compiler/crates/react_hermes_parser/tests/fixtures/for-return.js deleted file mode 100644 index 0e3651b75e283..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/for-return.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - for (let i = 0; i < props.count; i++) { - return; - } -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/frozen-after-alias.js b/compiler/crates/react_hermes_parser/tests/fixtures/frozen-after-alias.js deleted file mode 100644 index 852504b81d922..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/frozen-after-alias.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component() { - const a = []; - const b = a; - useFreeze(a); - foo(b); // should be readonly, value is guaranteed frozen via alias - return b; -} - -function useFreeze() {} -function foo(x) {} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-reassign.js b/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-reassign.js deleted file mode 100644 index 92ee854664328..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-reassign.js +++ /dev/null @@ -1,7 +0,0 @@ -function component() { - function x(a) { - a.foo(); - } - x = {}; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-redeclare.js b/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-redeclare.js deleted file mode 100644 index 03ba36473d4e1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-redeclare.js +++ /dev/null @@ -1,7 +0,0 @@ -function component() { - function x(a) { - a.foo(); - } - function x() {} - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-simple.js b/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-simple.js deleted file mode 100644 index f37d5e13ee509..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/function-declaration-simple.js +++ /dev/null @@ -1,8 +0,0 @@ -function component(a) { - let t = { a }; - function x(p) { - p.foo(); - } - x(t); - return t; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-captures-value-later-frozen-jsx.js b/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-captures-value-later-frozen-jsx.js deleted file mode 100644 index 7e694fa1bd020..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-captures-value-later-frozen-jsx.js +++ /dev/null @@ -1,12 +0,0 @@ -function Component(props) { - let x = {}; - // onChange should be inferred as immutable, because the value - // it captures (`x`) is frozen by the time the function is referenced - const onChange = (e) => { - maybeMutate(x, e.target.value); - }; - if (props.cond) { -
{x}
; - } - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-maybe-mutates-hook-return-value.js b/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-maybe-mutates-hook-return-value.js deleted file mode 100644 index fcf38652b1cf0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-maybe-mutates-hook-return-value.js +++ /dev/null @@ -1,12 +0,0 @@ -function Component(props) { - const id = useSelectedEntitytId(); - // this example should infer `id` as mutable, and then infer `onLoad` as mutable, - // and be rejected because onLoad cannot be passed as a frozen value in the JSX. - // however, we likely have to allow this example to work, because hook return - // values are generally immutable in practice and are also widely referenced in - // callbacks. - const onLoad = () => { - log(id); - }; - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-with-store-to-parameter.js b/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-with-store-to-parameter.js deleted file mode 100644 index d8412a7c83ddd..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/function-expression-with-store-to-parameter.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - const mutate = (object, key, value) => { - object.updated = true; - object[key] = value; - }; - const x = makeObject(props); - mutate(x); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/function-param-assignment-pattern.js b/compiler/crates/react_hermes_parser/tests/fixtures/function-param-assignment-pattern.js deleted file mode 100644 index 2f2967583dcc2..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/function-param-assignment-pattern.js +++ /dev/null @@ -1,3 +0,0 @@ -function Component(x = "default", y = [{}]) { - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-default-function.js b/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-default-function.js deleted file mode 100644 index 2a8b7ea44bb45..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-default-function.js +++ /dev/null @@ -1,14 +0,0 @@ -// @gating @compilationMode(annotation) -export default function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -function NoForget(props) { - return {props.noForget}; -} - -function Foo(props) { - "use forget"; - return {props.bar}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-function-and-default.js b/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-function-and-default.js deleted file mode 100644 index afb28093075d9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-function-and-default.js +++ /dev/null @@ -1,14 +0,0 @@ -// @gating @compilationMode(annotation) -export default function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -function NoForget(props) { - return {props.noForget}; -} - -export function Foo(props) { - "use forget"; - return {props.bar}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-function.js b/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-function.js deleted file mode 100644 index eed7a0e67915c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/gating-test-export-function.js +++ /dev/null @@ -1,14 +0,0 @@ -// @gating @compilationMode(annotation) -export function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -export function NoForget(props) { - return {props.noForget}; -} - -export function Foo(props) { - "use forget"; - return {props.bar}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/gating-test.js b/compiler/crates/react_hermes_parser/tests/fixtures/gating-test.js deleted file mode 100644 index b4c928754e766..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/gating-test.js +++ /dev/null @@ -1,14 +0,0 @@ -// @gating @compilationMode(annotation) -function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -function NoForget(props) { - return {props.noForget}; -} - -function Foo(props) { - "use forget"; - return {props.bar}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/global-jsx-tag-lowered-between-mutations.js b/compiler/crates/react_hermes_parser/tests/fixtures/global-jsx-tag-lowered-between-mutations.js deleted file mode 100644 index 8a0744fd50512..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/global-jsx-tag-lowered-between-mutations.js +++ /dev/null @@ -1,15 +0,0 @@ -function Component(props) { - const maybeMutable = new MaybeMutable(); - // NOTE: this will produce invalid output. - // The HIR is roughly: - // ⌵ mutable range of `maybeMutable` - // StoreLocal maybeMutable = ... ⌝ - // t0 = LoadGlobal View ⎮ <-- View is lowered inside this mutable range - // and thus gets becomes an output of this scope, - // gets promoted to temporary - // t1 = LoadGlobal maybeMutate ⎮ - // t2 = LoadLocal maybeMutable ⎮ - // t3 = Call t1(t2) ⌟ - // t4 = Jsx tag=t0 props=[] children=[t3] <-- `t0` is an invalid tag - return {maybeMutate(maybeMutable)}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/globals-Boolean.js b/compiler/crates/react_hermes_parser/tests/fixtures/globals-Boolean.js deleted file mode 100644 index b19c8ff7a0504..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/globals-Boolean.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const x = {}; - const y = Boolean(x); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/globals-Number.js b/compiler/crates/react_hermes_parser/tests/fixtures/globals-Number.js deleted file mode 100644 index 8831bb4a33539..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/globals-Number.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const x = {}; - const y = Number(x); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/globals-String.js b/compiler/crates/react_hermes_parser/tests/fixtures/globals-String.js deleted file mode 100644 index d5e769807e997..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/globals-String.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const x = {}; - const y = String(x); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-expr.js b/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-expr.js deleted file mode 100644 index 533b5553a1595..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-expr.js +++ /dev/null @@ -1,4 +0,0 @@ -function t(props) { - let x = [, foo, props]; - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce-2.js b/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce-2.js deleted file mode 100644 index 3009a00812070..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce-2.js +++ /dev/null @@ -1,4 +0,0 @@ -function t(props) { - let [foo, bar, ,] = props; - return foo; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce.js b/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce.js deleted file mode 100644 index 2c070d4955377..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce.js +++ /dev/null @@ -1,4 +0,0 @@ -function t(props) { - let [, foo, bar] = props; - return foo; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/holey-array.js b/compiler/crates/react_hermes_parser/tests/fixtures/holey-array.js deleted file mode 100644 index 302672aa1cb61..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/holey-array.js +++ /dev/null @@ -1,5 +0,0 @@ -function t(props) { - let [, setstate] = useState(); - setstate(1); - return props.foo; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/hook-call.js b/compiler/crates/react_hermes_parser/tests/fixtures/hook-call.js deleted file mode 100644 index f77767cfc8cbe..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/hook-call.js +++ /dev/null @@ -1,14 +0,0 @@ -function useFreeze() {} -function foo() {} - -function Component(props) { - const x = []; - const y = useFreeze(x); - foo(y, x); - return ( - - {x} - {y} - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/hook-inside-logical-expression.js b/compiler/crates/react_hermes_parser/tests/fixtures/hook-inside-logical-expression.js deleted file mode 100644 index 483edd58bb12b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/hook-inside-logical-expression.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const user = useFragment(graphql`...`, props.user) ?? {}; - return user.name; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/hooks-freeze-arguments.js b/compiler/crates/react_hermes_parser/tests/fixtures/hooks-freeze-arguments.js deleted file mode 100644 index cdb1fce7e1dda..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/hooks-freeze-arguments.js +++ /dev/null @@ -1,10 +0,0 @@ -function Component() { - const a = []; - useFreeze(a); // should freeze - useFreeze(a); // should be readonly - call(a); // should be readonly - return a; -} - -function useFreeze(x) {} -function call(x) {} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/hooks-freeze-possibly-mutable-arguments.js b/compiler/crates/react_hermes_parser/tests/fixtures/hooks-freeze-possibly-mutable-arguments.js deleted file mode 100644 index bcf51ccc4ea29..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/hooks-freeze-possibly-mutable-arguments.js +++ /dev/null @@ -1,17 +0,0 @@ -function Component(props) { - const cond = props.cond; - const x = props.x; - let a; - if (cond) { - a = x; - } else { - a = []; - } - useFreeze(a); // should freeze, value *may* be mutable - useFreeze(a); // should be readonly - call(a); // should be readonly - return a; -} - -function useFreeze(x) {} -function call(x) {} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/immutable-hooks.js b/compiler/crates/react_hermes_parser/tests/fixtures/immutable-hooks.js deleted file mode 100644 index b4103fa5da63f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/immutable-hooks.js +++ /dev/null @@ -1,9 +0,0 @@ -// @enableAssumeHooksFollowRulesOfReact true -function Component(props) { - const x = {}; - // In enableAssumeHooksFollowRulesOfReact mode hooks freeze their inputs and return frozen values - const y = useFoo(x); - // Thus both x and y are frozen here, and x can be independently memoized - bar(x, y); - return [x, y]; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-class.js b/compiler/crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-class.js deleted file mode 100644 index 11740ef0a4288..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-class.js +++ /dev/null @@ -1,15 +0,0 @@ -function Component(props) { - const env = useRelayEnvironment(); - // Note: this is a class has no mutable methods, ie it always treats `this` as readonly - const mutator = new Mutator(env); - - useOtherHook(); - - // `x` should be independently memoizeable, since foo(x, mutator) cannot mutate - // the mutator. - const x = {}; - foo(x, mutator); - return x; -} - -class Mutator {} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-lambda.js b/compiler/crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-lambda.js deleted file mode 100644 index bd10465c7422e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-lambda.js +++ /dev/null @@ -1,13 +0,0 @@ -function Component(props) { - const [value, setValue] = useState(null); - // NOTE: this lambda does not capture any mutable values (only the state setter) - // and thus should be treated as readonly - const onChange = (e) => setValue((value) => value + e.target.value); - - useOtherHook(); - - // x should be independently memoizeable, since foo(x, onChange) cannot modify onChange - const x = {}; - foo(x, onChange); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/independent-across-if.js b/compiler/crates/react_hermes_parser/tests/fixtures/independent-across-if.js deleted file mode 100644 index d36900fff7597..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/independent-across-if.js +++ /dev/null @@ -1,28 +0,0 @@ -function compute() {} -function mutate() {} -function foo() {} -function Foo() {} - -/** - * Should produce 3 scopes: - * - * a: inputs=props.a & props.c; outputs=a - * a = compute(props.a); - * if (props.c) - * mutate(a) - * b: inputs=props.b & props.c; outputs=b - * b = compute(props.b); - * if (props.c) - * mutate(b) - * return: inputs=a, b outputs=return - * return = - */ -function Component(props) { - const a = compute(props.a); - const b = compute(props.b); - if (props.c) { - mutate(a); - mutate(b); - } - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/independent.js b/compiler/crates/react_hermes_parser/tests/fixtures/independent.js deleted file mode 100644 index d7daa41b73c4e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/independent.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Should produce 3 scopes: - * - * a: inputs=props.a, outputs=a - * a = compute(props.a); - * b: inputs=props.b, outputs=b - * b = compute(props.b); - * return: inputs=a, b outputs=return - * return = - */ -function Component(props) { - const a = compute(props.a); - const b = compute(props.b); - return ; -} - -function compute() {} -function foo() {} -function Foo() {} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/independently-memoize-object-property.js b/compiler/crates/react_hermes_parser/tests/fixtures/independently-memoize-object-property.js deleted file mode 100644 index e76dce6c91893..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/independently-memoize-object-property.js +++ /dev/null @@ -1,7 +0,0 @@ -function foo(a, b, c) { - const x = { a: a }; - // NOTE: this array should memoize independently from x, w only b,c as deps - x.y = [b, c]; - - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/infer-computed-delete.js b/compiler/crates/react_hermes_parser/tests/fixtures/infer-computed-delete.js deleted file mode 100644 index 187e797f40f8f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/infer-computed-delete.js +++ /dev/null @@ -1,6 +0,0 @@ -// @debug -function Component(props) { - const x = makeObject(); - const y = delete x[props.value]; - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/infer-global-object.js b/compiler/crates/react_hermes_parser/tests/fixtures/infer-global-object.js deleted file mode 100644 index bcee757cc1b6d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/infer-global-object.js +++ /dev/null @@ -1,13 +0,0 @@ -// Check that we correctly resolve type and effect lookups on the javascript -// global object. -function Component(props) { - let neverAliasedOrMutated = foo(props.b); - let primitiveVal1 = Math.max(props.a, neverAliasedOrMutated); - let primitiveVal2 = Infinity; - let primitiveVal3 = globaThis.globalThis.NaN; - - // Even though we don't know the function signature of foo, - // we should be able to infer that it does not mutate its inputs. - foo(primitiveVal1, primitiveVal2, primitiveVal3); - return { primitiveVal1, primitiveVal2, primitiveVal3 }; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/infer-phi-primitive.js b/compiler/crates/react_hermes_parser/tests/fixtures/infer-phi-primitive.js deleted file mode 100644 index faafa9ddd312c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/infer-phi-primitive.js +++ /dev/null @@ -1,11 +0,0 @@ -function foo(a, b) { - let x; - if (a) { - x = 1; - } else { - x = 2; - } - - let y = x; - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/infer-property-delete.js b/compiler/crates/react_hermes_parser/tests/fixtures/infer-property-delete.js deleted file mode 100644 index b8540044449b9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/infer-property-delete.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - const x = makeObject(); - const y = delete x.value; - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/infer-types-through-type-cast.flow.js b/compiler/crates/react_hermes_parser/tests/fixtures/infer-types-through-type-cast.flow.js deleted file mode 100644 index eaac49f9a24ed..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/infer-types-through-type-cast.flow.js +++ /dev/null @@ -1,9 +0,0 @@ -// @flow -function Component(props) { - // We can infer that `x` is a primitive bc it is aliased to `y`, - // which is used in a binary expression - const x = foo(); - const y = (x: any); - y + 1; - return x; -} \ No newline at end of file diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-dynamic.js b/compiler/crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-dynamic.js deleted file mode 100644 index dc36d75464e7f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-dynamic.js +++ /dev/null @@ -1,14 +0,0 @@ -function Component(props) { - const item = useFragment(FRAGMENT, props.item); - useFreeze(item); - - const count = new MaybeMutable(item); - return ( - - - {Text} - {{maybeMutate(count)}} - - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-static.js b/compiler/crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-static.js deleted file mode 100644 index 5c92f8bcf5afe..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-static.js +++ /dev/null @@ -1,11 +0,0 @@ -function Component(props) { - const count = new MaybeMutable(); - return ( - - - {Text} - {{maybeMutate(count)}} - - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/interdependent-across-if.js b/compiler/crates/react_hermes_parser/tests/fixtures/interdependent-across-if.js deleted file mode 100644 index 8f05da6973cce..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/interdependent-across-if.js +++ /dev/null @@ -1,22 +0,0 @@ -function compute() {} -function foo() {} -function Foo() {} - -/** - * Should produce 1 scope: - * - * return: inputs=props.a & props.b & props.c; outputs=return - * const a = compute(props.a); - * const b = compute(props.b); - * if (props.c) - * foo(a, b); - * return = - */ -function Component(props) { - const a = compute(props.a); - const b = compute(props.b); - if (props.c) { - foo(a, b); - } - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/interdependent.js b/compiler/crates/react_hermes_parser/tests/fixtures/interdependent.js deleted file mode 100644 index aef5a385a35ab..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/interdependent.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Should produce 1 scope: - * - * return: inputs=props.a & props.b; outputs=return - * const a = compute(props.a); - * const b = compute(props.b); - * foo(a, b); - * return = - */ -function Component(props) { - const a = compute(props.a); - const b = compute(props.b); - foo(a, b); - return ; -} - -function compute() {} -function foo() {} -function Foo() {} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/inverted-if-else.js b/compiler/crates/react_hermes_parser/tests/fixtures/inverted-if-else.js deleted file mode 100644 index 574de55c64991..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/inverted-if-else.js +++ /dev/null @@ -1,11 +0,0 @@ -function foo(a, b, c) { - let x = null; - label: { - if (a) { - x = b; - break label; - } - x = c; - } - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/inverted-if.js b/compiler/crates/react_hermes_parser/tests/fixtures/inverted-if.js deleted file mode 100644 index 97cd1fbff251a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/inverted-if.js +++ /dev/null @@ -1,11 +0,0 @@ -function foo(a, b, c, d) { - let y = []; - label: if (a) { - if (b) { - y.push(c); - break label; - } - y.push(d); - } - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/issue852.js b/compiler/crates/react_hermes_parser/tests/fixtures/issue852.js deleted file mode 100644 index 907ff058d5992..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/issue852.js +++ /dev/null @@ -1,6 +0,0 @@ -function Component(c) { - let x = { c }; - mutate(x); - let a = x; - let b = a; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/issue933-disjoint-set-infinite-loop.js b/compiler/crates/react_hermes_parser/tests/fixtures/issue933-disjoint-set-infinite-loop.js deleted file mode 100644 index 43d343bb1c4d4..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/issue933-disjoint-set-infinite-loop.js +++ /dev/null @@ -1,8 +0,0 @@ -// This caused an infinite loop in the compiler -function MyApp(props) { - const y = makeObj(); - const tmp = y.a; - const tmp2 = tmp.b; - y.push(tmp2); - return y; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-empty-expression.js b/compiler/crates/react_hermes_parser/tests/fixtures/jsx-empty-expression.js deleted file mode 100644 index 357f27186e0d3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-empty-expression.js +++ /dev/null @@ -1,8 +0,0 @@ -export function Component(props) { - return ( -
- {} - {props.a} -
- ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-fragment.js b/compiler/crates/react_hermes_parser/tests/fixtures/jsx-fragment.js deleted file mode 100644 index a8142a9539a89..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-fragment.js +++ /dev/null @@ -1,10 +0,0 @@ -function Foo(props) { - return ( - <> - Hello {props.greeting}{" "} -
- <>Text -
- - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-member-expression-tag-grouping.js b/compiler/crates/react_hermes_parser/tests/fixtures/jsx-member-expression-tag-grouping.js deleted file mode 100644 index 4455f9a9abdf4..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-member-expression-tag-grouping.js +++ /dev/null @@ -1,4 +0,0 @@ -function Component(props) { - const maybeMutable = new MaybeMutable(); - return {maybeMutate(maybeMutable)}; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-member-expression.js b/compiler/crates/react_hermes_parser/tests/fixtures/jsx-member-expression.js deleted file mode 100644 index 40f36ac072da6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-member-expression.js +++ /dev/null @@ -1,7 +0,0 @@ -function Component(props) { - return ( - - - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-namespaced-name.js b/compiler/crates/react_hermes_parser/tests/fixtures/jsx-namespaced-name.js deleted file mode 100644 index e09a13331d406..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-namespaced-name.js +++ /dev/null @@ -1,3 +0,0 @@ -function Component(props) { - return ; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-spread.js b/compiler/crates/react_hermes_parser/tests/fixtures/jsx-spread.js deleted file mode 100644 index 0dd5d5c96c2f3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-spread.js +++ /dev/null @@ -1,5 +0,0 @@ -function Component(props) { - return ( - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order-non-global.js b/compiler/crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order-non-global.js deleted file mode 100644 index b2440232c8359..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order-non-global.js +++ /dev/null @@ -1,13 +0,0 @@ -function Component(props) { - const maybeMutable = new MaybeMutable(); - let Tag = props.component; - // NOTE: the order of evaluation in the lowering is incorrect: - // the jsx element's tag observes `Tag` after reassignment, but should observe - // it before the reassignment. - return ( - - {((Tag = props.alternateComponent), maybeMutate(maybeMutable))} - - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order.js b/compiler/crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order.js deleted file mode 100644 index 51f6b51ff7170..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order.js +++ /dev/null @@ -1,9 +0,0 @@ -function Component(props) { - let Tag = View; - return ( - - {((Tag = HScroll), props.value)} - - - ); -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-capture-returned-alias.js b/compiler/crates/react_hermes_parser/tests/fixtures/lambda-capture-returned-alias.js deleted file mode 100644 index 0bc0187f9affe..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-capture-returned-alias.js +++ /dev/null @@ -1,18 +0,0 @@ -// Here, element should not be memoized independently of aliasedElement, since -// it is captured by fn. -// AnalyzeFunctions currently does not find captured objects. -// - mutated context refs are declared as `Capture` effect in `FunctionExpression.deps` -// - all other context refs are left as Unknown. InferReferenceEffects currently demotes -// them to reads -function CaptureNotMutate(props) { - const idx = foo(props.x); - const element = bar(props.el); - - const fn = function () { - const arr = { element }; - return arr[idx]; - }; - const aliasedElement = fn(); - mutate(aliasedElement); - return aliasedElement; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutate-shadowed-object.js b/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutate-shadowed-object.js deleted file mode 100644 index 4971f05bd7254..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutate-shadowed-object.js +++ /dev/null @@ -1,11 +0,0 @@ -function Component() { - const x = {}; - { - const x = []; - const fn = function () { - mutate(x); - }; - fn(); - } - return x; // should return {} -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutated-non-reactive-to-reactive.js b/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutated-non-reactive-to-reactive.js deleted file mode 100644 index 85c905ea13e72..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutated-non-reactive-to-reactive.js +++ /dev/null @@ -1,7 +0,0 @@ -function f(a) { - let x; - (() => { - x = { a }; - })(); - return
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutated-ref-non-reactive.js b/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutated-ref-non-reactive.js deleted file mode 100644 index 25f57c6374a33..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-mutated-ref-non-reactive.js +++ /dev/null @@ -1,8 +0,0 @@ -function f(a) { - let x; - (() => { - x = {}; - })(); - // this is not reactive on `x` as `x` is never reactive - return
; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-reassign-primitive.js b/compiler/crates/react_hermes_parser/tests/fixtures/lambda-reassign-primitive.js deleted file mode 100644 index 824b269bd5432..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-reassign-primitive.js +++ /dev/null @@ -1,14 +0,0 @@ -// writing to primitives is not a 'mutate' or 'store' to context references, -// under current analysis in AnalyzeFunctions. -// $23:TFunction = Function @deps[ -// $21:TPrimitive, $22:TPrimitive]: - -function Component() { - let x = 40; - - const fn = function () { - x = x + 1; - }; - fn(); - return x; -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-reassign-shadowed-primitive.js b/compiler/crates/react_hermes_parser/tests/fixtures/lambda-reassign-shadowed-primitive.js deleted file mode 100644 index 66edf6b9f3356..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-reassign-shadowed-primitive.js +++ /dev/null @@ -1,11 +0,0 @@ -function Component() { - const x = {}; - { - let x = 56; - const fn = function () { - x = 42; - }; - fn(); - } - return x; // should return {} -} diff --git a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-with-fbt.js b/compiler/crates/react_hermes_parser/tests/fixtures/lambda-with-fbt.js deleted file mode 100644 index 539fc7e1f60a6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/fixtures/lambda-with-fbt.js +++ /dev/null @@ -1,30 +0,0 @@ -import { fbt } from "fbt"; - -function Component() { - const buttonLabel = () => { - if (!someCondition) { - return {"Purchase as a gift"}; - } else if ( - !iconOnly && - showPrice && - item?.current_gift_offer?.price?.formatted != null - ) { - return ( - - {"Gift | "} - - {item?.current_gift_offer?.price?.formatted} - - - ); - } else if (!iconOnly && !showPrice) { - return {"Gift"}; - } - }; - - return ( - - ; - ; - - const j = function bar([quz, qux], ...args) {}; - - for (; i < 3; i += 1) { - x.push(i); - } - for (; i < 3; ) { - break; - } - for (;;) { - break; - } - - graphql` - ${g} - `; - - graphql`\\t\n`; - - for (c of [1, 2]) { - } - for ([v] of [[1], [2]]) { - } - for ({ v } of [{ v: 1 }, { v: 2 }]) { - } - - for (let x in { a: 1 }) { - } - - let updateIdentifier = 0; - --updateIdentifier; - ++updateIdentifier; - updateIdentifier.y++; - updateIdentifier.y--; - - switch (i) { - case 1 + 1: { - } - case foo(): { - } - case x.y: { - } - default: { - } - } - - function component(a) { - // Add support for function declarations once we support `var` hoisting. - function t() {} - t(); - } -} - -let moduleLocal = false; - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "ArrayPattern", - "elements": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 14, - 15 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 17, - 18 - ] - } - ], - "loc": null, - "range": [ - 13, - 19 - ] - }, - { - "type": "ObjectPattern", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 23, - 24 - ] - }, - "value": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 23, - 24 - ] - }, - "kind": "init", - "computed": false, - "shorthand": true, - "method": false, - "loc": null, - "range": [ - 23, - 24 - ] - }, - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 26, - 27 - ] - }, - "value": { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 26, - 27 - ] - }, - "kind": "init", - "computed": false, - "shorthand": true, - "method": false, - "loc": null, - "range": [ - 26, - 27 - ] - }, - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "e", - "typeAnnotation": null, - "loc": null, - "range": [ - 29, - 30 - ] - }, - "value": { - "type": "AssignmentPattern", - "left": { - "type": "Identifier", - "name": "e", - "typeAnnotation": null, - "loc": null, - "range": [ - 29, - 30 - ] - }, - "right": { - "type": "StringLiteral", - "value": "e", - "loc": null, - "range": [ - 33, - 36 - ] - }, - "loc": null, - "range": [ - 29, - 36 - ] - }, - "kind": "init", - "computed": false, - "shorthand": true, - "method": false, - "loc": null, - "range": [ - 29, - 36 - ] - } - ], - "loc": null, - "range": [ - 21, - 38 - ] - }, - { - "type": "AssignmentPattern", - "left": { - "type": "Identifier", - "name": "f", - "typeAnnotation": null, - "loc": null, - "range": [ - 40, - 41 - ] - }, - "right": { - "type": "StringLiteral", - "value": "f", - "loc": null, - "range": [ - 44, - 47 - ] - }, - "loc": null, - "range": [ - 40, - 47 - ] - }, - { - "type": "RestElement", - "argument": { - "type": "Identifier", - "name": "args", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 56 - ] - }, - "loc": null, - "range": [ - 49, - 56 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 66, - 67 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 70, - 71 - ] - }, - "loc": null, - "range": [ - 66, - 71 - ] - } - ], - "loc": null, - "range": [ - 62, - 72 - ] - }, - { - "type": "VariableDeclaration", - "kind": "var", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 79, - 80 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 83, - 85 - ] - }, - "loc": null, - "range": [ - 79, - 85 - ] - } - ], - "loc": null, - "range": [ - 75, - 86 - ] - }, - { - "type": "ClassDeclaration", - "id": { - "type": "Identifier", - "name": "Bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 96, - 99 - ] - }, - "superClass": null, - "body": { - "type": "ClassBody", - "body": [ - { - "type": "ClassPrivateProperty", - "key": { - "type": "Identifier", - "name": "secretSauce", - "typeAnnotation": null, - "loc": null, - "range": [ - 106, - 118 - ] - }, - "value": { - "type": "NumericLiteral", - "value": 42.0, - "loc": null, - "range": [ - 121, - 123 - ] - }, - "static": false, - "loc": null, - "range": [ - 106, - 124 - ] - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "typeAnnotation": null, - "loc": null, - "range": [ - 129, - 140 - ] - }, - "value": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "typeAnnotation": null, - "loc": null, - "range": [ - 151, - 158 - ] - }, - "property": { - "type": "Identifier", - "name": "log", - "typeAnnotation": null, - "loc": null, - "range": [ - 159, - 162 - ] - }, - "computed": false, - "loc": null, - "range": [ - 151, - 162 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": null, - "range": [ - 163, - 167 - ] - }, - "property": { - "type": "PrivateName", - "id": { - "type": "Identifier", - "name": "secretSauce", - "typeAnnotation": null, - "loc": null, - "range": [ - 168, - 180 - ] - }, - "loc": null, - "range": [ - 168, - 180 - ] - }, - "computed": false, - "loc": null, - "range": [ - 163, - 180 - ] - } - ], - "loc": null, - "range": [ - 151, - 181 - ] - }, - "directive": null, - "loc": null, - "range": [ - 151, - 182 - ] - } - ], - "loc": null, - "range": [ - 143, - 188 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 140, - 188 - ], - "loc": null, - "range": [ - 140, - 188 - ] - }, - "kind": "constructor", - "computed": false, - "static": false, - "loc": null, - "range": [ - 129, - 188 - ] - } - ], - "loc": null, - "range": [ - 100, - 192 - ] - }, - "loc": null, - "range": [ - 90, - 192 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "g", - "typeAnnotation": null, - "loc": null, - "range": [ - 202, - 203 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 208, - 209 - ] - }, - "value": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 212, - 214 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 208, - 214 - ], - "loc": null, - "range": [ - 208, - 214 - ] - }, - "kind": "init", - "method": true, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 208, - 214 - ] - }, - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 216, - 217 - ] - }, - "value": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 225, - 227 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 219, - 227 - ], - "expression": false, - "loc": null, - "range": [ - 219, - 227 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 216, - 227 - ] - } - ], - "loc": null, - "range": [ - 206, - 229 - ] - }, - "loc": null, - "range": [ - 202, - 229 - ] - } - ], - "loc": null, - "range": [ - 196, - 230 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ObjectPattern", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "z", - "typeAnnotation": null, - "loc": null, - "range": [ - 241, - 242 - ] - }, - "value": { - "type": "Identifier", - "name": "z", - "typeAnnotation": null, - "loc": null, - "range": [ - 241, - 242 - ] - }, - "kind": "init", - "computed": false, - "shorthand": true, - "method": false, - "loc": null, - "range": [ - 241, - 242 - ] - }, - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "aa", - "typeAnnotation": null, - "loc": null, - "range": [ - 244, - 246 - ] - }, - "value": { - "type": "AssignmentPattern", - "left": { - "type": "Identifier", - "name": "aa", - "typeAnnotation": null, - "loc": null, - "range": [ - 244, - 246 - ] - }, - "right": { - "type": "StringLiteral", - "value": "aa", - "loc": null, - "range": [ - 249, - 253 - ] - }, - "loc": null, - "range": [ - 244, - 253 - ] - }, - "kind": "init", - "computed": false, - "shorthand": true, - "method": false, - "loc": null, - "range": [ - 244, - 253 - ] - } - ], - "loc": null, - "range": [ - 239, - 255 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useCustom", - "typeAnnotation": null, - "loc": null, - "range": [ - 258, - 267 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 258, - 269 - ] - }, - "loc": null, - "range": [ - 239, - 269 - ] - } - ], - "loc": null, - "range": [ - 233, - 270 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Button", - "loc": null, - "range": [ - 275, - 281 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "haha", - "loc": null, - "range": [ - 282, - 286 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 288, - 289 - ] - }, - "loc": null, - "range": [ - 287, - 290 - ] - }, - "loc": null, - "range": [ - 282, - 290 - ] - } - ], - "selfClosing": false, - "loc": null, - "range": [ - 274, - 291 - ] - }, - "children": [], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Button", - "loc": null, - "range": [ - 293, - 299 - ] - }, - "loc": null, - "range": [ - 291, - 300 - ] - }, - "loc": null, - "range": [ - 274, - 300 - ] - }, - "directive": null, - "loc": null, - "range": [ - 274, - 301 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Button", - "loc": null, - "range": [ - 305, - 311 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 304, - 312 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "JSXEmptyExpression", - "loc": null, - "range": [ - 313, - 325 - ] - }, - "loc": null, - "range": [ - 312, - 326 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Button", - "loc": null, - "range": [ - 328, - 334 - ] - }, - "loc": null, - "range": [ - 326, - 335 - ] - }, - "loc": null, - "range": [ - 304, - 335 - ] - }, - "directive": null, - "loc": null, - "range": [ - 304, - 336 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "j", - "typeAnnotation": null, - "loc": null, - "range": [ - 346, - 347 - ] - }, - "init": { - "type": "FunctionExpression", - "id": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 359, - 362 - ] - }, - "params": [ - { - "type": "ArrayPattern", - "elements": [ - { - "type": "Identifier", - "name": "quz", - "typeAnnotation": null, - "loc": null, - "range": [ - 364, - 367 - ] - }, - { - "type": "Identifier", - "name": "qux", - "typeAnnotation": null, - "loc": null, - "range": [ - 369, - 372 - ] - } - ], - "loc": null, - "range": [ - 363, - 373 - ] - }, - { - "type": "RestElement", - "argument": { - "type": "Identifier", - "name": "args", - "typeAnnotation": null, - "loc": null, - "range": [ - 378, - 382 - ] - }, - "loc": null, - "range": [ - 375, - 382 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 384, - 386 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 350, - 386 - ], - "loc": null, - "range": [ - 350, - 386 - ] - }, - "loc": null, - "range": [ - 346, - 386 - ] - } - ], - "loc": null, - "range": [ - 340, - 387 - ] - }, - { - "type": "ForStatement", - "init": null, - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 398, - 399 - ] - }, - "operator": "<", - "right": { - "type": "NumericLiteral", - "value": 3.0, - "loc": null, - "range": [ - 402, - 403 - ] - }, - "loc": null, - "range": [ - 398, - 403 - ] - }, - "update": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 405, - 406 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 410, - 411 - ] - }, - "loc": null, - "range": [ - 405, - 411 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 419, - 420 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 421, - 425 - ] - }, - "computed": false, - "loc": null, - "range": [ - 419, - 425 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 426, - 427 - ] - } - ], - "loc": null, - "range": [ - 419, - 428 - ] - }, - "directive": null, - "loc": null, - "range": [ - 419, - 429 - ] - } - ], - "loc": null, - "range": [ - 413, - 433 - ] - }, - "loc": null, - "range": [ - 391, - 433 - ] - }, - { - "type": "ForStatement", - "init": null, - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 443, - 444 - ] - }, - "operator": "<", - "right": { - "type": "NumericLiteral", - "value": 3.0, - "loc": null, - "range": [ - 447, - 448 - ] - }, - "loc": null, - "range": [ - 443, - 448 - ] - }, - "update": null, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "BreakStatement", - "label": null, - "loc": null, - "range": [ - 458, - 464 - ] - } - ], - "loc": null, - "range": [ - 452, - 468 - ] - }, - "loc": null, - "range": [ - 436, - 468 - ] - }, - { - "type": "ForStatement", - "init": null, - "test": null, - "update": null, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "BreakStatement", - "label": null, - "loc": null, - "range": [ - 486, - 492 - ] - } - ], - "loc": null, - "range": [ - 480, - 496 - ] - }, - "loc": null, - "range": [ - 471, - 496 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "TaggedTemplateExpression", - "tag": { - "type": "Identifier", - "name": "graphql", - "typeAnnotation": null, - "loc": null, - "range": [ - 500, - 507 - ] - }, - "quasi": { - "type": "TemplateLiteral", - "quasis": [ - { - "type": "TemplateElement", - "tail": false, - "value": { - "cooked": "\n ", - "raw": "\n " - }, - "loc": null, - "range": [ - 507, - 515 - ] - }, - { - "type": "TemplateElement", - "tail": true, - "value": { - "cooked": "\n ", - "raw": "\n " - }, - "loc": null, - "range": [ - 516, - 521 - ] - } - ], - "expressions": [ - { - "type": "Identifier", - "name": "g", - "typeAnnotation": null, - "loc": null, - "range": [ - 515, - 516 - ] - } - ], - "loc": null, - "range": [ - 507, - 521 - ] - }, - "loc": null, - "range": [ - 500, - 521 - ] - }, - "directive": null, - "loc": null, - "range": [ - 500, - 522 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "TaggedTemplateExpression", - "tag": { - "type": "Identifier", - "name": "graphql", - "typeAnnotation": null, - "loc": null, - "range": [ - 526, - 533 - ] - }, - "quasi": { - "type": "TemplateLiteral", - "quasis": [ - { - "type": "TemplateElement", - "tail": true, - "value": { - "cooked": "\\t\n", - "raw": "\\\\t\\n" - }, - "loc": null, - "range": [ - 533, - 540 - ] - } - ], - "expressions": [], - "loc": null, - "range": [ - 533, - 540 - ] - }, - "loc": null, - "range": [ - 526, - 540 - ] - }, - "directive": null, - "loc": null, - "range": [ - 526, - 541 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 550, - 551 - ] - }, - "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 556, - 557 - ] - }, - { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 559, - 560 - ] - } - ], - "loc": null, - "range": [ - 555, - 561 - ] - }, - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 563, - 568 - ] - }, - "loc": null, - "range": [ - 545, - 568 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "ArrayPattern", - "elements": [ - { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 577, - 578 - ] - } - ], - "loc": null, - "range": [ - 576, - 579 - ] - }, - "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 585, - 586 - ] - } - ], - "loc": null, - "range": [ - 584, - 587 - ] - }, - { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 590, - 591 - ] - } - ], - "loc": null, - "range": [ - 589, - 592 - ] - } - ], - "loc": null, - "range": [ - 583, - 593 - ] - }, - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 595, - 600 - ] - }, - "loc": null, - "range": [ - 571, - 600 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "ObjectPattern", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 610, - 611 - ] - }, - "value": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 610, - 611 - ] - }, - "kind": "init", - "computed": false, - "shorthand": true, - "method": false, - "loc": null, - "range": [ - 610, - 611 - ] - } - ], - "loc": null, - "range": [ - 608, - 613 - ] - }, - "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 620, - 621 - ] - }, - "value": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 623, - 624 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 620, - 624 - ] - } - ], - "loc": null, - "range": [ - 618, - 626 - ] - }, - { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 630, - 631 - ] - }, - "value": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 633, - 634 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 630, - 634 - ] - } - ], - "loc": null, - "range": [ - 628, - 636 - ] - } - ], - "loc": null, - "range": [ - 617, - 637 - ] - }, - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 639, - 644 - ] - }, - "loc": null, - "range": [ - 603, - 644 - ] - }, - { - "type": "ForInStatement", - "left": { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 657, - 658 - ] - }, - "init": null, - "loc": null, - "range": [ - 657, - 658 - ] - } - ], - "loc": null, - "range": [ - 653, - 658 - ] - }, - "right": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 664, - 665 - ] - }, - "value": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 667, - 668 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 664, - 668 - ] - } - ], - "loc": null, - "range": [ - 662, - 670 - ] - }, - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 672, - 677 - ] - }, - "loc": null, - "range": [ - 648, - 677 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "updateIdentifier", - "typeAnnotation": null, - "loc": null, - "range": [ - 685, - 701 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 704, - 705 - ] - }, - "loc": null, - "range": [ - 685, - 705 - ] - } - ], - "loc": null, - "range": [ - 681, - 706 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "--", - "argument": { - "type": "Identifier", - "name": "updateIdentifier", - "typeAnnotation": null, - "loc": null, - "range": [ - 711, - 727 - ] - }, - "prefix": true, - "loc": null, - "range": [ - 709, - 727 - ] - }, - "directive": null, - "loc": null, - "range": [ - 709, - 728 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "Identifier", - "name": "updateIdentifier", - "typeAnnotation": null, - "loc": null, - "range": [ - 733, - 749 - ] - }, - "prefix": true, - "loc": null, - "range": [ - 731, - 749 - ] - }, - "directive": null, - "loc": null, - "range": [ - 731, - 750 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "updateIdentifier", - "typeAnnotation": null, - "loc": null, - "range": [ - 753, - 769 - ] - }, - "property": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 770, - 771 - ] - }, - "computed": false, - "loc": null, - "range": [ - 753, - 771 - ] - }, - "prefix": false, - "loc": null, - "range": [ - 753, - 773 - ] - }, - "directive": null, - "loc": null, - "range": [ - 753, - 774 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "--", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "updateIdentifier", - "typeAnnotation": null, - "loc": null, - "range": [ - 777, - 793 - ] - }, - "property": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 794, - 795 - ] - }, - "computed": false, - "loc": null, - "range": [ - 777, - 795 - ] - }, - "prefix": false, - "loc": null, - "range": [ - 777, - 797 - ] - }, - "directive": null, - "loc": null, - "range": [ - 777, - 798 - ] - }, - { - "type": "SwitchStatement", - "discriminant": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 810, - 811 - ] - }, - "cases": [ - { - "type": "SwitchCase", - "test": { - "type": "BinaryExpression", - "left": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 824, - 825 - ] - }, - "operator": "+", - "right": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 828, - 829 - ] - }, - "loc": null, - "range": [ - 824, - 829 - ] - }, - "consequent": [ - { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 831, - 838 - ] - } - ], - "loc": null, - "range": [ - 819, - 838 - ] - }, - { - "type": "SwitchCase", - "test": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 848, - 851 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 848, - 853 - ] - }, - "consequent": [ - { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 855, - 862 - ] - } - ], - "loc": null, - "range": [ - 843, - 862 - ] - }, - { - "type": "SwitchCase", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 872, - 873 - ] - }, - "property": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 874, - 875 - ] - }, - "computed": false, - "loc": null, - "range": [ - 872, - 875 - ] - }, - "consequent": [ - { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 877, - 884 - ] - } - ], - "loc": null, - "range": [ - 867, - 884 - ] - }, - { - "type": "SwitchCase", - "test": null, - "consequent": [ - { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 898, - 905 - ] - } - ], - "loc": null, - "range": [ - 889, - 905 - ] - } - ], - "loc": null, - "range": [ - 802, - 909 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "component", - "typeAnnotation": null, - "loc": null, - "range": [ - 922, - 931 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 932, - 933 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 1027, - 1028 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 1031, - 1033 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 1018, - 1033 - ], - "loc": null, - "range": [ - 1018, - 1033 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 1038, - 1039 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 1038, - 1041 - ] - }, - "directive": null, - "loc": null, - "range": [ - 1038, - 1042 - ] - } - ], - "loc": null, - "range": [ - 935, - 1046 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 913, - 1046 - ], - "loc": null, - "range": [ - 913, - 1046 - ] - } - ], - "loc": null, - "range": [ - 58, - 1048 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 1048 - ], - "loc": null, - "range": [ - 0, - 1048 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "moduleLocal", - "typeAnnotation": null, - "loc": null, - "range": [ - 1054, - 1065 - ] - }, - "init": { - "type": "BooleanLiteral", - "value": false, - "loc": null, - "range": [ - 1068, - 1073 - ] - }, - "loc": null, - "range": [ - 1054, - 1073 - ] - } - ], - "loc": null, - "range": [ - 1050, - 1074 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 1074 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo-unconditional-set-state-lambda.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo-unconditional-set-state-lambda.js.snap deleted file mode 100644 index 515c02c625933..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo-unconditional-set-state-lambda.js.snap +++ /dev/null @@ -1,393 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/error.todo-unconditional-set-state-lambda.js ---- -Input: -function Component(props) { - let y = 0; - const [x, setX] = useState(0); - - const foo = () => { - setX(1); - y = 1; // TODO: force foo's mutable range to extend, but ideally we can just remove this line - }; - foo(); - - return [x, y]; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 35 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 38, - 39 - ] - }, - "loc": null, - "range": [ - 34, - 39 - ] - } - ], - "loc": null, - "range": [ - 30, - 40 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ArrayPattern", - "elements": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 50, - 51 - ] - }, - { - "type": "Identifier", - "name": "setX", - "typeAnnotation": null, - "loc": null, - "range": [ - 53, - 57 - ] - } - ], - "loc": null, - "range": [ - 49, - 58 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useState", - "typeAnnotation": null, - "loc": null, - "range": [ - 61, - 69 - ] - }, - "arguments": [ - { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 70, - 71 - ] - } - ], - "loc": null, - "range": [ - 61, - 72 - ] - }, - "loc": null, - "range": [ - 49, - 72 - ] - } - ], - "loc": null, - "range": [ - 43, - 73 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 83, - 86 - ] - }, - "init": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "setX", - "typeAnnotation": null, - "loc": null, - "range": [ - 101, - 105 - ] - }, - "arguments": [ - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 106, - 107 - ] - } - ], - "loc": null, - "range": [ - 101, - 108 - ] - }, - "directive": null, - "loc": null, - "range": [ - 101, - 109 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 114, - 115 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 118, - 119 - ] - }, - "loc": null, - "range": [ - 114, - 119 - ] - }, - "directive": null, - "loc": null, - "range": [ - 114, - 120 - ] - } - ], - "loc": null, - "range": [ - 95, - 211 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 89, - 211 - ], - "expression": false, - "loc": null, - "range": [ - 89, - 211 - ] - }, - "loc": null, - "range": [ - 83, - 211 - ] - } - ], - "loc": null, - "range": [ - 77, - 212 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 215, - 218 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 215, - 220 - ] - }, - "directive": null, - "loc": null, - "range": [ - 215, - 221 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "ArrayExpression", - "elements": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 233, - 234 - ] - }, - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 236, - 237 - ] - } - ], - "loc": null, - "range": [ - 232, - 238 - ] - }, - "loc": null, - "range": [ - 225, - 239 - ] - } - ], - "loc": null, - "range": [ - 26, - 241 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 241 - ], - "loc": null, - "range": [ - 0, - 241 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 241 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo.destructure-assignment-to-context-var.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo.destructure-assignment-to-context-var.js.snap deleted file mode 100644 index 2e67170f049bf..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.todo.destructure-assignment-to-context-var.js.snap +++ /dev/null @@ -1,347 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/error.todo.destructure-assignment-to-context-var.js ---- -Input: -function useFoo(props) { - let x; - [x] = props; - const foo = () => { - x = getX(props); - }; - foo(); - return { x }; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "useFoo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 15 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 16, - 21 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 32 - ] - }, - "init": null, - "loc": null, - "range": [ - 31, - 32 - ] - } - ], - "loc": null, - "range": [ - 27, - 33 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "ArrayPattern", - "elements": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 37, - 38 - ] - } - ], - "loc": null, - "range": [ - 36, - 39 - ] - }, - "right": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 42, - 47 - ] - }, - "loc": null, - "range": [ - 36, - 47 - ] - }, - "directive": null, - "loc": null, - "range": [ - 36, - 48 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 57, - 60 - ] - }, - "init": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 75, - 76 - ] - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "getX", - "typeAnnotation": null, - "loc": null, - "range": [ - 79, - 83 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 84, - 89 - ] - } - ], - "loc": null, - "range": [ - 79, - 90 - ] - }, - "loc": null, - "range": [ - 75, - 90 - ] - }, - "directive": null, - "loc": null, - "range": [ - 75, - 91 - ] - } - ], - "loc": null, - "range": [ - 69, - 95 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 63, - 95 - ], - "expression": false, - "loc": null, - "range": [ - 63, - 95 - ] - }, - "loc": null, - "range": [ - 57, - 95 - ] - } - ], - "loc": null, - "range": [ - 51, - 96 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 99, - 102 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 99, - 104 - ] - }, - "directive": null, - "loc": null, - "range": [ - 99, - 105 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 117, - 118 - ] - }, - "value": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 117, - 118 - ] - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "loc": null, - "range": [ - 117, - 118 - ] - } - ], - "loc": null, - "range": [ - 115, - 120 - ] - }, - "loc": null, - "range": [ - 108, - 121 - ] - } - ], - "loc": null, - "range": [ - 23, - 123 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 123 - ], - "loc": null, - "range": [ - 0, - 123 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 123 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.useMemo-callback-generator.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.useMemo-callback-generator.js.snap deleted file mode 100644 index 6074deececbb7..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.useMemo-callback-generator.js.snap +++ /dev/null @@ -1,217 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/error.useMemo-callback-generator.js ---- -Input: -function component(a, b) { - // we don't handle generators at all so this test isn't - // useful for now, but adding this test in case we do - // add support for generators in the future. - let x = useMemo(function* () { - yield a; - }, []); - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 22, - 23 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 194, - 195 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useMemo", - "typeAnnotation": null, - "loc": null, - "range": [ - 198, - 205 - ] - }, - "arguments": [ - { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "YieldExpression", - "argument": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 231, - 232 - ] - }, - "delegate": false, - "loc": null, - "range": [ - 225, - 232 - ] - }, - "directive": null, - "loc": null, - "range": [ - 225, - 233 - ] - } - ], - "loc": null, - "range": [ - 219, - 237 - ] - }, - "generator": true, - "async": false, - "loc": null, - "range": [ - 206, - 237 - ], - "loc": null, - "range": [ - 206, - 237 - ] - }, - { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 239, - 241 - ] - } - ], - "loc": null, - "range": [ - 198, - 242 - ] - }, - "loc": null, - "range": [ - 194, - 242 - ] - } - ], - "loc": null, - "range": [ - 190, - 243 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 253, - 254 - ] - }, - "loc": null, - "range": [ - 246, - 255 - ] - } - ], - "loc": null, - "range": [ - 25, - 257 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 257 - ], - "loc": null, - "range": [ - 0, - 257 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 257 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.while-with-assignment-in-test.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.while-with-assignment-in-test.js.snap deleted file mode 100644 index e491fb67d0d76..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@error.while-with-assignment-in-test.js.snap +++ /dev/null @@ -1,367 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/error.while-with-assignment-in-test.js ---- -Input: -function f(reader) { - const queue = [1, 2, 3]; - let value = 0; - let sum = 0; - // BUG: we need to codegen the complex test expression - while ((value = queue.pop()) != null) { - sum += value; - } - return sum; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "f", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "reader", - "typeAnnotation": null, - "loc": null, - "range": [ - 11, - 17 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "queue", - "typeAnnotation": null, - "loc": null, - "range": [ - 29, - 34 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 38, - 39 - ] - }, - { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 41, - 42 - ] - }, - { - "type": "NumericLiteral", - "value": 3.0, - "loc": null, - "range": [ - 44, - 45 - ] - } - ], - "loc": null, - "range": [ - 37, - 46 - ] - }, - "loc": null, - "range": [ - 29, - 46 - ] - } - ], - "loc": null, - "range": [ - 23, - 47 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 54, - 59 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 62, - 63 - ] - }, - "loc": null, - "range": [ - 54, - 63 - ] - } - ], - "loc": null, - "range": [ - 50, - 64 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "sum", - "typeAnnotation": null, - "loc": null, - "range": [ - 71, - 74 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 77, - 78 - ] - }, - "loc": null, - "range": [ - 71, - 78 - ] - } - ], - "loc": null, - "range": [ - 67, - 79 - ] - }, - { - "type": "WhileStatement", - "test": { - "type": "BinaryExpression", - "left": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 147, - 152 - ] - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "queue", - "typeAnnotation": null, - "loc": null, - "range": [ - 155, - 160 - ] - }, - "property": { - "type": "Identifier", - "name": "pop", - "typeAnnotation": null, - "loc": null, - "range": [ - 161, - 164 - ] - }, - "computed": false, - "loc": null, - "range": [ - 155, - 164 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 155, - 166 - ] - }, - "loc": null, - "range": [ - 147, - 166 - ] - }, - "operator": "!=", - "right": { - "type": "NullLiteral", - "loc": null, - "range": [ - 171, - 175 - ] - }, - "loc": null, - "range": [ - 146, - 175 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "sum", - "typeAnnotation": null, - "loc": null, - "range": [ - 183, - 186 - ] - }, - "right": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 190, - 195 - ] - }, - "loc": null, - "range": [ - 183, - 195 - ] - }, - "directive": null, - "loc": null, - "range": [ - 183, - 196 - ] - } - ], - "loc": null, - "range": [ - 177, - 200 - ] - }, - "loc": null, - "range": [ - 139, - 200 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "sum", - "typeAnnotation": null, - "loc": null, - "range": [ - 210, - 213 - ] - }, - "loc": null, - "range": [ - 203, - 214 - ] - } - ], - "loc": null, - "range": [ - 19, - 216 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 216 - ], - "loc": null, - "range": [ - 0, - 216 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 216 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-destructured-rest-element.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-destructured-rest-element.js.snap deleted file mode 100644 index 47f45086bf04f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-destructured-rest-element.js.snap +++ /dev/null @@ -1,392 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-destructured-rest-element.js ---- -Input: -function Component(props) { - // b is an object, must be memoized even though the input is not memoized - const { a, ...b } = props.a; - // d is an array, mut be memoized even though the input is not memoized - const [c, ...d] = props.c; - return
; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ObjectPattern", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 114, - 115 - ] - }, - "value": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 114, - 115 - ] - }, - "kind": "init", - "computed": false, - "shorthand": true, - "method": false, - "loc": null, - "range": [ - 114, - 115 - ] - }, - { - "type": "RestElement", - "argument": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 120, - 121 - ] - }, - "loc": null, - "range": [ - 117, - 121 - ] - } - ], - "loc": null, - "range": [ - 112, - 123 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 126, - 131 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 132, - 133 - ] - }, - "computed": false, - "loc": null, - "range": [ - 126, - 133 - ] - }, - "loc": null, - "range": [ - 112, - 133 - ] - } - ], - "loc": null, - "range": [ - 106, - 134 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ArrayPattern", - "elements": [ - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 218, - 219 - ] - }, - { - "type": "RestElement", - "argument": { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 224, - 225 - ] - }, - "loc": null, - "range": [ - 221, - 225 - ] - } - ], - "loc": null, - "range": [ - 217, - 226 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 229, - 234 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 235, - 236 - ] - }, - "computed": false, - "loc": null, - "range": [ - 229, - 236 - ] - }, - "loc": null, - "range": [ - 217, - 236 - ] - } - ], - "loc": null, - "range": [ - 211, - 237 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 248, - 251 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "b", - "loc": null, - "range": [ - 252, - 253 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 255, - 256 - ] - }, - "loc": null, - "range": [ - 254, - 257 - ] - }, - "loc": null, - "range": [ - 252, - 257 - ] - }, - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "d", - "loc": null, - "range": [ - 258, - 259 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 261, - 262 - ] - }, - "loc": null, - "range": [ - 260, - 263 - ] - }, - "loc": null, - "range": [ - 258, - 263 - ] - } - ], - "selfClosing": false, - "loc": null, - "range": [ - 247, - 264 - ] - }, - "children": [], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 266, - 269 - ] - }, - "loc": null, - "range": [ - 264, - 270 - ] - }, - "loc": null, - "range": [ - 247, - 270 - ] - }, - "loc": null, - "range": [ - 240, - 271 - ] - } - ], - "loc": null, - "range": [ - 26, - 273 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 273 - ], - "loc": null, - "range": [ - 0, - 273 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 273 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-jsx-child.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-jsx-child.js.snap deleted file mode 100644 index 0ac5d0262bfb5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-jsx-child.js.snap +++ /dev/null @@ -1,420 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-jsx-child.js ---- -Input: -function foo(a, b, c) { - const x = []; - if (a) { - const y = []; - if (b) { - y.push(c); - } - x.push(
{y}
); - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 13, - 14 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 16, - 17 - ] - }, - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 32, - 33 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 36, - 38 - ] - }, - "loc": null, - "range": [ - 32, - 38 - ] - } - ], - "loc": null, - "range": [ - 26, - 39 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 46, - 47 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 61, - 62 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 65, - 67 - ] - }, - "loc": null, - "range": [ - 61, - 67 - ] - } - ], - "loc": null, - "range": [ - 55, - 68 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 77, - 78 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 88, - 89 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 90, - 94 - ] - }, - "computed": false, - "loc": null, - "range": [ - 88, - 94 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 95, - 96 - ] - } - ], - "loc": null, - "range": [ - 88, - 97 - ] - }, - "directive": null, - "loc": null, - "range": [ - 88, - 98 - ] - } - ], - "loc": null, - "range": [ - 80, - 104 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 73, - 104 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 109, - 110 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 111, - 115 - ] - }, - "computed": false, - "loc": null, - "range": [ - 109, - 115 - ] - }, - "arguments": [ - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 117, - 120 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 116, - 121 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 122, - 123 - ] - }, - "loc": null, - "range": [ - 121, - 124 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 126, - 129 - ] - }, - "loc": null, - "range": [ - 124, - 130 - ] - }, - "loc": null, - "range": [ - 116, - 130 - ] - } - ], - "loc": null, - "range": [ - 109, - 131 - ] - }, - "directive": null, - "loc": null, - "range": [ - 109, - 132 - ] - } - ], - "loc": null, - "range": [ - 49, - 136 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 42, - 136 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 146, - 147 - ] - }, - "loc": null, - "range": [ - 139, - 148 - ] - } - ], - "loc": null, - "range": [ - 22, - 150 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 150 - ], - "loc": null, - "range": [ - 0, - 150 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 150 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-logical.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-logical.js.snap deleted file mode 100644 index bd2e9d7451db0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-logical.js.snap +++ /dev/null @@ -1,335 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-logical.js ---- -Input: -function Component(props) { - const a = [props.a]; - const b = [props.b]; - const c = [props.c]; - // We don't do constant folding for non-primitive values (yet) so we consider - // that any of a, b, or c could return here - return (a && b) || c; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 46 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 47, - 48 - ] - }, - "computed": false, - "loc": null, - "range": [ - 41, - 48 - ] - } - ], - "loc": null, - "range": [ - 40, - 49 - ] - }, - "loc": null, - "range": [ - 36, - 49 - ] - } - ], - "loc": null, - "range": [ - 30, - 50 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 59, - 60 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 64, - 69 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 70, - 71 - ] - }, - "computed": false, - "loc": null, - "range": [ - 64, - 71 - ] - } - ], - "loc": null, - "range": [ - 63, - 72 - ] - }, - "loc": null, - "range": [ - 59, - 72 - ] - } - ], - "loc": null, - "range": [ - 53, - 73 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 82, - 83 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 87, - 92 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 93, - 94 - ] - }, - "computed": false, - "loc": null, - "range": [ - 87, - 94 - ] - } - ], - "loc": null, - "range": [ - 86, - 95 - ] - }, - "loc": null, - "range": [ - 82, - 95 - ] - } - ], - "loc": null, - "range": [ - 76, - 96 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "LogicalExpression", - "operator": "||", - "left": { - "type": "LogicalExpression", - "operator": "&&", - "left": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 233, - 234 - ] - }, - "right": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 238, - 239 - ] - }, - "loc": null, - "range": [ - 233, - 239 - ] - }, - "right": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 244, - 245 - ] - }, - "loc": null, - "range": [ - 232, - 245 - ] - }, - "loc": null, - "range": [ - 225, - 246 - ] - } - ], - "loc": null, - "range": [ - 26, - 248 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 248 - ], - "loc": null, - "range": [ - 0, - 248 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 248 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-allocating-dependency.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-allocating-dependency.js.snap deleted file mode 100644 index e84c7c7c7487d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-allocating-dependency.js.snap +++ /dev/null @@ -1,378 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-dependency.js ---- -Input: -function Component(props) { - // a can be independently memoized, is not mutated later - const a = [props.a]; - - // b and c are interleaved and grouped into a single scope, - // but they are independent values. c does not escape, but - // we need to ensure that a is memoized or else b will invalidate - // on every render since a is a dependency. - const b = []; - const c = {}; - c.a = a; - b.push(props.b); - - return b; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 95, - 96 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 100, - 105 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 106, - 107 - ] - }, - "computed": false, - "loc": null, - "range": [ - 100, - 107 - ] - } - ], - "loc": null, - "range": [ - 99, - 108 - ] - }, - "loc": null, - "range": [ - 95, - 108 - ] - } - ], - "loc": null, - "range": [ - 89, - 109 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 356, - 357 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 360, - 362 - ] - }, - "loc": null, - "range": [ - 356, - 362 - ] - } - ], - "loc": null, - "range": [ - 350, - 363 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 372, - 373 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 376, - 378 - ] - }, - "loc": null, - "range": [ - 372, - 378 - ] - } - ], - "loc": null, - "range": [ - 366, - 379 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 382, - 383 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 384, - 385 - ] - }, - "computed": false, - "loc": null, - "range": [ - 382, - 385 - ] - }, - "right": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 388, - 389 - ] - }, - "loc": null, - "range": [ - 382, - 389 - ] - }, - "directive": null, - "loc": null, - "range": [ - 382, - 390 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 393, - 394 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 395, - 399 - ] - }, - "computed": false, - "loc": null, - "range": [ - 393, - 399 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 400, - 405 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 406, - 407 - ] - }, - "computed": false, - "loc": null, - "range": [ - 400, - 407 - ] - } - ], - "loc": null, - "range": [ - 393, - 408 - ] - }, - "directive": null, - "loc": null, - "range": [ - 393, - 409 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 420, - 421 - ] - }, - "loc": null, - "range": [ - 413, - 422 - ] - } - ], - "loc": null, - "range": [ - 26, - 424 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 424 - ], - "loc": null, - "range": [ - 0, - 424 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 424 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js.snap deleted file mode 100644 index 1055cbcaf64e0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js.snap +++ /dev/null @@ -1,436 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js ---- -Input: -function Component(props) { - // a can be independently memoized, is not mutated later - // but a is a dependnecy of b, which is a dependency of c. - // we have to memoize a to avoid breaking memoization of b, - // to avoid breaking memoization of c. - const a = [props.a]; - - // a can be independently memoized, is not mutated later, - // but is a dependency of d which is part of c's scope. - // we have to memoize b to avoid breaking memoization of c. - const b = [a]; - - // c and d are interleaved and grouped into a single scope, - // but they are independent values. d does not escape, but - // we need to ensure that b is memoized or else b will invalidate - // on every render since a is a dependency. we also need to - // ensure that a is memoized, since it's a dependency of b. - const c = []; - const d = {}; - d.b = b; - c.push(props.b); - - return c; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 259, - 260 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 264, - 269 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 270, - 271 - ] - }, - "computed": false, - "loc": null, - "range": [ - 264, - 271 - ] - } - ], - "loc": null, - "range": [ - 263, - 272 - ] - }, - "loc": null, - "range": [ - 259, - 272 - ] - } - ], - "loc": null, - "range": [ - 253, - 273 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 463, - 464 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 468, - 469 - ] - } - ], - "loc": null, - "range": [ - 467, - 470 - ] - }, - "loc": null, - "range": [ - 463, - 470 - ] - } - ], - "loc": null, - "range": [ - 457, - 471 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 796, - 797 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 800, - 802 - ] - }, - "loc": null, - "range": [ - 796, - 802 - ] - } - ], - "loc": null, - "range": [ - 790, - 803 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 812, - 813 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 816, - 818 - ] - }, - "loc": null, - "range": [ - 812, - 818 - ] - } - ], - "loc": null, - "range": [ - 806, - 819 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 822, - 823 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 824, - 825 - ] - }, - "computed": false, - "loc": null, - "range": [ - 822, - 825 - ] - }, - "right": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 828, - 829 - ] - }, - "loc": null, - "range": [ - 822, - 829 - ] - }, - "directive": null, - "loc": null, - "range": [ - 822, - 830 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 833, - 834 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 835, - 839 - ] - }, - "computed": false, - "loc": null, - "range": [ - 833, - 839 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 840, - 845 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 846, - 847 - ] - }, - "computed": false, - "loc": null, - "range": [ - 840, - 847 - ] - } - ], - "loc": null, - "range": [ - 833, - 848 - ] - }, - "directive": null, - "loc": null, - "range": [ - 833, - 849 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 860, - 861 - ] - }, - "loc": null, - "range": [ - 853, - 862 - ] - } - ], - "loc": null, - "range": [ - 26, - 864 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 864 - ], - "loc": null, - "range": [ - 0, - 864 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 864 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-primitive-dependency.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-primitive-dependency.js.snap deleted file mode 100644 index 5d5c77fa320a6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-non-escaping-interleaved-primitive-dependency.js.snap +++ /dev/null @@ -1,408 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-non-escaping-interleaved-primitive-dependency.js ---- -Input: -function Component(props) { - // a does not need to be memoized ever, even though it's a - // dependency of c, which exists in a scope that has a memoized - // output. it doesn't need to be memoized bc the value is a primitive type. - const a = props.a + props.b; - - // b and c are interleaved and grouped into a single scope, - // but they are independent values. c does not escape, but - // we need to ensure that a is memoized or else b will invalidate - // on every render since a is a dependency. - const b = []; - const c = {}; - c.a = a; - b.push(props.c); - - return b; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 241, - 242 - ] - }, - "init": { - "type": "BinaryExpression", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 245, - 250 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 251, - 252 - ] - }, - "computed": false, - "loc": null, - "range": [ - 245, - 252 - ] - }, - "operator": "+", - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 255, - 260 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 261, - 262 - ] - }, - "computed": false, - "loc": null, - "range": [ - 255, - 262 - ] - }, - "loc": null, - "range": [ - 245, - 262 - ] - }, - "loc": null, - "range": [ - 241, - 262 - ] - } - ], - "loc": null, - "range": [ - 235, - 263 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 510, - 511 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 514, - 516 - ] - }, - "loc": null, - "range": [ - 510, - 516 - ] - } - ], - "loc": null, - "range": [ - 504, - 517 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 526, - 527 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 530, - 532 - ] - }, - "loc": null, - "range": [ - 526, - 532 - ] - } - ], - "loc": null, - "range": [ - 520, - 533 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 536, - 537 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 538, - 539 - ] - }, - "computed": false, - "loc": null, - "range": [ - 536, - 539 - ] - }, - "right": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 542, - 543 - ] - }, - "loc": null, - "range": [ - 536, - 543 - ] - }, - "directive": null, - "loc": null, - "range": [ - 536, - 544 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 547, - 548 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 549, - 553 - ] - }, - "computed": false, - "loc": null, - "range": [ - 547, - 553 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 554, - 559 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 560, - 561 - ] - }, - "computed": false, - "loc": null, - "range": [ - 554, - 561 - ] - } - ], - "loc": null, - "range": [ - 547, - 562 - ] - }, - "directive": null, - "loc": null, - "range": [ - 547, - 563 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 574, - 575 - ] - }, - "loc": null, - "range": [ - 567, - 576 - ] - } - ], - "loc": null, - "range": [ - 26, - 578 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 578 - ], - "loc": null, - "range": [ - 0, - 578 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 578 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-conditional-test.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-conditional-test.js.snap deleted file mode 100644 index 5bbd18ef34653..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-conditional-test.js.snap +++ /dev/null @@ -1,263 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-not-conditional-test.js ---- -Input: -function Component(props) { - const x = [props.a]; - const y = x ? props.b : props.c; - return y; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 46 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 47, - 48 - ] - }, - "computed": false, - "loc": null, - "range": [ - 41, - 48 - ] - } - ], - "loc": null, - "range": [ - 40, - 49 - ] - }, - "loc": null, - "range": [ - 36, - 49 - ] - } - ], - "loc": null, - "range": [ - 30, - 50 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 59, - 60 - ] - }, - "init": { - "type": "ConditionalExpression", - "test": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 64 - ] - }, - "alternate": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 77, - 82 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 83, - 84 - ] - }, - "computed": false, - "loc": null, - "range": [ - 77, - 84 - ] - }, - "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 67, - 72 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 73, - 74 - ] - }, - "computed": false, - "loc": null, - "range": [ - 67, - 74 - ] - }, - "loc": null, - "range": [ - 63, - 84 - ] - }, - "loc": null, - "range": [ - 59, - 84 - ] - } - ], - "loc": null, - "range": [ - 53, - 85 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 95, - 96 - ] - }, - "loc": null, - "range": [ - 88, - 97 - ] - } - ], - "loc": null, - "range": [ - 26, - 99 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 99 - ], - "loc": null, - "range": [ - 0, - 99 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 99 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-if-test.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-if-test.js.snap deleted file mode 100644 index ff520a92b2598..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-if-test.js.snap +++ /dev/null @@ -1,345 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-not-if-test.js ---- -Input: -function Component(props) { - const x = [props.a]; - let y; - if (x) { - y = props.b; - } else { - y = props.c; - } - return y; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 46 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 47, - 48 - ] - }, - "computed": false, - "loc": null, - "range": [ - 41, - 48 - ] - } - ], - "loc": null, - "range": [ - 40, - 49 - ] - }, - "loc": null, - "range": [ - 36, - 49 - ] - } - ], - "loc": null, - "range": [ - 30, - 50 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 57, - 58 - ] - }, - "init": null, - "loc": null, - "range": [ - 57, - 58 - ] - } - ], - "loc": null, - "range": [ - 53, - 59 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 66, - 67 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 75, - 76 - ] - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 79, - 84 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 85, - 86 - ] - }, - "computed": false, - "loc": null, - "range": [ - 79, - 86 - ] - }, - "loc": null, - "range": [ - 75, - 86 - ] - }, - "directive": null, - "loc": null, - "range": [ - 75, - 87 - ] - } - ], - "loc": null, - "range": [ - 69, - 91 - ] - }, - "alternate": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 103, - 104 - ] - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 107, - 112 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 113, - 114 - ] - }, - "computed": false, - "loc": null, - "range": [ - 107, - 114 - ] - }, - "loc": null, - "range": [ - 103, - 114 - ] - }, - "directive": null, - "loc": null, - "range": [ - 103, - 115 - ] - } - ], - "loc": null, - "range": [ - 97, - 119 - ] - }, - "loc": null, - "range": [ - 62, - 119 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 129, - 130 - ] - }, - "loc": null, - "range": [ - 122, - 131 - ] - } - ], - "loc": null, - "range": [ - 26, - 133 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 133 - ], - "loc": null, - "range": [ - 0, - 133 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 133 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-switch-case.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-switch-case.js.snap deleted file mode 100644 index 661cc40f6aee4..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-switch-case.js.snap +++ /dev/null @@ -1,347 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-case.js ---- -Input: -function Component(props) { - const a = [props.a]; - let x = props.b; - switch (props.c) { - case a: { - x = props.d; - } - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 46 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 47, - 48 - ] - }, - "computed": false, - "loc": null, - "range": [ - 41, - 48 - ] - } - ], - "loc": null, - "range": [ - 40, - 49 - ] - }, - "loc": null, - "range": [ - 36, - 49 - ] - } - ], - "loc": null, - "range": [ - 30, - 50 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 57, - 58 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 61, - 66 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 67, - 68 - ] - }, - "computed": false, - "loc": null, - "range": [ - 61, - 68 - ] - }, - "loc": null, - "range": [ - 57, - 68 - ] - } - ], - "loc": null, - "range": [ - 53, - 69 - ] - }, - { - "type": "SwitchStatement", - "discriminant": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 85 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 86, - 87 - ] - }, - "computed": false, - "loc": null, - "range": [ - 80, - 87 - ] - }, - "cases": [ - { - "type": "SwitchCase", - "test": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 100, - 101 - ] - }, - "consequent": [ - { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 111, - 112 - ] - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 115, - 120 - ] - }, - "property": { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 121, - 122 - ] - }, - "computed": false, - "loc": null, - "range": [ - 115, - 122 - ] - }, - "loc": null, - "range": [ - 111, - 122 - ] - }, - "directive": null, - "loc": null, - "range": [ - 111, - 123 - ] - } - ], - "loc": null, - "range": [ - 103, - 129 - ] - } - ], - "loc": null, - "range": [ - 95, - 129 - ] - } - ], - "loc": null, - "range": [ - 72, - 133 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 143, - 144 - ] - }, - "loc": null, - "range": [ - 136, - 145 - ] - } - ], - "loc": null, - "range": [ - 26, - 147 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 147 - ], - "loc": null, - "range": [ - 0, - 147 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 147 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-switch-test.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-switch-test.js.snap deleted file mode 100644 index 29058c823b2f0..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@escape-analysis-not-switch-test.js.snap +++ /dev/null @@ -1,327 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/escape-analysis-not-switch-test.js ---- -Input: -function Component(props) { - const a = [props.a]; - let x = props.b; - switch (a) { - case true: { - x = props.c; - } - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 46 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 47, - 48 - ] - }, - "computed": false, - "loc": null, - "range": [ - 41, - 48 - ] - } - ], - "loc": null, - "range": [ - 40, - 49 - ] - }, - "loc": null, - "range": [ - 36, - 49 - ] - } - ], - "loc": null, - "range": [ - 30, - 50 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 57, - 58 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 61, - 66 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 67, - 68 - ] - }, - "computed": false, - "loc": null, - "range": [ - 61, - 68 - ] - }, - "loc": null, - "range": [ - 57, - 68 - ] - } - ], - "loc": null, - "range": [ - 53, - 69 - ] - }, - { - "type": "SwitchStatement", - "discriminant": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 81 - ] - }, - "cases": [ - { - "type": "SwitchCase", - "test": { - "type": "BooleanLiteral", - "value": true, - "loc": null, - "range": [ - 94, - 98 - ] - }, - "consequent": [ - { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 108, - 109 - ] - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 112, - 117 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 118, - 119 - ] - }, - "computed": false, - "loc": null, - "range": [ - 112, - 119 - ] - }, - "loc": null, - "range": [ - 108, - 119 - ] - }, - "directive": null, - "loc": null, - "range": [ - 108, - 120 - ] - } - ], - "loc": null, - "range": [ - 100, - 126 - ] - } - ], - "loc": null, - "range": [ - 89, - 126 - ] - } - ], - "loc": null, - "range": [ - 72, - 130 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 140, - 141 - ] - }, - "loc": null, - "range": [ - 133, - 142 - ] - } - ], - "loc": null, - "range": [ - 26, - 144 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 144 - ], - "loc": null, - "range": [ - 0, - 144 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 144 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@expression-with-assignment-dynamic.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@expression-with-assignment-dynamic.js.snap deleted file mode 100644 index 42dcd00aad523..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@expression-with-assignment-dynamic.js.snap +++ /dev/null @@ -1,184 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/expression-with-assignment-dynamic.js ---- -Input: -function f(y) { - let x = y; - return x + (x = 2) + x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "f", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 11, - 12 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 22, - 23 - ] - }, - "init": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 26, - 27 - ] - }, - "loc": null, - "range": [ - 22, - 27 - ] - } - ], - "loc": null, - "range": [ - 18, - 28 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "BinaryExpression", - "left": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 38, - 39 - ] - }, - "operator": "+", - "right": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 44 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 47, - 48 - ] - }, - "loc": null, - "range": [ - 43, - 48 - ] - }, - "loc": null, - "range": [ - 38, - 49 - ] - }, - "operator": "+", - "right": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 53 - ] - }, - "loc": null, - "range": [ - 38, - 53 - ] - }, - "loc": null, - "range": [ - 31, - 54 - ] - } - ], - "loc": null, - "range": [ - 14, - 56 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 56 - ], - "loc": null, - "range": [ - 0, - 56 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 56 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@expression-with-assignment.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@expression-with-assignment.js.snap deleted file mode 100644 index c88c52f595631..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@expression-with-assignment.js.snap +++ /dev/null @@ -1,172 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/expression-with-assignment.js ---- -Input: -function f() { - let x = 1; - return x + (x = 2) + x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "f", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 21, - 22 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 25, - 26 - ] - }, - "loc": null, - "range": [ - 21, - 26 - ] - } - ], - "loc": null, - "range": [ - 17, - 27 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "BinaryExpression", - "left": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 37, - 38 - ] - }, - "operator": "+", - "right": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 42, - 43 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 46, - 47 - ] - }, - "loc": null, - "range": [ - 42, - 47 - ] - }, - "loc": null, - "range": [ - 37, - 48 - ] - }, - "operator": "+", - "right": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 51, - 52 - ] - }, - "loc": null, - "range": [ - 37, - 52 - ] - }, - "loc": null, - "range": [ - 30, - 53 - ] - } - ], - "loc": null, - "range": [ - 13, - 55 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 55 - ], - "loc": null, - "range": [ - 0, - 55 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 55 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@extend-scopes-if.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@extend-scopes-if.js.snap deleted file mode 100644 index 44c0829251e41..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@extend-scopes-if.js.snap +++ /dev/null @@ -1,365 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/extend-scopes-if.js ---- -Input: -function foo(a, b, c) { - let x = []; - if (a) { - if (b) { - if (c) { - x.push(0); - } - } - } - if (x.length) { - return x; - } - return null; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 13, - 14 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 16, - 17 - ] - }, - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 30, - 31 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 34, - 36 - ] - }, - "loc": null, - "range": [ - 30, - 36 - ] - } - ], - "loc": null, - "range": [ - 26, - 37 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 44, - 45 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 57, - 58 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 72, - 73 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 85, - 86 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 87, - 91 - ] - }, - "computed": false, - "loc": null, - "range": [ - 85, - 91 - ] - }, - "arguments": [ - { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 92, - 93 - ] - } - ], - "loc": null, - "range": [ - 85, - 94 - ] - }, - "directive": null, - "loc": null, - "range": [ - 85, - 95 - ] - } - ], - "loc": null, - "range": [ - 75, - 103 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 68, - 103 - ] - } - ], - "loc": null, - "range": [ - 60, - 109 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 53, - 109 - ] - } - ], - "loc": null, - "range": [ - 47, - 113 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 40, - 113 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 120, - 121 - ] - }, - "property": { - "type": "Identifier", - "name": "length", - "typeAnnotation": null, - "loc": null, - "range": [ - 122, - 128 - ] - }, - "computed": false, - "loc": null, - "range": [ - 120, - 128 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 143, - 144 - ] - }, - "loc": null, - "range": [ - 136, - 145 - ] - } - ], - "loc": null, - "range": [ - 130, - 149 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 116, - 149 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NullLiteral", - "loc": null, - "range": [ - 159, - 163 - ] - }, - "loc": null, - "range": [ - 152, - 164 - ] - } - ], - "loc": null, - "range": [ - 22, - 166 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 166 - ], - "loc": null, - "range": [ - 0, - 166 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 166 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-call-complex-param-value.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-call-complex-param-value.js.snap deleted file mode 100644 index f40751ff37df1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-call-complex-param-value.js.snap +++ /dev/null @@ -1,378 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/fbt-call-complex-param-value.js ---- -Input: -import fbt from "fbt"; - -function Component(props) { - const text = fbt( - `Hello, ${fbt.param("(key) name", capitalize(props.name))}!`, - "(description) Greeting" - ); - return
{text}
; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ImportDeclaration", - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "local": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 7, - 10 - ] - }, - "loc": null, - "range": [ - 7, - 10 - ] - } - ], - "source": { - "type": "StringLiteral", - "value": "fbt", - "loc": null, - "range": [ - 16, - 21 - ] - }, - "loc": null, - "range": [ - 0, - 22 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 33, - 42 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 48 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "text", - "typeAnnotation": null, - "loc": null, - "range": [ - 60, - 64 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 67, - 70 - ] - }, - "arguments": [ - { - "type": "TemplateLiteral", - "quasis": [ - { - "type": "TemplateElement", - "tail": false, - "value": { - "cooked": "Hello, ", - "raw": "Hello, " - }, - "loc": null, - "range": [ - 76, - 86 - ] - }, - { - "type": "TemplateElement", - "tail": true, - "value": { - "cooked": "!", - "raw": "!" - }, - "loc": null, - "range": [ - 133, - 136 - ] - } - ], - "expressions": [ - { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 86, - 89 - ] - }, - "property": { - "type": "Identifier", - "name": "param", - "typeAnnotation": null, - "loc": null, - "range": [ - 90, - 95 - ] - }, - "computed": false, - "loc": null, - "range": [ - 86, - 95 - ] - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "(key) name", - "loc": null, - "range": [ - 96, - 108 - ] - }, - { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "capitalize", - "typeAnnotation": null, - "loc": null, - "range": [ - 110, - 120 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 121, - 126 - ] - }, - "property": { - "type": "Identifier", - "name": "name", - "typeAnnotation": null, - "loc": null, - "range": [ - 127, - 131 - ] - }, - "computed": false, - "loc": null, - "range": [ - 121, - 131 - ] - } - ], - "loc": null, - "range": [ - 110, - 132 - ] - } - ], - "loc": null, - "range": [ - 86, - 133 - ] - } - ], - "loc": null, - "range": [ - 76, - 136 - ] - }, - { - "type": "StringLiteral", - "value": "(description) Greeting", - "loc": null, - "range": [ - 142, - 166 - ] - } - ], - "loc": null, - "range": [ - 67, - 170 - ] - }, - "loc": null, - "range": [ - 60, - 170 - ] - } - ], - "loc": null, - "range": [ - 54, - 171 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 182, - 185 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 181, - 186 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "text", - "typeAnnotation": null, - "loc": null, - "range": [ - 187, - 191 - ] - }, - "loc": null, - "range": [ - 186, - 192 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 194, - 197 - ] - }, - "loc": null, - "range": [ - 192, - 198 - ] - }, - "loc": null, - "range": [ - 181, - 198 - ] - }, - "loc": null, - "range": [ - 174, - 199 - ] - } - ], - "loc": null, - "range": [ - 50, - 201 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 24, - 201 - ], - "loc": null, - "range": [ - 24, - 201 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 201 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-call.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-call.js.snap deleted file mode 100644 index e965c671525e8..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-call.js.snap +++ /dev/null @@ -1,358 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/fbt-call.js ---- -Input: -import fbt from "fbt"; - -function Component(props) { - const text = fbt( - `${fbt.param("(key) count", props.count)} items`, - "(description) Number of items" - ); - return
{text}
; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ImportDeclaration", - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "local": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 7, - 10 - ] - }, - "loc": null, - "range": [ - 7, - 10 - ] - } - ], - "source": { - "type": "StringLiteral", - "value": "fbt", - "loc": null, - "range": [ - 16, - 21 - ] - }, - "loc": null, - "range": [ - 0, - 22 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 33, - 42 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 48 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "text", - "typeAnnotation": null, - "loc": null, - "range": [ - 60, - 64 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 67, - 70 - ] - }, - "arguments": [ - { - "type": "TemplateLiteral", - "quasis": [ - { - "type": "TemplateElement", - "tail": false, - "value": { - "cooked": "", - "raw": "" - }, - "loc": null, - "range": [ - 76, - 79 - ] - }, - { - "type": "TemplateElement", - "tail": true, - "value": { - "cooked": " items", - "raw": " items" - }, - "loc": null, - "range": [ - 116, - 124 - ] - } - ], - "expressions": [ - { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 79, - 82 - ] - }, - "property": { - "type": "Identifier", - "name": "param", - "typeAnnotation": null, - "loc": null, - "range": [ - 83, - 88 - ] - }, - "computed": false, - "loc": null, - "range": [ - 79, - 88 - ] - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "(key) count", - "loc": null, - "range": [ - 89, - 102 - ] - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 104, - 109 - ] - }, - "property": { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 110, - 115 - ] - }, - "computed": false, - "loc": null, - "range": [ - 104, - 115 - ] - } - ], - "loc": null, - "range": [ - 79, - 116 - ] - } - ], - "loc": null, - "range": [ - 76, - 124 - ] - }, - { - "type": "StringLiteral", - "value": "(description) Number of items", - "loc": null, - "range": [ - 130, - 161 - ] - } - ], - "loc": null, - "range": [ - 67, - 165 - ] - }, - "loc": null, - "range": [ - 60, - 165 - ] - } - ], - "loc": null, - "range": [ - 54, - 166 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 177, - 180 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 176, - 181 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "text", - "typeAnnotation": null, - "loc": null, - "range": [ - 182, - 186 - ] - }, - "loc": null, - "range": [ - 181, - 187 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 189, - 192 - ] - }, - "loc": null, - "range": [ - 187, - 193 - ] - }, - "loc": null, - "range": [ - 176, - 193 - ] - }, - "loc": null, - "range": [ - 169, - 194 - ] - } - ], - "loc": null, - "range": [ - 50, - 196 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 24, - 196 - ], - "loc": null, - "range": [ - 24, - 196 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 196 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-params-complex-param-value.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-params-complex-param-value.js.snap deleted file mode 100644 index a230a474e6a90..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-params-complex-param-value.js.snap +++ /dev/null @@ -1,387 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/fbt-params-complex-param-value.js ---- -Input: -import fbt from "fbt"; - -function Component(props) { - return ( - - Hello {capitalize(props.name)} - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ImportDeclaration", - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "local": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 7, - 10 - ] - }, - "loc": null, - "range": [ - 7, - 10 - ] - } - ], - "source": { - "type": "StringLiteral", - "value": "fbt", - "loc": null, - "range": [ - 16, - 21 - ] - }, - "loc": null, - "range": [ - 0, - 22 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 33, - 42 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 48 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "fbt", - "loc": null, - "range": [ - 68, - 71 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "desc", - "loc": null, - "range": [ - 72, - 76 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "StringLiteral", - "value": "Dialog to show to user", - "loc": null, - "range": [ - 78, - 102 - ] - }, - "loc": null, - "range": [ - 77, - 103 - ] - }, - "loc": null, - "range": [ - 72, - 103 - ] - } - ], - "selfClosing": false, - "loc": null, - "range": [ - 67, - 104 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n Hello ", - "raw": "\n Hello ", - "loc": null, - "range": [ - 104, - 117 - ] - }, - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXNamespacedName", - "namespace": { - "type": "JSXIdentifier", - "name": "fbt", - "loc": null, - "range": [ - 118, - 121 - ] - }, - "name": { - "type": "JSXIdentifier", - "name": "param", - "loc": null, - "range": [ - 122, - 127 - ] - }, - "loc": null, - "range": [ - 118, - 127 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "name", - "loc": null, - "range": [ - 128, - 132 - ] - }, - "value": { - "type": "JSXStringLiteral", - "value": "user name", - "raw": "\"user name\"", - "loc": null, - "range": [ - 133, - 144 - ] - }, - "loc": null, - "range": [ - 128, - 144 - ] - } - ], - "selfClosing": false, - "loc": null, - "range": [ - 117, - 145 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "capitalize", - "typeAnnotation": null, - "loc": null, - "range": [ - 146, - 156 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 157, - 162 - ] - }, - "property": { - "type": "Identifier", - "name": "name", - "typeAnnotation": null, - "loc": null, - "range": [ - 163, - 167 - ] - }, - "computed": false, - "loc": null, - "range": [ - 157, - 167 - ] - } - ], - "loc": null, - "range": [ - 146, - 168 - ] - }, - "loc": null, - "range": [ - 145, - 169 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXNamespacedName", - "namespace": { - "type": "JSXIdentifier", - "name": "fbt", - "loc": null, - "range": [ - 171, - 174 - ] - }, - "name": { - "type": "JSXIdentifier", - "name": "param", - "loc": null, - "range": [ - 175, - 180 - ] - }, - "loc": null, - "range": [ - 171, - 180 - ] - }, - "loc": null, - "range": [ - 169, - 181 - ] - }, - "loc": null, - "range": [ - 117, - 181 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 181, - 186 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "fbt", - "loc": null, - "range": [ - 188, - 191 - ] - }, - "loc": null, - "range": [ - 186, - 192 - ] - }, - "loc": null, - "range": [ - 67, - 192 - ] - }, - "loc": null, - "range": [ - 54, - 197 - ] - } - ], - "loc": null, - "range": [ - 50, - 199 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 24, - 199 - ], - "loc": null, - "range": [ - 24, - 199 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 199 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-params.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-params.js.snap deleted file mode 100644 index 7e022bca6cdf2..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-params.js.snap +++ /dev/null @@ -1,367 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/fbt-params.js ---- -Input: -import fbt from "fbt"; - -function Component(props) { - return ( - - Hello {props.name} - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ImportDeclaration", - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "local": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 7, - 10 - ] - }, - "loc": null, - "range": [ - 7, - 10 - ] - } - ], - "source": { - "type": "StringLiteral", - "value": "fbt", - "loc": null, - "range": [ - 16, - 21 - ] - }, - "loc": null, - "range": [ - 0, - 22 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 33, - 42 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 48 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "fbt", - "loc": null, - "range": [ - 68, - 71 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "desc", - "loc": null, - "range": [ - 72, - 76 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "StringLiteral", - "value": "Dialog to show to user", - "loc": null, - "range": [ - 78, - 102 - ] - }, - "loc": null, - "range": [ - 77, - 103 - ] - }, - "loc": null, - "range": [ - 72, - 103 - ] - } - ], - "selfClosing": false, - "loc": null, - "range": [ - 67, - 104 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n Hello ", - "raw": "\n Hello ", - "loc": null, - "range": [ - 104, - 117 - ] - }, - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXNamespacedName", - "namespace": { - "type": "JSXIdentifier", - "name": "fbt", - "loc": null, - "range": [ - 118, - 121 - ] - }, - "name": { - "type": "JSXIdentifier", - "name": "param", - "loc": null, - "range": [ - 122, - 127 - ] - }, - "loc": null, - "range": [ - 118, - 127 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "name", - "loc": null, - "range": [ - 128, - 132 - ] - }, - "value": { - "type": "JSXStringLiteral", - "value": "user name", - "raw": "\"user name\"", - "loc": null, - "range": [ - 133, - 144 - ] - }, - "loc": null, - "range": [ - 128, - 144 - ] - } - ], - "selfClosing": false, - "loc": null, - "range": [ - 117, - 145 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 146, - 151 - ] - }, - "property": { - "type": "Identifier", - "name": "name", - "typeAnnotation": null, - "loc": null, - "range": [ - 152, - 156 - ] - }, - "computed": false, - "loc": null, - "range": [ - 146, - 156 - ] - }, - "loc": null, - "range": [ - 145, - 157 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXNamespacedName", - "namespace": { - "type": "JSXIdentifier", - "name": "fbt", - "loc": null, - "range": [ - 159, - 162 - ] - }, - "name": { - "type": "JSXIdentifier", - "name": "param", - "loc": null, - "range": [ - 163, - 168 - ] - }, - "loc": null, - "range": [ - 159, - 168 - ] - }, - "loc": null, - "range": [ - 157, - 169 - ] - }, - "loc": null, - "range": [ - 117, - 169 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 169, - 174 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "fbt", - "loc": null, - "range": [ - 176, - 179 - ] - }, - "loc": null, - "range": [ - 174, - 180 - ] - }, - "loc": null, - "range": [ - 67, - 180 - ] - }, - "loc": null, - "range": [ - 54, - 185 - ] - } - ], - "loc": null, - "range": [ - 50, - 187 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 24, - 187 - ], - "loc": null, - "range": [ - 24, - 187 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 187 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-template-string-same-scope.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-template-string-same-scope.js.snap deleted file mode 100644 index 46566d81578ed..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@fbt-template-string-same-scope.js.snap +++ /dev/null @@ -1,556 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/fbt-template-string-same-scope.js ---- -Input: -import fbt from "fbt"; - -export function Component(props) { - let count = 0; - if (props.items) { - count = props.items.length; - } - return ( - - {fbt( - `for ${fbt.param("count", count)} experiences`, - `Label for the number of items`, - { project: "public" } - )} - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ImportDeclaration", - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "local": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 7, - 10 - ] - }, - "loc": null, - "range": [ - 7, - 10 - ] - } - ], - "source": { - "type": "StringLiteral", - "value": "fbt", - "loc": null, - "range": [ - 16, - 21 - ] - }, - "loc": null, - "range": [ - 0, - 22 - ] - }, - { - "type": "ExportNamedDeclaration", - "declaration": { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 40, - 49 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 50, - 55 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 65, - 70 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 73, - 74 - ] - }, - "loc": null, - "range": [ - 65, - 74 - ] - } - ], - "loc": null, - "range": [ - 61, - 75 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 82, - 87 - ] - }, - "property": { - "type": "Identifier", - "name": "items", - "typeAnnotation": null, - "loc": null, - "range": [ - 88, - 93 - ] - }, - "computed": false, - "loc": null, - "range": [ - 82, - 93 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 101, - 106 - ] - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 109, - 114 - ] - }, - "property": { - "type": "Identifier", - "name": "items", - "typeAnnotation": null, - "loc": null, - "range": [ - 115, - 120 - ] - }, - "computed": false, - "loc": null, - "range": [ - 109, - 120 - ] - }, - "property": { - "type": "Identifier", - "name": "length", - "typeAnnotation": null, - "loc": null, - "range": [ - 121, - 127 - ] - }, - "computed": false, - "loc": null, - "range": [ - 109, - 127 - ] - }, - "loc": null, - "range": [ - 101, - 127 - ] - }, - "directive": null, - "loc": null, - "range": [ - 101, - 128 - ] - } - ], - "loc": null, - "range": [ - 95, - 132 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 78, - 132 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 149, - 153 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 148, - 154 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 154, - 161 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 162, - 165 - ] - }, - "arguments": [ - { - "type": "TemplateLiteral", - "quasis": [ - { - "type": "TemplateElement", - "tail": false, - "value": { - "cooked": "for ", - "raw": "for " - }, - "loc": null, - "range": [ - 175, - 182 - ] - }, - { - "type": "TemplateElement", - "tail": true, - "value": { - "cooked": " experiences", - "raw": " experiences" - }, - "loc": null, - "range": [ - 207, - 221 - ] - } - ], - "expressions": [ - { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "fbt", - "typeAnnotation": null, - "loc": null, - "range": [ - 182, - 185 - ] - }, - "property": { - "type": "Identifier", - "name": "param", - "typeAnnotation": null, - "loc": null, - "range": [ - 186, - 191 - ] - }, - "computed": false, - "loc": null, - "range": [ - 182, - 191 - ] - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "count", - "loc": null, - "range": [ - 192, - 199 - ] - }, - { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 201, - 206 - ] - } - ], - "loc": null, - "range": [ - 182, - 207 - ] - } - ], - "loc": null, - "range": [ - 175, - 221 - ] - }, - { - "type": "TemplateLiteral", - "quasis": [ - { - "type": "TemplateElement", - "tail": true, - "value": { - "cooked": "Label for the number of items", - "raw": "Label for the number of items" - }, - "loc": null, - "range": [ - 231, - 262 - ] - } - ], - "expressions": [], - "loc": null, - "range": [ - 231, - 262 - ] - }, - { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "project", - "typeAnnotation": null, - "loc": null, - "range": [ - 274, - 281 - ] - }, - "value": { - "type": "StringLiteral", - "value": "public", - "loc": null, - "range": [ - 283, - 291 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 274, - 291 - ] - } - ], - "loc": null, - "range": [ - 272, - 293 - ] - } - ], - "loc": null, - "range": [ - 162, - 301 - ] - }, - "loc": null, - "range": [ - 161, - 302 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 302, - 307 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 309, - 313 - ] - }, - "loc": null, - "range": [ - 307, - 314 - ] - }, - "loc": null, - "range": [ - 148, - 314 - ] - }, - "loc": null, - "range": [ - 135, - 319 - ] - } - ], - "loc": null, - "range": [ - 57, - 321 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 31, - 321 - ], - "loc": null, - "range": [ - 31, - 321 - ] - }, - "specifiers": [], - "source": null, - "loc": null, - "range": [ - 24, - 321 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 321 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-empty-update-with-continue.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-empty-update-with-continue.js.snap deleted file mode 100644 index f3e4c2f6c7da2..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-empty-update-with-continue.js.snap +++ /dev/null @@ -1,321 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-empty-update-with-continue.js ---- -Input: -function Component(props) { - let x = 0; - for (let i = 0; i < props.count; ) { - x += i; - i += 1; - continue; - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 35 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 38, - 39 - ] - }, - "loc": null, - "range": [ - 34, - 39 - ] - } - ], - "loc": null, - "range": [ - 30, - 40 - ] - }, - { - "type": "ForStatement", - "init": { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 53 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 56, - 57 - ] - }, - "loc": null, - "range": [ - 52, - 57 - ] - } - ], - "loc": null, - "range": [ - 48, - 57 - ] - }, - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 59, - 60 - ] - }, - "operator": "<", - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 68 - ] - }, - "property": { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 69, - 74 - ] - }, - "computed": false, - "loc": null, - "range": [ - 63, - 74 - ] - }, - "loc": null, - "range": [ - 59, - 74 - ] - }, - "update": null, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 84, - 85 - ] - }, - "right": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 89, - 90 - ] - }, - "loc": null, - "range": [ - 84, - 90 - ] - }, - "directive": null, - "loc": null, - "range": [ - 84, - 91 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 96, - 97 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 101, - 102 - ] - }, - "loc": null, - "range": [ - 96, - 102 - ] - }, - "directive": null, - "loc": null, - "range": [ - 96, - 103 - ] - }, - { - "type": "ContinueStatement", - "label": null, - "loc": null, - "range": [ - 108, - 117 - ] - } - ], - "loc": null, - "range": [ - 78, - 121 - ] - }, - "loc": null, - "range": [ - 43, - 121 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 131, - 132 - ] - }, - "loc": null, - "range": [ - 124, - 133 - ] - } - ], - "loc": null, - "range": [ - 26, - 135 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 135 - ], - "loc": null, - "range": [ - 0, - 135 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 135 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-empty-update.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-empty-update.js.snap deleted file mode 100644 index 860ad9e2c38ef..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-empty-update.js.snap +++ /dev/null @@ -1,332 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-empty-update.js ---- -Input: -function Component(props) { - let x = 0; - for (let i = 0; i < props.count; ) { - x += i; - if (x > 10) { - break; - } - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 35 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 38, - 39 - ] - }, - "loc": null, - "range": [ - 34, - 39 - ] - } - ], - "loc": null, - "range": [ - 30, - 40 - ] - }, - { - "type": "ForStatement", - "init": { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 53 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 56, - 57 - ] - }, - "loc": null, - "range": [ - 52, - 57 - ] - } - ], - "loc": null, - "range": [ - 48, - 57 - ] - }, - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 59, - 60 - ] - }, - "operator": "<", - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 68 - ] - }, - "property": { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 69, - 74 - ] - }, - "computed": false, - "loc": null, - "range": [ - 63, - 74 - ] - }, - "loc": null, - "range": [ - 59, - 74 - ] - }, - "update": null, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 84, - 85 - ] - }, - "right": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 89, - 90 - ] - }, - "loc": null, - "range": [ - 84, - 90 - ] - }, - "directive": null, - "loc": null, - "range": [ - 84, - 91 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 100, - 101 - ] - }, - "operator": ">", - "right": { - "type": "NumericLiteral", - "value": 10.0, - "loc": null, - "range": [ - 104, - 106 - ] - }, - "loc": null, - "range": [ - 100, - 106 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "BreakStatement", - "label": null, - "loc": null, - "range": [ - 116, - 122 - ] - } - ], - "loc": null, - "range": [ - 108, - 128 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 96, - 128 - ] - } - ], - "loc": null, - "range": [ - 78, - 132 - ] - }, - "loc": null, - "range": [ - 43, - 132 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 142, - 143 - ] - }, - "loc": null, - "range": [ - 135, - 144 - ] - } - ], - "loc": null, - "range": [ - 26, - 146 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 146 - ], - "loc": null, - "range": [ - 0, - 146 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 146 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-logical.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-logical.js.snap deleted file mode 100644 index 7783dc8d4f263..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-logical.js.snap +++ /dev/null @@ -1,465 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-logical.js ---- -Input: -function foo(props) { - let y = 0; - for ( - let x = 0; - x > props.min && x < props.max; - x += props.cond ? props.increment : 2 - ) { - x *= 2; - y += x; - } - return y; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 13, - 18 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 28, - 29 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 32, - 33 - ] - }, - "loc": null, - "range": [ - 28, - 33 - ] - } - ], - "loc": null, - "range": [ - 24, - 34 - ] - }, - { - "type": "ForStatement", - "init": { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 51, - 52 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 55, - 56 - ] - }, - "loc": null, - "range": [ - 51, - 56 - ] - } - ], - "loc": null, - "range": [ - 47, - 56 - ] - }, - "test": { - "type": "LogicalExpression", - "operator": "&&", - "left": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 62, - 63 - ] - }, - "operator": ">", - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 66, - 71 - ] - }, - "property": { - "type": "Identifier", - "name": "min", - "typeAnnotation": null, - "loc": null, - "range": [ - 72, - 75 - ] - }, - "computed": false, - "loc": null, - "range": [ - 66, - 75 - ] - }, - "loc": null, - "range": [ - 62, - 75 - ] - }, - "right": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 79, - 80 - ] - }, - "operator": "<", - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 83, - 88 - ] - }, - "property": { - "type": "Identifier", - "name": "max", - "typeAnnotation": null, - "loc": null, - "range": [ - 89, - 92 - ] - }, - "computed": false, - "loc": null, - "range": [ - 83, - 92 - ] - }, - "loc": null, - "range": [ - 79, - 92 - ] - }, - "loc": null, - "range": [ - 62, - 92 - ] - }, - "update": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 98, - 99 - ] - }, - "right": { - "type": "ConditionalExpression", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 103, - 108 - ] - }, - "property": { - "type": "Identifier", - "name": "cond", - "typeAnnotation": null, - "loc": null, - "range": [ - 109, - 113 - ] - }, - "computed": false, - "loc": null, - "range": [ - 103, - 113 - ] - }, - "alternate": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 134, - 135 - ] - }, - "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 116, - 121 - ] - }, - "property": { - "type": "Identifier", - "name": "increment", - "typeAnnotation": null, - "loc": null, - "range": [ - 122, - 131 - ] - }, - "computed": false, - "loc": null, - "range": [ - 116, - 131 - ] - }, - "loc": null, - "range": [ - 103, - 135 - ] - }, - "loc": null, - "range": [ - 98, - 135 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "*=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 146, - 147 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 151, - 152 - ] - }, - "loc": null, - "range": [ - 146, - 152 - ] - }, - "directive": null, - "loc": null, - "range": [ - 146, - 153 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 158, - 159 - ] - }, - "right": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 163, - 164 - ] - }, - "loc": null, - "range": [ - 158, - 164 - ] - }, - "directive": null, - "loc": null, - "range": [ - 158, - 165 - ] - } - ], - "loc": null, - "range": [ - 140, - 169 - ] - }, - "loc": null, - "range": [ - 37, - 169 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 179, - 180 - ] - }, - "loc": null, - "range": [ - 172, - 181 - ] - } - ], - "loc": null, - "range": [ - 20, - 183 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 183 - ], - "loc": null, - "range": [ - 0, - 183 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 183 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-break.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-break.js.snap deleted file mode 100644 index b5e1feba0e78a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-break.js.snap +++ /dev/null @@ -1,205 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-of-break.js ---- -Input: -function Component() { - const x = []; - for (const item of [1, 2]) { - break; - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 32 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 35, - 37 - ] - }, - "loc": null, - "range": [ - 31, - 37 - ] - } - ], - "loc": null, - "range": [ - 25, - 38 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 56 - ] - }, - "init": null, - "loc": null, - "range": [ - 52, - 56 - ] - } - ], - "loc": null, - "range": [ - 46, - 56 - ] - }, - "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 61, - 62 - ] - }, - { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 64, - 65 - ] - } - ], - "loc": null, - "range": [ - 60, - 66 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "BreakStatement", - "label": null, - "loc": null, - "range": [ - 74, - 80 - ] - } - ], - "loc": null, - "range": [ - 68, - 84 - ] - }, - "loc": null, - "range": [ - 41, - 84 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 94, - 95 - ] - }, - "loc": null, - "range": [ - 87, - 96 - ] - } - ], - "loc": null, - "range": [ - 21, - 98 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 98 - ], - "loc": null, - "range": [ - 0, - 98 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 98 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-conditional-break.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-conditional-break.js.snap deleted file mode 100644 index fce0ca3612a5c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-conditional-break.js.snap +++ /dev/null @@ -1,313 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-of-conditional-break.js ---- -Input: -function Component() { - const x = []; - for (const item of [1, 2]) { - if (item === 1) { - break; - } - x.push(item); - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 32 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 35, - 37 - ] - }, - "loc": null, - "range": [ - 31, - 37 - ] - } - ], - "loc": null, - "range": [ - 25, - 38 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 56 - ] - }, - "init": null, - "loc": null, - "range": [ - 52, - 56 - ] - } - ], - "loc": null, - "range": [ - 46, - 56 - ] - }, - "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 61, - 62 - ] - }, - { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 64, - 65 - ] - } - ], - "loc": null, - "range": [ - 60, - 66 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 78, - 82 - ] - }, - "operator": "===", - "right": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 87, - 88 - ] - }, - "loc": null, - "range": [ - 78, - 88 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "BreakStatement", - "label": null, - "loc": null, - "range": [ - 98, - 104 - ] - } - ], - "loc": null, - "range": [ - 90, - 110 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 74, - 110 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 115, - 116 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 117, - 121 - ] - }, - "computed": false, - "loc": null, - "range": [ - 115, - 121 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 122, - 126 - ] - } - ], - "loc": null, - "range": [ - 115, - 127 - ] - }, - "directive": null, - "loc": null, - "range": [ - 115, - 128 - ] - } - ], - "loc": null, - "range": [ - 68, - 132 - ] - }, - "loc": null, - "range": [ - 41, - 132 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 142, - 143 - ] - }, - "loc": null, - "range": [ - 135, - 144 - ] - } - ], - "loc": null, - "range": [ - 21, - 146 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 146 - ], - "loc": null, - "range": [ - 0, - 146 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 146 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-continue.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-continue.js.snap deleted file mode 100644 index d507c6f7db5d3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-continue.js.snap +++ /dev/null @@ -1,389 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-of-continue.js ---- -Input: -function Component() { - const x = [0, 1, 2, 3]; - const ret = []; - for (const item of x) { - if (item === 0) { - continue; - } - ret.push(item / 2); - } - return ret; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 32 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 36, - 37 - ] - }, - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 39, - 40 - ] - }, - { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 42, - 43 - ] - }, - { - "type": "NumericLiteral", - "value": 3.0, - "loc": null, - "range": [ - 45, - 46 - ] - } - ], - "loc": null, - "range": [ - 35, - 47 - ] - }, - "loc": null, - "range": [ - 31, - 47 - ] - } - ], - "loc": null, - "range": [ - 25, - 48 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "ret", - "typeAnnotation": null, - "loc": null, - "range": [ - 57, - 60 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 63, - 65 - ] - }, - "loc": null, - "range": [ - 57, - 65 - ] - } - ], - "loc": null, - "range": [ - 51, - 66 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 84 - ] - }, - "init": null, - "loc": null, - "range": [ - 80, - 84 - ] - } - ], - "loc": null, - "range": [ - 74, - 84 - ] - }, - "right": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 88, - 89 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 101, - 105 - ] - }, - "operator": "===", - "right": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 110, - 111 - ] - }, - "loc": null, - "range": [ - 101, - 111 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ContinueStatement", - "label": null, - "loc": null, - "range": [ - 121, - 130 - ] - } - ], - "loc": null, - "range": [ - 113, - 136 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 97, - 136 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "ret", - "typeAnnotation": null, - "loc": null, - "range": [ - 141, - 144 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 145, - 149 - ] - }, - "computed": false, - "loc": null, - "range": [ - 141, - 149 - ] - }, - "arguments": [ - { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 150, - 154 - ] - }, - "operator": "/", - "right": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 157, - 158 - ] - }, - "loc": null, - "range": [ - 150, - 158 - ] - } - ], - "loc": null, - "range": [ - 141, - 159 - ] - }, - "directive": null, - "loc": null, - "range": [ - 141, - 160 - ] - } - ], - "loc": null, - "range": [ - 91, - 164 - ] - }, - "loc": null, - "range": [ - 69, - 164 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "ret", - "typeAnnotation": null, - "loc": null, - "range": [ - 174, - 177 - ] - }, - "loc": null, - "range": [ - 167, - 178 - ] - } - ], - "loc": null, - "range": [ - 21, - 180 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 180 - ], - "loc": null, - "range": [ - 0, - 180 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 180 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-destructure.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-destructure.js.snap deleted file mode 100644 index d314b9e299834..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-destructure.js.snap +++ /dev/null @@ -1,449 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-of-destructure.js ---- -Input: -function Component() { - let x = []; - let items = [{ v: 0 }, { v: 1 }, { v: 2 }]; - for (const { v } of items) { - x.push(v * 2); - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 29, - 30 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 33, - 35 - ] - }, - "loc": null, - "range": [ - 29, - 35 - ] - } - ], - "loc": null, - "range": [ - 25, - 36 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "items", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 48 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 54, - 55 - ] - }, - "value": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 57, - 58 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 54, - 58 - ] - } - ], - "loc": null, - "range": [ - 52, - 60 - ] - }, - { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 64, - 65 - ] - }, - "value": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 67, - 68 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 64, - 68 - ] - } - ], - "loc": null, - "range": [ - 62, - 70 - ] - }, - { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 74, - 75 - ] - }, - "value": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 77, - 78 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 74, - 78 - ] - } - ], - "loc": null, - "range": [ - 72, - 80 - ] - } - ], - "loc": null, - "range": [ - 51, - 81 - ] - }, - "loc": null, - "range": [ - 43, - 81 - ] - } - ], - "loc": null, - "range": [ - 39, - 82 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ObjectPattern", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 98, - 99 - ] - }, - "value": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 98, - 99 - ] - }, - "kind": "init", - "computed": false, - "shorthand": true, - "method": false, - "loc": null, - "range": [ - 98, - 99 - ] - } - ], - "loc": null, - "range": [ - 96, - 101 - ] - }, - "init": null, - "loc": null, - "range": [ - 96, - 101 - ] - } - ], - "loc": null, - "range": [ - 90, - 101 - ] - }, - "right": { - "type": "Identifier", - "name": "items", - "typeAnnotation": null, - "loc": null, - "range": [ - 105, - 110 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 118, - 119 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 120, - 124 - ] - }, - "computed": false, - "loc": null, - "range": [ - 118, - 124 - ] - }, - "arguments": [ - { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "v", - "typeAnnotation": null, - "loc": null, - "range": [ - 125, - 126 - ] - }, - "operator": "*", - "right": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 129, - 130 - ] - }, - "loc": null, - "range": [ - 125, - 130 - ] - } - ], - "loc": null, - "range": [ - 118, - 131 - ] - }, - "directive": null, - "loc": null, - "range": [ - 118, - 132 - ] - } - ], - "loc": null, - "range": [ - 112, - 136 - ] - }, - "loc": null, - "range": [ - 85, - 136 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 146, - 147 - ] - }, - "loc": null, - "range": [ - 139, - 148 - ] - } - ], - "loc": null, - "range": [ - 21, - 150 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 150 - ], - "loc": null, - "range": [ - 0, - 150 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 150 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-mutate.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-mutate.js.snap deleted file mode 100644 index e97e7b519532c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-mutate.js.snap +++ /dev/null @@ -1,434 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-of-mutate.js ---- -Input: -function Component(props) { - const collection = [makeObject()]; - const results = []; - for (const item of collection) { - results.push(
{mutate(item)}
); - } - return
{results}
; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "collection", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 46 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "makeObject", - "typeAnnotation": null, - "loc": null, - "range": [ - 50, - 60 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 50, - 62 - ] - } - ], - "loc": null, - "range": [ - 49, - 63 - ] - }, - "loc": null, - "range": [ - 36, - 63 - ] - } - ], - "loc": null, - "range": [ - 30, - 64 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "results", - "typeAnnotation": null, - "loc": null, - "range": [ - 73, - 80 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 83, - 85 - ] - }, - "loc": null, - "range": [ - 73, - 85 - ] - } - ], - "loc": null, - "range": [ - 67, - 86 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 100, - 104 - ] - }, - "init": null, - "loc": null, - "range": [ - 100, - 104 - ] - } - ], - "loc": null, - "range": [ - 94, - 104 - ] - }, - "right": { - "type": "Identifier", - "name": "collection", - "typeAnnotation": null, - "loc": null, - "range": [ - 108, - 118 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "results", - "typeAnnotation": null, - "loc": null, - "range": [ - 126, - 133 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 134, - 138 - ] - }, - "computed": false, - "loc": null, - "range": [ - 126, - 138 - ] - }, - "arguments": [ - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 140, - 143 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 139, - 144 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 145, - 151 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 152, - 156 - ] - } - ], - "loc": null, - "range": [ - 145, - 157 - ] - }, - "loc": null, - "range": [ - 144, - 158 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 160, - 163 - ] - }, - "loc": null, - "range": [ - 158, - 164 - ] - }, - "loc": null, - "range": [ - 139, - 164 - ] - } - ], - "loc": null, - "range": [ - 126, - 165 - ] - }, - "directive": null, - "loc": null, - "range": [ - 126, - 166 - ] - } - ], - "loc": null, - "range": [ - 120, - 170 - ] - }, - "loc": null, - "range": [ - 89, - 170 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 181, - 184 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 180, - 185 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "results", - "typeAnnotation": null, - "loc": null, - "range": [ - 186, - 193 - ] - }, - "loc": null, - "range": [ - 185, - 194 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 196, - 199 - ] - }, - "loc": null, - "range": [ - 194, - 200 - ] - }, - "loc": null, - "range": [ - 180, - 200 - ] - }, - "loc": null, - "range": [ - 173, - 201 - ] - } - ], - "loc": null, - "range": [ - 26, - 203 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 203 - ], - "loc": null, - "range": [ - 0, - 203 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 203 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-simple.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-simple.js.snap deleted file mode 100644 index 50af44c422fa1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-of-simple.js.snap +++ /dev/null @@ -1,321 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-of-simple.js ---- -Input: -function Component() { - let x = []; - let items = [0, 1, 2]; - for (const ii of items) { - x.push(ii * 2); - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 29, - 30 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 33, - 35 - ] - }, - "loc": null, - "range": [ - 29, - 35 - ] - } - ], - "loc": null, - "range": [ - 25, - 36 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "items", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 48 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 52, - 53 - ] - }, - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 55, - 56 - ] - }, - { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 58, - 59 - ] - } - ], - "loc": null, - "range": [ - 51, - 60 - ] - }, - "loc": null, - "range": [ - 43, - 60 - ] - } - ], - "loc": null, - "range": [ - 39, - 61 - ] - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "ii", - "typeAnnotation": null, - "loc": null, - "range": [ - 75, - 77 - ] - }, - "init": null, - "loc": null, - "range": [ - 75, - 77 - ] - } - ], - "loc": null, - "range": [ - 69, - 77 - ] - }, - "right": { - "type": "Identifier", - "name": "items", - "typeAnnotation": null, - "loc": null, - "range": [ - 81, - 86 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 94, - 95 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 96, - 100 - ] - }, - "computed": false, - "loc": null, - "range": [ - 94, - 100 - ] - }, - "arguments": [ - { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "ii", - "typeAnnotation": null, - "loc": null, - "range": [ - 101, - 103 - ] - }, - "operator": "*", - "right": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 106, - 107 - ] - }, - "loc": null, - "range": [ - 101, - 107 - ] - } - ], - "loc": null, - "range": [ - 94, - 108 - ] - }, - "directive": null, - "loc": null, - "range": [ - 94, - 109 - ] - } - ], - "loc": null, - "range": [ - 88, - 113 - ] - }, - "loc": null, - "range": [ - 64, - 113 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 123, - 124 - ] - }, - "loc": null, - "range": [ - 116, - 125 - ] - } - ], - "loc": null, - "range": [ - 21, - 127 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 127 - ], - "loc": null, - "range": [ - 0, - 127 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 127 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-return.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-return.js.snap deleted file mode 100644 index 483bb236688ed..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@for-return.js.snap +++ /dev/null @@ -1,205 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/for-return.js ---- -Input: -function Component(props) { - for (let i = 0; i < props.count; i++) { - return; - } -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ForStatement", - "init": { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 39, - 40 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 0.0, - "loc": null, - "range": [ - 43, - 44 - ] - }, - "loc": null, - "range": [ - 39, - 44 - ] - } - ], - "loc": null, - "range": [ - 35, - 44 - ] - }, - "test": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 46, - 47 - ] - }, - "operator": "<", - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 50, - 55 - ] - }, - "property": { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 56, - 61 - ] - }, - "computed": false, - "loc": null, - "range": [ - 50, - 61 - ] - }, - "loc": null, - "range": [ - 46, - 61 - ] - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "argument": { - "type": "Identifier", - "name": "i", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 64 - ] - }, - "prefix": false, - "loc": null, - "range": [ - 63, - 66 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": null, - "loc": null, - "range": [ - 74, - 81 - ] - } - ], - "loc": null, - "range": [ - 68, - 85 - ] - }, - "loc": null, - "range": [ - 30, - 85 - ] - } - ], - "loc": null, - "range": [ - 26, - 87 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 87 - ], - "loc": null, - "range": [ - 0, - 87 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 87 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@frozen-after-alias.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@frozen-after-alias.js.snap deleted file mode 100644 index 2cfc16d7ca4cc..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@frozen-after-alias.js.snap +++ /dev/null @@ -1,320 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/frozen-after-alias.js ---- -Input: -function Component() { - const a = []; - const b = a; - useFreeze(a); - foo(b); // should be readonly, value is guaranteed frozen via alias - return b; -} - -function useFreeze() {} -function foo(x) {} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 32 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 35, - 37 - ] - }, - "loc": null, - "range": [ - 31, - 37 - ] - } - ], - "loc": null, - "range": [ - 25, - 38 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 47, - 48 - ] - }, - "init": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 51, - 52 - ] - }, - "loc": null, - "range": [ - 47, - 52 - ] - } - ], - "loc": null, - "range": [ - 41, - 53 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 56, - 65 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 66, - 67 - ] - } - ], - "loc": null, - "range": [ - 56, - 68 - ] - }, - "directive": null, - "loc": null, - "range": [ - 56, - 69 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 72, - 75 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 76, - 77 - ] - } - ], - "loc": null, - "range": [ - 72, - 78 - ] - }, - "directive": null, - "loc": null, - "range": [ - 72, - 79 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 149, - 150 - ] - }, - "loc": null, - "range": [ - 142, - 151 - ] - } - ], - "loc": null, - "range": [ - 21, - 153 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 153 - ], - "loc": null, - "range": [ - 0, - 153 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 164, - 173 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 176, - 178 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 155, - 178 - ], - "loc": null, - "range": [ - 155, - 178 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 188, - 191 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 192, - 193 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 195, - 197 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 179, - 197 - ], - "loc": null, - "range": [ - 179, - 197 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 197 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-reassign.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-reassign.js.snap deleted file mode 100644 index 667b8b4af0a3f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-reassign.js.snap +++ /dev/null @@ -1,212 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/function-declaration-reassign.js ---- -Input: -function component() { - function x(a) { - a.foo(); - } - x = {}; - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 35 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 45, - 46 - ] - }, - "property": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 47, - 50 - ] - }, - "computed": false, - "loc": null, - "range": [ - 45, - 50 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 45, - 52 - ] - }, - "directive": null, - "loc": null, - "range": [ - 45, - 53 - ] - } - ], - "loc": null, - "range": [ - 39, - 57 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 25, - 57 - ], - "loc": null, - "range": [ - 25, - 57 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 60, - 61 - ] - }, - "right": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 64, - 66 - ] - }, - "loc": null, - "range": [ - 60, - 66 - ] - }, - "directive": null, - "loc": null, - "range": [ - 60, - 67 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 77, - 78 - ] - }, - "loc": null, - "range": [ - 70, - 79 - ] - } - ], - "loc": null, - "range": [ - 21, - 81 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 81 - ], - "loc": null, - "range": [ - 0, - 81 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 81 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-redeclare.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-redeclare.js.snap deleted file mode 100644 index 39e3ca87ea374..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-redeclare.js.snap +++ /dev/null @@ -1,210 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/function-declaration-redeclare.js ---- -Input: -function component() { - function x(a) { - a.foo(); - } - function x() {} - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 35 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 45, - 46 - ] - }, - "property": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 47, - 50 - ] - }, - "computed": false, - "loc": null, - "range": [ - 45, - 50 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 45, - 52 - ] - }, - "directive": null, - "loc": null, - "range": [ - 45, - 53 - ] - } - ], - "loc": null, - "range": [ - 39, - 57 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 25, - 57 - ], - "loc": null, - "range": [ - 25, - 57 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 69, - 70 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 73, - 75 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 60, - 75 - ], - "loc": null, - "range": [ - 60, - 75 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 85, - 86 - ] - }, - "loc": null, - "range": [ - 78, - 87 - ] - } - ], - "loc": null, - "range": [ - 21, - 89 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 89 - ], - "loc": null, - "range": [ - 0, - 89 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 89 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-simple.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-simple.js.snap deleted file mode 100644 index 9a60fc5e55fba..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-declaration-simple.js.snap +++ /dev/null @@ -1,297 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/function-declaration-simple.js ---- -Input: -function component(a) { - let t = { a }; - function x(p) { - p.foo(); - } - x(t); - return t; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 30, - 31 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "value": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "loc": null, - "range": [ - 36, - 37 - ] - } - ], - "loc": null, - "range": [ - 34, - 39 - ] - }, - "loc": null, - "range": [ - 30, - 39 - ] - } - ], - "loc": null, - "range": [ - 26, - 40 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 53 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "p", - "typeAnnotation": null, - "loc": null, - "range": [ - 54, - 55 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "p", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 64 - ] - }, - "property": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 65, - 68 - ] - }, - "computed": false, - "loc": null, - "range": [ - 63, - 68 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 63, - 70 - ] - }, - "directive": null, - "loc": null, - "range": [ - 63, - 71 - ] - } - ], - "loc": null, - "range": [ - 57, - 75 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 43, - 75 - ], - "loc": null, - "range": [ - 43, - 75 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 78, - 79 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 81 - ] - } - ], - "loc": null, - "range": [ - 78, - 82 - ] - }, - "directive": null, - "loc": null, - "range": [ - 78, - 83 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 93, - 94 - ] - }, - "loc": null, - "range": [ - 86, - 95 - ] - } - ], - "loc": null, - "range": [ - 22, - 97 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 97 - ], - "loc": null, - "range": [ - 0, - 97 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 97 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-captures-value-later-frozen-jsx.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-captures-value-later-frozen-jsx.js.snap deleted file mode 100644 index c6b01ee09f94e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-captures-value-later-frozen-jsx.js.snap +++ /dev/null @@ -1,501 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/function-expression-captures-value-later-frozen-jsx.js ---- -Input: -function Component(props) { - let x = {}; - // onChange should be inferred as immutable, because the value - // it captures (`x`) is frozen by the time the function is referenced - const onChange = (e) => { - maybeMutate(x, e.target.value); - }; - if (props.cond) { -
{x}
; - } - return ; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 35 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 38, - 40 - ] - }, - "loc": null, - "range": [ - 34, - 40 - ] - } - ], - "loc": null, - "range": [ - 30, - 41 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "onChange", - "typeAnnotation": null, - "loc": null, - "range": [ - 187, - 195 - ] - }, - "init": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [ - { - "type": "Identifier", - "name": "e", - "typeAnnotation": null, - "loc": null, - "range": [ - 199, - 200 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "maybeMutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 211, - 222 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 223, - 224 - ] - }, - { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "e", - "typeAnnotation": null, - "loc": null, - "range": [ - 226, - 227 - ] - }, - "property": { - "type": "Identifier", - "name": "target", - "typeAnnotation": null, - "loc": null, - "range": [ - 228, - 234 - ] - }, - "computed": false, - "loc": null, - "range": [ - 226, - 234 - ] - }, - "property": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 235, - 240 - ] - }, - "computed": false, - "loc": null, - "range": [ - 226, - 240 - ] - } - ], - "loc": null, - "range": [ - 211, - 241 - ] - }, - "directive": null, - "loc": null, - "range": [ - 211, - 242 - ] - } - ], - "loc": null, - "range": [ - 205, - 246 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 198, - 246 - ], - "expression": false, - "loc": null, - "range": [ - 198, - 246 - ] - }, - "loc": null, - "range": [ - 187, - 246 - ] - } - ], - "loc": null, - "range": [ - 181, - 247 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 254, - 259 - ] - }, - "property": { - "type": "Identifier", - "name": "cond", - "typeAnnotation": null, - "loc": null, - "range": [ - 260, - 264 - ] - }, - "computed": false, - "loc": null, - "range": [ - 254, - 264 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 273, - 276 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 272, - 277 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 278, - 279 - ] - }, - "loc": null, - "range": [ - 277, - 280 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 282, - 285 - ] - }, - "loc": null, - "range": [ - 280, - 286 - ] - }, - "loc": null, - "range": [ - 272, - 286 - ] - }, - "directive": null, - "loc": null, - "range": [ - 272, - 287 - ] - } - ], - "loc": null, - "range": [ - 266, - 291 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 250, - 291 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 302, - 305 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "value", - "loc": null, - "range": [ - 306, - 311 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 313, - 314 - ] - }, - "loc": null, - "range": [ - 312, - 315 - ] - }, - "loc": null, - "range": [ - 306, - 315 - ] - }, - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "onChange", - "loc": null, - "range": [ - 316, - 324 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "onChange", - "typeAnnotation": null, - "loc": null, - "range": [ - 326, - 334 - ] - }, - "loc": null, - "range": [ - 325, - 335 - ] - }, - "loc": null, - "range": [ - 316, - 335 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 301, - 338 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 301, - 338 - ] - }, - "loc": null, - "range": [ - 294, - 339 - ] - } - ], - "loc": null, - "range": [ - 26, - 341 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 341 - ], - "loc": null, - "range": [ - 0, - 341 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 341 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-maybe-mutates-hook-return-value.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-maybe-mutates-hook-return-value.js.snap deleted file mode 100644 index 656e3ce563761..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-maybe-mutates-hook-return-value.js.snap +++ /dev/null @@ -1,296 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/function-expression-maybe-mutates-hook-return-value.js ---- -Input: -function Component(props) { - const id = useSelectedEntitytId(); - // this example should infer `id` as mutable, and then infer `onLoad` as mutable, - // and be rejected because onLoad cannot be passed as a frozen value in the JSX. - // however, we likely have to allow this example to work, because hook return - // values are generally immutable in practice and are also widely referenced in - // callbacks. - const onLoad = () => { - log(id); - }; - return ; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "id", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 38 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useSelectedEntitytId", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 61 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 41, - 63 - ] - }, - "loc": null, - "range": [ - 36, - 63 - ] - } - ], - "loc": null, - "range": [ - 30, - 64 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "onLoad", - "typeAnnotation": null, - "loc": null, - "range": [ - 418, - 424 - ] - }, - "init": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "log", - "typeAnnotation": null, - "loc": null, - "range": [ - 439, - 442 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "id", - "typeAnnotation": null, - "loc": null, - "range": [ - 443, - 445 - ] - } - ], - "loc": null, - "range": [ - 439, - 446 - ] - }, - "directive": null, - "loc": null, - "range": [ - 439, - 447 - ] - } - ], - "loc": null, - "range": [ - 433, - 451 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 427, - 451 - ], - "expression": false, - "loc": null, - "range": [ - 427, - 451 - ] - }, - "loc": null, - "range": [ - 418, - 451 - ] - } - ], - "loc": null, - "range": [ - 412, - 452 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 463, - 466 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "onLoad", - "loc": null, - "range": [ - 467, - 473 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "onLoad", - "typeAnnotation": null, - "loc": null, - "range": [ - 475, - 481 - ] - }, - "loc": null, - "range": [ - 474, - 482 - ] - }, - "loc": null, - "range": [ - 467, - 482 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 462, - 485 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 462, - 485 - ] - }, - "loc": null, - "range": [ - 455, - 486 - ] - } - ], - "loc": null, - "range": [ - 26, - 488 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 488 - ], - "loc": null, - "range": [ - 0, - 488 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 488 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-with-store-to-parameter.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-with-store-to-parameter.js.snap deleted file mode 100644 index 46602651fbbdb..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-expression-with-store-to-parameter.js.snap +++ /dev/null @@ -1,393 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/function-expression-with-store-to-parameter.js ---- -Input: -function Component(props) { - const mutate = (object, key, value) => { - object.updated = true; - object[key] = value; - }; - const x = makeObject(props); - mutate(x); - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 42 - ] - }, - "init": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [ - { - "type": "Identifier", - "name": "object", - "typeAnnotation": null, - "loc": null, - "range": [ - 46, - 52 - ] - }, - { - "type": "Identifier", - "name": "key", - "typeAnnotation": null, - "loc": null, - "range": [ - 54, - 57 - ] - }, - { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 59, - 64 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "object", - "typeAnnotation": null, - "loc": null, - "range": [ - 75, - 81 - ] - }, - "property": { - "type": "Identifier", - "name": "updated", - "typeAnnotation": null, - "loc": null, - "range": [ - 82, - 89 - ] - }, - "computed": false, - "loc": null, - "range": [ - 75, - 89 - ] - }, - "right": { - "type": "BooleanLiteral", - "value": true, - "loc": null, - "range": [ - 92, - 96 - ] - }, - "loc": null, - "range": [ - 75, - 96 - ] - }, - "directive": null, - "loc": null, - "range": [ - 75, - 97 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "object", - "typeAnnotation": null, - "loc": null, - "range": [ - 102, - 108 - ] - }, - "property": { - "type": "Identifier", - "name": "key", - "typeAnnotation": null, - "loc": null, - "range": [ - 109, - 112 - ] - }, - "computed": true, - "loc": null, - "range": [ - 102, - 113 - ] - }, - "right": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 116, - 121 - ] - }, - "loc": null, - "range": [ - 102, - 121 - ] - }, - "directive": null, - "loc": null, - "range": [ - 102, - 122 - ] - } - ], - "loc": null, - "range": [ - 69, - 126 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 45, - 126 - ], - "expression": false, - "loc": null, - "range": [ - 45, - 126 - ] - }, - "loc": null, - "range": [ - 36, - 126 - ] - } - ], - "loc": null, - "range": [ - 30, - 127 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 136, - 137 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "makeObject", - "typeAnnotation": null, - "loc": null, - "range": [ - 140, - 150 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 151, - 156 - ] - } - ], - "loc": null, - "range": [ - 140, - 157 - ] - }, - "loc": null, - "range": [ - 136, - 157 - ] - } - ], - "loc": null, - "range": [ - 130, - 158 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 161, - 167 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 168, - 169 - ] - } - ], - "loc": null, - "range": [ - 161, - 170 - ] - }, - "directive": null, - "loc": null, - "range": [ - 161, - 171 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 181, - 182 - ] - }, - "loc": null, - "range": [ - 174, - 183 - ] - } - ], - "loc": null, - "range": [ - 26, - 185 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 185 - ], - "loc": null, - "range": [ - 0, - 185 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 185 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-param-assignment-pattern.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-param-assignment-pattern.js.snap deleted file mode 100644 index bca3d0a3b58ce..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@function-param-assignment-pattern.js.snap +++ /dev/null @@ -1,162 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/function-param-assignment-pattern.js ---- -Input: -function Component(x = "default", y = [{}]) { - return [x, y]; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "AssignmentPattern", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - }, - "right": { - "type": "StringLiteral", - "value": "default", - "loc": null, - "range": [ - 23, - 32 - ] - }, - "loc": null, - "range": [ - 19, - 32 - ] - }, - { - "type": "AssignmentPattern", - "left": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 35 - ] - }, - "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 39, - 41 - ] - } - ], - "loc": null, - "range": [ - 38, - 42 - ] - }, - "loc": null, - "range": [ - 34, - 42 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "ArrayExpression", - "elements": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 56, - 57 - ] - }, - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 59, - 60 - ] - } - ], - "loc": null, - "range": [ - 55, - 61 - ] - }, - "loc": null, - "range": [ - 48, - 62 - ] - } - ], - "loc": null, - "range": [ - 44, - 64 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 64 - ], - "loc": null, - "range": [ - 0, - 64 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 64 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-default-function.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-default-function.js.snap deleted file mode 100644 index 60c1e0b1a15aa..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-default-function.js.snap +++ /dev/null @@ -1,492 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/gating-test-export-default-function.js ---- -Input: -// @gating @compilationMode(annotation) -export default function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -function NoForget(props) { - return {props.noForget}; -} - -function Foo(props) { - "use forget"; - return {props.bar}; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ExportDefaultDeclaration", - "declaration": { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 64, - 67 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 68, - 73 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "StringLiteral", - "value": "use forget", - "loc": null, - "range": [ - 79, - 91 - ] - }, - "directive": null, - "loc": null, - "range": [ - 79, - 92 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 103, - 106 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 102, - 107 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 108, - 113 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 114, - 117 - ] - }, - "computed": false, - "loc": null, - "range": [ - 108, - 117 - ] - }, - "loc": null, - "range": [ - 107, - 118 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 120, - 123 - ] - }, - "loc": null, - "range": [ - 118, - 124 - ] - }, - "loc": null, - "range": [ - 102, - 124 - ] - }, - "loc": null, - "range": [ - 95, - 125 - ] - } - ], - "loc": null, - "range": [ - 75, - 127 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 55, - 127 - ], - "loc": null, - "range": [ - 55, - 127 - ] - }, - "loc": null, - "range": [ - 40, - 127 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "NoForget", - "typeAnnotation": null, - "loc": null, - "range": [ - 138, - 146 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 147, - 152 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 166, - 169 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 165, - 170 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 171, - 176 - ] - }, - "property": { - "type": "Identifier", - "name": "noForget", - "typeAnnotation": null, - "loc": null, - "range": [ - 177, - 185 - ] - }, - "computed": false, - "loc": null, - "range": [ - 171, - 185 - ] - }, - "loc": null, - "range": [ - 170, - 186 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 188, - 191 - ] - }, - "loc": null, - "range": [ - 186, - 192 - ] - }, - "loc": null, - "range": [ - 165, - 192 - ] - }, - "loc": null, - "range": [ - 158, - 193 - ] - } - ], - "loc": null, - "range": [ - 154, - 195 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 129, - 195 - ], - "loc": null, - "range": [ - 129, - 195 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 206, - 209 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 210, - 215 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "StringLiteral", - "value": "use forget", - "loc": null, - "range": [ - 221, - 233 - ] - }, - "directive": null, - "loc": null, - "range": [ - 221, - 234 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 245, - 248 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 244, - 249 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 250, - 255 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 256, - 259 - ] - }, - "computed": false, - "loc": null, - "range": [ - 250, - 259 - ] - }, - "loc": null, - "range": [ - 249, - 260 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 262, - 265 - ] - }, - "loc": null, - "range": [ - 260, - 266 - ] - }, - "loc": null, - "range": [ - 244, - 266 - ] - }, - "loc": null, - "range": [ - 237, - 267 - ] - } - ], - "loc": null, - "range": [ - 217, - 269 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 197, - 269 - ], - "loc": null, - "range": [ - 197, - 269 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 40, - 269 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-function-and-default.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-function-and-default.js.snap deleted file mode 100644 index 14a4dd3e8112c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-function-and-default.js.snap +++ /dev/null @@ -1,502 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/gating-test-export-function-and-default.js ---- -Input: -// @gating @compilationMode(annotation) -export default function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -function NoForget(props) { - return {props.noForget}; -} - -export function Foo(props) { - "use forget"; - return {props.bar}; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ExportDefaultDeclaration", - "declaration": { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 64, - 67 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 68, - 73 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "StringLiteral", - "value": "use forget", - "loc": null, - "range": [ - 79, - 91 - ] - }, - "directive": null, - "loc": null, - "range": [ - 79, - 92 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 103, - 106 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 102, - 107 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 108, - 113 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 114, - 117 - ] - }, - "computed": false, - "loc": null, - "range": [ - 108, - 117 - ] - }, - "loc": null, - "range": [ - 107, - 118 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 120, - 123 - ] - }, - "loc": null, - "range": [ - 118, - 124 - ] - }, - "loc": null, - "range": [ - 102, - 124 - ] - }, - "loc": null, - "range": [ - 95, - 125 - ] - } - ], - "loc": null, - "range": [ - 75, - 127 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 55, - 127 - ], - "loc": null, - "range": [ - 55, - 127 - ] - }, - "loc": null, - "range": [ - 40, - 127 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "NoForget", - "typeAnnotation": null, - "loc": null, - "range": [ - 138, - 146 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 147, - 152 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 166, - 169 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 165, - 170 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 171, - 176 - ] - }, - "property": { - "type": "Identifier", - "name": "noForget", - "typeAnnotation": null, - "loc": null, - "range": [ - 177, - 185 - ] - }, - "computed": false, - "loc": null, - "range": [ - 171, - 185 - ] - }, - "loc": null, - "range": [ - 170, - 186 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 188, - 191 - ] - }, - "loc": null, - "range": [ - 186, - 192 - ] - }, - "loc": null, - "range": [ - 165, - 192 - ] - }, - "loc": null, - "range": [ - 158, - 193 - ] - } - ], - "loc": null, - "range": [ - 154, - 195 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 129, - 195 - ], - "loc": null, - "range": [ - 129, - 195 - ] - }, - { - "type": "ExportNamedDeclaration", - "declaration": { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 213, - 216 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 217, - 222 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "StringLiteral", - "value": "use forget", - "loc": null, - "range": [ - 228, - 240 - ] - }, - "directive": null, - "loc": null, - "range": [ - 228, - 241 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 252, - 255 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 251, - 256 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 257, - 262 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 263, - 266 - ] - }, - "computed": false, - "loc": null, - "range": [ - 257, - 266 - ] - }, - "loc": null, - "range": [ - 256, - 267 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 269, - 272 - ] - }, - "loc": null, - "range": [ - 267, - 273 - ] - }, - "loc": null, - "range": [ - 251, - 273 - ] - }, - "loc": null, - "range": [ - 244, - 274 - ] - } - ], - "loc": null, - "range": [ - 224, - 276 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 204, - 276 - ], - "loc": null, - "range": [ - 204, - 276 - ] - }, - "specifiers": [], - "source": null, - "loc": null, - "range": [ - 197, - 276 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 40, - 276 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-function.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-function.js.snap deleted file mode 100644 index 24d0f5df7e09d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test-export-function.js.snap +++ /dev/null @@ -1,514 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/gating-test-export-function.js ---- -Input: -// @gating @compilationMode(annotation) -export function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -export function NoForget(props) { - return {props.noForget}; -} - -export function Foo(props) { - "use forget"; - return {props.bar}; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ExportNamedDeclaration", - "declaration": { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 56, - 59 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 60, - 65 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "StringLiteral", - "value": "use forget", - "loc": null, - "range": [ - 71, - 83 - ] - }, - "directive": null, - "loc": null, - "range": [ - 71, - 84 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 95, - 98 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 94, - 99 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 100, - 105 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 106, - 109 - ] - }, - "computed": false, - "loc": null, - "range": [ - 100, - 109 - ] - }, - "loc": null, - "range": [ - 99, - 110 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 112, - 115 - ] - }, - "loc": null, - "range": [ - 110, - 116 - ] - }, - "loc": null, - "range": [ - 94, - 116 - ] - }, - "loc": null, - "range": [ - 87, - 117 - ] - } - ], - "loc": null, - "range": [ - 67, - 119 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 47, - 119 - ], - "loc": null, - "range": [ - 47, - 119 - ] - }, - "specifiers": [], - "source": null, - "loc": null, - "range": [ - 40, - 119 - ] - }, - { - "type": "ExportNamedDeclaration", - "declaration": { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "NoForget", - "typeAnnotation": null, - "loc": null, - "range": [ - 137, - 145 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 146, - 151 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 165, - 168 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 164, - 169 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 170, - 175 - ] - }, - "property": { - "type": "Identifier", - "name": "noForget", - "typeAnnotation": null, - "loc": null, - "range": [ - 176, - 184 - ] - }, - "computed": false, - "loc": null, - "range": [ - 170, - 184 - ] - }, - "loc": null, - "range": [ - 169, - 185 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 187, - 190 - ] - }, - "loc": null, - "range": [ - 185, - 191 - ] - }, - "loc": null, - "range": [ - 164, - 191 - ] - }, - "loc": null, - "range": [ - 157, - 192 - ] - } - ], - "loc": null, - "range": [ - 153, - 194 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 128, - 194 - ], - "loc": null, - "range": [ - 128, - 194 - ] - }, - "specifiers": [], - "source": null, - "loc": null, - "range": [ - 121, - 194 - ] - }, - { - "type": "ExportNamedDeclaration", - "declaration": { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 212, - 215 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 216, - 221 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "StringLiteral", - "value": "use forget", - "loc": null, - "range": [ - 227, - 239 - ] - }, - "directive": null, - "loc": null, - "range": [ - 227, - 240 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 251, - 254 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 250, - 255 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 256, - 261 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 262, - 265 - ] - }, - "computed": false, - "loc": null, - "range": [ - 256, - 265 - ] - }, - "loc": null, - "range": [ - 255, - 266 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 268, - 271 - ] - }, - "loc": null, - "range": [ - 266, - 272 - ] - }, - "loc": null, - "range": [ - 250, - 272 - ] - }, - "loc": null, - "range": [ - 243, - 273 - ] - } - ], - "loc": null, - "range": [ - 223, - 275 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 203, - 275 - ], - "loc": null, - "range": [ - 203, - 275 - ] - }, - "specifiers": [], - "source": null, - "loc": null, - "range": [ - 196, - 275 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 40, - 275 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test.js.snap deleted file mode 100644 index 3c83c15474dc2..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@gating-test.js.snap +++ /dev/null @@ -1,484 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/gating-test.js ---- -Input: -// @gating @compilationMode(annotation) -function Bar(props) { - "use forget"; - return
{props.bar}
; -} - -function NoForget(props) { - return {props.noForget}; -} - -function Foo(props) { - "use forget"; - return {props.bar}; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 49, - 52 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 53, - 58 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "StringLiteral", - "value": "use forget", - "loc": null, - "range": [ - 64, - 76 - ] - }, - "directive": null, - "loc": null, - "range": [ - 64, - 77 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 88, - 91 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 87, - 92 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 93, - 98 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 99, - 102 - ] - }, - "computed": false, - "loc": null, - "range": [ - 93, - 102 - ] - }, - "loc": null, - "range": [ - 92, - 103 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 105, - 108 - ] - }, - "loc": null, - "range": [ - 103, - 109 - ] - }, - "loc": null, - "range": [ - 87, - 109 - ] - }, - "loc": null, - "range": [ - 80, - 110 - ] - } - ], - "loc": null, - "range": [ - 60, - 112 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 40, - 112 - ], - "loc": null, - "range": [ - 40, - 112 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "NoForget", - "typeAnnotation": null, - "loc": null, - "range": [ - 123, - 131 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 132, - 137 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 151, - 154 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 150, - 155 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 156, - 161 - ] - }, - "property": { - "type": "Identifier", - "name": "noForget", - "typeAnnotation": null, - "loc": null, - "range": [ - 162, - 170 - ] - }, - "computed": false, - "loc": null, - "range": [ - 156, - 170 - ] - }, - "loc": null, - "range": [ - 155, - 171 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 173, - 176 - ] - }, - "loc": null, - "range": [ - 171, - 177 - ] - }, - "loc": null, - "range": [ - 150, - 177 - ] - }, - "loc": null, - "range": [ - 143, - 178 - ] - } - ], - "loc": null, - "range": [ - 139, - 180 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 114, - 180 - ], - "loc": null, - "range": [ - 114, - 180 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 191, - 194 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 195, - 200 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "StringLiteral", - "value": "use forget", - "loc": null, - "range": [ - 206, - 218 - ] - }, - "directive": null, - "loc": null, - "range": [ - 206, - 219 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 230, - 233 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 229, - 234 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 235, - 240 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 241, - 244 - ] - }, - "computed": false, - "loc": null, - "range": [ - 235, - 244 - ] - }, - "loc": null, - "range": [ - 234, - 245 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 247, - 250 - ] - }, - "loc": null, - "range": [ - 245, - 251 - ] - }, - "loc": null, - "range": [ - 229, - 251 - ] - }, - "loc": null, - "range": [ - 222, - 252 - ] - } - ], - "loc": null, - "range": [ - 202, - 254 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 182, - 254 - ], - "loc": null, - "range": [ - 182, - 254 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 40, - 254 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@global-jsx-tag-lowered-between-mutations.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@global-jsx-tag-lowered-between-mutations.js.snap deleted file mode 100644 index 55387038588a1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@global-jsx-tag-lowered-between-mutations.js.snap +++ /dev/null @@ -1,222 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/global-jsx-tag-lowered-between-mutations.js ---- -Input: -function Component(props) { - const maybeMutable = new MaybeMutable(); - // NOTE: this will produce invalid output. - // The HIR is roughly: - // ⌵ mutable range of `maybeMutable` - // StoreLocal maybeMutable = ... ⌝ - // t0 = LoadGlobal View ⎮ <-- View is lowered inside this mutable range - // and thus gets becomes an output of this scope, - // gets promoted to temporary - // t1 = LoadGlobal maybeMutate ⎮ - // t2 = LoadLocal maybeMutable ⎮ - // t3 = Call t1(t2) ⌟ - // t4 = Jsx tag=t0 props=[] children=[t3] <-- `t0` is an invalid tag - return {maybeMutate(maybeMutable)}; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "maybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 48 - ] - }, - "init": { - "type": "NewExpression", - "callee": { - "type": "Identifier", - "name": "MaybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 55, - 67 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 51, - 69 - ] - }, - "loc": null, - "range": [ - 36, - 69 - ] - } - ], - "loc": null, - "range": [ - 30, - 70 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 722, - 726 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 721, - 727 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "maybeMutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 728, - 739 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "maybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 740, - 752 - ] - } - ], - "loc": null, - "range": [ - 728, - 753 - ] - }, - "loc": null, - "range": [ - 727, - 754 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 756, - 760 - ] - }, - "loc": null, - "range": [ - 754, - 761 - ] - }, - "loc": null, - "range": [ - 721, - 761 - ] - }, - "loc": null, - "range": [ - 714, - 762 - ] - } - ], - "loc": null, - "range": [ - 26, - 764 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 764 - ], - "loc": null, - "range": [ - 0, - 764 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 764 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-Boolean.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-Boolean.js.snap deleted file mode 100644 index 0e9530bb6186b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-Boolean.js.snap +++ /dev/null @@ -1,207 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/globals-Boolean.js ---- -Input: -function Component(props) { - const x = {}; - const y = Boolean(x); - return [x, y]; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 40, - 42 - ] - }, - "loc": null, - "range": [ - 36, - 42 - ] - } - ], - "loc": null, - "range": [ - 30, - 43 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 53 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "Boolean", - "typeAnnotation": null, - "loc": null, - "range": [ - 56, - 63 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 64, - 65 - ] - } - ], - "loc": null, - "range": [ - 56, - 66 - ] - }, - "loc": null, - "range": [ - 52, - 66 - ] - } - ], - "loc": null, - "range": [ - 46, - 67 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "ArrayExpression", - "elements": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 78, - 79 - ] - }, - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 81, - 82 - ] - } - ], - "loc": null, - "range": [ - 77, - 83 - ] - }, - "loc": null, - "range": [ - 70, - 84 - ] - } - ], - "loc": null, - "range": [ - 26, - 86 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 86 - ], - "loc": null, - "range": [ - 0, - 86 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 86 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-Number.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-Number.js.snap deleted file mode 100644 index 050eca3313a5e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-Number.js.snap +++ /dev/null @@ -1,207 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/globals-Number.js ---- -Input: -function Component(props) { - const x = {}; - const y = Number(x); - return [x, y]; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 40, - 42 - ] - }, - "loc": null, - "range": [ - 36, - 42 - ] - } - ], - "loc": null, - "range": [ - 30, - 43 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 53 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "Number", - "typeAnnotation": null, - "loc": null, - "range": [ - 56, - 62 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 64 - ] - } - ], - "loc": null, - "range": [ - 56, - 65 - ] - }, - "loc": null, - "range": [ - 52, - 65 - ] - } - ], - "loc": null, - "range": [ - 46, - 66 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "ArrayExpression", - "elements": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 77, - 78 - ] - }, - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 81 - ] - } - ], - "loc": null, - "range": [ - 76, - 82 - ] - }, - "loc": null, - "range": [ - 69, - 83 - ] - } - ], - "loc": null, - "range": [ - 26, - 85 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 85 - ], - "loc": null, - "range": [ - 0, - 85 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 85 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-String.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-String.js.snap deleted file mode 100644 index 3d65520fc8cb1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@globals-String.js.snap +++ /dev/null @@ -1,207 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/globals-String.js ---- -Input: -function Component(props) { - const x = {}; - const y = String(x); - return [x, y]; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 40, - 42 - ] - }, - "loc": null, - "range": [ - 36, - 42 - ] - } - ], - "loc": null, - "range": [ - 30, - 43 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 53 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "String", - "typeAnnotation": null, - "loc": null, - "range": [ - 56, - 62 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 64 - ] - } - ], - "loc": null, - "range": [ - 56, - 65 - ] - }, - "loc": null, - "range": [ - 52, - 65 - ] - } - ], - "loc": null, - "range": [ - 46, - 66 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "ArrayExpression", - "elements": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 77, - 78 - ] - }, - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 81 - ] - } - ], - "loc": null, - "range": [ - 76, - 82 - ] - }, - "loc": null, - "range": [ - 69, - 83 - ] - } - ], - "loc": null, - "range": [ - 26, - 85 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 85 - ], - "loc": null, - "range": [ - 0, - 85 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 85 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-expr.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-expr.js.snap deleted file mode 100644 index 79cba2c84b3b1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-expr.js.snap +++ /dev/null @@ -1,149 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/holey-array-expr.js ---- -Input: -function t(props) { - let x = [, foo, props]; - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 11, - 16 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 26, - 27 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [ - null, - { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 33, - 36 - ] - }, - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 38, - 43 - ] - } - ], - "loc": null, - "range": [ - 30, - 44 - ] - }, - "loc": null, - "range": [ - 26, - 44 - ] - } - ], - "loc": null, - "range": [ - 22, - 45 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 55, - 56 - ] - }, - "loc": null, - "range": [ - 48, - 57 - ] - } - ], - "loc": null, - "range": [ - 18, - 59 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 59 - ], - "loc": null, - "range": [ - 0, - 59 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 59 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-pattern-dce-2.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-pattern-dce-2.js.snap deleted file mode 100644 index f306b2cb2427e..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-pattern-dce-2.js.snap +++ /dev/null @@ -1,149 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce-2.js ---- -Input: -function t(props) { - let [foo, bar, ,] = props; - return foo; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 11, - 16 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ArrayPattern", - "elements": [ - { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 27, - 30 - ] - }, - { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 32, - 35 - ] - }, - null - ], - "loc": null, - "range": [ - 26, - 39 - ] - }, - "init": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 42, - 47 - ] - }, - "loc": null, - "range": [ - 26, - 47 - ] - } - ], - "loc": null, - "range": [ - 22, - 48 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 58, - 61 - ] - }, - "loc": null, - "range": [ - 51, - 62 - ] - } - ], - "loc": null, - "range": [ - 18, - 64 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 64 - ], - "loc": null, - "range": [ - 0, - 64 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 64 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-pattern-dce.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-pattern-dce.js.snap deleted file mode 100644 index 488c00ee84309..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array-pattern-dce.js.snap +++ /dev/null @@ -1,149 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/holey-array-pattern-dce.js ---- -Input: -function t(props) { - let [, foo, bar] = props; - return foo; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 11, - 16 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ArrayPattern", - "elements": [ - null, - { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 29, - 32 - ] - }, - { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 37 - ] - } - ], - "loc": null, - "range": [ - 26, - 38 - ] - }, - "init": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 46 - ] - }, - "loc": null, - "range": [ - 26, - 46 - ] - } - ], - "loc": null, - "range": [ - 22, - 47 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 57, - 60 - ] - }, - "loc": null, - "range": [ - 50, - 61 - ] - } - ], - "loc": null, - "range": [ - 18, - 63 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 63 - ], - "loc": null, - "range": [ - 0, - 63 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 63 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array.js.snap deleted file mode 100644 index da5c4d9e9e796..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@holey-array.js.snap +++ /dev/null @@ -1,206 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/holey-array.js ---- -Input: -function t(props) { - let [, setstate] = useState(); - setstate(1); - return props.foo; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "t", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 11, - 16 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ArrayPattern", - "elements": [ - null, - { - "type": "Identifier", - "name": "setstate", - "typeAnnotation": null, - "loc": null, - "range": [ - 29, - 37 - ] - } - ], - "loc": null, - "range": [ - 26, - 38 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useState", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 49 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 41, - 51 - ] - }, - "loc": null, - "range": [ - 26, - 51 - ] - } - ], - "loc": null, - "range": [ - 22, - 52 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "setstate", - "typeAnnotation": null, - "loc": null, - "range": [ - 55, - 63 - ] - }, - "arguments": [ - { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 64, - 65 - ] - } - ], - "loc": null, - "range": [ - 55, - 66 - ] - }, - "directive": null, - "loc": null, - "range": [ - 55, - 67 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 77, - 82 - ] - }, - "property": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 83, - 86 - ] - }, - "computed": false, - "loc": null, - "range": [ - 77, - 86 - ] - }, - "loc": null, - "range": [ - 70, - 87 - ] - } - ], - "loc": null, - "range": [ - 18, - 89 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 89 - ], - "loc": null, - "range": [ - 0, - 89 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 89 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hook-call.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hook-call.js.snap deleted file mode 100644 index 5d5d7a086bee4..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hook-call.js.snap +++ /dev/null @@ -1,417 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/hook-call.js ---- -Input: -function useFreeze() {} -function foo() {} - -function Component(props) { - const x = []; - const y = useFreeze(x); - foo(y, x); - return ( - - {x} - {y} - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 21, - 23 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 23 - ], - "loc": null, - "range": [ - 0, - 23 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 33, - 36 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 39, - 41 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 24, - 41 - ], - "loc": null, - "range": [ - 24, - 41 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 61 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 62, - 67 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 79, - 80 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 83, - 85 - ] - }, - "loc": null, - "range": [ - 79, - 85 - ] - } - ], - "loc": null, - "range": [ - 73, - 86 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 95, - 96 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 99, - 108 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 109, - 110 - ] - } - ], - "loc": null, - "range": [ - 99, - 111 - ] - }, - "loc": null, - "range": [ - 95, - 111 - ] - } - ], - "loc": null, - "range": [ - 89, - 112 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 115, - 118 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 119, - 120 - ] - }, - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 122, - 123 - ] - } - ], - "loc": null, - "range": [ - 115, - 124 - ] - }, - "directive": null, - "loc": null, - "range": [ - 115, - 125 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Component", - "loc": null, - "range": [ - 142, - 151 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 141, - 152 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 152, - 159 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 160, - 161 - ] - }, - "loc": null, - "range": [ - 159, - 162 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 162, - 169 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 170, - 171 - ] - }, - "loc": null, - "range": [ - 169, - 172 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 172, - 177 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Component", - "loc": null, - "range": [ - 179, - 188 - ] - }, - "loc": null, - "range": [ - 177, - 189 - ] - }, - "loc": null, - "range": [ - 141, - 189 - ] - }, - "loc": null, - "range": [ - 128, - 194 - ] - } - ], - "loc": null, - "range": [ - 69, - 196 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 43, - 196 - ], - "loc": null, - "range": [ - 43, - 196 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 196 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hook-inside-logical-expression.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hook-inside-logical-expression.js.snap deleted file mode 100644 index 8e47df4c425ea..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hook-inside-logical-expression.js.snap +++ /dev/null @@ -1,246 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/hook-inside-logical-expression.js ---- -Input: -function Component(props) { - const user = useFragment(graphql`...`, props.user) ?? {}; - return user.name; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "user", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 40 - ] - }, - "init": { - "type": "LogicalExpression", - "operator": "??", - "left": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFragment", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 54 - ] - }, - "arguments": [ - { - "type": "TaggedTemplateExpression", - "tag": { - "type": "Identifier", - "name": "graphql", - "typeAnnotation": null, - "loc": null, - "range": [ - 55, - 62 - ] - }, - "quasi": { - "type": "TemplateLiteral", - "quasis": [ - { - "type": "TemplateElement", - "tail": true, - "value": { - "cooked": "...", - "raw": "..." - }, - "loc": null, - "range": [ - 62, - 67 - ] - } - ], - "expressions": [], - "loc": null, - "range": [ - 62, - 67 - ] - }, - "loc": null, - "range": [ - 55, - 67 - ] - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 69, - 74 - ] - }, - "property": { - "type": "Identifier", - "name": "user", - "typeAnnotation": null, - "loc": null, - "range": [ - 75, - 79 - ] - }, - "computed": false, - "loc": null, - "range": [ - 69, - 79 - ] - } - ], - "loc": null, - "range": [ - 43, - 80 - ] - }, - "right": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 84, - 86 - ] - }, - "loc": null, - "range": [ - 43, - 86 - ] - }, - "loc": null, - "range": [ - 36, - 86 - ] - } - ], - "loc": null, - "range": [ - 30, - 87 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "user", - "typeAnnotation": null, - "loc": null, - "range": [ - 97, - 101 - ] - }, - "property": { - "type": "Identifier", - "name": "name", - "typeAnnotation": null, - "loc": null, - "range": [ - 102, - 106 - ] - }, - "computed": false, - "loc": null, - "range": [ - 97, - 106 - ] - }, - "loc": null, - "range": [ - 90, - 107 - ] - } - ], - "loc": null, - "range": [ - 26, - 109 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 109 - ], - "loc": null, - "range": [ - 0, - 109 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 109 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hooks-freeze-arguments.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hooks-freeze-arguments.js.snap deleted file mode 100644 index 86c6d565d0fc8..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hooks-freeze-arguments.js.snap +++ /dev/null @@ -1,331 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/hooks-freeze-arguments.js ---- -Input: -function Component() { - const a = []; - useFreeze(a); // should freeze - useFreeze(a); // should be readonly - call(a); // should be readonly - return a; -} - -function useFreeze(x) {} -function call(x) {} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 32 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 35, - 37 - ] - }, - "loc": null, - "range": [ - 31, - 37 - ] - } - ], - "loc": null, - "range": [ - 25, - 38 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 50 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 51, - 52 - ] - } - ], - "loc": null, - "range": [ - 41, - 53 - ] - }, - "directive": null, - "loc": null, - "range": [ - 41, - 54 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 74, - 83 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 84, - 85 - ] - } - ], - "loc": null, - "range": [ - 74, - 86 - ] - }, - "directive": null, - "loc": null, - "range": [ - 74, - 87 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "call", - "typeAnnotation": null, - "loc": null, - "range": [ - 112, - 116 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 117, - 118 - ] - } - ], - "loc": null, - "range": [ - 112, - 119 - ] - }, - "directive": null, - "loc": null, - "range": [ - 112, - 120 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 152, - 153 - ] - }, - "loc": null, - "range": [ - 145, - 154 - ] - } - ], - "loc": null, - "range": [ - 21, - 156 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 156 - ], - "loc": null, - "range": [ - 0, - 156 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 167, - 176 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 177, - 178 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 180, - 182 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 158, - 182 - ], - "loc": null, - "range": [ - 158, - 182 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "call", - "typeAnnotation": null, - "loc": null, - "range": [ - 192, - 196 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 197, - 198 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 200, - 202 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 183, - 202 - ], - "loc": null, - "range": [ - 183, - 202 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 202 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hooks-freeze-possibly-mutable-arguments.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hooks-freeze-possibly-mutable-arguments.js.snap deleted file mode 100644 index 317577aff52a4..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@hooks-freeze-possibly-mutable-arguments.js.snap +++ /dev/null @@ -1,570 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/hooks-freeze-possibly-mutable-arguments.js ---- -Input: -function Component(props) { - const cond = props.cond; - const x = props.x; - let a; - if (cond) { - a = x; - } else { - a = []; - } - useFreeze(a); // should freeze, value *may* be mutable - useFreeze(a); // should be readonly - call(a); // should be readonly - return a; -} - -function useFreeze(x) {} -function call(x) {} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "cond", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 40 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 48 - ] - }, - "property": { - "type": "Identifier", - "name": "cond", - "typeAnnotation": null, - "loc": null, - "range": [ - 49, - 53 - ] - }, - "computed": false, - "loc": null, - "range": [ - 43, - 53 - ] - }, - "loc": null, - "range": [ - 36, - 53 - ] - } - ], - "loc": null, - "range": [ - 30, - 54 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 64 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 67, - 72 - ] - }, - "property": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 73, - 74 - ] - }, - "computed": false, - "loc": null, - "range": [ - 67, - 74 - ] - }, - "loc": null, - "range": [ - 63, - 74 - ] - } - ], - "loc": null, - "range": [ - 57, - 75 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 82, - 83 - ] - }, - "init": null, - "loc": null, - "range": [ - 82, - 83 - ] - } - ], - "loc": null, - "range": [ - 78, - 84 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "cond", - "typeAnnotation": null, - "loc": null, - "range": [ - 91, - 95 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 103, - 104 - ] - }, - "right": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 107, - 108 - ] - }, - "loc": null, - "range": [ - 103, - 108 - ] - }, - "directive": null, - "loc": null, - "range": [ - 103, - 109 - ] - } - ], - "loc": null, - "range": [ - 97, - 113 - ] - }, - "alternate": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 125, - 126 - ] - }, - "right": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 129, - 131 - ] - }, - "loc": null, - "range": [ - 125, - 131 - ] - }, - "directive": null, - "loc": null, - "range": [ - 125, - 132 - ] - } - ], - "loc": null, - "range": [ - 119, - 136 - ] - }, - "loc": null, - "range": [ - 87, - 136 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 139, - 148 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 149, - 150 - ] - } - ], - "loc": null, - "range": [ - 139, - 151 - ] - }, - "directive": null, - "loc": null, - "range": [ - 139, - 152 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 196, - 205 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 206, - 207 - ] - } - ], - "loc": null, - "range": [ - 196, - 208 - ] - }, - "directive": null, - "loc": null, - "range": [ - 196, - 209 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "call", - "typeAnnotation": null, - "loc": null, - "range": [ - 234, - 238 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 239, - 240 - ] - } - ], - "loc": null, - "range": [ - 234, - 241 - ] - }, - "directive": null, - "loc": null, - "range": [ - 234, - 242 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 274, - 275 - ] - }, - "loc": null, - "range": [ - 267, - 276 - ] - } - ], - "loc": null, - "range": [ - 26, - 278 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 278 - ], - "loc": null, - "range": [ - 0, - 278 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 289, - 298 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 299, - 300 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 302, - 304 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 280, - 304 - ], - "loc": null, - "range": [ - 280, - 304 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "call", - "typeAnnotation": null, - "loc": null, - "range": [ - 314, - 318 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 319, - 320 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 322, - 324 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 305, - 324 - ], - "loc": null, - "range": [ - 305, - 324 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 324 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@immutable-hooks.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@immutable-hooks.js.snap deleted file mode 100644 index c18369a053058..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@immutable-hooks.js.snap +++ /dev/null @@ -1,260 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/immutable-hooks.js ---- -Input: -// @enableAssumeHooksFollowRulesOfReact true -function Component(props) { - const x = {}; - // In enableAssumeHooksFollowRulesOfReact mode hooks freeze their inputs and return frozen values - const y = useFoo(x); - // Thus both x and y are frozen here, and x can be independently memoized - bar(x, y); - return [x, y]; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 54, - 63 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 64, - 69 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 81, - 82 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 85, - 87 - ] - }, - "loc": null, - "range": [ - 81, - 87 - ] - } - ], - "loc": null, - "range": [ - 75, - 88 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 197, - 198 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFoo", - "typeAnnotation": null, - "loc": null, - "range": [ - 201, - 207 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 208, - 209 - ] - } - ], - "loc": null, - "range": [ - 201, - 210 - ] - }, - "loc": null, - "range": [ - 197, - 210 - ] - } - ], - "loc": null, - "range": [ - 191, - 211 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 290, - 293 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 294, - 295 - ] - }, - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 297, - 298 - ] - } - ], - "loc": null, - "range": [ - 290, - 299 - ] - }, - "directive": null, - "loc": null, - "range": [ - 290, - 300 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "ArrayExpression", - "elements": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 311, - 312 - ] - }, - { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 314, - 315 - ] - } - ], - "loc": null, - "range": [ - 310, - 316 - ] - }, - "loc": null, - "range": [ - 303, - 317 - ] - } - ], - "loc": null, - "range": [ - 71, - 319 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 45, - 319 - ], - "loc": null, - "range": [ - 45, - 319 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 45, - 319 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inadvertent-mutability-readonly-class.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inadvertent-mutability-readonly-class.js.snap deleted file mode 100644 index 4e9f35d0b08a1..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inadvertent-mutability-readonly-class.js.snap +++ /dev/null @@ -1,350 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-class.js ---- -Input: -function Component(props) { - const env = useRelayEnvironment(); - // Note: this is a class has no mutable methods, ie it always treats `this` as readonly - const mutator = new Mutator(env); - - useOtherHook(); - - // `x` should be independently memoizeable, since foo(x, mutator) cannot mutate - // the mutator. - const x = {}; - foo(x, mutator); - return x; -} - -class Mutator {} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "env", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 39 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useRelayEnvironment", - "typeAnnotation": null, - "loc": null, - "range": [ - 42, - 61 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 42, - 63 - ] - }, - "loc": null, - "range": [ - 36, - 63 - ] - } - ], - "loc": null, - "range": [ - 30, - 64 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "mutator", - "typeAnnotation": null, - "loc": null, - "range": [ - 163, - 170 - ] - }, - "init": { - "type": "NewExpression", - "callee": { - "type": "Identifier", - "name": "Mutator", - "typeAnnotation": null, - "loc": null, - "range": [ - 177, - 184 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "env", - "typeAnnotation": null, - "loc": null, - "range": [ - 185, - 188 - ] - } - ], - "loc": null, - "range": [ - 173, - 189 - ] - }, - "loc": null, - "range": [ - 163, - 189 - ] - } - ], - "loc": null, - "range": [ - 157, - 190 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useOtherHook", - "typeAnnotation": null, - "loc": null, - "range": [ - 194, - 206 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 194, - 208 - ] - }, - "directive": null, - "loc": null, - "range": [ - 194, - 209 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 319, - 320 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 323, - 325 - ] - }, - "loc": null, - "range": [ - 319, - 325 - ] - } - ], - "loc": null, - "range": [ - 313, - 326 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 329, - 332 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 333, - 334 - ] - }, - { - "type": "Identifier", - "name": "mutator", - "typeAnnotation": null, - "loc": null, - "range": [ - 336, - 343 - ] - } - ], - "loc": null, - "range": [ - 329, - 344 - ] - }, - "directive": null, - "loc": null, - "range": [ - 329, - 345 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 355, - 356 - ] - }, - "loc": null, - "range": [ - 348, - 357 - ] - } - ], - "loc": null, - "range": [ - 26, - 359 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 359 - ], - "loc": null, - "range": [ - 0, - 359 - ] - }, - { - "type": "ClassDeclaration", - "id": { - "type": "Identifier", - "name": "Mutator", - "typeAnnotation": null, - "loc": null, - "range": [ - 367, - 374 - ] - }, - "superClass": null, - "body": { - "type": "ClassBody", - "body": [], - "loc": null, - "range": [ - 375, - 377 - ] - }, - "loc": null, - "range": [ - 361, - 377 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 377 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inadvertent-mutability-readonly-lambda.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inadvertent-mutability-readonly-lambda.js.snap deleted file mode 100644 index 34939711ea68f..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inadvertent-mutability-readonly-lambda.js.snap +++ /dev/null @@ -1,464 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/inadvertent-mutability-readonly-lambda.js ---- -Input: -function Component(props) { - const [value, setValue] = useState(null); - // NOTE: this lambda does not capture any mutable values (only the state setter) - // and thus should be treated as readonly - const onChange = (e) => setValue((value) => value + e.target.value); - - useOtherHook(); - - // x should be independently memoizeable, since foo(x, onChange) cannot modify onChange - const x = {}; - foo(x, onChange); - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "ArrayPattern", - "elements": [ - { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 37, - 42 - ] - }, - { - "type": "Identifier", - "name": "setValue", - "typeAnnotation": null, - "loc": null, - "range": [ - 44, - 52 - ] - } - ], - "loc": null, - "range": [ - 36, - 53 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useState", - "typeAnnotation": null, - "loc": null, - "range": [ - 56, - 64 - ] - }, - "arguments": [ - { - "type": "NullLiteral", - "loc": null, - "range": [ - 65, - 69 - ] - } - ], - "loc": null, - "range": [ - 56, - 70 - ] - }, - "loc": null, - "range": [ - 36, - 70 - ] - } - ], - "loc": null, - "range": [ - 30, - 71 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "onChange", - "typeAnnotation": null, - "loc": null, - "range": [ - 207, - 215 - ] - }, - "init": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [ - { - "type": "Identifier", - "name": "e", - "typeAnnotation": null, - "loc": null, - "range": [ - 219, - 220 - ] - } - ], - "body": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "setValue", - "typeAnnotation": null, - "loc": null, - "range": [ - 225, - 233 - ] - }, - "arguments": [ - { - "type": "ArrowFunctionExpression", - "id": null, - "params": [ - { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 235, - 240 - ] - } - ], - "body": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 245, - 250 - ] - }, - "operator": "+", - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "e", - "typeAnnotation": null, - "loc": null, - "range": [ - 253, - 254 - ] - }, - "property": { - "type": "Identifier", - "name": "target", - "typeAnnotation": null, - "loc": null, - "range": [ - 255, - 261 - ] - }, - "computed": false, - "loc": null, - "range": [ - 253, - 261 - ] - }, - "property": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 262, - 267 - ] - }, - "computed": false, - "loc": null, - "range": [ - 253, - 267 - ] - }, - "loc": null, - "range": [ - 245, - 267 - ] - }, - "generator": true, - "async": false, - "loc": null, - "range": [ - 234, - 267 - ], - "expression": true, - "loc": null, - "range": [ - 234, - 267 - ] - } - ], - "loc": null, - "range": [ - 225, - 268 - ] - }, - "generator": true, - "async": false, - "loc": null, - "range": [ - 218, - 268 - ], - "expression": true, - "loc": null, - "range": [ - 218, - 268 - ] - }, - "loc": null, - "range": [ - 207, - 268 - ] - } - ], - "loc": null, - "range": [ - 201, - 269 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useOtherHook", - "typeAnnotation": null, - "loc": null, - "range": [ - 273, - 285 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 273, - 287 - ] - }, - "directive": null, - "loc": null, - "range": [ - 273, - 288 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 388, - 389 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 392, - 394 - ] - }, - "loc": null, - "range": [ - 388, - 394 - ] - } - ], - "loc": null, - "range": [ - 382, - 395 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 398, - 401 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 402, - 403 - ] - }, - { - "type": "Identifier", - "name": "onChange", - "typeAnnotation": null, - "loc": null, - "range": [ - 405, - 413 - ] - } - ], - "loc": null, - "range": [ - 398, - 414 - ] - }, - "directive": null, - "loc": null, - "range": [ - 398, - 415 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 425, - 426 - ] - }, - "loc": null, - "range": [ - 418, - 427 - ] - } - ], - "loc": null, - "range": [ - 26, - 429 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 429 - ], - "loc": null, - "range": [ - 0, - 429 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 429 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independent-across-if.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independent-across-if.js.snap deleted file mode 100644 index 9f07608dbf4c3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independent-across-if.js.snap +++ /dev/null @@ -1,625 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/independent-across-if.js ---- -Input: -function compute() {} -function mutate() {} -function foo() {} -function Foo() {} - -/** - * Should produce 3 scopes: - * - * a: inputs=props.a & props.c; outputs=a - * a = compute(props.a); - * if (props.c) - * mutate(a) - * b: inputs=props.b & props.c; outputs=b - * b = compute(props.b); - * if (props.c) - * mutate(b) - * return: inputs=a, b outputs=return - * return = - */ -function Component(props) { - const a = compute(props.a); - const b = compute(props.b); - if (props.c) { - mutate(a); - mutate(b); - } - return ; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 16 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 19, - 21 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 21 - ], - "loc": null, - "range": [ - 0, - 21 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 37 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 40, - 42 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 22, - 42 - ], - "loc": null, - "range": [ - 22, - 42 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 52, - 55 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 58, - 60 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 43, - 60 - ], - "loc": null, - "range": [ - 43, - 60 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 70, - 73 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 76, - 78 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 61, - 78 - ], - "loc": null, - "range": [ - 61, - 78 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 408, - 417 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 418, - 423 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 435, - 436 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 439, - 446 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 447, - 452 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 453, - 454 - ] - }, - "computed": false, - "loc": null, - "range": [ - 447, - 454 - ] - } - ], - "loc": null, - "range": [ - 439, - 455 - ] - }, - "loc": null, - "range": [ - 435, - 455 - ] - } - ], - "loc": null, - "range": [ - 429, - 456 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 465, - 466 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 469, - 476 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 477, - 482 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 483, - 484 - ] - }, - "computed": false, - "loc": null, - "range": [ - 477, - 484 - ] - } - ], - "loc": null, - "range": [ - 469, - 485 - ] - }, - "loc": null, - "range": [ - 465, - 485 - ] - } - ], - "loc": null, - "range": [ - 459, - 486 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 493, - 498 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 499, - 500 - ] - }, - "computed": false, - "loc": null, - "range": [ - 493, - 500 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 508, - 514 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 515, - 516 - ] - } - ], - "loc": null, - "range": [ - 508, - 517 - ] - }, - "directive": null, - "loc": null, - "range": [ - 508, - 518 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 523, - 529 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 530, - 531 - ] - } - ], - "loc": null, - "range": [ - 523, - 532 - ] - }, - "directive": null, - "loc": null, - "range": [ - 523, - 533 - ] - } - ], - "loc": null, - "range": [ - 502, - 537 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 489, - 537 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 548, - 551 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "a", - "loc": null, - "range": [ - 552, - 553 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 555, - 556 - ] - }, - "loc": null, - "range": [ - 554, - 557 - ] - }, - "loc": null, - "range": [ - 552, - 557 - ] - }, - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "b", - "loc": null, - "range": [ - 558, - 559 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 561, - 562 - ] - }, - "loc": null, - "range": [ - 560, - 563 - ] - }, - "loc": null, - "range": [ - 558, - 563 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 547, - 566 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 547, - 566 - ] - }, - "loc": null, - "range": [ - 540, - 567 - ] - } - ], - "loc": null, - "range": [ - 425, - 569 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 399, - 569 - ], - "loc": null, - "range": [ - 399, - 569 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 569 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independent.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independent.js.snap deleted file mode 100644 index 500f9269950f9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independent.js.snap +++ /dev/null @@ -1,455 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/independent.js ---- -Input: -/** - * Should produce 3 scopes: - * - * a: inputs=props.a, outputs=a - * a = compute(props.a); - * b: inputs=props.b, outputs=b - * b = compute(props.b); - * return: inputs=a, b outputs=return - * return = - */ -function Component(props) { - const a = compute(props.a); - const b = compute(props.b); - return ; -} - -function compute() {} -function foo() {} -function Foo() {} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 238, - 247 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 248, - 253 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 265, - 266 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 269, - 276 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 277, - 282 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 283, - 284 - ] - }, - "computed": false, - "loc": null, - "range": [ - 277, - 284 - ] - } - ], - "loc": null, - "range": [ - 269, - 285 - ] - }, - "loc": null, - "range": [ - 265, - 285 - ] - } - ], - "loc": null, - "range": [ - 259, - 286 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 295, - 296 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 299, - 306 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 307, - 312 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 313, - 314 - ] - }, - "computed": false, - "loc": null, - "range": [ - 307, - 314 - ] - } - ], - "loc": null, - "range": [ - 299, - 315 - ] - }, - "loc": null, - "range": [ - 295, - 315 - ] - } - ], - "loc": null, - "range": [ - 289, - 316 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 327, - 330 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "a", - "loc": null, - "range": [ - 331, - 332 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 334, - 335 - ] - }, - "loc": null, - "range": [ - 333, - 336 - ] - }, - "loc": null, - "range": [ - 331, - 336 - ] - }, - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "b", - "loc": null, - "range": [ - 337, - 338 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 340, - 341 - ] - }, - "loc": null, - "range": [ - 339, - 342 - ] - }, - "loc": null, - "range": [ - 337, - 342 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 326, - 345 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 326, - 345 - ] - }, - "loc": null, - "range": [ - 319, - 346 - ] - } - ], - "loc": null, - "range": [ - 255, - 348 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 229, - 348 - ], - "loc": null, - "range": [ - 229, - 348 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 359, - 366 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 369, - 371 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 350, - 371 - ], - "loc": null, - "range": [ - 350, - 371 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 381, - 384 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 387, - 389 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 372, - 389 - ], - "loc": null, - "range": [ - 372, - 389 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 399, - 402 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 405, - 407 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 390, - 407 - ], - "loc": null, - "range": [ - 390, - 407 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 229, - 407 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independently-memoize-object-property.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independently-memoize-object-property.js.snap deleted file mode 100644 index ff5691c5d9d8a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@independently-memoize-object-property.js.snap +++ /dev/null @@ -1,260 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/independently-memoize-object-property.js ---- -Input: -function foo(a, b, c) { - const x = { a: a }; - // NOTE: this array should memoize independently from x, w only b,c as deps - x.y = [b, c]; - - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 13, - 14 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 16, - 17 - ] - }, - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 32, - 33 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 38, - 39 - ] - }, - "value": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 41, - 42 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 38, - 42 - ] - } - ], - "loc": null, - "range": [ - 36, - 44 - ] - }, - "loc": null, - "range": [ - 32, - 44 - ] - } - ], - "loc": null, - "range": [ - 26, - 45 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 126, - 127 - ] - }, - "property": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 128, - 129 - ] - }, - "computed": false, - "loc": null, - "range": [ - 126, - 129 - ] - }, - "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 133, - 134 - ] - }, - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 136, - 137 - ] - } - ], - "loc": null, - "range": [ - 132, - 138 - ] - }, - "loc": null, - "range": [ - 126, - 138 - ] - }, - "directive": null, - "loc": null, - "range": [ - 126, - 139 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 150, - 151 - ] - }, - "loc": null, - "range": [ - 143, - 152 - ] - } - ], - "loc": null, - "range": [ - 22, - 154 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 154 - ], - "loc": null, - "range": [ - 0, - 154 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 154 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-computed-delete.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-computed-delete.js.snap deleted file mode 100644 index 8e5c2897e0f92..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-computed-delete.js.snap +++ /dev/null @@ -1,226 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/infer-computed-delete.js ---- -Input: -// @debug -function Component(props) { - const x = makeObject(); - const y = delete x[props.value]; - return y; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 28 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 29, - 34 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 46, - 47 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "makeObject", - "typeAnnotation": null, - "loc": null, - "range": [ - 50, - 60 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 50, - 62 - ] - }, - "loc": null, - "range": [ - 46, - 62 - ] - } - ], - "loc": null, - "range": [ - 40, - 63 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 72, - 73 - ] - }, - "init": { - "type": "UnaryExpression", - "operator": "delete", - "prefix": true, - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 83, - 84 - ] - }, - "property": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 85, - 90 - ] - }, - "property": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 91, - 96 - ] - }, - "computed": false, - "loc": null, - "range": [ - 85, - 96 - ] - }, - "computed": true, - "loc": null, - "range": [ - 83, - 97 - ] - }, - "loc": null, - "range": [ - 76, - 97 - ] - }, - "loc": null, - "range": [ - 72, - 97 - ] - } - ], - "loc": null, - "range": [ - 66, - 98 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 108, - 109 - ] - }, - "loc": null, - "range": [ - 101, - 110 - ] - } - ], - "loc": null, - "range": [ - 36, - 112 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 10, - 112 - ], - "loc": null, - "range": [ - 10, - 112 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 10, - 112 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-global-object.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-global-object.js.snap deleted file mode 100644 index 29da25c837bbf..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-global-object.js.snap +++ /dev/null @@ -1,554 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/infer-global-object.js ---- -Input: -// Check that we correctly resolve type and effect lookups on the javascript -// global object. -function Component(props) { - let neverAliasedOrMutated = foo(props.b); - let primitiveVal1 = Math.max(props.a, neverAliasedOrMutated); - let primitiveVal2 = Infinity; - let primitiveVal3 = globaThis.globalThis.NaN; - - // Even though we don't know the function signature of foo, - // we should be able to infer that it does not mutate its inputs. - foo(primitiveVal1, primitiveVal2, primitiveVal3); - return { primitiveVal1, primitiveVal2, primitiveVal3 }; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 104, - 113 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 114, - 119 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "neverAliasedOrMutated", - "typeAnnotation": null, - "loc": null, - "range": [ - 129, - 150 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 153, - 156 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 157, - 162 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 163, - 164 - ] - }, - "computed": false, - "loc": null, - "range": [ - 157, - 164 - ] - } - ], - "loc": null, - "range": [ - 153, - 165 - ] - }, - "loc": null, - "range": [ - 129, - 165 - ] - } - ], - "loc": null, - "range": [ - 125, - 166 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "primitiveVal1", - "typeAnnotation": null, - "loc": null, - "range": [ - 173, - 186 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Math", - "typeAnnotation": null, - "loc": null, - "range": [ - 189, - 193 - ] - }, - "property": { - "type": "Identifier", - "name": "max", - "typeAnnotation": null, - "loc": null, - "range": [ - 194, - 197 - ] - }, - "computed": false, - "loc": null, - "range": [ - 189, - 197 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 198, - 203 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 204, - 205 - ] - }, - "computed": false, - "loc": null, - "range": [ - 198, - 205 - ] - }, - { - "type": "Identifier", - "name": "neverAliasedOrMutated", - "typeAnnotation": null, - "loc": null, - "range": [ - 207, - 228 - ] - } - ], - "loc": null, - "range": [ - 189, - 229 - ] - }, - "loc": null, - "range": [ - 173, - 229 - ] - } - ], - "loc": null, - "range": [ - 169, - 230 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "primitiveVal2", - "typeAnnotation": null, - "loc": null, - "range": [ - 237, - 250 - ] - }, - "init": { - "type": "Identifier", - "name": "Infinity", - "typeAnnotation": null, - "loc": null, - "range": [ - 253, - 261 - ] - }, - "loc": null, - "range": [ - 237, - 261 - ] - } - ], - "loc": null, - "range": [ - 233, - 262 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "primitiveVal3", - "typeAnnotation": null, - "loc": null, - "range": [ - 269, - 282 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "globaThis", - "typeAnnotation": null, - "loc": null, - "range": [ - 285, - 294 - ] - }, - "property": { - "type": "Identifier", - "name": "globalThis", - "typeAnnotation": null, - "loc": null, - "range": [ - 295, - 305 - ] - }, - "computed": false, - "loc": null, - "range": [ - 285, - 305 - ] - }, - "property": { - "type": "Identifier", - "name": "NaN", - "typeAnnotation": null, - "loc": null, - "range": [ - 306, - 309 - ] - }, - "computed": false, - "loc": null, - "range": [ - 285, - 309 - ] - }, - "loc": null, - "range": [ - 269, - 309 - ] - } - ], - "loc": null, - "range": [ - 265, - 310 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 444, - 447 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "primitiveVal1", - "typeAnnotation": null, - "loc": null, - "range": [ - 448, - 461 - ] - }, - { - "type": "Identifier", - "name": "primitiveVal2", - "typeAnnotation": null, - "loc": null, - "range": [ - 463, - 476 - ] - }, - { - "type": "Identifier", - "name": "primitiveVal3", - "typeAnnotation": null, - "loc": null, - "range": [ - 478, - 491 - ] - } - ], - "loc": null, - "range": [ - 444, - 492 - ] - }, - "directive": null, - "loc": null, - "range": [ - 444, - 493 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "primitiveVal1", - "typeAnnotation": null, - "loc": null, - "range": [ - 505, - 518 - ] - }, - "value": { - "type": "Identifier", - "name": "primitiveVal1", - "typeAnnotation": null, - "loc": null, - "range": [ - 505, - 518 - ] - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "loc": null, - "range": [ - 505, - 518 - ] - }, - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "primitiveVal2", - "typeAnnotation": null, - "loc": null, - "range": [ - 520, - 533 - ] - }, - "value": { - "type": "Identifier", - "name": "primitiveVal2", - "typeAnnotation": null, - "loc": null, - "range": [ - 520, - 533 - ] - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "loc": null, - "range": [ - 520, - 533 - ] - }, - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "primitiveVal3", - "typeAnnotation": null, - "loc": null, - "range": [ - 535, - 548 - ] - }, - "value": { - "type": "Identifier", - "name": "primitiveVal3", - "typeAnnotation": null, - "loc": null, - "range": [ - 535, - 548 - ] - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "loc": null, - "range": [ - 535, - 548 - ] - } - ], - "loc": null, - "range": [ - 503, - 550 - ] - }, - "loc": null, - "range": [ - 496, - 551 - ] - } - ], - "loc": null, - "range": [ - 121, - 553 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 95, - 553 - ], - "loc": null, - "range": [ - 95, - 553 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 95, - 553 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-phi-primitive.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-phi-primitive.js.snap deleted file mode 100644 index 55a62a80afb2c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-phi-primitive.js.snap +++ /dev/null @@ -1,287 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/infer-phi-primitive.js ---- -Input: -function foo(a, b) { - let x; - if (a) { - x = 1; - } else { - x = 2; - } - - let y = x; - return y; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 13, - 14 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 16, - 17 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 27, - 28 - ] - }, - "init": null, - "loc": null, - "range": [ - 27, - 28 - ] - } - ], - "loc": null, - "range": [ - 23, - 29 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 45, - 46 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 49, - 50 - ] - }, - "loc": null, - "range": [ - 45, - 50 - ] - }, - "directive": null, - "loc": null, - "range": [ - 45, - 51 - ] - } - ], - "loc": null, - "range": [ - 39, - 55 - ] - }, - "alternate": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 67, - 68 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 2.0, - "loc": null, - "range": [ - 71, - 72 - ] - }, - "loc": null, - "range": [ - 67, - 72 - ] - }, - "directive": null, - "loc": null, - "range": [ - 67, - 73 - ] - } - ], - "loc": null, - "range": [ - 61, - 77 - ] - }, - "loc": null, - "range": [ - 32, - 77 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 85, - 86 - ] - }, - "init": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 89, - 90 - ] - }, - "loc": null, - "range": [ - 85, - 90 - ] - } - ], - "loc": null, - "range": [ - 81, - 91 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 101, - 102 - ] - }, - "loc": null, - "range": [ - 94, - 103 - ] - } - ], - "loc": null, - "range": [ - 19, - 105 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 105 - ], - "loc": null, - "range": [ - 0, - 105 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 105 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-property-delete.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-property-delete.js.snap deleted file mode 100644 index 2fece294825fe..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-property-delete.js.snap +++ /dev/null @@ -1,206 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/infer-property-delete.js ---- -Input: -function Component(props) { - const x = makeObject(); - const y = delete x.value; - return y; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "makeObject", - "typeAnnotation": null, - "loc": null, - "range": [ - 40, - 50 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 40, - 52 - ] - }, - "loc": null, - "range": [ - 36, - 52 - ] - } - ], - "loc": null, - "range": [ - 30, - 53 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 62, - 63 - ] - }, - "init": { - "type": "UnaryExpression", - "operator": "delete", - "prefix": true, - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 73, - 74 - ] - }, - "property": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 75, - 80 - ] - }, - "computed": false, - "loc": null, - "range": [ - 73, - 80 - ] - }, - "loc": null, - "range": [ - 66, - 80 - ] - }, - "loc": null, - "range": [ - 62, - 80 - ] - } - ], - "loc": null, - "range": [ - 56, - 81 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 91, - 92 - ] - }, - "loc": null, - "range": [ - 84, - 93 - ] - } - ], - "loc": null, - "range": [ - 26, - 95 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 95 - ], - "loc": null, - "range": [ - 0, - 95 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 95 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-types-through-type-cast.flow.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-types-through-type-cast.flow.js.snap deleted file mode 100644 index 6552176b09ae7..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@infer-types-through-type-cast.flow.js.snap +++ /dev/null @@ -1,233 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/infer-types-through-type-cast.flow.js ---- -Input: -// @flow -function Component(props) { - // We can infer that `x` is a primitive bc it is aliased to `y`, - // which is used in a binary expression - const x = foo(); - const y = (x: any); - y + 1; - return x; -} - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 18, - 27 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 28, - 33 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 154, - 155 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 158, - 161 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 158, - 163 - ] - }, - "loc": null, - "range": [ - 154, - 163 - ] - } - ], - "loc": null, - "range": [ - 148, - 164 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 173, - 174 - ] - }, - "init": { - "type": "CoverTypedIdentifier", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 178, - 179 - ] - }, - "right": { - "type": "TSTypeAnnotation", - "loc": null, - "range": [ - 179, - 184 - ] - }, - "loc": null, - "range": [ - 178, - 184 - ] - }, - "loc": null, - "range": [ - 173, - 185 - ] - } - ], - "loc": null, - "range": [ - 167, - 186 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 189, - 190 - ] - }, - "operator": "+", - "right": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 193, - 194 - ] - }, - "loc": null, - "range": [ - 189, - 194 - ] - }, - "directive": null, - "loc": null, - "range": [ - 189, - 195 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 205, - 206 - ] - }, - "loc": null, - "range": [ - 198, - 207 - ] - } - ], - "loc": null, - "range": [ - 35, - 209 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 9, - 209 - ], - "loc": null, - "range": [ - 9, - 209 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 9, - 209 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inner-memo-value-not-promoted-to-outer-scope-dynamic.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inner-memo-value-not-promoted-to-outer-scope-dynamic.js.snap deleted file mode 100644 index 3f8b5ed6e8f0c..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inner-memo-value-not-promoted-to-outer-scope-dynamic.js.snap +++ /dev/null @@ -1,573 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-dynamic.js ---- -Input: -function Component(props) { - const item = useFragment(FRAGMENT, props.item); - useFreeze(item); - - const count = new MaybeMutable(item); - return ( - - - {Text} - {{maybeMutate(count)}} - - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 40 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFragment", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 54 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "FRAGMENT", - "typeAnnotation": null, - "loc": null, - "range": [ - 55, - 63 - ] - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 65, - 70 - ] - }, - "property": { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 71, - 75 - ] - }, - "computed": false, - "loc": null, - "range": [ - 65, - 75 - ] - } - ], - "loc": null, - "range": [ - 43, - 76 - ] - }, - "loc": null, - "range": [ - 36, - 76 - ] - } - ], - "loc": null, - "range": [ - 30, - 77 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "useFreeze", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 89 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 90, - 94 - ] - } - ], - "loc": null, - "range": [ - 80, - 95 - ] - }, - "directive": null, - "loc": null, - "range": [ - 80, - 96 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 106, - 111 - ] - }, - "init": { - "type": "NewExpression", - "callee": { - "type": "Identifier", - "name": "MaybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 118, - 130 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "item", - "typeAnnotation": null, - "loc": null, - "range": [ - 131, - 135 - ] - } - ], - "loc": null, - "range": [ - 114, - 136 - ] - }, - "loc": null, - "range": [ - 106, - 136 - ] - } - ], - "loc": null, - "range": [ - 100, - 137 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 154, - 158 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 153, - 159 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 159, - 166 - ] - }, - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 167, - 171 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 166, - 172 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 172, - 181 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "span", - "loc": null, - "range": [ - 183, - 187 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 182, - 188 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "Text", - "raw": "Text", - "loc": null, - "range": [ - 188, - 192 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "span", - "loc": null, - "range": [ - 194, - 198 - ] - }, - "loc": null, - "range": [ - 192, - 199 - ] - }, - "loc": null, - "range": [ - 182, - 199 - ] - }, - "loc": null, - "range": [ - 181, - 200 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 200, - 209 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "span", - "loc": null, - "range": [ - 211, - 215 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 210, - 216 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "maybeMutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 217, - 228 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 229, - 234 - ] - } - ], - "loc": null, - "range": [ - 217, - 235 - ] - }, - "loc": null, - "range": [ - 216, - 236 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "span", - "loc": null, - "range": [ - 238, - 242 - ] - }, - "loc": null, - "range": [ - 236, - 243 - ] - }, - "loc": null, - "range": [ - 210, - 243 - ] - }, - "loc": null, - "range": [ - 209, - 244 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 244, - 251 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 253, - 257 - ] - }, - "loc": null, - "range": [ - 251, - 258 - ] - }, - "loc": null, - "range": [ - 166, - 258 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 258, - 263 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 265, - 269 - ] - }, - "loc": null, - "range": [ - 263, - 270 - ] - }, - "loc": null, - "range": [ - 153, - 270 - ] - }, - "loc": null, - "range": [ - 140, - 275 - ] - } - ], - "loc": null, - "range": [ - 26, - 277 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 277 - ], - "loc": null, - "range": [ - 0, - 277 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 277 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inner-memo-value-not-promoted-to-outer-scope-static.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inner-memo-value-not-promoted-to-outer-scope-static.js.snap deleted file mode 100644 index de7548a615c42..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inner-memo-value-not-promoted-to-outer-scope-static.js.snap +++ /dev/null @@ -1,432 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/inner-memo-value-not-promoted-to-outer-scope-static.js ---- -Input: -function Component(props) { - const count = new MaybeMutable(); - return ( - - - {Text} - {{maybeMutate(count)}} - - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 41 - ] - }, - "init": { - "type": "NewExpression", - "callee": { - "type": "Identifier", - "name": "MaybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 48, - 60 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 44, - 62 - ] - }, - "loc": null, - "range": [ - 36, - 62 - ] - } - ], - "loc": null, - "range": [ - 30, - 63 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 80, - 84 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 79, - 85 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 85, - 92 - ] - }, - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 93, - 97 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 92, - 98 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 98, - 107 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "span", - "loc": null, - "range": [ - 109, - 113 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 108, - 114 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "Text", - "raw": "Text", - "loc": null, - "range": [ - 114, - 118 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "span", - "loc": null, - "range": [ - 120, - 124 - ] - }, - "loc": null, - "range": [ - 118, - 125 - ] - }, - "loc": null, - "range": [ - 108, - 125 - ] - }, - "loc": null, - "range": [ - 107, - 126 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 126, - 135 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "span", - "loc": null, - "range": [ - 137, - 141 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 136, - 142 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "maybeMutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 143, - 154 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "count", - "typeAnnotation": null, - "loc": null, - "range": [ - 155, - 160 - ] - } - ], - "loc": null, - "range": [ - 143, - 161 - ] - }, - "loc": null, - "range": [ - 142, - 162 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "span", - "loc": null, - "range": [ - 164, - 168 - ] - }, - "loc": null, - "range": [ - 162, - 169 - ] - }, - "loc": null, - "range": [ - 136, - 169 - ] - }, - "loc": null, - "range": [ - 135, - 170 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 170, - 177 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 179, - 183 - ] - }, - "loc": null, - "range": [ - 177, - 184 - ] - }, - "loc": null, - "range": [ - 92, - 184 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 184, - 189 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "View", - "loc": null, - "range": [ - 191, - 195 - ] - }, - "loc": null, - "range": [ - 189, - 196 - ] - }, - "loc": null, - "range": [ - 79, - 196 - ] - }, - "loc": null, - "range": [ - 66, - 201 - ] - } - ], - "loc": null, - "range": [ - 26, - 203 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 203 - ], - "loc": null, - "range": [ - 0, - 203 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 203 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@interdependent-across-if.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@interdependent-across-if.js.snap deleted file mode 100644 index b77ce61bd641b..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@interdependent-across-if.js.snap +++ /dev/null @@ -1,555 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/interdependent-across-if.js ---- -Input: -function compute() {} -function foo() {} -function Foo() {} - -/** - * Should produce 1 scope: - * - * return: inputs=props.a & props.b & props.c; outputs=return - * const a = compute(props.a); - * const b = compute(props.b); - * if (props.c) - * foo(a, b); - * return = - */ -function Component(props) { - const a = compute(props.a); - const b = compute(props.b); - if (props.c) { - foo(a, b); - } - return ; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 16 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 19, - 21 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 21 - ], - "loc": null, - "range": [ - 0, - 21 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 34 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 37, - 39 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 22, - 39 - ], - "loc": null, - "range": [ - 22, - 39 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 49, - 52 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 55, - 57 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 40, - 57 - ], - "loc": null, - "range": [ - 40, - 57 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 304, - 313 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 314, - 319 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 331, - 332 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 335, - 342 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 343, - 348 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 349, - 350 - ] - }, - "computed": false, - "loc": null, - "range": [ - 343, - 350 - ] - } - ], - "loc": null, - "range": [ - 335, - 351 - ] - }, - "loc": null, - "range": [ - 331, - 351 - ] - } - ], - "loc": null, - "range": [ - 325, - 352 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 361, - 362 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 365, - 372 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 373, - 378 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 379, - 380 - ] - }, - "computed": false, - "loc": null, - "range": [ - 373, - 380 - ] - } - ], - "loc": null, - "range": [ - 365, - 381 - ] - }, - "loc": null, - "range": [ - 361, - 381 - ] - } - ], - "loc": null, - "range": [ - 355, - 382 - ] - }, - { - "type": "IfStatement", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 389, - 394 - ] - }, - "property": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 395, - 396 - ] - }, - "computed": false, - "loc": null, - "range": [ - 389, - 396 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 404, - 407 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 408, - 409 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 411, - 412 - ] - } - ], - "loc": null, - "range": [ - 404, - 413 - ] - }, - "directive": null, - "loc": null, - "range": [ - 404, - 414 - ] - } - ], - "loc": null, - "range": [ - 398, - 418 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 385, - 418 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 429, - 432 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "a", - "loc": null, - "range": [ - 433, - 434 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 436, - 437 - ] - }, - "loc": null, - "range": [ - 435, - 438 - ] - }, - "loc": null, - "range": [ - 433, - 438 - ] - }, - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "b", - "loc": null, - "range": [ - 439, - 440 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 442, - 443 - ] - }, - "loc": null, - "range": [ - 441, - 444 - ] - }, - "loc": null, - "range": [ - 439, - 444 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 428, - 447 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 428, - 447 - ] - }, - "loc": null, - "range": [ - 421, - 448 - ] - } - ], - "loc": null, - "range": [ - 321, - 450 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 295, - 450 - ], - "loc": null, - "range": [ - 295, - 450 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 450 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@interdependent.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@interdependent.js.snap deleted file mode 100644 index f78aa452e90d6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@interdependent.js.snap +++ /dev/null @@ -1,504 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/interdependent.js ---- -Input: -/** - * Should produce 1 scope: - * - * return: inputs=props.a & props.b; outputs=return - * const a = compute(props.a); - * const b = compute(props.b); - * foo(a, b); - * return = - */ -function Component(props) { - const a = compute(props.a); - const b = compute(props.b); - foo(a, b); - return ; -} - -function compute() {} -function foo() {} -function Foo() {} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 215, - 224 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 225, - 230 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 242, - 243 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 246, - 253 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 254, - 259 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 260, - 261 - ] - }, - "computed": false, - "loc": null, - "range": [ - 254, - 261 - ] - } - ], - "loc": null, - "range": [ - 246, - 262 - ] - }, - "loc": null, - "range": [ - 242, - 262 - ] - } - ], - "loc": null, - "range": [ - 236, - 263 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 272, - 273 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 276, - 283 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 284, - 289 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 290, - 291 - ] - }, - "computed": false, - "loc": null, - "range": [ - 284, - 291 - ] - } - ], - "loc": null, - "range": [ - 276, - 292 - ] - }, - "loc": null, - "range": [ - 272, - 292 - ] - } - ], - "loc": null, - "range": [ - 266, - 293 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 296, - 299 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 300, - 301 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 303, - 304 - ] - } - ], - "loc": null, - "range": [ - 296, - 305 - ] - }, - "directive": null, - "loc": null, - "range": [ - 296, - 306 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 317, - 320 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "a", - "loc": null, - "range": [ - 321, - 322 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 324, - 325 - ] - }, - "loc": null, - "range": [ - 323, - 326 - ] - }, - "loc": null, - "range": [ - 321, - 326 - ] - }, - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "b", - "loc": null, - "range": [ - 327, - 328 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 330, - 331 - ] - }, - "loc": null, - "range": [ - 329, - 332 - ] - }, - "loc": null, - "range": [ - 327, - 332 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 316, - 335 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 316, - 335 - ] - }, - "loc": null, - "range": [ - 309, - 336 - ] - } - ], - "loc": null, - "range": [ - 232, - 338 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 206, - 338 - ], - "loc": null, - "range": [ - 206, - 338 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "compute", - "typeAnnotation": null, - "loc": null, - "range": [ - 349, - 356 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 359, - 361 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 340, - 361 - ], - "loc": null, - "range": [ - 340, - 361 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 371, - 374 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 377, - 379 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 362, - 379 - ], - "loc": null, - "range": [ - 362, - 379 - ] - }, - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 389, - 392 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [], - "loc": null, - "range": [ - 395, - 397 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 380, - 397 - ], - "loc": null, - "range": [ - 380, - 397 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 206, - 397 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inverted-if-else.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inverted-if-else.js.snap deleted file mode 100644 index 622e6add63de9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inverted-if-else.js.snap +++ /dev/null @@ -1,304 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/inverted-if-else.js ---- -Input: -function foo(a, b, c) { - let x = null; - label: { - if (a) { - x = b; - break label; - } - x = c; - } - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 13, - 14 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 16, - 17 - ] - }, - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 30, - 31 - ] - }, - "init": { - "type": "NullLiteral", - "loc": null, - "range": [ - 34, - 38 - ] - }, - "loc": null, - "range": [ - 30, - 38 - ] - } - ], - "loc": null, - "range": [ - 26, - 39 - ] - }, - { - "type": "LabeledStatement", - "label": { - "type": "Identifier", - "name": "label", - "typeAnnotation": null, - "loc": null, - "range": [ - 42, - 47 - ] - }, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 59, - 60 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 70, - 71 - ] - }, - "right": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 74, - 75 - ] - }, - "loc": null, - "range": [ - 70, - 75 - ] - }, - "directive": null, - "loc": null, - "range": [ - 70, - 76 - ] - }, - { - "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label", - "typeAnnotation": null, - "loc": null, - "range": [ - 89, - 94 - ] - }, - "loc": null, - "range": [ - 83, - 95 - ] - } - ], - "loc": null, - "range": [ - 62, - 101 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 55, - 101 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 106, - 107 - ] - }, - "right": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 110, - 111 - ] - }, - "loc": null, - "range": [ - 106, - 111 - ] - }, - "directive": null, - "loc": null, - "range": [ - 106, - 112 - ] - } - ], - "loc": null, - "range": [ - 49, - 116 - ] - }, - "loc": null, - "range": [ - 42, - 116 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 126, - 127 - ] - }, - "loc": null, - "range": [ - 119, - 128 - ] - } - ], - "loc": null, - "range": [ - 22, - 130 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 130 - ], - "loc": null, - "range": [ - 0, - 130 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 130 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inverted-if.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inverted-if.js.snap deleted file mode 100644 index c5ecfe6aebeb3..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@inverted-if.js.snap +++ /dev/null @@ -1,374 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/inverted-if.js ---- -Input: -function foo(a, b, c, d) { - let y = []; - label: if (a) { - if (b) { - y.push(c); - break label; - } - y.push(d); - } - return y; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 13, - 14 - ] - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 16, - 17 - ] - }, - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - }, - { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 22, - 23 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 33, - 34 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 37, - 39 - ] - }, - "loc": null, - "range": [ - 33, - 39 - ] - } - ], - "loc": null, - "range": [ - 29, - 40 - ] - }, - { - "type": "LabeledStatement", - "label": { - "type": "Identifier", - "name": "label", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 48 - ] - }, - "body": { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 54, - 55 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 67, - 68 - ] - }, - "consequent": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 78, - 79 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 84 - ] - }, - "computed": false, - "loc": null, - "range": [ - 78, - 84 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 85, - 86 - ] - } - ], - "loc": null, - "range": [ - 78, - 87 - ] - }, - "directive": null, - "loc": null, - "range": [ - 78, - 88 - ] - }, - { - "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label", - "typeAnnotation": null, - "loc": null, - "range": [ - 101, - 106 - ] - }, - "loc": null, - "range": [ - 95, - 107 - ] - } - ], - "loc": null, - "range": [ - 70, - 113 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 63, - 113 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 118, - 119 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 120, - 124 - ] - }, - "computed": false, - "loc": null, - "range": [ - 118, - 124 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "d", - "typeAnnotation": null, - "loc": null, - "range": [ - 125, - 126 - ] - } - ], - "loc": null, - "range": [ - 118, - 127 - ] - }, - "directive": null, - "loc": null, - "range": [ - 118, - 128 - ] - } - ], - "loc": null, - "range": [ - 57, - 132 - ] - }, - "alternate": null, - "loc": null, - "range": [ - 50, - 132 - ] - }, - "loc": null, - "range": [ - 43, - 132 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 142, - 143 - ] - }, - "loc": null, - "range": [ - 135, - 144 - ] - } - ], - "loc": null, - "range": [ - 25, - 146 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 146 - ], - "loc": null, - "range": [ - 0, - 146 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 146 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@issue852.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@issue852.js.snap deleted file mode 100644 index 038bd5d4ba616..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@issue852.js.snap +++ /dev/null @@ -1,261 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/issue852.js ---- -Input: -function Component(c) { - let x = { c }; - mutate(x); - let a = x; - let b = a; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 20 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 30, - 31 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "value": { - "type": "Identifier", - "name": "c", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 37 - ] - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "loc": null, - "range": [ - 36, - 37 - ] - } - ], - "loc": null, - "range": [ - 34, - 39 - ] - }, - "loc": null, - "range": [ - 30, - 39 - ] - } - ], - "loc": null, - "range": [ - 26, - 40 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 43, - 49 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 50, - 51 - ] - } - ], - "loc": null, - "range": [ - 43, - 52 - ] - }, - "directive": null, - "loc": null, - "range": [ - 43, - 53 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 60, - 61 - ] - }, - "init": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 64, - 65 - ] - }, - "loc": null, - "range": [ - 60, - 65 - ] - } - ], - "loc": null, - "range": [ - 56, - 66 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 73, - 74 - ] - }, - "init": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 77, - 78 - ] - }, - "loc": null, - "range": [ - 73, - 78 - ] - } - ], - "loc": null, - "range": [ - 69, - 79 - ] - } - ], - "loc": null, - "range": [ - 22, - 81 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 81 - ], - "loc": null, - "range": [ - 0, - 81 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 81 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@issue933-disjoint-set-infinite-loop.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@issue933-disjoint-set-infinite-loop.js.snap deleted file mode 100644 index 0aeec079dc445..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@issue933-disjoint-set-infinite-loop.js.snap +++ /dev/null @@ -1,315 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/issue933-disjoint-set-infinite-loop.js ---- -Input: -// This caused an infinite loop in the compiler -function MyApp(props) { - const y = makeObj(); - const tmp = y.a; - const tmp2 = tmp.b; - y.push(tmp2); - return y; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "MyApp", - "typeAnnotation": null, - "loc": null, - "range": [ - 57, - 62 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 63, - 68 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 80, - 81 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "makeObj", - "typeAnnotation": null, - "loc": null, - "range": [ - 84, - 91 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 84, - 93 - ] - }, - "loc": null, - "range": [ - 80, - 93 - ] - } - ], - "loc": null, - "range": [ - 74, - 94 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "tmp", - "typeAnnotation": null, - "loc": null, - "range": [ - 103, - 106 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 109, - 110 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 111, - 112 - ] - }, - "computed": false, - "loc": null, - "range": [ - 109, - 112 - ] - }, - "loc": null, - "range": [ - 103, - 112 - ] - } - ], - "loc": null, - "range": [ - 97, - 113 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "tmp2", - "typeAnnotation": null, - "loc": null, - "range": [ - 122, - 126 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "tmp", - "typeAnnotation": null, - "loc": null, - "range": [ - 129, - 132 - ] - }, - "property": { - "type": "Identifier", - "name": "b", - "typeAnnotation": null, - "loc": null, - "range": [ - 133, - 134 - ] - }, - "computed": false, - "loc": null, - "range": [ - 129, - 134 - ] - }, - "loc": null, - "range": [ - 122, - 134 - ] - } - ], - "loc": null, - "range": [ - 116, - 135 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 138, - 139 - ] - }, - "property": { - "type": "Identifier", - "name": "push", - "typeAnnotation": null, - "loc": null, - "range": [ - 140, - 144 - ] - }, - "computed": false, - "loc": null, - "range": [ - 138, - 144 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "tmp2", - "typeAnnotation": null, - "loc": null, - "range": [ - 145, - 149 - ] - } - ], - "loc": null, - "range": [ - 138, - 150 - ] - }, - "directive": null, - "loc": null, - "range": [ - 138, - 151 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "y", - "typeAnnotation": null, - "loc": null, - "range": [ - 161, - 162 - ] - }, - "loc": null, - "range": [ - 154, - 163 - ] - } - ], - "loc": null, - "range": [ - 70, - 165 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 48, - 165 - ], - "loc": null, - "range": [ - 48, - 165 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 48, - 165 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-empty-expression.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-empty-expression.js.snap deleted file mode 100644 index 2280f9a57c200..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-empty-expression.js.snap +++ /dev/null @@ -1,222 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/jsx-empty-expression.js ---- -Input: -export function Component(props) { - return ( -
- {} - {props.a} -
- ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "ExportNamedDeclaration", - "declaration": { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 16, - 25 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 26, - 31 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 51, - 54 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 50, - 55 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 55, - 62 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "JSXEmptyExpression", - "loc": null, - "range": [ - 63, - 63 - ] - }, - "loc": null, - "range": [ - 62, - 64 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 64, - 71 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 72, - 77 - ] - }, - "property": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 78, - 79 - ] - }, - "computed": false, - "loc": null, - "range": [ - 72, - 79 - ] - }, - "loc": null, - "range": [ - 71, - 80 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 80, - 85 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 87, - 90 - ] - }, - "loc": null, - "range": [ - 85, - 91 - ] - }, - "loc": null, - "range": [ - 50, - 91 - ] - }, - "loc": null, - "range": [ - 37, - 96 - ] - } - ], - "loc": null, - "range": [ - 33, - 98 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 7, - 98 - ], - "loc": null, - "range": [ - 7, - 98 - ] - }, - "specifiers": [], - "source": null, - "loc": null, - "range": [ - 0, - 98 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 98 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-fragment.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-fragment.js.snap deleted file mode 100644 index ed96edd2b5f6d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-fragment.js.snap +++ /dev/null @@ -1,297 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/jsx-fragment.js ---- -Input: -function Foo(props) { - return ( - <> - Hello {props.greeting}{" "} -
- <>Text -
- - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 12 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 13, - 18 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXFragment", - "openingFragment": { - "type": "JSXOpeningFragment", - "loc": null, - "range": [ - 37, - 39 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n Hello ", - "raw": "\n Hello ", - "loc": null, - "range": [ - 39, - 52 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 53, - 58 - ] - }, - "property": { - "type": "Identifier", - "name": "greeting", - "typeAnnotation": null, - "loc": null, - "range": [ - 59, - 67 - ] - }, - "computed": false, - "loc": null, - "range": [ - 53, - 67 - ] - }, - "loc": null, - "range": [ - 52, - 68 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "StringLiteral", - "value": " ", - "loc": null, - "range": [ - 69, - 72 - ] - }, - "loc": null, - "range": [ - 68, - 73 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 73, - 80 - ] - }, - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 81, - 84 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 80, - 85 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 85, - 94 - ] - }, - { - "type": "JSXFragment", - "openingFragment": { - "type": "JSXOpeningFragment", - "loc": null, - "range": [ - 94, - 96 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "Text", - "raw": "Text", - "loc": null, - "range": [ - 96, - 100 - ] - } - ], - "closingFragment": { - "type": "JSXClosingFragment", - "loc": null, - "range": [ - 100, - 103 - ] - }, - "loc": null, - "range": [ - 94, - 103 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 103, - 110 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 112, - 115 - ] - }, - "loc": null, - "range": [ - 110, - 116 - ] - }, - "loc": null, - "range": [ - 80, - 116 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 116, - 121 - ] - } - ], - "closingFragment": { - "type": "JSXClosingFragment", - "loc": null, - "range": [ - 121, - 124 - ] - }, - "loc": null, - "range": [ - 37, - 124 - ] - }, - "loc": null, - "range": [ - 24, - 129 - ] - } - ], - "loc": null, - "range": [ - 20, - 131 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 131 - ], - "loc": null, - "range": [ - 0, - 131 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 131 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-member-expression-tag-grouping.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-member-expression-tag-grouping.js.snap deleted file mode 100644 index b0acf24cace28..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-member-expression-tag-grouping.js.snap +++ /dev/null @@ -1,245 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/jsx-member-expression-tag-grouping.js ---- -Input: -function Component(props) { - const maybeMutable = new MaybeMutable(); - return {maybeMutate(maybeMutable)}; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "maybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 48 - ] - }, - "init": { - "type": "NewExpression", - "callee": { - "type": "Identifier", - "name": "MaybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 55, - 67 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 51, - 69 - ] - }, - "loc": null, - "range": [ - 36, - 69 - ] - } - ], - "loc": null, - "range": [ - 30, - 70 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 81, - 84 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 85, - 88 - ] - }, - "loc": null, - "range": [ - 81, - 88 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 80, - 89 - ] - }, - "children": [ - { - "type": "JSXExpressionContainer", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "maybeMutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 90, - 101 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "maybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 102, - 114 - ] - } - ], - "loc": null, - "range": [ - 90, - 115 - ] - }, - "loc": null, - "range": [ - 89, - 116 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 118, - 121 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 122, - 125 - ] - }, - "loc": null, - "range": [ - 118, - 125 - ] - }, - "loc": null, - "range": [ - 116, - 126 - ] - }, - "loc": null, - "range": [ - 80, - 126 - ] - }, - "loc": null, - "range": [ - 73, - 127 - ] - } - ], - "loc": null, - "range": [ - 26, - 129 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 129 - ], - "loc": null, - "range": [ - 0, - 129 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 129 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-member-expression.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-member-expression.js.snap deleted file mode 100644 index e4419c5eb1b83..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-member-expression.js.snap +++ /dev/null @@ -1,279 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/jsx-member-expression.js ---- -Input: -function Component(props) { - return ( - - - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Sathya", - "loc": null, - "range": [ - 44, - 50 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Codes", - "loc": null, - "range": [ - 51, - 56 - ] - }, - "loc": null, - "range": [ - 44, - 56 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Forget", - "loc": null, - "range": [ - 57, - 63 - ] - }, - "loc": null, - "range": [ - 44, - 63 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 43, - 64 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 64, - 71 - ] - }, - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Foo", - "loc": null, - "range": [ - 72, - 75 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Bar", - "loc": null, - "range": [ - 76, - 79 - ] - }, - "loc": null, - "range": [ - 72, - 79 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Baz", - "loc": null, - "range": [ - 80, - 83 - ] - }, - "loc": null, - "range": [ - 72, - 83 - ] - }, - "attributes": [], - "selfClosing": true, - "loc": null, - "range": [ - 71, - 86 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 71, - 86 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 86, - 91 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXMemberExpression", - "object": { - "type": "JSXIdentifier", - "name": "Sathya", - "loc": null, - "range": [ - 93, - 99 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Codes", - "loc": null, - "range": [ - 100, - 105 - ] - }, - "loc": null, - "range": [ - 93, - 105 - ] - }, - "property": { - "type": "JSXIdentifier", - "name": "Forget", - "loc": null, - "range": [ - 106, - 112 - ] - }, - "loc": null, - "range": [ - 93, - 112 - ] - }, - "loc": null, - "range": [ - 91, - 113 - ] - }, - "loc": null, - "range": [ - 43, - 113 - ] - }, - "loc": null, - "range": [ - 30, - 118 - ] - } - ], - "loc": null, - "range": [ - 26, - 120 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 120 - ], - "loc": null, - "range": [ - 0, - 120 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 120 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-namespaced-name.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-namespaced-name.js.snap deleted file mode 100644 index 527e8c67466d9..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-namespaced-name.js.snap +++ /dev/null @@ -1,196 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/jsx-namespaced-name.js ---- -Input: -function Component(props) { - return ; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXNamespacedName", - "namespace": { - "type": "JSXIdentifier", - "name": "xml", - "loc": null, - "range": [ - 38, - 41 - ] - }, - "name": { - "type": "JSXIdentifier", - "name": "http", - "loc": null, - "range": [ - 42, - 46 - ] - }, - "loc": null, - "range": [ - 38, - 46 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXNamespacedName", - "namespace": { - "type": "JSXIdentifier", - "name": "protocol", - "loc": null, - "range": [ - 47, - 55 - ] - }, - "name": { - "type": "JSXIdentifier", - "name": "version", - "loc": null, - "range": [ - 56, - 63 - ] - }, - "loc": null, - "range": [ - 47, - 63 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 65, - 70 - ] - }, - "property": { - "type": "Identifier", - "name": "version", - "typeAnnotation": null, - "loc": null, - "range": [ - 71, - 78 - ] - }, - "computed": false, - "loc": null, - "range": [ - 65, - 78 - ] - }, - "loc": null, - "range": [ - 64, - 79 - ] - }, - "loc": null, - "range": [ - 47, - 79 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 37, - 82 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 37, - 82 - ] - }, - "loc": null, - "range": [ - 30, - 83 - ] - } - ], - "loc": null, - "range": [ - 26, - 85 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 85 - ], - "loc": null, - "range": [ - 0, - 85 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 85 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-spread.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-spread.js.snap deleted file mode 100644 index cce9008695277..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-spread.js.snap +++ /dev/null @@ -1,263 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/jsx-spread.js ---- -Input: -function Component(props) { - return ( - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Component", - "loc": null, - "range": [ - 44, - 53 - ] - }, - "attributes": [ - { - "type": "JSXSpreadAttribute", - "argument": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 58, - 63 - ] - }, - "loc": null, - "range": [ - 54, - 64 - ] - }, - { - "type": "JSXSpreadAttribute", - "argument": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 71, - 74 - ] - }, - "value": { - "type": "ConditionalExpression", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 76, - 81 - ] - }, - "property": { - "type": "Identifier", - "name": "cond", - "typeAnnotation": null, - "loc": null, - "range": [ - 82, - 86 - ] - }, - "computed": false, - "loc": null, - "range": [ - 76, - 86 - ] - }, - "alternate": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 101, - 106 - ] - }, - "property": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 107, - 110 - ] - }, - "computed": false, - "loc": null, - "range": [ - 101, - 110 - ] - }, - "consequent": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 89, - 94 - ] - }, - "property": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 95, - 98 - ] - }, - "computed": false, - "loc": null, - "range": [ - 89, - 98 - ] - }, - "loc": null, - "range": [ - 76, - 110 - ] - }, - "kind": "init", - "method": false, - "shorthand": false, - "computed": false, - "loc": null, - "range": [ - 71, - 110 - ] - } - ], - "loc": null, - "range": [ - 69, - 112 - ] - }, - "loc": null, - "range": [ - 65, - 113 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 43, - 116 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 43, - 116 - ] - }, - "loc": null, - "range": [ - 30, - 121 - ] - } - ], - "loc": null, - "range": [ - 26, - 123 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 123 - ], - "loc": null, - "range": [ - 0, - 123 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 123 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-tag-evaluation-order-non-global.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-tag-evaluation-order-non-global.js.snap deleted file mode 100644 index 6d1c301de6b53..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-tag-evaluation-order-non-global.js.snap +++ /dev/null @@ -1,395 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order-non-global.js ---- -Input: -function Component(props) { - const maybeMutable = new MaybeMutable(); - let Tag = props.component; - // NOTE: the order of evaluation in the lowering is incorrect: - // the jsx element's tag observes `Tag` after reassignment, but should observe - // it before the reassignment. - return ( - - {((Tag = props.alternateComponent), maybeMutate(maybeMutable))} - - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "maybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 36, - 48 - ] - }, - "init": { - "type": "NewExpression", - "callee": { - "type": "Identifier", - "name": "MaybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 55, - 67 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 51, - 69 - ] - }, - "loc": null, - "range": [ - 36, - 69 - ] - } - ], - "loc": null, - "range": [ - 30, - 70 - ] - }, - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "Tag", - "typeAnnotation": null, - "loc": null, - "range": [ - 77, - 80 - ] - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 83, - 88 - ] - }, - "property": { - "type": "Identifier", - "name": "component", - "typeAnnotation": null, - "loc": null, - "range": [ - 89, - 98 - ] - }, - "computed": false, - "loc": null, - "range": [ - 83, - 98 - ] - }, - "loc": null, - "range": [ - 77, - 98 - ] - } - ], - "loc": null, - "range": [ - 73, - 99 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Tag", - "loc": null, - "range": [ - 295, - 298 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 294, - 299 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 299, - 306 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "SequenceExpression", - "expressions": [ - { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "Tag", - "typeAnnotation": null, - "loc": null, - "range": [ - 309, - 312 - ] - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 315, - 320 - ] - }, - "property": { - "type": "Identifier", - "name": "alternateComponent", - "typeAnnotation": null, - "loc": null, - "range": [ - 321, - 339 - ] - }, - "computed": false, - "loc": null, - "range": [ - 315, - 339 - ] - }, - "loc": null, - "range": [ - 309, - 339 - ] - }, - { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "maybeMutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 342, - 353 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "maybeMutable", - "typeAnnotation": null, - "loc": null, - "range": [ - 354, - 366 - ] - } - ], - "loc": null, - "range": [ - 342, - 367 - ] - } - ], - "loc": null, - "range": [ - 308, - 367 - ] - }, - "loc": null, - "range": [ - 306, - 369 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 369, - 376 - ] - }, - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Tag", - "loc": null, - "range": [ - 377, - 380 - ] - }, - "attributes": [], - "selfClosing": true, - "loc": null, - "range": [ - 376, - 383 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 376, - 383 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 383, - 388 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Tag", - "loc": null, - "range": [ - 390, - 393 - ] - }, - "loc": null, - "range": [ - 388, - 394 - ] - }, - "loc": null, - "range": [ - 294, - 394 - ] - }, - "loc": null, - "range": [ - 281, - 399 - ] - } - ], - "loc": null, - "range": [ - 26, - 401 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 401 - ], - "loc": null, - "range": [ - 0, - 401 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 401 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-tag-evaluation-order.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-tag-evaluation-order.js.snap deleted file mode 100644 index 8a1f9cd1f0742..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@jsx-tag-evaluation-order.js.snap +++ /dev/null @@ -1,304 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/jsx-tag-evaluation-order.js ---- -Input: -function Component(props) { - let Tag = View; - return ( - - {((Tag = HScroll), props.value)} - - - ); -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 19, - 24 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "Tag", - "typeAnnotation": null, - "loc": null, - "range": [ - 34, - 37 - ] - }, - "init": { - "type": "Identifier", - "name": "View", - "typeAnnotation": null, - "loc": null, - "range": [ - 40, - 44 - ] - }, - "loc": null, - "range": [ - 34, - 44 - ] - } - ], - "loc": null, - "range": [ - 30, - 45 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Tag", - "loc": null, - "range": [ - 62, - 65 - ] - }, - "attributes": [], - "selfClosing": false, - "loc": null, - "range": [ - 61, - 66 - ] - }, - "children": [ - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 66, - 73 - ] - }, - { - "type": "JSXExpressionContainer", - "expression": { - "type": "SequenceExpression", - "expressions": [ - { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "Tag", - "typeAnnotation": null, - "loc": null, - "range": [ - 76, - 79 - ] - }, - "right": { - "type": "Identifier", - "name": "HScroll", - "typeAnnotation": null, - "loc": null, - "range": [ - 82, - 89 - ] - }, - "loc": null, - "range": [ - 76, - 89 - ] - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 92, - 97 - ] - }, - "property": { - "type": "Identifier", - "name": "value", - "typeAnnotation": null, - "loc": null, - "range": [ - 98, - 103 - ] - }, - "computed": false, - "loc": null, - "range": [ - 92, - 103 - ] - } - ], - "loc": null, - "range": [ - 75, - 103 - ] - }, - "loc": null, - "range": [ - 73, - 105 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 105, - 112 - ] - }, - { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "Tag", - "loc": null, - "range": [ - 113, - 116 - ] - }, - "attributes": [], - "selfClosing": true, - "loc": null, - "range": [ - 112, - 119 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 112, - 119 - ] - }, - { - "type": "JSXText", - "value": "\n ", - "raw": "\n ", - "loc": null, - "range": [ - 119, - 124 - ] - } - ], - "closingElement": { - "type": "JSXClosingElement", - "name": { - "type": "JSXIdentifier", - "name": "Tag", - "loc": null, - "range": [ - 126, - 129 - ] - }, - "loc": null, - "range": [ - 124, - 130 - ] - }, - "loc": null, - "range": [ - 61, - 130 - ] - }, - "loc": null, - "range": [ - 48, - 135 - ] - } - ], - "loc": null, - "range": [ - 26, - 137 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 137 - ], - "loc": null, - "range": [ - 0, - 137 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 137 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-capture-returned-alias.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-capture-returned-alias.js.snap deleted file mode 100644 index ec9650ab90cf5..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-capture-returned-alias.js.snap +++ /dev/null @@ -1,510 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/lambda-capture-returned-alias.js ---- -Input: -// Here, element should not be memoized independently of aliasedElement, since -// it is captured by fn. -// AnalyzeFunctions currently does not find captured objects. -// - mutated context refs are declared as `Capture` effect in `FunctionExpression.deps` -// - all other context refs are left as Unknown. InferReferenceEffects currently demotes -// them to reads -function CaptureNotMutate(props) { - const idx = foo(props.x); - const element = bar(props.el); - - const fn = function () { - const arr = { element }; - return arr[idx]; - }; - const aliasedElement = fn(); - mutate(aliasedElement); - return aliasedElement; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "CaptureNotMutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 374, - 390 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 391, - 396 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "idx", - "typeAnnotation": null, - "loc": null, - "range": [ - 408, - 411 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo", - "typeAnnotation": null, - "loc": null, - "range": [ - 414, - 417 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 418, - 423 - ] - }, - "property": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 424, - 425 - ] - }, - "computed": false, - "loc": null, - "range": [ - 418, - 425 - ] - } - ], - "loc": null, - "range": [ - 414, - 426 - ] - }, - "loc": null, - "range": [ - 408, - 426 - ] - } - ], - "loc": null, - "range": [ - 402, - 427 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "element", - "typeAnnotation": null, - "loc": null, - "range": [ - 436, - 443 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "bar", - "typeAnnotation": null, - "loc": null, - "range": [ - 446, - 449 - ] - }, - "arguments": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "props", - "typeAnnotation": null, - "loc": null, - "range": [ - 450, - 455 - ] - }, - "property": { - "type": "Identifier", - "name": "el", - "typeAnnotation": null, - "loc": null, - "range": [ - 456, - 458 - ] - }, - "computed": false, - "loc": null, - "range": [ - 450, - 458 - ] - } - ], - "loc": null, - "range": [ - 446, - 459 - ] - }, - "loc": null, - "range": [ - 436, - 459 - ] - } - ], - "loc": null, - "range": [ - 430, - 460 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "fn", - "typeAnnotation": null, - "loc": null, - "range": [ - 470, - 472 - ] - }, - "init": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "arr", - "typeAnnotation": null, - "loc": null, - "range": [ - 499, - 502 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "element", - "typeAnnotation": null, - "loc": null, - "range": [ - 507, - 514 - ] - }, - "value": { - "type": "Identifier", - "name": "element", - "typeAnnotation": null, - "loc": null, - "range": [ - 507, - 514 - ] - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "loc": null, - "range": [ - 507, - 514 - ] - } - ], - "loc": null, - "range": [ - 505, - 516 - ] - }, - "loc": null, - "range": [ - 499, - 516 - ] - } - ], - "loc": null, - "range": [ - 493, - 517 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "arr", - "typeAnnotation": null, - "loc": null, - "range": [ - 529, - 532 - ] - }, - "property": { - "type": "Identifier", - "name": "idx", - "typeAnnotation": null, - "loc": null, - "range": [ - 533, - 536 - ] - }, - "computed": true, - "loc": null, - "range": [ - 529, - 537 - ] - }, - "loc": null, - "range": [ - 522, - 538 - ] - } - ], - "loc": null, - "range": [ - 487, - 542 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 475, - 542 - ], - "loc": null, - "range": [ - 475, - 542 - ] - }, - "loc": null, - "range": [ - 470, - 542 - ] - } - ], - "loc": null, - "range": [ - 464, - 543 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "aliasedElement", - "typeAnnotation": null, - "loc": null, - "range": [ - 552, - 566 - ] - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fn", - "typeAnnotation": null, - "loc": null, - "range": [ - 569, - 571 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 569, - 573 - ] - }, - "loc": null, - "range": [ - 552, - 573 - ] - } - ], - "loc": null, - "range": [ - 546, - 574 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 577, - 583 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "aliasedElement", - "typeAnnotation": null, - "loc": null, - "range": [ - 584, - 598 - ] - } - ], - "loc": null, - "range": [ - 577, - 599 - ] - }, - "directive": null, - "loc": null, - "range": [ - 577, - 600 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "aliasedElement", - "typeAnnotation": null, - "loc": null, - "range": [ - 610, - 624 - ] - }, - "loc": null, - "range": [ - 603, - 625 - ] - } - ], - "loc": null, - "range": [ - 398, - 627 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 365, - 627 - ], - "loc": null, - "range": [ - 365, - 627 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 365, - 627 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutate-shadowed-object.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutate-shadowed-object.js.snap deleted file mode 100644 index 2de0412cbbef6..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutate-shadowed-object.js.snap +++ /dev/null @@ -1,294 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/lambda-mutate-shadowed-object.js ---- -Input: -function Component() { - const x = {}; - { - const x = []; - const fn = function () { - mutate(x); - }; - fn(); - } - return x; // should return {} -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 32 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 35, - 37 - ] - }, - "loc": null, - "range": [ - 31, - 37 - ] - } - ], - "loc": null, - "range": [ - 25, - 38 - ] - }, - { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 53, - 54 - ] - }, - "init": { - "type": "ArrayExpression", - "elements": [], - "loc": null, - "range": [ - 57, - 59 - ] - }, - "loc": null, - "range": [ - 53, - 59 - ] - } - ], - "loc": null, - "range": [ - 47, - 60 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "fn", - "typeAnnotation": null, - "loc": null, - "range": [ - 71, - 73 - ] - }, - "init": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "mutate", - "typeAnnotation": null, - "loc": null, - "range": [ - 96, - 102 - ] - }, - "arguments": [ - { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 103, - 104 - ] - } - ], - "loc": null, - "range": [ - 96, - 105 - ] - }, - "directive": null, - "loc": null, - "range": [ - 96, - 106 - ] - } - ], - "loc": null, - "range": [ - 88, - 112 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 76, - 112 - ], - "loc": null, - "range": [ - 76, - 112 - ] - }, - "loc": null, - "range": [ - 71, - 112 - ] - } - ], - "loc": null, - "range": [ - 65, - 113 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fn", - "typeAnnotation": null, - "loc": null, - "range": [ - 118, - 120 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 118, - 122 - ] - }, - "directive": null, - "loc": null, - "range": [ - 118, - 123 - ] - } - ], - "loc": null, - "range": [ - 41, - 127 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 137, - 138 - ] - }, - "loc": null, - "range": [ - 130, - 139 - ] - } - ], - "loc": null, - "range": [ - 21, - 161 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 161 - ], - "loc": null, - "range": [ - 0, - 161 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 161 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutated-non-reactive-to-reactive.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutated-non-reactive-to-reactive.js.snap deleted file mode 100644 index 5493a31f3d458..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutated-non-reactive-to-reactive.js.snap +++ /dev/null @@ -1,293 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/lambda-mutated-non-reactive-to-reactive.js ---- -Input: -function f(a) { - let x; - (() => { - x = { a }; - })(); - return
; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "f", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 11, - 12 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 22, - 23 - ] - }, - "init": null, - "loc": null, - "range": [ - 22, - 23 - ] - } - ], - "loc": null, - "range": [ - 18, - 24 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 40, - 41 - ] - }, - "right": { - "type": "ObjectExpression", - "properties": [ - { - "type": "Property", - "key": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 46, - 47 - ] - }, - "value": { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 46, - 47 - ] - }, - "kind": "init", - "method": false, - "shorthand": true, - "computed": false, - "loc": null, - "range": [ - 46, - 47 - ] - } - ], - "loc": null, - "range": [ - 44, - 49 - ] - }, - "loc": null, - "range": [ - 40, - 49 - ] - }, - "directive": null, - "loc": null, - "range": [ - 40, - 50 - ] - } - ], - "loc": null, - "range": [ - 34, - 54 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 28, - 54 - ], - "expression": false, - "loc": null, - "range": [ - 28, - 54 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 27, - 57 - ] - }, - "directive": null, - "loc": null, - "range": [ - 27, - 58 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 69, - 72 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "x", - "loc": null, - "range": [ - 73, - 74 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 76, - 77 - ] - }, - "loc": null, - "range": [ - 75, - 78 - ] - }, - "loc": null, - "range": [ - 73, - 78 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 68, - 81 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 68, - 81 - ] - }, - "loc": null, - "range": [ - 61, - 82 - ] - } - ], - "loc": null, - "range": [ - 14, - 84 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 84 - ], - "loc": null, - "range": [ - 0, - 84 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 84 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutated-ref-non-reactive.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutated-ref-non-reactive.js.snap deleted file mode 100644 index 4cd943c83f57d..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-mutated-ref-non-reactive.js.snap +++ /dev/null @@ -1,261 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/lambda-mutated-ref-non-reactive.js ---- -Input: -function f(a) { - let x; - (() => { - x = {}; - })(); - // this is not reactive on `x` as `x` is never reactive - return
; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "f", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 10 - ] - }, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": null, - "loc": null, - "range": [ - 11, - 12 - ] - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 22, - 23 - ] - }, - "init": null, - "loc": null, - "range": [ - 22, - 23 - ] - } - ], - "loc": null, - "range": [ - 18, - 24 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "ArrowFunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 40, - 41 - ] - }, - "right": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 44, - 46 - ] - }, - "loc": null, - "range": [ - 40, - 46 - ] - }, - "directive": null, - "loc": null, - "range": [ - 40, - 47 - ] - } - ], - "loc": null, - "range": [ - 34, - 51 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 28, - 51 - ], - "expression": false, - "loc": null, - "range": [ - 28, - 51 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 27, - 54 - ] - }, - "directive": null, - "loc": null, - "range": [ - 27, - 55 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "JSXElement", - "openingElement": { - "type": "JSXOpeningElement", - "name": { - "type": "JSXIdentifier", - "name": "div", - "loc": null, - "range": [ - 124, - 127 - ] - }, - "attributes": [ - { - "type": "JSXAttribute", - "name": { - "type": "JSXIdentifier", - "name": "x", - "loc": null, - "range": [ - 128, - 129 - ] - }, - "value": { - "type": "JSXExpressionContainer", - "expression": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 131, - 132 - ] - }, - "loc": null, - "range": [ - 130, - 133 - ] - }, - "loc": null, - "range": [ - 128, - 133 - ] - } - ], - "selfClosing": true, - "loc": null, - "range": [ - 123, - 136 - ] - }, - "children": [], - "closingElement": null, - "loc": null, - "range": [ - 123, - 136 - ] - }, - "loc": null, - "range": [ - 116, - 137 - ] - } - ], - "loc": null, - "range": [ - 14, - 139 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 139 - ], - "loc": null, - "range": [ - 0, - 139 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 139 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-reassign-primitive.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-reassign-primitive.js.snap deleted file mode 100644 index 5476654f94d4a..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-reassign-primitive.js.snap +++ /dev/null @@ -1,266 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/lambda-reassign-primitive.js ---- -Input: -// writing to primitives is not a 'mutate' or 'store' to context references, -// under current analysis in AnalyzeFunctions. -// $23:TFunction = Function @deps[ -// $21:TPrimitive, $22:TPrimitive]: - -function Component() { - let x = 40; - - const fn = function () { - x = x + 1; - }; - fn(); - return x; -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 235, - 244 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 255, - 256 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 40.0, - "loc": null, - "range": [ - 259, - 261 - ] - }, - "loc": null, - "range": [ - 255, - 261 - ] - } - ], - "loc": null, - "range": [ - 251, - 262 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "fn", - "typeAnnotation": null, - "loc": null, - "range": [ - 272, - 274 - ] - }, - "init": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 295, - 296 - ] - }, - "right": { - "type": "BinaryExpression", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 299, - 300 - ] - }, - "operator": "+", - "right": { - "type": "NumericLiteral", - "value": 1.0, - "loc": null, - "range": [ - 303, - 304 - ] - }, - "loc": null, - "range": [ - 299, - 304 - ] - }, - "loc": null, - "range": [ - 295, - 304 - ] - }, - "directive": null, - "loc": null, - "range": [ - 295, - 305 - ] - } - ], - "loc": null, - "range": [ - 289, - 309 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 277, - 309 - ], - "loc": null, - "range": [ - 277, - 309 - ] - }, - "loc": null, - "range": [ - 272, - 309 - ] - } - ], - "loc": null, - "range": [ - 266, - 310 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fn", - "typeAnnotation": null, - "loc": null, - "range": [ - 313, - 315 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 313, - 317 - ] - }, - "directive": null, - "loc": null, - "range": [ - 313, - 318 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 328, - 329 - ] - }, - "loc": null, - "range": [ - 321, - 330 - ] - } - ], - "loc": null, - "range": [ - 247, - 332 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 226, - 332 - ], - "loc": null, - "range": [ - 226, - 332 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 226, - 332 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-reassign-shadowed-primitive.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-reassign-shadowed-primitive.js.snap deleted file mode 100644 index e648de8b656bd..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-reassign-shadowed-primitive.js.snap +++ /dev/null @@ -1,292 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/lambda-reassign-shadowed-primitive.js ---- -Input: -function Component() { - const x = {}; - { - let x = 56; - const fn = function () { - x = 42; - }; - fn(); - } - return x; // should return {} -} - - -Output: -{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "Component", - "typeAnnotation": null, - "loc": null, - "range": [ - 9, - 18 - ] - }, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 31, - 32 - ] - }, - "init": { - "type": "ObjectExpression", - "properties": [], - "loc": null, - "range": [ - 35, - 37 - ] - }, - "loc": null, - "range": [ - 31, - 37 - ] - } - ], - "loc": null, - "range": [ - 25, - 38 - ] - }, - { - "type": "BlockStatement", - "body": [ - { - "type": "VariableDeclaration", - "kind": "let", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 51, - 52 - ] - }, - "init": { - "type": "NumericLiteral", - "value": 56.0, - "loc": null, - "range": [ - 55, - 57 - ] - }, - "loc": null, - "range": [ - 51, - 57 - ] - } - ], - "loc": null, - "range": [ - 47, - 58 - ] - }, - { - "type": "VariableDeclaration", - "kind": "const", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "fn", - "typeAnnotation": null, - "loc": null, - "range": [ - 69, - 71 - ] - }, - "init": { - "type": "FunctionExpression", - "id": null, - "params": [], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 94, - 95 - ] - }, - "right": { - "type": "NumericLiteral", - "value": 42.0, - "loc": null, - "range": [ - 98, - 100 - ] - }, - "loc": null, - "range": [ - 94, - 100 - ] - }, - "directive": null, - "loc": null, - "range": [ - 94, - 101 - ] - } - ], - "loc": null, - "range": [ - 86, - 107 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 74, - 107 - ], - "loc": null, - "range": [ - 74, - 107 - ] - }, - "loc": null, - "range": [ - 69, - 107 - ] - } - ], - "loc": null, - "range": [ - 63, - 108 - ] - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fn", - "typeAnnotation": null, - "loc": null, - "range": [ - 113, - 115 - ] - }, - "arguments": [], - "loc": null, - "range": [ - 113, - 117 - ] - }, - "directive": null, - "loc": null, - "range": [ - 113, - 118 - ] - } - ], - "loc": null, - "range": [ - 41, - 122 - ] - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "x", - "typeAnnotation": null, - "loc": null, - "range": [ - 132, - 133 - ] - }, - "loc": null, - "range": [ - 125, - 134 - ] - } - ], - "loc": null, - "range": [ - 21, - 156 - ] - }, - "generator": false, - "async": false, - "loc": null, - "range": [ - 0, - 156 - ], - "loc": null, - "range": [ - 0, - 156 - ] - } - ], - "sourceType": "script", - "loc": null, - "range": [ - 0, - 156 - ] -} diff --git a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-with-fbt.js.snap b/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-with-fbt.js.snap deleted file mode 100644 index b7463108d5238..0000000000000 --- a/compiler/crates/react_hermes_parser/tests/snapshots/parser_test__fixtures@lambda-with-fbt.js.snap +++ /dev/null @@ -1,1130 +0,0 @@ ---- -source: crates/react_hermes_parser/tests/parser_test.rs -expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")" -input_file: crates/react_hermes_parser/tests/fixtures/lambda-with-fbt.js ---- -Input: -import { fbt } from "fbt"; - -function Component() { - const buttonLabel = () => { - if (!someCondition) { - return {"Purchase as a gift"}; - } else if ( - !iconOnly && - showPrice && - item?.current_gift_offer?.price?.formatted != null - ) { - return ( - - {"Gift | "} - - {item?.current_gift_offer?.price?.formatted} - - - ); - } else if (!iconOnly && !showPrice) { - return {"Gift"}; - } - }; - - return ( - -