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