Skip to content

API global

Liu.Yandong.Hanks edited this page Aug 19, 2026 · 2 revisions

global

当前 ScriptDomain 的全局执行对象

Global execution object for the current ScriptDomain

脚本 API 目录

Script API Directory

概述

Overview

global 是编译器提供的当前 Domain 全局对象。宿主注入的全局变量和函数可通过它读取;它也公开已加载模块注册表。普通脚本可以直接读取未被局部变量遮蔽的宿主全局名,global 更适合需要显式对象访问时使用。

global is the compiler-provided global object for the current domain. Host-injected variables and functions can be read through it, and it exposes the loaded-module registry. Scripts can usually read an unshadowed host global directly; use global when explicit object access is useful.

global.modules

Returns

当前 Domain 已加载模块的注册表对象。

Registry object for modules loaded in the current domain.

用途

仅用于诊断或高级集成;不要依赖其内部布局作为稳定的应用数据结构。

Intended for diagnostics or advanced integration; do not depend on its internal layout as application data.

@module(MAIN);

export func moduleRegistry() {
    return global.modules;
}

Clone this wiki locally