JS_CompileScript 编辑

Compiles a script for execution.

Syntax

// Added in SpiderMonkey 45

bool
JS_CompileScript(JSContext *cx,
                 const char *ascii, size_t length,
                 const JS::CompileOptions &options,
                 JS::MutableHandleScript script);

bool
JS_CompileUCScript(JSContext *cx,
                   const char16_t *chars, size_t length,
                   const JS::CompileOptions &options,
                   JS::MutableHandleScript script);

// Obsolete since JSAPI 39

bool
JS_CompileScript(JSContext *cx, JS::HandleObject obj,
                 const char *ascii, size_t length,
                 const JS::CompileOptions &options,
                 JS::MutableHandleScript script);

bool
JS_CompileUCScript(JSContext *cx, JS::HandleObject obj,
                   const char16_t *chars, size_t length,
                   const JS::CompileOptions &options,
                   JS::MutableHandleScript script);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
objJS::HandleObjectThe global object, or NULL. If the JSOPTION_COMPILE_N_GO option is set in cx, the resulting script must be executed in this scope, and at most once. Obsolete since JSAPI 39
ascii or charsconst char * or const char16_t *String containing the script to compile.
lengthsize_tThe length, in characters, of source.
optionsJS::CompileOptions &Compile options.
scriptJS::MutableHandleScriptOut parameter. On success, script receives the result script.

Description

JS_CompileScript compiles a script, source, for execution. JS_CompileUCScript is the Unicode version of the function.

The script is associated with a JS object. ascii and chars are the string containing the text of the script. length indicates the size of the text version of the script in characters.

On success, JS_CompileScript and JS_CompileUCScript stores the newly compiled script to *script and returns true. Otherwise, they report an error, stores NULL to *script, and return false.

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:124 次

字数:5124

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文