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

Side by Side Diff: src/runtime.js

Issue 1126043004: Migrate error messages, part 10. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed and rebased Created 5 years, 7 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
« no previous file with comments | « src/objects.cc ('k') | src/runtime/runtime-classes.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 // 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return %NumberAdd(%$toNumber(a), %$toNumber(b)); 229 return %NumberAdd(%$toNumber(a), %$toNumber(b));
230 } 230 }
231 } 231 }
232 232
233 233
234 // Strong mode ADD throws if an implicit conversion would be performed 234 // Strong mode ADD throws if an implicit conversion would be performed
235 ADD_STRONG = function ADD_STRONG(x) { 235 ADD_STRONG = function ADD_STRONG(x) {
236 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x); 236 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberAdd(this, x);
237 if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x); 237 if (IS_STRING(this) && IS_STRING(x)) return %_StringAdd(this, x);
238 238
239 throw %MakeTypeError('strong_implicit_cast'); 239 throw %MakeTypeError(kStrongImplicitCast);
240 } 240 }
241 241
242 242
243 // Left operand (this) is already a string. 243 // Left operand (this) is already a string.
244 STRING_ADD_LEFT = function STRING_ADD_LEFT(y) { 244 STRING_ADD_LEFT = function STRING_ADD_LEFT(y) {
245 if (!IS_STRING(y)) { 245 if (!IS_STRING(y)) {
246 if (IS_STRING_WRAPPER(y) && %_IsStringWrapperSafeForDefaultValueOf(y)) { 246 if (IS_STRING_WRAPPER(y) && %_IsStringWrapperSafeForDefaultValueOf(y)) {
247 y = %_ValueOf(y); 247 y = %_ValueOf(y);
248 } else { 248 } else {
249 y = IS_NUMBER(y) 249 y = IS_NUMBER(y)
250 ? %_NumberToString(y) 250 ? %_NumberToString(y)
251 : %$toString(%$toPrimitive(y, NO_HINT)); 251 : %$toString(%$toPrimitive(y, NO_HINT));
252 } 252 }
253 } 253 }
254 return %_StringAdd(this, y); 254 return %_StringAdd(this, y);
255 } 255 }
256 256
257 257
258 // Left operand (this) is already a string. 258 // Left operand (this) is already a string.
259 STRING_ADD_LEFT_STRONG = function STRING_ADD_LEFT_STRONG(y) { 259 STRING_ADD_LEFT_STRONG = function STRING_ADD_LEFT_STRONG(y) {
260 if (IS_STRING(y)) { 260 if (IS_STRING(y)) {
261 return %_StringAdd(this, y); 261 return %_StringAdd(this, y);
262 } 262 }
263 throw %MakeTypeError('strong_implicit_cast'); 263 throw %MakeTypeError(kStrongImplicitCast);
264 } 264 }
265 265
266 266
267 // Right operand (y) is already a string. 267 // Right operand (y) is already a string.
268 STRING_ADD_RIGHT = function STRING_ADD_RIGHT(y) { 268 STRING_ADD_RIGHT = function STRING_ADD_RIGHT(y) {
269 var x = this; 269 var x = this;
270 if (!IS_STRING(x)) { 270 if (!IS_STRING(x)) {
271 if (IS_STRING_WRAPPER(x) && %_IsStringWrapperSafeForDefaultValueOf(x)) { 271 if (IS_STRING_WRAPPER(x) && %_IsStringWrapperSafeForDefaultValueOf(x)) {
272 x = %_ValueOf(x); 272 x = %_ValueOf(x);
273 } else { 273 } else {
274 x = IS_NUMBER(x) 274 x = IS_NUMBER(x)
275 ? %_NumberToString(x) 275 ? %_NumberToString(x)
276 : %$toString(%$toPrimitive(x, NO_HINT)); 276 : %$toString(%$toPrimitive(x, NO_HINT));
277 } 277 }
278 } 278 }
279 return %_StringAdd(x, y); 279 return %_StringAdd(x, y);
280 } 280 }
281 281
282 282
283 // Right operand (y) is already a string. 283 // Right operand (y) is already a string.
284 STRING_ADD_RIGHT_STRONG = function STRING_ADD_RIGHT_STRONG(y) { 284 STRING_ADD_RIGHT_STRONG = function STRING_ADD_RIGHT_STRONG(y) {
285 if (IS_STRING(this)) { 285 if (IS_STRING(this)) {
286 return %_StringAdd(this, y); 286 return %_StringAdd(this, y);
287 } 287 }
288 throw %MakeTypeError('strong_implicit_cast'); 288 throw %MakeTypeError(kStrongImplicitCast);
289 } 289 }
290 290
291 291
292 // ECMA-262, section 11.6.2, page 50. 292 // ECMA-262, section 11.6.2, page 50.
293 SUB = function SUB(y) { 293 SUB = function SUB(y) {
294 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); 294 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
295 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 295 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
296 return %NumberSub(x, y); 296 return %NumberSub(x, y);
297 } 297 }
298 298
299 299
300 // Strong mode SUB throws if an implicit conversion would be performed 300 // Strong mode SUB throws if an implicit conversion would be performed
301 SUB_STRONG = function SUB_STRONG(y) { 301 SUB_STRONG = function SUB_STRONG(y) {
302 if (IS_NUMBER(this) && IS_NUMBER(y)) { 302 if (IS_NUMBER(this) && IS_NUMBER(y)) {
303 return %NumberSub(this, y); 303 return %NumberSub(this, y);
304 } 304 }
305 throw %MakeTypeError('strong_implicit_cast'); 305 throw %MakeTypeError(kStrongImplicitCast);
306 } 306 }
307 307
308 308
309 // ECMA-262, section 11.5.1, page 48. 309 // ECMA-262, section 11.5.1, page 48.
310 MUL = function MUL(y) { 310 MUL = function MUL(y) {
311 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); 311 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
312 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 312 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
313 return %NumberMul(x, y); 313 return %NumberMul(x, y);
314 } 314 }
315 315
316 316
317 // Strong mode MUL throws if an implicit conversion would be performed 317 // Strong mode MUL throws if an implicit conversion would be performed
318 MUL_STRONG = function MUL_STRONG(y) { 318 MUL_STRONG = function MUL_STRONG(y) {
319 if (IS_NUMBER(this) && IS_NUMBER(y)) { 319 if (IS_NUMBER(this) && IS_NUMBER(y)) {
320 return %NumberMul(this, y); 320 return %NumberMul(this, y);
321 } 321 }
322 throw %MakeTypeError('strong_implicit_cast'); 322 throw %MakeTypeError(kStrongImplicitCast);
323 } 323 }
324 324
325 325
326 // ECMA-262, section 11.5.2, page 49. 326 // ECMA-262, section 11.5.2, page 49.
327 DIV = function DIV(y) { 327 DIV = function DIV(y) {
328 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); 328 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
329 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 329 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
330 return %NumberDiv(x, y); 330 return %NumberDiv(x, y);
331 } 331 }
332 332
333 333
334 // Strong mode DIV throws if an implicit conversion would be performed 334 // Strong mode DIV throws if an implicit conversion would be performed
335 DIV_STRONG = function DIV_STRONG(y) { 335 DIV_STRONG = function DIV_STRONG(y) {
336 if (IS_NUMBER(this) && IS_NUMBER(y)) { 336 if (IS_NUMBER(this) && IS_NUMBER(y)) {
337 return %NumberDiv(this, y); 337 return %NumberDiv(this, y);
338 } 338 }
339 throw %MakeTypeError('strong_implicit_cast'); 339 throw %MakeTypeError(kStrongImplicitCast);
340 } 340 }
341 341
342 342
343 // ECMA-262, section 11.5.3, page 49. 343 // ECMA-262, section 11.5.3, page 49.
344 MOD = function MOD(y) { 344 MOD = function MOD(y) {
345 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); 345 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
346 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 346 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
347 return %NumberMod(x, y); 347 return %NumberMod(x, y);
348 } 348 }
349 349
350 350
351 // Strong mode MOD throws if an implicit conversion would be performed 351 // Strong mode MOD throws if an implicit conversion would be performed
352 MOD_STRONG = function MOD_STRONG(y) { 352 MOD_STRONG = function MOD_STRONG(y) {
353 if (IS_NUMBER(this) && IS_NUMBER(y)) { 353 if (IS_NUMBER(this) && IS_NUMBER(y)) {
354 return %NumberMod(this, y); 354 return %NumberMod(this, y);
355 } 355 }
356 throw %MakeTypeError('strong_implicit_cast'); 356 throw %MakeTypeError(kStrongImplicitCast);
357 } 357 }
358 358
359 359
360 /* ------------------------------------------- 360 /* -------------------------------------------
361 - - - B i t o p e r a t i o n s - - - 361 - - - B i t o p e r a t i o n s - - -
362 ------------------------------------------- 362 -------------------------------------------
363 */ 363 */
364 364
365 // ECMA-262, section 11.10, page 57. 365 // ECMA-262, section 11.10, page 57.
366 BIT_OR = function BIT_OR(y) { 366 BIT_OR = function BIT_OR(y) {
367 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); 367 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
368 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 368 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
369 return %NumberOr(x, y); 369 return %NumberOr(x, y);
370 } 370 }
371 371
372 372
373 // Strong mode BIT_OR throws if an implicit conversion would be performed 373 // Strong mode BIT_OR throws if an implicit conversion would be performed
374 BIT_OR_STRONG = function BIT_OR_STRONG(y) { 374 BIT_OR_STRONG = function BIT_OR_STRONG(y) {
375 if (IS_NUMBER(this) && IS_NUMBER(y)) { 375 if (IS_NUMBER(this) && IS_NUMBER(y)) {
376 return %NumberOr(this, y); 376 return %NumberOr(this, y);
377 } 377 }
378 throw %MakeTypeError('strong_implicit_cast'); 378 throw %MakeTypeError(kStrongImplicitCast);
379 } 379 }
380 380
381 381
382 // ECMA-262, section 11.10, page 57. 382 // ECMA-262, section 11.10, page 57.
383 BIT_AND = function BIT_AND(y) { 383 BIT_AND = function BIT_AND(y) {
384 var x; 384 var x;
385 if (IS_NUMBER(this)) { 385 if (IS_NUMBER(this)) {
386 x = this; 386 x = this;
387 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 387 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
388 } else { 388 } else {
(...skipping 10 matching lines...) Expand all
399 } 399 }
400 return %NumberAnd(x, y); 400 return %NumberAnd(x, y);
401 } 401 }
402 402
403 403
404 // Strong mode BIT_AND throws if an implicit conversion would be performed 404 // Strong mode BIT_AND throws if an implicit conversion would be performed
405 BIT_AND_STRONG = function BIT_AND_STRONG(y) { 405 BIT_AND_STRONG = function BIT_AND_STRONG(y) {
406 if (IS_NUMBER(this) && IS_NUMBER(y)) { 406 if (IS_NUMBER(this) && IS_NUMBER(y)) {
407 return %NumberAnd(this, y); 407 return %NumberAnd(this, y);
408 } 408 }
409 throw %MakeTypeError('strong_implicit_cast'); 409 throw %MakeTypeError(kStrongImplicitCast);
410 } 410 }
411 411
412 412
413 // ECMA-262, section 11.10, page 57. 413 // ECMA-262, section 11.10, page 57.
414 BIT_XOR = function BIT_XOR(y) { 414 BIT_XOR = function BIT_XOR(y) {
415 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); 415 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
416 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 416 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
417 return %NumberXor(x, y); 417 return %NumberXor(x, y);
418 } 418 }
419 419
420 420
421 // Strong mode BIT_XOR throws if an implicit conversion would be performed 421 // Strong mode BIT_XOR throws if an implicit conversion would be performed
422 BIT_XOR_STRONG = function BIT_XOR_STRONG(y) { 422 BIT_XOR_STRONG = function BIT_XOR_STRONG(y) {
423 if (IS_NUMBER(this) && IS_NUMBER(y)) { 423 if (IS_NUMBER(this) && IS_NUMBER(y)) {
424 return %NumberXor(this, y); 424 return %NumberXor(this, y);
425 } 425 }
426 throw %MakeTypeError('strong_implicit_cast'); 426 throw %MakeTypeError(kStrongImplicitCast);
427 } 427 }
428 428
429 429
430 // ECMA-262, section 11.7.1, page 51. 430 // ECMA-262, section 11.7.1, page 51.
431 SHL = function SHL(y) { 431 SHL = function SHL(y) {
432 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); 432 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
433 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 433 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
434 return %NumberShl(x, y); 434 return %NumberShl(x, y);
435 } 435 }
436 436
437 437
438 // Strong mode SHL throws if an implicit conversion would be performed 438 // Strong mode SHL throws if an implicit conversion would be performed
439 SHL_STRONG = function SHL_STRONG(y) { 439 SHL_STRONG = function SHL_STRONG(y) {
440 if (IS_NUMBER(this) && IS_NUMBER(y)) { 440 if (IS_NUMBER(this) && IS_NUMBER(y)) {
441 return %NumberShl(this, y); 441 return %NumberShl(this, y);
442 } 442 }
443 throw %MakeTypeError('strong_implicit_cast'); 443 throw %MakeTypeError(kStrongImplicitCast);
444 } 444 }
445 445
446 446
447 // ECMA-262, section 11.7.2, page 51. 447 // ECMA-262, section 11.7.2, page 51.
448 SAR = function SAR(y) { 448 SAR = function SAR(y) {
449 var x; 449 var x;
450 if (IS_NUMBER(this)) { 450 if (IS_NUMBER(this)) {
451 x = this; 451 x = this;
452 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 452 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
453 } else { 453 } else {
(...skipping 10 matching lines...) Expand all
464 } 464 }
465 return %NumberSar(x, y); 465 return %NumberSar(x, y);
466 } 466 }
467 467
468 468
469 // Strong mode SAR throws if an implicit conversion would be performed 469 // Strong mode SAR throws if an implicit conversion would be performed
470 SAR_STRONG = function SAR_STRONG(y) { 470 SAR_STRONG = function SAR_STRONG(y) {
471 if (IS_NUMBER(this) && IS_NUMBER(y)) { 471 if (IS_NUMBER(this) && IS_NUMBER(y)) {
472 return %NumberSar(this, y); 472 return %NumberSar(this, y);
473 } 473 }
474 throw %MakeTypeError('strong_implicit_cast'); 474 throw %MakeTypeError(kStrongImplicitCast);
475 } 475 }
476 476
477 477
478 // ECMA-262, section 11.7.3, page 52. 478 // ECMA-262, section 11.7.3, page 52.
479 SHR = function SHR(y) { 479 SHR = function SHR(y) {
480 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this); 480 var x = IS_NUMBER(this) ? this : %$nonNumberToNumber(this);
481 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y); 481 if (!IS_NUMBER(y)) y = %$nonNumberToNumber(y);
482 return %NumberShr(x, y); 482 return %NumberShr(x, y);
483 } 483 }
484 484
485 485
486 // Strong mode SHR throws if an implicit conversion would be performed 486 // Strong mode SHR throws if an implicit conversion would be performed
487 SHR_STRONG = function SHR_STRONG(y) { 487 SHR_STRONG = function SHR_STRONG(y) {
488 if (IS_NUMBER(this) && IS_NUMBER(y)) { 488 if (IS_NUMBER(this) && IS_NUMBER(y)) {
489 return %NumberShr(this, y); 489 return %NumberShr(this, y);
490 } 490 }
491 throw %MakeTypeError('strong_implicit_cast'); 491 throw %MakeTypeError(kStrongImplicitCast);
492 } 492 }
493 493
494 494
495 /* ----------------------------- 495 /* -----------------------------
496 - - - H e l p e r s - - - 496 - - - H e l p e r s - - -
497 ----------------------------- 497 -----------------------------
498 */ 498 */
499 499
500 // ECMA-262, section 11.4.1, page 46. 500 // ECMA-262, section 11.4.1, page 46.
501 DELETE = function DELETE(key, language_mode) { 501 DELETE = function DELETE(key, language_mode) {
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 $toLength = ToLength; 1012 $toLength = ToLength;
1013 $toName = ToName; 1013 $toName = ToName;
1014 $toNumber = ToNumber; 1014 $toNumber = ToNumber;
1015 $toObject = ToObject; 1015 $toObject = ToObject;
1016 $toPositiveInteger = ToPositiveInteger; 1016 $toPositiveInteger = ToPositiveInteger;
1017 $toPrimitive = ToPrimitive; 1017 $toPrimitive = ToPrimitive;
1018 $toString = ToString; 1018 $toString = ToString;
1019 $toUint32 = ToUint32; 1019 $toUint32 = ToUint32;
1020 1020
1021 }) 1021 })
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime/runtime-classes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698