77 Commits
Author SHA1 Message Date
Thomas Weber 8ce06bc6a8 Import most of the forkphorus test suite (#303)
forkphorus has its own test suite, most of which are regression tests for real bugs in a real compiler so it may be worth testing against.

forkphorus-befunge-eratosthenes and forkphorus-string-functions are probably the most meaningful new test cases; at the very least i wouldn't have needed a new test case in #300 to see changes in snapshots if they were merged

The tests also add coverage for specializations like "delete 1 of list" that somehow weren't in the suite before?
2026-10-18 14:49:20 -05:00
Thomas Weber 0c8ce96233 Regenerate snapshots due to missing rebase before merge
3aca9363a3 was not rebased first so its new snapshots were missing changes from fd1cc6bb4f
2026-10-18 14:32:43 -05:00
Thomas Weber 3aca9363a3 Optimize jsexecute helpers (#389)
* replace Number.isNaN -> x !== x (see https://github.com/TurboWarp/scratch-vm/pull/367 for background on this though it matters less than expected)
 * optimize listGet for numbers
 * optimize listReplace for numbers
 * optimize listDelete for first and last items
 * optimize listContains / listIndexOf by hoisting work that would previously happened inside compareEqual many times
2026-10-18 13:29:37 -05:00
Thomas Weber ec5733a9e7 Remove yields from stop all and delete clone (#392) 2026-10-18 13:05:45 -05:00
Lu Yifei fd1cc6bb4f Compile non-yielding thread entry points as regular functions (#391) 2026-10-18 11:12:44 -05:00
Thomas Weber 55fd9b7c95 Fix compiler error when argument name is literal number (#387) 2026-10-11 19:29:56 -05:00
Thomas Weber 7d0d67ad9f Fix missing optimization passes on procedures with multiple variants (#383) 2026-10-11 17:09:05 -05:00
Thomas Weber a2441e3830 Manually inline toNotNaN (#384)
Safari's JIT enjoys this one a lot more.
2026-10-11 14:02:40 -05:00
Thomas Weber 042235b193 Fix tangent (#381)
fix https://github.com/TurboWarp/scratch-vm/issues/380
2026-10-05 20:50:07 -05:00
Thomas Weber 32b5428fab Fix casting constant boolean interpretable string to number (#371)
They both should convert to 0
Fixes https://github.com/TurboWarp/scratch-vm/issues/359
2026-10-03 02:46:40 -05:00
Thomas Weber 8c62a150e1 Fix isNotActuallyZero on very small numbers (#373)
Fixes https://github.com/TurboWarp/scratch-vm/issues/361
2026-10-03 02:33:43 -05:00
Thomas Weber 984e05f83e Fix type analysis of casts with partially matching input types (#369)
Fixes https://github.com/TurboWarp/scratch-vm/issues/356
2026-10-03 01:45:28 -05:00
Thomas Weber c5bf9c3266 Fix custom reporter exit state analysis (#368)
Fixes https://github.com/TurboWarp/scratch-vm/issues/358
2026-10-03 01:39:14 -05:00
Thomas Weber 7fefa6f666 Check for either input never being numbers first in OP_EQUALS
Fixes https://github.com/TurboWarp/scratch-vm/issues/311
2025-12-29 20:06:36 -06:00
Thomas Weber 0e5043d4dc Fix missing boolean cast in control_repeat_until
Fixes https://github.com/TurboWarp/scratch-vm/issues/317
2025-12-29 19:50:15 -06:00
Thomas Weber 7aa8930802 Fix incorrect types for sensing_of
They can return 0 if the sprite does not exist
Fixes https://github.com/TurboWarp/scratch-vm/issues/262
Closes https://github.com/TurboWarp/scratch-vm/pull/325
(this one uses a different fix and has tests)

There are broader issues about compiled sensing_of not handling dynamic
sprite create/delete. We should tackle that later. The other PR wouldn't
really fix this either.
2025-12-29 18:58:44 -06:00
Thomas Weber 9624ea5456 Compile looks_say and looks_think without compatibility layer 2025-12-04 21:38:16 -06:00
Thomas Weber 6f6845ba3c Fix all remaining negative zero bugs 2025-12-04 21:32:19 -06:00
Thomas Weber fd1b85589e Merge pull request #301 from TurboWarp/more-unnecessary-casts
Remove more unnecessary casts
2025-12-04 21:29:22 -06:00
Thomas Weber 8860e2d602 Fix repeat block iteration count not being optimizable in yielding loops 2025-10-12 11:16:25 -05:00
Thomas Weber eb0d678068 Only analyze repeat block inputs at the start of the loop 2025-10-12 11:12:05 -05:00
Thomas Weber 3b947da95e Remove unnecessary number index casts 2025-10-08 18:43:50 -05:00
Thomas Weber 67cb7cfc5d Remove unnecessary string casts 2025-10-08 18:42:43 -05:00
Thomas Weber 07309b6ebf Use more specific type for string length 2025-10-08 17:15:44 -05:00
Thomas Weber d09f82a2fe Add new test case that does some simple string operations 2025-10-08 17:15:24 -05:00
Thomas Weber 2ac7095947 Optimize loops with provably-integer iteration counts 2025-10-04 20:05:31 -05:00
Tacodiva 8fe321c357 Make types for blocks which returns ints more spercific 2025-09-28 12:30:32 +10:00
Thomas Weber 2244b26773 Discard old state after calling yielding procedure 2025-09-24 16:48:01 -05:00
Thomas Weber 4a8a5ad901 Add test case for 7ed29f5801 2025-09-22 19:30:23 -05:00
Thomas Weber 214b86a063 Add test case for d8c73c71d2 2025-09-22 19:29:06 -05:00
Thomas Weber 445a129939 Add test case for 7cc8f580b3 2025-09-22 19:28:17 -05:00
Thomas Weber c372e925a5 Add test case for 6a37fee386 2025-09-22 19:27:08 -05:00
Thomas Weber 5a90e13981 Fix TypeState#after setting variable types to undefined
If a variable existed in `this` but not in `other`, its resulting type
would be set to undefined. Changing it to use the type from `this`
seems to fix https://github.com/TurboWarp/scratch-vm/issues/273.
2025-09-22 18:41:48 -05:00
Thomas Weber 40715dc259 Add test case for https://github.com/TurboWarp/scratch-vm/issues/276 2025-09-22 18:41:48 -05:00
Thomas Weber 2639653647 Revert "Fix #273"
This reverts commit c16be25178.

Caused https://github.com/TurboWarp/scratch-vm/issues/276
2025-09-22 18:41:38 -05:00
Thomas Weber 44e2589e65 Fix https://github.com/TurboWarp/scratch-vm/issues/277
Need to clear the state before analyzing the condition as the condition
may be re-evaluated after yielding.
2025-09-22 18:40:34 -05:00
Tacodiva 749e923378 Fix #272 (thanks @Geotale) 2025-09-21 23:10:50 +10:00
Tacodiva c16be25178 Fix #273 2025-09-21 22:59:56 +10:00
Thomas Weber cd353ca31e Merge pull request #268 from TurboWarp/fix-analyzeLoopedBlock-infinite-loop
Give up analyzing looped stack after 10000 iterations
2025-09-20 13:57:52 -05:00
Thomas Weber fa035541da Give up analyzing looped stack after 10000 iterations
Temporary fix for an infinite loop, to be properly fixed later
2025-09-20 13:53:41 -05:00
Thomas Weber 5b027b995e Fix motion_turnleft and motion_turnright missing type casts 2025-09-15 18:01:45 -05:00
Tacodiva 7cc8f580b3 Fix yielding loop arguments not re-analyzing 2025-09-08 17:08:23 +10:00
Tacodiva fbca1bf49b Fixed NaN = 0 wrongly reporting true, and add a test 2025-09-08 11:48:55 +10:00
Tacodiva b8defadedb Merge remote-tracking branch 'origin/develop' into HEAD 2025-09-07 11:56:25 +10:00
Thomas Weber 7ef5e29c16 interpreter: fix skipped blocks in recursive procedures using "stop this script"
Closes https://github.com/TurboWarp/scratch-vm/issues/249
Regression from 20f25f252c
2025-03-07 01:21:08 -06:00
Muffin cd63c87f07 js: reset variable types after compatibility layer call
Fixes https://github.com/TurboWarp/scratch-vm/issues/245
2025-02-11 00:49:36 -06:00
Thomas Weber af3b7513a4 ir: Match vanilla quirks when handling variable or list fields with null ID 2025-01-18 00:29:09 -06:00
Thomas Weber 2c9d301da2 ir: Fix variable cache collision when variable or list field has null ID
Fixes https://github.com/TurboWarp/scratch-vm/issues/239
2025-01-18 00:09:09 -06:00
Tacodiva df65b01cde Merge branch 'origin/develop' into next-next 2024-09-26 11:50:09 +10:00
Muffin 179030ad49 Don't eagerly cast boolean arguments to boolean (#223)
Fixes https://github.com/TurboWarp/scratch-vm/issues/222
2024-09-08 11:56:47 -05:00