winedbg: Add control operators to Thumb2 disassembler.
[wine.git] / dlls / msvcp90 / exception.c
blobd6841409a2a3567380f023512c779a0bc8f24b6f
1 /*
2 * Copyright 2010 Piotr Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
23 #include "msvcp90.h"
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
30 /* dlls/msvcrt/cppexcept.h */
31 typedef void (*cxx_copy_ctor)(void);
33 /* complete information about a C++ type */
34 typedef struct __cxx_type_info
36 UINT flags; /* flags (see CLASS_* flags below) */
37 const type_info *type_info; /* C++ type info */
38 this_ptr_offsets offsets; /* offsets for computing the this pointer */
39 unsigned int size; /* object size */
40 cxx_copy_ctor copy_ctor; /* copy constructor */
41 } cxx_type_info;
42 #define CLASS_IS_SIMPLE_TYPE 1
43 #define CLASS_HAS_VIRTUAL_BASE_CLASS 4
45 /* table of C++ types that apply for a given object */
46 typedef struct __cxx_type_info_table
48 UINT count; /* number of types */
49 const cxx_type_info *info[3]; /* variable length, we declare it large enough for static RTTI */
50 } cxx_type_info_table;
52 /* type information for an exception object */
53 typedef struct __cxx_exception_type
55 UINT flags; /* TYPE_FLAG flags */
56 void (*destructor)(void);/* exception object destructor */
57 void* /*cxx_exc_custom_handler*/ custom_handler; /* custom handler for this exception */
58 const cxx_type_info_table *type_info_table; /* list of types for this exception object */
59 } cxx_exception_type;
61 void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
63 /* vtables */
64 extern const vtable_ptr MSVCP_exception_vtable;
65 extern const vtable_ptr MSVCP_bad_alloc_vtable;
66 extern const vtable_ptr MSVCP_logic_error_vtable;
67 extern const vtable_ptr MSVCP_length_error_vtable;
68 extern const vtable_ptr MSVCP_out_of_range_vtable;
69 extern const vtable_ptr MSVCP_invalid_argument_vtable;
70 extern const vtable_ptr MSVCP_runtime_error_vtable;
71 extern const vtable_ptr MSVCP_failure_vtable;
73 static void MSVCP_type_info_dtor(type_info * _this)
75 free(_this->name);
78 /* Unexported */
79 DEFINE_THISCALL_WRAPPER(MSVCP_type_info_vector_dtor,8)
80 void * __thiscall MSVCP_type_info_vector_dtor(type_info * _this, unsigned int flags)
82 TRACE("(%p %x)\n", _this, flags);
83 if (flags & 2)
85 /* we have an array, with the number of elements stored before the first object */
86 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
88 for (i = *ptr - 1; i >= 0; i--) MSVCP_type_info_dtor(_this + i);
89 MSVCRT_operator_delete(ptr);
91 else
93 MSVCP_type_info_dtor(_this);
94 if (flags & 1) MSVCRT_operator_delete(_this);
96 return _this;
99 DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" );
101 static exception* MSVCP_exception_ctor(exception *this, const char **name)
103 TRACE("(%p %s)\n", this, *name);
105 this->vtable = &MSVCP_exception_vtable;
106 if(*name) {
107 unsigned int name_len = strlen(*name) + 1;
108 this->name = malloc(name_len);
109 memcpy(this->name, *name, name_len);
110 this->do_free = TRUE;
111 } else {
112 this->name = NULL;
113 this->do_free = FALSE;
115 return this;
118 DEFINE_THISCALL_WRAPPER(MSVCP_exception_copy_ctor,8)
119 exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception *rhs)
121 TRACE("(%p,%p)\n", this, rhs);
123 if(!rhs->do_free) {
124 this->vtable = &MSVCP_exception_vtable;
125 this->name = rhs->name;
126 this->do_free = FALSE;
127 } else
128 MSVCP_exception_ctor(this, (const char**)&rhs->name);
129 TRACE("name = %s\n", this->name);
130 return this;
133 DEFINE_THISCALL_WRAPPER(MSVCP_exception_dtor,4)
134 void __thiscall MSVCP_exception_dtor(exception *this)
136 TRACE("(%p)\n", this);
137 this->vtable = &MSVCP_exception_vtable;
138 if(this->do_free)
139 free(this->name);
142 DEFINE_THISCALL_WRAPPER(MSVCP_exception_vector_dtor, 8)
143 void * __thiscall MSVCP_exception_vector_dtor(exception *this, unsigned int flags)
145 TRACE("%p %x\n", this, flags);
146 if(flags & 2) {
147 /* we have an array, with the number of elements stored before the first object */
148 INT_PTR i, *ptr = (INT_PTR *)this-1;
150 for(i=*ptr-1; i>=0; i--)
151 MSVCP_exception_dtor(this+i);
152 MSVCRT_operator_delete(ptr);
153 } else {
154 MSVCP_exception_dtor(this);
155 if(flags & 1)
156 MSVCRT_operator_delete(this);
159 return this;
162 DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@std@@");
164 static const cxx_type_info exception_cxx_type_info = {
166 &exception_type_info,
167 { 0, -1, 0 },
168 sizeof(exception),
169 (cxx_copy_ctor)THISCALL(MSVCP_exception_dtor)
172 static const cxx_type_info_table exception_cxx_type_table = {
175 &exception_cxx_type_info,
176 NULL,
177 NULL
181 static const cxx_exception_type exception_cxx_type = {
183 (cxx_copy_ctor)THISCALL(MSVCP_exception_copy_ctor),
184 NULL,
185 &exception_cxx_type_table
188 /* bad_alloc class data */
189 typedef exception bad_alloc;
191 static bad_alloc* MSVCP_bad_alloc_ctor(bad_alloc *this, const char **name)
193 TRACE("%p %s\n", this, *name);
194 MSVCP_exception_ctor(this, name);
195 this->vtable = &MSVCP_bad_alloc_vtable;
196 return this;
199 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_copy_ctor, 8)
200 bad_alloc* __thiscall MSVCP_bad_alloc_copy_ctor(bad_alloc *this, const bad_alloc *rhs)
202 TRACE("%p %p\n", this, rhs);
203 MSVCP_exception_copy_ctor(this, rhs);
204 this->vtable = &MSVCP_bad_alloc_vtable;
205 return this;
208 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_dtor, 4)
209 void __thiscall MSVCP_bad_alloc_dtor(bad_alloc *this)
211 TRACE("%p\n", this);
212 MSVCP_exception_dtor(this);
215 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_vector_dtor, 8)
216 void * __thiscall MSVCP_bad_alloc_vector_dtor(bad_alloc *this, unsigned int flags)
218 TRACE("%p %x\n", this, flags);
219 if(flags & 2) {
220 /* we have an array, with the number of elements stored before the first object */
221 INT_PTR i, *ptr = (INT_PTR *)this-1;
223 for(i=*ptr-1; i>=0; i--)
224 MSVCP_bad_alloc_dtor(this+i);
225 MSVCRT_operator_delete(ptr);
226 } else {
227 MSVCP_bad_alloc_dtor(this);
228 if(flags & 1)
229 MSVCRT_operator_delete(this);
232 return this;
235 DEFINE_THISCALL_WRAPPER(MSVCP_what_exception,4)
236 const char* __thiscall MSVCP_what_exception(exception * this)
238 TRACE("(%p) returning %s\n", this, this->name);
239 return this->name ? this->name : "Unknown exception";
242 DEFINE_RTTI_DATA1(bad_alloc, 0, &exception_rtti_base_descriptor, ".?AVbad_alloc@std@@");
244 static const cxx_type_info bad_alloc_cxx_type_info = {
246 &bad_alloc_type_info,
247 { 0, -1, 0 },
248 sizeof(bad_alloc),
249 (cxx_copy_ctor)THISCALL(MSVCP_bad_alloc_copy_ctor)
252 static const cxx_type_info_table bad_alloc_cxx_type_table = {
255 &bad_alloc_cxx_type_info,
256 &exception_cxx_type_info,
257 NULL
261 static const cxx_exception_type bad_alloc_cxx_type = {
263 (cxx_copy_ctor)THISCALL(MSVCP_bad_alloc_dtor),
264 NULL,
265 &bad_alloc_cxx_type_table
268 /* logic_error class data */
269 typedef struct _logic_error {
270 exception e;
271 basic_string_char str;
272 } logic_error;
274 static logic_error* MSVCP_logic_error_ctor(
275 logic_error *this, const char **name)
277 TRACE("%p %s\n", this, *name);
278 this->e.vtable = &MSVCP_logic_error_vtable;
279 this->e.name = NULL;
280 this->e.do_free = FALSE;
281 MSVCP_basic_string_char_ctor_cstr(&this->str, *name);
282 return this;
285 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_copy_ctor, 8)
286 logic_error* __thiscall MSVCP_logic_error_copy_ctor(
287 logic_error *this, logic_error *rhs)
289 TRACE("%p %p\n", this, rhs);
290 MSVCP_exception_copy_ctor(&this->e, &rhs->e);
291 MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
292 this->e.vtable = &MSVCP_logic_error_vtable;
293 return this;
296 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_dtor, 4)
297 void __thiscall MSVCP_logic_error_dtor(logic_error *this)
299 TRACE("%p\n", this);
300 MSVCP_exception_dtor(&this->e);
301 MSVCP_basic_string_char_dtor(&this->str);
304 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_vector_dtor, 8)
305 void* __thiscall MSVCP_logic_error_vector_dtor(
306 logic_error *this, unsigned int flags)
308 TRACE("%p %x\n", this, flags);
309 if(flags & 2) {
310 /* we have an array, with the number of elements stored before the first object */
311 INT_PTR i, *ptr = (INT_PTR *)this-1;
313 for(i=*ptr-1; i>=0; i--)
314 MSVCP_logic_error_dtor(this+i);
315 MSVCRT_operator_delete(ptr);
316 } else {
317 MSVCP_logic_error_dtor(this);
318 if(flags & 1)
319 MSVCRT_operator_delete(this);
322 return this;
325 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4)
326 const char* __thiscall MSVCP_logic_error_what(logic_error *this)
328 TRACE("%p\n", this);
329 return MSVCP_basic_string_char_c_str(&this->str);
332 DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@std@@");
334 static const cxx_type_info logic_error_cxx_type_info = {
336 &logic_error_type_info,
337 { 0, -1, 0 },
338 sizeof(logic_error),
339 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_copy_ctor)
342 static const cxx_type_info_table logic_error_cxx_type_table = {
345 &logic_error_cxx_type_info,
346 &exception_cxx_type_info,
347 NULL
351 static const cxx_exception_type logic_error_cxx_type = {
353 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_dtor),
354 NULL,
355 &logic_error_cxx_type_table
358 /* length_error class data */
359 typedef logic_error length_error;
361 static length_error* MSVCP_length_error_ctor(
362 length_error *this, const char **name)
364 TRACE("%p %s\n", this, *name);
365 MSVCP_logic_error_ctor(this, name);
366 this->e.vtable = &MSVCP_length_error_vtable;
367 return this;
370 DEFINE_THISCALL_WRAPPER(MSVCP_length_error_copy_ctor, 8)
371 length_error* __thiscall MSVCP_length_error_copy_ctor(
372 length_error *this, length_error *rhs)
374 TRACE("%p %p\n", this, rhs);
375 MSVCP_logic_error_copy_ctor(this, rhs);
376 this->e.vtable = &MSVCP_length_error_vtable;
377 return this;
380 DEFINE_RTTI_DATA2(length_error, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVlength_error@std@@");
382 static const cxx_type_info length_error_cxx_type_info = {
384 &length_error_type_info,
385 { 0, -1, 0 },
386 sizeof(length_error),
387 (cxx_copy_ctor)THISCALL(MSVCP_length_error_copy_ctor)
390 static const cxx_type_info_table length_error_cxx_type_table = {
393 &length_error_cxx_type_info,
394 &logic_error_cxx_type_info,
395 &exception_cxx_type_info
399 static const cxx_exception_type length_error_cxx_type = {
401 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_dtor),
402 NULL,
403 &length_error_cxx_type_table
406 /* out_of_range class data */
407 typedef logic_error out_of_range;
409 static out_of_range* MSVCP_out_of_range_ctor(
410 out_of_range *this, const char **name)
412 TRACE("%p %s\n", this, *name);
413 MSVCP_logic_error_ctor(this, name);
414 this->e.vtable = &MSVCP_out_of_range_vtable;
415 return this;
418 DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_copy_ctor, 8)
419 out_of_range* __thiscall MSVCP_out_of_range_copy_ctor(
420 out_of_range *this, out_of_range *rhs)
422 TRACE("%p %p\n", this, rhs);
423 MSVCP_logic_error_copy_ctor(this, rhs);
424 this->e.vtable = &MSVCP_out_of_range_vtable;
425 return this;
428 DEFINE_RTTI_DATA2(out_of_range, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVout_of_range@std@@");
430 static const cxx_type_info out_of_range_cxx_type_info = {
432 &out_of_range_type_info,
433 { 0, -1, 0 },
434 sizeof(out_of_range),
435 (cxx_copy_ctor)THISCALL(MSVCP_out_of_range_copy_ctor)
438 static const cxx_type_info_table out_of_range_cxx_type_table = {
441 &out_of_range_cxx_type_info,
442 &logic_error_cxx_type_info,
443 &exception_cxx_type_info
447 static const cxx_exception_type out_of_range_cxx_type = {
449 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_dtor),
450 NULL,
451 &out_of_range_cxx_type_table
454 /* invalid_argument class data */
455 typedef logic_error invalid_argument;
457 static invalid_argument* MSVCP_invalid_argument_ctor(
458 invalid_argument *this, const char **name)
460 TRACE("%p %s\n", this, *name);
461 MSVCP_logic_error_ctor(this, name);
462 this->e.vtable = &MSVCP_invalid_argument_vtable;
463 return this;
466 DEFINE_THISCALL_WRAPPER(MSVCP_invalid_argument_copy_ctor, 8)
467 invalid_argument* __thiscall MSVCP_invalid_argument_copy_ctor(
468 invalid_argument *this, invalid_argument *rhs)
470 TRACE("%p %p\n", this, rhs);
471 MSVCP_logic_error_copy_ctor(this, rhs);
472 this->e.vtable = &MSVCP_invalid_argument_vtable;
473 return this;
476 DEFINE_RTTI_DATA2(invalid_argument, 0, &logic_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVinvalid_argument@std@@");
478 static const cxx_type_info invalid_argument_cxx_type_info = {
480 &invalid_argument_type_info,
481 { 0, -1, 0 },
482 sizeof(invalid_argument),
483 (cxx_copy_ctor)THISCALL(MSVCP_invalid_argument_copy_ctor)
486 static const cxx_type_info_table invalid_argument_cxx_type_table = {
489 &invalid_argument_cxx_type_info,
490 &logic_error_cxx_type_info,
491 &exception_cxx_type_info
495 static const cxx_exception_type invalid_argument_cxx_type = {
497 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_dtor),
498 NULL,
499 &invalid_argument_cxx_type_table
502 /* runtime_error class data */
503 typedef struct {
504 exception e;
505 basic_string_char str;
506 } runtime_error;
508 static runtime_error* MSVCP_runtime_error_ctor(
509 runtime_error *this, const char **name)
511 TRACE("%p %s\n", this, *name);
512 this->e.vtable = &MSVCP_runtime_error_vtable;
513 this->e.name = NULL;
514 this->e.do_free = FALSE;
515 MSVCP_basic_string_char_ctor_cstr(&this->str, *name);
516 return this;
519 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_copy_ctor, 8)
520 runtime_error* __thiscall MSVCP_runtime_error_copy_ctor(
521 runtime_error *this, runtime_error *rhs)
523 TRACE("%p %p\n", this, rhs);
524 MSVCP_exception_copy_ctor(&this->e, &rhs->e);
525 MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
526 this->e.vtable = &MSVCP_runtime_error_vtable;
527 return this;
530 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_dtor, 4)
531 void __thiscall MSVCP_runtime_error_dtor(runtime_error *this)
533 TRACE("%p\n", this);
534 MSVCP_exception_dtor(&this->e);
535 MSVCP_basic_string_char_dtor(&this->str);
538 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_vector_dtor, 8)
539 void* __thiscall MSVCP_runtime_error_vector_dtor(
540 runtime_error *this, unsigned int flags)
542 TRACE("%p %x\n", this, flags);
543 if(flags & 2) {
544 /* we have an array, with the number of elements stored before the first object */
545 INT_PTR i, *ptr = (INT_PTR *)this-1;
547 for(i=*ptr-1; i>=0; i--)
548 MSVCP_runtime_error_dtor(this+i);
549 MSVCRT_operator_delete(ptr);
550 } else {
551 MSVCP_runtime_error_dtor(this);
552 if(flags & 1)
553 MSVCRT_operator_delete(this);
556 return this;
559 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_what, 4)
560 const char* __thiscall MSVCP_runtime_error_what(runtime_error *this)
562 TRACE("%p\n", this);
563 return MSVCP_basic_string_char_c_str(&this->str);
566 DEFINE_RTTI_DATA1(runtime_error, 0, &exception_rtti_base_descriptor, ".?AVruntime_error@std@@");
568 static const cxx_type_info runtime_error_cxx_type_info = {
570 &runtime_error_type_info,
571 { 0, -1, 0 },
572 sizeof(runtime_error),
573 (cxx_copy_ctor)THISCALL(MSVCP_runtime_error_copy_ctor)
576 static const cxx_type_info_table runtime_error_cxx_type_table = {
579 &runtime_error_cxx_type_info,
580 &exception_cxx_type_info,
581 NULL
585 static const cxx_exception_type runtime_error_cxx_type = {
587 (cxx_copy_ctor)THISCALL(MSVCP_runtime_error_dtor),
588 NULL,
589 &runtime_error_cxx_type_table
592 /* failure class data */
593 typedef runtime_error failure;
595 static failure* MSVCP_failure_ctor(
596 failure *this, const char **name)
598 TRACE("%p %s\n", this, *name);
599 MSVCP_runtime_error_ctor(this, name);
600 this->e.vtable = &MSVCP_failure_vtable;
601 return this;
604 DEFINE_THISCALL_WRAPPER(MSVCP_failure_copy_ctor, 8)
605 failure* __thiscall MSVCP_failure_copy_ctor(
606 failure *this, failure *rhs)
608 TRACE("%p %p\n", this, rhs);
609 MSVCP_runtime_error_copy_ctor(this, rhs);
610 this->e.vtable = &MSVCP_failure_vtable;
611 return this;
614 DEFINE_THISCALL_WRAPPER(MSVCP_failure_dtor, 4)
615 void __thiscall MSVCP_failure_dtor(failure *this)
617 TRACE("%p\n", this);
618 MSVCP_runtime_error_dtor(this);
621 DEFINE_THISCALL_WRAPPER(MSVCP_failure_vector_dtor, 8)
622 void* __thiscall MSVCP_failure_vector_dtor(
623 failure *this, unsigned int flags)
625 TRACE("%p %x\n", this, flags);
626 return MSVCP_runtime_error_vector_dtor(this, flags);
629 DEFINE_THISCALL_WRAPPER(MSVCP_failure_what, 4)
630 const char* __thiscall MSVCP_failure_what(failure *this)
632 TRACE("%p\n", this);
633 return MSVCP_runtime_error_what(this);
636 DEFINE_RTTI_DATA2(failure, 0, &runtime_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVfailure@std@@");
638 static const cxx_type_info failure_cxx_type_info = {
640 &failure_type_info,
641 { 0, -1, 0 },
642 sizeof(failure),
643 (cxx_copy_ctor)THISCALL(MSVCP_failure_copy_ctor)
646 static const cxx_type_info_table failure_cxx_type_table = {
649 &failure_cxx_type_info,
650 &runtime_error_cxx_type_info,
651 &exception_cxx_type_info
655 static const cxx_exception_type failure_cxx_type = {
657 (cxx_copy_ctor)THISCALL(MSVCP_failure_dtor),
658 NULL,
659 &failure_cxx_type_table
662 #ifndef __GNUC__
663 void __asm_dummy_vtables(void) {
664 #endif
665 __ASM_VTABLE(type_info,
666 VTABLE_ADD_FUNC(MSVCP_type_info_vector_dtor));
667 __ASM_VTABLE(exception,
668 VTABLE_ADD_FUNC(MSVCP_exception_vector_dtor)
669 VTABLE_ADD_FUNC(MSVCP_what_exception));
670 __ASM_VTABLE(bad_alloc,
671 VTABLE_ADD_FUNC(MSVCP_bad_alloc_vector_dtor)
672 VTABLE_ADD_FUNC(MSVCP_what_exception));
673 __ASM_VTABLE(logic_error,
674 VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
675 VTABLE_ADD_FUNC(MSVCP_logic_error_what));
676 __ASM_VTABLE(length_error,
677 VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
678 VTABLE_ADD_FUNC(MSVCP_logic_error_what));
679 __ASM_VTABLE(out_of_range,
680 VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
681 VTABLE_ADD_FUNC(MSVCP_logic_error_what));
682 __ASM_VTABLE(invalid_argument,
683 VTABLE_ADD_FUNC(MSVCP_logic_error_vector_dtor)
684 VTABLE_ADD_FUNC(MSVCP_logic_error_what));
685 __ASM_VTABLE(runtime_error,
686 VTABLE_ADD_FUNC(MSVCP_runtime_error_vector_dtor)
687 VTABLE_ADD_FUNC(MSVCP_runtime_error_what));
688 __ASM_VTABLE(failure,
689 VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor)
690 VTABLE_ADD_FUNC(MSVCP_failure_what));
691 #ifndef __GNUC__
693 #endif
695 /* Internal: throws selected exception */
696 void throw_exception(exception_type et, const char *str)
698 const char *addr = str;
700 switch(et) {
701 case EXCEPTION_RERAISE:
702 _CxxThrowException(NULL, NULL);
703 case EXCEPTION: {
704 exception e;
705 MSVCP_exception_ctor(&e, &addr);
706 _CxxThrowException(&e, &exception_cxx_type);
708 case EXCEPTION_BAD_ALLOC: {
709 bad_alloc e;
710 MSVCP_bad_alloc_ctor(&e, &addr);
711 _CxxThrowException(&e, &bad_alloc_cxx_type);
713 case EXCEPTION_LOGIC_ERROR: {
714 logic_error e;
715 MSVCP_logic_error_ctor(&e, &addr);
716 _CxxThrowException((exception*)&e, &logic_error_cxx_type);
718 case EXCEPTION_LENGTH_ERROR: {
719 length_error e;
720 MSVCP_length_error_ctor(&e, &addr);
721 _CxxThrowException((exception*)&e, &length_error_cxx_type);
723 case EXCEPTION_OUT_OF_RANGE: {
724 out_of_range e;
725 MSVCP_out_of_range_ctor(&e, &addr);
726 _CxxThrowException((exception*)&e, &out_of_range_cxx_type);
728 case EXCEPTION_INVALID_ARGUMENT: {
729 invalid_argument e;
730 MSVCP_invalid_argument_ctor(&e, &addr);
731 _CxxThrowException((exception*)&e, &invalid_argument_cxx_type);
733 case EXCEPTION_RUNTIME_ERROR: {
734 runtime_error e;
735 MSVCP_runtime_error_ctor(&e, &addr);
736 _CxxThrowException((exception*)&e, &runtime_error_cxx_type);
738 case EXCEPTION_FAILURE: {
739 failure e;
740 MSVCP_failure_ctor(&e, &addr);
741 _CxxThrowException((exception*)&e, &failure_cxx_type);
746 void init_exception(void *base)
748 #ifdef __x86_64__
749 init_type_info_rtti(base);
750 init_exception_rtti(base);
751 init_bad_alloc_rtti(base);
752 init_logic_error_rtti(base);
753 init_length_error_rtti(base);
754 init_out_of_range_rtti(base);
755 init_invalid_argument_rtti(base);
756 init_runtime_error_rtti(base);
757 init_failure_rtti(base);
758 #endif