cfsolve 0.1.2 → 0.1.4

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 (395) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +8 -3
  4. data/THIRD_PARTY_LICENSES/README.md +71 -254
  5. data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
  6. data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
  7. data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
  8. data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
  9. data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
  10. data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
  11. data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
  12. data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
  13. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
  14. data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
  15. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
  16. data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
  17. data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
  18. data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
  19. data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
  20. data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
  21. data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
  22. data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
  23. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
  24. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
  25. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
  26. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
  27. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
  28. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
  29. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
  30. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
  31. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
  32. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
  33. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
  34. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
  35. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
  36. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
  37. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
  38. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
  39. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
  40. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
  41. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
  42. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
  43. data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
  44. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
  45. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
  46. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
  47. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
  48. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
  49. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
  50. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
  51. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
  52. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
  53. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
  54. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
  55. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
  56. data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
  57. data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
  58. data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
  59. data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
  60. data/UPSTREAM.md +14 -6
  61. data/ext/cfsolve/Cargo.lock +534 -1727
  62. data/ext/cfsolve/Cargo.toml +4 -0
  63. data/ext/cfsolve/src/main.rs +1 -1
  64. data/lib/cfsolve/profiles/chrome-157-macos/answers.json +4777 -0
  65. data/lib/cfsolve/profiles/chrome-157-macos.json +613 -0
  66. data/lib/cfsolve/profiles/safari-26-ios/answers.json +266 -265
  67. data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
  68. data/lib/cfsolve/profiles/safari-26-ios.json +106 -152
  69. data/lib/cfsolve/version.rb +2 -2
  70. data/lib/cfsolve.rb +1 -1
  71. data/vendor/cfsolve/Cargo.lock +561 -1729
  72. data/vendor/cfsolve/Cargo.toml +26 -8
  73. data/vendor/cfsolve/README.md +57 -5
  74. data/vendor/cfsolve/examples/check_answers.rs +2 -2
  75. data/vendor/cfsolve/examples/compare_session.rs +1 -2
  76. data/vendor/cfsolve/examples/solver_profile.rs +84 -0
  77. data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
  78. data/vendor/cfsolve/examples/stage2_snapshot.rs +2 -2
  79. data/vendor/cfsolve/examples/tls_echo.rs +3 -3
  80. data/vendor/cfsolve/examples/turnstile_smoke.rs +58 -0
  81. data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
  82. data/vendor/cfsolve/profiles/chrome-157-macos/answers.json +4777 -0
  83. data/vendor/cfsolve/profiles/chrome-157-macos.json +613 -0
  84. data/vendor/cfsolve/profiles/safari-26-ios/answers.json +266 -265
  85. data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
  86. data/vendor/cfsolve/profiles/safari-26-ios.json +106 -152
  87. data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
  88. data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
  89. data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
  90. data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
  91. data/vendor/cfsolve/src/capture/proxy.rs +44 -13
  92. data/vendor/cfsolve/src/capture/sessions.rs +4 -3
  93. data/vendor/cfsolve/src/capture/upstream.rs +1 -1
  94. data/vendor/cfsolve/src/challenge/codec.rs +4 -2
  95. data/vendor/cfsolve/src/challenge/expression.rs +161 -117
  96. data/vendor/cfsolve/src/challenge/installed/audit.rs +11 -10
  97. data/vendor/cfsolve/src/challenge/installed.rs +13 -6
  98. data/vendor/cfsolve/src/challenge/merge.rs +120 -80
  99. data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
  100. data/vendor/cfsolve/src/challenge/payload.rs +69 -31
  101. data/vendor/cfsolve/src/challenge/program.rs +197 -178
  102. data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
  103. data/vendor/cfsolve/src/challenge/source.rs +151 -96
  104. data/vendor/cfsolve/src/challenge/state.rs +180 -148
  105. data/vendor/cfsolve/src/challenge/tally.rs +64 -50
  106. data/vendor/cfsolve/src/challenge.rs +1 -0
  107. data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
  108. data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
  109. data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
  110. data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
  111. data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
  112. data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
  113. data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
  114. data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
  115. data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
  116. data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
  117. data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
  118. data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
  119. data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
  120. data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
  121. data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
  122. data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
  123. data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
  124. data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +198 -203
  125. data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
  126. data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +338 -513
  127. data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
  128. data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
  129. data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
  130. data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
  131. data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
  132. data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
  133. data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
  134. data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +353 -327
  135. data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
  136. data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
  137. data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
  138. data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
  139. data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
  140. data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
  141. data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
  142. data/vendor/cfsolve/src/deobfuscate.rs +15 -11
  143. data/vendor/cfsolve/src/embedding_page/extra_params.rs +132 -24
  144. data/vendor/cfsolve/src/embedding_page/page.rs +41 -1
  145. data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
  146. data/vendor/cfsolve/src/error.rs +40 -5
  147. data/vendor/cfsolve/src/fingerprint.rs +8 -2
  148. data/vendor/cfsolve/src/http/client.rs +7 -10
  149. data/vendor/cfsolve/src/http/requests.rs +2 -2
  150. data/vendor/cfsolve/src/js/ast.rs +479 -263
  151. data/vendor/cfsolve/src/lib.rs +1 -0
  152. data/vendor/cfsolve/src/listing/fold.rs +19 -9
  153. data/vendor/cfsolve/src/listing/query.rs +1 -47
  154. data/vendor/cfsolve/src/performance_clock.rs +20 -1
  155. data/vendor/cfsolve/src/profiling.rs +49 -0
  156. data/vendor/cfsolve/src/script.rs +35 -24
  157. data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
  158. data/vendor/cfsolve/src/session/channel.rs +2 -2
  159. data/vendor/cfsolve/src/session/initial.rs +12 -11
  160. data/vendor/cfsolve/src/session/probes.rs +1 -0
  161. data/vendor/cfsolve/src/session/sink.rs +26 -1
  162. data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
  163. data/vendor/cfsolve/src/session.rs +1 -1
  164. data/vendor/cfsolve/src/solver.rs +3 -1
  165. data/vendor/cfsolve/src/stage2/analysis/analyze.rs +33 -4
  166. data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
  167. data/vendor/cfsolve/src/stage2/analysis/discovery.rs +13 -2
  168. data/vendor/cfsolve/src/stage2/analysis/envelope.rs +2 -1
  169. data/vendor/cfsolve/src/stage2/audit_globals.rs +142 -74
  170. data/vendor/cfsolve/src/stage2/benchmark.rs +113 -41
  171. data/vendor/cfsolve/src/stage2/call_stack.rs +1564 -1041
  172. data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
  173. data/vendor/cfsolve/src/stage2/fixtures/encoded_benchmark_worker.js +1 -0
  174. data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
  175. data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
  176. data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -4
  177. data/vendor/cfsolve/src/stage2/payload/recover.rs +2 -2
  178. data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
  179. data/vendor/cfsolve/src/stage2/probes/dates.rs +44 -0
  180. data/vendor/cfsolve/src/stage2/probes/parent_info_array.rs +326 -0
  181. data/vendor/cfsolve/src/stage2/probes/performance.rs +12 -8
  182. data/vendor/cfsolve/src/stage2/probes/stack.rs +117 -4
  183. data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +80 -2
  184. data/vendor/cfsolve/src/stage2/probes.rs +1 -0
  185. data/vendor/cfsolve/src/stage2/queries.rs +50 -0
  186. data/vendor/cfsolve/src/stage2/reference.rs +5 -0
  187. data/vendor/cfsolve/src/stage2/registry.rs +8 -2
  188. data/vendor/cfsolve/src/stage2/replay.rs +34 -3
  189. data/vendor/cfsolve/src/stage2/stylesheets.rs +35 -0
  190. data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
  191. data/vendor/cfsolve/src/stage2/trace.rs +134 -108
  192. data/vendor/cfsolve/src/stage2/value_labels.rs +185 -0
  193. data/vendor/cfsolve/src/stage2/vocabulary.rs +112 -17
  194. data/vendor/cfsolve/src/stage2.rs +3 -0
  195. data/vendor/cfsolve/src/vm/disassemble.rs +75 -7
  196. data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
  197. data/vendor/cfsolve/src/vm/encoded_names.rs +635 -0
  198. data/vendor/cfsolve/src/vm/extract.rs +550 -250
  199. data/vendor/cfsolve/src/vm/fixtures/free_functions/README.md +9 -0
  200. data/vendor/cfsolve/src/vm/fixtures/free_functions/machine.js +7438 -0
  201. data/vendor/cfsolve/src/vm/fixtures/free_functions/program.base64 +1 -0
  202. data/vendor/cfsolve/src/vm/interpret/access.rs +71 -50
  203. data/vendor/cfsolve/src/vm/interpret/builtin.rs +10 -10
  204. data/vendor/cfsolve/src/vm/interpret/call.rs +116 -52
  205. data/vendor/cfsolve/src/vm/interpret/compile.rs +79 -62
  206. data/vendor/cfsolve/src/vm/interpret/copies.rs +2 -2
  207. data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +63 -42
  208. data/vendor/cfsolve/src/vm/interpret/evaluate.rs +65 -575
  209. data/vendor/cfsolve/src/vm/interpret/explore.rs +7 -10
  210. data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
  211. data/vendor/cfsolve/src/vm/interpret/frozen.rs +3 -5
  212. data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +160 -58
  213. data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
  214. data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
  215. data/vendor/cfsolve/src/vm/interpret/pattern.rs +1765 -0
  216. data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
  217. data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +392 -0
  218. data/vendor/cfsolve/src/vm/interpret/run.rs +120 -45
  219. data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
  220. data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
  221. data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
  222. data/vendor/cfsolve/src/vm/interpret.rs +9 -1
  223. data/vendor/cfsolve/src/vm/machine.rs +116 -51
  224. data/vendor/cfsolve/src/vm/output.rs +19 -6
  225. data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
  226. data/vendor/cfsolve/src/vm/registers.rs +35 -21
  227. data/vendor/cfsolve/src/vm/session.rs +189 -121
  228. data/vendor/cfsolve/src/vm/value.rs +22 -19
  229. data/vendor/cfsolve/src/vm.rs +3 -1
  230. data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
  231. data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
  232. metadata +106 -178
  233. data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
  234. data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
  235. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
  236. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
  237. data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
  238. data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
  239. data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
  240. data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
  241. data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
  242. data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
  243. data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
  244. data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
  245. data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
  246. data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
  247. data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
  248. data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
  249. data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
  250. data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
  251. data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
  252. data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
  253. data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
  254. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
  255. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
  256. data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
  257. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
  258. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
  259. data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
  260. data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
  261. data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
  262. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
  263. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
  264. data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
  265. data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
  266. data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
  267. data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
  268. data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
  269. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
  270. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
  271. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
  272. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
  273. data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
  274. data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
  275. data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
  276. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
  277. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
  278. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
  279. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
  280. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
  281. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
  282. data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
  283. data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
  284. data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
  285. data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
  286. data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
  287. data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
  288. data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
  289. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
  290. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
  291. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
  292. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
  293. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
  294. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
  295. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
  296. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
  297. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
  298. data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
  299. data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
  300. data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
  301. data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
  302. data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
  303. data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
  304. data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
  305. data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
  306. data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
  307. data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
  308. data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
  309. data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
  310. data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
  311. data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
  312. data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
  313. data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
  314. data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
  315. data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
  316. data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
  317. data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
  318. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
  319. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
  320. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
  321. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
  322. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
  323. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
  324. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
  325. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
  326. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
  327. data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
  328. data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
  329. data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
  330. data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
  331. data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
  332. data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
  333. data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
  334. data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
  335. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
  336. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
  337. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
  338. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
  339. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
  340. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
  341. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
  342. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
  343. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
  344. data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
  345. data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
  346. data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
  347. data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
  348. data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
  349. data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
  350. data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
  351. data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
  352. data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
  353. data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
  354. data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
  355. data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
  356. data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
  357. data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
  358. data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
  359. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
  360. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
  361. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
  362. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
  363. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
  364. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
  365. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
  366. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
  367. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
  368. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
  369. data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
  370. data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
  371. data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
  372. /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
  373. /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
  374. /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
  375. /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
  376. /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
  377. /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
  378. /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
  379. /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
  380. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
  381. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
  382. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
  383. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
  384. /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
  385. /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
  386. /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
  387. /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
  388. /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
  389. /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
  390. /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
  391. /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
  392. /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
  393. /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
  394. /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
  395. /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,15 @@ 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
+
383
+ pub(in crate::vm) fn register_access(&self) -> crate::vm::registers::Access<'ast> {
384
+ self.session.register_access
385
+ }
386
+
324
387
  /// The path this run took, or why the handler rejected its operands.
325
388
  pub(super) fn finish(mut self, outcome: Evaluation<'ast, Value<'ast>>) -> Result<Path, String> {
326
389
  self.session.spare.replace(mem::take(&mut self.spare));
@@ -407,7 +470,7 @@ impl<'ast, 'session> Run<'ast, 'session> {
407
470
  /// Records that an expression equals a constant after a true strict equality test or a false
408
471
  /// strict inequality test.
409
472
  fn learn(&mut self, mut condition: &Term, mut holds: bool) {
410
- while let Term::Unary(UnaryOp::Bang, inner) = condition {
473
+ while let Term::Unary(UnaryOperator::LogicalNot, inner) = condition {
411
474
  condition = inner;
412
475
  holds = !holds;
413
476
  }
@@ -415,8 +478,8 @@ impl<'ast, 'session> Run<'ast, 'session> {
415
478
  return;
416
479
  };
417
480
  let equal = match operator {
418
- BinaryOp::EqEqEq => holds,
419
- BinaryOp::NotEqEq => !holds,
481
+ BinaryOperator::StrictEquality => holds,
482
+ BinaryOperator::StrictInequality => !holds,
420
483
  _ => return,
421
484
  };
422
485
  if equal
@@ -451,44 +514,54 @@ impl<'ast, 'session> Run<'ast, 'session> {
451
514
  self.frames.last().expect("code runs inside a frame")
452
515
  }
453
516
 
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
517
+ pub(super) fn frame_mut(&mut self) -> &mut Frame<'ast> {
518
+ self.frames.last_mut().expect("code runs inside a frame")
519
+ }
520
+
521
+ /// Declares `binding` in the active call's scope.
522
+ pub(super) fn declare(&mut self, binding: Binding<'ast>, value: Value<'ast>) {
523
+ self.frame_mut()
524
+ .own_scope()
458
525
  .borrow_mut()
459
526
  .variables
460
- .insert(name, value);
527
+ .insert(binding, value);
461
528
  }
462
529
 
463
- pub(super) fn lookup(&mut self, name: &Atom) -> Evaluation<'ast, Value<'ast>> {
464
- if let Some(value) = Env::find(&self.frame().scope, name) {
530
+ /// Reads `binding` from the scopes, then from session bindings and functions declared
531
+ /// beside the class. A binding none of them hold, such as a parameter of a function
532
+ /// enclosing the VM, reads as the global of its name, as an unresolved reference does.
533
+ pub(super) fn lookup(&mut self, binding: Binding<'ast>) -> Evaluation<'ast, Value<'ast>> {
534
+ if let Some(value) = self.frame().find(binding) {
465
535
  return Ok(value);
466
536
  }
467
- if let Some(value) = self.globals.get(name) {
537
+ if let Some(value) = self.globals.get(&binding) {
468
538
  return Ok(value.clone());
469
539
  }
470
- if let Some(reason) = self.unavailable.get(name) {
540
+ let name = self.session.script.name(binding);
541
+ if let Some(reason) = self.unavailable.get(&binding) {
471
542
  return Err(Stop::unsupported(&format!(
472
543
  "{name}, whose setup stopped: {reason}"
473
544
  )));
474
545
  }
475
- if let Some(value) = self.session.bindings.get(name) {
546
+ if let Some(value) = self.session.bindings.get(&binding) {
476
547
  let value = self.isolate(value);
477
- self.set_global(name.clone(), value.clone());
548
+ self.set_global(binding, value.clone());
478
549
  return Ok(value);
479
550
  }
480
- if let Some(function) = self.session.functions.get(name) {
551
+ if let Binding::Symbol(symbol) = binding
552
+ && let Some(&function) = self.session.functions.get(&symbol)
553
+ {
481
554
  let mut values = self.session.function_values.borrow_mut();
482
- let value = values.entry(name.clone()).or_insert_with(|| {
555
+ let value = values.entry(symbol).or_insert_with(|| {
483
556
  Value::function(Callable::Script {
484
- name: Some(name.clone()),
557
+ name: Some(name),
485
558
  function,
486
559
  scope: None,
487
560
  })
488
561
  });
489
562
  return Ok(value.clone());
490
563
  }
491
- Ok(match &**name {
564
+ Ok(match name {
492
565
  "undefined" => Value::Undefined,
493
566
  "NaN" => Value::Number(f64::NAN),
494
567
  "Infinity" => Value::Number(f64::INFINITY),
@@ -497,15 +570,17 @@ impl<'ast, 'session> Run<'ast, 'session> {
497
570
  })
498
571
  }
499
572
 
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 {
573
+ /// Assigns `binding` in the nearest scope holding it, or else the session binding. Otherwise
574
+ /// declares it in the active call's scope.
575
+ pub(super) fn assign(&mut self, binding: Binding<'ast>, value: Value<'ast>) {
576
+ let Some(value) = self.frame().assign(binding, value) else {
502
577
  return;
503
578
  };
504
- if self.globals.contains_key(name) || self.session.bindings.contains_key(name) {
505
- self.set_global(name.clone(), value);
579
+ if self.globals.contains_key(&binding) || self.session.bindings.contains_key(&binding) {
580
+ self.set_global(binding, value);
506
581
  return;
507
582
  }
508
- self.declare(name.clone(), value);
583
+ self.declare(binding, value);
509
584
  }
510
585
 
511
586
  /// Returns an instance field from the current run or the constructor's initial value.
@@ -538,9 +613,9 @@ impl<'ast, 'session> Run<'ast, 'session> {
538
613
  }
539
614
  }
540
615
 
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));
616
+ fn set_global(&mut self, binding: Binding<'ast>, value: Value<'ast>) {
617
+ let old = self.globals.insert(binding, value);
618
+ self.journal.record(Undo::Global(binding, old));
544
619
  }
545
620
 
546
621
  /// Starts a speculative attempt. [`Run::restore`] rolls it back; [`Run::release`] commits
@@ -597,7 +672,7 @@ impl<'ast, 'session> Run<'ast, 'session> {
597
672
 
598
673
  /// Returns the scope that a newly created function would capture.
599
674
  pub(super) fn closure_scope(&mut self) -> Scope<'ast> {
600
- let scope = self.frame().scope.clone();
675
+ let scope = self.frame_mut().own_scope().clone();
601
676
  if !self
602
677
  .closed
603
678
  .last()
@@ -683,7 +758,7 @@ impl<'ast, 'session> Run<'ast, 'session> {
683
758
  .map(|(term, value)| (term.clone(), fork.value(value)))
684
759
  .collect(),
685
760
  this: fork.value(&frame.this),
686
- scope: fork.scope(&frame.scope),
761
+ scope: frame.scope.fork(&mut fork),
687
762
  locals: locals
688
763
  .iter()
689
764
  .map(|local| local.as_ref().map(|value| fork.value(value)))
@@ -723,7 +798,7 @@ impl<'ast, 'session> Run<'ast, 'session> {
723
798
  .collect();
724
799
  run.frames.push(Frame {
725
800
  this: fork.value(&snapshot.this),
726
- scope: fork.scope(&snapshot.scope),
801
+ scope: snapshot.scope.fork(&mut fork),
727
802
  });
728
803
  let locals = snapshot
729
804
  .locals
@@ -745,7 +820,7 @@ pub(super) struct Snapshot<'ast> {
745
820
  registers: HashMap<u8, Value<'ast>>,
746
821
  tags: HashMap<u8, Value<'ast>>,
747
822
  fields: HashMap<String, Value<'ast>>,
748
- globals: HashMap<Atom, Value<'ast>>,
823
+ globals: HashMap<Binding<'ast>, Value<'ast>>,
749
824
  copies: Option<Copies<'ast>>,
750
825
  closed: Vec<Scope<'ast>>,
751
826
  effects: Vec<Effect>,
@@ -753,7 +828,7 @@ pub(super) struct Snapshot<'ast> {
753
828
  conditions: Vec<(Term, bool)>,
754
829
  facts: Vec<(Term, Value<'ast>)>,
755
830
  this: Value<'ast>,
756
- scope: Scope<'ast>,
831
+ scope: CallScope<'ast>,
757
832
  locals: Vec<Option<Value<'ast>>>,
758
833
  /// Every scope the snapshot holds, cleared when it is dropped to break cycles.
759
834
  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
  }