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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 Handle<Object> Factory::NewError(const char* type, | 394 Handle<Object> Factory::NewError(const char* type, |
395 Vector< Handle<Object> > args) { | 395 Vector< Handle<Object> > args) { |
396 return NewError("MakeError", type, args); | 396 return NewError("MakeError", type, args); |
397 } | 397 } |
398 | 398 |
399 | 399 |
400 Handle<Object> Factory::NewError(const char* maker, | 400 Handle<Object> Factory::NewError(const char* maker, |
401 const char* type, | 401 const char* type, |
402 Handle<JSArray> args) { | 402 Handle<JSArray> args) { |
403 Handle<String> make_str = Factory::LookupAsciiSymbol(maker); | 403 Handle<String> make_str = Factory::LookupAsciiSymbol(maker); |
404 Handle<JSFunction> fun = | 404 Handle<Object> fun_obj(Top::builtins()->GetProperty(*make_str)); |
405 Handle<JSFunction>( | 405 // If the builtins haven't been properly configured yet this error |
406 JSFunction::cast( | 406 // constructor may not have been defined. Bail out. |
407 Top::builtins()->GetProperty(*make_str))); | 407 if (!fun_obj->IsJSFunction()) |
| 408 return Factory::undefined_value(); |
| 409 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); |
408 Handle<Object> type_obj = Factory::LookupAsciiSymbol(type); | 410 Handle<Object> type_obj = Factory::LookupAsciiSymbol(type); |
409 Object** argv[2] = { type_obj.location(), | 411 Object** argv[2] = { type_obj.location(), |
410 Handle<Object>::cast(args).location() }; | 412 Handle<Object>::cast(args).location() }; |
411 | 413 |
412 // Invoke the JavaScript factory method. If an exception is thrown while | 414 // Invoke the JavaScript factory method. If an exception is thrown while |
413 // running the factory method, use the exception as the result. | 415 // running the factory method, use the exception as the result. |
414 bool caught_exception; | 416 bool caught_exception; |
415 Handle<Object> result = Execution::TryCall(fun, | 417 Handle<Object> result = Execution::TryCall(fun, |
416 Top::builtins(), | 418 Top::builtins(), |
417 2, | 419 2, |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 Execution::ConfigureInstance(instance, | 929 Execution::ConfigureInstance(instance, |
928 instance_template, | 930 instance_template, |
929 pending_exception); | 931 pending_exception); |
930 } else { | 932 } else { |
931 *pending_exception = false; | 933 *pending_exception = false; |
932 } | 934 } |
933 } | 935 } |
934 | 936 |
935 | 937 |
936 } } // namespace v8::internal | 938 } } // namespace v8::internal |
OLD | NEW |