AVM2 Overview を翻訳しよう
Adobeのdevnetで公開されている文書「Adobe ActionScript Virtual Machine 2 (AVM2) Overview (PDF, 400K)」を翻訳しようというページです。FlashPlayer9から導入されたAVM2についての、公式かつ詳細な文書です。
以下に、PDF内の英文全文を、引用マーク(>)付きで引用します。この英文の著作権は全てAdobeにあります。英文の、Wikiフォーマットに整形する以外の編集は一切行わないで下さい。引用マークも消さないで下さい。斜体やリンクは出来るだけ原文に沿ってください。尚、警告その他が来た場合は即刻ページを削除します。
訳文は、対応する英文の下に、英文を消さずに掲載してください。ルールを守っていただければ、誰でも自由に編集していただいて構いません。誤訳や誤字脱字を発見した場合も、自由に直していただいて構いません。但し、その場合は一言添えていただけると良いかもしれません。
それでははじまりはじまり。
Adobe ®
ActionScript Virtual Machine 2 (AVM2) Overview
ActionScript Virtual Machine2 (AVM2) 概要
May 2007
Copyright © 2006–2007 Adobe Systems Incorporated. All rights reserved.
NOTICE: All information contained herein is the property of Adobe Systems Incorporated. No part of this publication (whether in hardcopy or electronic form) may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written consent of Adobe Systems Incorporated.
Adobe, the Adobe Logo, and ActionScript, are trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. All other trademarks are the property of their respective owners.
This publication and the information herein is furnished AS IS, is subject to change without notice, and should not be construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies, makes no warranty of any kind (express, implied, or statutory) with respect to this publication, and expressly disclaims any and all warranties of merchantability, fitness for particular purposes, and noninfringement of third party rights.
Adobe Systems Incorporated
345 Park Avenue
San Jose, CA 95110
(408) 536-6000
Contents
目次
- AVM2 Overview を翻訳しよう
- ActionScript Virtual Machine2 (AVM2) 概要
- 5 AVM2 instructions
- instruction name
- add
- add_i
- astype
- astypelate
- bitand
- bitnot
- bitor
- bitxor
- call
- callmethod
- callproperty
- callproplex
- callpropvoid
- callstatic
- callsuper
- callsupervoid
- checkfilter
- coerce
- coerce_a
- coerse_s
- construct
- constructprop
- constructsuper
- convert_b
- convert_i
- convert_d
- convert_o
- convert_u
- convert_s
- initproperty
- newclass
1 Introduction
1 導入
The Adobe® ActionScript™ Virtual Machine 2, or AVM2 for short, was designed to execute programs written in the ActionScript 3.0 language. ActionScript 3.0 is based on ECMAScript, the international standardized programming language for scripting. ActionScript 3.0 is compliant with the ECMAScript Language Specification, Third Edition (ECMA-262). It also contains functionality based on ongoing work on ECMAScript Edition 4, occurring within the Ecma International standards body.
Adobe® ActionScript™ Virtual Machine 2 (以下AVM2)は、ActionScript 3.0 によって書かれたプログラムを実行するために設計されました。ActionScript 3.0 は、スクリプティングのための国際標準であるプログラミング言語、ECMAScriptがベースとなっており、その第3版の言語仕様である ECMAScript Language Specification, Third Edition (ECMA-262)に準拠しています。また、Ecma国際標準化団体で現在策定中の ECMAScript Edition 4 に基づく機能も含んでいます。
This document describes the operation of the AVM2 and defines the file formats, data structures, and instruction formats used by the AVM2.
この文書では、AVM2の動作と、AVM2で使用されるファイルフォーマットや、データ構造と命令フォーマットの定義について記述します。
1.1 Concepts
1.1 コンセプト
The AVM2 was designed to support the ActionScript (AS) 3.0 language, and for the remaining chapters it is assumed that the reader is aware of the terminology and concepts of the language.
AVM2はActionScript 3.0をサポートするように設計されました。これ以降の章において、読者はこの言語の用語と概念を知っているものとします。
The following vocabulary and associated definitions are taken from the ActionScript 3.0 Language Specification and are presented only as a review of the material. For full details, refer to the language specification.
以下の用語と関連する定義はActionScript 3.0言語仕様書から取られれたもので、構成要素の概要として提示しています。詳細については、言語仕様書を参照して下さい。
Virtual Machine—A virtual machine is a mechanism that takes as its input the description of a computation and that performs that computation. For the AVM2, the input is in the form of an ABC file, which contains compiled programs; these comprise constant data, instructions from the AVM2 instruction set, and various kinds of metadata.
仮想マシン ― 仮想マシンとは、入力として計算についての記述を受け取り、その計算を実行する機構のことです。AVM2の場合、入力はABCファイルの形式を取ります。 ABCファイルは、コンパイルされたプログラムを含み、定数、AVM2の命令群にある命令と様々なメタデータから構成されます。
Script—A script set of traits and an initializer method; a script populates a top-level environment with definitions and data.
スクリプト ― 形質や初期化メソッドからなるスクリプトの集合。 スクリプトはトップレベルに定義やデータを投入します。
Bytecode, code—Bytecode or code is a specification of computation in the form of a sequence of simple actions on the virtual machine state.
バイトコード、コード・バイトコード、コード ― 単純な仮想マシンの状態に対するアクションの列からなる計算についての詳細な記述。
Scope—Scope is a mapping from names to locations, where no two names are the same. Scopes can nest, and nested scopes can contain bindings (associations between names and locations) that shadow the bindings of the nesting scope.
Object—An object is an unordered collection of named properties, which are containers that hold values.
A value in ActionScript 3.0 is either an Object reference or one of the special values null or undefined.
Namespace—Namespaces are used to control the visibility of a set of properties independent of the major structure of the program.
Class—A class is a named description of a group of objects. Objects are created from classes by instantiation.
Inheritance—New classes can be derived from older classes by the mechanism known as inheritance or subclassing. The new class is called the derived class or subclass of the old class, and the old class is called the base class or superclass.
Trait—A trait is a fixed-name property shared by all objects that are instances of the same class; a set of traits expresses the type of an object.
Method—The word method is used with two separate meanings. 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.
Verification—The contents of an ABC file undergo verification when the file is loaded into the AVM2.
The ABC file is rejected by the verifier if it does not conform to the AVM2 Overview. Verification is described in Chapter 3.
Just-in-Time (JIT) Compiler—AVM2 implementations may contain an optional run-time compiler for transforming AVM2 instructions into processor-specific instructions. Although not an implementation requirement, employing a JIT compiler provides a performance benefit for many applications.
2 The structure of the ActionScript Virtual Machine
2 ActionScript仮想マシンの構造
2.1 Constant values
The constant values of the AVM2 are one of the following types: int, uint, double, string, namespace, undefined, or null. The values of these types appear directly in the ABC file or in the instruction encodings.
Important characteristics of these types are: int—This type is used to represent an integer valued number whose values are 32-bit signed two’s complement integers. The range of values is from -2,147,483,648 to 2,147,483,647 (-231 to 231-1), inclusive.
uint—This type is used for integer valued numbers with values that are 32-bit unsigned two’s complement integers. The range of values is from 0 to 4,294,967,296 (232), inclusive.
double—This type is used for capturing floating point numbers using 64-bit double precision IEEE 754 values as specified in IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Standard. 754- 1985).
string—This type represents a sequence of Unicode characters. Strings are represented in UTF-8 and can be as long as 230-1 bytes.
namespace—Namespaces tie a URI (represented internally by a string) to a trait. The relationship is unidirectional, meaning the namespace data type only contains a URI. Each namespace is also of a particular kind, and there are restrictions regarding the relationships between the trait and kind. These rules are defined later in this chapter.
null—A singleton value representing “no object”.
undefined—A singleton value representing “no meaningful value”. This constant value is allowed only in certain contexts.
The AVM2 utilizes several representations for values in its instruction encoding and in the ABC file in order to provide as compact an encoding as is required.
2.2 Virtual machine overview
Computation in the AVM2 is based on executing the code of a method body in the context of method information, a local data area, a constant pool, a heap for non-primitive data objects created at run-time, and a run-time environment. Many data elements are static and are read at startup from an ABC file, whose structure is defined in Chapter 4.
The code for a method body is composed of instructions, defined in Chapter 5. Each instruction modifies the state of the machine in some way, or has an effect on the external environment by means of input or output.1 The method information determines how the method is used—for example, how default argument values should be substituted for missing arguments when the method is called.
The local data area for the method consists of the operand stack, the scope stack, and the local registers.
1 In practice, the AVM2 may transform the code at run-time by means of a JIT, but this does not affect the
semantics of execution, only its performance.
o The operand stack holds operands for the instructions and receives their results. Arguments are pushed onto the stack top or popped off the stack top. The top element always has address 0; the one below it has address 1, and so on. Stack addresses are not used except as a specification mechanism.
o The scope stack is part of the run-time environment and holds objects that are to be searched by the AVM2 when an instruction is executed that calls for name lookup. Instructions push elements onto the scope stack as part of the implementation of exception handling, closure creation, and for the ActionScript 3.0 with statement.
o The local registers hold parameter values, local variables in some cases, and temporaries.
The constant pool holds constant values that are referenced, ultimately, by the instruction stream: numbers, strings, and various kinds of names.
Instructions and the AVM2 can create new objects at run-time, and these objects are allocated in the heap. The only way to access the heap is through an object allocated in it. Objects in the heap that are no longer needed will eventually be reclaimed by the AVM2.
The run-time environment logically consists of a chain of objects, and named properties on these objects are the locations found during a name lookup at run-time. Name lookup proceeds from the innermost (most recently pushed) scope toward the outermost (global) scope.
The creation of a method closure causes the run-time environment that is current at the time of creation to be captured in the closure; when the closure is later invoked, that scope is made current, and will be extended by the code in the method body.
2.3 Names
Names in the AVM are represented by a combination of an unqualified name and one or more namespaces.
These are collectively called multinames. Multiname entries usually consist of a name index, and a namespace or namespace set index. Some multinames can have the name and/or namespace part resolved at runtime. There are a number of different types of multinames as described below. Properties of objects are always named by a simple QName (a pair of name and namespace). The other types of multinames are used to resolve properties at runtime.
RTQName, RTQNameL, and MultinameL are collectively referred to as runtime multinames.
2.3.1 QName (Qualified Name)
This is the simplest form of a multiname. It is a name with exactly one namespace, hence QName for qualified name. QName entries will have a name index followed by a namespace index. The name index is an index into the string constant pool, and the namespace index is an index into the namespace constant pool.
QNames are typically used to represent the names of variables, and for type annotations.
public var s : String; This code will produce two QName entries, one for the variable s (public namespace, name "s") and one for the type String (public namespace, name "String").
2.3.2 RTQName (Runtime Qualified Name)
This is a runtime QName, where the namespace is not resolved until runtime. RTQName entries will have only a name index, which is an index into the string constant pool. The namespace is determined at runtime.
When a RTQName is an operand to an opcode, there should be a namespace value on the stack the RTQName should use. So when the RTQName is used, the top value of the stack will be popped off, and the RTQName will use that as its namespace.
RTQNames are typically used for qualified names when the namespace is not known at compile time.
var ns = getANamespace(); x = ns::r; This code will produce a RTQName entry for ns::r. It will have a name of "r" and code will be generated to push the value of ns onto the stack.
2.3.3 RTQNameL (Runtime Qualified Name Late)
This is a runtime QName, where both the name and namespace are resolved at runtime. When a RTQNameL is an operand to an opcode there will be a name and a namespace value on the stack. The name value on the stack must be of type String, and the namespace value on the stack must be of type Namespace.
RTQNameLs are typically used for qualified names when neither the name, nor the qualifier is known at compile time.
var x = getAName(); var ns = getANamespace(); w = ns::[x]; This code will produce a RTQNameL entry in the constant pool for ns::[x]. It has neither a name nor a namespace, but code will be generated to push the value of ns and x onto the stack.
2.3.4 Multiname (Multiple Namespace Name)
This is a multiname with a name and a namespace set. The namespace set is used to represent a collection of namespaces. Multiname entries will have a name index followed by a namespace set index. The name index is an index into the string constant pool, and the namespace set index is an index into the namespace set constant pool.
Multinames are typically used for unqualified names. In these cases all open namespaces are used for the multiname.
use namespace t; trace(f); This code will produce a multiname entry for f. It will have a name of "f" and a namespace set for all the open namespaces (the public namespace, the namespace t, and any private or internal namespaces open in that context). At runtime f could be resolved in any of the namespaces specified by the multiname.
2.3.5 MultinameL (Multiple Namespace Name Late)
This is a runtime multiname where the name is resolved at runtime. The namespace set is used to represent a collection of namespaces. MultinameL entries have a namespace set index. The namespace set index is an index into the namespace set constant pool. When a MultinameL is an operand to an opcode there will be a name value on the stack. The name value on the stack must be of type String.
MultinameLs? are typically used for unqualified names where the name is not known at compile time.
use namespace t; trace(o[x]); This code will produce a MultinameL entry. It will have no name, and will have a namespace set for all the open namespaces in that context. Code will be generated to push the value of x onto the stack, and that value will be used as the name.
2.3.6 Resolving multinames
Typically, the order of the search for resolving multinames is the object’s declared traits, its dynamic properties, and finally the prototype chain.2 The dynamic properties and prototype chain search will only happen if the multiname contains the public namespace (dynamic properties are always in the public namespace in ActionScript 3.0; a run-time error is signaled if an attempt is add a non-public property). If a search does not include one or more of these locations, it is noted in the text in the following chapters. Otherwise, you can assume that all three are searched in this order to resolve a multiname.
If the multiname is any type of QName, then the QName will resolve to the property with the same name and namespace as the QName. If no property has the same name and namespace as the QName, the QName is unresolved on that object.
If the multiname has a namespace set, then the object is searched for any properties whose name is the same as the multinames name, and whose namespace matches any of the namespaces in the multinames namespace set.
Since the multiname may have more than one namespace, there could be multiple properties that match the multiname. If there are multiple properties that match a TypeError? is raised since it is ambiguous which property the multiname is referring to. If no properties match, then the multiname is unresolved on that object.
2.4 Method invocation notes
When invoking a method in the AVM2, the first argument is always the “this” value to be used in the method.
All methods take at least 1 argument (the “this” value), followed by any declared arguments.
When invoking the [[Call]] property, the behavior is different for different types of closures. A closure is an object that contains a reference to a method, and the [[Call]] property acts differently depending on whether it is a function, method, or class closure. A function closure is one that is of a global method that isn‘t associated with any instance of a class. A method closure contains an instance method of a class, and will always remember its original “this” value.
function f(){} var a = f; // a is a function closure class C{ function m(){} } var q = new C(); var a = q.m; // a is a method closure If the closure is a function closure, then the first argument passed to [[Call]] is passed on to the method and gets used as the “this” value. If the first argument is null or undefined, then the global object will be used as the “this” value for the method.
2 ECMAScript 3 supports prototyped-based inheritance. See ECMA 262 section 4.2.1 for a description of
the prototype chain.
If the closure is a method closure, then the first argument of [[Call]] will be ignored, and the saved “this” value for the method closure will be passed to the method as the first argument. A method closure records what its original “this” value was and always uses that instead of the first argument to [[Call]].
If the closure is a class closure, and there is 1 argument passed to [[Call]] (in addition to the “this” argument), then the call is treated as a type conversion, and the argument will be coerced to the type represented by the closure.
2.5 Instruction set summary
2.5 命令の要約
This section provides an overview of the AVM2 instruction set. By convention, instructions specific to a specific data type are named with a suffix which indicates the data type on which it operates. Specifically, the following suffixes are used: _b (Boolean), _a (any), _i (int), _d (double), _s (string), _u (unsigned), and _o (object).
2.5.1 Load and store instructions
Local registers can be accessed using the following instructions: getlocal, getlocal0, getlocal1, getlocal2, getlocal3, setlocal, setlocal0, setlocal1, setlocal2, setlocal3.
2.5.2 Arithmetic instructions
The arithmetic instructions provide a full repertoire of mathematical operations. Zero, one, or more typically two operands are removed from the top of the stack and the result of the operation is pushed back onto the operand stack.
Addition is performed using one the following: increment, increment_i, inclocal, inclocal_i, add, add_i.
Subtraction is accomplished using the following: decrement, decrement_i, declocal, declocal_i, subtract, subtract_i.
Multiplication and division are achieved with multiply, multiply_i, divide, and modulo.
In order to reverse the sign of a value, the negate or negate_i instruction can be used.
There also exists a set of instructions that perform value comparisons on the top two entries on the stack replacing them with a true or false value. These include equals, strictequals, lessthan, lessequals, greaterthan, greaterequals, istype, istypelate, and in.
2.5.3 Bit manipulation instructions
Instructions that allow the bits of a value to be manipulated include bitnot, bitand, bitor, bitxor, lshift, rshift, urshift.
Prior to executing these instructions, the value to be operated upon is converted to an integer, if necessary.
2.5.4 Type conversion instructions
The ActionScript language is a loosely typed language where objects are freely converted into whatever types are necessary in order to complete an operation. In some cases explicit conversion is required and for those instances the coerce instructions are provided. These include coerce, convert_b, coerce_a, convert_i, convert_d, coerce_s, convert_s, convert_u, and convert_o.
2.5.5 Object creation and manipulation instructions
2.5.5 オブジェクトの生成と操作
Entities are created by using one of the following instructions: newclass, newobject, newarray, newactivation.
オブジェクトは、newclass、newobject、newarray、newactivationのいずれかによって作られます。
In order to invoke an object’s constructor the instructions construct, constructsuper, and constructprop are used.
オブジェクトのコンストラクタを起動するには、construct、constructsuper、constructpropが使われます。
Namespaces can be constructed dynamically using dxns and dxnslate.
名前空間はdxnsかdxnslateによって動的に生成することができます。
2.5.6 Stack management instructions
A number of instructions provide direct access to manipulate values placed on the stack. Instructions that push a value directly include pushnull, pushundefined, pushtrue, pushfalse, pushnan, pushbyte, pushshort, pushstring, pushint, pushdouble, pushscope, and pushnamespace.
A value can be removed from the stack by using pop, while dup duplicates the value at the top of the stack, and similarly swap exchanges the top two values on the stack.
2.5.7 Control transfer instructions
The control transfer instructions transfer execution to an instruction other than the one immediately following the transfer instruction. The transfer can be unconditional or based upon a comparison operation that is implicit with the instruction.
The conditional branches instructions include iflt, ifle, ifnlt, ifnle, ifgt, ifge, ifngt, ifnge, ifeq, ifne, ifstricteq, ifstrictne, iftrue, and iffalse. These instructions perform any necessary type conversions in order to implement the compare; the conversion rules are outlined in ECMA-262.
The label instruction is used to mark the target position of backwards branch instruction. Thus the target location of every backwards branch instruction should land on a label instruction.
The lookupswitch instruction provides a compact form for encoding a multi-way compare expression.
2.5.8 Function invocation and return instructions
There are a number of instructions to invoke functions and methods. The call instruction implements a fully compliant rendition of Function.prototype.call of the ECMA-262 specification. To invoke object instance methods the callmethod instruction is utilized. Likewise for calling class, also known as static methods, callstatic exists. In order to invoke instance methods not on an object, but on its base class, callsuper is used. For named elements which are invoked as a method and for which the ActionScript compiler can validate the usage as such, callproperty and callproplex are available. The latter is for the case when the object for which the property being invoked exists on the stack.
For cases in which the return value of the call is never used, callpropvoid and callsupervoid can be used in place of callproperty and callsuper, respectively.
2.5.9 Exception instructions
An exception is thrown programmatically using the throw instruction. Exceptions can also be thrown by various AVM instructions when an abnormal condition is encountered.
The try/catch statement in the ActionScript language is translated into a table of intervals, and target instructions that are specified in the method body portion of the abc file. The table defines a range of instructions over which a given exception type may be caught. Thus if during the execution of a given set of instructions an exception is thrown and there is an associated entry in the exception table, program execution will continue at the target instruction specified in the table.
2.5.10 Debugging instructions
Unlike many traditional execution environments the debugging facilities of the AVM2 are tightly intertwined with a series of instructions that are placed directly in the execution stream. To track current file name and line number information debugfile and debugline are emitted at appropriate points in the instruction stream. In cases where additional debugging detail is required, the debug instruction is used. For example, the names of local variables are provided by this mechanism.
3 Loading, linking, verification, and execution
3.1 Overview
An ABC file is processed by the AVM2 in four logical phases, known as loading, linking, verification, and execution. These phases overlap and, in particular, verification overlaps with all of the other phases.
During loading, the ABC file is read into memory and decoded. For example, the constant pool is transformed to an in-memory data structure using different encodings. Verification at this stage is relative to the structure of the ABC file, which must conform to the definitions presented in the next chapter.
During linking, some names referenced from individual fields of the ABC file structure are resolved, and the resulting objects are linked together into a more complex data structure. For example, a class definition’s “base class” field names the base class; resolving that name finds the definition of the base class, and a final class object for the derived class is created based on information from the two definition objects. Verification at this stage is relative to this web of objects: the names mentioned must resolve; the resulting traits sets must be coherent; and so on.
During execution, the bytecodes representing compiled code in the ABC file are run through an interpreter, thus performing computation. Verification at this stage is relative to the stream of instructions and the contents of the execution stack: instructions must not jump outside the bytecode array; instructions that require certain operand types can be applied only to operands whose known type is the correct one; the code must not use more stack and register space than it has reserved; and so on.
When verification fails during any of these phases, the AVM2 throws a VerifyError?. VerifyErrors? thrown during execution can be caught by the program.
The AVM2 interleaves linking with both loading and execution. When linking is performed during loading, forward references are precluded; for example, class definitions can only reference previously defined classes as base classes. In contrast, when linking is performed during execution, some references to undefined entities may not be flagged as errors; for example, a method that uses the name of a type that hasn’t been defined may not cause a VerifyError? to be thrown provided the method isn’t invoked.
3.2 Loading and linking
During the loading and linking phase, the following steps occur. (Note that a fair amount of linking is deferred until the execution phase.) • Each ABC file is loaded into memory and decoded. This initial decoding verifies that the ABC file has the correct structure and that the fields that matter at this stage contain valid references to other parts of the ABC file.
• Trait objects are created for classes and scripts.
• Subclass/superclass relationships are resolved. The trait set of each class’s superclass is merged into the trait set for the class, and interfaces in the class’s interface set are looked up. Early resolution ensures that the inheritance graph is a tree.
• The constant pool is constructed. Each reference to another element of the constant pool is resolved (it must be in range for the correct type).
• Method bodies are linked with their method information (signature) structures.
3.3 Execution
This section describes the state of the virtual machine as it is observed by the executing bytecode.
3.3.1 Program invocation and exit
One of the entries in the ABC file is an array of script_info entries (see the next chapter). Each of these entries contains a reference to an initialization method for the script and a set of traits to be defined in the script’s environment. The last entry in that array is the entry point for the ABC file; that is, the last entry’s initialization method contains the first bytecode that’s run when the ABC file is executed.
The other scripts’ initialization blocks are run on demand, when entities exported from those scripts are first referenced by the program during property lookup.
As far as the virtual machine is concerned, the initialization blocks are normal methods, and they should signal normal termination by executing one of the return instructions (OP_returnvalue, OP_returnvoid). The value returned by a script is ignored.
3.3.2 Class initialization
The class’s static initializer will be run when the newclass instruction is executed on the class_info entry for the class.
3.3.3 Method entry
When a method body is first entered, its execution environment is set up in a particular way. In the following discussion, method_info and method_body_info refer to structures defined in the next chapter.
When control enters a method, three local data areas are allocated for it, as outlined in Chapter 2—an operand stack segment, a scope stack segment, and a set of local registers. The operand stack segment holds operands to the instructions; values are pushed onto that stack or popped off it by most instructions. The scope stack segments holds scope objects in which the virtual machine will look up names at execution time. Objects are pushed onto the scope stack by OP_pushscope and OP_pushwith, and popped off by OP_popscope and by the exception handling machinery. The local registers hold parameter values, local variables, and temporaries.
On method entry, the state of these data areas is as follows.
• The operand stack is empty and has room for method_body_info.max_stack values.
• The scope stack is empty and has room for method_body_info.max_scope_stack values.
• There are method_body_info.local_count registers.
• Register 0 holds the “this” object. This value is never null.
• Registers 1 through method_info.param_count holds parameter values coerced to the declared types of the parameters. If fewer than method_body_info.local_count values are supplied to the call then the remaining values are either the values provided by default value declarations (optional arguments) or the value undefined.
• If NEED_REST is set in method_info.flags, the method_info.param_count+1 register is set up to reference an array that holds the superflous arguments.
• If NEED_ARGUMENTS is set in method_info.flags, the method_info.param_count+1 register is set up to reference an “arguments” object that holds all the actual arguments: see ECMA-262 for more information. (The AVM2 is not strictly compatible with ECMA-262; it creates an Array object for the “arguments” object, whereas ECMA-262 requires a plain Object.) 3.3.4 Execution mechanics
Execution begins with the first instruction of the code in the method_body_info. The address of this first instruction is 0. The first byte of each instruction is the opcode, which is followed by zero or more bytes of operands. The instruction may modify the local data areas as well as objects on the heap, and it may create new objects on the heap either directly or indirectly. (The AVM2 instruction set is defined in Section 2.5.) Branch and jump instructions add a signed offset to the program counter to effectuate the branch. The base value for the program counter is the instruction address following the instruction.
3.3.5 Calling and returning
When one of the call instructions is executed, a new local data area is created for the called function. The called function has no access to the local data area of its caller. The actual parameter values are coerced to the types expected by the called function as part of the call protocol.
The return instructions transfer a single value from the returning function’s stack, or the implied value undefined, to the caller. The returned value is coerced to the returning function’s declared return type as part of the return protocol. The coerced value replaces the operands of the call instruction in the calling method’s stack, and the called method’s local data area is destroyed.
3.3.6 Exception handling
Exception handlers are defined by a table associated with each method. The table defines a range of bytecode addresses across which a particular handler is active, the bytecode address of the handler, and a type which is used to determine whether the handler will handle a particular exception.
When an exception is thrown, the call stack is unwound until a method is found that contains a handler which covers the current program counter and whose type is a supertype of the type of the object thrown. The method containing the handler is reactivated and the program counter is set to point to the first address of the handler. The value and scope stacks in the handling method are cleared before the handler is entered.
A finally clause is normally translated as an exception handler that accepts any type of value, which it catches and rethrows after the body of the finally block finishes executing.
3.4 Verification
As noted earlier, verification does not happen all at once. Verification is often put off until a datum is actually needed or until some dependent object has been loaded, so that forward references will be possible.
The following list summarizes some of the verification errors signaled by the AVM2. (Not all verification errors are listed.) • There must be no nonzero bits above bit 30 in a u30 value.
• No control flow instruction must cause control to be transferred outside the code vector or into the middle of another instruction.
• Multiple control flow instructions to the same instruction must have compatible scope stacks, operand stacks, and register values.
• Named types (for example, in coerce instructions or in a base class reference) must always be uniquely resolvable.
• Names may not reference index zero of the name pool unless explicitly specified for that particular name field.
• Some name fields (for example, instance_info) require the referenced name to be a QName.
• A class cannot subclass a final class or an interface.
• The interface set of a class cannot reference interface zero, and must reference interfaces (not classes).
• Method indices for callmethod and callstatic must provably be within the range of the receiver object’s method table.
• When an instruction definition section contains wording along the lines of “<value> must be less than <constraint>”, this usually implies a static constraint that is checked by the verifier.
4 The ActionScript Byte Code (abc) format
4 ActionScript Byte Code (abc) フォーマット
Syntactically complete sections of ActionScript code are processed by a compiler into ActionScript Byte Code segments. These segments are described by the abcFile structure, which is defined below. The abcFile structure is the unit of loading and execution used by the AVM2.
正しい構文の ActionScript コードのセクションは、コンパイラによって ActionScript Byte Code セグメントへと処理されます。これらのセグメントは、以下に示す abcFile 構造体で表されます。abcFile 構造体は AVM2 によるロード、実行の単位です。
The abcFile structure describes the interpretation of a block of 8-bit bytes. Despite the name, the contents of an abcFile does not need to be read from a file in the file system; it can be generated dynamically by a runtime compiler or other tools. The use of the word “file” is historical.
abcFile 構造体とは 8 ビットバイトによるブロックの読み取り方を表します。その名前に反して、abcFile の内容はファイルから読み込まれるだけでなく、実行時にコンパイラや他のツールによって生成することもできます。file という単語を使っているのは歴史的な理由です。
The abcFile structure comprises primitive data, structured data, and arrays of primitive and structured data.
abcFile 構造体は、基本型や構造体、また基本型や構造体の配列を含みます。
The following sections describe all the data formats.
以下の節で全てのデータフォーマットについて詳述します。
Primitive data include integers and floating-point numbers encoded in various ways.
基本型は、多様な方法でエンコードされた整数型や浮動小数点型を含みます。
Structured data, including the abcFile itself, are presented here using a C-like structural notation, with individual named fields. Fields within this structure are in reality just sequences of bytes that are interpreted according to their type. The fields are stored sequentially without any padding or alignment.
構造体(abcFile そのものも含む)は、個々のフィールドに名前が付けられた、C 言語の構造体に似た書き方で表します。この構造体の中のフィールドは、それらの型に応じて解釈される単なるバイト列です。フィールドはパディングやアラインメントを含まずに連続的に保存されています。
4.1 Primitive data types
4.1 基本データ型
Multi-byte primitive data are stored in little-endian order (less significant bytes precede more significant bytes). Negative integers are represented using two’s complement.
マルチバイトの基本データ型は、リトルエンディアン(下位バイトが上位バイトより先に来る)で格納されています。負の整数は 2 の補数で表されています。
The type u8 represents a one-byte unsigned integer value. The type u16 represents a two-byte unsigned integer value. The type s24 represents a three-byte signed integer value. The type u30 represents a variable-length encoded 30-bit unsigned integer value. The types u32 and s32 represent variable-length encoded 32-bit unsigned and signed integer values respectively. The type d64 defines an 8-byte IEEE-754 floating point value. The high byte of the double value contains the sign and upper bits of the exponent, and the low byte contains the least significant bits of the significand.
- u8 型は、符号なし 1 バイト整数を表します。
- u16 型は、符号なし 2 バイト整数を表します。
- s24 型は、符号付き 3 バイト整数を表します。
- u30 型は、可変長エンコードされた符号なし 30 ビット整数を表します。
- u32 と s32 型は、可変長エンコードされた符号なし、符号あり 32 ビット整数を表します。
- d64 型は、8 バイトの IEEE-754 浮動小数点値を定義します。double 値の上位バイトは符号と指数の上位ビットで、下位バイトは仮数の下位ビットです。
The variable-length encoding for u30, u32, and s32 uses one to five bytes, depending on the magnitude of the value encoded. Each byte contributes its low seven bits to the value. If the high (eighth) bit of a byte is set, then the next byte of the abcFile is also part of the value. In the case of s32, sign extension is applied: the seventh bit of the last byte of the encoding is propagated to fill out the 32 bits of the decoded value.
u30、u32、s32 で用いる可変長エンコードは、エンコードされる値の大きさにおおじて 1 から 5 バイトを使用します。それぞれのバイトが持つ下位の 7 ビットがエンコードされている値となります。最上位(8 つ目の)ビットが 1 であれば、abcFile 内の次のバイトも値の一部となります。s32 の場合は符号の拡張が適用されます。最後のバイトの 7 ビット目が、デコードされた値の 32 ビット(訳注:32 番目のビットという意味ではない)を埋めるために伝播されます。
4.2 abcFile
4.2 abcFile
abcFile { u16 minor_version u16 major_version cpool_info constant_pool u30 method_count method_info method[method_count] u30 metadata_count metadata_info metadata[metadata_count] u30 class_count instance_info instance[class_count] class_info class[class_count] u30 script_count script_info script[script_count] u30 method_body_count method_body_info method_body[method_body_count] }
abcFile
{
u16 minor_version
u16 major_version
cpool_info constant_pool
u30 method_count
method_info method[method_count]
u30 metadata_count
metadata_info metadata[metadata_count]
u30 class_count
instance_info instance[class_count]
class_info class[class_count]
u30 script_count
script_info script[script_count]
u30 method_body_count
method_body_info method_body[method_body_count]
}
The abcFile structure describes an executable code block with all its constant data, type descriptors, code, and metadata. It comprises the following fields.
abcFile 構造体は、定数データ、型の識別子、コード、メタデータからなる実行可能なコードブロックを表します。以下に示すフィールドを含みます。
minor_version, major_version The values of major_version and minor_version are the major and minor version numbers of the abcFile format. A change in the minor version number signifies a change in the file format that is backward compatible, in the sense that an implementation of the AVM2 can still make use of a file of an older version. A change in the major version number denotes an incompatible adjustment to the file format. As of the publication of this overview, the major version is 46 and the minor version is 16.
- minor_version, major_version
- major_version と minor_version の値は、abcFile フォーマットのメジャー、マイナーバージョンです。マイナーバージョンの変化は、ファイルフォーマットに後方互換性のある変更があったこと、つまり古いバージョンのファイルに対しても AVM2 の実装が使えることを表しています。メジャーバージョンの変化は、ファイルフォーマットに互換性がない修正があったことを表しています。
この概要が公開された時点で、メジャーバージョンは 46、マイナーバージョンは 16 です。
constant_pool The constant_pool is a variable length structure composed of integers, doubles, strings, namespaces, namespace sets, and multinames. These constants are referenced from other parts of the abcFile structure.
- constant_pool
- constant_pool は、integer、double、string、namespace、namespace セット、multiname からなる可変長の構造体です。これらの定数は abcFile 構造体の他の場所から参照されます。
method_count, method The value of method_count is the number of entries in the method array. Each entry in the method array is a variable length method_info structure. The array holds information about every method defined in this abcFile. The code for method bodies is held separately in the method_body array (see below). Some entries in method may have no body—this is the case for native methods, for example.
- method_count, method
- method_count の値は method 配列の要素数です。method 配列のそれぞれの要素は可変長の method_info 構造体です。配列は、この abcFile で定義されている全てのメソッドについての情報を保持しています。メソッドの本体は method_body 配列に別に保持されています(下記参照)。method のうちのいくつか、例えばネイティブメソッドの場合には本体を持ちません。
metadata_count, metadata The value of metadata_count is the number of entries in the metadata array. Each metadata entry is a metadata_info structure that maps a name to a set of string values.
- metadata_count、metadata
- metadata_count の値は metadata 配列の要素数です。metadata の要素は、名前を文字列のセットにマッピングする metadata_info 構造体です。
class_count, instance, class The value of class_count is the number of entries in the instance and class arrays. Each instance entry is a variable length instance_info structure which specifies the characteristics of object instances created by a particular class. Each class entry defines the characteristics of a class. It is used in conjunction with the instance field to derive a full description of an AS Class.
- class_count、instance、class
- class_count の値は instance と class 配列の要素数です。 instance の要素は、特定のクラスによって作られたオブジェクトインスタンスの特徴を示す、可変長の instance_info 構造体です。
class の要素はクラスの特徴を示します。AS Class の詳細を導くため、instance フィールドとともに使われます。
script_count, script The value of script_count is the number of entries in the script array. Each script entry is a script_info structure that defines the characteristics of a single script in this file. As explained in the previous chapter, the last entry in this array is the entry point for execution in the abcFile.
- script_count、script
- script_count の値は script 配列の要素数です。script のそれぞれの要素は、ファイル内の 1 つのスクリプトの特徴を定義する script_info 構造体です。前の章で説明したとおり、この配列の最後の要素は abcFile を実行する際のエントリポイントとなります。
method_body_count, method_body The value of method_body_count is the number of entries in the method_body array. Each method_body entry consists of a variable length method_body_info structure which contains the instructions for an individual method or function.
- method_body_count、method_body
- method_body_count の値は method_body 配列の要素数です。method_body のそれぞれの要素は、個別のメソッドや機能の命令を含む、可変長の method_body_info 構造体です。
4.3 Constant pool
4.3 定数プール
The constant pool is a block of array-based entries that reflect the constants used by all methods. Each of the count entries (for example, int_count) must be one more than the number of entries in the corresponding array, and the first entry in the array is element “1”. For all constant pools, the index “0” has a special meaning, typically a sensible default value. For example, the “0” entry is used to represent the empty sting (""), the any namespace, or the any type (*) depending on the context it is used in. When “0” has a special meaning it is described in the text below.
定数プールは、配列ベースの要素の集まりで、メソッドから用いられる定数を示しています。それぞれの個数要素(例えば int_count)は、対応する配列の要素数より 1 大きい数でなければならず、配列の最初の要素の添字は 1 となります。定数プールの全てにおいて、添字 0 は特別な意味、主にデフォルト値としての意味を持ちます。例えば、0 番目の要素は空の文字列("")や、任意の名前空間や、任意の型(*)などを、それぞれのコンテキストに応じて表します。0 が特別な意味を持つケースについては、以下で述べます。
cpool_info { u30 int_count s32 integer[int_count] u30 uint_count u32 uinteger[uint_count] u30 double_count d64 double[double_count] u30 string_count string_info string[string_count] u30 namespace_count namespace_info namespace[namespace_count] u30 ns_set_count ns_set_info ns_set[ns_set_count] u30 multiname_count multiname_info multiname[multiname_count] }
cpool_info
{
u30 int_count
s32 integer[int_count]
u30 uint_count
u32 uinteger[uint_count]
u30 double_count
d64 double[double_count]
u30 string_count
string_info string[string_count]
u30 namespace_count
namespace_info namespace[namespace_count]
u30 ns_set_count
ns_set_info ns_set[ns_set_count]
u30 multiname_count
multiname_info multiname[multiname_count]
}
If there is more than one entry in one of these arrays for the same entity, such as a name, the AVM may or may not consider those two entries to mean the same thing. The AVM currently guarantees that names flagged as belonging to the “private” namespace are treated as unique.
これらの中からある配列の中で同一の値を示す要素(例えば名前)が 2 つ以上ある場合、AVM はそれらの要素を同一と見たり見なかったりします。現在、AVM は private 名前空間に属する名前であればユニークなものとして扱います。
int_count, integer The value of int_count is the number of entries in the integer array, plus one. The integer array holds integer constants referenced by the bytecode. The “0” entry of the integer array is not present in the abcFile; it represents the zero value for the purposes of providing values for optional parameters and field initialization.
- int_count, integer
- int_count の値は integer 配列の要素数 + 1 です。integer 配列は、バイトコードから参照される符号付き整数の定数を保持します。0 番目の要素は abcFile 中には存在しませんが、値は 0 であり、オプションの引数や、フィールドの初期化に用いられます。
uint_count, uinteger The value of uint_count is the number of entries in the uinteger array, plus one. The uinteger array holds unsigned integer constants referenced by the bytecode. The “0” entry of the uinteger array is not present in the abcFile; it represents the zero value for the purposes of providing values for optional parameters and field initialization.
- uint_count, uinteger
- uint_count の値は uinteger 配列の要素数 + 1 です。uinteger 配列は、バイトコードから参照される符号なし整数の定数を保持します。0 番目の要素は abcFile 中には存在しませんが、値は 0 であり、オプションの引数や、フィールドの初期化に用いられます。
double_count, double The value of double_count is the number of entries in the double array, plus one. The double array holds IEEE double-precision floating point constants referenced by the bytecode. The “0” entry of the double array is not present in the abcFile; it represents the NaN (Not-a-Number) value for the purposes of providing values for optional parameters and field initialization.
- double_count, double
- double_count の値は double 配列の要素数 + 1 です。double 配列は、バイトコードから参照される IEEE 倍精度浮動小数点値の定数を保持します。0 番目の要素は abcFile 中には存在しませんが、値は NaN(Not-a-Number)であり、オプションの引数や、フィールドの初期化に用いられます。
string_count, string The value of string_count is the number of entries in the string array, plus one. The string array holds UTF-8 encoded strings referenced by the compiled code and by many other parts of the abcFile. In addition to describing string constants in programs, string data in the constant pool are used in the description of names of many kinds. Entry “0” of the string array is not present in the abcFile; it represents the empty string in most contexts but is also used to represent the “any” name in others (known as “*” in ActionScript).
- string_count, string
- string_count の値は string 配列の要素数 + 1 です。string 配列は、バイトコードや、abcFile 内の他の多くの場所から参照される UTF-8 エンコードされた文字列を保持します。定数プール内の文字列は、プログラム中の文字列定数を示すのに加え、多種にわたる名前を記述するためにも使われます。0 番目の要素は abcFile 中には存在しません。ほとんどの場合、値は空の文字列ですが、任意の名前(ActionScript 中では "*")として使われることもあります。
namespace_count, namespace The value of namespace_count is the number of entries in the namespace array, plus one. The namespace array describes the namespaces used by the bytecode and also for names of many kinds. Entry “0” of the namespace array is not present in the abcFile; it represents the “any” namespace (known as “*” in ActionScript).
- namespace_count, namespace
- namespace_count の値は namespace 配列の要素数 + 1 です。namespace 配列は、バイトコードや多くの名前から参照される名前空間を表します。0 番目の要素は abcFile 中には存在しませんが、値は任意の名前空間(ActionScript 中では "*")です。
ns_set_count, ns_set The value of ns_set_count is the number of entries in the ns_set array, plus one. The ns_set array describes namespace sets used in the descriptions of multinames. The “0” entry of the ns_set array is not present in the abcFile.
- ns_set_count, ns_set
- ns_set_count の値は ns_set 配列の要素数 + 1 です。ns_set 配列は、multiname の詳細で用いられる namespace セットを表します。や多くの名前から参照される名前空間を表します。0 番目の要素は abcFile 中には存在しません。
multiname_count, multiname The value of multiname_count is the number of entries in the multiname array, plus one. The multiname array describes names used by the bytecode. The “0” entry of the multiname array is not present in the abcFile.
- multiname_count, multiname
- multiname_count の値は multiname 配列の要素数 + 1 です。multiname 配列は、バイトコードから用いられる名前を表します。0 番目の要素は abcFile 中には存在しません。
4.4 String
4.4 文字列
A string_info element encodes a string of 16-bit characters on a length-and-data format. The meaning of each character is normally taken to be that of a Unicode 16-bit code point. The data are UTF-8 encoded. For more information on Unicode, see unicode.org.
string_info は 16 ビットの文字を長さ-データの形式でエンコードします。通常、そ れぞれの文字は 16 ビット Unicode として解釈されます。データは UTF-8 でエンコードされています。Unicode についての詳しい情報は unicode.org を参照してください。
string_info { u30 size u8 utf8[size] }
string_info
{
u30 size
u8 utf8[size]
}
4.4.1 Namespace
4.4.1 名前空間
A namespace_info entry defines a namespace. Namespaces have string names, represented by indices into the string array, and kinds. User-defined namespaces have kind CONSTANT_Namespace or CONSTANT_ExplicitNamespace and a non-empty name. System namespaces have empty names and one of the other kinds, and provides a means for the loader to map references to these namespaces onto internal entities.
namespace_info は名前空間を定義します。名前空間は、string 配列内で名前空間の名前を指す添字と、種類を持ちます。ユーザが定義した名前空間の種類は CONSTANT_Namespace か CONSTANT_ExplicitNamespace で、空でない名前を持ちます。システムの名前空間は、空の名前と、その他の種類のうち 1 つを持ち、これらの名前空間を内部の実体に対応付けるための参照をローダに与えます。(訳注:この最後の一文が訳しづらかったので改善希望)
namespace_info { u8 kind u30 name }
namespace_info
{
u8 kind
u30 name
}
A single byte defines the type of entry that follows, thus identifying how the name field should be interpreted by the loader. The name field is an index into the string section of the constant pool. A value of zero denotes an empty string. The table below lists the legal values for kind.
先頭の 1 バイトが、以下に続く要素の種類を定義します。これにより、name フィールドをローダがどう解釈するかが決まります。name フィールドは定数プールの string 配列の添字です。0 は空白の文字列を表します。kind の値として有効なものを以下の表に示します。
Namespace Kind Value CONSTANT_Namespace 0x08 CONSTANT_PackageNamespace 0x16 CONSTANT_PackageInternalNs 0x17 CONSTANT_ProtectedNamespace 0x18 CONSTANT_ExplicitNamespace 0x19 CONSTANT_StaticProtectedNs 0x1A CONSTANT_PrivateNs 0x05
| Namespace Kind | Value |
| CONSTANT_Namespace | 0x08 |
| CONSTANT_PackageNamespace | 0x16 |
| CONSTANT_PackageInternalNs | 0x17 |
| CONSTANT_ProtectedNamespace | 0x18 |
| CONSTANT_ExplicitNamespace | 0x19 |
| CONSTANT_StaticProtectedNs | 0x1A |
| CONSTANT_PrivateNs | 0x05 |
4.4.2 Namespace set
4.4.2 名前空間セット
An ns_set_info entry defines a set of namespaces, allowing the set to be used as a unit in the definition of multinames.
ns_set_info はマルチネームの定義で単位として用いられる名前空間のセットを定義します。
ns_set_info { u30 count u30 ns[count] }
ns_set_info
{
u30 count
u30 ns[count]
}
The count field defines how many ns’s are identified for the entry, while each ns is an integer that indexes into the namespace array of the constant pool. No entry in the ns array may be zero.
count フィールドはこの要素の ns がいくつ指定されるかを定義します。それぞれの ns は定数プールの namespace 配列の要素を示す整数です。ns 配列のどの要素も 0 になることはありません。
4.4.3 Multiname
4.4.3 マルチネーム
A multiname_info entry is a variable length item that is used to define multiname entities used by the bytecode. There are many kinds of multinames. The kind field acts as a tag: its value determines how the loader should see the variable-length data field. The layout of the contents of the data field under a particular kind is described below by the multiname_kind_ structures.
multiname_info はバイトコードから用いられるマルチネームの実体を定義するために用いられる可変長の要素です。マルチネームには多くの種類があります。kind フィールドがタグとして作用し、可変長の data フィールドをローダが解釈する方法を決定します。それぞれの kind に対する data フィールドの内容については、以下の multiname_kind_ 構造体を参照してください。
multiname_info { u8 kind u8 data[] }
multiname_info
{
u8 kind
u8 data[]
}
Multiname Kind Value CONSTANT_QName 0x07 CONSTANT_QNameA 0x0D CONSTANT_RTQName 0x0F CONSTANT_RTQNameA 0x10 CONSTANT_RTQNameL 0x11 CONSTANT_RTQNameLA 0x12 CONSTANT_Multiname 0x09 CONSTANT_MultinameA 0x0E CONSTANT_MultinameL 0x1B CONSTANT_MultinameLA 0x1C
| Multiname Kind | Value |
| CONSTANT_QName | 0x07 |
| CONSTANT_QNameA | 0x0D |
| CONSTANT_RTQName | 0x0F |
| CONSTANT_RTQNameA | 0x10 |
| CONSTANT_RTQNameL | 0x11 |
| CONSTANT_RTQNameLA | 0x12 |
| CONSTANT_Multiname | 0x09 |
| CONSTANT_MultinameA | 0x0E |
| CONSTANT_MultinameL | 0x1B |
| CONSTANT_MultinameLA | 0x1C |
Those constants ending in “A” (such as CONSTANT_QNameA) represent the names of attributes.
CONSTANT_QNameA などの末尾についている "A" は、属性の名前であることを示しています。
QName
QName
The multiname_kind_QName format is used for kinds CONSTANT_QName and CONSTANT_QNameA.
multiname_kind_QName 形式は、CONSTANT_QName と CONSTANT_QNameA で用いられます。
multiname_kind_QName { u30 ns u30 name }
multiname_kind_QName
{
u30 ns
u30 name
}
The ns and name fields are indexes into the namespace and string arrays of the constant_pool entry, respectively. A value of zero for the ns field indicates the any (“*”) namespace, and a value of zero for the name field indicates the any (“*”) name.
ns と name フィールドは、定数プールの namespace と string 配列の要素を示す番号です。ns フィールドの値が 0 であれば、任意の名前空間("*")を表します。name フィールドの値が 0 であれば、任意の名前("*")を表します。
RTQName
The multiname_kind_RTQName format is used for kinds CONSTANT_RTQName and CONSTANT_RTQNameA. multiname_kind_RTQName
{ u30 name }
The single field, name, is an index into the string array of the constant pool. A value of zero indicates the any (“*”) name.
RTQName
multiname_kind_RTQName 形式は、CONSTANT_RTQName と CONSTANT_RTQNameA で用いられます。
multiname_kind_RTQName
{
u30 name
}
name フィールドは、定数プールの string 配列の要素を示す番号です。0 の場合は任意の名前("*")を表します。
RTQNameL
The multiname_kind_RTQNameL format is used for kinds CONSTANT_RTQNameL and CONSTANT_RTQNameLA.
multiname_kind_RTQNameL { } This kind has no associated data.
RTQNameL
multiname_kind_RTQNameL 形式は、CONSTANT_RTQNameL と CONSTANT_RTQNameLA で用いられます。
multiname_kind_RTQNameL
{
}
関連するデータはありません。
Multiname The multiname_kind_Multiname format is used for kinds CONSTANT_Multiname and CONSTANT_MultinameA.
multiname_kind_Multiname { u30 name u30 ns_set } The name field is an index into the string array, and the ns_set field is an index into the ns_set array. A value of zero for the name field indicates the any (“*”) name. The value of ns_set cannot be zero.
Multiname
multiname_kind_Multiname 形式は、CONSTANT_Multiname と CONSTANT_MultinameA で用いられます。
multiname_kind_Multiname
{
u30 name
u30 ns_set
}
name と ns_set フィールドは、定数プールの string と ns_set 配列の要素を示す番号です。name フィールドの値が 0 であれば、任意の名前("*")を表します。ns_set は 0 になりません。
MultinameL The multiname_kind_MultinameL format is used for kinds CONSTANT_MultinameL and CONSTANT_MultinameLA.
multiname_kind_MultinameL { u30 ns_set } The ns_set field is an index into the ns_set array of the constant pool. The value of ns_set cannot be zero.
MultinameL
multiname_kind_MultinameL 形式は、CONSTANT_MultinameL と CONSTANT_MultinameLA で用いられます。
multiname_kind_MultinameL
{
u30 ns_set
}
ns_set フィールドは、定数プールの ns_set 配列の要素を示す番号です。ns_set は 0 になりません。
4.5 Method signature
4.5 メソッドシグネチャ
The method_info entry defines the signature of a single method. method_info { u30 param_count u30 return_type u30 param_type[param_count] u30 name u8 flags option_info options param_info param_names }
method_info はメソッド 1 つのシグネチャを定義します。
method_info
{
u30 param_count
u30 return_type
u30 param_type[param_count]
u30 name
u8 flags
option_info options
param_info param_names
}
The fields are as follows:
フィールドは以下の通りです。
param_count, param_type The param_count field is the number of formal parameters that the method supports; it also represents the length of the param_type array. Each entry in the param_type array is an index into the multiname array of the constant pool; the name at that entry provides the name of the type of the corresponding formal parameter. A zero value denotes the any (“*”) type.
- param_count, param_type
- param_count フィールドは、メソッドが公式にサポートする引数の数です。param_type の要素数も表します。param_type 配列のそれぞれの要素は、定数プールの multiname 配列の添字で、対応する引数の型を表します。値が 0 であれば、任意の型("*")を表します。
return_type The return_type field is an index into the multiname array of the constant pool; the name at that entry provides the name of the return type of this method. A zero value denotes the any (“*”) type.
- return_type
- return_type フィールドは、定数プールの multiname 配列の添字で、このメソッドの戻り値の型を表します。値が 0 であれば、任意の型("*")を表します。
name The name field is an index into the string array of the constant pool; the string at that entry provides the name of this method. If the index is zero, this method has no name.
- name
- name フィールドは、定数プールの string の添字で、このメソッドの名前を表します。値が 0 であればメソッドは名前を持ちません。
flags The flag field is a bit vector that provides additional information about the method. The bits are described by the following table. (Bits not described in the table should all be set to zero.)
- flags
- flags フィールドは、メソッドについての追加情報をビット列で表します。以下の表にビットの意味を示します(この表にないビットは 0 でなければなりません)。
Name Value Meaning NEED_ARGUMENTS 0x01 Suggests to the run-time that an “arguments” object (as specified by the ActionScript 3.0 Language Reference) be created. Must not be used together with NEED_REST. See Chapter 3. NEED_ACTIVATION 0x02 Must be set if this method uses the newactivation opcode. NEED_REST 0x04 This flag creates an ActionScript 3.0 rest arguments array. Must not be used with NEED_ARGUMENTS. See Chapter 3. HAS_OPTIONAL 0x08 Must be set if this method has optional parameters and the options field is present in this method_info structure. SET_DXNS 0x40 Must be set if this method uses the dxns or dxnslate opcodes. HAS_PARAM_NAMES 0x80 Must be set when the param_names field is present in this method_info structure.
| Name | Value | Meaning |
| NEED_ARGUMENTS | 0x01 | ランタイムに "arguments" オブジェクト(ActionScript 3.0 Language Reference に示されている)を作るように指示します。NEED_REST と同時に使ってはいけません。Chapter 3 参照。 |
| NEED_ACTIVATION | 0x02 | メソッドが newactivation オペコードを使うときにセットされます。 |
| NEED_REST | 0x04 | このフラグによって、ActionScript 3.0 rest 引数配列が作られます。NEED_ARGUMENTS と同時に使ってはいけません。Chapter 3 参照。 |
| HAS_OPTIONAL | 0x08 | メソッドがオプション引数を持ち、この method_info 構造体の options フィールドが存在するときセットされます。 |
| SET_DXNS | 0x40 | このメソッドが dxns または dxnslate オペコードを使うときにセットされます。 |
| HAS_PARAM_NAMES | 0x80 | この method_info 構造体の param_names フィールドが存在するときセットされます。 |
options This entry may be present only if the HAS_OPTIONAL flag is set in flags.
- options
- この要素は flags の HAS_OPTIONAL フラグがセットされている場合のみ存在します。
param_names This entry may be present only if the HAS_PARAM_NAMES flag is set in flags.
- param_names
- この要素は flags の HAS_PARAM_NAMES フラグがセットされている場合のみ存在します。
4.5.1 Optional parameters
4.5.1 オプション引数
The option_info entry is used to define the default values for the optional parameters of the method. The number of optional parameters is given by option_count, which must not be zero nor greater than the parameter_count field of the enclosing method_info structure.
option_info 要素は、メソッドのオプション引数のデフォルト値を定義するのに用いられます。オプション引数の数は option_count で与えられます。この値は 0 以外で、このメソッドを表す method_info の parameter_count 以下でなければなりません。
option_info { u30 option_count option_detail option[option_count] } option_detail { u30 val u8 kind }
option_info
{
u30 option_count
option_detail option[option_count]
}
option_detail
{
u30 val
u8 kind
}
Each optional value consists of a kind field that denotes the type of value represented, and a val field that is an index into one of the array entries of the constant pool. The correct array is selected based on the kind.
それぞれのオプション引数は、値の型を示す kind フィールドと、定数プールの要素を示す添字である val フィールドによって表されます。kind に基づいて正しい配列が選択されます。
Constant Kind Value Entry CONSTANT_Int 0x03 integer CONSTANT_UInt 0x04 uinteger CONSTANT_Double 0x06 double CONSTANT_Utf8 0x01 string CONSTANT_True 0x0B - CONSTANT_False 0x0A - CONSTANT_Null 0x0C - CONSTANT_Undefined 0x00 - CONSTANT_Namespace 0x08 namespace CONSTANT_PackageNamespace 0x16 namespace CONSTANT_PackageInternalNs 0x17 Namespace CONSTANT_ProtectedNamespace 0x18 Namespace CONSTANT_ExplicitNamespace 0x19 Namespace CONSTANT_StaticProtectedNs 0x1A Namespace CONSTANT_PrivateNs 0x05 namespace
| Constant Kind | Value | Entry |
| CONSTANT_Int | 0x03 | integer |
| CONSTANT_UInt | 0x04 | uinteger |
| CONSTANT_Double | 0x06 | double |
| CONSTANT_Utf8 | 0x01 | string |
| CONSTANT_True | 0x0B | - |
| CONSTANT_False | 0x0A | - |
| CONSTANT_Null | 0x0C | - |
| CONSTANT_Undefined | 0x00 | - |
| CONSTANT_Namespace | 0x08 | namespace |
| CONSTANT_PackageNamespace | 0x16 | namespace |
| CONSTANT_PackageInternalNs | 0x17 | Namespace |
| CONSTANT_ProtectedNamespace | 0x18 | Namespace |
| CONSTANT_ExplicitNamespace | 0x19 | Namespace |
| CONSTANT_StaticProtectedNs | 0x1A | Namespace |
| CONSTANT_PrivateNs | 0x05 | namespace |
4.5.2 Parameter names
4.5.2 パラメータ名
The param_names entry is available only when the HAS_PARAM_NAMES bit is set in the flags. Each param_info element of the array is an index into the constant pool’s string array. The parameter name entry exists solely for external tool use and is not used by the AVM2.
param_info 要素は、flags の HAS_PARAM_NAMES ビットがセットされているときのみ有効です。配列内のそれぞれの param_name 要素は、定数プールの string 配列に対する添字です。(訳注:原文で param_names と param_info が逆になっていると思われたので逆にしてます。)引数の名前は外部のツールが使うだけで、AVM2 は使用しません。
param_info { u30 param_name[param_count] }
param_info
{
u30 param_name[param_count]
}
4.6 metadata_info
4.6 metadeta_info
The metadata_info entry provides a means of embedding arbitrary key /value pairs into the ABC file. The AVM2 will ignore all such entries.
metadeta_info 要素は、任意のキー/値のペアを ABC ファイルに埋め込むために用いられます。AVM2 はこれらの要素をすべて無視します。
metadata_info { u30 name u30 item_count item_info items[item_count] }
metadata_info
{
u30 name
u30 item_count
item_info items[item_count]
}
The name field is an index into the string array of the constant pool; it provides a name for the metadata entry. The value of the name field must not be zero. Zero or more items may be associated with the entry; item_count denotes the number of items that follow in the items array.
name フィールドは定数プールの string 配列に対する添字で、メタデータの名前を表します。このフィールドの値は 0 であってはいけません。0 個以上の項目が、要素に関連付けられます。item_count は items 配列の要素数を表します。
item_info { u30 key u30 value }
item_info
{
u30 key
u30 value
}
The item_info entry consists of item_count elements that are interpreted as key/value pairs of indices into the string table of the constant pool. If the value of key is zero, this is a keyless entry and only carries a value.
item_info 要素は item_count 個のキー、値のペアからなります。キーと値は、定数プールの string に対する添字で表されます。key の値が 0 であれば、キーがなく値だけがあるものとして扱われます。
4.7 Instance
4.7 インスタンス
The instance_info entry is used to define the characteristics of a run-time object (a class instance) within the AVM2. The corresponding class_info entry is used in order to fully define an ActionScript 3.0 Class.
instance_info 要素は、AVM2 の実行時オブジェクト(クラスのインスタンス)の特性を表すために用いられます。完全な ActionScript 3.0 Class が定義には、対応する class_info 要素が用いられます。
instance_info { u30 name u30 super_name u8 flags u30 protectedNs u30 intrf_count u30 interface[intrf_count] u30 iinit u30 trait_count traits_info trait[trait_count] }
instance_info
{
u30 name
u30 super_name
u8 flags
u30 protectedNs
u30 intrf_count
u30 interface[intrf_count]
u30 iinit
u30 trait_count
traits_info trait[trait_count]
}
name The name field is an index into the multiname array of the constant pool; it provides a name for the class. The entry specified must be a QName.
- name
- name フィールドは、定数プールの multiname 配列に対する添字で、クラスの名前を表します。名前は QName でなければなりません。
super_name The super_name field is an index into the multiname array of the constant pool; it provides the name of the base class of this class, if any. A value of zero indicates that this class has no base class.
- super_name
- super_name フィールドは、定数プールの multiname 配列に対する添字で、このクラスの基底クラスを表します。値が 0 であれば基底クラスを持たないことを表します。
flags The flags field is used to identify various options when interpreting the instance_info entry. It is bit vector; the following entries are defined. Other bits must be zero. Name Value Meaning CONSTANT_ClassSealed 0x01 The class is sealed: properties can not be dynamically added to instances of the class. CONSTANT_ClassFinal 0x02 The class is final: it cannot be a base class for any other class. CONSTANT_ClassInterface 0x04 The class is an interface. CONSTANT_ClassProtectedNs 0x08 The class uses its protected namespace and the protectedNs field is present in the interface_info structure.
- flags
- flags フィールドは、instance_info 要素を解釈するためのオプションを示すビット列です。以下の値が定義されており、他のビットは 0 でなければなりません。
| Name | Value | Meaning |
| CONSTANT_ClassSealed | 0x01 | クラスが sealed であることを表します。このクラスのインスタンスに動的にプロパティを追加することはできません。 |
| CONSTANT_ClassFinal | 0x02 | クラスが final であることを表します。このクラスは他のクラスの基底クラスになることができません。 |
| CONSTANT_ClassInterface | 0x04 | クラスはインスタンスであることを表します。 |
| CONSTANT_ClassProtectedNs | 0x08 | クラスが protected 名前空間を用い、interface_info 構造体の protectedNs フィールドが存在することを表します。 |
protectedNs This field is present only if the CONSTANT_ProtectedNs bit of flags is set. It is an index into the namespace array of the constant pool and identifies the namespace that serves as the protected namespace for this class.
- protectedNs
- このフィールドは、flags の CONSTANT_ProtectedNs ビットがセットされている場合のみ存在します。値は、定数プールの namespace 配列に対する添字で、このクラスの protected 名前空間として用いられる名前空間を表します。
intrf_count, interface The value of the intrf_count field is the number of entries in the interface array. The interface array contains indices into the multiname array of the constant pool; the referenced names specify the interfaces implemented by this class. None of the indices may be zero.
- intrf_count、interface
- intrf_count の値は、interface 配列の要素数を表します。interface 配列は、定数プールの multiname 配列に対する添字から成り、このクラスによって実装されるインタフェースの名前を表します。すべての添字は 0 であってはなりません。
iinit This is an index into the method array of the abcFile; it references the method that is invoked whenever an object of this class is constructed. This method is sometimes referred to as an instance initializer.
- iinit
- abcFile の method 配列に対する添字で、このクラスのオブジェクトが構築されるときに呼び出されるメソッドを表します。このメソッドはインスタンスイニシャライザと呼ばれることもあります。
trait_count, trait The value of trait_count is the number of elements in the trait array. The trait array defines the set of traits of a class instance. The next section defines the meaning of the traits_info structure.
- trait_count、trait
- trait_count の値は、trait 配列の要素数です。trait 配列は、クラスインスタンスの trait を表します。次のセクションで traits_info 構造体の意味を定義します。
4.8 Trait
4.8 Trait
A trait is a fixed property of an object or class; it has a name, a type, and some associated data. The traits_info structure bundles these data.
trait は、オブジェクトやクラスの固定プロパティで、名前、型、関連するいくつかのデータから成ります。traits_info 構造体はこれらのデータを含みます。
traits_info { u30 name u8 kind u8 data[] u30 metadata_count u30 metadata[metadata_count] }
traits_info
{
u30 name
u8 kind
u8 data[]
u30 metadata_count
u30 metadata[metadata_count]
}
name The name field is an index into the multiname array of the constant pool; it provides a name for the trait. The value can not be zero, and the multiname entry specified must be a QName.
- name
- name フィールドは、定数プールの multiname 配列に対する添字で、trait の名前を表します。値が 0 であってはならず、multiname の指定された要素は QName でなければなりません。
kind The kind field contains two four-bit fields. The lower four bits determine the kind of this trait. The upper four bits comprise a bit vector providing attributes of the trait. See the following tables and sections for full descriptions.
- kind
- kind フィールドは、2 つの 4 ビットフィールドから成ります。下位の 4 ビットは、trait の種類を定めます。上位の 4 ビットは、trait の属性を定めます。詳しくは以下の表やセクションを参照してください。
data The interpretation of the data field depends on the type of the trait, which is provided by the low four bits of the kind field. See below for a full description.
- data
- data フィールドの解釈は、kind フィールドの下位 4 ビットで与えられる trait の型によって異なります。詳しくは後述します。
metadata_count, metadata These fields are present only if ATTR_Metadata is present in the upper four bits of the kind field. The value of the metadata_count field is the number of entries in the metadata array. That array contains indices into the metadata array of the abcFile.
- metadata_count、metadata
- これらのフィールドは、kind フィールドの上位 4 ビットで ATTR_Metadata がセットされているときのみ存在します。
metadata_count フィールドは、metadata 配列の要素数を表します。配列の要素は abcFile の metadata 配列に対する添字です。
4.8.1 Summary of trait types
4.8.1 trait 型の要約
The following table summarizes the trait types. Type Value Trait_Slot 0 Trait_Method 1 Trait_Getter 2 Trait_Setter 3 Trait_Class 4 Trait_Function 5 Trait_Const 6 4.8.2 Slot and const traits
以下の表が trait 型の要約です。
| Type | Value |
| Trait_Slot | 0 |
| Trait_Method | 1 |
| Trait_Getter | 2 |
| Trait_Setter | 3 |
| Trait_Class | 4 |
| Trait_Function | 5 |
| Trait_Const | 6 |
4.8.2 Slot and const traits
4.8.2 Slot と const trait
A kind value of Trait_Slot (0) or Trait_Const (6) requires that the data field be read using trait_slot, which takes the following form: trait_slot { u30 slot_id u30 type_name u30 vindex u8 vkind }
kind の値が Trait_Slot (0) か Trait_Const (6) である場合、data フィールドは以下で定義される trait_slot を用いて読み込む必要があります。
trait_slot
{
u30 slot_id
u30 type_name
u30 vindex
u8 vkind
}
slot_id The slot_id field is an integer from 0 to N and is used to identify a position in which this trait resides. A value of 0 requests the AVM2 to assign a position.
- slot_id
- slot_id フィールドは、0 から N の整数値で、この trait がどこに位置するかを定めます。値が 0 である場合は、AVM2 が位置を定めます。
type_name This field is used to identify the type of the trait. It is an index into the multiname array of the constant_pool. A value of zero indicates that the type is the any type (*).
- type_name
- このフィールドは、trait の型を決めるために用いられます。値は定数プールの multiname 配列に対する添字で、0 であれば任意の型(“*”)を表します。
vindex This field is an index that is used in conjunction with the vkind field in order to define a value for the trait. If it is 0, vkind is empty; otherwise it references one of the tables in the constant pool, depending on the value of vkind.
- vindex
- このフィールドは、trait の値を決めるために vkind とあわせて用いられる添字です。値が 0 であれば、vkind は空です。それ以外であれば、添字は vkind に応じた定数プールを参照します。
vkind This field exists only when vindex is non-zero. It is used to determine how vindex will be interpreted. See the “Constant Kind” table above for details.
- vkind
- このフィールドは、vindex が 0 でないときのみ存在し、vindex が持つ意味を決定します。詳細は上にある“Constant Kind”の表を参照してください。
4.8.3 Class traits
4.8.3 Class traits
A kind value of Trait_Class (0x04) implies that the trait_class entry should be used.
Trait_Class (0x04) の kind の値は、trait_class 要素を用いることを表します。
trait_class { u30 slot_id u30 classi }
trait_class
{
u30 slot_id
u30 classi
}
slot_id The slot_id field is an integer from 0 to N and is used to identify a position in which this trait resides. A value of 0 requests the AVM2 to assign a position.
- slot_id
- slot_id フィールドは、0 から N の整数値で、この trait がどこに位置するかを定めます。値が 0 である場合は、AVM2 が位置を定めます。
class The classi field is an index that points into the class array of the abcFile entry.
- classi(訳注:原文では class となっているがたぶん間違い)
- classi フィールドは、abcFile の class 配列に対する添字です。
4.8.4 Function traits
4.8.4 Function traits
A kind value of Trait_Function (0x05) implies that the trait_function entry should be used.
Trait_Function (0x05) の kind の値は、trait_function 要素を用いることを表します。
trait_function { u30 slot_id u30 function }
trait_function
{
u30 slot_id
u30 function
}
slot_id The slot_id field is an integer from 0 to N and is used to identify a position in which this trait resides. A value of 0 requests the AVM2 to assign a position.
- slot_id
- slot_id フィールドは、0 から N の整数値で、この trait がどこに位置するかを定めます。値が 0 である場合は、AVM2 が位置を定めます。
function The function field is an index that points into the method array of the abcFile entry.
- function
- function フィールドは、abcFile の method 配列に対する添字です。
4.8.5 Method, getter, and setter traits
4.8.5 メソッド、getter、setter traits
A kind value of Trait_Method (0x01), Trait_Getter (0x02) or Trait_Setter (0x03) implies that the trait_method entry should be used.
Trait_Method (0x01) 、Trait_Getter (0x02)、Trait_Setter(0x03)の kind の値は、trait_method 要素を用いることを表します。
trait_method { u30 disp_id u30 method }
trait_method
{
u30 disp_id
u30 method
}
disp_id The disp_id field is a compiler assigned integer that is used by the AVM2 to optimize the resolution of virtual function calls. An overridden method must have the same disp_id as that of the method in the base class. A value of zero disables this optimization.
- disp_id
- disp_id は、コンパイラによって設定される整数で、AVM2 が仮想関数の呼び出しの解決を最適化するのに用います。オーバーライドされたメソッドは、基底クラスのものと同じ disp_id の値でなければなりません。
method The method field is an index that points into the method array of the abcFile entry.
- method
- method フィールドは、abcFile の method 配列に対する添字です。
4.8.6 Trait attributes
4.8.6 Trait 属性
As previously mentioned the upper nibble of the kind field is used to encode attributes. A description of how the attributes are interpreted for each kind is outlined below. Any other combination of attribute with kind is ignored.
以前に述べたとおり、kind フィールドの上位 4 ビットは、属性を表すために用いられます。以下の表に、それぞれの kind に応じてどのように属性が解釈されるかを示します。ここにない attribute と kind の組み合わせは無視されます。
Attributes Value ATTR_Final 0x1 Is used with Trait_Method, Trait_Getter and Trait_Setter. It marks a method that cannot be overridden by a sub-class ATTR_Override 0x2 Is used with Trait_Method, Trait_Getter and Trait_Setter. It marks a method that has been overridden in this class ATTR_Metadata 0x4 Is used to signal that the fields metadata_count and metadata follow the data field in the traits_info entry
| Attributes | Value | |
| ATTR_Final | 0x1 | Trait_Method、Trait_Getter、Trait_Setter で用いられ、メソッドがサブクラスによってオーバーライドされてはいけないことを示します。 |
| ATTR_Override | 0x2 | Trait_Method、Trait_Getter、Trait_Setter で用いられ、メソッドがこのクラスでオーバーライドされていることを示します。 |
| ATTR_Metadata | 0x4 | traits_info 要素で、metadata_count、metadata フィールドが data フィールドの次に存在することを示します。。 |
4.9 Class
4.9 Class
The class_info entry is used to define characteristics of an ActionScript 3.0 class.
class_info 要素は ActionScript 3.0 クラスの性質を定義するために用いられます。
class_info { u30 cinit u30 trait_count traits_info traits[trait_count] }
class_info
{
u30 cinit
u30 trait_count
traits_info traits[trait_count]
}
cinit This is an index into the method array of the abcFile; it references the method that is invoked when the class is first created. This method is also known as the static initializer for the class.
- cinit
- abcFile の method 配列に対する添字で、クラスが最初に作られたときに呼び出されるメソッドを指します。このメソッドはクラスのスタティックイニシャライザとしても知られています。
trait_count, trait The value of trait_count is the number of entries in the trait array. The trait array holds the traits for the class (see above for information on traits).
- trait_count、trait
- trait_count の値は trait 配列の要素数です。trait 配列はクラスの trait を表します(trait については上を参照してください)。
4.10 Script
4.10 Script
The script_info entry is used to define characteristics of an ActionScript 3.0 script.
script_info 要素は ActionScript 3.0 スクリプトの性質を定義するために用いられます。
script_info { u30 init u30 trait_count traits_info trait[trait_count] }
script_info
{
u30 init
u30 trait_count
traits_info trait[trait_count]
}
init The init field is an index into the method array of the abcFile. It identifies a function that is to be invoked prior to any other code in this script.
- init
- init フィールドは abcFile の method 配列に対する添字で、スクリプト中の他のコードに先駆けて実行される関数を指します。
trait_count, trait The value of trait_count is the number of entries in the trait array. The trait array is the set of traits defined by the script.
- trait_count、trait
- trait_count は trait 配列の要素数です。trait 配列はスクリプトで定義される trait の集合です。
4.11 Method body
4.11 Method body
The method_body_info entry holds the AVM2 instructions that are associated with a particular method or function body. Some of the fields in this entry declare the maximum amount of resources the body will consume during execution. These declarations allow the AVM2 to anticipate the requirements of the method without analyzing the method body prior to execution. The declarations also serve as promises about the resource boundary within which the method has agreed to remain.3 There can be fewer method bodies in the method_body table than than there are method signatures in the method table―some methods have no bodies. Therefore the method_body contains a reference to the method it belongs to, and other parts of the abcFile always reference the method table, not the method_body table. 3 Any code loaded from an untrusted source will be examined in order to verify that the code stays within the declared limits.
method_body_info 要素は、メソッドや関数の本体に関連付けられた AVM2 命令を保持します。この要素のいくつかのフィールドは実行時に本体が消費するリソースの最大量を宣言します。これらの宣言によって、メソッド本体を実行する前に、そのメソッドによる要求を AVM2 が予測できます。また、メソッドが存続する領域がリソースの境界であることを約束します(信頼されていないソースから読み込まれたコードに対して、コードが宣言された境界内にとどまることが検証されます)。
method_body テーブルの中に、method テーブルにあるメソッドのシグネチャの数よりも少ないメソッド本体がある場合もあります。その場合は、いくつかのメソッドには本体が無いということになります。よって、method_body はそれが属しているメソッドに対する参照を持ち、abcFile の他の部分からは、常に method_body ではなく method テーブルを参照するようにします。
method_body_info { u30 method u30 max_stack u30 local_count u30 init_scope_depth u30 max_scope_depth u30 code_length u8 code[code_length] u30 exception_count exception_info exception[exception_count] u30 trait_count traits_info trait[trait_count] }
method_body_info
{
u30 method
u30 max_stack
u30 local_count
u30 init_scope_depth
u30 max_scope_depth
u30 code_length
u8 code[code_length]
u30 exception_count
exception_info exception[exception_count]
u30 trait_count
traits_info trait[trait_count]
}
method The method field is an index into the method array of the abcFile; it identifies the method signature with which this body is to be associated.
- method