EcmaScriptComponent

Overview

The main component to use when working with EcmaScript (Javascript). It's the engine itself that contains all the EcmaScript specific logic. This component lets you set the script, run it, run functions on it and debug it.

Location

 

constructor

 

constructor

 

EcmaScriptComponent()

 

Sub New()

CallStack    (declared in ScriptComponent)

Holds the current callstack, only gets loaded when Debug is true.

 

property CallStack: ReadOnlyCollection<ScriptStackFrame> read;

 

ReadOnlyCollection<ScriptStackFrame> CallStack { get; }

 

ReadOnly Property CallStack() As ReadOnlyCollection<ScriptStackFrame>

Clear

Remove the state of the script engine and optionally clear the globals.

 

method Clear(aGlobals: Boolean)

 

void Clear(Boolean aGlobals)

 

Sub Clear(aGlobals As Boolean)

Parameters:

  • aGlobals:

Debug    (declared in ScriptComponent)

If true, the engine places debug instructions in the compiled scripts and enables the debugging features.

 

property Debug: Boolean read write;

 

Boolean Debug { get; set; }

 

Property Debug() As Boolean

DebugDebugger    (declared in ScriptComponent)

Called when a code breakpoint is triggered. Like an EcmaScript "debugger;" statement.

 

event DebugDebugger: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugDebugger()

 

Event DebugDebugger As EventHandler<ScriptDebugEventArgs>

DebugException    (declared in ScriptComponent)

Called when an Exception occurs in the engine. Only works when Debug = true.

 

event DebugException: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugException()

 

Event DebugException As EventHandler<ScriptDebugEventArgs>

DebugExceptionUnwind    (declared in ScriptComponent)

Called when an Exception occurs in the engine and isn't caught. Only works when Debug = true.

 

event DebugExceptionUnwind: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugExceptionUnwind()

 

Event DebugExceptionUnwind As EventHandler<ScriptDebugEventArgs>

DebugFrameEnter    (declared in ScriptComponent)

Called when a function is entered. Only works when Debug = true.

 

event DebugFrameEnter: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugFrameEnter()

 

Event DebugFrameEnter As EventHandler<ScriptDebugEventArgs>

DebugFrameExit    (declared in ScriptComponent)

Called when a function is exited. Only works when Debug = true.

 

event DebugFrameExit: EventHandler<ScriptDebugExitScopeEventArgs>;

 

delegate EventHandler<ScriptDebugExitScopeEventArgs> DebugFrameExit()

 

Event DebugFrameExit As EventHandler<ScriptDebugExitScopeEventArgs>

DebugLastPos    (declared in ScriptComponent)

Contains the last source location.

 

property DebugLastPos: PositionPair read;

 

PositionPair DebugLastPos { get; }

 

ReadOnly Property DebugLastPos() As PositionPair

DebugThreadExit    (declared in ScriptComponent)

 

event DebugThreadExit: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugThreadExit()

 

Event DebugThreadExit As EventHandler<ScriptDebugEventArgs>

DebugTracePoint    (declared in ScriptComponent)

Called when the engine is at a source line. Only works when Debug = true.

 

event DebugTracePoint: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugTracePoint()

 

Event DebugTracePoint As EventHandler<ScriptDebugEventArgs>

Dispose    (declared in ScriptComponent)

 

method Dispose(disposing: Boolean)

 

void Dispose(Boolean disposing)

 

Sub Dispose(disposing As Boolean)

Parameters:

  • disposing:

ExposeType

Expose a regular .NET type to the engine, under a given name. The type becomes usable like a regular Javascript Object on the global object.

 

method ExposeType(type: Type; name: String)

 

void ExposeType(Type type, String name)

 

Sub ExposeType(type As Type, name As String)

Parameters:

  • type:
  • name:

GlobalObject

The instance of the global object in the script. The global object contains the Javascript runtime library.

 

property GlobalObject: GlobalObject read;

 

GlobalObject GlobalObject { get; }

 

ReadOnly Property GlobalObject() As GlobalObject

Globals

A list of globals to expose to the engine. This can be used to add variables and functions to the engine without interfering with the global object.

 

property Globals: ScriptScope read;

 

ScriptScope Globals { get; }

 

ReadOnly Property Globals() As ScriptScope

HasFunction

Returns true if there is a global function with that name

 

method HasFunction(aName: String): Boolean

 

Boolean HasFunction(String aName)

 

Function HasFunction(aName As String) As Boolean

Parameters:

  • aName:

Include

 

method Include(aFileName: String; aData: String)

 

void Include(String aFileName, String aData)

 

Sub Include(aFileName As String, aData As String)

Parameters:

  • aFileName:
  • aData:

IntRun  protected

 

method IntRun: Object

 

Object IntRun()

 

Function IntRun() As Object

JustFunctions

 

property JustFunctions: Boolean read write;

 

Boolean JustFunctions { get; set; }

 

Property JustFunctions() As Boolean

NonThreadedIdle    (declared in ScriptComponent)

Called when the engine is waiting to be resumed, when it's paused. When RunInThread is false, this can be used to handle windows messages. Only works when Debug = true.

 

event NonThreadedIdle: EventHandler;

 

delegate EventHandler NonThreadedIdle()

 

Event NonThreadedIdle As EventHandler

Pause    (declared in ScriptComponent)

Pause the engine (only works if Debug is true).

 

method Pause

 

void Pause()

 

Sub Pause()

RootContext

The context used for the global scope. This can be used in calls to the Utilities class. A context is used to define what variables are available currently and if the script is strict or not.

 

property RootContext: ExecutionContext read write;

 

ExecutionContext RootContext { get; set; }

 

Property RootContext() As ExecutionContext

Run    (declared in ScriptComponent)

Run the current script.

 

method Run

 

void Run()

 

Sub Run()

RunException    (declared in ScriptComponent)

This field contains the exception object that escaped the engine after the last run.

 

property RunException: Exception read write;

 

Exception RunException { get; set; }

 

Property RunException() As Exception

RunFunction (ScriptStatus, String, array of Object): Object

Run a function in the engine. Note that this will fail with an exception if there's no given function with that name. Use HasFunction to find if there is. The initialstatus is used for debugging when you want to step into a function instead of just run it.

 

method RunFunction(initialStatus: ScriptStatus; name: String; params args: array of Object): Object

 

Object RunFunction(ScriptStatus initialStatus, String name, params Object[] args)

 

Function RunFunction(initialStatus As ScriptStatus, name As String, ParamArray args As Object()) As Object

Parameters:

  • initialStatus:
  • name:
  • args:

RunFunction (String, array of Object): Object    (declared in ScriptComponent)

Run a function by it's name. Returns the result of the function if any. The function must exist, if not an exception is thrown.

 

method RunFunction(name: String; params args: array of Object): Object

 

Object RunFunction(String name, params Object[] args)

 

Function RunFunction(name As String, ParamArray args As Object()) As Object

Parameters:

  • name:
  • args:

RunInThread    (declared in ScriptComponent)

If true, the Run method starts a new thread and runs the script there, else Run blocks.

 

property RunInThread: Boolean read write;

 

Boolean RunInThread { get; set; }

 

Property RunInThread() As Boolean

RunResult    (declared in ScriptComponent)

Contains the result of running the script. For EcmaScript this is the last expression.

 

property RunResult: Object read;

 

Object RunResult { get; }

 

ReadOnly Property RunResult() As Object

SetDebug  protected

 

method SetDebug(b: Boolean)

 

void SetDebug(Boolean b)

 

Sub SetDebug(b As Boolean)

Parameters:

  • b:

Source    (declared in ScriptComponent)

Source of the script you want to run.

 

property Source: String read write;

 

String Source { get; set; }

 

Property Source() As String

SourceFileName    (declared in ScriptComponent)

Source file name of the script. This is used in error messages to denote where the errors are.

 

property SourceFileName: String read write;

 

String SourceFileName { get; set; }

 

Property SourceFileName() As String

Status    (declared in ScriptComponent)

Holds the current status of the engine.

 

property Status: ScriptStatus read write;

 

ScriptStatus Status { get; set; }

 

Property Status() As ScriptStatus

StatusChanged    (declared in ScriptComponent)

Triggered when the Status property is changed.

 

event StatusChanged: EventHandler;

 

delegate EventHandler StatusChanged()

 

Event StatusChanged As EventHandler

StepInto    (declared in ScriptComponent)

Step into the next function call (if any, else steps over it). Only works if Debug = true.

 

method StepInto

 

void StepInto()

 

Sub StepInto()

StepOut    (declared in ScriptComponent)

Step out of the current function. Only works if Debug = true.

 

method StepOut

 

void StepOut()

 

Sub StepOut()

StepOver    (declared in ScriptComponent)

Step over the next function call. Only works if Debug = true.

 

method StepOver

 

void StepOver()

 

Sub StepOver()

Stop    (declared in ScriptComponent)

Stop the engine.

 

method Stop

 

void Stop()

 

Sub Stop()

 

CallStack    (declared in ScriptComponent)

Holds the current callstack, only gets loaded when Debug is true.

 

property CallStack: ReadOnlyCollection<ScriptStackFrame> read;

 

ReadOnlyCollection<ScriptStackFrame> CallStack { get; }

 

ReadOnly Property CallStack() As ReadOnlyCollection<ScriptStackFrame>

Debug    (declared in ScriptComponent)

If true, the engine places debug instructions in the compiled scripts and enables the debugging features.

 

property Debug: Boolean read write;

 

Boolean Debug { get; set; }

 

Property Debug() As Boolean

DebugLastPos    (declared in ScriptComponent)

Contains the last source location.

 

property DebugLastPos: PositionPair read;

 

PositionPair DebugLastPos { get; }

 

ReadOnly Property DebugLastPos() As PositionPair

GlobalObject

The instance of the global object in the script. The global object contains the Javascript runtime library.

 

property GlobalObject: GlobalObject read;

 

GlobalObject GlobalObject { get; }

 

ReadOnly Property GlobalObject() As GlobalObject

Globals

A list of globals to expose to the engine. This can be used to add variables and functions to the engine without interfering with the global object.

 

property Globals: ScriptScope read;

 

ScriptScope Globals { get; }

 

ReadOnly Property Globals() As ScriptScope

JustFunctions

 

property JustFunctions: Boolean read write;

 

Boolean JustFunctions { get; set; }

 

Property JustFunctions() As Boolean

RootContext

The context used for the global scope. This can be used in calls to the Utilities class. A context is used to define what variables are available currently and if the script is strict or not.

 

property RootContext: ExecutionContext read write;

 

ExecutionContext RootContext { get; set; }

 

Property RootContext() As ExecutionContext

RunException    (declared in ScriptComponent)

This field contains the exception object that escaped the engine after the last run.

 

property RunException: Exception read write;

 

Exception RunException { get; set; }

 

Property RunException() As Exception

RunInThread    (declared in ScriptComponent)

If true, the Run method starts a new thread and runs the script there, else Run blocks.

 

property RunInThread: Boolean read write;

 

Boolean RunInThread { get; set; }

 

Property RunInThread() As Boolean

RunResult    (declared in ScriptComponent)

Contains the result of running the script. For EcmaScript this is the last expression.

 

property RunResult: Object read;

 

Object RunResult { get; }

 

ReadOnly Property RunResult() As Object

Source    (declared in ScriptComponent)

Source of the script you want to run.

 

property Source: String read write;

 

String Source { get; set; }

 

Property Source() As String

SourceFileName    (declared in ScriptComponent)

Source file name of the script. This is used in error messages to denote where the errors are.

 

property SourceFileName: String read write;

 

String SourceFileName { get; set; }

 

Property SourceFileName() As String

Status    (declared in ScriptComponent)

Holds the current status of the engine.

 

property Status: ScriptStatus read write;

 

ScriptStatus Status { get; set; }

 

Property Status() As ScriptStatus

 

constructor

 

constructor

 

EcmaScriptComponent()

 

Sub New()

Clear

Remove the state of the script engine and optionally clear the globals.

 

method Clear(aGlobals: Boolean)

 

void Clear(Boolean aGlobals)

 

Sub Clear(aGlobals As Boolean)

Parameters:

  • aGlobals:

Dispose    (declared in ScriptComponent)

 

method Dispose(disposing: Boolean)

 

void Dispose(Boolean disposing)

 

Sub Dispose(disposing As Boolean)

Parameters:

  • disposing:

ExposeType

Expose a regular .NET type to the engine, under a given name. The type becomes usable like a regular Javascript Object on the global object.

 

method ExposeType(type: Type; name: String)

 

void ExposeType(Type type, String name)

 

Sub ExposeType(type As Type, name As String)

Parameters:

  • type:
  • name:

HasFunction

Returns true if there is a global function with that name

 

method HasFunction(aName: String): Boolean

 

Boolean HasFunction(String aName)

 

Function HasFunction(aName As String) As Boolean

Parameters:

  • aName:

Include

 

method Include(aFileName: String; aData: String)

 

void Include(String aFileName, String aData)

 

Sub Include(aFileName As String, aData As String)

Parameters:

  • aFileName:
  • aData:

IntRun  protected

 

method IntRun: Object

 

Object IntRun()

 

Function IntRun() As Object

Pause    (declared in ScriptComponent)

Pause the engine (only works if Debug is true).

 

method Pause

 

void Pause()

 

Sub Pause()

Run    (declared in ScriptComponent)

Run the current script.

 

method Run

 

void Run()

 

Sub Run()

RunFunction (ScriptStatus, String, array of Object): Object

Run a function in the engine. Note that this will fail with an exception if there's no given function with that name. Use HasFunction to find if there is. The initialstatus is used for debugging when you want to step into a function instead of just run it.

 

method RunFunction(initialStatus: ScriptStatus; name: String; params args: array of Object): Object

 

Object RunFunction(ScriptStatus initialStatus, String name, params Object[] args)

 

Function RunFunction(initialStatus As ScriptStatus, name As String, ParamArray args As Object()) As Object

Parameters:

  • initialStatus:
  • name:
  • args:

RunFunction (String, array of Object): Object    (declared in ScriptComponent)

Run a function by it's name. Returns the result of the function if any. The function must exist, if not an exception is thrown.

 

method RunFunction(name: String; params args: array of Object): Object

 

Object RunFunction(String name, params Object[] args)

 

Function RunFunction(name As String, ParamArray args As Object()) As Object

Parameters:

  • name:
  • args:

SetDebug  protected

 

method SetDebug(b: Boolean)

 

void SetDebug(Boolean b)

 

Sub SetDebug(b As Boolean)

Parameters:

  • b:

StepInto    (declared in ScriptComponent)

Step into the next function call (if any, else steps over it). Only works if Debug = true.

 

method StepInto

 

void StepInto()

 

Sub StepInto()

StepOut    (declared in ScriptComponent)

Step out of the current function. Only works if Debug = true.

 

method StepOut

 

void StepOut()

 

Sub StepOut()

StepOver    (declared in ScriptComponent)

Step over the next function call. Only works if Debug = true.

 

method StepOver

 

void StepOver()

 

Sub StepOver()

Stop    (declared in ScriptComponent)

Stop the engine.

 

method Stop

 

void Stop()

 

Sub Stop()

 

DebugDebugger    (declared in ScriptComponent)

Called when a code breakpoint is triggered. Like an EcmaScript "debugger;" statement.

 

event DebugDebugger: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugDebugger()

 

Event DebugDebugger As EventHandler<ScriptDebugEventArgs>

DebugException    (declared in ScriptComponent)

Called when an Exception occurs in the engine. Only works when Debug = true.

 

event DebugException: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugException()

 

Event DebugException As EventHandler<ScriptDebugEventArgs>

DebugExceptionUnwind    (declared in ScriptComponent)

Called when an Exception occurs in the engine and isn't caught. Only works when Debug = true.

 

event DebugExceptionUnwind: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugExceptionUnwind()

 

Event DebugExceptionUnwind As EventHandler<ScriptDebugEventArgs>

DebugFrameEnter    (declared in ScriptComponent)

Called when a function is entered. Only works when Debug = true.

 

event DebugFrameEnter: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugFrameEnter()

 

Event DebugFrameEnter As EventHandler<ScriptDebugEventArgs>

DebugFrameExit    (declared in ScriptComponent)

Called when a function is exited. Only works when Debug = true.

 

event DebugFrameExit: EventHandler<ScriptDebugExitScopeEventArgs>;

 

delegate EventHandler<ScriptDebugExitScopeEventArgs> DebugFrameExit()

 

Event DebugFrameExit As EventHandler<ScriptDebugExitScopeEventArgs>

DebugThreadExit    (declared in ScriptComponent)

 

event DebugThreadExit: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugThreadExit()

 

Event DebugThreadExit As EventHandler<ScriptDebugEventArgs>

DebugTracePoint    (declared in ScriptComponent)

Called when the engine is at a source line. Only works when Debug = true.

 

event DebugTracePoint: EventHandler<ScriptDebugEventArgs>;

 

delegate EventHandler<ScriptDebugEventArgs> DebugTracePoint()

 

Event DebugTracePoint As EventHandler<ScriptDebugEventArgs>

NonThreadedIdle    (declared in ScriptComponent)

Called when the engine is waiting to be resumed, when it's paused. When RunInThread is false, this can be used to handle windows messages. Only works when Debug = true.

 

event NonThreadedIdle: EventHandler;

 

delegate EventHandler NonThreadedIdle()

 

Event NonThreadedIdle As EventHandler

StatusChanged    (declared in ScriptComponent)

Triggered when the Status property is changed.

 

event StatusChanged: EventHandler;

 

delegate EventHandler StatusChanged()

 

Event StatusChanged As EventHandler