1 // $Id: jikes.cpp,v 1.98 2004/03/20 04:48:17 jikesadmin Exp $
2 //
3 // This software is subject to the terms of the IBM Jikes Compiler
4 // License Agreement available at the following URL:
5 // http://ibm.com/developerworks/opensource/jikes.
6 // Copyright (C) 1996, 2004 IBM Corporation and others. All Rights Reserved.
7 // You must accept the terms of that agreement to use this software.
8 //
9
10 #include "platform.h"
11 #include "jikesapi.h"
12 #include "error.h"
13
14 #ifdef HAVE_JIKES_NAMESPACE
15 using namespace Jikes;
16 #endif
17
main(int argc,char * argv[])18 int main(int argc, char *argv[])
19 {
20 // Here we are creating instance of default API
21 JikesAPI *compiler = new JikesAPI();
22
23 int return_code;
24 char **files;
25
26 files = compiler -> parseOptions(argc, argv);
27
28 if (compiler -> getOptions() -> help)
29 {
30 printf("%s%s", StringConstant::U8S_help_header,
31 StringConstant::U8S_command_format);
32 printf("\n"
33 "\tRegular options:\n"
34 "-bootclasspath path location of system classes [default '']\n"
35 "-classpath path location of user classes and source files [default .]\n"
36 "-d dir write class files in directory dir [default .]\n"
37 "-debug no effect (ignored for compatibility)\n"
38 "-depend | -Xdepend recompile all used classes\n"
39 "-deprecation report uses of deprecated features\n"
40 #if defined(HAVE_ENCODING)
41 "-encoding encoding use specified encoding to read source files\n"
42 " [default is system and locale dependent]\n"
43 # if defined(HAVE_LIBICU_UC)
44 " this binary requires the ICU library\n"
45 # endif
46 #endif
47 "-extdirs path location of zip/jar files with platform extensions\n"
48 " [default '']\n"
49 "-g | -g:none | -g:{lines,vars,source}\n"
50 " control level of debug information in class files\n"
51 " [default lines,source]\n"
52 "-J... no effect (ignored for compatibility)\n"
53 "-nowarn javac-compatible equivalent of +Z0\n"
54 "-nowrite do not write any class files, useful with -verbose\n"
55 "-O optimize bytecode (presently does nothing)\n"
56 "-source release interpret source by Java SDK release rules\n"
57 " [default to max(target, 1.4)]\n"
58 "-sourcepath path location of user source files [default '']\n"
59 "-target release output bytecode for Java SDK release rules\n"
60 " [default to source if specified, else 1.4.2]\n"
61 "-verbose list files read and written\n"
62 "-Werror javac-compatible equivalent of +Z2\n"
63 "-Xstdout redirect output listings to stdout\n"
64 "-Xswitchcheck warn about fallthrough between switch statement cases\n"
65 "\tEnhanced options:\n"
66 "++ compile in incremental mode\n"
67 "+a omit assert statements from class files\n"
68 "+B do not invoke bytecode generator\n"
69 "+D report errors immediately in emacs-form without buffering\n"
70 "+DR=filename generate dependence report in filename\n"
71 "+E list errors in emacs-form\n"
72 "+F do full dependence check except for Zip and Jar files\n"
73 "+Kname=TypeKeyWord map name to type keyword\n"
74 "+M generate makefile dependencies\n"
75 "+OLDCSO perform original Jikes classpath order for compatibility\n"
76 "+P pedantic compilation - issues lots of warnings\n"
77 " some warnings can be turned on or off independently:\n");
78
79 SemanticError::PrintNamedWarnings();
80
81 printf("+T=n set value of tab to n spaces, defaults to 8\n"
82 "+U do full dependence check including Zip and Jar files\n"
83 "+Z0 do not issue warning messages\n"
84 "+Z1 treat cautions as errors\n"
85 "+Z2 treat both warnings and cautions as errors\n"
86 "+Z equivalent to +Z1\n"
87 #ifdef JIKES_DEBUG
88 "\tDebugging options:\n"
89 "+A dump AST to standard output\n"
90 "+c do not discard comments from lexer output, use with +L\n"
91 "+C dump bytecodes to standard output\n"
92 "+L dump lexer output (stream of tokens) to file.java.tok\n"
93 "+O numbytes call no-op op_trap() for bytecodes of the given length\n"
94 "+S trace method stack depth to standard output\n"
95 "+u unparse AST; produces Java code for the AST\n"
96 "+ud unparse AST, with extra debugging information\n"
97 #endif
98 "\tMiscellaneous options:\n"
99 "-help | --help display this message and exit\n"
100 "-version | --version display version and contact information, and exit\n");
101
102 return_code = 0;
103 }
104 else if (compiler -> getOptions() -> version)
105 {
106 printf("%s", StringConstant::U8S_help_header);
107 printf("Originally written by Philippe Charles and David Shields of IBM Research,\n"
108 "Jikes is now maintained and refined by the Jikes Project at:\n"
109 "<http://ibm.com/developerworks/opensource/jikes>\n"
110 "Please consult this URL for more information and for reporting problems.\n");
111
112 return_code = 0;
113 }
114 else if (files && files[0])
115 {
116 return_code = compiler -> compile(files);
117 }
118 else
119 {
120 printf("%s", StringConstant::U8S_command_format);
121 printf("For more help, try -help or -version.\n");
122
123 return_code = 2;
124 }
125
126 delete compiler;
127 return return_code;
128 }
129