diff --git a/translated/issues-11.html b/translated/issues-11.html index 8e09048f4f..6b368550bc 100644 --- a/translated/issues-11.html +++ b/translated/issues-11.html @@ -1,16 +1,16 @@ -

Abstract Operations

-

These operations are not a part of the ECMAScript language; they are defined here to solely to aid the specification of the semantics of the ECMAScript language. Other, more specialized abstract operations are defined throughout this specification.

+

抽象操作

+

这些操作不是 ECMAScript 语言的一部分;在这里定义他们只是为了规范 ECMAScript 语言的语义。另外,本规范中还定义了其他特定的抽象操作。

-

Type Conversion

-

The ECMAScript language implicitly performs automatic type conversion as needed. To clarify the semantics of certain constructs it is useful to define a set of conversion abstract operations. The conversion abstract operations are polymorphic; they can accept a value of any ECMAScript language type. But no other specification types are used with these operations.

+

类型转换

+

ECMAScript 语言根据需要会自动执行类型转换。为了解释清楚某些结构的语义,定义一组转换抽象操作是很有用的。转换抽象操作是多态的;他们可以接受一个任意 ECMAScript 类型的值。但是这些操作中没有使用其他相应的规范类型。

ToPrimitive ( _input_ [ , _PreferredType_ ] )

-

The abstract operation ToPrimitive takes an _input_ argument and an optional argument _PreferredType_. The abstract operation ToPrimitive converts its _input_ argument to a non-Object type. If an object is capable of converting to more than one primitive type, it may use the optional hint _PreferredType_ to favour that type. Conversion occurs according to the following algorithm:

+

抽象操作 ToPrimitive 接受一个 _input_ 参数和一个可选的 _PreferredType_ 参数。ToPrimitive 负责把 _input_ 参数转换为一个非对象类型。如果一个对象可以转换为多个原始类型,则应该根据可选提示 _PreferredType_ 来判断转换的类型。根据以下算法进行转换:

1. Assert: _input_ is an ECMAScript language value. 1. If Type(_input_) is Object, then @@ -27,12 +27,12 @@

ToPrimitive ( _input_ [ , _PreferredType_ ] )

1. Return _input_.
-

When ToPrimitive is called with no hint, then it generally behaves as if the hint were Number. However, objects may over-ride this behaviour by defining a @@toPrimitive method. Of the objects defined in this specification only Date objects (see ) and Symbol objects (see ) over-ride the default ToPrimitive behaviour. Date objects treat no hint as if the hint were String.

+

当调用 ToPrimitive 没有提示参数时,通常表现和提示为 Number 类型一样。然而,对象可能通过定义一个 @@toPrimitive 方法,来覆盖这一行为。在本规范中的对象只有 Date 对象 (见 ) 和 Symbol(见 ) 会覆盖默认的 ToPrimitive 行为。Date 对象处理没有提示的调用就像提示为 String 类型一样。

OrdinaryToPrimitive ( _O_, _hint_ )

-

When the abstract operation OrdinaryToPrimitive is called with arguments _O_ and _hint_, the following steps are taken:

+

当使用参数 _O_ 和 _hint_ 调用抽象操作 OrdinaryToPrimitive 时,执行以下步骤:

1. Assert: Type(_O_) is Object. 1. Assert: Type(_hint_) is String and its value is either `"string"` or `"number"`. @@ -53,16 +53,16 @@

OrdinaryToPrimitive ( _O_, _hint_ )

ToBoolean ( _argument_ )

-

The abstract operation ToBoolean converts _argument_ to a value of type Boolean according to :

+

抽象操作 ToBoolean 把参数 _argument_ 转换为一个 Boolean 类型的值,见表

@@ -70,7 +70,7 @@

ToBoolean ( _argument_ )

Undefined @@ -78,7 +78,7 @@

ToBoolean ( _argument_ )

Null @@ -86,7 +86,7 @@

ToBoolean ( _argument_ )

Boolean @@ -94,7 +94,7 @@

ToBoolean ( _argument_ )

Number @@ -102,7 +102,7 @@

ToBoolean ( _argument_ )

String @@ -110,7 +110,7 @@

ToBoolean ( _argument_ )

Symbol @@ -118,7 +118,7 @@

ToBoolean ( _argument_ )

Object @@ -129,16 +129,16 @@

ToBoolean ( _argument_ )

ToNumber ( _argument_ )

-

The abstract operation ToNumber converts _argument_ to a value of type Number according to :

+

抽象操作把 _argument_ 转换为一个 Number 类型的值,转换结果见表

- Argument Type + 参数类型 - Result + 结果
- Return *false*. + 返回 *false*。
- Return *false*. + 返回 *false*。
- Return _argument_. + 返回 _argument_。
- If _argument_ is *+0*, *-0*, or *NaN*, return *false*; otherwise return *true*. + 如果 _argument_ 为 *+0*,*-0*,or *NaN*,返回 *false*; 否则返回 *true*。
- If _argument_ is the empty String (its length is zero), return *false*; otherwise return *true*. + 如果 _argument_ 是一个空字符串 (长度为0的字符串), 返回 *false*; 否则返回 *true*。
- Return *true*. + 返回 *true*。
- Return *true*. + 返回 *true*。
@@ -146,7 +146,7 @@

ToNumber ( _argument_ )

Undefined @@ -154,7 +154,7 @@

ToNumber ( _argument_ )

Null @@ -162,7 +162,7 @@

ToNumber ( _argument_ )

Boolean @@ -170,7 +170,7 @@

ToNumber ( _argument_ )

Number @@ -178,7 +178,7 @@

ToNumber ( _argument_ )

String @@ -186,7 +186,7 @@

ToNumber ( _argument_ )

Symbol @@ -194,7 +194,7 @@

ToNumber ( _argument_ )

Object
- Argument Type + 参数类型 - Result + 结果
- Return *NaN*. + 返回 *NaN*。
- Return *+0*. + 返回 *+0*。
- If _argument_ is *true*, return 1. If _argument_ is *false*, return *+0*. + 如果 _argument_ 是 *true*,返回 1。如果 _argument_ 是 *false*,返回 *+0*。
- Return _argument_ (no conversion). + 返回 _argument_ (不转换)。
- See grammar and conversion algorithm below. + 见下面语法和转换算法。
- Throw a *TypeError* exception. + 抛出一个 *TypeError* 异常。
-

Apply the following steps:

+

应用以下步骤:

1. Let _primValue_ be ? ToPrimitive(_argument_, hint Number). 1. Return ? ToNumber(_primValue_). @@ -207,10 +207,10 @@

ToNumber ( _argument_ )

-

ToNumber Applied to the String Type

-

ToNumber applied to Strings applies the following grammar to the input String interpreted as a sequence of UTF-16 encoded code points (). If the grammar cannot interpret the String as an expansion of |StringNumericLiteral|, then the result of ToNumber is *NaN*.

+

应用于 String 类型的 ToNumber

+

应用 ToNumber 的字符串使用如下语法把字符串解释为一个 UTF-16 的编码码点 ()。如果语法不能解释字符串为一个 |StringNumericLiteral| 终结符的扩展,那么 ToNumber 的结果是 *NaN*。

-

The terminal symbols of this grammar are all composed of Unicode BMP code points so the result will be *NaN* if the string contains the UTF-16 encoding of any supplementary code points or any unpaired surrogate code points.

+

这个语法的终结符都由 Unicode BMP 码点组成,所以如果字符串包含任何补充码点或任何未配对替代码点的 UTF-16 编码,那么结果就会是 NaN。

Syntax

@@ -242,98 +242,98 @@

Syntax

`.` DecimalDigits ExponentPart? DecimalDigits ExponentPart?
-

All grammar symbols not explicitly defined above have the definitions used in the Lexical Grammar for numeric literals ()

+

以上所有未明确定义的语法符号都在数字字面量词法定义()

-

Some differences should be noted between the syntax of a |StringNumericLiteral| and a |NumericLiteral|:

+

应该注意 |StringNumericLiteral| 和 |NumericLiteral| 语法之间的一些区别:

  • - A |StringNumericLiteral| may include leading and/or trailing white space and/or line terminators. + |StringNumericLiteral| 可能包含前导和(或)结尾的空白和(或)行终止符。
  • - A |StringNumericLiteral| that is decimal may have any number of leading `0` digits. + 十进制的 |StringNumericLiteral| 可能包含多位前导 `0` 的数字。
  • - A |StringNumericLiteral| that is decimal may include a `+` or `-` to indicate its sign. + 十进制的 |StringNumericLiteral| 可能包含一个 `+` 或 `-` 以指示其符号。
  • - A |StringNumericLiteral| that is empty or contains only white space is converted to *+0*. + 空的或者只有空格的 |StringNumericLiteral| 会被转换为 *+0*。
  • - `Infinity` and `-Infinity` are recognized as a |StringNumericLiteral| but not as a |NumericLiteral|. + `Infinity` 和 `-Infinity` 公认是 |StringNumericLiteral| 而不是 |NumericLiteral|。
-

Runtime Semantics: MV

-

The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see ), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in .

+

运行时语义: MV

+

字符串到 Number 值的转换和一个的数字字面量 Number 值的确定总体上来说是相似的(见 ),但是也有一些细微的差别,因此在这里给出了转换一个 String 类型的数字字面量为一个 Number 类型的值的过程。这个数字由以下两个步骤确定:首先,从 String 类型的数字字面量导出数值(MV)由数学值(MV,以下简称数值);然后,这个数字像下面描述的那样舍入。很多语法符号的数值不在下面提供,在 定义。

  • - The MV of StringNumericLiteral ::: [empty] is 0. + StringNumericLiteral ::: [empty] 的数值 0.
  • - The MV of StringNumericLiteral ::: StrWhiteSpace is 0. + StringNumericLiteral ::: StrWhiteSpace 的数值是 0.
  • - The MV of StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace? is the MV of |StrNumericLiteral|, no matter whether white space is present or not. + StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?的数值是 |StrNumericLiteral| 的数值, 无论是否存在空格.
  • - The MV of StrNumericLiteral ::: StrDecimalLiteral is the MV of |StrDecimalLiteral|. + StrNumericLiteral ::: StrDecimalLiteral的数值是 |StrDecimalLiteral| 的数值.
  • - The MV of StrNumericLiteral ::: BinaryIntegerLiteral is the MV of |BinaryIntegerLiteral|. + StrNumericLiteral ::: BinaryIntegerLiteral的数值是 |BinaryIntegerLiteral| 的数值.
  • - The MV of StrNumericLiteral ::: OctalIntegerLiteral is the MV of |OctalIntegerLiteral|. + StrNumericLiteral ::: OctalIntegerLiteral的数值是 |OctalIntegerLiteral| 的数值.
  • - The MV of StrNumericLiteral ::: HexIntegerLiteral is the MV of |HexIntegerLiteral|. + StrNumericLiteral ::: HexIntegerLiteral的数值是 |HexIntegerLiteral| 的数值.
  • - The MV of StrDecimalLiteral ::: StrUnsignedDecimalLiteral is the MV of |StrUnsignedDecimalLiteral|. + StrDecimalLiteral ::: StrUnsignedDecimalLiteral的数值是 |StrUnsignedDecimalLiteral| 的数值.
  • - The MV of StrDecimalLiteral ::: `+` StrUnsignedDecimalLiteral is the MV of |StrUnsignedDecimalLiteral|. + StrDecimalLiteral ::: `+` StrUnsignedDecimalLiteral的数值是 |StrUnsignedDecimalLiteral| 的数值.
  • - The MV of StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0* or *-0* as appropriate.) + StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral的数值是 |StrUnsignedDecimalLiteral| 的数值的负数.(注意,如果 |StrUnsignedDecimalLiteral| 的数值是 0,那么这个数值的负数也是 0。下面的舍入规则描述了合理的处理转换无符号数字 0 为一个浮点数 *+0* 或 *-0*。)
  • - The MV of StrUnsignedDecimalLiteral ::: `Infinity` is 1010000 (a value so large that it will round to *+∞*). + StrUnsignedDecimalLiteral ::: `Infinity`的数值是 1010000 (一个这么大的数字将舍入为 `+∞`).
  • - The MV of StrUnsignedDecimalLiteral ::: DecimalDigits `.` is the MV of |DecimalDigits|. + StrUnsignedDecimalLiteral ::: DecimalDigits `.`的数值是 |DecimalDigits| 的数值.
  • - The MV of StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10-_n_), where _n_ is the number of code points in the second |DecimalDigits|. + StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits的数值是第一个 |DecimalDigits| 的数值加上(第二个 |DecimalDigits| 的数值乘上 10-_n_), 这里的 _n_ 是第二个 |DecimalDigits| 的码点数.
  • - The MV of StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart is the MV of |DecimalDigits| times 10_e_, where _e_ is the MV of |ExponentPart|. + StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart的数值是 |DecimalDigits| 的数值乘上 10_e_, 这里的 _e_ 是 |ExponentPart| 的数值.
  • - The MV of StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10-_n_)) times 10_e_, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|. + StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart的数值是(第一个 |DecimalDigits| 的数值加上(第二个 |DecimalDigits| 的数值乘以 10-_n_))乘以 10_e_, 这里 _n_ 第二个 |DecimalDigits| 码点数,_e_ 是 |ExponentPart| 的数值.
  • - The MV of StrUnsignedDecimalLiteral ::: `.` DecimalDigits is the MV of |DecimalDigits| times 10-_n_, where _n_ is the number of code points in |DecimalDigits|. + StrUnsignedDecimalLiteral ::: `.` DecimalDigits的数值是 |DecimalDigits| 的数值乘上 10-_n_, 这里的 _n_ 是 |DecimalDigits| 码点数.
  • - The MV of StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart is the MV of |DecimalDigits| times 10_e_-_n_, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|. + StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart的数值是 |DecimalDigits| 的数值乘以 10_e_-_n_, 这里 _n_ 是 |DecimalDigits| 的码点数,_e_ 是 |ExponentPart| 的数值.
  • - The MV of StrUnsignedDecimalLiteral ::: DecimalDigits is the MV of |DecimalDigits|. + StrUnsignedDecimalLiteral ::: DecimalDigits的数值是 |DecimalDigits| 的数值.
  • - The MV of StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart is the MV of |DecimalDigits| times 10_e_, where _e_ is the MV of |ExponentPart|. + StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart的数值是 |DecimalDigits| 的数值乘上 10_e_, _e_ 是 |ExponentPart| 的数值.
-

Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0* unless the first non white space code point in the String numeric literal is `"-"`, in which case the rounded value is *-0*. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in ), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and

+

一旦确定了字符串数字字面量确切的数值,它将被舍入为一个 Number 类型的值。如果数值为 0,那么它舍入的值为 *+0*,除非字符串数字字面量的第一个非空格码点是 `"-"`,这种情况舍入值为 *-0*。否则,舍入的值必须为一个数字类型的数值(定义在 )除非这个字面量包含一个 |StrUnsignedDecimalLiteral| 并且拥有超过 20 位的有效数值,这种情况下,这个数值可以是由 0 替换字面量第 20 位后面的每个有效数字的字面量数值,也可以是在替换后从第 20 位数位递增的字面量数值。如果数字不是一个 |ExponentPart| 的部分,并且

  • - it is not `0`; or + 这个数字不是 `0`; 或者
  • - there is a nonzero digit to its left and there is a nonzero digit, not in the |ExponentPart|, to its right. + 数字的左侧是一个非零的数字且他的右边是一个不在 |ExponentPart| 的非零数字。那么这个数字是有效的。
@@ -343,7 +343,7 @@

Runtime Semantics: MV

ToInteger ( _argument_ )

-

The abstract operation ToInteger converts _argument_ to an integral numeric value. This abstract operation functions as follows:

+

抽象操作 ToInteger 把 _argument_ 转换为整数数值。这个抽象操作算法如下:

1. Let _number_ be ? ToNumber(_argument_). 1. If _number_ is *NaN*, return *+0*. @@ -355,7 +355,7 @@

ToInteger ( _argument_ )

ToInt32 ( _argument_ )

-

The abstract operation ToInt32 converts _argument_ to one of 232 integer values in the range -231 through 231-1, inclusive. This abstract operation functions as follows:

+

抽象操作 ToInt32 把 _argument_ 转换为范围为 -231231-1的 232 个整数之一,这个抽象操作算法如下:

1. Let _number_ be ? ToNumber(_argument_). 1. If _number_ is *NaN*, *+0*, *-0*, *+∞*, or *-∞*, return *+0*. @@ -364,16 +364,16 @@

ToInt32 ( _argument_ )

1. If _int32bit_ ≥ 231, return _int32bit_ - 232; otherwise return _int32bit_.
-

Given the above definition of ToInt32:

+

鉴于以上 ToInt32 的定义:

  • - The ToInt32 abstract operation is idempotent: if applied to a result that it produced, the second application leaves that value unchanged. + ToInt32 是等幂的: 其作用在同一个元素上产生的结果相同。
  • - ToInt32(ToUint32(_x_)) is equal to ToInt32(_x_) for all values of _x_. (It is to preserve this latter property that *+∞* and *-∞* are mapped to *+0*.) + 对于任意 _x_,ToInt32(ToUint32(_x_)) 等于 ToInt32(_x_)。 (这是为了保证 *+∞* 和 *-∞* 会被映射为 *+0*。)
  • - ToInt32 maps *-0* to *+0*. + ToInt32把 *-0* 映射为 *+0*.