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

Side by Side Diff: src/v8natives.js

Issue 6580038: [Isolates] Merge from bleeding_edge, revisions 5934-6100. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/v8-counters.h ('k') | src/v8preparserdll-main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 (!desc.hasValue() || 556 (!desc.hasValue() ||
557 SameValue(desc.getValue(), current.getValue())) && 557 SameValue(desc.getValue(), current.getValue())) &&
558 (!desc.hasGetter() || 558 (!desc.hasGetter() ||
559 SameValue(desc.getGet(), current.getGet())) && 559 SameValue(desc.getGet(), current.getGet())) &&
560 (!desc.hasSetter() || 560 (!desc.hasSetter() ||
561 SameValue(desc.getSet(), current.getSet()))) { 561 SameValue(desc.getSet(), current.getSet()))) {
562 return true; 562 return true;
563 } 563 }
564 564
565 // Step 7 565 // Step 7
566 if (desc.isConfigurable() || desc.isEnumerable() != current.isEnumerable()) 566 if (desc.isConfigurable() || desc.isEnumerable() != current.isEnumerable())
567 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 567 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
568 // Step 9 568 // Step 9
569 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) 569 if (IsDataDescriptor(current) != IsDataDescriptor(desc))
570 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 570 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
571 // Step 10 571 // Step 10
572 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { 572 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
573 if (!current.isWritable() && desc.isWritable()) 573 if (!current.isWritable() && desc.isWritable())
574 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 574 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
575 if (!current.isWritable() && desc.hasValue() && 575 if (!current.isWritable() && desc.hasValue() &&
576 !SameValue(desc.getValue(), current.getValue())) { 576 !SameValue(desc.getValue(), current.getValue())) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 flag |= DONT_DELETE; 608 flag |= DONT_DELETE;
609 609
610 if (IsDataDescriptor(desc) || IsGenericDescriptor(desc)) { 610 if (IsDataDescriptor(desc) || IsGenericDescriptor(desc)) {
611 if (desc.hasWritable()) { 611 if (desc.hasWritable()) {
612 flag |= desc.isWritable() ? 0 : READ_ONLY; 612 flag |= desc.isWritable() ? 0 : READ_ONLY;
613 } else if (!IS_UNDEFINED(current)) { 613 } else if (!IS_UNDEFINED(current)) {
614 flag |= current.isWritable() ? 0 : READ_ONLY; 614 flag |= current.isWritable() ? 0 : READ_ONLY;
615 } else { 615 } else {
616 flag |= READ_ONLY; 616 flag |= READ_ONLY;
617 } 617 }
618 %DefineOrRedefineDataProperty(obj, p, desc.getValue(), flag); 618 var value = void 0; // Default value is undefined.
619 if (desc.hasValue()) {
620 value = desc.getValue();
621 } else if (!IS_UNDEFINED(current)) {
622 value = current.getValue();
623 }
624 %DefineOrRedefineDataProperty(obj, p, value, flag);
619 } else { 625 } else {
620 if (desc.hasGetter() && IS_FUNCTION(desc.getGet())) { 626 if (desc.hasGetter() &&
627 (IS_FUNCTION(desc.getGet()) || IS_UNDEFINED(desc.getGet()))) {
621 %DefineOrRedefineAccessorProperty(obj, p, GETTER, desc.getGet(), flag); 628 %DefineOrRedefineAccessorProperty(obj, p, GETTER, desc.getGet(), flag);
622 } 629 }
623 if (desc.hasSetter() && IS_FUNCTION(desc.getSet())) { 630 if (desc.hasSetter() &&
631 (IS_FUNCTION(desc.getSet()) || IS_UNDEFINED(desc.getSet()))) {
624 %DefineOrRedefineAccessorProperty(obj, p, SETTER, desc.getSet(), flag); 632 %DefineOrRedefineAccessorProperty(obj, p, SETTER, desc.getSet(), flag);
625 } 633 }
626 } 634 }
627 return true; 635 return true;
628 } 636 }
629 637
630 638
631 // ES5 section 15.2.3.2. 639 // ES5 section 15.2.3.2.
632 function ObjectGetPrototypeOf(obj) { 640 function ObjectGetPrototypeOf(obj) {
633 if (!IS_SPEC_OBJECT(obj)) 641 if (!IS_SPEC_OBJECT(obj))
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 904
897 function BooleanValueOf() { 905 function BooleanValueOf() {
898 // NOTE: Both Boolean objects and values can enter here as 906 // NOTE: Both Boolean objects and values can enter here as
899 // 'this'. This is not as dictated by ECMA-262. 907 // 'this'. This is not as dictated by ECMA-262.
900 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) 908 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this))
901 throw new $TypeError('Boolean.prototype.valueOf is not generic'); 909 throw new $TypeError('Boolean.prototype.valueOf is not generic');
902 return %_ValueOf(this); 910 return %_ValueOf(this);
903 } 911 }
904 912
905 913
906 function BooleanToJSON(key) {
907 return CheckJSONPrimitive(this.valueOf());
908 }
909
910
911 // ---------------------------------------------------------------------------- 914 // ----------------------------------------------------------------------------
912 915
913 916
914 function SetupBoolean() { 917 function SetupBoolean() {
915 InstallFunctions($Boolean.prototype, DONT_ENUM, $Array( 918 InstallFunctions($Boolean.prototype, DONT_ENUM, $Array(
916 "toString", BooleanToString, 919 "toString", BooleanToString,
917 "valueOf", BooleanValueOf, 920 "valueOf", BooleanValueOf
918 "toJSON", BooleanToJSON
919 )); 921 ));
920 } 922 }
921 923
922 SetupBoolean(); 924 SetupBoolean();
923 925
924 // ---------------------------------------------------------------------------- 926 // ----------------------------------------------------------------------------
925 // Number 927 // Number
926 928
927 // Set the Number function and constructor. 929 // Set the Number function and constructor.
928 %SetCode($Number, function(x) { 930 %SetCode($Number, function(x) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this)); 1010 if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this));
1009 var p = TO_INTEGER(precision); 1011 var p = TO_INTEGER(precision);
1010 if (p < 1 || p > 21) { 1012 if (p < 1 || p > 21) {
1011 throw new $RangeError("toPrecision() argument must be between 1 and 21"); 1013 throw new $RangeError("toPrecision() argument must be between 1 and 21");
1012 } 1014 }
1013 var x = ToNumber(this); 1015 var x = ToNumber(this);
1014 return %NumberToPrecision(x, p); 1016 return %NumberToPrecision(x, p);
1015 } 1017 }
1016 1018
1017 1019
1018 function CheckJSONPrimitive(val) {
1019 if (!IsPrimitive(val))
1020 throw MakeTypeError('result_not_primitive', ['toJSON', val]);
1021 return val;
1022 }
1023
1024
1025 function NumberToJSON(key) {
1026 return CheckJSONPrimitive(this.valueOf());
1027 }
1028
1029
1030 // ---------------------------------------------------------------------------- 1020 // ----------------------------------------------------------------------------
1031 1021
1032 function SetupNumber() { 1022 function SetupNumber() {
1033 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); 1023 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8);
1034 // Setup the constructor property on the Number prototype object. 1024 // Setup the constructor property on the Number prototype object.
1035 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); 1025 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
1036 1026
1037 %OptimizeObjectForAddingMultipleProperties($Number, 5); 1027 %OptimizeObjectForAddingMultipleProperties($Number, 5);
1038 // ECMA-262 section 15.7.3.1. 1028 // ECMA-262 section 15.7.3.1.
1039 %SetProperty($Number, 1029 %SetProperty($Number,
(...skipping 20 matching lines...) Expand all
1060 DONT_ENUM | DONT_DELETE | READ_ONLY); 1050 DONT_ENUM | DONT_DELETE | READ_ONLY);
1061 %ToFastProperties($Number); 1051 %ToFastProperties($Number);
1062 1052
1063 // Setup non-enumerable functions on the Number prototype object. 1053 // Setup non-enumerable functions on the Number prototype object.
1064 InstallFunctions($Number.prototype, DONT_ENUM, $Array( 1054 InstallFunctions($Number.prototype, DONT_ENUM, $Array(
1065 "toString", NumberToString, 1055 "toString", NumberToString,
1066 "toLocaleString", NumberToLocaleString, 1056 "toLocaleString", NumberToLocaleString,
1067 "valueOf", NumberValueOf, 1057 "valueOf", NumberValueOf,
1068 "toFixed", NumberToFixed, 1058 "toFixed", NumberToFixed,
1069 "toExponential", NumberToExponential, 1059 "toExponential", NumberToExponential,
1070 "toPrecision", NumberToPrecision, 1060 "toPrecision", NumberToPrecision
1071 "toJSON", NumberToJSON
1072 )); 1061 ));
1073 } 1062 }
1074 1063
1075 SetupNumber(); 1064 SetupNumber();
1076 1065
1077 1066
1078
1079 // ---------------------------------------------------------------------------- 1067 // ----------------------------------------------------------------------------
1080 // Function 1068 // Function
1081 1069
1082 $Function.prototype.constructor = $Function; 1070 $Function.prototype.constructor = $Function;
1083 1071
1084 function FunctionSourceString(func) { 1072 function FunctionSourceString(func) {
1085 if (!IS_FUNCTION(func)) { 1073 if (!IS_FUNCTION(func)) {
1086 throw new $TypeError('Function.prototype.toString is not generic'); 1074 throw new $TypeError('Function.prototype.toString is not generic');
1087 } 1075 }
1088 1076
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 // ---------------------------------------------------------------------------- 1175 // ----------------------------------------------------------------------------
1188 1176
1189 function SetupFunction() { 1177 function SetupFunction() {
1190 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1178 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1191 "bind", FunctionBind, 1179 "bind", FunctionBind,
1192 "toString", FunctionToString 1180 "toString", FunctionToString
1193 )); 1181 ));
1194 } 1182 }
1195 1183
1196 SetupFunction(); 1184 SetupFunction();
OLDNEW
« no previous file with comments | « src/v8-counters.h ('k') | src/v8preparserdll-main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698