* Fixed includes
[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 2959 2005-07-09 17:30:32Z twisti $
30
31 */
32
33
34 #include <string.h>
35
36 #include "config.h"
37 #include "types.h"
38
39 #include "vm/options.h"
40
41
42 /* command line option */
43
44 bool opt_verbose = false;
45 bool compileall = false;
46 bool runverbose = false;       /* trace all method invocation                */
47 bool verboseexception = false;
48
49 bool loadverbose = false;
50 bool linkverbose = false;
51 bool initverbose = false;
52 bool opt_verbosegc = false;
53 bool opt_verbosejni = false;
54
55 bool opt_rt = false;           /* true if RTA parse should be used     RT-CO  */
56 bool opt_xta = false;          /* true if XTA parse should be used    XTA-CO  */
57 bool opt_vta = false;          /* true if VTA parse should be used    VTA-CO  */
58
59 bool opt_liberalutf = false;   /* Don't check overlong UTF-8 sequences        */
60
61 bool showmethods = false;
62 bool showconstantpool = false;
63 bool showutf = false;
64
65 bool compileverbose =  false;           /* trace compiler actions             */
66 bool showstack = false;
67 bool opt_showdisassemble = false;       /* generate disassembler listing      */
68 bool opt_showddatasegment = false;      /* generate data segment listing      */
69 bool opt_showintermediate = false;      /* generate intermediate code listing */
70 bool opt_showexceptionstubs = false;
71 bool opt_shownativestub = false;
72
73 bool useinliningm = false;      /* use method inlining                        */
74 bool useinlining = false;      /* use method inlining                        */
75 bool inlinevirtuals = false;   /* inline unique virtual methods              */
76 bool inlineexceptions = false; /* inline methods, that contain excptions     */
77 bool inlineparamopt = false;   /* optimize parameter passing to inlined methods */
78 bool inlineoutsiders = false;  /* inline methods, that are not member of the invoker's class */
79
80 bool checkbounds = true;       /* check array bounds                         */
81 bool checknull = true;         /* check null pointers                        */
82 bool opt_noieee = false;       /* don't implement ieee compliant floats      */
83 bool checksync = true;         /* do synchronization                         */
84 bool opt_loops = false;        /* optimize array accesses in loops           */
85
86 bool makeinitializations = true;
87
88 bool getloadingtime = false;   /* to measure the runtime                     */
89 bool getcompilingtime = false; /* compute compile time                       */
90
91 int has_ext_instr_set = 0;     /* has instruction set extensions */
92
93 bool opt_stat = false;
94 bool opt_verify = true;        /* true if classfiles should be verified      */
95 bool opt_eager = false;
96 #ifdef LSRA
97 bool opt_lsra = false;
98 #endif
99 int opt_ind = 1;               /* index of processed arguments               */
100 char *opt_arg;                 /* this one exports the option argument       */
101
102
103 /* get_opt *********************************************************************
104
105    DOCUMENT ME!!!
106
107 *******************************************************************************/
108
109 int get_opt(int argc, char **argv, opt_struct *opts)
110 {
111         char *a;
112         s4    i;
113         
114         if (opt_ind >= argc)
115                 return OPT_DONE;
116         
117         a = argv[opt_ind];
118
119         if (a[0] != '-')
120                 return OPT_DONE;
121
122         for (i = 0; opts[i].name; i++) {
123                 if (!opts[i].arg) {
124                         /* boolean option found */
125
126                         if (strcmp(a + 1, opts[i].name) == 0) {
127                                 opt_ind++;
128                                 return opts[i].value;
129                         }
130
131                 } else {
132                         /* parameter option found */
133
134                         /* with a space between */
135
136                         if (strcmp(a + 1, opts[i].name) == 0) {
137                                 opt_ind++;
138
139                                 if (opt_ind < argc) {
140                                         opt_arg = argv[opt_ind];
141                                         opt_ind++;
142                                         return opts[i].value;
143                                 }
144
145                                 return OPT_ERROR;
146
147                         } else {
148                                 /* parameter and option have no space between */
149
150                                 size_t l = strlen(opts[i].name);
151                                 if (strlen(a + 1) > l) {
152                                         if (memcmp(a + 1, opts[i].name, l) == 0) {
153                                                 opt_ind++;
154                                                 opt_arg = a + 1 + l;
155                                                 return opts[i].value;
156                                         }
157                                 }
158                         }
159                 }
160         } /* end for */ 
161
162         return OPT_ERROR;
163 }
164
165
166 /*
167  * These are local overrides for various environment variables in Emacs.
168  * Please do not remove this and leave it at the end of the file, where
169  * Emacs will automagically detect them.
170  * ---------------------------------------------------------------------
171  * Local variables:
172  * mode: c
173  * indent-tabs-mode: t
174  * c-basic-offset: 4
175  * tab-width: 4
176  * End:
177  */