Changed field name className to new declaringClass.
[cacao.git] / options.c
index f4d9b8ee6a27e4ca056bdc15972255fb8e869447..ccb776148f483dcc58d91206c9b14ad160941906 100644 (file)
--- a/options.c
+++ b/options.c
 
    Authors: Christian Thalinger
 
-   $Id: options.c 1223 2004-06-30 19:13:00Z twisti $
+   $Id: options.c 1546 2004-11-18 12:25:04Z twisti $
 
 */
 
 
-#include "global.h"
+#include <string.h>
+#include "options.h"
+#include "types.h"
 
 
 /* command line option */
 
-bool verbose = false;
+bool opt_verbose = false;
 bool compileall = false;
 bool runverbose = false;       /* trace all method invocation                */
 bool verboseexception = false;
@@ -63,6 +65,7 @@ bool showdisassemble = false;  /* generate disassembler listing              */
 bool showddatasegment = false; /* generate data segment listing              */
 bool showintermediate = false; /* generate intermediate code listing         */
 
+bool useinliningm = false;      /* use method inlining                        */
 bool useinlining = false;      /* use method inlining                        */
 bool inlinevirtuals = false;   /* inline unique virtual methods              */
 bool inlineexceptions = false; /* inline methods, that contain excptions     */
@@ -87,6 +90,62 @@ bool opt_verify = true;        /* true if classfiles should be verified      */
 bool opt_eager = false;
 
 
+int opt_ind = 1;               /* index of processed arguments               */
+char *opt_arg;                 /* this one exports the option argument       */
+
+
+/* get_opt *********************************************************************
+
+   DOCUMENT ME!!!
+
+*******************************************************************************/
+
+int get_opt(int argc, char **argv, opt_struct *opts)
+{
+       char *a;
+       int i;
+       
+       if (opt_ind >= argc)
+               return OPT_DONE;
+       
+       a = argv[opt_ind];
+       if (a[0] != '-')
+               return OPT_DONE;
+
+       for (i = 0; opts[i].name; i++) {
+               if (!opts[i].arg) {
+                       if (strcmp(a + 1, opts[i].name) == 0) { /* boolean option found */
+                               opt_ind++;
+                               return opts[i].value;
+                       }
+
+               } else {
+                       if (strcmp(a + 1, opts[i].name) == 0) { /* parameter option found */
+                               opt_ind++;
+                               if (opt_ind < argc) {
+                                       opt_arg = argv[opt_ind];
+                                       opt_ind++;
+                                       return opts[i].value;
+                               }
+                               return OPT_ERROR;
+
+                       } else {
+                               size_t l = strlen(opts[i].name);
+                               if (strlen(a + 1) > l) {
+                                       if (memcmp(a + 1, opts[i].name, l) == 0) {
+                                               opt_ind++;
+                                               opt_arg = a + 1 + l;
+                                               return opts[i].value;
+                                       }
+                               }
+                       }
+               }
+       } /* end for */ 
+
+       return OPT_ERROR;
+}
+
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where