* opt_showexceptionstubs: added
[cacao.git] / src / vm / options.c
1 /* options.c - contains global options
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Thalinger
28
29    $Id: options.c 2950 2005-07-09 13:37:29Z twisti $
30
31 */
32
33
34 #include <string.h>
35 #include "options.h"
36 #include "types.h"
37
38
39 /* command line option */
40
41 bool opt_verbose = false;
42 bool compileall = false;
43 bool runverbose = false;       /* trace all method invocation                */
44 bool verboseexception = false;
45
46 bool loadverbose = false;
47 bool linkverbose = false;
48 bool initverbose = false;
49 bool opt_verbosegc = false;
50 bool opt_verbosejni = false;
51
52 bool opt_rt = false;           /* true if RTA parse should be used     RT-CO  */
53 bool opt_xta = false;          /* true if XTA parse should be used    XTA-CO  */
54 bool opt_vta = false;          /* true if VTA parse should be used    VTA-CO  */
55
56 bool opt_liberalutf = false;   /* Don't check overlong UTF-8 sequences        */
57
58 bool showmethods = false;
59 bool showconstantpool = false;
60 bool showutf = false;
61
62 bool compileverbose =  false;           /* trace compiler actions             */
63 bool showstack = false;
64 bool opt_showdisassemble = false;       /* generate disassembler listing      */
65 bool opt_showddatasegment = false;      /* generate data segment listing      */
66 bool opt_showintermediate = false;      /* generate intermediate code listing */
67 bool opt_showexceptionstubs = false;
68 bool opt_shownativestub = false;
69
70 bool useinliningm = false;      /* use method inlining                        */
71 bool useinlining = false;      /* use method inlining                        */
72 bool inlinevirtuals = false;   /* inline unique virtual methods              */
73 bool inlineexceptions = false; /* inline methods, that contain excptions     */
74 bool inlineparamopt = false;   /* optimize parameter passing to inlined methods */
75 bool inlineoutsiders = false;  /* inline methods, that are not member of the invoker's class */
76
77 bool checkbounds = true;       /* check array bounds                         */
78 bool checknull = true;         /* check null pointers                        */
79 bool opt_noieee = false;       /* don't implement ieee compliant floats      */
80 bool checksync = true;         /* do synchronization                         */
81 bool opt_loops = false;        /* optimize array accesses in loops           */
82
83 bool makeinitializations = true;
84
85 bool getloadingtime = false;   /* to measure the runtime                     */
86 bool getcompilingtime = false; /* compute compile time                       */
87
88 int has_ext_instr_set = 0;     /* has instruction set extensions */
89
90 bool opt_stat = false;
91 bool opt_verify = true;        /* true if classfiles should be verified      */
92 bool opt_eager = false;
93 #ifdef LSRA
94 bool opt_lsra = false;
95 #endif
96 int opt_ind = 1;               /* index of processed arguments               */
97 char *opt_arg;                 /* this one exports the option argument       */
98
99
100 /* get_opt *********************************************************************
101
102    DOCUMENT ME!!!
103
104 *******************************************************************************/
105
106 int get_opt(int argc, char **argv, opt_struct *opts)
107 {
108         char *a;
109         s4    i;
110         
111         if (opt_ind >= argc)
112                 return OPT_DONE;
113         
114         a = argv[opt_ind];
115
116         if (a[0] != '-')
117                 return OPT_DONE;
118
119         for (i = 0; opts[i].name; i++) {
120                 if (!opts[i].arg) {
121                         /* boolean option found */
122
123                         if (strcmp(a + 1, opts[i].name) == 0) {
124                                 opt_ind++;
125                                 return opts[i].value;
126                         }
127
128                 } else {
129                         /* parameter option found */
130
131                         /* with a space between */
132
133                         if (strcmp(a + 1, opts[i].name) == 0) {
134                                 opt_ind++;
135
136                                 if (opt_ind < argc) {
137                                         opt_arg = argv[opt_ind];
138                                         opt_ind++;
139                                         return opts[i].value;
140                                 }
141
142                                 return OPT_ERROR;
143
144                         } else {
145                                 /* parameter and option have no space between */
146
147                                 size_t l = strlen(opts[i].name);
148                                 if (strlen(a + 1) > l) {
149                                         if (memcmp(a + 1, opts[i].name, l) == 0) {
150                                                 opt_ind++;
151                                                 opt_arg = a + 1 + l;
152                                                 return opts[i].value;
153                                         }
154                                 }
155                         }
156                 }
157         } /* end for */ 
158
159         return OPT_ERROR;
160 }
161
162
163 /*
164  * These are local overrides for various environment variables in Emacs.
165  * Please do not remove this and leave it at the end of the file, where
166  * Emacs will automagically detect them.
167  * ---------------------------------------------------------------------
168  * Local variables:
169  * mode: c
170  * indent-tabs-mode: t
171  * c-basic-offset: 4
172  * tab-width: 4
173  * End:
174  */