msvcp90: Added collate<unsigned short> class stub.
[wine.git] / dlls / msvcp90 / exception.c
blobf2ff017aa697a1e612a38a05a25fad960a91de3e
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(msvcp90);
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_bad_alloc_vtable;
65 extern const vtable_ptr MSVCP_logic_error_vtable;
66 extern const vtable_ptr MSVCP_length_error_vtable;
67 extern const vtable_ptr MSVCP_out_of_range_vtable;
68 extern const vtable_ptr MSVCP_invalid_argument_vtable;
69 extern const vtable_ptr MSVCP_runtime_error_vtable;
71 /* exception class data */
72 static type_info exception_type_info = {
73 NULL, /* set by set_exception_vtable */
74 NULL,
75 ".?AVexception@std@@"
78 DEFINE_THISCALL_WRAPPER(MSVCP_exception_ctor, 8)
79 exception* __thiscall MSVCP_exception_ctor(exception *this, const char **name)
81 TRACE("(%p %s)\n", this, *name);
83 this->vtable = exception_type_info.vtable;
84 if(*name) {
85 unsigned int name_len = strlen(*name) + 1;
86 this->name = malloc(name_len);
87 memcpy(this->name, *name, name_len);
88 this->do_free = TRUE;
89 } else {
90 this->name = NULL;
91 this->do_free = FALSE;
93 return this;
96 DEFINE_THISCALL_WRAPPER(MSVCP_exception_copy_ctor,8)
97 exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception *rhs)
99 TRACE("(%p,%p)\n", this, rhs);
101 if(!rhs->do_free) {
102 this->vtable = exception_type_info.vtable;
103 this->name = rhs->name;
104 this->do_free = FALSE;
105 } else
106 MSVCP_exception_ctor(this, (const char**)&rhs->name);
107 TRACE("name = %s\n", this->name);
108 return this;
111 DEFINE_THISCALL_WRAPPER(MSVCP_exception_dtor,4)
112 void __thiscall MSVCP_exception_dtor(exception *this)
114 TRACE("(%p)\n", this);
115 this->vtable = exception_type_info.vtable;
116 if(this->do_free)
117 free(this->name);
120 static const rtti_base_descriptor exception_rtti_base_descriptor = {
121 &exception_type_info,
123 { 0, -1, 0 },
127 static const cxx_type_info exception_cxx_type_info = {
129 &exception_type_info,
130 { 0, -1, 0 },
131 sizeof(exception),
132 (cxx_copy_ctor)THISCALL(MSVCP_exception_dtor)
135 static const cxx_type_info_table exception_cxx_type_table = {
138 &exception_cxx_type_info,
139 NULL,
140 NULL
144 static const cxx_exception_type exception_cxx_type = {
146 (cxx_copy_ctor)THISCALL(MSVCP_exception_copy_ctor),
147 NULL,
148 &exception_cxx_type_table
151 void set_exception_vtable(void)
153 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
154 exception_type_info.vtable = (void*)GetProcAddress(hmod, "??_7exception@@6B@");
157 /* bad_alloc class data */
158 typedef exception bad_alloc;
160 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_ctor, 8)
161 bad_alloc* __thiscall MSVCP_bad_alloc_ctor(bad_alloc *this, const char **name)
163 TRACE("%p %s\n", this, *name);
164 MSVCP_exception_ctor(this, name);
165 this->vtable = &MSVCP_bad_alloc_vtable;
166 return this;
169 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_copy_ctor, 8)
170 bad_alloc* __thiscall MSVCP_bad_alloc_copy_ctor(bad_alloc *this, const bad_alloc *rhs)
172 TRACE("%p %p\n", this, rhs);
173 MSVCP_exception_copy_ctor(this, rhs);
174 this->vtable = &MSVCP_bad_alloc_vtable;
175 return this;
178 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_dtor, 4)
179 void __thiscall MSVCP_bad_alloc_dtor(bad_alloc *this)
181 TRACE("%p\n", this);
182 MSVCP_exception_dtor(this);
185 DEFINE_THISCALL_WRAPPER(MSVCP_bad_alloc_vector_dtor, 8)
186 void * __thiscall MSVCP_bad_alloc_vector_dtor(bad_alloc *this, unsigned int flags)
188 TRACE("%p %x\n", this, flags);
189 if(flags & 2) {
190 /* we have an array, with the number of elements stored before the first object */
191 int i, *ptr = (int *)this-1;
193 for(i=*ptr-1; i>=0; i--)
194 MSVCP_bad_alloc_dtor(this+i);
195 MSVCRT_operator_delete(ptr);
196 } else {
197 MSVCP_bad_alloc_dtor(this);
198 if(flags & 1)
199 MSVCRT_operator_delete(this);
202 return this;
205 DEFINE_THISCALL_WRAPPER(MSVCP_what_exception,4)
206 const char* __thiscall MSVCP_what_exception(exception * this)
208 TRACE("(%p) returning %s\n", this, this->name);
209 return this->name ? this->name : "Unknown exception";
212 static const type_info bad_alloc_type_info = {
213 &MSVCP_bad_alloc_vtable,
214 NULL,
215 ".?AVbad_alloc@std@@"
218 static const rtti_base_descriptor bad_alloc_rtti_base_descriptor = {
219 &bad_alloc_type_info,
221 { 0, -1, 0 },
225 static const rtti_base_array bad_alloc_rtti_base_array = {
227 &bad_alloc_rtti_base_descriptor,
228 &exception_rtti_base_descriptor,
229 NULL
233 static const rtti_object_hierarchy bad_alloc_type_hierarchy = {
237 &bad_alloc_rtti_base_array
240 const rtti_object_locator bad_alloc_rtti = {
244 &bad_alloc_type_info,
245 &bad_alloc_type_hierarchy
248 static const cxx_type_info bad_alloc_cxx_type_info = {
250 &bad_alloc_type_info,
251 { 0, -1, 0 },
252 sizeof(bad_alloc),
253 (cxx_copy_ctor)THISCALL(MSVCP_bad_alloc_copy_ctor)
256 static const cxx_type_info_table bad_alloc_cxx_type_table = {
259 &bad_alloc_cxx_type_info,
260 &exception_cxx_type_info,
261 NULL
265 static const cxx_exception_type bad_alloc_cxx_type = {
267 (cxx_copy_ctor)THISCALL(MSVCP_bad_alloc_dtor),
268 NULL,
269 &bad_alloc_cxx_type_table
272 /* logic_error class data */
273 typedef struct _logic_error {
274 exception e;
275 basic_string_char str;
276 } logic_error;
278 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor, 8)
279 logic_error* __thiscall MSVCP_logic_error_ctor(
280 logic_error *this, const char **name)
282 TRACE("%p %s\n", this, *name);
283 this->e.vtable = &MSVCP_logic_error_vtable;
284 this->e.name = NULL;
285 this->e.do_free = FALSE;
286 MSVCP_basic_string_char_ctor_cstr(&this->str, *name);
287 return this;
290 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_copy_ctor, 8)
291 logic_error* __thiscall MSVCP_logic_error_copy_ctor(
292 logic_error *this, logic_error *rhs)
294 TRACE("%p %p\n", this, rhs);
295 MSVCP_exception_copy_ctor(&this->e, &rhs->e);
296 MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
297 this->e.vtable = &MSVCP_logic_error_vtable;
298 return this;
301 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_dtor, 4)
302 void __thiscall MSVCP_logic_error_dtor(logic_error *this)
304 TRACE("%p\n", this);
305 MSVCP_exception_dtor(&this->e);
306 MSVCP_basic_string_char_dtor(&this->str);
309 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_vector_dtor, 8)
310 void* __thiscall MSVCP_logic_error_vector_dtor(
311 logic_error *this, unsigned int flags)
313 TRACE("%p %x\n", this, flags);
314 if(flags & 2) {
315 /* we have an array, with the number of elements stored before the first object */
316 int i, *ptr = (int *)this-1;
318 for(i=*ptr-1; i>=0; i--)
319 MSVCP_logic_error_dtor(this+i);
320 MSVCRT_operator_delete(ptr);
321 } else {
322 MSVCP_logic_error_dtor(this);
323 if(flags & 1)
324 MSVCRT_operator_delete(this);
327 return this;
330 DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4)
331 const char* __thiscall MSVCP_logic_error_what(logic_error *this)
333 TRACE("%p\n", this);
334 return MSVCP_basic_string_char_c_str(&this->str);
337 static const type_info logic_error_type_info = {
338 &MSVCP_logic_error_vtable,
339 NULL,
340 ".?AVlogic_error@std@@"
343 static const rtti_base_descriptor logic_error_rtti_base_descriptor = {
344 &logic_error_type_info,
346 { 0, -1, 0 },
350 static const rtti_base_array logic_error_rtti_base_array = {
352 &logic_error_rtti_base_descriptor,
353 &exception_rtti_base_descriptor,
354 NULL
358 static const rtti_object_hierarchy logic_error_type_hierarchy = {
362 &logic_error_rtti_base_array
365 const rtti_object_locator logic_error_rtti = {
369 &logic_error_type_info,
370 &logic_error_type_hierarchy
373 static const cxx_type_info logic_error_cxx_type_info = {
375 &logic_error_type_info,
376 { 0, -1, 0 },
377 sizeof(logic_error),
378 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_copy_ctor)
381 static const cxx_type_info_table logic_error_cxx_type_table = {
384 &logic_error_cxx_type_info,
385 &exception_cxx_type_info,
386 NULL
390 static const cxx_exception_type logic_error_cxx_type = {
392 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_dtor),
393 NULL,
394 &logic_error_cxx_type_table
397 /* length_error class data */
398 typedef logic_error length_error;
400 DEFINE_THISCALL_WRAPPER(MSVCP_length_error_ctor, 8)
401 length_error* __thiscall MSVCP_length_error_ctor(
402 length_error *this, const char **name)
404 TRACE("%p %s\n", this, *name);
405 MSVCP_logic_error_ctor(this, name);
406 this->e.vtable = &MSVCP_length_error_vtable;
407 return this;
410 DEFINE_THISCALL_WRAPPER(MSVCP_length_error_copy_ctor, 8)
411 length_error* __thiscall MSVCP_length_error_copy_ctor(
412 length_error *this, length_error *rhs)
414 TRACE("%p %p\n", this, rhs);
415 MSVCP_logic_error_copy_ctor(this, rhs);
416 this->e.vtable = &MSVCP_length_error_vtable;
417 return this;
420 DEFINE_THISCALL_WRAPPER(MSVCP_length_error_vector_dtor, 8)
421 void* __thiscall MSVCP_length_error_vector_dtor(
422 length_error *this, unsigned int flags)
424 TRACE("%p %x\n", this, flags);
425 return MSVCP_logic_error_vector_dtor(this, flags);
428 static const type_info length_error_type_info = {
429 &MSVCP_length_error_vtable,
430 NULL,
431 ".?AVlength_error@std@@"
434 static const rtti_base_descriptor length_error_rtti_base_descriptor = {
435 &length_error_type_info,
437 { 0, -1, 0 },
441 static const rtti_base_array length_error_rtti_base_array = {
443 &length_error_rtti_base_descriptor,
444 &logic_error_rtti_base_descriptor,
445 &exception_rtti_base_descriptor
449 static const rtti_object_hierarchy length_error_type_hierarchy = {
453 &length_error_rtti_base_array
456 const rtti_object_locator length_error_rtti = {
460 &length_error_type_info,
461 &length_error_type_hierarchy
464 static const cxx_type_info length_error_cxx_type_info = {
466 &length_error_type_info,
467 { 0, -1, 0 },
468 sizeof(length_error),
469 (cxx_copy_ctor)THISCALL(MSVCP_length_error_copy_ctor)
472 static const cxx_type_info_table length_error_cxx_type_table = {
475 &length_error_cxx_type_info,
476 &logic_error_cxx_type_info,
477 &exception_cxx_type_info
481 static const cxx_exception_type length_error_cxx_type = {
483 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_dtor),
484 NULL,
485 &length_error_cxx_type_table
488 /* out_of_range class data */
489 typedef logic_error out_of_range;
491 DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_ctor, 8)
492 out_of_range* __thiscall MSVCP_out_of_range_ctor(
493 out_of_range *this, const char **name)
495 TRACE("%p %s\n", this, *name);
496 MSVCP_logic_error_ctor(this, name);
497 this->e.vtable = &MSVCP_out_of_range_vtable;
498 return this;
501 DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_copy_ctor, 8)
502 out_of_range* __thiscall MSVCP_out_of_range_copy_ctor(
503 out_of_range *this, out_of_range *rhs)
505 TRACE("%p %p\n", this, rhs);
506 MSVCP_logic_error_copy_ctor(this, rhs);
507 this->e.vtable = &MSVCP_out_of_range_vtable;
508 return this;
511 DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_vector_dtor, 8)
512 void* __thiscall MSVCP_out_of_range_vector_dtor(
513 out_of_range *this, unsigned int flags)
515 TRACE("%p %x\n", this, flags);
516 return MSVCP_logic_error_vector_dtor(this, flags);
519 static const type_info out_of_range_type_info = {
520 &MSVCP_out_of_range_vtable,
521 NULL,
522 ".?AVout_of_range@std@@"
525 static const rtti_base_descriptor out_of_range_rtti_base_descriptor = {
526 &out_of_range_type_info,
528 { 0, -1, 0 },
532 static const rtti_base_array out_of_range_rtti_base_array = {
534 &out_of_range_rtti_base_descriptor,
535 &logic_error_rtti_base_descriptor,
536 &exception_rtti_base_descriptor
540 static const rtti_object_hierarchy out_of_range_type_hierarchy = {
544 &out_of_range_rtti_base_array
547 const rtti_object_locator out_of_range_rtti = {
551 &out_of_range_type_info,
552 &out_of_range_type_hierarchy
555 static const cxx_type_info out_of_range_cxx_type_info = {
557 &out_of_range_type_info,
558 { 0, -1, 0 },
559 sizeof(out_of_range),
560 (cxx_copy_ctor)THISCALL(MSVCP_out_of_range_copy_ctor)
563 static const cxx_type_info_table out_of_range_cxx_type_table = {
566 &out_of_range_cxx_type_info,
567 &logic_error_cxx_type_info,
568 &exception_cxx_type_info
572 static const cxx_exception_type out_of_range_cxx_type = {
574 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_dtor),
575 NULL,
576 &out_of_range_cxx_type_table
579 /* invalid_argument class data */
580 typedef logic_error invalid_argument;
582 DEFINE_THISCALL_WRAPPER(MSVCP_invalid_argument_ctor, 8)
583 invalid_argument* __thiscall MSVCP_invalid_argument_ctor(
584 invalid_argument *this, const char **name)
586 TRACE("%p %s\n", this, *name);
587 MSVCP_logic_error_ctor(this, name);
588 this->e.vtable = &MSVCP_invalid_argument_vtable;
589 return this;
592 DEFINE_THISCALL_WRAPPER(MSVCP_invalid_argument_copy_ctor, 8)
593 invalid_argument* __thiscall MSVCP_invalid_argument_copy_ctor(
594 invalid_argument *this, invalid_argument *rhs)
596 TRACE("%p %p\n", this, rhs);
597 MSVCP_logic_error_copy_ctor(this, rhs);
598 this->e.vtable = &MSVCP_invalid_argument_vtable;
599 return this;
602 DEFINE_THISCALL_WRAPPER(MSVCP_invalid_argument_vector_dtor, 8)
603 void* __thiscall MSVCP_invalid_argument_vector_dtor(
604 invalid_argument *this, unsigned int flags)
606 TRACE("%p %x\n", this, flags);
607 return MSVCP_logic_error_vector_dtor(this, flags);
610 static const type_info invalid_argument_type_info = {
611 &MSVCP_invalid_argument_vtable,
612 NULL,
613 ".?AVinvalid_argument@std@@"
616 static const rtti_base_descriptor invalid_argument_rtti_base_descriptor = {
617 &invalid_argument_type_info,
619 { 0, -1, 0 },
623 static const rtti_base_array invalid_argument_rtti_base_array = {
625 &invalid_argument_rtti_base_descriptor,
626 &logic_error_rtti_base_descriptor,
627 &exception_rtti_base_descriptor
631 static const rtti_object_hierarchy invalid_argument_type_hierarchy = {
635 &invalid_argument_rtti_base_array
638 const rtti_object_locator invalid_argument_rtti = {
642 &invalid_argument_type_info,
643 &invalid_argument_type_hierarchy
646 static const cxx_type_info invalid_argument_cxx_type_info = {
648 &invalid_argument_type_info,
649 { 0, -1, 0 },
650 sizeof(invalid_argument),
651 (cxx_copy_ctor)THISCALL(MSVCP_invalid_argument_copy_ctor)
654 static const cxx_type_info_table invalid_argument_cxx_type_table = {
657 &invalid_argument_cxx_type_info,
658 &logic_error_cxx_type_info,
659 &exception_cxx_type_info
663 static const cxx_exception_type invalid_argument_cxx_type = {
665 (cxx_copy_ctor)THISCALL(MSVCP_logic_error_dtor),
666 NULL,
667 &invalid_argument_cxx_type_table
670 /* runtime_error class data */
671 typedef struct {
672 exception e;
673 basic_string_char str;
674 } runtime_error;
676 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_ctor, 8)
677 runtime_error* __thiscall MSVCP_runtime_error_ctor(
678 runtime_error *this, const char **name)
680 TRACE("%p %s\n", this, *name);
681 this->e.vtable = &MSVCP_runtime_error_vtable;
682 this->e.name = NULL;
683 this->e.do_free = FALSE;
684 MSVCP_basic_string_char_ctor_cstr(&this->str, *name);
685 return this;
688 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_copy_ctor, 8)
689 runtime_error* __thiscall MSVCP_runtime_error_copy_ctor(
690 runtime_error *this, runtime_error *rhs)
692 TRACE("%p %p\n", this, rhs);
693 MSVCP_exception_copy_ctor(&this->e, &rhs->e);
694 MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str);
695 this->e.vtable = &MSVCP_runtime_error_vtable;
696 return this;
699 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_dtor, 4)
700 void __thiscall MSVCP_runtime_error_dtor(runtime_error *this)
702 TRACE("%p\n", this);
703 MSVCP_exception_dtor(&this->e);
704 MSVCP_basic_string_char_dtor(&this->str);
707 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_vector_dtor, 8)
708 void* __thiscall MSVCP_runtime_error_vector_dtor(
709 runtime_error *this, unsigned int flags)
711 TRACE("%p %x\n", this, flags);
712 if(flags & 2) {
713 /* we have an array, with the number of elements stored before the first object */
714 int i, *ptr = (int *)this-1;
716 for(i=*ptr-1; i>=0; i--)
717 MSVCP_runtime_error_dtor(this+i);
718 MSVCRT_operator_delete(ptr);
719 } else {
720 MSVCP_runtime_error_dtor(this);
721 if(flags & 1)
722 MSVCRT_operator_delete(this);
725 return this;
728 static const type_info runtime_error_type_info = {
729 &MSVCP_runtime_error_vtable,
730 NULL,
731 ".?AVruntime_error@std@@"
734 static const rtti_base_descriptor runtime_error_rtti_base_descriptor = {
735 &runtime_error_type_info,
737 { 0, -1, 0 },
741 static const rtti_base_array runtime_error_rtti_base_array = {
743 &runtime_error_rtti_base_descriptor,
744 &exception_rtti_base_descriptor,
745 NULL
749 static const rtti_object_hierarchy runtime_error_type_hierarchy = {
753 &runtime_error_rtti_base_array
756 const rtti_object_locator runtime_error_rtti = {
760 &runtime_error_type_info,
761 &runtime_error_type_hierarchy
764 static const cxx_type_info runtime_error_cxx_type_info = {
766 &runtime_error_type_info,
767 { 0, -1, 0 },
768 sizeof(runtime_error),
769 (cxx_copy_ctor)THISCALL(MSVCP_runtime_error_copy_ctor)
772 static const cxx_type_info_table runtime_error_cxx_type_table = {
775 &runtime_error_cxx_type_info,
776 &exception_cxx_type_info,
777 NULL
781 static const cxx_exception_type runtime_error_cxx_type = {
783 (cxx_copy_ctor)THISCALL(MSVCP_runtime_error_dtor),
784 NULL,
785 &runtime_error_cxx_type_table
788 DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_what, 4)
789 const char* __thiscall MSVCP_runtime_error_what(runtime_error *this)
791 TRACE("%p\n", this);
792 return MSVCP_basic_string_char_c_str(&this->str);
795 #ifndef __GNUC__
796 void __asm_dummy_vtables(void) {
797 #endif
798 __ASM_VTABLE(bad_alloc, VTABLE_ADD_FUNC(MSVCP_what_exception));
799 __ASM_VTABLE(logic_error, VTABLE_ADD_FUNC(MSVCP_logic_error_what));
800 __ASM_VTABLE(length_error, VTABLE_ADD_FUNC(MSVCP_logic_error_what));
801 __ASM_VTABLE(out_of_range, VTABLE_ADD_FUNC(MSVCP_logic_error_what));
802 __ASM_VTABLE(invalid_argument, VTABLE_ADD_FUNC(MSVCP_logic_error_what));
803 __ASM_VTABLE(runtime_error, VTABLE_ADD_FUNC(MSVCP_runtime_error_what));
804 #ifndef __GNUC__
806 #endif
808 /* Internal: throws selected exception */
809 void throw_exception(exception_type et, const char *str)
811 const char *addr = str;
813 switch(et) {
814 case EXCEPTION: {
815 exception e;
816 MSVCP_exception_ctor(&e, &addr);
817 _CxxThrowException(&e, &exception_cxx_type);
819 case EXCEPTION_BAD_ALLOC: {
820 bad_alloc e;
821 MSVCP_bad_alloc_ctor(&e, &addr);
822 _CxxThrowException(&e, &bad_alloc_cxx_type);
824 case EXCEPTION_LOGIC_ERROR: {
825 logic_error e;
826 MSVCP_logic_error_ctor(&e, &addr);
827 _CxxThrowException((exception*)&e, &logic_error_cxx_type);
829 case EXCEPTION_LENGTH_ERROR: {
830 length_error e;
831 MSVCP_length_error_ctor(&e, &addr);
832 _CxxThrowException((exception*)&e, &length_error_cxx_type);
834 case EXCEPTION_OUT_OF_RANGE: {
835 out_of_range e;
836 MSVCP_out_of_range_ctor(&e, &addr);
837 _CxxThrowException((exception*)&e, &out_of_range_cxx_type);
839 case EXCEPTION_INVALID_ARGUMENT: {
840 invalid_argument e;
841 MSVCP_invalid_argument_ctor(&e, &addr);
842 _CxxThrowException((exception*)&e, &invalid_argument_cxx_type);
844 case EXCEPTION_RUNTIME_ERROR: {
845 runtime_error e;
846 MSVCP_runtime_error_ctor(&e, &addr);
847 _CxxThrowException((exception*)&e, &runtime_error_cxx_type);