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

Side by Side Diff: src/math.js

Issue 6445: This change removes the %AddProperty native JavaScript function from V8.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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 | Annotate | Revision Log
« no previous file with comments | « src/date-delay.js ('k') | src/messages.js » ('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 22 matching lines...) Expand all
33 const $floor = MathFloor; 33 const $floor = MathFloor;
34 const $random = MathRandom; 34 const $random = MathRandom;
35 const $abs = MathAbs; 35 const $abs = MathAbs;
36 36
37 // Instance class name can only be set on functions. That is the only 37 // Instance class name can only be set on functions. That is the only
38 // purpose for MathConstructor. 38 // purpose for MathConstructor.
39 function MathConstructor() {} 39 function MathConstructor() {}
40 %FunctionSetInstanceClassName(MathConstructor, 'Math'); 40 %FunctionSetInstanceClassName(MathConstructor, 'Math');
41 const $Math = new MathConstructor(); 41 const $Math = new MathConstructor();
42 $Math.__proto__ = global.Object.prototype; 42 $Math.__proto__ = global.Object.prototype;
43 %AddProperty(global, "Math", $Math, DONT_ENUM); 43 %SetProperty(global, "Math", $Math, DONT_ENUM);
44 44
45 // ECMA 262 - 15.8.2.1 45 // ECMA 262 - 15.8.2.1
46 function MathAbs(x) { 46 function MathAbs(x) {
47 if (%_IsSmi(x)) { 47 if (%_IsSmi(x)) {
48 return x >= 0 ? x : -x; 48 return x >= 0 ? x : -x;
49 } else { 49 } else {
50 return %Math_abs(ToNumber(x)); 50 return %Math_abs(ToNumber(x));
51 } 51 }
52 } 52 }
53 53
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 // ECMA 262 - 15.8.2.18 120 // ECMA 262 - 15.8.2.18
121 function MathTan(x) { return %Math_tan(ToNumber(x)); } 121 function MathTan(x) { return %Math_tan(ToNumber(x)); }
122 122
123 123
124 // ------------------------------------------------------------------- 124 // -------------------------------------------------------------------
125 125
126 function SetupMath() { 126 function SetupMath() {
127 // Setup math constants. 127 // Setup math constants.
128 // ECMA-262, section 15.8.1.1. 128 // ECMA-262, section 15.8.1.1.
129 %AddProperty($Math, "E", 2.7182818284590452354, DONT_ENUM | DONT_DELETE | REA D_ONLY); 129 %SetProperty($Math,
130 "E",
131 2.7182818284590452354,
132 DONT_ENUM | DONT_DELETE | READ_ONLY);
130 // ECMA-262, section 15.8.1.2. 133 // ECMA-262, section 15.8.1.2.
131 %AddProperty($Math, "LN10", 2.302585092994046, DONT_ENUM | DONT_DELETE | READ _ONLY); 134 %SetProperty($Math,
135 "LN10",
136 2.302585092994046,
137 DONT_ENUM | DONT_DELETE | READ_ONLY);
132 // ECMA-262, section 15.8.1.3. 138 // ECMA-262, section 15.8.1.3.
133 %AddProperty($Math, "LN2", 0.6931471805599453, DONT_ENUM | DONT_DELETE | READ _ONLY); 139 %SetProperty($Math,
140 "LN2",
141 0.6931471805599453,
142 DONT_ENUM | DONT_DELETE | READ_ONLY);
134 // ECMA-262, section 15.8.1.4. 143 // ECMA-262, section 15.8.1.4.
135 %AddProperty($Math, "LOG2E", 1.4426950408889634, DONT_ENUM | DONT_DELETE | RE AD_ONLY); 144 %SetProperty($Math,
136 %AddProperty($Math, "LOG10E", 0.43429448190325176, DONT_ENUM | DONT_DELETE | READ_ONLY); 145 "LOG2E",
137 %AddProperty($Math, "PI", 3.1415926535897932, DONT_ENUM | DONT_DELETE | READ_ ONLY); 146 1.4426950408889634,
138 %AddProperty($Math, "SQRT1_2", 0.7071067811865476, DONT_ENUM | DONT_DELETE | READ_ONLY); 147 DONT_ENUM | DONT_DELETE | READ_ONLY);
139 %AddProperty($Math, "SQRT2", 1.4142135623730951, DONT_ENUM | DONT_DELETE | RE AD_ONLY); 148 %SetProperty($Math,
149 "LOG10E",
150 0.43429448190325176,
151 DONT_ENUM | DONT_DELETE | READ_ONLY);
152 %SetProperty($Math,
153 "PI",
154 3.1415926535897932,
155 DONT_ENUM | DONT_DELETE | READ_ONLY);
156 %SetProperty($Math,
157 "SQRT1_2",
158 0.7071067811865476,
159 DONT_ENUM | DONT_DELETE | READ_ONLY);
160 %SetProperty($Math,
161 "SQRT2",
162 1.4142135623730951,
163 DONT_ENUM | DONT_DELETE | READ_ONLY);
140 164
141 // Setup non-enumerable functions of the Math object and 165 // Setup non-enumerable functions of the Math object and
142 // set their names. 166 // set their names.
143 InstallFunctions($Math, DONT_ENUM, $Array( 167 InstallFunctions($Math, DONT_ENUM, $Array(
144 "random", MathRandom, 168 "random", MathRandom,
145 "abs", MathAbs, 169 "abs", MathAbs,
146 "acos", MathAcos, 170 "acos", MathAcos,
147 "asin", MathAsin, 171 "asin", MathAsin,
148 "atan", MathAtan, 172 "atan", MathAtan,
149 "ceil", MathCeil, 173 "ceil", MathCeil,
150 "cos", MathCos, 174 "cos", MathCos,
151 "exp", MathExp, 175 "exp", MathExp,
152 "floor", MathFloor, 176 "floor", MathFloor,
153 "log", MathLog, 177 "log", MathLog,
154 "round", MathRound, 178 "round", MathRound,
155 "sin", MathSin, 179 "sin", MathSin,
156 "sqrt", MathSqrt, 180 "sqrt", MathSqrt,
157 "tan", MathTan, 181 "tan", MathTan,
158 "atan2", MathAtan2, 182 "atan2", MathAtan2,
159 "pow", MathPow, 183 "pow", MathPow,
160 "max", MathMax, 184 "max", MathMax,
161 "min", MathMin 185 "min", MathMin
162 )); 186 ));
163 }; 187 };
164 188
165 189
166 SetupMath(); 190 SetupMath();
OLDNEW
« no previous file with comments | « src/date-delay.js ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698