Move global code for builtins into setup functions.
R=rossberg@chromium.org Review URL: https://codereview.chromium.org/14125004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14228 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
714113b22c
commit
6a260c3363
@ -1454,8 +1454,10 @@ function ArrayIsArray(obj) {
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function SetUpArray() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// Set up non-enumerable constructor property on the Array.prototype
|
||||
// object.
|
||||
%SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
|
||||
|
@ -27,16 +27,20 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// This file relies on the fact that the following declaration has been made
|
||||
// in runtime.js:
|
||||
// var $Array = global.Array;
|
||||
|
||||
var $Set = global.Set;
|
||||
var $Map = global.Map;
|
||||
var $WeakMap = global.WeakMap;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// Global sentinel to be used instead of undefined keys, which are not
|
||||
// supported internally but required for Harmony sets and maps.
|
||||
var undefined_sentinel = {};
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Harmony Set
|
||||
|
||||
function SetConstructor() {
|
||||
if (%_IsConstructCall()) {
|
||||
@ -107,6 +111,30 @@ function SetClear() {
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function SetUpSet() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%SetCode($Set, SetConstructor);
|
||||
%SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
|
||||
|
||||
// Set up the non-enumerable functions on the Set prototype object.
|
||||
InstallGetter($Set.prototype, "size", SetGetSize);
|
||||
InstallFunctions($Set.prototype, DONT_ENUM, $Array(
|
||||
"add", SetAdd,
|
||||
"has", SetHas,
|
||||
"delete", SetDelete,
|
||||
"clear", SetClear
|
||||
));
|
||||
}
|
||||
|
||||
SetUpSet();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Harmony Map
|
||||
|
||||
function MapConstructor() {
|
||||
if (%_IsConstructCall()) {
|
||||
%MapInitialize(this);
|
||||
@ -183,6 +211,31 @@ function MapClear() {
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function SetUpMap() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%SetCode($Map, MapConstructor);
|
||||
%SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
|
||||
|
||||
// Set up the non-enumerable functions on the Map prototype object.
|
||||
InstallGetter($Map.prototype, "size", MapGetSize);
|
||||
InstallFunctions($Map.prototype, DONT_ENUM, $Array(
|
||||
"get", MapGet,
|
||||
"set", MapSet,
|
||||
"has", MapHas,
|
||||
"delete", MapDelete,
|
||||
"clear", MapClear
|
||||
));
|
||||
}
|
||||
|
||||
SetUpMap();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Harmony WeakMap
|
||||
|
||||
function WeakMapConstructor() {
|
||||
if (%_IsConstructCall()) {
|
||||
%WeakMapInitialize(this);
|
||||
@ -239,42 +292,13 @@ function WeakMapDelete(key) {
|
||||
return %WeakMapDelete(this, key);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
(function () {
|
||||
function SetUpWeakMap() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// Set up the Set and Map constructor function.
|
||||
%SetCode($Set, SetConstructor);
|
||||
%SetCode($Map, MapConstructor);
|
||||
|
||||
// Set up the constructor property on the Set and Map prototype object.
|
||||
%SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
|
||||
%SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
|
||||
|
||||
// Set up the non-enumerable functions on the Set prototype object.
|
||||
InstallGetter($Set.prototype, "size", SetGetSize);
|
||||
InstallFunctions($Set.prototype, DONT_ENUM, $Array(
|
||||
"add", SetAdd,
|
||||
"has", SetHas,
|
||||
"delete", SetDelete,
|
||||
"clear", SetClear
|
||||
));
|
||||
|
||||
// Set up the non-enumerable functions on the Map prototype object.
|
||||
InstallGetter($Map.prototype, "size", MapGetSize);
|
||||
InstallFunctions($Map.prototype, DONT_ENUM, $Array(
|
||||
"get", MapGet,
|
||||
"set", MapSet,
|
||||
"has", MapHas,
|
||||
"delete", MapDelete,
|
||||
"clear", MapClear
|
||||
));
|
||||
|
||||
// Set up the WeakMap constructor function.
|
||||
%SetCode($WeakMap, WeakMapConstructor);
|
||||
|
||||
// Set up the constructor property on the WeakMap prototype object.
|
||||
%SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM);
|
||||
|
||||
// Set up the non-enumerable functions on the WeakMap prototype object.
|
||||
@ -284,4 +308,6 @@ function WeakMapDelete(key) {
|
||||
"has", WeakMapHas,
|
||||
"delete", WeakMapDelete
|
||||
));
|
||||
})();
|
||||
}
|
||||
|
||||
SetUpWeakMap();
|
||||
|
19
src/date.js
19
src/date.js
@ -25,20 +25,16 @@
|
||||
// (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 file relies on the fact that the following declarations have been made
|
||||
// in v8natives.js:
|
||||
// var $isFinite = GlobalIsFinite;
|
||||
|
||||
var $Date = global.Date;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// This file contains date support implemented in JavaScript.
|
||||
|
||||
// Keep reference to original values of some global properties. This
|
||||
// has the added benefit that the code in this file is isolated from
|
||||
// changes to these properties.
|
||||
var $Date = global.Date;
|
||||
|
||||
// Helper function to throw error.
|
||||
function ThrowDateTypeError() {
|
||||
throw new $TypeError('this is not a Date object.');
|
||||
@ -142,7 +138,7 @@ var Date_cache = {
|
||||
};
|
||||
|
||||
|
||||
%SetCode($Date, function(year, month, date, hours, minutes, seconds, ms) {
|
||||
function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
|
||||
if (!%_IsConstructCall()) {
|
||||
// ECMA 262 - 15.9.2
|
||||
return (new $Date()).toString();
|
||||
@ -199,10 +195,7 @@ var Date_cache = {
|
||||
value = MakeDate(day, time);
|
||||
SET_LOCAL_DATE_VALUE(this, value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
%FunctionSetPrototype($Date, new $Date($NaN));
|
||||
}
|
||||
|
||||
|
||||
var WeekDays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||
@ -767,6 +760,10 @@ function ResetDateCache() {
|
||||
|
||||
function SetUpDate() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%SetCode($Date, DateConstructor);
|
||||
%FunctionSetPrototype($Date, new $Date($NaN));
|
||||
|
||||
// Set up non-enumerable properties of the Date object itself.
|
||||
InstallFunctions($Date, DONT_ENUM, $Array(
|
||||
"UTC", DateUTC,
|
||||
|
18
src/json.js
18
src/json.js
@ -25,8 +25,15 @@
|
||||
// (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 file relies on the fact that the following declarations have been made
|
||||
// in runtime.js:
|
||||
// var $Array = global.Array;
|
||||
// var $String = global.String;
|
||||
|
||||
var $JSON = global.JSON;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function Revive(holder, name, reviver) {
|
||||
var val = holder[name];
|
||||
if (IS_OBJECT(val)) {
|
||||
@ -207,14 +214,23 @@ function JSONStringify(value, replacer, space) {
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function SetUpJSON() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// Set up non-enumerable properties of the JSON object.
|
||||
InstallFunctions($JSON, DONT_ENUM, $Array(
|
||||
"parse", JSONParse,
|
||||
"stringify", JSONStringify
|
||||
));
|
||||
}
|
||||
|
||||
SetUpJSON();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// JSON Builtins
|
||||
|
||||
function JSONSerializeAdapter(key, object) {
|
||||
var holder = {};
|
||||
@ -222,5 +238,3 @@ function JSONSerializeAdapter(key, object) {
|
||||
// No need to pass the actual holder since there is no replacer function.
|
||||
return JSONSerialize(key, holder, void 0, new InternalArray(), "", "");
|
||||
}
|
||||
|
||||
SetUpJSON();
|
||||
|
13
src/math.js
13
src/math.js
@ -25,6 +25,9 @@
|
||||
// (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 file relies on the fact that the following declarations have been made
|
||||
// in runtime.js:
|
||||
// var $Object = global.Object;
|
||||
|
||||
// Keep reference to original values of some global properties. This
|
||||
// has the added benefit that the code in this file is isolated from
|
||||
@ -35,10 +38,9 @@ var $abs = MathAbs;
|
||||
// Instance class name can only be set on functions. That is the only
|
||||
// purpose for MathConstructor.
|
||||
function MathConstructor() {}
|
||||
%FunctionSetInstanceClassName(MathConstructor, 'Math');
|
||||
var $Math = new MathConstructor();
|
||||
%SetPrototype($Math, $Object.prototype);
|
||||
%SetProperty(global, "Math", $Math, DONT_ENUM);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// ECMA 262 - 15.8.2.1
|
||||
function MathAbs(x) {
|
||||
@ -216,6 +218,11 @@ function MathTan(x) {
|
||||
|
||||
function SetUpMath() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%SetPrototype($Math, $Object.prototype);
|
||||
%SetProperty(global, "Math", $Math, DONT_ENUM);
|
||||
%FunctionSetInstanceClassName(MathConstructor, 'Math');
|
||||
|
||||
// Set up math constants.
|
||||
// ECMA-262, section 15.8.1.1.
|
||||
%OptimizeObjectForAddingMultipleProperties($Math, 8);
|
||||
|
34
src/proxy.js
34
src/proxy.js
@ -27,9 +27,13 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
global.Proxy = new $Object();
|
||||
// This file relies on the fact that the following declaration has been made
|
||||
// in runtime.js:
|
||||
// var $Object = global.Object;
|
||||
|
||||
var $Proxy = global.Proxy
|
||||
var $Proxy = new $Object();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function ProxyCreate(handler, proto) {
|
||||
if (!IS_SPEC_OBJECT(handler))
|
||||
@ -62,16 +66,26 @@ function ProxyCreateFunction(handler, callTrap, constructTrap) {
|
||||
handler, callTrap, constructTrap, $Function.prototype)
|
||||
}
|
||||
|
||||
%CheckIsBootstrapping()
|
||||
InstallFunctions($Proxy, DONT_ENUM, [
|
||||
"create", ProxyCreate,
|
||||
"createFunction", ProxyCreateFunction
|
||||
])
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function SetUpProxy() {
|
||||
%CheckIsBootstrapping()
|
||||
|
||||
global.Proxy = $Proxy;
|
||||
|
||||
// Set up non-enumerable properties of the Proxy object.
|
||||
InstallFunctions($Proxy, DONT_ENUM, [
|
||||
"create", ProxyCreate,
|
||||
"createFunction", ProxyCreateFunction
|
||||
])
|
||||
}
|
||||
|
||||
SetUpProxy();
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Builtins
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// -------------------------------------------------------------------
|
||||
// Proxy Builtins
|
||||
|
||||
function DerivedConstructTrap(callTrap) {
|
||||
return function() {
|
||||
|
@ -25,11 +25,15 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Expect $Object = global.Object;
|
||||
// Expect $Array = global.Array;
|
||||
// This file relies on the fact that the following declaration has been made
|
||||
// in runtime.js:
|
||||
// var $Object = global.Object;
|
||||
// var $Array = global.Array;
|
||||
|
||||
var $RegExp = global.RegExp;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// A recursive descent parser for Patterns according to the grammar of
|
||||
// ECMA-262 15.10.1, with deviations noted below.
|
||||
function DoConstructRegExp(object, pattern, flags) {
|
||||
|
@ -25,24 +25,22 @@
|
||||
// (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 file relies on the fact that the following declaration has been made
|
||||
// in runtime.js:
|
||||
// var $String = global.String;
|
||||
// var $NaN = 0/0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Set the String function and constructor.
|
||||
%SetCode($String, function(x) {
|
||||
function StringConstructor(x) {
|
||||
var value = %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x);
|
||||
if (%_IsConstructCall()) {
|
||||
%_SetValueOf(this, value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
%FunctionSetPrototype($String, new $String());
|
||||
|
||||
// ECMA-262 section 15.5.4.2
|
||||
function StringToString() {
|
||||
@ -994,16 +992,19 @@ SetUpLockedPrototype(ReplaceResultBuilder,
|
||||
|
||||
function SetUpString() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// Set the String function and constructor.
|
||||
%SetCode($String, StringConstructor);
|
||||
%FunctionSetPrototype($String, new $String());
|
||||
|
||||
// Set up the constructor property on the String prototype object.
|
||||
%SetProperty($String.prototype, "constructor", $String, DONT_ENUM);
|
||||
|
||||
|
||||
// Set up the non-enumerable functions on the String object.
|
||||
InstallFunctions($String, DONT_ENUM, $Array(
|
||||
"fromCharCode", StringFromCharCode
|
||||
));
|
||||
|
||||
|
||||
// Set up the non-enumerable functions on the String prototype object.
|
||||
InstallFunctions($String.prototype, DONT_ENUM, $Array(
|
||||
"valueOf", StringValueOf,
|
||||
|
@ -27,8 +27,14 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// This file relies on the fact that the following declaration has been made
|
||||
// in runtime.js:
|
||||
// var $Array = global.Array;
|
||||
|
||||
var $Symbol = global.Symbol;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function SymbolConstructor(x) {
|
||||
var value =
|
||||
IS_SYMBOL(x) ? x : %CreateSymbol(IS_UNDEFINED(x) ? x : ToString(x));
|
||||
|
@ -27,8 +27,14 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// This file relies on the fact that the following declaration has been made
|
||||
// in runtime.js:
|
||||
// var $Array = global.Array;
|
||||
|
||||
var $ArrayBuffer = global.__ArrayBuffer;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
function ArrayBufferConstructor(byteLength) { // length = 1
|
||||
if (%_IsConstructCall()) {
|
||||
var l = TO_POSITIVE_INTEGER(byteLength);
|
||||
@ -77,10 +83,9 @@ function ArrayBufferSlice(start, end) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
(function () {
|
||||
function SetUpArrayBuffer() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// Set up the Uint16Array constructor function.
|
||||
@ -94,5 +99,6 @@ function ArrayBufferSlice(start, end) {
|
||||
InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, $Array(
|
||||
"slice", ArrayBufferSlice
|
||||
));
|
||||
}
|
||||
|
||||
})();
|
||||
SetUpArrayBuffer();
|
||||
|
@ -25,11 +25,15 @@
|
||||
// (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 file relies on the fact that the following declaration has been made
|
||||
// in runtime.js:
|
||||
// var $Array = global.Array;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// This file contains support for URI manipulations written in
|
||||
// JavaScript.
|
||||
|
||||
// Expect $String = global.String;
|
||||
|
||||
// Lazily initialized.
|
||||
var hexCharArray = 0;
|
||||
var hexCharCodeArray = 0;
|
||||
@ -437,6 +441,7 @@ function URIUnescape(str) {
|
||||
|
||||
function SetUpUri() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// Set up non-enumerable URI functions on the global object and set
|
||||
// their names.
|
||||
InstallFunctions(global, DONT_ENUM, $Array(
|
||||
|
@ -26,7 +26,6 @@
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file relies on the fact that the following declarations have been made
|
||||
//
|
||||
// in runtime.js:
|
||||
// var $Object = global.Object;
|
||||
// var $Boolean = global.Boolean;
|
||||
@ -43,7 +42,6 @@ var $isFinite = GlobalIsFinite;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Helper function used to install functions on objects.
|
||||
function InstallFunctions(object, attributes, functions) {
|
||||
if (functions.length >= 8) {
|
||||
@ -198,6 +196,7 @@ function GlobalEval(x) {
|
||||
// Set up global object.
|
||||
function SetUpGlobal() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
// ECMA 262 - 15.1.1.1.
|
||||
%SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
|
||||
@ -220,27 +219,10 @@ function SetUpGlobal() {
|
||||
|
||||
SetUpGlobal();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Boolean (first part of definition)
|
||||
|
||||
|
||||
%SetCode($Boolean, function(x) {
|
||||
if (%_IsConstructCall()) {
|
||||
%_SetValueOf(this, ToBoolean(x));
|
||||
} else {
|
||||
return ToBoolean(x);
|
||||
}
|
||||
});
|
||||
|
||||
%FunctionSetPrototype($Boolean, new $Boolean(false));
|
||||
|
||||
%SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Object
|
||||
|
||||
$Object.prototype.constructor = $Object;
|
||||
|
||||
// ECMA-262 - 15.2.4.2
|
||||
function ObjectToString() {
|
||||
if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
|
||||
@ -1357,7 +1339,7 @@ function ObjectPoisonProto(obj) {
|
||||
}
|
||||
|
||||
|
||||
%SetCode($Object, function(x) {
|
||||
function ObjectConstructor(x) {
|
||||
if (%_IsConstructCall()) {
|
||||
if (x == null) return this;
|
||||
return ToObject(x);
|
||||
@ -1365,7 +1347,7 @@ function ObjectPoisonProto(obj) {
|
||||
if (x == null) return { };
|
||||
return ToObject(x);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1374,6 +1356,8 @@ function ObjectPoisonProto(obj) {
|
||||
function SetUpObject() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
$Object.prototype.constructor = $Object;
|
||||
%SetCode($Object, ObjectConstructor);
|
||||
%FunctionSetName(ObjectPoisonProto, "__proto__");
|
||||
%FunctionRemovePrototype(ObjectPoisonProto);
|
||||
%SetExpectedNumberOfProperties($Object, 4);
|
||||
@ -1415,9 +1399,19 @@ function SetUpObject() {
|
||||
|
||||
SetUpObject();
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Boolean
|
||||
|
||||
function BooleanConstructor(x) {
|
||||
if (%_IsConstructCall()) {
|
||||
%_SetValueOf(this, ToBoolean(x));
|
||||
} else {
|
||||
return ToBoolean(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function BooleanToString() {
|
||||
// NOTE: Both Boolean objects and values can enter here as
|
||||
// 'this'. This is not as dictated by ECMA-262.
|
||||
@ -1444,9 +1438,13 @@ function BooleanValueOf() {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
function SetUpBoolean () {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%SetCode($Boolean, BooleanConstructor);
|
||||
%FunctionSetPrototype($Boolean, new $Boolean(false));
|
||||
%SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM);
|
||||
|
||||
InstallFunctions($Boolean.prototype, DONT_ENUM, $Array(
|
||||
"toString", BooleanToString,
|
||||
"valueOf", BooleanValueOf
|
||||
@ -1459,17 +1457,15 @@ SetUpBoolean();
|
||||
// ----------------------------------------------------------------------------
|
||||
// Number
|
||||
|
||||
// Set the Number function and constructor.
|
||||
%SetCode($Number, function(x) {
|
||||
function NumberConstructor(x) {
|
||||
var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x);
|
||||
if (%_IsConstructCall()) {
|
||||
%_SetValueOf(this, value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
%FunctionSetPrototype($Number, new $Number(0));
|
||||
|
||||
// ECMA-262 section 15.7.4.2.
|
||||
function NumberToString(radix) {
|
||||
@ -1607,6 +1603,10 @@ function NumberIsNaN(number) {
|
||||
|
||||
function SetUpNumber() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
%SetCode($Number, NumberConstructor);
|
||||
%FunctionSetPrototype($Number, new $Number(0));
|
||||
|
||||
%OptimizeObjectForAddingMultipleProperties($Number.prototype, 8);
|
||||
// Set up the constructor property on the Number prototype object.
|
||||
%SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
|
||||
@ -1659,8 +1659,6 @@ SetUpNumber();
|
||||
// ----------------------------------------------------------------------------
|
||||
// Function
|
||||
|
||||
$Function.prototype.constructor = $Function;
|
||||
|
||||
function FunctionSourceString(func) {
|
||||
while (%IsJSFunctionProxy(func)) {
|
||||
func = %GetCallTrap(func);
|
||||
@ -1784,12 +1782,15 @@ function NewFunction(arg1) { // length == 1
|
||||
return %SetNewFunctionAttributes(f);
|
||||
}
|
||||
|
||||
%SetCode($Function, NewFunction);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function SetUpFunction() {
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
$Function.prototype.constructor = $Function;
|
||||
%SetCode($Function, NewFunction);
|
||||
|
||||
InstallFunctions($Function.prototype, DONT_ENUM, $Array(
|
||||
"bind", FunctionBind,
|
||||
"toString", FunctionToString
|
||||
|
Loading…
Reference in New Issue
Block a user