| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/exceptions.h" | 5 #include "vm/exceptions.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 371 } |
| 372 Isolate* isolate = Isolate::Current(); | 372 Isolate* isolate = Isolate::Current(); |
| 373 Class& error_class = Class::Handle(isolate, | 373 Class& error_class = Class::Handle(isolate, |
| 374 isolate->object_store()->error_class()); | 374 isolate->object_store()->error_class()); |
| 375 if (error_class.IsNull()) { | 375 if (error_class.IsNull()) { |
| 376 const Library& core_lib = Library::Handle(isolate, Library::CoreLibrary()); | 376 const Library& core_lib = Library::Handle(isolate, Library::CoreLibrary()); |
| 377 error_class = core_lib.LookupClass(Symbols::Error(), NULL); | 377 error_class = core_lib.LookupClass(Symbols::Error(), NULL); |
| 378 ASSERT(!error_class.IsNull()); | 378 ASSERT(!error_class.IsNull()); |
| 379 isolate->object_store()->set_error_class(error_class); | 379 isolate->object_store()->set_error_class(error_class); |
| 380 } | 380 } |
| 381 const Class& instance_class = Class::Handle(isolate, instance.clazz()); | 381 // If instance class extends 'class Error' return '_stackTrace' field. |
| 382 Error& malformed_type_error = Error::Handle(isolate); | 382 Class& test_class = Class::Handle(isolate, instance.clazz()); |
| 383 if (instance_class.IsSubtypeOf(Object::null_abstract_type_arguments(), | 383 AbstractType& type = AbstractType::Handle(isolate, AbstractType::null()); |
| 384 error_class, | 384 while (true) { |
| 385 Object::null_abstract_type_arguments(), | 385 if (test_class.raw() == error_class.raw()) { |
| 386 &malformed_type_error)) { | 386 return error_class.LookupInstanceField(Symbols::_stackTrace()); |
| 387 ASSERT(malformed_type_error.IsNull()); | 387 } |
| 388 return error_class.LookupInstanceField(Symbols::_stackTrace()); | 388 type = test_class.super_type(); |
| 389 } | 389 if (type.IsNull()) return Field::null(); |
| 390 test_class = type.type_class(); |
| 391 }; |
| 392 UNREACHABLE(); |
| 390 return Field::null(); | 393 return Field::null(); |
| 391 } | 394 } |
| 392 | 395 |
| 393 | 396 |
| 394 static void ThrowExceptionHelper(const Instance& incoming_exception, | 397 static void ThrowExceptionHelper(const Instance& incoming_exception, |
| 395 const Instance& existing_stacktrace) { | 398 const Instance& existing_stacktrace) { |
| 396 bool use_preallocated_stacktrace = false; | 399 bool use_preallocated_stacktrace = false; |
| 397 Isolate* isolate = Isolate::Current(); | 400 Isolate* isolate = Isolate::Current(); |
| 398 Instance& exception = Instance::Handle(isolate, incoming_exception.raw()); | 401 Instance& exception = Instance::Handle(isolate, incoming_exception.raw()); |
| 399 if (exception.IsNull()) { | 402 if (exception.IsNull()) { |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 break; | 752 break; |
| 750 } | 753 } |
| 751 | 754 |
| 752 return DartLibraryCalls::InstanceCreate(library, | 755 return DartLibraryCalls::InstanceCreate(library, |
| 753 *class_name, | 756 *class_name, |
| 754 *constructor_name, | 757 *constructor_name, |
| 755 arguments); | 758 arguments); |
| 756 } | 759 } |
| 757 | 760 |
| 758 } // namespace dart | 761 } // namespace dart |
| OLD | NEW |