JsPreparedScript Class

A parsed and compiled script. It is immutable: it can run in several realms and engines, on several threads (e.g. the scripts of a test harness, parsed once for all the pages). The syntax errors of the whole script are reported by JsPreparedScript.Parse, but the body of a nested function is compiled on its first call (once, whichever engine calls it).

public sealed class JsPreparedScript

Properties

NameDescription
UrlGets the URL (or the file name) of the script.

Gets the URL (or the file name) of the script.

public string? Url { get; }

Property value

string?

Methods

NameDescription
Parse(string, string?, int, int)Parses and compiles a script.
Parse(string, string?, int, int, int)Parses and compiles a script in which the named function expression that starts at unboundNameFunctionStart does not bind its name in its scope, as if it were anonymous: its name is the name given by its context (e.g. the key of a property definition) and its source text keeps the name (the function of an event handler content attribute).
TryParse(string, string?, int, int, JsPreparedScript?, JsSyntaxErrorException?)Parses and compiles a script; returns false and the syntax error when the script is not valid.
TryParse(string, string?, int, int, int, JsPreparedScript?, JsSyntaxErrorException?)Parses and compiles a script (see JsPreparedScript.Parse); returns false and the syntax error when the script is not valid.

Parse overloads

Parse(string, string?, int, int)

JsPreparedScript.cs

Parses and compiles a script.

public static JsPreparedScript Parse(string code, string? url = null, int lineOffset = 0, int columnOffset = 0)
Parameters
code string
The source text.
url string?
The URL (or the file name) of the script, used in the stack traces and the error locations.
lineOffset int
The number of lines before the code in its document (e.g. an inline script of an HTML document).
columnOffset int
The column of the code in the first line of its document (0-based).
Returns

JsPreparedScript

Exceptions
JsSyntaxErrorException
The script is not valid.

Parse(string, string?, int, int, int)

JsPreparedScript.cs

Parses and compiles a script in which the named function expression that starts at unboundNameFunctionStart does not bind its name in its scope, as if it were anonymous: its name is the name given by its context (e.g. the key of a property definition) and its source text keeps the name (the function of an event handler content attribute).

public static JsPreparedScript Parse(string code, string? url, int lineOffset, int columnOffset, int unboundNameFunctionStart)
Parameters
code string
The source text.
url string?
The URL (or the file name) of the script, used in the stack traces and the error locations.
lineOffset int
The number of lines before the code in its document (e.g. an inline script of an HTML document).
columnOffset int
The column of the code in the first line of its document (0-based).
unboundNameFunctionStart int
The index in code of the function keyword of the function expression whose name is not bound, or -1 for none.
Returns

JsPreparedScript

Exceptions
JsSyntaxErrorException
The script is not valid.

TryParse overloads

TryParse(string, string?, int, int, JsPreparedScript?, JsSyntaxErrorException?)

JsPreparedScript.cs

Parses and compiles a script; returns false and the syntax error when the script is not valid.

public static bool TryParse(string code, string? url, int lineOffset, int columnOffset, out JsPreparedScript? script, out JsSyntaxErrorException? error)
Parameters
code string
url string?
lineOffset int
columnOffset int
script JsPreparedScript?
error JsSyntaxErrorException?
Returns

bool

TryParse(string, string?, int, int, int, JsPreparedScript?, JsSyntaxErrorException?)

JsPreparedScript.cs

Parses and compiles a script (see JsPreparedScript.Parse); returns false and the syntax error when the script is not valid.

public static bool TryParse(string code, string? url, int lineOffset, int columnOffset, int unboundNameFunctionStart, out JsPreparedScript? script, out JsSyntaxErrorException? error)
Parameters
code string
The source text.
url string?
The URL (or the file name) of the script, used in the stack traces and the error locations.
lineOffset int
The number of lines before the code in its document (e.g. an inline script of an HTML document).
columnOffset int
The column of the code in the first line of its document (0-based).
unboundNameFunctionStart int
The index in code of the function keyword of the function expression whose name is not bound, or -1 for none.
script JsPreparedScript?
The compiled script, when the script is valid.
error JsSyntaxErrorException?
The syntax error, when the script is not valid.
Returns

bool