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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 PropagateError(Error::Cast(result)); | 386 PropagateError(Error::Cast(result)); |
387 } else { | 387 } else { |
388 ASSERT(result.IsInstance()); | 388 ASSERT(result.IsInstance()); |
389 Throw(Instance::Cast(result)); | 389 Throw(Instance::Cast(result)); |
390 } | 390 } |
391 } | 391 } |
392 | 392 |
393 | 393 |
394 RawObject* Exceptions::Create(ExceptionType type, const Array& arguments) { | 394 RawObject* Exceptions::Create(ExceptionType type, const Array& arguments) { |
395 Library& library = Library::Handle(); | 395 Library& library = Library::Handle(); |
396 String& class_name = String::Handle(); | 396 const String* class_name = NULL; |
397 switch (type) { | 397 switch (type) { |
398 case kNone: | 398 case kNone: |
399 UNREACHABLE(); | 399 UNREACHABLE(); |
400 break; | 400 break; |
401 case kRange: | 401 case kRange: |
402 library = Library::CoreLibrary(); | 402 library = Library::CoreLibrary(); |
403 class_name = Symbols::New("RangeError"); | 403 class_name = &Symbols::RangeError(); |
404 break; | 404 break; |
405 case kArgument: | 405 case kArgument: |
406 library = Library::CoreLibrary(); | 406 library = Library::CoreLibrary(); |
407 class_name = Symbols::New("ArgumentError"); | 407 class_name = &Symbols::ArgumentError(); |
408 break; | 408 break; |
409 case kNoSuchMethod: | 409 case kNoSuchMethod: |
410 library = Library::CoreLibrary(); | 410 library = Library::CoreLibrary(); |
411 class_name = Symbols::New("NoSuchMethodError"); | 411 class_name = &Symbols::NoSuchMethodError(); |
412 break; | 412 break; |
413 case kFormat: | 413 case kFormat: |
414 library = Library::CoreLibrary(); | 414 library = Library::CoreLibrary(); |
415 class_name = Symbols::New("FormatException"); | 415 class_name = &Symbols::FormatException(); |
416 break; | 416 break; |
417 case kStackOverflow: | 417 case kStackOverflow: |
418 library = Library::CoreLibrary(); | 418 library = Library::CoreLibrary(); |
419 class_name = Symbols::New("StackOverflowError"); | 419 class_name = &Symbols::StackOverflowError(); |
420 break; | 420 break; |
421 case kOutOfMemory: | 421 case kOutOfMemory: |
422 library = Library::CoreLibrary(); | 422 library = Library::CoreLibrary(); |
423 class_name = Symbols::New("OutOfMemoryError"); | 423 class_name = &Symbols::OutOfMemoryError(); |
424 break; | 424 break; |
425 case kInternalError: | 425 case kInternalError: |
426 library = Library::CoreLibrary(); | 426 library = Library::CoreLibrary(); |
427 class_name = Symbols::New("InternalError"); | 427 class_name = &Symbols::InternalError(); |
428 break; | 428 break; |
429 case kNullThrown: | 429 case kNullThrown: |
430 library = Library::CoreLibrary(); | 430 library = Library::CoreLibrary(); |
431 class_name = Symbols::New("NullThrownError"); | 431 class_name = &Symbols::NullThrownError(); |
432 break; | 432 break; |
433 case kIllegalJSRegExp: | 433 case kIllegalJSRegExp: |
434 library = Library::CoreLibrary(); | 434 library = Library::CoreLibrary(); |
435 class_name = Symbols::New("IllegalJSRegExpException"); | 435 class_name = &Symbols::IllegalJSRegExpException(); |
436 break; | 436 break; |
437 case kIsolateSpawn: | 437 case kIsolateSpawn: |
438 library = Library::IsolateLibrary(); | 438 library = Library::IsolateLibrary(); |
439 class_name = Symbols::New("IsolateSpawnException"); | 439 class_name = &Symbols::IsolateSpawnException(); |
440 break; | 440 break; |
441 case kIsolateUnhandledException: | 441 case kIsolateUnhandledException: |
442 library = Library::IsolateLibrary(); | 442 library = Library::IsolateLibrary(); |
443 class_name = Symbols::New("IsolateUnhandledException"); | 443 class_name = &Symbols::IsolateUnhandledException(); |
444 break; | 444 break; |
445 } | 445 } |
446 | 446 |
447 return DartLibraryCalls::ExceptionCreate(library, class_name, arguments); | 447 return DartLibraryCalls::ExceptionCreate(library, *class_name, arguments); |
448 } | 448 } |
449 | 449 |
450 } // namespace dart | 450 } // namespace dart |
OLD | NEW |