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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 } | 417 } |
418 throw %make_type_error(kStrongImplicitConversion); | 418 throw %make_type_error(kStrongImplicitConversion); |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 /* ----------------------------- | 422 /* ----------------------------- |
423 - - - H e l p e r s - - - | 423 - - - H e l p e r s - - - |
424 ----------------------------- | 424 ----------------------------- |
425 */ | 425 */ |
426 | 426 |
427 // ECMA-262, section 11.8.7, page 54. | |
428 function IN(x) { | |
429 if (!IS_SPEC_OBJECT(x)) { | |
430 throw %make_type_error(kInvalidInOperatorUse, this, x); | |
431 } | |
432 if (%_IsNonNegativeSmi(this)) { | |
433 if (IS_ARRAY(x) && %_HasFastPackedElements(x)) { | |
434 return this < x.length; | |
435 } | |
436 return %HasElement(x, this); | |
437 } | |
438 return %HasProperty(x, this); | |
439 } | |
440 | |
441 | |
442 function CALL_NON_FUNCTION() { | 427 function CALL_NON_FUNCTION() { |
443 var delegate = %GetFunctionDelegate(this); | 428 var delegate = %GetFunctionDelegate(this); |
444 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); | 429 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); |
445 } | 430 } |
446 | 431 |
447 | 432 |
448 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { | 433 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { |
449 var delegate = %GetConstructorDelegate(this); | 434 var delegate = %GetConstructorDelegate(this); |
450 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); | 435 return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); |
451 } | 436 } |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 "call_function_proxy_as_constructor_builtin", CALL_FUNCTION_PROXY_AS_CONSTRUCT
OR, | 804 "call_function_proxy_as_constructor_builtin", CALL_FUNCTION_PROXY_AS_CONSTRUCT
OR, |
820 "call_function_proxy_builtin", CALL_FUNCTION_PROXY, | 805 "call_function_proxy_builtin", CALL_FUNCTION_PROXY, |
821 "call_non_function_as_constructor_builtin", CALL_NON_FUNCTION_AS_CONSTRUCTOR, | 806 "call_non_function_as_constructor_builtin", CALL_NON_FUNCTION_AS_CONSTRUCTOR, |
822 "call_non_function_builtin", CALL_NON_FUNCTION, | 807 "call_non_function_builtin", CALL_NON_FUNCTION, |
823 "compare_builtin", COMPARE, | 808 "compare_builtin", COMPARE, |
824 "compare_strong_builtin", COMPARE_STRONG, | 809 "compare_strong_builtin", COMPARE_STRONG, |
825 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, | 810 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, |
826 "div_builtin", DIV, | 811 "div_builtin", DIV, |
827 "div_strong_builtin", DIV_STRONG, | 812 "div_strong_builtin", DIV_STRONG, |
828 "equals_builtin", EQUALS, | 813 "equals_builtin", EQUALS, |
829 "in_builtin", IN, | |
830 "mod_builtin", MOD, | 814 "mod_builtin", MOD, |
831 "mod_strong_builtin", MOD_STRONG, | 815 "mod_strong_builtin", MOD_STRONG, |
832 "mul_builtin", MUL, | 816 "mul_builtin", MUL, |
833 "mul_strong_builtin", MUL_STRONG, | 817 "mul_strong_builtin", MUL_STRONG, |
834 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, | 818 "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, |
835 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, | 819 "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, |
836 "sar_builtin", SAR, | 820 "sar_builtin", SAR, |
837 "sar_strong_builtin", SAR_STRONG, | 821 "sar_strong_builtin", SAR_STRONG, |
838 "shl_builtin", SHL, | 822 "shl_builtin", SHL, |
839 "shl_strong_builtin", SHL_STRONG, | 823 "shl_strong_builtin", SHL_STRONG, |
(...skipping 19 matching lines...) Expand all Loading... |
859 | 843 |
860 utils.Export(function(to) { | 844 utils.Export(function(to) { |
861 to.ToBoolean = ToBoolean; | 845 to.ToBoolean = ToBoolean; |
862 to.ToLength = ToLength; | 846 to.ToLength = ToLength; |
863 to.ToNumber = ToNumber; | 847 to.ToNumber = ToNumber; |
864 to.ToPrimitive = ToPrimitive; | 848 to.ToPrimitive = ToPrimitive; |
865 to.ToString = ToString; | 849 to.ToString = ToString; |
866 }); | 850 }); |
867 | 851 |
868 }) | 852 }) |
OLD | NEW |