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