Interpreter

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

Constructors

this
this(bool printVMDebugInfo)

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, bool printDisasm, bool fromScript)

This is the main entry point for evaluating a script program. If the useVM option was set in the constructor, bytecode compilation and execution will be used, otherwise tree walking.

evaluateFile
ScriptAny evaluateFile(string pathName, bool printDisasm, bool fromScript)

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.

printVMDebugInfo
bool printVMDebugInfo()

whether or not debug info should be printed between each VM instruction

runVMFibers
void runVMFibers()

Run the VM queued fibers. This API is still being worked on.

vm
VirtualMachine vm()

Virtual machine property should never at any point be null

Meta