Commit Graph
36 Commits
Author SHA1 Message Date
Paul Kaplan 34dfbb50ba Update naming and implementation for custom procedure blocks 2017-11-16 14:17:08 -05:00
Wang Yu 6ec231db9d Fix the next thread is skipped after clone deleted
Problem:
When a clone is deleted, its thread is removed from the thread
list; but the index "i" in the execution for-loop will still +1,
making the next thread skipped.

Changes:
Added a flag "isKilled" on a thread;
Set the flag when a thread is removed from the thread list;
reduce the "i" counter if the thread of the current loop is removed.
2017-05-12 14:01:37 +08:00
Ray Schamp a4f095db5e Use ES6 style classes 2017-04-17 19:42:48 -04:00
Ray Schamp e01c4ae108 Pass with --fix 2017-04-17 15:10:04 -04:00
griffpatch 9cb595312e Implement "Stop this script" function
Existing implementation incorrectly terminates the entire thread.
See: http://llk.github.io/scratch-vm/#144142535
2017-02-08 09:44:10 +00:00
Ray Schamp 727fcc7875 Lint for eslint-config-scratch@3 2017-02-01 16:27:55 -05:00
Andrew Sliwinski c2a488a197 Merge pull request #408 from griffpatch/optimisation/avoid-negative-index-lookups
Optimisation - Avoid negative index lookups #407
2017-01-30 15:06:02 -05:00
griffpatch fbf2c0c345 Optimisation - Recycle Stack Frame for cosecutive blocks
This saves popping, destroying, recreating, and pushing the stack frame,
and then reassigning the warp mode attribute for every block to block
step in the execution.
2017-01-28 17:06:07 +00:00
griffpatch bd9159b9fb More negative index checks 2017-01-28 14:39:22 +00:00
griffpatch a25e117412 optimisation/avoid negative index lookups #407
Run-time Optimisation

The thread.stackFrames array is accessed all the time to retrieve the
'parent' stack frame. This is done using as index of [this.stack.length
- 1]. However, a lot of the time this evaluated to [-1]. Although this
results in null, which is fine, to get to this javascript actually
defers from a numeric array lookup to an object lookup using the string
"-1". This is roughly 100 times slower to compute and so a simple catch
for negative indexes is well worth the extra check.
2017-01-28 14:38:13 +00:00
Ray Schamp f6c0064235 All linting other than console statements 2016-10-23 22:20:29 -04:00
Ray Schamp 68ed110b49 Pass with eslint --fix
Resolved whitespace issues, e.g., space-before-function-paren and key-spacing
2016-10-23 12:41:45 -04:00
Tim Mickel e49f076fa1 Interpreter fixes, enhancements, features (#280)
* Thread stepping rework; interp.redraw equivalent

* Add turbo mode and pause mode

* Yielding behavior to match Scratch 2.0

* Implement warp-mode procedure threads

* Add check for recursive call

* Inline wait block timer

* Revert to setInterval and always drawing

* Restore yielding in glide

* 30TPS compatibility mode

* 5-call count recursion limit

* Removing dead primitive code

* To simplify, access runtime.threads inline in `stepThreads`.

* Warp mode/timer fixes; recursive check fixes; clean-up

* Add basic single-stepping

* Add single-stepping speed slider

* Allow yielding threads to run in single-stepping

* Restore inactive threads tracking for block glows

* Add clock pausing during pause mode

* Documentation and clean-up throughout

* Don't look for block glows in `thread.topBlock`.

* Add null check for block glows; rename `_updateScriptGlows` to reflect block glowing

* Use the current executed block for glow, instead of stack

* Add more comments to `stepToProcedure`, and re-arrange to match 2.0

* Tweak to Blocks.prototype.getTopLevelScript

* Revert previous

* Fix threads array to be resilient to changes during `stepThreads`

* Restore inactive threads filtering

* Fix typo in "procedure"

* !! instead of == true
2016-10-17 23:23:16 -04:00
Tim Mickel 8c654bbe60 Procedure blocks (#264) 2016-10-13 13:11:26 -04:00
Tim Mickel 9744bcbb70 Clones (#150)
* Provide property to Clone to distinguish "original" clones

* Provide method to clone a clone's properties

* Don't report clones in the UI target list

* Add target info to Thread

* Allow hats to skip clones (for green flag)

* Green flag skips clones

* Implement "create clone" and hat

* Pass the runtime to sprites and clones (for start hats)

* Clone disposal; trigger hats after drawable initializes.

* Separate stop threads for target; fix handling of stop button

* Remove extraneous `skipClones` property

* Add global clone limit

* Don't allow a non-clone to delete itself.

* Rename `cloneClone` -> `makeClone`

* Variable updates in runtime.js

* Synchronous drawable initialization (until we put it back to promises)
2016-09-15 19:37:12 -04:00
Tim Mickel 5df0acc895 Better glows (#152)
* Strip out old script glowing in thread management

* Add new tracking mechanism for glowing scripts

* Track parents and use them to determine script glows

* Use top-block for a thread if there's nothing on the stack

* Remove `console.log`
2016-09-08 09:40:53 -04:00
Tim Mickel 39fdbaf983 Add atStackTop helper to Thread 2016-08-23 18:12:19 -04:00
Tim Mickel de6ba08866 Add single-frame yield mode 2016-07-01 10:44:43 -04:00
Tim Mickel ec4567aa8a Simplify logic for Thread status 2016-06-30 18:56:31 -04:00
Tim Mickel ab6e0d3839 Remove YieldTimers, unused WeDo blocks 2016-06-30 18:56:31 -04:00
Tim Mickel 6daee9a70e Remove VM-locking yield mode per discussion 2016-06-30 18:56:23 -04:00
Tim Mickel d44b806b4f Add blocking yield mode 2016-06-30 18:56:23 -04:00
Tim Mickel 6181bcd5cb Refactor Thread.peekParentStackFrame 2016-06-30 18:56:23 -04:00
Tim Mickel d15c93af05 Keep "waiting reporter name" on the stack frame.
Also add highlighting for inputs.
2016-06-30 18:56:23 -04:00
Tim Mickel 97f7571c6f Prototype implementation of yielding reporters 2016-06-30 18:56:23 -04:00
Tim Mickel 190208b620 Clean up yield-timers: support multiple, move logic to Threads. 2016-06-30 18:56:23 -04:00
Tim Mickel 526a260101 Simplify execution by removing nextBlock
Everything is managed by the stack, including what the execute() function does.
2016-06-09 17:08:30 -04:00
Tim Mickel 9df470255e Add helpers to thread object 2016-06-09 14:22:58 -04:00
Tim Mickel 379b2dec79 Stack management, stack frames, forever and repeat 2016-05-03 13:28:24 -04:00
Tim Mickel 4de24cfc30 Implement thread status, YieldTimer, block glow, wait 2016-05-03 11:26:28 -04:00
Tim Mickel 773f2e1bbc Improve JSDoc on Thread 2016-05-02 13:05:48 -04:00
Tim Mickel 96123f870f Fix _removeThread documentation and add toggleStack 2016-04-29 17:31:04 -04:00
Tim Mickel 92dab97b84 Add thread management and stepping to runtime 2016-04-26 16:50:49 -04:00
Tim Mickel b6186a44f3 Add basics for the sequencer and threads 2016-04-26 15:00:45 -04:00
Andrew Sliwinski 981b85e78f AST create / change / move / delete from blockly 2016-04-26 09:49:52 -04:00
Andrew Sliwinski f9f47ed103 WIP 2016-04-18 17:20:30 -04:00