<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: BlockPyEngine</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-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: BlockPyEngine</h1>

    




<section>

<header>
    
        <h2>BlockPyEngine</h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    <h4 class="name" id="BlockPyEngine"><span class="type-signature"></span>new BlockPyEngine<span class="signature">(main, tag)</span><span class="type-signature"></span></h4>

    



<div class="description">
    An object for executing Python code and passing the results along to interested components.
</div>







    <h5>This:</h5>
    <ul><li>{<a href="BlockPyEditor.html">BlockPyEditor</a>}</li></ul>



    <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>main</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The main BlockPy instance</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>tag</code></td>
            

            <td class="type">
            
                
<span class="param-type">HTMLElement</span>


            
            </td>

            

            

            <td class="description last">The HTML object this is attached to.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line9">line 9</a>
    </li></ul></dd>
    

    

    

    
</dl>
















    
    </div>

    

    

    

     

    

    
        <h3 class="subsection-title">Members</h3>

        
            
<h4 class="name" id="onExecutionEnd"><span class="type-signature"></span>onExecutionEnd<span class="type-signature"></span></h4>




<div class="description">
    Definable function to be run when execution has fully ended,
whether it succeeds or fails.
</div>







<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line24">line 24</a>
    </li></ul></dd>
    

    

    

    
</dl>






        
    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    <h4 class="name" id="analyze"><span class="type-signature"></span>analyze<span class="signature">()</span><span class="type-signature"> &rarr; {Boolean}</span></h4>

    



<div class="description">
    Runs the AbstractInterpreter to get some static information about the code,
including potential semantic errors. It then parses that information to give
feedback.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line177">line 177</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    Whether the code was successfully analyzed.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Boolean</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="analyzeVariables"><span class="type-signature"></span>analyzeVariables<span class="signature">()</span><span class="type-signature"> &rarr; {Object.&lt;String, AIType>}</span></h4>

    



<div class="description">
    Runs the AbstractInterpreter to get some static information about the code,
in particular the variables' types. This is needed for type checking.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line158">line 158</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    Maps variable names (as Strings) to types as constructed by the AbstractIntepreter.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object.&lt;String, AIType></span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="executionEnd_"><span class="type-signature"></span>executionEnd_<span class="signature">()</span><span class="type-signature"></span></h4>

    



<div class="description">
    Helper function that will attempt to call the defined onExecutionEnd,
but will do nothing if there is no function defined.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line30">line 30</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="lastStep"><span class="type-signature"></span>lastStep<span class="signature">()</span><span class="type-signature"></span></h4>

    



<div class="description">
    Called at the end of the Skulpt execution to terminate the executionBuffer
and hand it off to the execution trace in the model.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line143">line 143</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="loadEngine"><span class="type-signature"></span>loadEngine<span class="signature">()</span><span class="type-signature"></span></h4>

    



<div class="description">
    Initializes the Python Execution engine and the Printer (console).
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line39">line 39</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="readFile"><span class="type-signature"></span>readFile<span class="signature">(filename)</span><span class="type-signature"> &rarr; {String}</span></h4>

    



<div class="description">
    Used to access Skulpt built-ins. This is pretty generic, taken
almost directly from the Skulpt docs.
</div>









    <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>filename</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">The python filename (e.g., "os" or "pprint") that will be loaded.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line80">line 80</a>
    </li></ul></dd>
    

    

    

    
</dl>











<h5>Throws:</h5>

        

    <div class="param-desc">
    
        Will throw an error if the file isn't found.
    
    </div>


    


<h5>Returns:</h5>

        
<div class="param-desc">
    The JavaScript source code of the file (weird, right?)
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">String</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id="reset"><span class="type-signature"></span>reset<span class="signature">()</span><span class="type-signature"></span></h4>

    



<div class="description">
    Resets the state of the execution engine, including reinitailizing
the execution buffer (trace, step, etc.), reseting the printer, and
hiding the trace button.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line94">line 94</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="run"><span class="type-signature"></span>run<span class="signature">()</span><span class="type-signature"></span></h4>

    



<div class="description">
    Runs the given python code, resetting the console and Trace Table.
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line251">line 251</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id="step"><span class="type-signature"></span>step<span class="signature">(variables, lineNumber, columnNumber, filename, astType, ast)</span><span class="type-signature"></span></h4>

    



<div class="description">
    "Steps" the execution of the code, meant to be used as a callback to the Skulpt
environment.
</div>









    <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>variables</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">Hash that maps the names of variables (Strings) to their Skulpt representation.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>lineNumber</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The corresponding line number in the source code that is being executed.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>columnNumber</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The corresponding column number in the source code that is being executed. Think of it as the "X" position to the lineNumber's "Y" position.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>filename</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">The name of the python file being executed (e.g., "__main__.py").</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>astType</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">Unused? TODO: What is this?</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>ast</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">String-encoded JSON representation of the AST node associated with this element.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="engine.js.html">engine.js</a>, <a href="engine.js.html#line120">line 120</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BlockPy.html">BlockPy</a></li><li><a href="BlockPyCorgis.html">BlockPyCorgis</a></li><li><a href="BlockPyDialog.html">BlockPyDialog</a></li><li><a href="BlockPyEditor.html">BlockPyEditor</a></li><li><a href="BlockPyEngine.html">BlockPyEngine</a></li><li><a href="BlockPyEnglish.html">BlockPyEnglish</a></li><li><a href="BlockPyFeedback.html">BlockPyFeedback</a></li><li><a href="BlockPyHistory.html">BlockPyHistory</a></li><li><a href="BlockPyPresentation.html">BlockPyPresentation</a></li><li><a href="BlockPyPrinter.html">BlockPyPrinter</a></li><li><a href="BlockPyServer.html">BlockPyServer</a></li><li><a href="BlockPyToolbar.html">BlockPyToolbar</a></li><li><a href="LocalStorageWrapper.html">LocalStorageWrapper</a></li><li><a href="PythonToBlocks.html">PythonToBlocks</a></li></ul><h3>Global</h3><ul><li><a href="global.html#BlockPyInterface">BlockPyInterface</a></li><li><a href="global.html#cloneNode">cloneNode</a></li><li><a href="global.html#encodeHTML">encodeHTML</a></li><li><a href="global.html#expandArray">expandArray</a></li><li><a href="global.html#EXTENDED_ERROR_EXPLANATION">EXTENDED_ERROR_EXPLANATION</a></li><li><a href="global.html#indent">indent</a></li><li><a href="global.html#instructor_module">instructor_module</a></li><li><a href="global.html#prettyPrintDateTime">prettyPrintDateTime</a></li><li><a href="global.html#randomInteger">randomInteger</a></li><li><a href="global.html#set_button_loaded">set_button_loaded</a></li><li><a href="global.html#timerGuard">timerGuard</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Mar 26 2017 09:45:04 GMT-0400 (Eastern Daylight Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>