OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 %SetNativeFlag(f); | 68 %SetNativeFlag(f); |
69 } | 69 } |
70 %ToFastProperties(object); | 70 %ToFastProperties(object); |
71 } | 71 } |
72 | 72 |
73 // Emulates JSC by installing functions on a hidden prototype that | 73 // Emulates JSC by installing functions on a hidden prototype that |
74 // lies above the current object/prototype. This lets you override | 74 // lies above the current object/prototype. This lets you override |
75 // functions on String.prototype etc. and then restore the old function | 75 // functions on String.prototype etc. and then restore the old function |
76 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717 | 76 // with delete. See http://code.google.com/p/chromium/issues/detail?id=1717 |
77 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { | 77 function InstallFunctionsOnHiddenPrototype(object, attributes, functions) { |
| 78 %CheckIsBootstrapping(); |
78 var hidden_prototype = new $Object(); | 79 var hidden_prototype = new $Object(); |
79 %SetHiddenPrototype(object, hidden_prototype); | 80 %SetHiddenPrototype(object, hidden_prototype); |
80 InstallFunctions(hidden_prototype, attributes, functions); | 81 InstallFunctions(hidden_prototype, attributes, functions); |
81 } | 82 } |
82 | 83 |
83 | 84 |
| 85 // Prevents changes to the prototype of a built-infunction. |
| 86 // The "prototype" property of the function object is made non-configurable, |
| 87 // and the prototype object is made non-extensible. The latter prevents |
| 88 // changing the __proto__ property. |
| 89 function SetUpLockedPrototype(constructor, fields, methods) { |
| 90 %CheckIsBootstrapping(); |
| 91 var prototype = constructor.prototype; |
| 92 // Install functions first, because this function is used to initialize |
| 93 // PropertyDescriptor itself. |
| 94 var property_count = (methods.length >> 1) + (fields ? fields.length : 0); |
| 95 if (property_count >= 4) { |
| 96 %OptimizeObjectForAddingMultipleProperties(prototype, property_count); |
| 97 } |
| 98 if (fields) { |
| 99 for (var i = 0; i < fields.length; i++) { |
| 100 %SetProperty(prototype, fields[i], void 0, DONT_ENUM | DONT_DELETE); |
| 101 } |
| 102 } |
| 103 for (var i = 0; i < methods.length; i += 2) { |
| 104 var key = methods[i]; |
| 105 var f = methods[i + 1]; |
| 106 %SetProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 107 %SetNativeFlag(f); |
| 108 } |
| 109 prototype.__proto__ = null; |
| 110 %PreventExtensions(prototype); |
| 111 %ToFastProperties(prototype); |
| 112 |
| 113 var desc = GetOwnProperty(constructor, "prototype"); |
| 114 desc.setWritable(false); |
| 115 desc.setConfigurable(false); |
| 116 DefineOwnProperty(constructor, "prototype", desc, false); |
| 117 } |
| 118 |
| 119 |
84 // ---------------------------------------------------------------------------- | 120 // ---------------------------------------------------------------------------- |
85 | 121 |
86 | 122 |
87 // ECMA 262 - 15.1.4 | 123 // ECMA 262 - 15.1.4 |
88 function GlobalIsNaN(number) { | 124 function GlobalIsNaN(number) { |
89 var n = ToNumber(number); | 125 var n = ToNumber(number); |
90 return NUMBER_IS_NAN(n); | 126 return NUMBER_IS_NAN(n); |
91 } | 127 } |
92 | 128 |
93 | 129 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 200 |
165 var f = %CompileString(x); | 201 var f = %CompileString(x); |
166 if (!IS_FUNCTION(f)) return f; | 202 if (!IS_FUNCTION(f)) return f; |
167 | 203 |
168 return %_CallFunction(receiver, f); | 204 return %_CallFunction(receiver, f); |
169 } | 205 } |
170 | 206 |
171 | 207 |
172 // ---------------------------------------------------------------------------- | 208 // ---------------------------------------------------------------------------- |
173 | 209 |
174 | 210 // Set up global object. |
175 function SetupGlobal() { | 211 function SetUpGlobal() { |
| 212 %CheckIsBootstrapping(); |
176 // ECMA 262 - 15.1.1.1. | 213 // ECMA 262 - 15.1.1.1. |
177 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); | 214 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); |
178 | 215 |
179 // ECMA-262 - 15.1.1.2. | 216 // ECMA-262 - 15.1.1.2. |
180 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); | 217 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); |
181 | 218 |
182 // ECMA-262 - 15.1.1.3. | 219 // ECMA-262 - 15.1.1.3. |
183 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); | 220 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); |
184 | 221 |
185 // Setup non-enumerable function on the global object. | 222 // Set up non-enumerable function on the global object. |
186 InstallFunctions(global, DONT_ENUM, $Array( | 223 InstallFunctions(global, DONT_ENUM, $Array( |
187 "isNaN", GlobalIsNaN, | 224 "isNaN", GlobalIsNaN, |
188 "isFinite", GlobalIsFinite, | 225 "isFinite", GlobalIsFinite, |
189 "parseInt", GlobalParseInt, | 226 "parseInt", GlobalParseInt, |
190 "parseFloat", GlobalParseFloat, | 227 "parseFloat", GlobalParseFloat, |
191 "eval", GlobalEval | 228 "eval", GlobalEval |
192 )); | 229 )); |
193 } | 230 } |
194 | 231 |
195 SetupGlobal(); | 232 SetUpGlobal(); |
196 | |
197 | 233 |
198 // ---------------------------------------------------------------------------- | 234 // ---------------------------------------------------------------------------- |
199 // Boolean (first part of definition) | 235 // Boolean (first part of definition) |
200 | 236 |
201 | 237 |
202 %SetCode($Boolean, function(x) { | 238 %SetCode($Boolean, function(x) { |
203 if (%_IsConstructCall()) { | 239 if (%_IsConstructCall()) { |
204 %_SetValueOf(this, ToBoolean(x)); | 240 %_SetValueOf(this, ToBoolean(x)); |
205 } else { | 241 } else { |
206 return ToBoolean(x); | 242 return ToBoolean(x); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 this.enumerable_ = false; | 519 this.enumerable_ = false; |
484 this.hasEnumerable_ = false; | 520 this.hasEnumerable_ = false; |
485 this.configurable_ = false; | 521 this.configurable_ = false; |
486 this.hasConfigurable_ = false; | 522 this.hasConfigurable_ = false; |
487 this.get_ = void 0; | 523 this.get_ = void 0; |
488 this.hasGetter_ = false; | 524 this.hasGetter_ = false; |
489 this.set_ = void 0; | 525 this.set_ = void 0; |
490 this.hasSetter_ = false; | 526 this.hasSetter_ = false; |
491 } | 527 } |
492 | 528 |
493 PropertyDescriptor.prototype.__proto__ = null; | 529 SetUpLockedPrototype(PropertyDescriptor, $Array( |
494 | 530 "value_", |
495 PropertyDescriptor.prototype.toString = function() { | 531 "hasValue_", |
496 return "[object PropertyDescriptor]"; | 532 "writable_", |
497 }; | 533 "hasWritable_", |
498 | 534 "enumerable_", |
499 PropertyDescriptor.prototype.setValue = function(value) { | 535 "hasEnumerable_", |
500 this.value_ = value; | 536 "configurable_", |
501 this.hasValue_ = true; | 537 "hasConfigurable_", |
502 } | 538 "get_", |
503 | 539 "hasGetter_", |
504 | 540 "set_", |
505 PropertyDescriptor.prototype.getValue = function() { | 541 "hasSetter_" |
506 return this.value_; | 542 ), $Array( |
507 } | 543 "toString", function() { |
508 | 544 return "[object PropertyDescriptor]"; |
509 | 545 }, |
510 PropertyDescriptor.prototype.hasValue = function() { | 546 "setValue", function(value) { |
511 return this.hasValue_; | 547 this.value_ = value; |
512 } | 548 this.hasValue_ = true; |
513 | 549 }, |
514 | 550 "getValue", function() { |
515 PropertyDescriptor.prototype.setEnumerable = function(enumerable) { | 551 return this.value_; |
516 this.enumerable_ = enumerable; | 552 }, |
517 this.hasEnumerable_ = true; | 553 "hasValue", function() { |
518 } | 554 return this.hasValue_; |
519 | 555 }, |
520 | 556 "setEnumerable", function(enumerable) { |
521 PropertyDescriptor.prototype.isEnumerable = function () { | 557 this.enumerable_ = enumerable; |
522 return this.enumerable_; | 558 this.hasEnumerable_ = true; |
523 } | 559 }, |
524 | 560 "isEnumerable", function () { |
525 | 561 return this.enumerable_; |
526 PropertyDescriptor.prototype.hasEnumerable = function() { | 562 }, |
527 return this.hasEnumerable_; | 563 "hasEnumerable", function() { |
528 } | 564 return this.hasEnumerable_; |
529 | 565 }, |
530 | 566 "setWritable", function(writable) { |
531 PropertyDescriptor.prototype.setWritable = function(writable) { | 567 this.writable_ = writable; |
532 this.writable_ = writable; | 568 this.hasWritable_ = true; |
533 this.hasWritable_ = true; | 569 }, |
534 } | 570 "isWritable", function() { |
535 | 571 return this.writable_; |
536 | 572 }, |
537 PropertyDescriptor.prototype.isWritable = function() { | 573 "hasWritable", function() { |
538 return this.writable_; | 574 return this.hasWritable_; |
539 } | 575 }, |
540 | 576 "setConfigurable", function(configurable) { |
541 | 577 this.configurable_ = configurable; |
542 PropertyDescriptor.prototype.hasWritable = function() { | 578 this.hasConfigurable_ = true; |
543 return this.hasWritable_; | 579 }, |
544 } | 580 "hasConfigurable", function() { |
545 | 581 return this.hasConfigurable_; |
546 | 582 }, |
547 PropertyDescriptor.prototype.setConfigurable = function(configurable) { | 583 "isConfigurable", function() { |
548 this.configurable_ = configurable; | 584 return this.configurable_; |
549 this.hasConfigurable_ = true; | 585 }, |
550 } | 586 "setGet", function(get) { |
551 | 587 this.get_ = get; |
552 | 588 this.hasGetter_ = true; |
553 PropertyDescriptor.prototype.hasConfigurable = function() { | 589 }, |
554 return this.hasConfigurable_; | 590 "getGet", function() { |
555 } | 591 return this.get_; |
556 | 592 }, |
557 | 593 "hasGetter", function() { |
558 PropertyDescriptor.prototype.isConfigurable = function() { | 594 return this.hasGetter_; |
559 return this.configurable_; | 595 }, |
560 } | 596 "setSet", function(set) { |
561 | 597 this.set_ = set; |
562 | 598 this.hasSetter_ = true; |
563 PropertyDescriptor.prototype.setGet = function(get) { | 599 }, |
564 this.get_ = get; | 600 "getSet", function() { |
565 this.hasGetter_ = true; | 601 return this.set_; |
566 } | 602 }, |
567 | 603 "hasSetter", function() { |
568 | 604 return this.hasSetter_; |
569 PropertyDescriptor.prototype.getGet = function() { | 605 })); |
570 return this.get_; | |
571 } | |
572 | |
573 | |
574 PropertyDescriptor.prototype.hasGetter = function() { | |
575 return this.hasGetter_; | |
576 } | |
577 | |
578 | |
579 PropertyDescriptor.prototype.setSet = function(set) { | |
580 this.set_ = set; | |
581 this.hasSetter_ = true; | |
582 } | |
583 | |
584 | |
585 PropertyDescriptor.prototype.getSet = function() { | |
586 return this.set_; | |
587 } | |
588 | |
589 | |
590 PropertyDescriptor.prototype.hasSetter = function() { | |
591 return this.hasSetter_; | |
592 } | |
593 | 606 |
594 | 607 |
595 // Converts an array returned from Runtime_GetOwnProperty to an actual | 608 // Converts an array returned from Runtime_GetOwnProperty to an actual |
596 // property descriptor. For a description of the array layout please | 609 // property descriptor. For a description of the array layout please |
597 // see the runtime.cc file. | 610 // see the runtime.cc file. |
598 function ConvertDescriptorArrayToDescriptor(desc_array) { | 611 function ConvertDescriptorArrayToDescriptor(desc_array) { |
599 if (desc_array === false) { | 612 if (desc_array === false) { |
600 throw 'Internal error: invalid desc_array'; | 613 throw 'Internal error: invalid desc_array'; |
601 } | 614 } |
602 | 615 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 return ToObject(x); | 1183 return ToObject(x); |
1171 } else { | 1184 } else { |
1172 if (x == null) return { }; | 1185 if (x == null) return { }; |
1173 return ToObject(x); | 1186 return ToObject(x); |
1174 } | 1187 } |
1175 }); | 1188 }); |
1176 | 1189 |
1177 %SetExpectedNumberOfProperties($Object, 4); | 1190 %SetExpectedNumberOfProperties($Object, 4); |
1178 | 1191 |
1179 // ---------------------------------------------------------------------------- | 1192 // ---------------------------------------------------------------------------- |
| 1193 // Object |
1180 | 1194 |
1181 | 1195 function SetUpObject() { |
1182 function SetupObject() { | 1196 %CheckIsBootstrapping(); |
1183 // Setup non-enumerable functions on the Object.prototype object. | 1197 // Set Up non-enumerable functions on the Object.prototype object. |
1184 InstallFunctions($Object.prototype, DONT_ENUM, $Array( | 1198 InstallFunctions($Object.prototype, DONT_ENUM, $Array( |
1185 "toString", ObjectToString, | 1199 "toString", ObjectToString, |
1186 "toLocaleString", ObjectToLocaleString, | 1200 "toLocaleString", ObjectToLocaleString, |
1187 "valueOf", ObjectValueOf, | 1201 "valueOf", ObjectValueOf, |
1188 "hasOwnProperty", ObjectHasOwnProperty, | 1202 "hasOwnProperty", ObjectHasOwnProperty, |
1189 "isPrototypeOf", ObjectIsPrototypeOf, | 1203 "isPrototypeOf", ObjectIsPrototypeOf, |
1190 "propertyIsEnumerable", ObjectPropertyIsEnumerable, | 1204 "propertyIsEnumerable", ObjectPropertyIsEnumerable, |
1191 "__defineGetter__", ObjectDefineGetter, | 1205 "__defineGetter__", ObjectDefineGetter, |
1192 "__lookupGetter__", ObjectLookupGetter, | 1206 "__lookupGetter__", ObjectLookupGetter, |
1193 "__defineSetter__", ObjectDefineSetter, | 1207 "__defineSetter__", ObjectDefineSetter, |
1194 "__lookupSetter__", ObjectLookupSetter | 1208 "__lookupSetter__", ObjectLookupSetter |
1195 )); | 1209 )); |
1196 InstallFunctions($Object, DONT_ENUM, $Array( | 1210 InstallFunctions($Object, DONT_ENUM, $Array( |
1197 "keys", ObjectKeys, | 1211 "keys", ObjectKeys, |
1198 "create", ObjectCreate, | 1212 "create", ObjectCreate, |
1199 "defineProperty", ObjectDefineProperty, | 1213 "defineProperty", ObjectDefineProperty, |
1200 "defineProperties", ObjectDefineProperties, | 1214 "defineProperties", ObjectDefineProperties, |
1201 "freeze", ObjectFreeze, | 1215 "freeze", ObjectFreeze, |
1202 "getPrototypeOf", ObjectGetPrototypeOf, | 1216 "getPrototypeOf", ObjectGetPrototypeOf, |
1203 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, | 1217 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
1204 "getOwnPropertyNames", ObjectGetOwnPropertyNames, | 1218 "getOwnPropertyNames", ObjectGetOwnPropertyNames, |
1205 "isExtensible", ObjectIsExtensible, | 1219 "isExtensible", ObjectIsExtensible, |
1206 "isFrozen", ObjectIsFrozen, | 1220 "isFrozen", ObjectIsFrozen, |
1207 "isSealed", ObjectIsSealed, | 1221 "isSealed", ObjectIsSealed, |
1208 "preventExtensions", ObjectPreventExtension, | 1222 "preventExtensions", ObjectPreventExtension, |
1209 "seal", ObjectSeal | 1223 "seal", ObjectSeal |
1210 )); | 1224 )); |
1211 } | 1225 } |
1212 | 1226 |
1213 SetupObject(); | 1227 SetUpObject(); |
1214 | |
1215 | 1228 |
1216 // ---------------------------------------------------------------------------- | 1229 // ---------------------------------------------------------------------------- |
1217 // Boolean | 1230 // Boolean |
1218 | 1231 |
1219 function BooleanToString() { | 1232 function BooleanToString() { |
1220 // NOTE: Both Boolean objects and values can enter here as | 1233 // NOTE: Both Boolean objects and values can enter here as |
1221 // 'this'. This is not as dictated by ECMA-262. | 1234 // 'this'. This is not as dictated by ECMA-262. |
1222 var b = this; | 1235 var b = this; |
1223 if (!IS_BOOLEAN(b)) { | 1236 if (!IS_BOOLEAN(b)) { |
1224 if (!IS_BOOLEAN_WRAPPER(b)) { | 1237 if (!IS_BOOLEAN_WRAPPER(b)) { |
(...skipping 10 matching lines...) Expand all Loading... |
1235 // 'this'. This is not as dictated by ECMA-262. | 1248 // 'this'. This is not as dictated by ECMA-262. |
1236 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) | 1249 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) |
1237 throw new $TypeError('Boolean.prototype.valueOf is not generic'); | 1250 throw new $TypeError('Boolean.prototype.valueOf is not generic'); |
1238 return %_ValueOf(this); | 1251 return %_ValueOf(this); |
1239 } | 1252 } |
1240 | 1253 |
1241 | 1254 |
1242 // ---------------------------------------------------------------------------- | 1255 // ---------------------------------------------------------------------------- |
1243 | 1256 |
1244 | 1257 |
1245 function SetupBoolean() { | 1258 function SetUpBoolean () { |
| 1259 %CheckIsBootstrapping(); |
1246 InstallFunctions($Boolean.prototype, DONT_ENUM, $Array( | 1260 InstallFunctions($Boolean.prototype, DONT_ENUM, $Array( |
1247 "toString", BooleanToString, | 1261 "toString", BooleanToString, |
1248 "valueOf", BooleanValueOf | 1262 "valueOf", BooleanValueOf |
1249 )); | 1263 )); |
1250 } | 1264 } |
1251 | 1265 |
1252 SetupBoolean(); | 1266 SetUpBoolean(); |
| 1267 |
1253 | 1268 |
1254 // ---------------------------------------------------------------------------- | 1269 // ---------------------------------------------------------------------------- |
1255 // Number | 1270 // Number |
1256 | 1271 |
1257 // Set the Number function and constructor. | 1272 // Set the Number function and constructor. |
1258 %SetCode($Number, function(x) { | 1273 %SetCode($Number, function(x) { |
1259 var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x); | 1274 var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x); |
1260 if (%_IsConstructCall()) { | 1275 if (%_IsConstructCall()) { |
1261 %_SetValueOf(this, value); | 1276 %_SetValueOf(this, value); |
1262 } else { | 1277 } else { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 if (p < 1 || p > 21) { | 1371 if (p < 1 || p > 21) { |
1357 throw new $RangeError("toPrecision() argument must be between 1 and 21"); | 1372 throw new $RangeError("toPrecision() argument must be between 1 and 21"); |
1358 } | 1373 } |
1359 var x = ToNumber(this); | 1374 var x = ToNumber(this); |
1360 return %NumberToPrecision(x, p); | 1375 return %NumberToPrecision(x, p); |
1361 } | 1376 } |
1362 | 1377 |
1363 | 1378 |
1364 // ---------------------------------------------------------------------------- | 1379 // ---------------------------------------------------------------------------- |
1365 | 1380 |
1366 function SetupNumber() { | 1381 function SetUpNumber() { |
| 1382 %CheckIsBootstrapping(); |
1367 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); | 1383 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); |
1368 // Setup the constructor property on the Number prototype object. | 1384 // Set up the constructor property on the Number prototype object. |
1369 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); | 1385 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); |
1370 | 1386 |
1371 %OptimizeObjectForAddingMultipleProperties($Number, 5); | 1387 %OptimizeObjectForAddingMultipleProperties($Number, 5); |
1372 // ECMA-262 section 15.7.3.1. | 1388 // ECMA-262 section 15.7.3.1. |
1373 %SetProperty($Number, | 1389 %SetProperty($Number, |
1374 "MAX_VALUE", | 1390 "MAX_VALUE", |
1375 1.7976931348623157e+308, | 1391 1.7976931348623157e+308, |
1376 DONT_ENUM | DONT_DELETE | READ_ONLY); | 1392 DONT_ENUM | DONT_DELETE | READ_ONLY); |
1377 | 1393 |
1378 // ECMA-262 section 15.7.3.2. | 1394 // ECMA-262 section 15.7.3.2. |
1379 %SetProperty($Number, "MIN_VALUE", 5e-324, DONT_ENUM | DONT_DELETE | READ_ONLY
); | 1395 %SetProperty($Number, "MIN_VALUE", 5e-324, DONT_ENUM | DONT_DELETE | READ_ONLY
); |
1380 | 1396 |
1381 // ECMA-262 section 15.7.3.3. | 1397 // ECMA-262 section 15.7.3.3. |
1382 %SetProperty($Number, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); | 1398 %SetProperty($Number, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); |
1383 | 1399 |
1384 // ECMA-262 section 15.7.3.4. | 1400 // ECMA-262 section 15.7.3.4. |
1385 %SetProperty($Number, | 1401 %SetProperty($Number, |
1386 "NEGATIVE_INFINITY", | 1402 "NEGATIVE_INFINITY", |
1387 -1/0, | 1403 -1/0, |
1388 DONT_ENUM | DONT_DELETE | READ_ONLY); | 1404 DONT_ENUM | DONT_DELETE | READ_ONLY); |
1389 | 1405 |
1390 // ECMA-262 section 15.7.3.5. | 1406 // ECMA-262 section 15.7.3.5. |
1391 %SetProperty($Number, | 1407 %SetProperty($Number, |
1392 "POSITIVE_INFINITY", | 1408 "POSITIVE_INFINITY", |
1393 1/0, | 1409 1/0, |
1394 DONT_ENUM | DONT_DELETE | READ_ONLY); | 1410 DONT_ENUM | DONT_DELETE | READ_ONLY); |
1395 %ToFastProperties($Number); | 1411 %ToFastProperties($Number); |
1396 | 1412 |
1397 // Setup non-enumerable functions on the Number prototype object. | 1413 // Set up non-enumerable functions on the Number prototype object. |
1398 InstallFunctions($Number.prototype, DONT_ENUM, $Array( | 1414 InstallFunctions($Number.prototype, DONT_ENUM, $Array( |
1399 "toString", NumberToString, | 1415 "toString", NumberToString, |
1400 "toLocaleString", NumberToLocaleString, | 1416 "toLocaleString", NumberToLocaleString, |
1401 "valueOf", NumberValueOf, | 1417 "valueOf", NumberValueOf, |
1402 "toFixed", NumberToFixed, | 1418 "toFixed", NumberToFixed, |
1403 "toExponential", NumberToExponential, | 1419 "toExponential", NumberToExponential, |
1404 "toPrecision", NumberToPrecision | 1420 "toPrecision", NumberToPrecision |
1405 )); | 1421 )); |
1406 } | 1422 } |
1407 | 1423 |
1408 SetupNumber(); | 1424 SetUpNumber(); |
1409 | 1425 |
1410 | 1426 |
1411 // ---------------------------------------------------------------------------- | 1427 // ---------------------------------------------------------------------------- |
1412 // Function | 1428 // Function |
1413 | 1429 |
1414 $Function.prototype.constructor = $Function; | 1430 $Function.prototype.constructor = $Function; |
1415 | 1431 |
1416 function FunctionSourceString(func) { | 1432 function FunctionSourceString(func) { |
1417 if (!IS_FUNCTION(func)) { | 1433 if (!IS_FUNCTION(func)) { |
1418 throw new $TypeError('Function.prototype.toString is not generic'); | 1434 throw new $TypeError('Function.prototype.toString is not generic'); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). | 1543 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). |
1528 var f = %CompileString(source)(); | 1544 var f = %CompileString(source)(); |
1529 %FunctionMarkNameShouldPrintAsAnonymous(f); | 1545 %FunctionMarkNameShouldPrintAsAnonymous(f); |
1530 return %SetNewFunctionAttributes(f); | 1546 return %SetNewFunctionAttributes(f); |
1531 } | 1547 } |
1532 | 1548 |
1533 %SetCode($Function, NewFunction); | 1549 %SetCode($Function, NewFunction); |
1534 | 1550 |
1535 // ---------------------------------------------------------------------------- | 1551 // ---------------------------------------------------------------------------- |
1536 | 1552 |
1537 function SetupFunction() { | 1553 function SetUpFunction() { |
| 1554 %CheckIsBootstrapping(); |
1538 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1555 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1539 "bind", FunctionBind, | 1556 "bind", FunctionBind, |
1540 "toString", FunctionToString | 1557 "toString", FunctionToString |
1541 )); | 1558 )); |
1542 } | 1559 } |
1543 | 1560 |
1544 SetupFunction(); | 1561 SetUpFunction(); |
OLD | NEW |