Removed return value from descriptor_params_from_paramtypes.
[cacao.git] / src / vm / assertion.cpp
1 /* src/vm/assertion.cpp - assertion options
2
3    Copyright (C) 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #include "config.h"
27
28 #include <stdint.h>
29
30 #include <cstddef>
31
32 #include "mm/memory.hpp"
33
34 #include "toolbox/list.hpp"
35
36 #include "vm/assertion.hpp"
37 #include "vm/global.h"
38 #include "vm/os.hpp"
39
40
41 /* -ea/-da options ************************************************************/
42
43 List<assertion_name_t*>* list_assertion_names = NULL;
44 int32_t  assertion_class_count    = 0;
45 int32_t  assertion_package_count  = 0;
46 bool     assertion_user_enabled   = false;
47 bool     assertion_system_enabled = false;
48
49
50 /* assertion_ea_da *************************************************************
51
52    Handle -ea:/-enableassertions: and -da:/-disableassertions: options.
53
54 *******************************************************************************/
55
56 void assertion_ea_da(const char *name, bool enabled)
57 {
58         bool              package;
59         size_t            len;
60         char             *buf;
61         assertion_name_t *item;
62
63         if (name == NULL) {
64                 assertion_user_enabled = enabled;
65                 return;
66         }
67
68         package = false;
69         len     = os::strlen(name);
70
71         if (name[len - 1] == '/') {
72                 return;
73         }
74
75         buf = os::strdup(name);
76
77         if (buf == NULL) {
78                 os::abort_errno("assertion_ea_da: strdup failed");
79         }
80
81         if ((len > 2) && (strcmp(name + (len - 3), "...") == 0)) {
82                 package = true;
83                 assertion_package_count += 1;
84 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
85                 buf[len - 2] = '\0';
86                 buf[len - 3] = '/';
87 #else
88                 buf[len - 3] = '\0';
89 #endif
90         }
91         else {
92                 assertion_class_count += 1;
93         }
94
95         len = os::strlen(buf);
96
97         for (size_t i = 0; i < len; i++) {
98 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
99                 if (buf[i] == '.') {
100                         buf[i] = '/';
101                 }
102 #else
103                 if (buf[i] == '/') {
104                         buf[i] = '.';
105                 }
106 #endif
107         }
108
109         item          = NEW(assertion_name_t);
110         item->name    = buf;
111         item->enabled = enabled;
112         item->package = package;
113
114         if (list_assertion_names == NULL) {
115                 list_assertion_names = new List<assertion_name_t*>();
116         }
117
118         list_assertion_names->push_back(item);
119 }
120
121
122 /*
123  * These are local overrides for various environment variables in Emacs.
124  * Please do not remove this and leave it at the end of the file, where
125  * Emacs will automagically detect them.
126  * ---------------------------------------------------------------------
127  * Local variables:
128  * mode: c++
129  * indent-tabs-mode: t
130  * c-basic-offset: 4
131  * tab-width: 4
132  * End:
133  * vim:noexpandtab:sw=4:ts=4:
134  */