-
Notifications
You must be signed in to change notification settings - Fork 0
Nan Adapter
The Interpreter can be required in the following way:
var Interpreter = require('InterpreterNan');
To create a new Program object and run it, use:
var jsProgram = {/*This object contains the program definition*/};
var program = new Interpreter.Program(jsProgram);
program.run(1, 2, false); //The parameters to this function will be passed to the main function of the program
An object that may be parameter for an Interpreter.Program construction must have the following attributes:
-
functions
: must contain a Map from Number to function objects -
start
: must be a Number that is a valid key of thefunctions
attribute
An object inside a program objects function
attribute must be an object with the following attributes:
-
inputs
: An array of input datatype names -
outputs
: An array of output datatype names -
variables
: An array of variable declarations -
blocks
: A Map from Number to block objects -
start
: A Number that is a valid key of theblocks
attribute -
connections
: An array of connections
A variable declaration is an object with the following attributes:
-
ID
: The variable identifier (must be of type string) -
type
: Refers to the datatype name of the variables type
A block object is an object that must contain at least one attribute:
-
type
: The type of block as a string Depending on the type, additional attributes may have to be specified (see Block types)
A connection is an Object with the following attributes:
-
startBlock
: Must be a valid key to theblocks
attribute of a function -
endBlock
: Must be a valid key to theblocks
attribute of a function -
startPort
: The index of the port in thestartBlock
-
endPort
: The index of the port in theendBlock
All connections must be between ports of the same type, or otherwise the typecheck will fail!
The constructor of a Interpreter.Program
might throw errors, in which case these error objects may contain a functionID
and a blockID
attribute, indicating where the error occured.
If the function or block in question are not known, these values will have the javascript undefined
value