AngelScript 是当作一个引擎而构建的,当应用程序需要注册函数、属性(properties)和任意数据类型的时候,这个脚本可能会派上用场(原文: AngelScript is structured around an engine where the application should register the functions, properties, and even types, that the scripts will be able to use.)。本脚本库依赖于应用程序,它会被编译到应用程序的一个或多个模块之中(原文: The scripts are then compiled into modules, where the application may have one or more modules, depending on the need of the application.)。应用程序也可以通过各式各样的接口来使用configuration集合的每一个模块(原文:The application can also expose a different interface to each module through the use of configuration groups)。当应用程序需要一个多类型的脚本时,例如图形用户界面,人工智能控制等等本脚本库就显得特别有用了(原文: This is especially useful when the application works with multiple types of scripts, e.g. GUI, AI control, etc.)。
脚本的函数、全局变量和类,每个模块都有它自己的作用域范围(原文: Each module has it's own scope of script functions, global variables, and classes)。即使各个模块可能组建于同一个脚本源码,它们之间通常也不会共享(原文: These are normally not shared between modules, even though multiple modules may be built from the same source scripts)。不过模块可以通过绑定函数来相互配合相互影响(原文: However modules may interact with each others through function binding.)。
作为一个脚本,被编译成 字节码 AngelScript同样也提供了一个虚拟机来作为执行这些字节码的脚本环境,AngelScript同样也提供了一个虚拟机来解析脚本的上下文,来将脚本编译成字节码并执行。(原文:As the scripts are compiled into bytecode AngelScript also provides a virtual machine, also known as a script context, for executing the bytecode)。尽管大多数应用程序可能仅需要一个脚本环境,但是应用程序可以在同一时间获取许多脚本上下文(原文:The application can have any number of script context at the same time, though most applications will probably only need one.)。
这个环境支持可执行体的挂起和恢复,因此,这个应用程序可以很容易的执行就好像同时执行脚本和普通程序一样(原文:The contexts support suspending the execution and then resuming it, so the application can easily implement features such as concurrent scripts and co-routines.)。脚本环境为了获取运行时信息业提供了一个接口,这对调试脚本非常有用(原文:The script context also provides an interface for extracting run-time information, useful for debugging scripts.)。
AngelScript的脚本语言是在众所周知的C + +语法之上增加像Java, C#和D等更现代语言的语法(原文:The script language is based on the well known syntax of C++ and more modern languages such as Java, C#, and D.)。任何人只要了解一些别的语言,或者其他有着类似语法的脚本语言,像Javascript和ActionScript,再用AngelScript会有一种一见如故的感觉(Anyone with some knowledge of those languages, or other script languages with similar syntax, such as Javascript and ActionScript, should feel right at home with AngelScript.)。
跟许多的脚本语言相反,AngelScript是一个强类型的语言,它允许更快更稳定的执行代码与宿主应用程序之间的交互会减少有类型值所需要的运行时间(原文:Contrary to most script languages, AngelScript is a strongly typed language, which permits faster execution of the code and smoother interaction with the host application as there will be less need for runtime evaluation of the true type of values.)。
AngelScript的内存管理是基于一个用于检测和释放的循环引用对象来增加垃圾回收的引用计数(原文:The memory management in AngelScript is based on reference counting with an incremental garbage collector for detecting and freeing objects with circular references)。这就提供了一个可控环境,除非应用程序冻结垃圾回收机制来申请内存(原文:This provides for a controlled environment without application freezes as the garbage collector steps in to free up memory.)。
--------- besterChen
译于2010年2月26日星期五