19 Commits
Author SHA1 Message Date
Thomas Weber 7387fa0883 Replace tap with node:test (#393) 2026-10-18 14:43:49 -05:00
GarboMuffin 20f25f252c interpreter: Do not re-evaluate procedure arguments after stop this script or return (#202)
"stop this script" and "return" would previously cause all the procedure
arguments to be re-evaluated and then discarded. In vanilla Scratch the
worst case is a performance penalty, but with our custom reporters it
can cause infinite loops.

Fixes https://github.com/TurboWarp/scratch-vm/issues/201
2024-03-30 17:53:13 -05:00
GarboMuffin f033067b6f Non-warp recursion should yield in interpreter
Matches normal procedure blocks. Already worked in compiler.
2023-07-14 19:28:13 -05:00
Karishma Chadha c499106f85 Revert "Raise params to the next frame when pushing" 2019-07-22 12:59:48 -04:00
Michael "Z" Goddard 8d91e3cbd7 test stopThisScript in procedures
- Test that stopThisScript in a procedure stays in the procedure and
  moves it to the end where Sequencer can pop it normally
2019-06-25 14:38:46 -04:00
Michael "Z" Goddard e1254bd8c7 elevate stack block id and frame info into thread
- Add pointer member to thread. This is the current executing block.
- Add stackFrame member to thread. This is the current frame
  information like procedure parameters.

This is a step potentially towards stack-less threads. With further
modifications we could have stack and stackFrames be null if a script
does not call a procedure.
2019-06-03 18:13:01 -04:00
Karishma Chadha e0b0d35b46 Add references to runtime to constructor calls for Sprite, Target, and RenderedTarget so blocks get created properly. 2019-01-29 15:30:45 -05:00
Michael "Z" Goddard 20ff75b776 fix: initialize stack frame params for all procedures
A previous change fixed compatibility with Scratch 2 removing 3's
unintentional scope leaking. This furthers that change so that
procedures with no parameters will also not accidentally use values in
other procedure stacks.
2018-12-13 10:51:44 -05:00
Michael "Z" Goddard 05291aa254 turn reporter tree into instruction sequence
Turn the reporter tree execute walks into a sequence of block
functions. After calling a block function store the reported value in
the arguments object its depending block will use.

- Set the reported value on the thread. There is only ever one "just"
  reported value, which is read and stored elsewhere after being
  reported.
2018-06-12 14:21:40 -04:00
Michael "Z" Goddard d04d6b2c6a Revert "Revert "Push reported""
This reverts commit 107adad647.
2018-04-16 13:21:53 -04:00
kchadha 107adad647 Revert "Push reported" 2018-02-02 12:42:09 -05:00
Michael "Z" Goddard 6b7582f1c7 Report block result to stackFrame.justReported
- Add stackFrame.justReported

Report the block result to a known key `justReported` instead of a
dynamic key on `reported`. Assuming blocks with a promised value are
relatively infrequent the most common recursive input flow immediately
reads the value "just" reported. In the assumed uncommon case of a
promised thread status, empty the already argValues assigned values
onto the currentStackFrame's reported member. In the next execute call
on this stackFrame, values assigned to reported are read back off onto
argValues, and execute will returned to the assumed common case. This
is a safe assumption since a thread in the promise state will not exit
that state until the next frame when javascript has a chance to call
the resolve handle, setting the thread's state back to another
executable state.

Using direct assignment to `justReported` saves building an object
dynamically. Instead of always building `reported` and `argValues` only
`argValues` is built until a promised state is reached. This also gives
a known time when `reported` is used, allowing cleanup of a
stackFrame's reported to only happen when it was used to persist
already reported values.
2018-01-24 17:00:12 -05:00
Paul Kaplan 2d2b691b6f Return a default falsey value for unknown params based on param type 2017-12-06 11:46:43 -05:00
Paul Kaplan 91c93830a8 Fix tests 2017-11-16 14:23:56 -05:00
Paul Kaplan 34dfbb50ba Update naming and implementation for custom procedure blocks 2017-11-16 14:17:08 -05:00
Ray Schamp bafdf8d9f2 Use ES6 linting rules in the project root
Update all tests for `no-var` and `prefer-arrow-callback` (using `--fix`)
2017-04-24 15:37:58 -04:00
SillyInventor e8949dcdf5 Added remaining tests 2017-02-10 13:06:39 -05:00
SillyInventor 3324f51193 Added some unit tests for some thread functions 2017-02-09 18:18:53 -05:00
Andrew Sliwinski 8ca6944292 Add unit tests for all utility modules. Re GH-103 2016-10-03 16:34:57 -04:00