OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. | 5 // This files contains runtime support implemented in JavaScript. |
6 | 6 |
7 // CAUTION: Some of the functions specified in this file are called | 7 // CAUTION: Some of the functions specified in this file are called |
8 // directly from compiled code. These are the functions with names in | 8 // directly from compiled code. These are the functions with names in |
9 // ALL CAPS. The compiled code passes the first argument in 'this'. | 9 // ALL CAPS. The compiled code passes the first argument in 'this'. |
10 | 10 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 192 |
193 | 193 |
194 // ECMA-262, section 11.6.2, page 50. | 194 // ECMA-262, section 11.6.2, page 50. |
195 function SUB(y) { | 195 function SUB(y) { |
196 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); | 196 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
197 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); | 197 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
198 return %NumberSub(x, y); | 198 return %NumberSub(x, y); |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 //ECMA-262, section 11.6.2, page 50. | |
rossberg
2015/04/23 13:29:37
Nit: spacing (here and below)
conradw
2015/04/23 14:51:54
Done. It looks like this is a "feature" of Eclipse
| |
203 function SUB_STRONG(y) { | |
204 if (IS_NUMBER(this) && IS_NUMBER(y)) { | |
205 return %NumberSub(this, y); | |
206 } | |
207 throw %MakeTypeError('strong_implicit_cast'); | |
208 } | |
209 | |
210 | |
202 // ECMA-262, section 11.5.1, page 48. | 211 // ECMA-262, section 11.5.1, page 48. |
203 function MUL(y) { | 212 function MUL(y) { |
204 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); | 213 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
205 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); | 214 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
206 return %NumberMul(x, y); | 215 return %NumberMul(x, y); |
207 } | 216 } |
208 | 217 |
209 | 218 |
219 //ECMA-262, section 11.5.1, page 48. | |
220 function MUL_STRONG(y) { | |
221 if (IS_NUMBER(this) && IS_NUMBER(y)) { | |
222 return %NumberMul(this, y); | |
223 } | |
224 throw %MakeTypeError('strong_implicit_cast'); | |
225 } | |
226 | |
227 | |
210 // ECMA-262, section 11.5.2, page 49. | 228 // ECMA-262, section 11.5.2, page 49. |
211 function DIV(y) { | 229 function DIV(y) { |
212 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); | 230 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
213 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); | 231 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
214 return %NumberDiv(x, y); | 232 return %NumberDiv(x, y); |
215 } | 233 } |
216 | 234 |
217 | 235 |
236 //ECMA-262, section 11.5.2, page 49. | |
237 function DIV_STRONG(y) { | |
238 if (IS_NUMBER(this) && IS_NUMBER(y)) { | |
239 return %NumberDiv(this, y); | |
240 } | |
241 throw %MakeTypeError('strong_implicit_cast'); | |
242 } | |
243 | |
244 | |
218 // ECMA-262, section 11.5.3, page 49. | 245 // ECMA-262, section 11.5.3, page 49. |
219 function MOD(y) { | 246 function MOD(y) { |
220 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); | 247 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
221 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); | 248 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
222 return %NumberMod(x, y); | 249 return %NumberMod(x, y); |
223 } | 250 } |
224 | 251 |
225 | 252 |
253 //ECMA-262, section 11.5.3, page 49. | |
254 function MOD_STRONG(y) { | |
255 if (IS_NUMBER(this) && IS_NUMBER(y)) { | |
256 return %NumberMod(this, y); | |
257 } | |
258 throw %MakeTypeError('strong_implicit_cast'); | |
259 } | |
260 | |
226 | 261 |
227 /* ------------------------------------------- | 262 /* ------------------------------------------- |
228 - - - B i t o p e r a t i o n s - - - | 263 - - - B i t o p e r a t i o n s - - - |
229 ------------------------------------------- | 264 ------------------------------------------- |
230 */ | 265 */ |
231 | 266 |
232 // ECMA-262, section 11.10, page 57. | 267 // ECMA-262, section 11.10, page 57. |
233 function BIT_OR(y) { | 268 function BIT_OR(y) { |
234 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); | 269 var x = IS_NUMBER(this) ? this : %NonNumberToNumber(this); |
235 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); | 270 if (!IS_NUMBER(y)) y = %NonNumberToNumber(y); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 | 813 |
779 /* ----------------------------------------------- | 814 /* ----------------------------------------------- |
780 - - - J a v a S c r i p t S t u b s - - - | 815 - - - J a v a S c r i p t S t u b s - - - |
781 ----------------------------------------------- | 816 ----------------------------------------------- |
782 */ | 817 */ |
783 | 818 |
784 function STRING_LENGTH_STUB(name) { | 819 function STRING_LENGTH_STUB(name) { |
785 var receiver = this; // implicit first parameter | 820 var receiver = this; // implicit first parameter |
786 return %_StringGetLength(%_JSValueGetValue(receiver)); | 821 return %_StringGetLength(%_JSValueGetValue(receiver)); |
787 } | 822 } |
OLD | NEW |