| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 | 168 |
| 169 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { | 169 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { |
| 170 ASSERT(!object->IsJSFunction()); | 170 ASSERT(!object->IsJSFunction()); |
| 171 | 171 |
| 172 // If you return a function from here, it will be called when an | 172 // If you return a function from here, it will be called when an |
| 173 // attempt is made to call the given object as a function. | 173 // attempt is made to call the given object as a function. |
| 174 | 174 |
| 175 // Regular expressions can be called as functions in both Firefox | 175 // Regular expressions can be called as functions in both Firefox |
| 176 // and Safari so we allow it too. | 176 // and Safari so we allow it too. |
| 177 bool is_regexp = | 177 if (object->IsJSRegExp()) { |
| 178 object->IsHeapObject() && | |
| 179 (HeapObject::cast(*object)->map()->constructor() == | |
| 180 *Top::regexp_function()); | |
| 181 | |
| 182 if (is_regexp) { | |
| 183 Handle<String> exec = Factory::exec_symbol(); | 178 Handle<String> exec = Factory::exec_symbol(); |
| 184 return Handle<Object>(object->GetProperty(*exec)); | 179 return Handle<Object>(object->GetProperty(*exec)); |
| 185 } | 180 } |
| 186 | 181 |
| 187 // Objects created through the API can have an instance-call handler | 182 // Objects created through the API can have an instance-call handler |
| 188 // that should be used when calling the object as a function. | 183 // that should be used when calling the object as a function. |
| 189 if (object->IsHeapObject() && | 184 if (object->IsHeapObject() && |
| 190 HeapObject::cast(*object)->map()->has_instance_call_handler()) { | 185 HeapObject::cast(*object)->map()->has_instance_call_handler()) { |
| 191 return Handle<JSFunction>( | 186 return Handle<JSFunction>( |
| 192 Top::global_context()->call_as_function_delegate()); | 187 Top::global_context()->call_as_function_delegate()); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 // All allocation spaces other than NEW_SPACE have the same effect. | 661 // All allocation spaces other than NEW_SPACE have the same effect. |
| 667 Heap::CollectAllGarbage(); | 662 Heap::CollectAllGarbage(); |
| 668 return v8::Undefined(); | 663 return v8::Undefined(); |
| 669 } | 664 } |
| 670 | 665 |
| 671 | 666 |
| 672 static GCExtension kGCExtension; | 667 static GCExtension kGCExtension; |
| 673 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); | 668 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); |
| 674 | 669 |
| 675 } } // namespace v8::internal | 670 } } // namespace v8::internal |
| OLD | NEW |