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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 // stack. It is guaranteed to be a small integer at this point. | 326 // stack. It is guaranteed to be a small integer at this point. |
327 return length; | 327 return length; |
328 } | 328 } |
329 | 329 |
330 | 330 |
331 function CONCAT_ITERABLE_TO_ARRAY(iterable) { | 331 function CONCAT_ITERABLE_TO_ARRAY(iterable) { |
332 return %concat_iterable_to_array(this, iterable); | 332 return %concat_iterable_to_array(this, iterable); |
333 }; | 333 }; |
334 | 334 |
335 | 335 |
336 function STACK_OVERFLOW(length) { | |
337 throw %make_range_error(kStackOverflow); | |
338 } | |
339 | |
340 | |
341 /* ------------------------------------- | 336 /* ------------------------------------- |
342 - - - C o n v e r s i o n s - - - | 337 - - - C o n v e r s i o n s - - - |
343 ------------------------------------- | 338 ------------------------------------- |
344 */ | 339 */ |
345 | 340 |
346 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 341 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
347 // (1) for number hint, and (2) for string hint. | 342 // (1) for number hint, and (2) for string hint. |
348 function ToPrimitive(x, hint) { | 343 function ToPrimitive(x, hint) { |
349 if (!IS_SPEC_OBJECT(x)) return x; | 344 if (!IS_SPEC_OBJECT(x)) return x; |
350 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; | 345 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 %InstallToContext([ | 546 %InstallToContext([ |
552 "apply_prepare_builtin", APPLY_PREPARE, | 547 "apply_prepare_builtin", APPLY_PREPARE, |
553 "call_function_proxy_as_constructor_builtin", CALL_FUNCTION_PROXY_AS_CONSTRUCT
OR, | 548 "call_function_proxy_as_constructor_builtin", CALL_FUNCTION_PROXY_AS_CONSTRUCT
OR, |
554 "call_non_function_as_constructor_builtin", CALL_NON_FUNCTION_AS_CONSTRUCTOR, | 549 "call_non_function_as_constructor_builtin", CALL_NON_FUNCTION_AS_CONSTRUCTOR, |
555 "compare_builtin", COMPARE, | 550 "compare_builtin", COMPARE, |
556 "compare_strong_builtin", COMPARE_STRONG, | 551 "compare_strong_builtin", COMPARE_STRONG, |
557 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, | 552 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, |
558 "equals_builtin", EQUALS, | 553 "equals_builtin", EQUALS, |
559 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, | 554 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, |
560 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, | 555 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, |
561 "stack_overflow_builtin", STACK_OVERFLOW, | |
562 "string_add_left_builtin", STRING_ADD_LEFT, | 556 "string_add_left_builtin", STRING_ADD_LEFT, |
563 "string_add_right_builtin", STRING_ADD_RIGHT, | 557 "string_add_right_builtin", STRING_ADD_RIGHT, |
564 ]); | 558 ]); |
565 | 559 |
566 %InstallToContext([ | 560 %InstallToContext([ |
567 "concat_iterable_to_array", ConcatIterableToArray, | 561 "concat_iterable_to_array", ConcatIterableToArray, |
568 "non_number_to_number", NonNumberToNumber, | 562 "non_number_to_number", NonNumberToNumber, |
569 "non_string_to_string", NonStringToString, | 563 "non_string_to_string", NonStringToString, |
570 "to_integer_fun", ToInteger, | 564 "to_integer_fun", ToInteger, |
571 "to_length_fun", ToLength, | 565 "to_length_fun", ToLength, |
572 "to_number_fun", ToNumber, | 566 "to_number_fun", ToNumber, |
573 "to_primitive", ToPrimitive, | 567 "to_primitive", ToPrimitive, |
574 "to_string_fun", ToString, | 568 "to_string_fun", ToString, |
575 ]); | 569 ]); |
576 | 570 |
577 utils.Export(function(to) { | 571 utils.Export(function(to) { |
578 to.ToBoolean = ToBoolean; | 572 to.ToBoolean = ToBoolean; |
579 to.ToLength = ToLength; | 573 to.ToLength = ToLength; |
580 to.ToNumber = ToNumber; | 574 to.ToNumber = ToNumber; |
581 to.ToPrimitive = ToPrimitive; | 575 to.ToPrimitive = ToPrimitive; |
582 to.ToString = ToString; | 576 to.ToString = ToString; |
583 }); | 577 }); |
584 | 578 |
585 }) | 579 }) |
OLD | NEW |