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 // 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 var delegate = %GetFunctionDelegate(callee); | 320 var delegate = %GetFunctionDelegate(callee); |
321 if (!IS_FUNCTION(delegate)) { | 321 if (!IS_FUNCTION(delegate)) { |
322 throw %MakeTypeError('called_non_callable', [typeof callee]); | 322 throw %MakeTypeError('called_non_callable', [typeof callee]); |
323 } | 323 } |
324 | 324 |
325 var parameters = %NewArguments(delegate); | 325 var parameters = %NewArguments(delegate); |
326 return delegate.apply(callee, parameters); | 326 return delegate.apply(callee, parameters); |
327 } | 327 } |
328 | 328 |
329 | 329 |
| 330 function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { |
| 331 var callee = %GetCalledFunction(); |
| 332 var delegate = %GetConstructorDelegate(callee); |
| 333 if (!IS_FUNCTION(delegate)) { |
| 334 throw %MakeTypeError('called_non_callable', [typeof callee]); |
| 335 } |
| 336 |
| 337 var parameters = %NewArguments(delegate); |
| 338 return delegate.apply(callee, parameters); |
| 339 } |
| 340 |
| 341 |
330 function APPLY_PREPARE(args) { | 342 function APPLY_PREPARE(args) { |
331 var length; | 343 var length; |
332 // First check whether length is a positive Smi and args is an array. This is
the | 344 // First check whether length is a positive Smi and args is an array. This is
the |
333 // fast case. If this fails, we do the slow case that takes care of more even
tualities | 345 // fast case. If this fails, we do the slow case that takes care of more even
tualities |
334 if (%_IsArray(args)) { | 346 if (%_IsArray(args)) { |
335 length = args.length; | 347 length = args.length; |
336 if (%_IsSmi(length) && length >= 0 && length < 0x800000 && IS_FUNCTION(this)
) { | 348 if (%_IsSmi(length) && length >= 0 && length < 0x800000 && IS_FUNCTION(this)
) { |
337 return length; | 349 return length; |
338 } | 350 } |
339 } | 351 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 throw %MakeTypeError('cannot_convert_to_primitive', []); | 528 throw %MakeTypeError('cannot_convert_to_primitive', []); |
517 } | 529 } |
518 | 530 |
519 | 531 |
520 // NOTE: Setting the prototype for Array must take place as early as | 532 // NOTE: Setting the prototype for Array must take place as early as |
521 // possible due to code generation for array literals. When | 533 // possible due to code generation for array literals. When |
522 // generating code for a array literal a boilerplate array is created | 534 // generating code for a array literal a boilerplate array is created |
523 // that is cloned when running the code. It is essiential that the | 535 // that is cloned when running the code. It is essiential that the |
524 // boilerplate gets the right prototype. | 536 // boilerplate gets the right prototype. |
525 %FunctionSetPrototype($Array, new $Array(0)); | 537 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |