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 JsPreparedScriptProperties
| Name | Description |
|---|---|
| Url | Gets the URL (or the file name) of the script. |
Methods
| Name | Description |
|---|---|
| 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.csParses and compiles a script.
public static JsPreparedScript Parse(string code, string? url = null, int lineOffset = 0, int columnOffset = 0)Parameters
codestring- The source text.
urlstring?- The URL (or the file name) of the script, used in the stack traces and the error locations.
lineOffsetint- The number of lines before the code in its document (e.g. an inline script of an HTML document).
columnOffsetint- The column of the code in the first line of its document (0-based).
Returns
Exceptions
JsSyntaxErrorException- The script is not valid.
Parse(string, string?, int, int, int)
JsPreparedScript.csParses 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
codestring- The source text.
urlstring?- The URL (or the file name) of the script, used in the stack traces and the error locations.
lineOffsetint- The number of lines before the code in its document (e.g. an inline script of an HTML document).
columnOffsetint- The column of the code in the first line of its document (0-based).
unboundNameFunctionStartint- The index in
codeof thefunctionkeyword of the function expression whose name is not bound, or -1 for none.
Returns
Exceptions
JsSyntaxErrorException- The script is not valid.
TryParse overloads
TryParse(string, string?, int, int, JsPreparedScript?, JsSyntaxErrorException?)
JsPreparedScript.csParses 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
codestringurlstring?lineOffsetintcolumnOffsetintscriptJsPreparedScript?errorJsSyntaxErrorException?
Returns
TryParse(string, string?, int, int, int, JsPreparedScript?, JsSyntaxErrorException?)
JsPreparedScript.csParses 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
codestring- The source text.
urlstring?- The URL (or the file name) of the script, used in the stack traces and the error locations.
lineOffsetint- The number of lines before the code in its document (e.g. an inline script of an HTML document).
columnOffsetint- The column of the code in the first line of its document (0-based).
unboundNameFunctionStartint- The index in
codeof thefunctionkeyword of the function expression whose name is not bound, or -1 for none. scriptJsPreparedScript?- The compiled script, when the script is valid.
errorJsSyntaxErrorException?- The syntax error, when the script is not valid.