Interpreter

This is the main interface for the host application to interact with scripts.

Constructors

this
this(bool printDisasm, bool printSteps)

Constructs a new Interpreter with a global environment. Note that all calls to evaluate run in a new environment below the global environment. This allows keywords such as let and const to not pollute the global namespace. However, scripts can use var to declare variables that are global.

Members

Functions

evaluate
ScriptAny evaluate(string code, string name)

This is the main entry point for evaluating a script program.

evaluateFile
ScriptAny evaluateFile(string pathName)

Evaluates a file that can be either binary bytecode or textual source code.

forceSetGlobal
void forceSetGlobal(string name, T value, bool isConst)

Sets a global variable or constant without checking whether or not the variable or const was already declared. This is used by host applications to define custom functions or objects.

forceUnsetGlobal
void forceUnsetGlobal(string name)

Unsets a variable or constant in the global environment. Used by host applications to remove items that were loaded by the standard library load functions. Specific functions of script classes can be removed by modifying the "prototype" field of their constructor.

initializeStdlib
void initializeStdlib()

Initializes the Mildew standard library, such as Object, Math, and console namespaces. This is optional and is not called by the constructor. For a script to use these methods such as console.log this must be called first. It is also possible to only call specific initialize*Library functions and/or force set globals from them to UNDEFINED.

runVMFibers
void runVMFibers()

Run the VM queued fibers. This API is still a work in progress.

vm
VirtualMachine vm()

Gets the VirtualMachine instance of this Interpreter

Meta