-
Notifications
You must be signed in to change notification settings - Fork 0
API Host ScriptContext
传递给高级宿主回调和 CompileBlock 调用的执行上下文。
Execution context passed to advanced host callbacks and compiled block invocations.
命名空间:AuroraScript.Runtime。类型:class。
Namespace:
AuroraScript.Runtime. Kind: class.
ScriptContext 是公开宿主类型。通过下方签名选择调用方式;对运行时对象、生命周期和异常,应由宿主在边界处明确处理。
Execution context passed to advanced host callbacks and compiled block invocations.
注意
此类型主要用于自定义 CLR 回调和高级闭包调用。
Use this type mainly for custom CLR callbacks and advanced closure invocation.
下面是 ScriptContext 的最小使用方式。
A minimal use of
ScriptContext.
using var domain = engine.CreateDomain();
var context = new ScriptContext(domain);
Console.WriteLine(context.Domain == domain); // True签名
ScriptContext(ScriptDomain domain)ScriptContext(ScriptDomain domain, ScriptObject userState)
创建 ScriptContext 实例。
Use the member according to its public signature.
Parameters:
-
domain
要使用的脚本 Domain。Script Domain to use.
-
userState
与执行上下文关联的用户状态。User state associated with the execution context.
Returns
新建的 ScriptContext 实例。
A new
ScriptContextinstance.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
var value = new ScriptContext(/* 参数 */);读取 Domain 字段。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 ScriptDomain。
Returns
ScriptDomain.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var current = value.Domain;读取 Engine 字段。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 AuroraEngine。
Returns
AuroraEngine.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var current = value.Engine;读取 Global 字段。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 ScriptGlobal。
Returns
ScriptGlobal.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var current = value.Global;读取 Module 字段。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 ScriptModule。
Returns
ScriptModule.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var current = value.Module;读取 UserState 字段。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 ScriptObject。
Returns
ScriptObject.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var current = value.UserState;读取 Target 字段。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 ClosureFunction。
Returns
ClosureFunction.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var current = value.Target;读取 Location 字段。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 long。
Returns
long.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var current = value.Location;签名
ScriptContext With(ScriptModule module, ClosureFunction closure = null)ScriptContext With(ClosureFunction closure)ScriptContext With(ScriptModule module, ClosureFunction closure, ScriptObject userState)
调用 With 完成其公开操作。
Use the member according to its public signature.
Parameters:
-
module
要关联或执行的脚本模块。Script module to associate or execute.
-
closure
要调用的闭包函数。Closure function to invoke.
-
userState
与执行上下文关联的用户状态。User state associated with the execution context.
Returns
返回 ScriptContext。
Returns
ScriptContext.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var result = value.With(/* module */, /* closure */);调用 CallStack 完成其公开操作。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 AuroraStackTrace[]。
Returns
AuroraStackTrace[].
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var result = value.CallStack();调用 StackTrace 完成其公开操作。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 List<AuroraStackTrace>。
Returns
List<AuroraStackTrace>.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptContext value = /* 从宿主 API 获取实例 */;
var result = value.StackTrace();AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License