VirtualMachine.runFunction

This method provides a common interface for calling any ScriptFunction under the same compilation unit as the initial program. It should not be used to run "foreign" functions with a different const table. Use runProgram for that. This method may throw ScriptRuntimeException. Such an exception is caught at opNew and opCall boundaries and propagated or caught by the script.

class VirtualMachine
ScriptAny
runFunction
(
ScriptFunction func
,
ScriptAny thisObj
,
ScriptAny[] args
,
ScriptAny[string] contextValues = null
)

Parameters

func ScriptFunction

The function to be run.

thisObj ScriptAny

The "this" object to be used.

args ScriptAny[]

The arguments to be passed to the function. If this is a SCRIPT_FUNCTION the arguments will be set up by this method.

contextValues ScriptAny[string]

Special meaning variables that are added to the SCRIPT_FUNCTION environment. For example, \_\_new:true means that a modified thisObj will be returned. \_\_yield\_\_:yieldFunc is used for Generator functions.

Return Value

Type: ScriptAny

The return value of the function if an exception is not thrown in most cases (see contextValues).

Meta