-
Notifications
You must be signed in to change notification settings - Fork 0
API Special Values
$state and $args
Overview
$state 和 $args 不是构造器,而是编译器提供的上下文值。它们不能被用作 CompileBlock 的参数名。
$stateand$argsare compiler-provided context values, not constructors. They cannot be used asCompileBlockparameter names.
用途
读取宿主在创建 ScriptDomain 时提供的 ScriptObject 用户状态。
Reads the
ScriptObjectuser state supplied by the host when it creates aScriptDomain.
Returns
没有状态时为 null,否则为宿主提供的对象。
nullwhen no state exists, otherwise the host-supplied object.
@module(MAIN);
export func userName() {
return $state.Name;
}用途
读取当前函数调用收到的全部参数。
Reads all arguments received by the current function call.
Returns
参数集合;可通过 length 和数值索引读取。
An argument collection readable through
lengthand numeric indexes.
@module(MAIN);
export func last() {
return $args[$args.length - 1];
}边界行为
优先使用显式函数参数;仅当调用方允许可变参数时使用 $args。
Prefer explicit function parameters; use
$argsonly when variable arity is part of the contract.
AuroraScript.JIT 4.0.0 · 仓库 · MIT 许可
AuroraScript.JIT 4.0.0 · Repository · MIT License