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

Unified Diff: sdk/lib/_internal/compiler/implementation/dart2js.dart

Issue 48323003: Implement fromEnvironment on bool, int, String in dart2js. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/dart2js.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/dart2js.dart (revision 29517)
+++ sdk/lib/_internal/compiler/implementation/dart2js.dart (working copy)
@@ -112,6 +112,7 @@
// TODO(johnniwinther): Measure time for reading files.
SourceFileProvider inputProvider = new CompilerSourceFileProvider();
diagnosticHandler = new FormattingDiagnosticHandler(inputProvider);
+ Map<String, dynamic> environment = new Map<String, dynamic>();
passThrough(String argument) => options.add(argument);
@@ -174,6 +175,24 @@
passThrough('--verbose');
}
+ addInEnvironment(String argument) {
+ Match m = new RegExp('^-D(.+)=(.+)').firstMatch(argument);
ahe 2013/10/30 13:03:09 Terminate with $.
Lasse Reichstein Nielsen 2013/10/30 13:34:48 Terminating isn't necessary. The last capture is g
ngeoffray 2013/10/30 15:13:59 Done.
+ String name = m[1];
+ String value = m[2];
+ if (value == 'true') {
+ environment[name] = true;
Lasse Reichstein Nielsen 2013/10/30 13:34:48 Why parse the arguments here? Even if the value is
kasperl 2013/10/30 13:49:56 I agree with Lasse here. It seems cleaner to do th
ngeoffray 2013/10/30 15:13:59 Done.
+ } else if (value == 'false') {
+ environment[name] = false;
+ } else {
+ int number = int.parse(value, onError: (_) => null);
+ if (number == null) {
+ environment[name] = value;
+ } else {
+ environment[name] = number;
+ }
+ }
+ }
+
setCategories(String argument) {
List<String> categories = extractParameter(argument).split(',');
Set<String> allowedCategories =
@@ -275,6 +294,7 @@
new OptionHandler('--terse', passThrough),
new OptionHandler('--disallow-unsafe-eval',
(_) => hasDisallowUnsafeEval = true),
+ new OptionHandler('-D.+=.+', addInEnvironment),
// The following two options must come last.
new OptionHandler('-.*', (String argument) {
@@ -411,7 +431,7 @@
return api.compile(uri, libraryRoot, packageRoot,
inputProvider, diagnosticHandler,
- options, outputProvider)
+ options, outputProvider, environment)
.then(compilationDone);
}

Powered by Google App Engine
This is Rietveld 408576698