OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 | 7 |
8 import 'package:analyzer/analyzer.dart'; | 8 import 'package:analyzer/analyzer.dart'; |
9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 10 import 'package:collection/collection.dart'; |
10 import 'package:path/path.dart' as p; | 11 import 'package:path/path.dart' as p; |
11 import 'package:pool/pool.dart'; | 12 import 'package:pool/pool.dart'; |
12 | 13 |
13 import 'package:compiler_unsupported/compiler.dart' as compiler; | 14 import 'package:compiler_unsupported/compiler.dart' as compiler; |
14 import 'package:compiler_unsupported/src/dart2js.dart' | 15 import 'package:compiler_unsupported/src/dart2js.dart' |
15 show AbortLeg; | 16 show AbortLeg; |
16 import 'package:compiler_unsupported/src/io/source_file.dart'; | 17 import 'package:compiler_unsupported/src/io/source_file.dart'; |
17 import '../barback.dart'; | 18 import '../barback.dart'; |
18 import '../dart.dart' as dart; | 19 import '../dart.dart' as dart; |
19 import '../utils.dart'; | 20 import '../utils.dart'; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 terse: _configBool('terse'), | 148 terse: _configBool('terse'), |
148 includeSourceMapUrls: _generateSourceMaps); | 149 includeSourceMapUrls: _generateSourceMaps); |
149 } | 150 } |
150 | 151 |
151 /// Parses and returns the "commandLineOptions" configuration option. | 152 /// Parses and returns the "commandLineOptions" configuration option. |
152 List<String> get _configCommandLineOptions { | 153 List<String> get _configCommandLineOptions { |
153 if (!_settings.configuration.containsKey('commandLineOptions')) return null; | 154 if (!_settings.configuration.containsKey('commandLineOptions')) return null; |
154 | 155 |
155 var options = _settings.configuration['commandLineOptions']; | 156 var options = _settings.configuration['commandLineOptions']; |
156 if (options is List && options.every((option) => option is String)) { | 157 if (options is List && options.every((option) => option is String)) { |
157 return options; | 158 return DelegatingList.typed(options); |
158 } | 159 } |
159 | 160 |
160 throw new FormatException('Invalid value for ' | 161 throw new FormatException('Invalid value for ' |
161 '\$dart2js.commandLineOptions: ${JSON.encode(options)} (expected list ' | 162 '\$dart2js.commandLineOptions: ${JSON.encode(options)} (expected list ' |
162 'of strings).'); | 163 'of strings).'); |
163 } | 164 } |
164 | 165 |
165 /// Parses and returns the "environment" configuration option. | 166 /// Parses and returns the "environment" configuration option. |
166 Map<String, String> get _configEnvironment { | 167 Map<String, String> get _configEnvironment { |
167 if (!_settings.configuration.containsKey('environment')) { | 168 if (!_settings.configuration.containsKey('environment')) { |
168 return _environment.environmentConstants; | 169 return _environment.environmentConstants; |
169 } | 170 } |
170 | 171 |
171 var environment = _settings.configuration['environment']; | 172 var environment = _settings.configuration['environment']; |
172 if (environment is Map && | 173 if (environment is Map && |
173 environment.keys.every((key) => key is String) && | 174 environment.keys.every((key) => key is String) && |
174 environment.values.every((key) => key is String)) { | 175 environment.values.every((key) => key is String)) { |
175 return mergeMaps(environment, _environment.environmentConstants); | 176 return mergeMaps( |
| 177 DelegatingMap.typed(environment), |
| 178 _environment.environmentConstants); |
176 } | 179 } |
177 | 180 |
178 throw new FormatException('Invalid value for \$dart2js.environment: ' | 181 throw new FormatException('Invalid value for \$dart2js.environment: ' |
179 '${JSON.encode(environment)} (expected map from strings to strings).'); | 182 '${JSON.encode(environment)} (expected map from strings to strings).'); |
180 } | 183 } |
181 | 184 |
182 /// Parses and returns a boolean configuration option. | 185 /// Parses and returns a boolean configuration option. |
183 /// | 186 /// |
184 /// [defaultsTo] is the default value of the option. | 187 /// [defaultsTo] is the default value of the option. |
185 bool _configBool(String name, {bool defaultsTo: false}) { | 188 bool _configBool(String name, {bool defaultsTo: false}) { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } | 412 } |
410 } | 413 } |
411 | 414 |
412 /// An [EventSink] that discards all data. Provided to dart2js when we don't | 415 /// An [EventSink] that discards all data. Provided to dart2js when we don't |
413 /// want an actual output. | 416 /// want an actual output. |
414 class NullSink<T> implements EventSink<T> { | 417 class NullSink<T> implements EventSink<T> { |
415 void add(T event) {} | 418 void add(T event) {} |
416 void addError(errorEvent, [StackTrace stackTrace]) {} | 419 void addError(errorEvent, [StackTrace stackTrace]) {} |
417 void close() {} | 420 void close() {} |
418 } | 421 } |
OLD | NEW |