Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: frog/frog_options.dart

Issue 10548047: Remove frog from the repository. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move test and update apidoc.gyp. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/frog_leg.dart ('k') | frog/frogc.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /** General options used by the compiler. */
6 FrogOptions options;
7
8 /** Extracts options from command-line arguments. */
9 void parseOptions(String homedir, List<String> args, FileSystem files) {
10 assert(options == null);
11 options = new FrogOptions(homedir, args, files);
12 }
13
14 // TODO(sigmund): make into a generic option parser...
15 class FrogOptions {
16 /** Location of corelib and other special dart libraries. */
17 String libDir;
18
19 /* The top-level dart script to compile. */
20 String dartScript;
21
22 /* The directory to look in for "package:" scheme URIs. */
23 String packageRoot;
24
25 /** Where to place the generated code. */
26 String outfile;
27
28 // TODO(dgrove): fix this. For now, either 'sdk' or 'dev'.
29 final config = 'dev';
30
31 // Options that modify behavior significantly
32 bool legOnly = false;
33 bool allowMockCompilation = false;
34 bool enableAsserts = false;
35 bool enableTypeChecks = false;
36 bool warningsAsErrors = false;
37 bool verifyImplements = false; // TODO(jimhug): Implement
38 bool compileAll = false;
39 bool forceDynamic = false;
40 bool dietParse = false;
41 bool compileOnly = false;
42 bool inferTypes = false;
43 bool checkOnly = false;
44 bool ignoreUnrecognizedFlags = false;
45 bool emitCodeComments = false;
46
47 // Specifies non-compliant behavior where array bounds checks are
48 // not implemented in generated code.
49 bool disableBoundsChecks = false;
50
51 // Message support
52 bool throwOnErrors = false;
53 bool throwOnWarnings = false;
54 bool throwOnFatal = false;
55 bool showInfo = false;
56 bool showWarnings = true;
57 bool useColors = true;
58
59 // Not currently settable via command line.
60 // Intended for use by compiler implementer during debugging.
61 // TODO(jmesserly): what are the right values for these?
62 int maxInferenceIterations = 4;
63
64 /**
65 * Options to be used later for passing to the generated code. These are all
66 * the arguments after the first dart script, if any.
67 */
68 List<String> childArgs;
69
70 FrogOptions(String homedir, List<String> args, FileSystem files) {
71 if (config == 'dev') {
72 libDir = joinPaths(homedir, '/lib'); // Default value for --libdir.
73 } else if (config == 'sdk') {
74 libDir = joinPaths(homedir, '/../lib');
75 } else {
76 world.error('Invalid configuration $config', null);
77 throw('Invalid configuration');
78 }
79
80 bool passedLibDir = false;
81 childArgs = [];
82
83 // Start from 2 to skip arguments representing the compiler command
84 // (python followed by frog.py).
85 loop: for (int i = 2; i < args.length; i++) {
86 var arg = args[i];
87 if (tryParseSimpleOption(arg)) continue;
88 if (arg.endsWith('.dart')) {
89 dartScript = arg;
90 childArgs = args.getRange(i + 1, args.length - i - 1);
91 break loop;
92 } else if (arg.startsWith('--out=')) {
93 outfile = arg.substring('--out='.length);
94 } else if (arg.startsWith('--libdir=')) {
95 libDir = arg.substring('--libdir='.length);
96 passedLibDir = true;
97 } else if (arg.startsWith('--package-root')) {
98 packageRoot = arg.substring('--package-root='.length);
99 } else if (!ignoreUnrecognizedFlags) {
100 print('unrecognized flag: "$arg"');
101 }
102 }
103
104 // TODO(jimhug): Remove this hack.
105 if (!passedLibDir && config == 'dev' && !files.fileExists(libDir)) {
106 // Try locally
107 var temp = 'frog/lib';
108 if (files.fileExists(temp)) {
109 libDir = temp;
110 } else {
111 libDir = 'lib';
112 }
113 }
114 }
115
116 bool tryParseSimpleOption(String option) {
117 if (!option.startsWith('--')) return false;
118 switch (option.replaceAll('_', '-')) {
119 case '--leg':
120 case '--enable-leg':
121 case '--leg-only':
122 legOnly = true;
123 return true;
124
125 case '--allow-mock-compilation':
126 allowMockCompilation = true;
127 return true;
128
129 case '--enable-asserts':
130 enableAsserts = true;
131 return true;
132
133 case '--enable-type-checks':
134 enableTypeChecks = true;
135 enableAsserts = true; // TODO(kasperl): Remove once VM stops.
136 return true;
137
138 case '--verify-implements':
139 verifyImplements = true;
140 return true;
141
142 case '--compile-all':
143 compileAll = true;
144 return true;
145
146 case '--check-only':
147 checkOnly = true;
148 return true;
149
150 case '--diet-parse':
151 dietParse = true;
152 return true;
153
154 case '--ignore-unrecognized-flags':
155 ignoreUnrecognizedFlags = true;
156 return true;
157
158 case '--verbose':
159 showInfo = true;
160 return true;
161
162 case '--suppress-warnings':
163 showWarnings = false;
164 return true;
165
166 case '--warnings-as-errors':
167 warningsAsErrors = true;
168 return true;
169
170 case '--throw-on-errors':
171 throwOnErrors = true;
172 return true;
173
174 case '--throw-on-warnings':
175 throwOnWarnings = true;
176 return true;
177
178 case '--compile-only':
179 // As opposed to compiling and running, the default behavior.
180 compileOnly = true;
181 return true;
182
183 case '--Xforce-dynamic':
184 forceDynamic = true;
185 return true;
186
187 case '--no-colors':
188 useColors = false;
189 return true;
190
191 case '--Xinfer-types':
192 inferTypes = true;
193 return true;
194
195 case '--enable-checked-mode':
196 case '--checked':
197 enableTypeChecks = true;
198 enableAsserts = true;
199 return true;
200
201 case '--unchecked':
202 disableBoundsChecks = true;
203 return true;
204
205 case '--emit-code-comments':
206 emitCodeComments = true;
207 return true;
208 }
209 return false;
210 }
211 }
OLDNEW
« no previous file with comments | « frog/frog_leg.dart ('k') | frog/frogc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698