# 1.2 Script

* `Script.runtime`: 字符串属性，表示当前使用的运行时实现。`QJS` 或 `V8` 。
* `Script.pin()`: 暂时阻止卸载当前脚本。这个行为会被引用计数，因此后面某个地方一定要有个匹配的`unpin()`。通常在你需要手动控制另一个线程的清理工作时，被用在`bindWeak()`的回调中。
* `Script.unpin()`: `pin()` 的逆操作，使当前的脚本可以被卸载。
* `Script.bindWeak(value, fn)`: 监视变量`value`，当`value`被垃圾回收后，或脚本将要被卸载时调用fn函数。该API返回一个`ID`，你可以将该ID传递给`Script.unbindWeak()`，进行显示的清理。当你构造语言绑定时，这个API会非常有用：当一个JS变量不再被需要时，脚本会自动释放Native资源。
* `Script.unbindWeak(id)`: 停止对`Script.bindWeak(value, fn)`监视的变量的监视，并立刻调用`fn`。
* `Script.setGlobalAccessHandler(handler | null)`: 安装或卸载一些处理函数，这些函数用来处理尝试访问不存在的全局变量时发生的异常。这个API在实现一个REPL时非常有用，比如尝试惰性取回数据库id时。\
  其中，`handler`是一个普通的JavaScript对象，该对象需要包含两个属性：\
  \* `enumerate()`: 用于查询那些全局变量存在，必须返回一个字符串数组。\
  \* `get(property)`: 用于取回指定property的值。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://frida.ivory.cafe/1.-yun-xing-shi-xin-xi/1.2-script.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
