-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Getting Started
适用版本:4.0.0。
Applies to 4.0.0.
在 .NET 宿主项目中安装 NuGet 包:
Install the NuGet package in the .NET host project:
dotnet add package AuroraScript.JIT --version 4.0.0当前包目标框架为 net8.0、net9.0 和 net10.0。Dynamic 与 OnlyRun 可用于这三个目标;Persistence 需要 net9.0 或更高版本。
The package targets
net8.0,net9.0, andnet10.0.DynamicandOnlyRunwork on all three targets;Persistencerequiresnet9.0or later.
先创建脚本文件 scripts/main.as。@module 必须是第一条有效语句。
First create
scripts/main.as.@modulemust be the first effective statement.
@module(MAIN);
export func main(value) {
return value + 22;
}再创建引擎、编译脚本、创建 Domain 并执行导出函数。
Then create the engine, build the script, create a domain, and execute the exported function.
using AuroraScript;
using AuroraScript.Core;
using AuroraScript.Runtime;
var options = EngineOptions.Default
.WithCompiler(compiler =>
{
compiler.SourceResolver = ScriptSources.FileSystem("./scripts");
compiler.Mode = CompilationMode.Dynamic;
});
var engine = new AuroraEngine(options);
await engine.BuildAsync("main.as");
using var domain = engine.CreateDomain();
var result = domain.Execute("MAIN", "main", ScriptDatum.FromNumber(20));
Console.WriteLine(result); // 42AuroraEngine 负责配置和编译;ScriptDomain 是一次独立运行环境,拥有自己的全局对象和模块实例。
AuroraEngineowns configuration and compilation;ScriptDomainis an isolated execution environment with its own global object and module instances.
- 学习模块、函数、闭包与语法:语言指南。
- 注入全局变量、状态或 CLR 类型:宿主集成。
- 查询对象、方法与参数:脚本 API 参考。
- 选择编译模式并优化热点:性能与基准。
- 使用 MCP、LSP 或 VSIX:工具链。
- Learn modules, functions, closures, and syntax: Language Guide.
- Inject globals, state, or CLR types: Host Integration.
- Look up objects, methods, and parameters: Script API Reference.
- Choose compilation modes and optimize hot paths: Performance and Benchmarks.
- Use MCP, LSP, or the VSIX: Tooling.
AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License