2008-09-09 20:08:45 +00:00
|
|
|
// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
// This files contains runtime support implemented in JavaScript.
|
|
|
|
|
|
|
|
// CAUTION: Some of the functions specified in this file are called
|
|
|
|
// directly from compiled code. These are the functions with names in
|
|
|
|
// ALL CAPS. The compiled code passes the first argument in 'this' and
|
|
|
|
// it does not push the function onto the stack. This means that you
|
|
|
|
// cannot use contexts in all these functions.
|
|
|
|
|
|
|
|
|
|
|
|
/* -----------------------------------
|
|
|
|
- - - C o m p a r i s o n - - -
|
|
|
|
-----------------------------------
|
|
|
|
*/
|
|
|
|
|
2012-02-20 13:48:24 +00:00
|
|
|
// The following declarations are shared with other native JS files.
|
|
|
|
// They are all declared at this one spot to avoid redeclaration errors.
|
|
|
|
var $Object = global.Object;
|
|
|
|
var $Array = global.Array;
|
|
|
|
var $String = global.String;
|
|
|
|
var $Number = global.Number;
|
|
|
|
var $Function = global.Function;
|
|
|
|
var $Boolean = global.Boolean;
|
2012-04-20 14:12:49 +00:00
|
|
|
var $NaN = %GetRootNaN();
|
2012-02-20 13:48:24 +00:00
|
|
|
var builtins = this;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-05-03 12:15:14 +00:00
|
|
|
// ECMA-262 Section 11.9.3.
|
2008-07-03 15:10:15 +00:00
|
|
|
function EQUALS(y) {
|
2008-10-07 10:54:50 +00:00
|
|
|
if (IS_STRING(this) && IS_STRING(y)) return %StringEquals(this, y);
|
2008-07-03 15:10:15 +00:00
|
|
|
var x = this;
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
if (IS_NUMBER(x)) {
|
2011-05-03 12:15:14 +00:00
|
|
|
while (true) {
|
|
|
|
if (IS_NUMBER(y)) return %NumberEquals(x, y);
|
|
|
|
if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
|
|
|
|
if (!IS_SPEC_OBJECT(y)) {
|
|
|
|
// String or boolean.
|
|
|
|
return %NumberEquals(x, %ToNumber(y));
|
|
|
|
}
|
|
|
|
y = %ToPrimitive(y, NO_HINT);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
} else if (IS_STRING(x)) {
|
2011-05-03 12:15:14 +00:00
|
|
|
while (true) {
|
|
|
|
if (IS_STRING(y)) return %StringEquals(x, y);
|
2013-04-03 17:06:22 +00:00
|
|
|
if (IS_SYMBOL(y)) return 1; // not equal
|
2011-05-03 12:15:14 +00:00
|
|
|
if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y);
|
|
|
|
if (IS_BOOLEAN(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y));
|
|
|
|
if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
|
|
|
|
y = %ToPrimitive(y, NO_HINT);
|
|
|
|
}
|
2013-04-03 17:06:22 +00:00
|
|
|
} else if (IS_SYMBOL(x)) {
|
|
|
|
while (true) {
|
|
|
|
if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1;
|
|
|
|
if (!IS_SPEC_OBJECT(y)) return 1; // not equal
|
|
|
|
y = %ToPrimitive(y, NO_HINT);
|
|
|
|
}
|
2011-05-03 12:15:14 +00:00
|
|
|
} else if (IS_BOOLEAN(x)) {
|
|
|
|
if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1;
|
|
|
|
if (IS_NULL_OR_UNDEFINED(y)) return 1;
|
2008-07-03 15:10:15 +00:00
|
|
|
if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y);
|
2011-05-03 12:15:14 +00:00
|
|
|
if (IS_STRING(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y));
|
2013-04-03 17:06:22 +00:00
|
|
|
if (IS_SYMBOL(y)) return 1; // not equal
|
2011-05-03 12:15:14 +00:00
|
|
|
// y is object.
|
|
|
|
x = %ToNumber(x);
|
2008-07-03 15:10:15 +00:00
|
|
|
y = %ToPrimitive(y, NO_HINT);
|
2011-05-03 12:15:14 +00:00
|
|
|
} else if (IS_NULL_OR_UNDEFINED(x)) {
|
|
|
|
return IS_NULL_OR_UNDEFINED(y) ? 0 : 1;
|
2008-07-03 15:10:15 +00:00
|
|
|
} else {
|
2011-05-03 12:15:14 +00:00
|
|
|
// x is an object.
|
2010-07-16 11:21:08 +00:00
|
|
|
if (IS_SPEC_OBJECT(y)) {
|
2008-09-08 06:17:38 +00:00
|
|
|
return %_ObjectEquals(x, y) ? 0 : 1;
|
|
|
|
}
|
2011-05-03 12:15:14 +00:00
|
|
|
if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
|
|
|
|
if (IS_BOOLEAN(y)) y = %ToNumber(y);
|
2008-07-03 15:10:15 +00:00
|
|
|
x = %ToPrimitive(x, NO_HINT);
|
|
|
|
}
|
|
|
|
}
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// ECMA-262, section 11.9.4, page 56.
|
|
|
|
function STRICT_EQUALS(x) {
|
|
|
|
if (IS_STRING(this)) {
|
|
|
|
if (!IS_STRING(x)) return 1; // not equal
|
|
|
|
return %StringEquals(this, x);
|
2009-06-15 09:49:17 +00:00
|
|
|
}
|
2008-09-08 06:17:38 +00:00
|
|
|
|
2008-10-10 06:26:35 +00:00
|
|
|
if (IS_NUMBER(this)) {
|
|
|
|
if (!IS_NUMBER(x)) return 1; // not equal
|
|
|
|
return %NumberEquals(this, x);
|
2009-06-15 09:49:17 +00:00
|
|
|
}
|
2008-09-08 06:17:38 +00:00
|
|
|
|
2009-04-03 12:44:45 +00:00
|
|
|
// If anything else gets here, we just do simple identity check.
|
|
|
|
// Objects (including functions), null, undefined and booleans were
|
|
|
|
// checked in the CompareStub, so there should be nothing left.
|
2008-09-08 06:17:38 +00:00
|
|
|
return %_ObjectEquals(this, x) ? 0 : 1;
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as
|
|
|
|
// the result when either (or both) the operands are NaN.
|
|
|
|
function COMPARE(x, ncr) {
|
2010-01-07 09:40:50 +00:00
|
|
|
var left;
|
2010-06-29 06:47:19 +00:00
|
|
|
var right;
|
2010-01-07 09:40:50 +00:00
|
|
|
// Fast cases for string, numbers and undefined compares.
|
|
|
|
if (IS_STRING(this)) {
|
2010-01-08 11:58:15 +00:00
|
|
|
if (IS_STRING(x)) return %_StringCompare(this, x);
|
2010-01-07 09:40:50 +00:00
|
|
|
if (IS_UNDEFINED(x)) return ncr;
|
|
|
|
left = this;
|
|
|
|
} else if (IS_NUMBER(this)) {
|
|
|
|
if (IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
|
|
|
|
if (IS_UNDEFINED(x)) return ncr;
|
|
|
|
left = this;
|
|
|
|
} else if (IS_UNDEFINED(this)) {
|
2010-06-29 06:47:19 +00:00
|
|
|
if (!IS_UNDEFINED(x)) {
|
|
|
|
%ToPrimitive(x, NUMBER_HINT);
|
|
|
|
}
|
|
|
|
return ncr;
|
|
|
|
} else if (IS_UNDEFINED(x)) {
|
|
|
|
%ToPrimitive(this, NUMBER_HINT);
|
2009-12-14 12:18:20 +00:00
|
|
|
return ncr;
|
2010-01-07 09:40:50 +00:00
|
|
|
} else {
|
|
|
|
left = %ToPrimitive(this, NUMBER_HINT);
|
2009-12-14 12:18:20 +00:00
|
|
|
}
|
|
|
|
|
2010-06-29 06:47:19 +00:00
|
|
|
right = %ToPrimitive(x, NUMBER_HINT);
|
2010-01-07 09:40:50 +00:00
|
|
|
if (IS_STRING(left) && IS_STRING(right)) {
|
2010-01-08 11:58:15 +00:00
|
|
|
return %_StringCompare(left, right);
|
2008-07-03 15:10:15 +00:00
|
|
|
} else {
|
2010-01-07 09:40:50 +00:00
|
|
|
var left_number = %ToNumber(left);
|
|
|
|
var right_number = %ToNumber(right);
|
|
|
|
if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr;
|
|
|
|
return %NumberCompare(left_number, right_number, ncr);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* -----------------------------------
|
|
|
|
- - - A r i t h m e t i c - - -
|
|
|
|
-----------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
// ECMA-262, section 11.6.1, page 50.
|
|
|
|
function ADD(x) {
|
|
|
|
// Fast case: Check for number operands and do the addition.
|
2008-10-07 10:54:50 +00:00
|
|
|
if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x);
|
2009-12-03 07:56:21 +00:00
|
|
|
if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x);
|
2008-10-03 07:14:31 +00:00
|
|
|
|
2008-10-07 10:54:50 +00:00
|
|
|
// Default implementation.
|
2008-07-03 15:10:15 +00:00
|
|
|
var a = %ToPrimitive(this, NO_HINT);
|
|
|
|
var b = %ToPrimitive(x, NO_HINT);
|
2009-06-15 09:49:17 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
if (IS_STRING(a)) {
|
2009-12-03 07:56:21 +00:00
|
|
|
return %_StringAdd(a, %ToString(b));
|
2008-07-03 15:10:15 +00:00
|
|
|
} else if (IS_STRING(b)) {
|
2011-01-05 13:52:00 +00:00
|
|
|
return %_StringAdd(%NonStringToString(a), b);
|
2008-07-03 15:10:15 +00:00
|
|
|
} else {
|
|
|
|
return %NumberAdd(%ToNumber(a), %ToNumber(b));
|
|
|
|
}
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2009-04-03 12:01:56 +00:00
|
|
|
// Left operand (this) is already a string.
|
2009-06-15 09:49:17 +00:00
|
|
|
function STRING_ADD_LEFT(y) {
|
2009-07-03 10:09:59 +00:00
|
|
|
if (!IS_STRING(y)) {
|
2010-08-12 13:43:08 +00:00
|
|
|
if (IS_STRING_WRAPPER(y) && %_IsStringWrapperSafeForDefaultValueOf(y)) {
|
2009-07-03 10:09:59 +00:00
|
|
|
y = %_ValueOf(y);
|
|
|
|
} else {
|
|
|
|
y = IS_NUMBER(y)
|
2010-02-16 09:41:11 +00:00
|
|
|
? %_NumberToString(y)
|
2009-07-03 10:09:59 +00:00
|
|
|
: %ToString(%ToPrimitive(y, NO_HINT));
|
|
|
|
}
|
|
|
|
}
|
2009-12-03 07:56:21 +00:00
|
|
|
return %_StringAdd(this, y);
|
2009-04-03 12:01:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-15 09:49:17 +00:00
|
|
|
// Right operand (y) is already a string.
|
|
|
|
function STRING_ADD_RIGHT(y) {
|
2009-07-03 10:09:59 +00:00
|
|
|
var x = this;
|
|
|
|
if (!IS_STRING(x)) {
|
2010-08-12 13:43:08 +00:00
|
|
|
if (IS_STRING_WRAPPER(x) && %_IsStringWrapperSafeForDefaultValueOf(x)) {
|
2009-07-03 10:09:59 +00:00
|
|
|
x = %_ValueOf(x);
|
|
|
|
} else {
|
|
|
|
x = IS_NUMBER(x)
|
2010-02-16 09:41:11 +00:00
|
|
|
? %_NumberToString(x)
|
2009-07-03 10:09:59 +00:00
|
|
|
: %ToString(%ToPrimitive(x, NO_HINT));
|
|
|
|
}
|
|
|
|
}
|
2009-12-03 07:56:21 +00:00
|
|
|
return %_StringAdd(x, y);
|
2009-04-03 12:01:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// ECMA-262, section 11.6.2, page 50.
|
2009-06-15 09:49:17 +00:00
|
|
|
function SUB(y) {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberSub(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.5.1, page 48.
|
2009-06-15 09:49:17 +00:00
|
|
|
function MUL(y) {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberMul(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.5.2, page 49.
|
2009-06-15 09:49:17 +00:00
|
|
|
function DIV(y) {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberDiv(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.5.3, page 49.
|
2009-06-15 09:49:17 +00:00
|
|
|
function MOD(y) {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberMod(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------
|
|
|
|
- - - B i t o p e r a t i o n s - - -
|
|
|
|
-------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
// ECMA-262, section 11.10, page 57.
|
2009-06-15 09:49:17 +00:00
|
|
|
function BIT_OR(y) {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberOr(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.10, page 57.
|
2009-06-15 09:49:17 +00:00
|
|
|
function BIT_AND(y) {
|
|
|
|
var x;
|
|
|
|
if (IS_NUMBER(this)) {
|
|
|
|
x = this;
|
2011-01-05 13:52:00 +00:00
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
} else {
|
2011-01-05 13:52:00 +00:00
|
|
|
x = %NonNumberToNumber(this);
|
2009-06-16 08:29:31 +00:00
|
|
|
// Make sure to convert the right operand to a number before
|
|
|
|
// bailing out in the fast case, but after converting the
|
|
|
|
// left operand. This ensures that valueOf methods on the right
|
|
|
|
// operand are always executed.
|
2011-01-05 13:52:00 +00:00
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
// Optimize for the case where we end up AND'ing a value
|
|
|
|
// that doesn't convert to a number. This is common in
|
|
|
|
// certain benchmarks.
|
|
|
|
if (NUMBER_IS_NAN(x)) return 0;
|
|
|
|
}
|
|
|
|
return %NumberAnd(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.10, page 57.
|
2009-06-15 09:49:17 +00:00
|
|
|
function BIT_XOR(y) {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberXor(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.4.7, page 47.
|
|
|
|
function UNARY_MINUS() {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberUnaryMinus(x);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.4.8, page 48.
|
|
|
|
function BIT_NOT() {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberNot(x);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.7.1, page 51.
|
2009-06-15 09:49:17 +00:00
|
|
|
function SHL(y) {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberShl(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.7.2, page 51.
|
2009-06-15 09:49:17 +00:00
|
|
|
function SAR(y) {
|
|
|
|
var x;
|
|
|
|
if (IS_NUMBER(this)) {
|
|
|
|
x = this;
|
2011-01-05 13:52:00 +00:00
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
} else {
|
2011-01-05 13:52:00 +00:00
|
|
|
x = %NonNumberToNumber(this);
|
2009-06-16 08:29:31 +00:00
|
|
|
// Make sure to convert the right operand to a number before
|
|
|
|
// bailing out in the fast case, but after converting the
|
|
|
|
// left operand. This ensures that valueOf methods on the right
|
|
|
|
// operand are always executed.
|
2011-01-05 13:52:00 +00:00
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
// Optimize for the case where we end up shifting a value
|
|
|
|
// that doesn't convert to a number. This is common in
|
|
|
|
// certain benchmarks.
|
|
|
|
if (NUMBER_IS_NAN(x)) return 0;
|
|
|
|
}
|
|
|
|
return %NumberSar(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.7.3, page 52.
|
2009-06-15 09:49:17 +00:00
|
|
|
function SHR(y) {
|
2011-01-05 13:52:00 +00:00
|
|
|
var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this);
|
|
|
|
if (!IS_NUMBER(y)) y = %NonNumberToNumber(y);
|
2009-06-15 09:49:17 +00:00
|
|
|
return %NumberShr(x, y);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* -----------------------------
|
|
|
|
- - - H e l p e r s - - -
|
|
|
|
-----------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
// ECMA-262, section 11.4.1, page 46.
|
2011-02-14 23:41:47 +00:00
|
|
|
function DELETE(key, strict) {
|
2013-03-04 15:00:57 +00:00
|
|
|
return %DeleteProperty(%ToObject(this), %ToName(key), strict);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 11.8.7, page 54.
|
|
|
|
function IN(x) {
|
2010-07-16 11:21:08 +00:00
|
|
|
if (!IS_SPEC_OBJECT(x)) {
|
2008-07-03 15:10:15 +00:00
|
|
|
throw %MakeTypeError('invalid_in_operator_use', [this, x]);
|
|
|
|
}
|
2011-09-22 10:45:37 +00:00
|
|
|
return %_IsNonNegativeSmi(this) ?
|
2013-03-04 15:00:57 +00:00
|
|
|
%HasElement(x, this) : %HasProperty(x, %ToName(this));
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2008-10-08 13:33:16 +00:00
|
|
|
// ECMA-262, section 11.8.6, page 54. To make the implementation more
|
2009-04-03 12:01:56 +00:00
|
|
|
// efficient, the return value should be zero if the 'this' is an
|
2008-10-08 13:33:16 +00:00
|
|
|
// instance of F, and non-zero if not. This makes it possible to avoid
|
|
|
|
// an expensive ToBoolean conversion in the generated code.
|
2008-07-03 15:10:15 +00:00
|
|
|
function INSTANCE_OF(F) {
|
|
|
|
var V = this;
|
2011-09-13 11:42:57 +00:00
|
|
|
if (!IS_SPEC_FUNCTION(F)) {
|
2011-08-11 16:11:07 +00:00
|
|
|
throw %MakeTypeError('instanceof_function_expected', [V]);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If V is not an object, return false.
|
2010-07-16 11:21:08 +00:00
|
|
|
if (!IS_SPEC_OBJECT(V)) {
|
2008-10-08 13:33:16 +00:00
|
|
|
return 1;
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 12:44:16 +00:00
|
|
|
// Check if function is bound, if so, get [[BoundFunction]] from it
|
|
|
|
// and use that instead of F.
|
|
|
|
var bindings = %BoundFunctionGetBindings(F);
|
|
|
|
if (bindings) {
|
|
|
|
F = bindings[kBoundFunctionIndex]; // Always a non-bound function.
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
// Get the prototype of F; if it is not an object, throw an error.
|
|
|
|
var O = F.prototype;
|
2010-07-16 11:21:08 +00:00
|
|
|
if (!IS_SPEC_OBJECT(O)) {
|
2008-07-03 15:10:15 +00:00
|
|
|
throw %MakeTypeError('instanceof_nonobject_proto', [O]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return whether or not O is in the prototype chain of V.
|
2008-10-08 13:33:16 +00:00
|
|
|
return %IsInPrototypeChain(O, V) ? 0 : 1;
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Filter a given key against an object by checking if the object
|
|
|
|
// has a property with the given key; return the key as a string if
|
2010-08-11 13:46:10 +00:00
|
|
|
// it has. Otherwise returns 0 (smi). Used in for-in statements.
|
2008-07-03 15:10:15 +00:00
|
|
|
function FILTER_KEY(key) {
|
2013-03-04 15:00:57 +00:00
|
|
|
var string = %ToName(key);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (%HasProperty(this, string)) return string;
|
2010-08-11 13:46:10 +00:00
|
|
|
return 0;
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
function CALL_NON_FUNCTION() {
|
2010-02-17 08:26:50 +00:00
|
|
|
var delegate = %GetFunctionDelegate(this);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (!IS_FUNCTION(delegate)) {
|
2010-02-17 08:26:50 +00:00
|
|
|
throw %MakeTypeError('called_non_callable', [typeof this]);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2011-09-14 12:33:57 +00:00
|
|
|
return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
|
2009-05-20 19:33:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function CALL_NON_FUNCTION_AS_CONSTRUCTOR() {
|
2010-02-17 08:26:50 +00:00
|
|
|
var delegate = %GetConstructorDelegate(this);
|
2009-05-20 19:33:44 +00:00
|
|
|
if (!IS_FUNCTION(delegate)) {
|
2010-02-17 08:26:50 +00:00
|
|
|
throw %MakeTypeError('called_non_callable', [typeof this]);
|
2009-05-20 19:33:44 +00:00
|
|
|
}
|
2011-09-14 12:33:57 +00:00
|
|
|
return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2011-09-13 11:42:57 +00:00
|
|
|
function CALL_FUNCTION_PROXY() {
|
|
|
|
var arity = %_ArgumentsLength() - 1;
|
|
|
|
var proxy = %_Arguments(arity); // The proxy comes in as an additional arg.
|
|
|
|
var trap = %GetCallTrap(proxy);
|
|
|
|
return %Apply(trap, this, arguments, 0, arity);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-16 12:26:29 +00:00
|
|
|
function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR() {
|
|
|
|
var proxy = this;
|
2011-09-13 11:42:57 +00:00
|
|
|
var trap = %GetConstructTrap(proxy);
|
2011-09-16 12:26:29 +00:00
|
|
|
return %Apply(trap, this, arguments, 0, %_ArgumentsLength());
|
2011-09-13 11:42:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
function APPLY_PREPARE(args) {
|
|
|
|
var length;
|
2009-06-24 08:01:38 +00:00
|
|
|
// First check whether length is a positive Smi and args is an
|
|
|
|
// array. This is the fast case. If this fails, we do the slow case
|
|
|
|
// that takes care of more eventualities.
|
2009-06-29 10:45:16 +00:00
|
|
|
if (IS_ARRAY(args)) {
|
2008-07-03 15:10:15 +00:00
|
|
|
length = args.length;
|
2011-09-13 11:42:57 +00:00
|
|
|
if (%_IsSmi(length) && length >= 0 && length < 0x800000 &&
|
|
|
|
IS_SPEC_FUNCTION(this)) {
|
2008-07-03 15:10:15 +00:00
|
|
|
return length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-13 13:26:31 +00:00
|
|
|
length = (args == null) ? 0 : %ToUint32(args.length);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// We can handle any number of apply arguments if the stack is
|
|
|
|
// big enough, but sanity check the value to avoid overflow when
|
|
|
|
// multiplying with pointer size.
|
|
|
|
if (length > 0x800000) {
|
2010-07-12 15:29:25 +00:00
|
|
|
throw %MakeRangeError('stack_overflow', []);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2011-09-13 11:42:57 +00:00
|
|
|
if (!IS_SPEC_FUNCTION(this)) {
|
2011-11-28 12:11:00 +00:00
|
|
|
throw %MakeTypeError('apply_non_function',
|
|
|
|
[ %ToString(this), typeof this ]);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the arguments list has the right type.
|
2011-10-19 13:56:18 +00:00
|
|
|
if (args != null && !IS_SPEC_OBJECT(args)) {
|
2008-07-03 15:10:15 +00:00
|
|
|
throw %MakeTypeError('apply_wrong_args', []);
|
|
|
|
}
|
2008-08-22 13:33:59 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Return the length which is the number of arguments to copy to the
|
|
|
|
// stack. It is guaranteed to be a small integer at this point.
|
|
|
|
return length;
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
function APPLY_OVERFLOW(length) {
|
2010-07-12 15:29:25 +00:00
|
|
|
throw %MakeRangeError('stack_overflow', []);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Convert the receiver to an object - forward to ToObject.
|
|
|
|
function TO_OBJECT() {
|
|
|
|
return %ToObject(this);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Convert the receiver to a number - forward to ToNumber.
|
|
|
|
function TO_NUMBER() {
|
|
|
|
return %ToNumber(this);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Convert the receiver to a string - forward to ToString.
|
|
|
|
function TO_STRING() {
|
|
|
|
return %ToString(this);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------
|
|
|
|
- - - C o n v e r s i o n s - - -
|
|
|
|
-------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
// ECMA-262, section 9.1, page 30. Use null/undefined for no hint,
|
|
|
|
// (1) for number hint, and (2) for string hint.
|
|
|
|
function ToPrimitive(x, hint) {
|
2008-10-07 10:54:50 +00:00
|
|
|
// Fast case check.
|
|
|
|
if (IS_STRING(x)) return x;
|
2008-10-07 12:06:48 +00:00
|
|
|
// Normal behavior.
|
2010-07-16 11:21:08 +00:00
|
|
|
if (!IS_SPEC_OBJECT(x)) return x;
|
2013-04-03 17:06:22 +00:00
|
|
|
if (IS_SYMBOL_WRAPPER(x)) return %_ValueOf(x);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT;
|
|
|
|
return (hint == NUMBER_HINT) ? %DefaultNumber(x) : %DefaultString(x);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2010-02-03 13:10:03 +00:00
|
|
|
// ECMA-262, section 9.2, page 30
|
|
|
|
function ToBoolean(x) {
|
|
|
|
if (IS_BOOLEAN(x)) return x;
|
|
|
|
if (IS_STRING(x)) return x.length != 0;
|
|
|
|
if (x == null) return false;
|
|
|
|
if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// ECMA-262, section 9.3, page 31.
|
|
|
|
function ToNumber(x) {
|
|
|
|
if (IS_NUMBER(x)) return x;
|
2010-08-27 11:47:12 +00:00
|
|
|
if (IS_STRING(x)) {
|
|
|
|
return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x)
|
|
|
|
: %StringToNumber(x);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
if (IS_BOOLEAN(x)) return x ? 1 : 0;
|
2008-08-27 13:47:52 +00:00
|
|
|
if (IS_UNDEFINED(x)) return $NaN;
|
2013-03-22 16:33:50 +00:00
|
|
|
if (IS_SYMBOL(x)) return $NaN;
|
2008-07-03 15:10:15 +00:00
|
|
|
return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-01-05 13:52:00 +00:00
|
|
|
function NonNumberToNumber(x) {
|
|
|
|
if (IS_STRING(x)) {
|
|
|
|
return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x)
|
|
|
|
: %StringToNumber(x);
|
|
|
|
}
|
|
|
|
if (IS_BOOLEAN(x)) return x ? 1 : 0;
|
|
|
|
if (IS_UNDEFINED(x)) return $NaN;
|
2013-03-22 16:33:50 +00:00
|
|
|
if (IS_SYMBOL(x)) return $NaN;
|
2011-01-05 13:52:00 +00:00
|
|
|
return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// ECMA-262, section 9.8, page 35.
|
|
|
|
function ToString(x) {
|
|
|
|
if (IS_STRING(x)) return x;
|
2010-02-16 09:41:11 +00:00
|
|
|
if (IS_NUMBER(x)) return %_NumberToString(x);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
|
|
|
|
if (IS_UNDEFINED(x)) return 'undefined';
|
|
|
|
return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-02-19 13:07:37 +00:00
|
|
|
function NonStringToString(x) {
|
2010-04-07 11:13:05 +00:00
|
|
|
if (IS_NUMBER(x)) return %_NumberToString(x);
|
2010-02-19 13:07:37 +00:00
|
|
|
if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
|
|
|
|
if (IS_UNDEFINED(x)) return 'undefined';
|
|
|
|
return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-03-04 15:00:57 +00:00
|
|
|
// ES6 symbols
|
|
|
|
function ToName(x) {
|
|
|
|
return IS_SYMBOL(x) ? x : %ToString(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// ECMA-262, section 9.9, page 36.
|
|
|
|
function ToObject(x) {
|
|
|
|
if (IS_STRING(x)) return new $String(x);
|
2013-03-22 16:33:50 +00:00
|
|
|
if (IS_SYMBOL(x)) return new $Symbol(x);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (IS_NUMBER(x)) return new $Number(x);
|
|
|
|
if (IS_BOOLEAN(x)) return new $Boolean(x);
|
2010-01-19 14:15:47 +00:00
|
|
|
if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) {
|
|
|
|
throw %MakeTypeError('null_to_object', []);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
return x;
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 9.4, page 34.
|
|
|
|
function ToInteger(x) {
|
|
|
|
if (%_IsSmi(x)) return x;
|
|
|
|
return %NumberToInteger(ToNumber(x));
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 9.6, page 34.
|
|
|
|
function ToUint32(x) {
|
2008-08-06 10:02:49 +00:00
|
|
|
if (%_IsSmi(x) && x >= 0) return x;
|
2008-07-03 15:10:15 +00:00
|
|
|
return %NumberToJSUint32(ToNumber(x));
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 9.5, page 34
|
|
|
|
function ToInt32(x) {
|
|
|
|
if (%_IsSmi(x)) return x;
|
|
|
|
return %NumberToJSInt32(ToNumber(x));
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
2010-02-03 13:10:03 +00:00
|
|
|
// ES5, section 9.12
|
|
|
|
function SameValue(x, y) {
|
|
|
|
if (typeof x != typeof y) return false;
|
|
|
|
if (IS_NUMBER(x)) {
|
|
|
|
if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
|
2010-05-25 06:25:27 +00:00
|
|
|
// x is +0 and y is -0 or vice versa.
|
2011-01-05 13:52:00 +00:00
|
|
|
if (x === 0 && y === 0 && (1 / x) != (1 / y)) return false;
|
2010-02-03 13:10:03 +00:00
|
|
|
}
|
2011-01-05 13:52:00 +00:00
|
|
|
return x === y;
|
2010-02-03 13:10:03 +00:00
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
/* ---------------------------------
|
|
|
|
- - - U t i l i t i e s - - -
|
|
|
|
---------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Returns if the given x is a primitive value - not an object or a
|
|
|
|
// function.
|
|
|
|
function IsPrimitive(x) {
|
2010-07-16 11:21:08 +00:00
|
|
|
// Even though the type of null is "object", null is still
|
|
|
|
// considered a primitive value. IS_SPEC_OBJECT handles this correctly
|
|
|
|
// (i.e., it will return false if x is null).
|
|
|
|
return !IS_SPEC_OBJECT(x);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 8.6.2.6, page 28.
|
|
|
|
function DefaultNumber(x) {
|
2010-12-16 12:49:55 +00:00
|
|
|
var valueOf = x.valueOf;
|
2011-09-13 11:42:57 +00:00
|
|
|
if (IS_SPEC_FUNCTION(valueOf)) {
|
2010-12-16 12:49:55 +00:00
|
|
|
var v = %_CallFunction(x, valueOf);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (%IsPrimitive(v)) return v;
|
|
|
|
}
|
|
|
|
|
2010-12-16 12:49:55 +00:00
|
|
|
var toString = x.toString;
|
2011-09-13 11:42:57 +00:00
|
|
|
if (IS_SPEC_FUNCTION(toString)) {
|
2010-12-16 12:49:55 +00:00
|
|
|
var s = %_CallFunction(x, toString);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (%IsPrimitive(s)) return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw %MakeTypeError('cannot_convert_to_primitive', []);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ECMA-262, section 8.6.2.6, page 28.
|
|
|
|
function DefaultString(x) {
|
2010-12-16 12:49:55 +00:00
|
|
|
var toString = x.toString;
|
2011-09-13 11:42:57 +00:00
|
|
|
if (IS_SPEC_FUNCTION(toString)) {
|
2010-12-16 12:49:55 +00:00
|
|
|
var s = %_CallFunction(x, toString);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (%IsPrimitive(s)) return s;
|
|
|
|
}
|
|
|
|
|
2010-12-16 12:49:55 +00:00
|
|
|
var valueOf = x.valueOf;
|
2011-09-13 11:42:57 +00:00
|
|
|
if (IS_SPEC_FUNCTION(valueOf)) {
|
2010-12-16 12:49:55 +00:00
|
|
|
var v = %_CallFunction(x, valueOf);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (%IsPrimitive(v)) return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw %MakeTypeError('cannot_convert_to_primitive', []);
|
2008-10-03 07:14:31 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// NOTE: Setting the prototype for Array must take place as early as
|
|
|
|
// possible due to code generation for array literals. When
|
|
|
|
// generating code for a array literal a boilerplate array is created
|
2011-05-13 10:58:25 +00:00
|
|
|
// that is cloned when running the code. It is essential that the
|
2008-07-03 15:10:15 +00:00
|
|
|
// boilerplate gets the right prototype.
|
|
|
|
%FunctionSetPrototype($Array, new $Array(0));
|