new BlockPyEngine(main, tag)
An object for executing Python code and passing the results along to interested components.
This:
Parameters:
Name | Type | Description |
---|---|---|
main |
Object | The main BlockPy instance |
tag |
HTMLElement | The HTML object this is attached to. |
Members
onExecutionEnd
Definable function to be run when execution has fully ended,
whether it succeeds or fails.
Methods
analyze() → {Boolean}
Runs the AbstractInterpreter to get some static information about the code,
including potential semantic errors. It then parses that information to give
feedback.
Returns:
Whether the code was successfully analyzed.
- Type
- Boolean
analyzeVariables() → {Object.<String, AIType>}
Runs the AbstractInterpreter to get some static information about the code,
in particular the variables' types. This is needed for type checking.
Returns:
Maps variable names (as Strings) to types as constructed by the AbstractIntepreter.
- Type
- Object.<String, AIType>
executionEnd_()
Helper function that will attempt to call the defined onExecutionEnd,
but will do nothing if there is no function defined.
lastStep()
Called at the end of the Skulpt execution to terminate the executionBuffer
and hand it off to the execution trace in the model.
loadEngine()
Initializes the Python Execution engine and the Printer (console).
readFile(filename) → {String}
Used to access Skulpt built-ins. This is pretty generic, taken
almost directly from the Skulpt docs.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | The python filename (e.g., "os" or "pprint") that will be loaded. |
Throws:
Will throw an error if the file isn't found.
Returns:
The JavaScript source code of the file (weird, right?)
- Type
- String
reset()
Resets the state of the execution engine, including reinitailizing
the execution buffer (trace, step, etc.), reseting the printer, and
hiding the trace button.
run()
Runs the given python code, resetting the console and Trace Table.
step(variables, lineNumber, columnNumber, filename, astType, ast)
"Steps" the execution of the code, meant to be used as a callback to the Skulpt
environment.
Parameters:
Name | Type | Description |
---|---|---|
variables |
Object | Hash that maps the names of variables (Strings) to their Skulpt representation. |
lineNumber |
Number | The corresponding line number in the source code that is being executed. |
columnNumber |
Number | 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. |
filename |
String | The name of the python file being executed (e.g., "__main__.py"). |
astType |
String | Unused? TODO: What is this? |
ast |
String | String-encoded JSON representation of the AST node associated with this element. |