cfsolve 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (368) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/THIRD_PARTY_LICENSES/README.md +71 -254
  4. data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
  5. data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
  6. data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
  7. data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
  8. data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
  9. data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
  10. data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
  11. data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
  12. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
  13. data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
  14. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
  15. data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
  16. data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
  17. data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
  18. data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
  19. data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
  20. data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
  21. data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
  22. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
  23. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
  24. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
  25. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
  26. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
  27. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
  28. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
  29. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
  30. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
  31. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
  32. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
  33. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
  34. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
  35. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
  36. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
  37. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
  38. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
  39. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
  40. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
  41. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
  42. data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
  43. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
  44. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
  45. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
  46. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
  47. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
  48. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
  49. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
  50. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
  51. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
  52. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
  53. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
  54. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
  55. data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
  56. data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
  57. data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
  58. data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
  59. data/UPSTREAM.md +7 -5
  60. data/ext/cfsolve/Cargo.lock +534 -1727
  61. data/ext/cfsolve/Cargo.toml +4 -0
  62. data/ext/cfsolve/src/main.rs +1 -1
  63. data/lib/cfsolve/profiles/safari-26-ios/answers.json +266 -265
  64. data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
  65. data/lib/cfsolve/profiles/safari-26-ios.json +106 -152
  66. data/lib/cfsolve/version.rb +2 -2
  67. data/vendor/cfsolve/Cargo.lock +561 -1729
  68. data/vendor/cfsolve/Cargo.toml +26 -8
  69. data/vendor/cfsolve/README.md +4 -0
  70. data/vendor/cfsolve/examples/check_answers.rs +2 -2
  71. data/vendor/cfsolve/examples/compare_session.rs +1 -2
  72. data/vendor/cfsolve/examples/solver_profile.rs +84 -0
  73. data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
  74. data/vendor/cfsolve/examples/stage2_snapshot.rs +2 -2
  75. data/vendor/cfsolve/examples/tls_echo.rs +3 -3
  76. data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
  77. data/vendor/cfsolve/profiles/safari-26-ios/answers.json +266 -265
  78. data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
  79. data/vendor/cfsolve/profiles/safari-26-ios.json +106 -152
  80. data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
  81. data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
  82. data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
  83. data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
  84. data/vendor/cfsolve/src/capture/proxy.rs +44 -13
  85. data/vendor/cfsolve/src/capture/sessions.rs +4 -3
  86. data/vendor/cfsolve/src/capture/upstream.rs +1 -1
  87. data/vendor/cfsolve/src/challenge/codec.rs +4 -2
  88. data/vendor/cfsolve/src/challenge/expression.rs +161 -117
  89. data/vendor/cfsolve/src/challenge/installed/audit.rs +11 -10
  90. data/vendor/cfsolve/src/challenge/installed.rs +13 -6
  91. data/vendor/cfsolve/src/challenge/merge.rs +120 -80
  92. data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
  93. data/vendor/cfsolve/src/challenge/payload.rs +69 -31
  94. data/vendor/cfsolve/src/challenge/program.rs +197 -178
  95. data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
  96. data/vendor/cfsolve/src/challenge/source.rs +151 -96
  97. data/vendor/cfsolve/src/challenge/state.rs +180 -148
  98. data/vendor/cfsolve/src/challenge/tally.rs +64 -50
  99. data/vendor/cfsolve/src/challenge.rs +1 -0
  100. data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
  101. data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
  102. data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
  103. data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
  104. data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
  105. data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
  106. data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
  107. data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
  108. data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
  109. data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
  110. data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
  111. data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
  112. data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
  113. data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
  114. data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
  115. data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
  116. data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
  117. data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +198 -203
  118. data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
  119. data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +338 -513
  120. data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
  121. data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
  122. data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
  123. data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
  124. data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
  125. data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
  126. data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
  127. data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +353 -327
  128. data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
  129. data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
  130. data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
  131. data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
  132. data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
  133. data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
  134. data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
  135. data/vendor/cfsolve/src/deobfuscate.rs +15 -11
  136. data/vendor/cfsolve/src/embedding_page/extra_params.rs +23 -18
  137. data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
  138. data/vendor/cfsolve/src/error.rs +40 -5
  139. data/vendor/cfsolve/src/fingerprint.rs +8 -2
  140. data/vendor/cfsolve/src/http/client.rs +7 -10
  141. data/vendor/cfsolve/src/http/requests.rs +2 -2
  142. data/vendor/cfsolve/src/js/ast.rs +479 -263
  143. data/vendor/cfsolve/src/lib.rs +1 -0
  144. data/vendor/cfsolve/src/listing/fold.rs +19 -9
  145. data/vendor/cfsolve/src/listing/query.rs +1 -47
  146. data/vendor/cfsolve/src/performance_clock.rs +20 -1
  147. data/vendor/cfsolve/src/profiling.rs +49 -0
  148. data/vendor/cfsolve/src/script.rs +35 -24
  149. data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
  150. data/vendor/cfsolve/src/session/channel.rs +2 -2
  151. data/vendor/cfsolve/src/session/initial.rs +5 -5
  152. data/vendor/cfsolve/src/session/sink.rs +26 -1
  153. data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
  154. data/vendor/cfsolve/src/session.rs +1 -1
  155. data/vendor/cfsolve/src/solver.rs +3 -1
  156. data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
  157. data/vendor/cfsolve/src/stage2/analysis/envelope.rs +2 -1
  158. data/vendor/cfsolve/src/stage2/audit_globals.rs +142 -74
  159. data/vendor/cfsolve/src/stage2/benchmark.rs +62 -31
  160. data/vendor/cfsolve/src/stage2/call_stack.rs +1415 -1025
  161. data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
  162. data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
  163. data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
  164. data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -4
  165. data/vendor/cfsolve/src/stage2/payload/recover.rs +2 -2
  166. data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
  167. data/vendor/cfsolve/src/stage2/probes/performance.rs +12 -8
  168. data/vendor/cfsolve/src/stage2/queries.rs +50 -0
  169. data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
  170. data/vendor/cfsolve/src/stage2/trace.rs +134 -108
  171. data/vendor/cfsolve/src/stage2/vocabulary.rs +1 -11
  172. data/vendor/cfsolve/src/stage2.rs +2 -0
  173. data/vendor/cfsolve/src/vm/disassemble.rs +7 -3
  174. data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
  175. data/vendor/cfsolve/src/vm/extract.rs +347 -250
  176. data/vendor/cfsolve/src/vm/interpret/access.rs +63 -48
  177. data/vendor/cfsolve/src/vm/interpret/builtin.rs +10 -10
  178. data/vendor/cfsolve/src/vm/interpret/call.rs +116 -52
  179. data/vendor/cfsolve/src/vm/interpret/compile.rs +79 -62
  180. data/vendor/cfsolve/src/vm/interpret/copies.rs +2 -2
  181. data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +63 -42
  182. data/vendor/cfsolve/src/vm/interpret/evaluate.rs +65 -575
  183. data/vendor/cfsolve/src/vm/interpret/explore.rs +7 -10
  184. data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
  185. data/vendor/cfsolve/src/vm/interpret/frozen.rs +3 -5
  186. data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +123 -59
  187. data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
  188. data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
  189. data/vendor/cfsolve/src/vm/interpret/pattern.rs +1736 -0
  190. data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
  191. data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
  192. data/vendor/cfsolve/src/vm/interpret/run.rs +116 -45
  193. data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
  194. data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
  195. data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
  196. data/vendor/cfsolve/src/vm/interpret.rs +9 -1
  197. data/vendor/cfsolve/src/vm/machine.rs +56 -49
  198. data/vendor/cfsolve/src/vm/output.rs +13 -5
  199. data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
  200. data/vendor/cfsolve/src/vm/session.rs +185 -120
  201. data/vendor/cfsolve/src/vm/value.rs +22 -19
  202. data/vendor/cfsolve/src/vm.rs +2 -1
  203. data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
  204. data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
  205. metadata +94 -178
  206. data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
  207. data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
  208. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
  209. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
  210. data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
  211. data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
  212. data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
  213. data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
  214. data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
  215. data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
  216. data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
  217. data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
  218. data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
  219. data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
  220. data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
  221. data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
  222. data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
  223. data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
  224. data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
  225. data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
  226. data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
  227. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
  228. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
  229. data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
  230. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
  231. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
  232. data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
  233. data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
  234. data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
  235. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
  236. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
  237. data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
  238. data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
  239. data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
  240. data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
  241. data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
  242. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
  243. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
  244. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
  245. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
  246. data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
  247. data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
  248. data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
  249. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
  250. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
  251. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
  252. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
  253. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
  254. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
  255. data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
  256. data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
  257. data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
  258. data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
  259. data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
  260. data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
  261. data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
  262. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
  263. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
  264. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
  265. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
  266. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
  267. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
  268. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
  269. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
  270. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
  271. data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
  272. data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
  273. data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
  274. data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
  275. data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
  276. data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
  277. data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
  278. data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
  279. data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
  280. data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
  281. data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
  282. data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
  283. data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
  284. data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
  285. data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
  286. data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
  287. data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
  288. data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
  289. data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
  290. data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
  291. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
  292. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
  293. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
  294. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
  295. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
  296. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
  297. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
  298. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
  299. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
  300. data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
  301. data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
  302. data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
  303. data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
  304. data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
  305. data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
  306. data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
  307. data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
  308. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
  309. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
  310. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
  311. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
  312. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
  313. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
  314. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
  315. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
  316. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
  317. data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
  318. data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
  319. data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
  320. data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
  321. data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
  322. data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
  323. data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
  324. data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
  325. data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
  326. data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
  327. data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
  328. data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
  329. data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
  330. data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
  331. data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
  332. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
  333. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
  334. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
  335. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
  336. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
  337. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
  338. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
  339. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
  340. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
  341. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
  342. data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
  343. data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
  344. data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
  345. /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
  346. /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
  347. /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
  348. /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
  349. /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
  350. /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
  351. /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
  352. /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
  353. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
  354. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
  355. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
  356. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
  357. /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
  358. /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
  359. /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
  360. /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
  361. /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
  362. /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
  363. /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
  364. /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
  365. /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
  366. /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
  367. /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
  368. /data/THIRD_PARTY_LICENSES/{cargo-platform-0.1.9 → zmij_ecma-1.0.23}/LICENSE-MIT +0 -0
@@ -7,13 +7,13 @@ use std::hash::Hash;
7
7
  use std::mem;
8
8
  use std::rc::Rc;
9
9
 
10
- use swc_core::atoms::Atom;
11
- use swc_core::ecma::ast::{BinaryOp, UnaryOp};
10
+ use oxc::syntax::operator::{BinaryOperator, UnaryOperator};
12
11
 
13
12
  use super::builtin;
14
13
  use super::copies::{self, Copies, Fork};
15
14
  use super::explore::Invocation;
16
15
  use super::frozen::{self, Frozen};
16
+ use crate::js::ast::{Binding, Script};
17
17
  use crate::vm::output::{Constant, Effect, Exit, Path, Position, Term};
18
18
  use crate::vm::session::Session;
19
19
  use crate::vm::value::{Callable, Env, Scope, Value};
@@ -44,8 +44,8 @@ pub(super) type Evaluation<'ast, T> = Result<T, Box<Stop<'ast>>>;
44
44
  pub(super) enum Flow<'ast> {
45
45
  Normal,
46
46
  Return(Value<'ast>),
47
- Break(Option<Atom>),
48
- Continue(Option<Atom>),
47
+ Break(Option<&'ast str>),
48
+ Continue(Option<&'ast str>),
49
49
  }
50
50
 
51
51
  pub(crate) struct Run<'ast, 'session> {
@@ -61,10 +61,10 @@ pub(crate) struct Run<'ast, 'session> {
61
61
  /// Instance fields this run has read or written.
62
62
  pub(super) fields: HashMap<String, Value<'ast>>,
63
63
  /// Session bindings this run has read or written.
64
- pub(super) globals: HashMap<Atom, Value<'ast>>,
65
- /// Names unavailable after interrupted setup, with their errors. Setup copies the
64
+ pub(super) globals: HashMap<Binding<'ast>, Value<'ast>>,
65
+ /// Bindings unavailable after interrupted setup, with their errors. Setup copies the
66
66
  /// session's map when it changes it.
67
- pub(super) unavailable: Cow<'session, HashMap<Atom, String>>,
67
+ pub(super) unavailable: Cow<'session, HashMap<Binding<'ast>, String>>,
68
68
  /// Copies isolate session objects; absent while building the session.
69
69
  copies: Option<Copies<'ast>>,
70
70
  pub(super) frames: Vec<Frame<'ast>>,
@@ -150,22 +150,22 @@ struct Polarity<'term> {
150
150
 
151
151
  #[derive(PartialEq)]
152
152
  enum Base<'term> {
153
- Binary(BinaryOp, &'term Term, &'term Term),
153
+ Binary(BinaryOperator, &'term Term, &'term Term),
154
154
  Other(&'term Term),
155
155
  }
156
156
 
157
157
  impl<'term> Polarity<'term> {
158
158
  fn of(mut term: &'term Term) -> Self {
159
159
  let mut negated = false;
160
- while let Term::Unary(UnaryOp::Bang, inner) = term {
160
+ while let Term::Unary(UnaryOperator::LogicalNot, inner) = term {
161
161
  term = inner;
162
162
  negated = !negated;
163
163
  }
164
164
  let base = match term {
165
165
  Term::Binary(operator, left, right) => {
166
166
  let (operator, inequality) = match operator {
167
- BinaryOp::NotEqEq => (BinaryOp::EqEqEq, true),
168
- BinaryOp::NotEq => (BinaryOp::EqEq, true),
167
+ BinaryOperator::StrictInequality => (BinaryOperator::StrictEquality, true),
168
+ BinaryOperator::Inequality => (BinaryOperator::Equality, true),
169
169
  operator => (*operator, false),
170
170
  };
171
171
  negated ^= inequality;
@@ -214,22 +214,76 @@ pub(super) struct Checkpoint {
214
214
  enum Undo<'ast> {
215
215
  Register(u8, Option<Value<'ast>>),
216
216
  Field(String, Option<Value<'ast>>),
217
- Global(Atom, Option<Value<'ast>>),
217
+ Global(Binding<'ast>, Option<Value<'ast>>),
218
218
  }
219
219
 
220
220
  /// Active call receiver and local scope.
221
221
  pub(super) struct Frame<'ast> {
222
222
  pub(super) this: Value<'ast>,
223
- pub(super) scope: Scope<'ast>,
223
+ pub(super) scope: CallScope<'ast>,
224
+ }
225
+
226
+ /// A call's own scope. Most slot-plan calls never store a variable in it, so it is created
227
+ /// on first use. Until then, the call sees exactly the variables of the scope it would enclose.
228
+ pub(super) enum CallScope<'ast> {
229
+ Own(Scope<'ast>),
230
+ /// Not yet created; it would enclose this scope.
231
+ Deferred(Option<Scope<'ast>>),
232
+ }
233
+
234
+ impl<'ast> CallScope<'ast> {
235
+ fn fork(&self, fork: &mut Fork<'_, 'ast>) -> Self {
236
+ match self {
237
+ Self::Own(scope) => Self::Own(fork.scope(scope)),
238
+ Self::Deferred(outer) => Self::Deferred(outer.as_ref().map(|outer| fork.scope(outer))),
239
+ }
240
+ }
224
241
  }
225
242
 
226
243
  impl<'ast> Frame<'ast> {
227
244
  pub(super) fn new(this: Value<'ast>) -> Self {
228
245
  Self {
229
246
  this,
230
- scope: Env::scope(HashMap::default(), None),
247
+ scope: CallScope::Deferred(None),
248
+ }
249
+ }
250
+
251
+ /// The call's own scope, creating it if needed.
252
+ pub(super) fn own_scope(&mut self) -> &Scope<'ast> {
253
+ if let CallScope::Deferred(outer) = &mut self.scope {
254
+ self.scope = CallScope::Own(Env::scope(HashMap::default(), outer.take()));
255
+ }
256
+ let CallScope::Own(scope) = &self.scope else {
257
+ unreachable!("the scope was just created");
258
+ };
259
+ scope
260
+ }
261
+
262
+ /// The scope enclosing the call's own variables, if the call has any.
263
+ fn visible(&self) -> Option<&Scope<'ast>> {
264
+ match &self.scope {
265
+ CallScope::Own(scope) => Some(scope),
266
+ CallScope::Deferred(outer) => outer.as_ref(),
231
267
  }
232
268
  }
269
+
270
+ pub(super) fn find(&self, binding: Binding<'ast>) -> Option<Value<'ast>> {
271
+ Env::find(self.visible()?, binding)
272
+ }
273
+
274
+ /// Assigns `binding` in the nearest scope containing it, as [`Env::assign`] does.
275
+ pub(super) fn assign(&self, binding: Binding<'ast>, value: Value<'ast>) -> Option<Value<'ast>> {
276
+ match self.visible() {
277
+ Some(scope) => Env::assign(scope, binding, value),
278
+ None => Some(value),
279
+ }
280
+ }
281
+
282
+ /// Whether the call itself declares `binding`.
283
+ pub(super) fn declares(&self, binding: Binding<'ast>) -> bool {
284
+ matches!(&self.scope, CallScope::Own(scope)
285
+ if scope.borrow().variables.contains_key(&binding))
286
+ }
233
287
  }
234
288
 
235
289
  impl<'ast, 'session> Run<'ast, 'session> {
@@ -321,6 +375,11 @@ impl<'ast, 'session> Run<'ast, 'session> {
321
375
  run
322
376
  }
323
377
 
378
+ /// The script whose code the run interprets.
379
+ pub(in crate::vm) fn source(&self) -> Script<'ast> {
380
+ self.session.script
381
+ }
382
+
324
383
  /// The path this run took, or why the handler rejected its operands.
325
384
  pub(super) fn finish(mut self, outcome: Evaluation<'ast, Value<'ast>>) -> Result<Path, String> {
326
385
  self.session.spare.replace(mem::take(&mut self.spare));
@@ -407,7 +466,7 @@ impl<'ast, 'session> Run<'ast, 'session> {
407
466
  /// Records that an expression equals a constant after a true strict equality test or a false
408
467
  /// strict inequality test.
409
468
  fn learn(&mut self, mut condition: &Term, mut holds: bool) {
410
- while let Term::Unary(UnaryOp::Bang, inner) = condition {
469
+ while let Term::Unary(UnaryOperator::LogicalNot, inner) = condition {
411
470
  condition = inner;
412
471
  holds = !holds;
413
472
  }
@@ -415,8 +474,8 @@ impl<'ast, 'session> Run<'ast, 'session> {
415
474
  return;
416
475
  };
417
476
  let equal = match operator {
418
- BinaryOp::EqEqEq => holds,
419
- BinaryOp::NotEqEq => !holds,
477
+ BinaryOperator::StrictEquality => holds,
478
+ BinaryOperator::StrictInequality => !holds,
420
479
  _ => return,
421
480
  };
422
481
  if equal
@@ -451,44 +510,54 @@ impl<'ast, 'session> Run<'ast, 'session> {
451
510
  self.frames.last().expect("code runs inside a frame")
452
511
  }
453
512
 
454
- /// Declares `name` in the active call's scope.
455
- pub(super) fn declare(&mut self, name: Atom, value: Value<'ast>) {
456
- self.frame()
457
- .scope
513
+ pub(super) fn frame_mut(&mut self) -> &mut Frame<'ast> {
514
+ self.frames.last_mut().expect("code runs inside a frame")
515
+ }
516
+
517
+ /// Declares `binding` in the active call's scope.
518
+ pub(super) fn declare(&mut self, binding: Binding<'ast>, value: Value<'ast>) {
519
+ self.frame_mut()
520
+ .own_scope()
458
521
  .borrow_mut()
459
522
  .variables
460
- .insert(name, value);
523
+ .insert(binding, value);
461
524
  }
462
525
 
463
- pub(super) fn lookup(&mut self, name: &Atom) -> Evaluation<'ast, Value<'ast>> {
464
- if let Some(value) = Env::find(&self.frame().scope, name) {
526
+ /// Reads `binding` from the scopes, then from session bindings and functions declared
527
+ /// beside the class. A binding none of them hold, such as a parameter of a function
528
+ /// enclosing the VM, reads as the global of its name, as an unresolved reference does.
529
+ pub(super) fn lookup(&mut self, binding: Binding<'ast>) -> Evaluation<'ast, Value<'ast>> {
530
+ if let Some(value) = self.frame().find(binding) {
465
531
  return Ok(value);
466
532
  }
467
- if let Some(value) = self.globals.get(name) {
533
+ if let Some(value) = self.globals.get(&binding) {
468
534
  return Ok(value.clone());
469
535
  }
470
- if let Some(reason) = self.unavailable.get(name) {
536
+ let name = self.session.script.name(binding);
537
+ if let Some(reason) = self.unavailable.get(&binding) {
471
538
  return Err(Stop::unsupported(&format!(
472
539
  "{name}, whose setup stopped: {reason}"
473
540
  )));
474
541
  }
475
- if let Some(value) = self.session.bindings.get(name) {
542
+ if let Some(value) = self.session.bindings.get(&binding) {
476
543
  let value = self.isolate(value);
477
- self.set_global(name.clone(), value.clone());
544
+ self.set_global(binding, value.clone());
478
545
  return Ok(value);
479
546
  }
480
- if let Some(function) = self.session.functions.get(name) {
547
+ if let Binding::Symbol(symbol) = binding
548
+ && let Some(&function) = self.session.functions.get(&symbol)
549
+ {
481
550
  let mut values = self.session.function_values.borrow_mut();
482
- let value = values.entry(name.clone()).or_insert_with(|| {
551
+ let value = values.entry(symbol).or_insert_with(|| {
483
552
  Value::function(Callable::Script {
484
- name: Some(name.clone()),
553
+ name: Some(name),
485
554
  function,
486
555
  scope: None,
487
556
  })
488
557
  });
489
558
  return Ok(value.clone());
490
559
  }
491
- Ok(match &**name {
560
+ Ok(match name {
492
561
  "undefined" => Value::Undefined,
493
562
  "NaN" => Value::Number(f64::NAN),
494
563
  "Infinity" => Value::Number(f64::INFINITY),
@@ -497,15 +566,17 @@ impl<'ast, 'session> Run<'ast, 'session> {
497
566
  })
498
567
  }
499
568
 
500
- pub(super) fn assign_name(&mut self, name: &Atom, value: Value<'ast>) {
501
- let Some(value) = Env::assign(&self.frame().scope, name, value) else {
569
+ /// Assigns `binding` in the nearest scope holding it, or else the session binding. Otherwise
570
+ /// declares it in the active call's scope.
571
+ pub(super) fn assign(&mut self, binding: Binding<'ast>, value: Value<'ast>) {
572
+ let Some(value) = self.frame().assign(binding, value) else {
502
573
  return;
503
574
  };
504
- if self.globals.contains_key(name) || self.session.bindings.contains_key(name) {
505
- self.set_global(name.clone(), value);
575
+ if self.globals.contains_key(&binding) || self.session.bindings.contains_key(&binding) {
576
+ self.set_global(binding, value);
506
577
  return;
507
578
  }
508
- self.declare(name.clone(), value);
579
+ self.declare(binding, value);
509
580
  }
510
581
 
511
582
  /// Returns an instance field from the current run or the constructor's initial value.
@@ -538,9 +609,9 @@ impl<'ast, 'session> Run<'ast, 'session> {
538
609
  }
539
610
  }
540
611
 
541
- fn set_global(&mut self, name: Atom, value: Value<'ast>) {
542
- let old = self.globals.insert(name.clone(), value);
543
- self.journal.record(Undo::Global(name, old));
612
+ fn set_global(&mut self, binding: Binding<'ast>, value: Value<'ast>) {
613
+ let old = self.globals.insert(binding, value);
614
+ self.journal.record(Undo::Global(binding, old));
544
615
  }
545
616
 
546
617
  /// Starts a speculative attempt. [`Run::restore`] rolls it back; [`Run::release`] commits
@@ -597,7 +668,7 @@ impl<'ast, 'session> Run<'ast, 'session> {
597
668
 
598
669
  /// Returns the scope that a newly created function would capture.
599
670
  pub(super) fn closure_scope(&mut self) -> Scope<'ast> {
600
- let scope = self.frame().scope.clone();
671
+ let scope = self.frame_mut().own_scope().clone();
601
672
  if !self
602
673
  .closed
603
674
  .last()
@@ -683,7 +754,7 @@ impl<'ast, 'session> Run<'ast, 'session> {
683
754
  .map(|(term, value)| (term.clone(), fork.value(value)))
684
755
  .collect(),
685
756
  this: fork.value(&frame.this),
686
- scope: fork.scope(&frame.scope),
757
+ scope: frame.scope.fork(&mut fork),
687
758
  locals: locals
688
759
  .iter()
689
760
  .map(|local| local.as_ref().map(|value| fork.value(value)))
@@ -723,7 +794,7 @@ impl<'ast, 'session> Run<'ast, 'session> {
723
794
  .collect();
724
795
  run.frames.push(Frame {
725
796
  this: fork.value(&snapshot.this),
726
- scope: fork.scope(&snapshot.scope),
797
+ scope: snapshot.scope.fork(&mut fork),
727
798
  });
728
799
  let locals = snapshot
729
800
  .locals
@@ -745,7 +816,7 @@ pub(super) struct Snapshot<'ast> {
745
816
  registers: HashMap<u8, Value<'ast>>,
746
817
  tags: HashMap<u8, Value<'ast>>,
747
818
  fields: HashMap<String, Value<'ast>>,
748
- globals: HashMap<Atom, Value<'ast>>,
819
+ globals: HashMap<Binding<'ast>, Value<'ast>>,
749
820
  copies: Option<Copies<'ast>>,
750
821
  closed: Vec<Scope<'ast>>,
751
822
  effects: Vec<Effect>,
@@ -753,7 +824,7 @@ pub(super) struct Snapshot<'ast> {
753
824
  conditions: Vec<(Term, bool)>,
754
825
  facts: Vec<(Term, Value<'ast>)>,
755
826
  this: Value<'ast>,
756
- scope: Scope<'ast>,
827
+ scope: CallScope<'ast>,
757
828
  locals: Vec<Option<Value<'ast>>>,
758
829
  /// Every scope the snapshot holds, cleared when it is dropped to break cycles.
759
830
  copied: Vec<Scope<'ast>>,
@@ -5,8 +5,7 @@ use std::cell::RefCell;
5
5
  use std::rc::Rc;
6
6
  use std::{mem, ops};
7
7
 
8
- use swc_core::ecma::ast::{BinaryOp, UnaryOp};
9
- use swc_ecma_utils::number::{JsNumber, ToJsString};
8
+ use oxc::syntax::operator::{BinaryOperator, UnaryOperator};
10
9
 
11
10
  use crate::js;
12
11
  use crate::vm::HashMap;
@@ -71,17 +70,17 @@ fn type_of<'a>(value: &Value<'_>) -> Option<Value<'a>> {
71
70
  Some(Value::String(string))
72
71
  }
73
72
 
74
- pub(super) fn unary_value<'a>(operator: UnaryOp, argument: Value<'a>) -> Value<'a> {
73
+ pub(super) fn unary_value<'a>(operator: UnaryOperator, argument: Value<'a>) -> Value<'a> {
75
74
  let concrete = match operator {
76
- UnaryOp::Bang => argument.truthy().map(|truthy| Value::Bool(!truthy)),
77
- UnaryOp::Minus => argument.number().map(|number| Value::Number(-number)),
78
- UnaryOp::Plus => argument.number().map(Value::Number),
79
- UnaryOp::Tilde => argument
75
+ UnaryOperator::LogicalNot => argument.truthy().map(|truthy| Value::Bool(!truthy)),
76
+ UnaryOperator::UnaryNegation => argument.number().map(|number| Value::Number(-number)),
77
+ UnaryOperator::UnaryPlus => argument.number().map(Value::Number),
78
+ UnaryOperator::BitwiseNot => argument
80
79
  .number()
81
80
  .map(|number| Value::Number(js::bit_not(number))),
82
- UnaryOp::TypeOf => type_of(&argument),
83
- UnaryOp::Void => Some(Value::Undefined),
84
- UnaryOp::Delete => unreachable!("delete needs its operand's reference"),
81
+ UnaryOperator::Typeof => type_of(&argument),
82
+ UnaryOperator::Void => Some(Value::Undefined),
83
+ UnaryOperator::Delete => unreachable!("delete needs its operand's reference"),
85
84
  };
86
85
  concrete
87
86
  .filter(|_| !argument.is_symbolic())
@@ -129,10 +128,14 @@ pub(super) fn same_value_zero<'a>(left: &Value<'a>, right: &Value<'a>) -> Option
129
128
  }
130
129
  }
131
130
 
132
- pub(super) fn binary_value<'a>(operator: BinaryOp, left: Value<'a>, right: Value<'a>) -> Value<'a> {
131
+ pub(super) fn binary_value<'a>(
132
+ operator: BinaryOperator,
133
+ left: Value<'a>,
134
+ right: Value<'a>,
135
+ ) -> Value<'a> {
133
136
  // Take ownership of the left string so concatenation can grow it in place.
134
137
  let left = match (operator, left) {
135
- (BinaryOp::Add, Value::String(string)) => match text(&right) {
138
+ (BinaryOperator::Addition, Value::String(string)) => match text(&right) {
136
139
  Some(suffix) => return Value::String(string.concat(&suffix)),
137
140
  None => Value::String(string),
138
141
  },
@@ -143,7 +146,10 @@ pub(super) fn binary_value<'a>(operator: BinaryOp, left: Value<'a>, right: Value
143
146
  // `undefined === r` and `r === undefined` are one condition.
144
147
  let symmetric = matches!(
145
148
  operator,
146
- BinaryOp::EqEqEq | BinaryOp::NotEqEq | BinaryOp::EqEq | BinaryOp::NotEq
149
+ BinaryOperator::StrictEquality
150
+ | BinaryOperator::StrictInequality
151
+ | BinaryOperator::Equality
152
+ | BinaryOperator::Inequality
147
153
  );
148
154
  if symmetric && matches!(left, Term::Const(_)) && !matches!(right, Term::Const(_)) {
149
155
  mem::swap(&mut left, &mut right);
@@ -153,7 +159,7 @@ pub(super) fn binary_value<'a>(operator: BinaryOp, left: Value<'a>, right: Value
153
159
  }
154
160
 
155
161
  fn concrete_binary<'a>(
156
- operator: BinaryOp,
162
+ operator: BinaryOperator,
157
163
  left: &Value<'a>,
158
164
  right: &Value<'a>,
159
165
  ) -> Option<Value<'a>> {
@@ -161,13 +167,10 @@ fn concrete_binary<'a>(
161
167
  return None;
162
168
  }
163
169
  let numbers = || Some((left.number()?, right.number()?));
164
- // JavaScript's numeric operators, applied to both operands as numbers.
165
- let arithmetic =
166
- |operator: fn(f64, f64) -> f64| numbers().map(|(a, b)| Value::Number(operator(a, b)));
167
170
  Some(match operator {
168
- BinaryOp::EqEqEq => Value::Bool(strict_equal(left, right)?),
169
- BinaryOp::NotEqEq => Value::Bool(!strict_equal(left, right)?),
170
- BinaryOp::EqEq | BinaryOp::NotEq => {
171
+ BinaryOperator::StrictEquality => Value::Bool(strict_equal(left, right)?),
172
+ BinaryOperator::StrictInequality => Value::Bool(!strict_equal(left, right)?),
173
+ BinaryOperator::Equality | BinaryOperator::Inequality => {
171
174
  let equal = match (left, right) {
172
175
  (Value::Undefined | Value::Null, Value::Undefined | Value::Null) => true,
173
176
  (Value::Undefined | Value::Null, _) | (_, Value::Undefined | Value::Null) => false,
@@ -182,9 +185,9 @@ fn concrete_binary<'a>(
182
185
  a == b
183
186
  }
184
187
  };
185
- Value::Bool(equal == (operator == BinaryOp::EqEq))
188
+ Value::Bool(equal == (operator == BinaryOperator::Equality))
186
189
  }
187
- BinaryOp::Add => match (left, right) {
190
+ BinaryOperator::Addition => match (left, right) {
188
191
  // A string operand triggers string conversion of both operands, in evaluation
189
192
  // order.
190
193
  (Value::String(_), _) | (_, Value::String(_)) => {
@@ -195,7 +198,10 @@ fn concrete_binary<'a>(
195
198
  Value::Number(a + b)
196
199
  }
197
200
  },
198
- BinaryOp::Lt | BinaryOp::LtEq | BinaryOp::Gt | BinaryOp::GtEq => {
201
+ BinaryOperator::LessThan
202
+ | BinaryOperator::LessEqualThan
203
+ | BinaryOperator::GreaterThan
204
+ | BinaryOperator::GreaterEqualThan => {
199
205
  // Compare two strings by UTF-16 code units; otherwise compare numbers.
200
206
  let ordering = match (left, right) {
201
207
  (Value::String(a), Value::String(b)) => Some(a.cmp(b)),
@@ -205,13 +211,17 @@ fn concrete_binary<'a>(
205
211
  }
206
212
  };
207
213
  Value::Bool(ordering.is_some_and(|ordering| match operator {
208
- BinaryOp::Lt => ordering.is_lt(),
209
- BinaryOp::LtEq => ordering.is_le(),
210
- BinaryOp::Gt => ordering.is_gt(),
214
+ BinaryOperator::LessThan => ordering.is_lt(),
215
+ BinaryOperator::LessEqualThan => ordering.is_le(),
216
+ BinaryOperator::GreaterThan => ordering.is_gt(),
211
217
  _ => ordering.is_ge(),
212
218
  }))
213
219
  }
214
- operator => arithmetic(numeric(operator)?)?,
220
+ // JavaScript's numeric operators, applied to both operands as numbers.
221
+ operator => {
222
+ let operation = numeric(operator)?;
223
+ numbers().map(|(a, b)| Value::Number(operation(a, b)))?
224
+ }
215
225
  })
216
226
  }
217
227
 
@@ -219,30 +229,44 @@ fn concrete_binary<'a>(
219
229
  /// Returns `None` for other operators.
220
230
  #[inline]
221
231
  #[must_use]
222
- pub(crate) fn numeric(operator: BinaryOp) -> Option<fn(f64, f64) -> f64> {
232
+ pub(crate) fn numeric(operator: BinaryOperator) -> Option<fn(f64, f64) -> f64> {
223
233
  let operation: fn(f64, f64) -> f64 = match operator {
224
- BinaryOp::Add => ops::Add::add,
225
- BinaryOp::Sub => ops::Sub::sub,
226
- BinaryOp::Mul => ops::Mul::mul,
227
- BinaryOp::Div => ops::Div::div,
228
- BinaryOp::Mod => ops::Rem::rem,
229
- BinaryOp::Exp => |a, b| *JsNumber::from(a).pow(b.into()),
230
- BinaryOp::BitAnd => js::bit_and,
231
- BinaryOp::BitOr => js::bit_or,
232
- BinaryOp::BitXor => js::bit_xor,
233
- BinaryOp::LShift => js::shl,
234
- BinaryOp::RShift => js::shr,
235
- BinaryOp::ZeroFillRShift => js::ushr,
234
+ BinaryOperator::Addition => ops::Add::add,
235
+ BinaryOperator::Subtraction => ops::Sub::sub,
236
+ BinaryOperator::Multiplication => ops::Mul::mul,
237
+ BinaryOperator::Division => ops::Div::div,
238
+ BinaryOperator::Remainder => ops::Rem::rem,
239
+ BinaryOperator::Exponential => exponentiate,
240
+ BinaryOperator::BitwiseAnd => js::bit_and,
241
+ BinaryOperator::BitwiseOR => js::bit_or,
242
+ BinaryOperator::BitwiseXOR => js::bit_xor,
243
+ BinaryOperator::ShiftLeft => js::shl,
244
+ BinaryOperator::ShiftRight => js::shr,
245
+ BinaryOperator::ShiftRightZeroFill => js::ushr,
236
246
  _ => return None,
237
247
  };
238
248
  Some(operation)
239
249
  }
240
250
 
251
+ /// `Number::exponentiate`: unlike `powf`, a NaN exponent gives NaN, and so does an infinite
252
+ /// exponent of a base with magnitude one.
253
+ pub(super) fn exponentiate(base: f64, exponent: f64) -> f64 {
254
+ if exponent.is_nan() || (base.abs() == 1.0 && exponent.is_infinite()) {
255
+ return f64::NAN;
256
+ }
257
+ base.powf(exponent)
258
+ }
259
+
260
+ /// `Number::toString` with radix 10.
261
+ pub(super) fn number_text(number: f64) -> String {
262
+ ryu_js::Buffer::new().format(number).to_owned()
263
+ }
264
+
241
265
  /// Applies `ToString` to a concrete primitive.
242
266
  pub(super) fn text(value: &Value<'_>) -> Option<JsString> {
243
267
  Some(match value {
244
268
  Value::String(string) => string.clone(),
245
- Value::Number(number) => JsString::from(&*number.to_js_string()),
269
+ Value::Number(number) => JsString::from(number_text(*number).as_str()),
246
270
  Value::Bool(value) => JsString::from(if *value { "true" } else { "false" }),
247
271
  Value::Undefined => JsString::from("undefined"),
248
272
  Value::Null => JsString::from("null"),
@@ -255,7 +279,7 @@ pub(super) fn text(value: &Value<'_>) -> Option<JsString> {
255
279
  pub(super) fn property_key(key: &Value<'_>) -> Option<String> {
256
280
  match key {
257
281
  Value::String(name) => name.text(),
258
- Value::Number(number) => Some(number.to_js_string()),
282
+ Value::Number(number) => Some(number_text(*number)),
259
283
  Value::Bool(value) => Some(value.to_string()),
260
284
  Value::Undefined => Some("undefined".into()),
261
285
  Value::Null => Some("null".into()),
@@ -267,7 +291,7 @@ pub(super) fn property_key(key: &Value<'_>) -> Option<String> {
267
291
  mod tests {
268
292
  use super::*;
269
293
 
270
- fn decide<'a>(operator: BinaryOp, left: &Value<'a>, right: &Value<'a>) -> bool {
294
+ fn decide<'a>(operator: BinaryOperator, left: &Value<'a>, right: &Value<'a>) -> bool {
271
295
  match concrete_binary(operator, left, right) {
272
296
  Some(Value::Bool(decided)) => decided,
273
297
  _ => panic!(
@@ -282,7 +306,8 @@ mod tests {
282
306
  /// point sorts after it. Nonstring operands compare numerically.
283
307
  #[test]
284
308
  fn strings_compare_by_code_units() {
285
- let less = |left: &str, right| decide(BinaryOp::Lt, &Value::string(left), &right);
309
+ let less =
310
+ |left: &str, right| decide(BinaryOperator::LessThan, &Value::string(left), &right);
286
311
  assert!(less("\u{1f1fa}", Value::string("\u{ff61}")));
287
312
  assert!(less("10", Value::string("9")));
288
313
  assert!(!less("10", Value::Number(9.0)));
@@ -291,7 +316,7 @@ mod tests {
291
316
  /// Object and symbol identity comparisons are concrete, requiring no symbolic condition.
292
317
  #[test]
293
318
  fn loose_equality_compares_objects_and_symbols_by_identity() {
294
- let equal = |left: &_, right: &_| decide(BinaryOp::EqEq, left, right);
319
+ let equal = |left: &_, right: &_| decide(BinaryOperator::Equality, left, right);
295
320
  let object = Value::Object(Rc::default());
296
321
  let other = Value::Object(Rc::default());
297
322
  let array = Value::array(Vec::new());
@@ -304,6 +329,6 @@ mod tests {
304
329
  assert!(!equal(&symbol, &Value::Symbol(Rc::new(()))));
305
330
  assert!(!equal(&symbol, &Value::string("x")));
306
331
  assert!(!equal(&symbol, &Value::Undefined));
307
- assert!(decide(BinaryOp::NotEq, &object, &other));
332
+ assert!(decide(BinaryOperator::Inequality, &object, &other));
308
333
  }
309
334
  }