1.AVM2基本概念

AVM2用于执行AS3(ActionScript 3.0)语言,根据ES3(ECMAScript语言规范第三版)实现,包含了部分ES4的功能。

文档会包含AVM2的操作文件格式(ABC)、数据结构(数据类型)、AVM2指令格式相关内容。

AS中部分概念如下:

  • 虚拟机(Virtual Machine)
    虚拟机读取输入作为计算的描述并执行计算。

    AVM2的输入ABC文件

    ABC文件包含:
    - 常量数据(constant data)
    - 指令(instructions)
    - 元数据(metadata) - 脚本(Script)
    trait和initializer方法集,顶级定义和数据环境

  • 字节码(Bytecode)
    计算规范,一组简单的顺序动作,用于改变虚拟机状态

  • 作用域(Scope)
    作用域是名称(names)与位置(locations)的映射,可以嵌套。嵌套的作用域包含绑定(bindings,在名称与位置之间,可以跟踪嵌套作用域的绑定)。

  • 对象(Object)
    对象是命名属性(named properties)的无序集合。AS3的值(value)只能是一个对象的引用或者nullundefined

  • 名称空间(Namespace)
    名称空间可以控制一组属性的可见性,而不管程序的结构

  • (Class)
    类是一组对象的命名描述(named description)。对象通过实例化(instantiation)根据类创建。

  • 继承(Inheritance)
    新类从旧类派生的机制,也叫子类化(subclassing)。
    新类叫做派生类(derived class)或子类(subclass)
    旧类叫做基类(base class)或父类(superclass)

  • Trait
    trait是实例化同一个类的多个对象共有的固定名称的属性(fixed-name property)。trait集描述对象的类型。

  • 方法(Method)
    方法有两层意思。
    一层是方法体(method body)。是一个对象,包含代码和数据。
    一层是方法闭包(method closure)。不仅包含方法体,还包含创建该闭包的环境(的引用)。
    函数(function)、构造函数(constructor)、AS3类方法(class method)及其他对象都可以认为是方法闭包。

    One meaning is a method body, which is an object that contains code as well as data that belong to that code or that describe the code.
    The other meaning is a method closure, which is a method body together with a reference to the environment in which the closure was created.
    In this document, functions, constructors, ActionScript 3.0 class methods, and other objects that can be invoked are collectively referred to as method closures.

  • 验证(Verificaiton)
    ABC文件加载到虚拟机后要经过验证,不符合规范的将被拒绝执行。

  • 即时编译器(Just-In-Time Compiler)
    运行时编译器(run-time compiler)将AVM2指令转换为处理器指令。可选的,并不是AVM2实现所必须,依赖于具体的AVM2实现。

上一篇/顶层|下一篇/2.AVM2结构|上级目录/顶层