easy-scratch/doc/scratch-vm/BlockCached.html

1569 lines
82 KiB
HTML
Raw Normal View History

2025-02-12 12:27:32 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>BlockCached - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="-_StackFrame.html">_StackFrame</a><ul class='methods'><li data-type='method'><a href="-_StackFrame.html#.create">create</a></li><li data-type='method'><a href="-_StackFrame.html#.release">release</a></li><li data-type='method'><a href="-_StackFrame.html#reset">reset</a></li><li data-type='method'><a href="-_StackFrame.html#reuse">reuse</a></li></ul></li><li><a href="BLE.html">BLE</a><ul class='methods'><li data-type='method'><a href="BLE.html#connectPeripheral">connectPeripheral</a></li><li data-type='method'><a href="BLE.html#didReceiveCall">didReceiveCall</a></li><li data-type='method'><a href="BLE.html#disconnect">disconnect</a></li><li data-type='method'><a href="BLE.html#handleDisconnectError">handleDisconnectError</a></li><li data-type='method'><a href="BLE.html#isConnected">isConnected</a></li><li data-type='method'><a href="BLE.html#read">read</a></li><li data-type='method'><a href="BLE.html#requestPeripheral">requestPeripheral</a></li><li data-type='method'><a href="BLE.html#startNotifications">startNotifications</a></li><li data-type='method'><a href="BLE.html#write">write</a></li></ul></li><li><a href="BlockCached.html">BlockCached</a></li><li><a href="Blocks.html">Blocks</a><ul class='methods'><li data-type='method'><a href="Blocks.html#_addScript">_addScript</a></li><li data-type='method'><a href="Blocks.html#_deleteScript">_deleteScript</a></li><li data-type='method'><a href="Blocks.html#_getBackdropField">_getBackdropField</a></li><li data-type='method'><a href="Blocks.html#_getBlockParams">_getBlockParams</a></li><li data-type='method'><a href="Blocks.html#_getCostumeField">_getCostumeField</a></li><li data-type='method'><a href="Blocks.html#_getCustomBlockInternal">_getCustomBlockInternal</a></li><li data-type='method'><a href="Blocks.html#_getSoundField">_getSoundField</a></li><li data-type='method'><a href="Blocks.html#_getSpriteField">_getSpriteField</a></li><li data-type='method'><a href="Blocks.html#blocklyListen">blocklyListen</a></li><li data-type='method'><a href="Blocks.html#blockToXML">blockToXML</a></li><li data-type='method'><a href="Blocks.html#changeBlock">changeBlock</a></li><li data-type='method'><a href="Blocks.html#createBlock">createBlock</a></li><li data-type='method'><a href="Blocks.html#deleteBlock">deleteBlock</a></li><li data-type='method'><a href="Blocks.html#emitProjectChanged">emitProjectChanged</a></li><li data-type='method'><a href="Blocks.html#getAllVariableAndListReferences">getAllVariableAndListReferences</a></li><li data-type='method'><a href="Blocks.html#getBlock">getBlock</a></li><li data-type='method'><a href="Blocks.html#getBranch">getBranch</a></li><li data-type='method'><a href="Blocks.html#getFields">getFields</a></li><li data-type='method'><a href="Blocks.html#getInputs">getInputs</a></li><li data-type='method'><a href="Blocks.html#getMutation">getMutation</a></li><li data-type='method'><a href="Blocks.html#getNextBlock">getNextBlock</a></li><li data-type='method'><a href="Blocks.html#getOpcode">getOpcode</a></li><li data-type='method'><a href="Blocks.html#getProcedureDefinition">getProcedureDefinition</a></li><li data-type='method'><a href="Blocks.html#getProcedureParamNamesAndIds">getProcedureParamNamesAndIds</a></li><li data-type='method'><a href="Blocks.html#getProcedureParamNamesIdsAndDefaults">getProcedureParamNamesIdsAndDefaults</a></li><li data-type='method'><a href="Blocks.html#getScripts">getScripts</a></li><li data-type='method'><a href="Blocks.html#getTopLevelScript">getTopLevelScript</a></li><li data-type='method'><a href="Blocks.html#moveBlock">moveBlock</a></li><li data-type='method'><a href="Blocks.html#mutationToXML">mutationToXML</a></li><li data-type='method'><a href="Blocks.html#resetCache">resetCache</a></li><li data-type='method'><a href="Blocks.html#runAllMonitored">runAllMonitored</a></li><li data-type='method'><a href="Blocks.html#toXML">toXML</a></li><li data-type='method'><a href="Blocks.html#updateAssetName">updateAssetName</a></li><li data-type='method'><a href
</nav>
<div id="main">
<h1 class="page-title">BlockCached</h1>
<section>
<header>
<h2>
BlockCached
</h2>
<div class="class-description"><p>A execute.js internal representation of a block to reduce the time spent in
execute as the same blocks are called the most.</p>
<p>With the help of the Blocks class create a mutable copy of block
information. The members of BlockCached derived values of block information
that does not need to be reevaluated until a change in Blocks. Since Blocks
handles where the cache instance is stored, it drops all cache versions of a
block when any change happens to it. This way we can quickly execute blocks
and keep perform the right action according to the current block information
in the editor.</p></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="BlockCached"><span class="type-signature"></span>new BlockCached<span class="signature">(blockContainer, cached)</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>blockContainer</code></td>
<td class="type">
<span class="param-type"><a href="Blocks.html">Blocks</a></span>
</td>
<td class="description last"><p>the related Blocks instance</p></td>
</tr>
<tr>
<td class="name"><code>cached</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>default set of cached values</p></td>
</tr>
</tbody>
</table>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="_argValues"><span class="type-signature"></span>_argValues<span class="type-signature"> :object</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>An arguments object for block implementations. All executions of this
specific block will use this objecct.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h4 class="name" id="_blockFunction"><span class="type-signature">(nullable) </span>_blockFunction<span class="type-signature"> :function</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The block opcode's implementation function.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">function</span>
</li>
</ul>
<h4 class="name" id="_definedBlockFunction"><span class="type-signature"></span>_definedBlockFunction<span class="type-signature"> :boolean</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Is the block function defined for this opcode?</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">boolean</span>
</li>
</ul>
<h4 class="name" id="_fields"><span class="type-signature"></span>_fields<span class="type-signature"> :object</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A copy of the block's fields that may be modified.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h4 class="name" id="_inputs"><span class="type-signature"></span>_inputs<span class="type-signature"> :object</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A copy of the block's inputs that may be modified.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h4 class="name" id="_isHat"><span class="type-signature"></span>_isHat<span class="type-signature"> :boolean</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Is the opcode a hat (event responder) block.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">boolean</span>
</li>
</ul>
<h4 class="name" id="_isShadowBlock"><span class="type-signature"></span>_isShadowBlock<span class="type-signature"> :boolean</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Is this block a block with no function but a static value to return.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">boolean</span>
</li>
</ul>
<h4 class="name" id="_ops"><span class="type-signature"></span>_ops<span class="type-signature"> :Array.&lt;<a href="BlockCached.html">BlockCached</a>></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A sequence of non-shadow operations that can must be performed. This
list recreates the order this block and its children are executed.
Since the order is always the same we can safely store that order
and iterate over the operations instead of dynamically walking the
tree every time.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;<a href="BlockCached.html">BlockCached</a>></span>
</li>
</ul>
<h4 class="name" id="_parentKey"><span class="type-signature"></span>_parentKey<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The inputs key the parent refers to this BlockCached by.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h4 class="name" id="_parentValues"><span class="type-signature"></span>_parentValues<span class="type-signature"> :object</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The target object where the parent wants the resulting value stored
with _parentKey as the key.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h4 class="name" id="_profiler"><span class="type-signature">(nullable) </span>_profiler<span class="type-signature"> :<a href="Profiler.html">Profiler</a></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The profiler the block is configured with.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="Profiler.html">Profiler</a></span>
</li>
</ul>
<h4 class="name" id="_profilerFrame"><span class="type-signature">(nullable) </span>_profilerFrame<span class="type-signature"> :<a href="ProfilerFrame.html">ProfilerFrame</a></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Profiler information frame.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="ProfilerFrame.html">ProfilerFrame</a></span>
</li>
</ul>
<h4 class="name" id="_shadowOps"><span class="type-signature"></span>_shadowOps<span class="type-signature"> :Array.&lt;<a href="BlockCached.html">BlockCached</a>></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A sequence of shadow value operations that can be performed in any
order and are easier to perform given that they are static.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;<a href="BlockCached.html">BlockCached</a>></span>
</li>
</ul>
<h4 class="name" id="_shadowValue"><span class="type-signature">(nullable) </span>_shadowValue<span class="type-signature"> :any</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The static value of this block if it is a shadow block.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">any</span>
</li>
</ul>
<h4 class="name" id="fields"><span class="type-signature"></span>fields<span class="type-signature"> :object</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Original block object containing argument values for static fields.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h4 class="name" id="id"><span class="type-signature"></span>id<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Block id in its parent set of blocks.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h4 class="name" id="inputs"><span class="type-signature"></span>inputs<span class="type-signature"> :object</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Original block object containing argument values for executable inputs.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h4 class="name" id="mutation"><span class="type-signature">(nullable) </span>mutation<span class="type-signature"> :object</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Procedure mutation.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">object</span>
</li>
</ul>
<h4 class="name" id="opcode"><span class="type-signature"></span>opcode<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Block operation code for this block.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>