Index: src/runtime.js |
diff --git a/src/runtime.js b/src/runtime.js |
index 004f9bf61bcdd1a088f12696b7216c0ead17f1c6..b425a2c1862f317ac7f8f6ffe3c07cbf7ce18752 100644 |
--- a/src/runtime.js |
+++ b/src/runtime.js |
@@ -16,86 +16,16 @@ |
// The following declarations are shared with other native JS files. |
// They are all declared at this one spot to avoid redeclaration errors. |
-var EQUALS; |
-var STRICT_EQUALS; |
-var COMPARE; |
-var ADD; |
-var ADD_STRONG; |
-var STRING_ADD_LEFT; |
-var STRING_ADD_LEFT_STRONG; |
-var STRING_ADD_RIGHT; |
-var STRING_ADD_RIGHT_STRONG; |
-var SUB; |
-var SUB_STRONG; |
-var MUL; |
-var MUL_STRONG; |
-var DIV; |
-var DIV_STRONG; |
-var MOD; |
-var MOD_STRONG; |
-var BIT_OR; |
-var BIT_OR_STRONG; |
-var BIT_AND; |
-var BIT_AND_STRONG; |
-var BIT_XOR; |
-var BIT_XOR_STRONG; |
-var SHL; |
-var SHL_STRONG; |
-var SAR; |
-var SAR_STRONG; |
-var SHR; |
-var SHR_STRONG; |
-var DELETE; |
-var IN; |
-var INSTANCE_OF; |
-var FILTER_KEY; |
-var CALL_NON_FUNCTION; |
-var CALL_NON_FUNCTION_AS_CONSTRUCTOR; |
-var CALL_FUNCTION_PROXY; |
-var CALL_FUNCTION_PROXY_AS_CONSTRUCTOR; |
-var APPLY_PREPARE; |
-var REFLECT_APPLY_PREPARE; |
-var REFLECT_CONSTRUCT_PREPARE; |
-var STACK_OVERFLOW; |
-var TO_OBJECT; |
-var TO_NUMBER; |
-var TO_STRING; |
-var TO_NAME; |
- |
-var STRING_LENGTH_STUB; |
- |
-var $defaultNumber; |
-var $defaultString; |
-var $NaN; |
-var $nonNumberToNumber; |
-var $nonStringToString; |
-var $sameValue; |
-var $sameValueZero; |
-var $toBoolean; |
-var $toInt32; |
-var $toInteger; |
-var $toLength; |
-var $toName; |
-var $toNumber; |
-var $toObject; |
-var $toPositiveInteger; |
-var $toPrimitive; |
-var $toString; |
-var $toUint32; |
- |
-(function() { |
- |
-%CheckIsBootstrapping(); |
- |
-var GlobalArray = global.Array; |
-var GlobalBoolean = global.Boolean; |
-var GlobalString = global.String; |
-var GlobalNumber = global.Number; |
- |
-// ---------------------------------------------------------------------------- |
+var $Object = global.Object; |
+var $Array = global.Array; |
+var $String = global.String; |
+var $Number = global.Number; |
+var $Function = global.Function; |
+var $Boolean = global.Boolean; |
+var $NaN = %GetRootNaN(); |
// ECMA-262 Section 11.9.3. |
-EQUALS = function EQUALS(y) { |
+function EQUALS(y) { |
if (IS_STRING(this) && IS_STRING(y)) return %StringEquals(this, y); |
var x = this; |
@@ -107,18 +37,18 @@ |
if (IS_SYMBOL(y)) return 1; // not equal |
if (!IS_SPEC_OBJECT(y)) { |
// String or boolean. |
- return %NumberEquals(x, %$toNumber(y)); |
+ return %NumberEquals(x, %ToNumber(y)); |
} |
- y = %$toPrimitive(y, NO_HINT); |
+ y = %ToPrimitive(y, NO_HINT); |
} |
} else if (IS_STRING(x)) { |
while (true) { |
if (IS_STRING(y)) return %StringEquals(x, y); |
if (IS_SYMBOL(y)) return 1; // not equal |
- if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y); |
- if (IS_BOOLEAN(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y)); |
+ 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); |
+ y = %ToPrimitive(y, NO_HINT); |
} |
} else if (IS_SYMBOL(x)) { |
if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1; |
@@ -126,12 +56,12 @@ |
} else if (IS_BOOLEAN(x)) { |
if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1; |
if (IS_NULL_OR_UNDEFINED(y)) return 1; |
- if (IS_NUMBER(y)) return %NumberEquals(%$toNumber(x), y); |
- if (IS_STRING(y)) return %NumberEquals(%$toNumber(x), %$toNumber(y)); |
+ if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y); |
+ if (IS_STRING(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y)); |
if (IS_SYMBOL(y)) return 1; // not equal |
// y is object. |
- x = %$toNumber(x); |
- y = %$toPrimitive(y, NO_HINT); |
+ x = %ToNumber(x); |
+ y = %ToPrimitive(y, NO_HINT); |
} else if (IS_NULL_OR_UNDEFINED(x)) { |
return IS_NULL_OR_UNDEFINED(y) ? 0 : 1; |
} else { |
@@ -141,14 +71,14 @@ |
} |
if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal |
if (IS_SYMBOL(y)) return 1; // not equal |
- if (IS_BOOLEAN(y)) y = %$toNumber(y); |
- x = %$toPrimitive(x, NO_HINT); |
+ if (IS_BOOLEAN(y)) y = %ToNumber(y); |
+ x = %ToPrimitive(x, NO_HINT); |
} |
} |
} |
// ECMA-262, section 11.9.4, page 56. |
-STRICT_EQUALS = function STRICT_EQUALS(x) { |
+function STRICT_EQUALS(x) { |
if (IS_STRING(this)) { |
if (!IS_STRING(x)) return 1; // not equal |
return %StringEquals(this, x); |
@@ -168,7 +98,7 @@ |
// ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as |
// the result when either (or both) the operands are NaN. |
-COMPARE = function COMPARE(x, ncr) { |
+function COMPARE(x, ncr) { |
var left; |
var right; |
// Fast cases for string, numbers and undefined compares. |
@@ -182,22 +112,22 @@ |
left = this; |
} else if (IS_UNDEFINED(this)) { |
if (!IS_UNDEFINED(x)) { |
- %$toPrimitive(x, NUMBER_HINT); |
+ %ToPrimitive(x, NUMBER_HINT); |
} |
return ncr; |
} else if (IS_UNDEFINED(x)) { |
- %$toPrimitive(this, NUMBER_HINT); |
+ %ToPrimitive(this, NUMBER_HINT); |
return ncr; |
} else { |
- left = %$toPrimitive(this, NUMBER_HINT); |
- } |
- |
- right = %$toPrimitive(x, NUMBER_HINT); |
+ left = %ToPrimitive(this, NUMBER_HINT); |
+ } |
+ |
+ right = %ToPrimitive(x, NUMBER_HINT); |
if (IS_STRING(left) && IS_STRING(right)) { |
return %_StringCompare(left, right); |
} else { |
- var left_number = %$toNumber(left); |
- var right_number = %$toNumber(right); |
+ 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); |
} |
@@ -211,27 +141,27 @@ |
*/ |
// ECMA-262, section 11.6.1, page 50. |
-ADD = function ADD(x) { |
+function ADD(x) { |
// Fast case: Check for number operands and do the addition. |
if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x); |
if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x); |
// Default implementation. |
- var a = %$toPrimitive(this, NO_HINT); |
- var b = %$toPrimitive(x, NO_HINT); |
+ var a = %ToPrimitive(this, NO_HINT); |
+ var b = %ToPrimitive(x, NO_HINT); |
if (IS_STRING(a)) { |
- return %_StringAdd(a, %$toString(b)); |
+ return %_StringAdd(a, %ToString(b)); |
} else if (IS_STRING(b)) { |
- return %_StringAdd(%$nonStringToString(a), b); |
+ return %_StringAdd(%NonStringToString(a), b); |
} else { |
- return %NumberAdd(%$toNumber(a), %$toNumber(b)); |
+ return %NumberAdd(%ToNumber(a), %ToNumber(b)); |
} |
} |
// Strong mode ADD throws if an implicit conversion would be performed |
-ADD_STRONG = function ADD_STRONG(x) { |
+function ADD_STRONG(x) { |
if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x); |
if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x); |
@@ -240,14 +170,14 @@ |
// Left operand (this) is already a string. |
-STRING_ADD_LEFT = function STRING_ADD_LEFT(y) { |
+function STRING_ADD_LEFT(y) { |
if (!IS_STRING(y)) { |
if (IS_STRING_WRAPPER(y) && %_IsStringWrapperSafeForDefaultValueOf(y)) { |
y = %_ValueOf(y); |
} else { |
y = IS_NUMBER(y) |
? %_NumberToString(y) |
- : %$toString(%$toPrimitive(y, NO_HINT)); |
+ : %ToString(%ToPrimitive(y, NO_HINT)); |
} |
} |
return %_StringAdd(this, y); |
@@ -255,7 +185,7 @@ |
// Left operand (this) is already a string. |
-STRING_ADD_LEFT_STRONG = function STRING_ADD_LEFT_STRONG(y) { |
+function STRING_ADD_LEFT_STRONG(y) { |
if (IS_STRING(y)) { |
return %_StringAdd(this, y); |
} |
@@ -264,7 +194,7 @@ |
// Right operand (y) is already a string. |
-STRING_ADD_RIGHT = function STRING_ADD_RIGHT(y) { |
+function STRING_ADD_RIGHT(y) { |
var x = this; |
if (!IS_STRING(x)) { |
if (IS_STRING_WRAPPER(x) && %_IsStringWrapperSafeForDefaultValueOf(x)) { |
@@ -272,7 +202,7 @@ |
} else { |
x = IS_NUMBER(x) |
? %_NumberToString(x) |
- : %$toString(%$toPrimitive(x, NO_HINT)); |
+ : %ToString(%ToPrimitive(x, NO_HINT)); |
} |
} |
return %_StringAdd(x, y); |
@@ -280,7 +210,7 @@ |
// Right operand (y) is already a string. |
-STRING_ADD_RIGHT_STRONG = function STRING_ADD_RIGHT_STRONG(y) { |
+function STRING_ADD_RIGHT_STRONG(y) { |
if (IS_STRING(this)) { |
return %_StringAdd(this, y); |
} |
@@ -289,15 +219,15 @@ |
// ECMA-262, section 11.6.2, page 50. |
-SUB = function SUB(y) { |
- var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+function SUB(y) { |
+ var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
return %NumberSub(x, y); |
} |
// Strong mode SUB throws if an implicit conversion would be performed |
-SUB_STRONG = function SUB_STRONG(y) { |
+function SUB_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberSub(this, y); |
} |
@@ -306,15 +236,15 @@ |
// ECMA-262, section 11.5.1, page 48. |
-MUL = function MUL(y) { |
- var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+function MUL(y) { |
+ var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
return %NumberMul(x, y); |
} |
// Strong mode MUL throws if an implicit conversion would be performed |
-MUL_STRONG = function MUL_STRONG(y) { |
+function MUL_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberMul(this, y); |
} |
@@ -323,15 +253,15 @@ |
// ECMA-262, section 11.5.2, page 49. |
-DIV = function DIV(y) { |
- var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+function DIV(y) { |
+ var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
return %NumberDiv(x, y); |
} |
// Strong mode DIV throws if an implicit conversion would be performed |
-DIV_STRONG = function DIV_STRONG(y) { |
+function DIV_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberDiv(this, y); |
} |
@@ -340,15 +270,15 @@ |
// ECMA-262, section 11.5.3, page 49. |
-MOD = function MOD(y) { |
- var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+function MOD(y) { |
+ var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
return %NumberMod(x, y); |
} |
// Strong mode MOD throws if an implicit conversion would be performed |
-MOD_STRONG = function MOD_STRONG(y) { |
+function MOD_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberMod(this, y); |
} |
@@ -362,15 +292,15 @@ |
*/ |
// ECMA-262, section 11.10, page 57. |
-BIT_OR = function BIT_OR(y) { |
- var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+function BIT_OR(y) { |
+ var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
return %NumberOr(x, y); |
} |
// Strong mode BIT_OR throws if an implicit conversion would be performed |
-BIT_OR_STRONG = function BIT_OR_STRONG(y) { |
+function BIT_OR_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberOr(this, y); |
} |
@@ -379,18 +309,18 @@ |
// ECMA-262, section 11.10, page 57. |
-BIT_AND = function BIT_AND(y) { |
+function BIT_AND(y) { |
var x; |
if (IS_NUMBER(this)) { |
x = this; |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
} else { |
- x = %$nonNumberToNumber(this); |
+ x = %NonNumberToNumber(this); |
// 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. |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
// 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. |
@@ -401,7 +331,7 @@ |
// Strong mode BIT_AND throws if an implicit conversion would be performed |
-BIT_AND_STRONG = function BIT_AND_STRONG(y) { |
+function BIT_AND_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberAnd(this, y); |
} |
@@ -410,15 +340,15 @@ |
// ECMA-262, section 11.10, page 57. |
-BIT_XOR = function BIT_XOR(y) { |
- var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+function BIT_XOR(y) { |
+ var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
return %NumberXor(x, y); |
} |
// Strong mode BIT_XOR throws if an implicit conversion would be performed |
-BIT_XOR_STRONG = function BIT_XOR_STRONG(y) { |
+function BIT_XOR_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberXor(this, y); |
} |
@@ -427,15 +357,15 @@ |
// ECMA-262, section 11.7.1, page 51. |
-SHL = function SHL(y) { |
- var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+function SHL(y) { |
+ var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
return %NumberShl(x, y); |
} |
// Strong mode SHL throws if an implicit conversion would be performed |
-SHL_STRONG = function SHL_STRONG(y) { |
+function SHL_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberShl(this, y); |
} |
@@ -444,18 +374,18 @@ |
// ECMA-262, section 11.7.2, page 51. |
-SAR = function SAR(y) { |
+function SAR(y) { |
var x; |
if (IS_NUMBER(this)) { |
x = this; |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
} else { |
- x = %$nonNumberToNumber(this); |
+ x = %NonNumberToNumber(this); |
// 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. |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
// Optimize for the case where we end up shifting a value |
// that doesn't convert to a number. This is common in |
// certain benchmarks. |
@@ -466,7 +396,7 @@ |
// Strong mode SAR throws if an implicit conversion would be performed |
-SAR_STRONG = function SAR_STRONG(y) { |
+function SAR_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberSar(this, y); |
} |
@@ -475,15 +405,15 @@ |
// ECMA-262, section 11.7.3, page 52. |
-SHR = function SHR(y) { |
- var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); |
- if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); |
+function SHR(y) { |
+ var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
+ if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
return %NumberShr(x, y); |
} |
// Strong mode SHR throws if an implicit conversion would be performed |
-SHR_STRONG = function SHR_STRONG(y) { |
+function SHR_STRONG(y) { |
if (IS_NUMBER(this) && IS_NUMBER(y)) { |
return %NumberShr(this, y); |
} |
@@ -497,13 +427,13 @@ |
*/ |
// ECMA-262, section 11.4.1, page 46. |
-DELETE = function DELETE(key, language_mode) { |
- return %DeleteProperty(%$toObject(this), %$toName(key), language_mode); |
+function DELETE(key, language_mode) { |
+ return %DeleteProperty(%ToObject(this), %ToName(key), language_mode); |
} |
// ECMA-262, section 11.8.7, page 54. |
-IN = function IN(x) { |
+function IN(x) { |
if (!IS_SPEC_OBJECT(x)) { |
throw %MakeTypeError(kInvalidInOperatorUse, this, x); |
} |
@@ -513,7 +443,7 @@ |
} |
return %HasElement(x, this); |
} |
- return %HasProperty(x, %$toName(this)); |
+ return %HasProperty(x, %ToName(this)); |
} |
@@ -521,7 +451,7 @@ |
// efficient, the return value should be zero if the 'this' is an |
// instance of F, and non-zero if not. This makes it possible to avoid |
// an expensive ToBoolean conversion in the generated code. |
-INSTANCE_OF = function INSTANCE_OF(F) { |
+function INSTANCE_OF(F) { |
var V = this; |
if (!IS_SPEC_FUNCTION(F)) { |
throw %MakeTypeError(kInstanceofFunctionExpected, F); |
@@ -552,14 +482,14 @@ |
// 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 |
// it has. Otherwise returns 0 (smi). Used in for-in statements. |
-FILTER_KEY = function FILTER_KEY(key) { |
- var string = %$toName(key); |
+function FILTER_KEY(key) { |
+ var string = %ToName(key); |
if (%HasProperty(this, string)) return string; |
return 0; |
} |
-CALL_NON_FUNCTION = function CALL_NON_FUNCTION() { |
+function CALL_NON_FUNCTION() { |
var delegate = %GetFunctionDelegate(this); |
if (!IS_FUNCTION(delegate)) { |
var callsite = %RenderCallSite(); |
@@ -570,7 +500,7 @@ |
} |
-CALL_NON_FUNCTION_AS_CONSTRUCTOR = function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { |
+function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { |
var delegate = %GetConstructorDelegate(this); |
if (!IS_FUNCTION(delegate)) { |
var callsite = %RenderCallSite(); |
@@ -581,7 +511,7 @@ |
} |
-CALL_FUNCTION_PROXY = function CALL_FUNCTION_PROXY() { |
+function CALL_FUNCTION_PROXY() { |
var arity = %_ArgumentsLength() - 1; |
var proxy = %_Arguments(arity); // The proxy comes in as an additional arg. |
var trap = %GetCallTrap(proxy); |
@@ -589,15 +519,14 @@ |
} |
-CALL_FUNCTION_PROXY_AS_CONSTRUCTOR = |
- function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR () { |
+function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR() { |
var proxy = this; |
var trap = %GetConstructTrap(proxy); |
return %Apply(trap, this, arguments, 0, %_ArgumentsLength()); |
} |
-APPLY_PREPARE = function APPLY_PREPARE(args) { |
+function APPLY_PREPARE(args) { |
var length; |
// 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 |
@@ -610,7 +539,7 @@ |
} |
} |
- length = (args == null) ? 0 : %$toUint32(args.length); |
+ length = (args == null) ? 0 : %ToUint32(args.length); |
// We can handle any number of apply arguments if the stack is |
// big enough, but sanity check the value to avoid overflow when |
@@ -618,7 +547,7 @@ |
if (length > kSafeArgumentsLength) throw %MakeRangeError(kStackOverflow); |
if (!IS_SPEC_FUNCTION(this)) { |
- throw %MakeTypeError(kApplyNonFunction, %$toString(this), typeof this); |
+ throw %MakeTypeError(kApplyNonFunction, %ToString(this), typeof this); |
} |
// Make sure the arguments list has the right type. |
@@ -632,7 +561,7 @@ |
} |
-REFLECT_APPLY_PREPARE = function REFLECT_APPLY_PREPARE(args) { |
+function REFLECT_APPLY_PREPARE(args) { |
var length; |
// 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 |
@@ -646,14 +575,14 @@ |
} |
if (!IS_SPEC_FUNCTION(this)) { |
- throw %MakeTypeError(kCalledNonCallable, %$toString(this)); |
+ throw %MakeTypeError(kCalledNonCallable, %ToString(this)); |
} |
if (!IS_SPEC_OBJECT(args)) { |
throw %MakeTypeError(kWrongArgs, "Reflect.apply"); |
} |
- length = %$toLength(args.length); |
+ length = %ToLength(args.length); |
// We can handle any number of apply arguments if the stack is |
// big enough, but sanity check the value to avoid overflow when |
@@ -666,8 +595,7 @@ |
} |
-REFLECT_CONSTRUCT_PREPARE = function REFLECT_CONSTRUCT_PREPARE( |
- args, newTarget) { |
+function REFLECT_CONSTRUCT_PREPARE(args, newTarget) { |
var length; |
var ctorOk = IS_SPEC_FUNCTION(this) && %IsConstructor(this); |
var newTargetOk = IS_SPEC_FUNCTION(newTarget) && %IsConstructor(newTarget); |
@@ -685,17 +613,17 @@ |
if (!ctorOk) { |
if (!IS_SPEC_FUNCTION(this)) { |
- throw %MakeTypeError(kCalledNonCallable, %$toString(this)); |
+ throw %MakeTypeError(kCalledNonCallable, %ToString(this)); |
} else { |
- throw %MakeTypeError(kNotConstructor, %$toString(this)); |
+ throw %MakeTypeError(kNotConstructor, %ToString(this)); |
} |
} |
if (!newTargetOk) { |
if (!IS_SPEC_FUNCTION(newTarget)) { |
- throw %MakeTypeError(kCalledNonCallable, %$toString(newTarget)); |
+ throw %MakeTypeError(kCalledNonCallable, %ToString(newTarget)); |
} else { |
- throw %MakeTypeError(kNotConstructor, %$toString(newTarget)); |
+ throw %MakeTypeError(kNotConstructor, %ToString(newTarget)); |
} |
} |
@@ -703,7 +631,7 @@ |
throw %MakeTypeError(kWrongArgs, "Reflect.construct"); |
} |
- length = %$toLength(args.length); |
+ length = %ToLength(args.length); |
// We can handle any number of apply arguments if the stack is |
// big enough, but sanity check the value to avoid overflow when |
@@ -716,43 +644,32 @@ |
} |
-STACK_OVERFLOW = function STACK_OVERFLOW(length) { |
+function STACK_OVERFLOW(length) { |
throw %MakeRangeError(kStackOverflow); |
} |
// Convert the receiver to an object - forward to ToObject. |
-TO_OBJECT = function TO_OBJECT() { |
- return %$toObject(this); |
+function TO_OBJECT() { |
+ return %ToObject(this); |
} |
// Convert the receiver to a number - forward to ToNumber. |
-TO_NUMBER = function TO_NUMBER() { |
- return %$toNumber(this); |
+function TO_NUMBER() { |
+ return %ToNumber(this); |
} |
// Convert the receiver to a string - forward to ToString. |
-TO_STRING = function TO_STRING() { |
- return %$toString(this); |
+function TO_STRING() { |
+ return %ToString(this); |
} |
// Convert the receiver to a string or symbol - forward to ToName. |
-TO_NAME = function TO_NAME() { |
- return %$toName(this); |
-} |
- |
- |
-/* ----------------------------------------------- |
- - - - J a v a S c r i p t S t u b s - - - |
- ----------------------------------------------- |
-*/ |
- |
-STRING_LENGTH_STUB = function STRING_LENGTH_STUB(name) { |
- var receiver = this; // implicit first parameter |
- return %_StringGetLength(%_JSValueGetValue(receiver)); |
+function TO_NAME() { |
+ return %ToName(this); |
} |
@@ -770,7 +687,7 @@ |
if (!IS_SPEC_OBJECT(x)) return x; |
if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError(kSymbolToPrimitive); |
if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; |
- return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x); |
+ return (hint == NUMBER_HINT) ? %DefaultNumber(x) : %DefaultString(x); |
} |
@@ -794,7 +711,7 @@ |
if (IS_BOOLEAN(x)) return x ? 1 : 0; |
if (IS_UNDEFINED(x)) return NAN; |
if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber); |
- return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); |
+ return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x)); |
} |
function NonNumberToNumber(x) { |
@@ -805,7 +722,7 @@ |
if (IS_BOOLEAN(x)) return x ? 1 : 0; |
if (IS_UNDEFINED(x)) return NAN; |
if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToNumber); |
- return (IS_NULL(x)) ? 0 : ToNumber(DefaultNumber(x)); |
+ return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x)); |
} |
@@ -815,33 +732,33 @@ |
if (IS_NUMBER(x)) return %_NumberToString(x); |
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; |
if (IS_UNDEFINED(x)) return 'undefined'; |
- if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString); |
- return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x)); |
+ if (IS_SYMBOL(x)) throw %MakeTypeError(kSymbolToString); |
+ return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x)); |
} |
function NonStringToString(x) { |
if (IS_NUMBER(x)) return %_NumberToString(x); |
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; |
if (IS_UNDEFINED(x)) return 'undefined'; |
- if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString); |
- return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x)); |
+ if (IS_SYMBOL(x)) throw %MakeTypeError(kSymbolToString); |
+ return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x)); |
} |
// ES6 symbols |
function ToName(x) { |
- return IS_SYMBOL(x) ? x : ToString(x); |
+ return IS_SYMBOL(x) ? x : %ToString(x); |
} |
// ECMA-262, section 9.9, page 36. |
function ToObject(x) { |
- if (IS_STRING(x)) return new GlobalString(x); |
- if (IS_NUMBER(x)) return new GlobalNumber(x); |
- if (IS_BOOLEAN(x)) return new GlobalBoolean(x); |
+ if (IS_STRING(x)) return new $String(x); |
+ if (IS_NUMBER(x)) return new $Number(x); |
+ if (IS_BOOLEAN(x)) return new $Boolean(x); |
if (IS_SYMBOL(x)) return %NewSymbolWrapper(x); |
if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { |
- throw MakeTypeError(kUndefinedOrNullToObject); |
+ throw %MakeTypeError(kUndefinedOrNullToObject); |
} |
return x; |
} |
@@ -858,8 +775,7 @@ |
function ToLength(arg) { |
arg = ToInteger(arg); |
if (arg < 0) return 0; |
- return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg |
- : GlobalNumber.MAX_SAFE_INTEGER; |
+ return arg < $Number.MAX_SAFE_INTEGER ? arg : $Number.MAX_SAFE_INTEGER; |
} |
@@ -890,7 +806,6 @@ |
return x === y; |
} |
- |
// ES6, section 7.2.4 |
function SameValueZero(x, y) { |
if (typeof x != typeof y) return false; |
@@ -931,16 +846,16 @@ |
var valueOf = x.valueOf; |
if (IS_SPEC_FUNCTION(valueOf)) { |
var v = %_CallFunction(x, valueOf); |
- if (IsPrimitive(v)) return v; |
+ if (%IsPrimitive(v)) return v; |
} |
var toString = x.toString; |
if (IS_SPEC_FUNCTION(toString)) { |
var s = %_CallFunction(x, toString); |
- if (IsPrimitive(s)) return s; |
- } |
- } |
- throw MakeTypeError(kCannotConvertToPrimitive); |
+ if (%IsPrimitive(s)) return s; |
+ } |
+ } |
+ throw %MakeTypeError(kCannotConvertToPrimitive); |
} |
// ECMA-262, section 8.6.2.6, page 28. |
@@ -949,16 +864,16 @@ |
var toString = x.toString; |
if (IS_SPEC_FUNCTION(toString)) { |
var s = %_CallFunction(x, toString); |
- if (IsPrimitive(s)) return s; |
+ if (%IsPrimitive(s)) return s; |
} |
var valueOf = x.valueOf; |
if (IS_SPEC_FUNCTION(valueOf)) { |
var v = %_CallFunction(x, valueOf); |
- if (IsPrimitive(v)) return v; |
- } |
- } |
- throw MakeTypeError(kCannotConvertToPrimitive); |
+ if (%IsPrimitive(v)) return v; |
+ } |
+ } |
+ throw %MakeTypeError(kCannotConvertToPrimitive); |
} |
function ToPositiveInteger(x, rangeErrorIndex) { |
@@ -967,34 +882,21 @@ |
return i; |
} |
-//---------------------------------------------------------------------------- |
// 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 |
// that is cloned when running the code. It is essential that the |
// boilerplate gets the right prototype. |
-%FunctionSetPrototype(GlobalArray, new GlobalArray(0)); |
- |
-//---------------------------------------------------------------------------- |
- |
-$defaultNumber = DefaultNumber; |
-$defaultString = DefaultString; |
-$NaN = %GetRootNaN(); |
-$nonNumberToNumber = NonNumberToNumber; |
-$nonStringToString = NonStringToString; |
-$sameValue = SameValue; |
-$sameValueZero = SameValueZero; |
-$toBoolean = ToBoolean; |
-$toInt32 = ToInt32; |
-$toInteger = ToInteger; |
-$toLength = ToLength; |
-$toName = ToName; |
-$toNumber = ToNumber; |
-$toObject = ToObject; |
-$toPositiveInteger = ToPositiveInteger; |
-$toPrimitive = ToPrimitive; |
-$toString = ToString; |
-$toUint32 = ToUint32; |
- |
-})(); |
+%FunctionSetPrototype($Array, new $Array(0)); |
+ |
+ |
+/* ----------------------------------------------- |
+ - - - J a v a S c r i p t S t u b s - - - |
+ ----------------------------------------------- |
+*/ |
+ |
+function STRING_LENGTH_STUB(name) { |
+ var receiver = this; // implicit first parameter |
+ return %_StringGetLength(%_JSValueGetValue(receiver)); |
+} |