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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 StubCode::JumpToErrorHandlerEntryPoint()); | 136 StubCode::JumpToErrorHandlerEntryPoint()); |
137 func(program_counter, stack_pointer, frame_pointer, raw_error); | 137 func(program_counter, stack_pointer, frame_pointer, raw_error); |
138 UNREACHABLE(); | 138 UNREACHABLE(); |
139 } | 139 } |
140 | 140 |
141 | 141 |
142 static void ThrowExceptionHelper(const Instance& incoming_exception, | 142 static void ThrowExceptionHelper(const Instance& incoming_exception, |
143 const Instance& existing_stacktrace) { | 143 const Instance& existing_stacktrace) { |
144 Instance& exception = Instance::Handle(incoming_exception.raw()); | 144 Instance& exception = Instance::Handle(incoming_exception.raw()); |
145 if (exception.IsNull()) { | 145 if (exception.IsNull()) { |
146 GrowableArray<const Object*> arguments; | 146 const Array& arguments = Array::Handle(Object::empty_array()); |
147 exception ^= Exceptions::Create(Exceptions::kNullThrown, arguments); | 147 exception ^= Exceptions::Create(Exceptions::kNullThrown, arguments); |
148 } | 148 } |
149 uword handler_pc = 0; | 149 uword handler_pc = 0; |
150 uword handler_sp = 0; | 150 uword handler_sp = 0; |
151 uword handler_fp = 0; | 151 uword handler_fp = 0; |
152 const GrowableObjectArray& func_list = | 152 const GrowableObjectArray& func_list = |
153 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 153 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
154 const GrowableObjectArray& code_list = | 154 const GrowableObjectArray& code_list = |
155 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 155 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
156 const GrowableObjectArray& pc_offset_list = | 156 const GrowableObjectArray& pc_offset_list = |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 uword handler_pc = 0; | 371 uword handler_pc = 0; |
372 uword handler_sp = 0; | 372 uword handler_sp = 0; |
373 uword handler_fp = 0; | 373 uword handler_fp = 0; |
374 FindErrorHandler(&handler_pc, &handler_sp, &handler_fp); | 374 FindErrorHandler(&handler_pc, &handler_sp, &handler_fp); |
375 JumpToErrorHandler(handler_pc, handler_sp, handler_fp, error); | 375 JumpToErrorHandler(handler_pc, handler_sp, handler_fp, error); |
376 } | 376 } |
377 UNREACHABLE(); | 377 UNREACHABLE(); |
378 } | 378 } |
379 | 379 |
380 | 380 |
381 void Exceptions::ThrowByType( | 381 void Exceptions::ThrowByType(ExceptionType type, const Array& arguments) { |
382 ExceptionType type, const GrowableArray<const Object*>& arguments) { | |
383 const Object& result = Object::Handle(Create(type, arguments)); | 382 const Object& result = Object::Handle(Create(type, arguments)); |
384 if (result.IsError()) { | 383 if (result.IsError()) { |
385 // We got an error while constructing the exception object. | 384 // We got an error while constructing the exception object. |
386 // Propagate the error instead of throwing the exception. | 385 // Propagate the error instead of throwing the exception. |
387 PropagateError(Error::Cast(result)); | 386 PropagateError(Error::Cast(result)); |
388 } else { | 387 } else { |
389 ASSERT(result.IsInstance()); | 388 ASSERT(result.IsInstance()); |
390 Throw(Instance::Cast(result)); | 389 Throw(Instance::Cast(result)); |
391 } | 390 } |
392 } | 391 } |
393 | 392 |
394 | 393 |
395 RawObject* Exceptions::Create( | 394 RawObject* Exceptions::Create(ExceptionType type, const Array& arguments) { |
396 ExceptionType type, const GrowableArray<const Object*>& arguments) { | |
397 Library& library = Library::Handle(); | 395 Library& library = Library::Handle(); |
398 String& class_name = String::Handle(); | 396 String& class_name = String::Handle(); |
399 switch (type) { | 397 switch (type) { |
400 case kNone: | 398 case kNone: |
401 UNREACHABLE(); | 399 UNREACHABLE(); |
402 break; | 400 break; |
403 case kRange: | 401 case kRange: |
404 library = Library::CoreLibrary(); | 402 library = Library::CoreLibrary(); |
405 class_name = Symbols::New("RangeError"); | 403 class_name = Symbols::New("RangeError"); |
406 break; | 404 break; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 case kIsolateUnhandledException: | 441 case kIsolateUnhandledException: |
444 library = Library::IsolateLibrary(); | 442 library = Library::IsolateLibrary(); |
445 class_name = Symbols::New("IsolateUnhandledException"); | 443 class_name = Symbols::New("IsolateUnhandledException"); |
446 break; | 444 break; |
447 } | 445 } |
448 | 446 |
449 return DartLibraryCalls::ExceptionCreate(library, class_name, arguments); | 447 return DartLibraryCalls::ExceptionCreate(library, class_name, arguments); |
450 } | 448 } |
451 | 449 |
452 } // namespace dart | 450 } // namespace dart |
OLD | NEW |