Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(711)

Side by Side Diff: src/v8natives.js

Issue 1400463002: [builtins] Drop useless ToBoolean JavaScript builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/macros.py ('K') | « src/runtime.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ---------------------------------------------------------------------------- 9 // ----------------------------------------------------------------------------
10 // Imports 10 // Imports
11 11
12 var FLAG_harmony_tostring; 12 var FLAG_harmony_tostring;
13 var GlobalArray = global.Array; 13 var GlobalArray = global.Array;
14 var GlobalBoolean = global.Boolean; 14 var GlobalBoolean = global.Boolean;
15 var GlobalFunction = global.Function; 15 var GlobalFunction = global.Function;
16 var GlobalNumber = global.Number; 16 var GlobalNumber = global.Number;
17 var GlobalObject = global.Object; 17 var GlobalObject = global.Object;
18 var InternalArray = utils.InternalArray; 18 var InternalArray = utils.InternalArray;
19 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 19 var iteratorSymbol = utils.ImportNow("iterator_symbol");
20 var MathAbs; 20 var MathAbs;
21 var ProxyDelegateCallAndConstruct; 21 var ProxyDelegateCallAndConstruct;
22 var ProxyDerivedHasOwnTrap; 22 var ProxyDerivedHasOwnTrap;
23 var ProxyDerivedKeysTrap; 23 var ProxyDerivedKeysTrap;
24 var StringIndexOf; 24 var StringIndexOf;
25 var ToBoolean = utils.ImportNow("ToBoolean");
26 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 25 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
27 26
28 utils.Import(function(from) { 27 utils.Import(function(from) {
29 MathAbs = from.MathAbs; 28 MathAbs = from.MathAbs;
30 StringIndexOf = from.StringIndexOf; 29 StringIndexOf = from.StringIndexOf;
31 }); 30 });
32 31
33 utils.ImportFromExperimental(function(from) { 32 utils.ImportFromExperimental(function(from) {
34 FLAG_harmony_tostring = from.FLAG_harmony_tostring; 33 FLAG_harmony_tostring = from.FLAG_harmony_tostring;
35 ProxyDelegateCallAndConstruct = from.ProxyDelegateCallAndConstruct; 34 ProxyDelegateCallAndConstruct = from.ProxyDelegateCallAndConstruct;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 340 }
342 341
343 342
344 // ES5 8.10.5. 343 // ES5 8.10.5.
345 function ToPropertyDescriptor(obj) { 344 function ToPropertyDescriptor(obj) {
346 if (!IS_SPEC_OBJECT(obj)) throw MakeTypeError(kPropertyDescObject, obj); 345 if (!IS_SPEC_OBJECT(obj)) throw MakeTypeError(kPropertyDescObject, obj);
347 346
348 var desc = new PropertyDescriptor(); 347 var desc = new PropertyDescriptor();
349 348
350 if ("enumerable" in obj) { 349 if ("enumerable" in obj) {
351 desc.setEnumerable(ToBoolean(obj.enumerable)); 350 desc.setEnumerable(TO_BOOLEAN(obj.enumerable));
352 } 351 }
353 352
354 if ("configurable" in obj) { 353 if ("configurable" in obj) {
355 desc.setConfigurable(ToBoolean(obj.configurable)); 354 desc.setConfigurable(TO_BOOLEAN(obj.configurable));
356 } 355 }
357 356
358 if ("value" in obj) { 357 if ("value" in obj) {
359 desc.setValue(obj.value); 358 desc.setValue(obj.value);
360 } 359 }
361 360
362 if ("writable" in obj) { 361 if ("writable" in obj) {
363 desc.setWritable(ToBoolean(obj.writable)); 362 desc.setWritable(TO_BOOLEAN(obj.writable));
364 } 363 }
365 364
366 if ("get" in obj) { 365 if ("get" in obj) {
367 var get = obj.get; 366 var get = obj.get;
368 if (!IS_UNDEFINED(get) && !IS_CALLABLE(get)) { 367 if (!IS_UNDEFINED(get) && !IS_CALLABLE(get)) {
369 throw MakeTypeError(kObjectGetterCallable, get); 368 throw MakeTypeError(kObjectGetterCallable, get);
370 } 369 }
371 desc.setGet(get); 370 desc.setGet(get);
372 } 371 }
373 372
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 } 606 }
608 607
609 608
610 // Harmony proxies. 609 // Harmony proxies.
611 function DefineProxyProperty(obj, p, attributes, should_throw) { 610 function DefineProxyProperty(obj, p, attributes, should_throw) {
612 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 611 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
613 if (IS_SYMBOL(p)) return false; 612 if (IS_SYMBOL(p)) return false;
614 613
615 var handler = %GetHandler(obj); 614 var handler = %GetHandler(obj);
616 var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes); 615 var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes);
617 if (!ToBoolean(result)) { 616 if (!result) {
618 if (should_throw) { 617 if (should_throw) {
619 throw MakeTypeError(kProxyHandlerReturned, 618 throw MakeTypeError(kProxyHandlerReturned,
620 handler, "false", "defineProperty"); 619 handler, "false", "defineProperty");
621 } else { 620 } else {
622 return false; 621 return false;
623 } 622 }
624 } 623 }
625 return true; 624 return true;
626 } 625 }
627 626
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 ]); 1364 ]);
1366 1365
1367 1366
1368 // ---------------------------------------------------------------------------- 1367 // ----------------------------------------------------------------------------
1369 // Boolean 1368 // Boolean
1370 1369
1371 function BooleanConstructor(x) { 1370 function BooleanConstructor(x) {
1372 // TODO(bmeurer): Move this to toplevel. 1371 // TODO(bmeurer): Move this to toplevel.
1373 "use strict"; 1372 "use strict";
1374 if (%_IsConstructCall()) { 1373 if (%_IsConstructCall()) {
1375 %_SetValueOf(this, ToBoolean(x)); 1374 %_SetValueOf(this, TO_BOOLEAN(x));
1376 } else { 1375 } else {
1377 return ToBoolean(x); 1376 return TO_BOOLEAN(x);
1378 } 1377 }
1379 } 1378 }
1380 1379
1381 1380
1382 function BooleanToString() { 1381 function BooleanToString() {
1383 // NOTE: Both Boolean objects and values can enter here as 1382 // NOTE: Both Boolean objects and values can enter here as
1384 // 'this'. This is not as dictated by ECMA-262. 1383 // 'this'. This is not as dictated by ECMA-262.
1385 var b = this; 1384 var b = this;
1386 if (!IS_BOOLEAN(b)) { 1385 if (!IS_BOOLEAN(b)) {
1387 if (!IS_BOOLEAN_WRAPPER(b)) { 1386 if (!IS_BOOLEAN_WRAPPER(b)) {
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 %InstallToContext([ 1841 %InstallToContext([
1843 "global_eval_fun", GlobalEval, 1842 "global_eval_fun", GlobalEval,
1844 "object_value_of", ObjectValueOf, 1843 "object_value_of", ObjectValueOf,
1845 "object_to_string", ObjectToString, 1844 "object_to_string", ObjectToString,
1846 "object_define_own_property", DefineOwnPropertyFromAPI, 1845 "object_define_own_property", DefineOwnPropertyFromAPI,
1847 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, 1846 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor,
1848 "to_complete_property_descriptor", ToCompletePropertyDescriptor, 1847 "to_complete_property_descriptor", ToCompletePropertyDescriptor,
1849 ]); 1848 ]);
1850 1849
1851 }) 1850 })
OLDNEW
« src/macros.py ('K') | « src/runtime.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698