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

Unified Diff: pkg/dev_compiler/lib/src/analyzer/context.dart

Issue 2503803004: fix #27784 and fix #27785, fromEnvironment constants in DDC (Closed)
Patch Set: fix Created 4 years, 1 month 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
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/lib/src/compiler/code_generator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/src/analyzer/context.dart
diff --git a/pkg/dev_compiler/lib/src/analyzer/context.dart b/pkg/dev_compiler/lib/src/analyzer/context.dart
index 209c2fe386ee0b1f97d908a5e52548781c70c094..5617f7fe4c8be5630b656c4d0c52962c05fbabef 100644
--- a/pkg/dev_compiler/lib/src/analyzer/context.dart
+++ b/pkg/dev_compiler/lib/src/analyzer/context.dart
@@ -46,16 +46,21 @@ class AnalyzerOptions {
/// of the unsummarized one.
final String dartSdkSummaryPath;
+ /// Defined variables used by `bool.fromEnvironment` etc.
+ final Map<String, String> declaredVariables;
+
AnalyzerOptions(
{this.summaryPaths: const [],
String dartSdkPath,
this.dartSdkSummaryPath,
this.customUrlMappings: const {},
this.packageRoot: null,
- this.packagePaths: const []})
+ this.packagePaths: const [],
+ this.declaredVariables: const {}})
: dartSdkPath = dartSdkPath ?? getSdkDir().path;
- factory AnalyzerOptions.fromArguments(ArgResults args) {
+ factory AnalyzerOptions.fromArguments(
+ ArgResults args, Map<String, String> declaredVariables) {
var sdkPath = args['dart-sdk'] ?? getSdkDir().path;
var sdkSummaryPath = args['dart-sdk-summary'];
@@ -72,7 +77,8 @@ class AnalyzerOptions {
dartSdkSummaryPath: sdkSummaryPath,
customUrlMappings: _parseUrlMappings(args['url-mapping']),
packageRoot: args['package-root'],
- packagePaths: (args['package-paths'] as String)?.split(',') ?? []);
+ packagePaths: (args['package-paths'] as String)?.split(',') ?? [],
+ declaredVariables: declaredVariables);
}
/// Whether to resolve 'package:' uris using the multi-package resolver.
@@ -186,3 +192,25 @@ DartUriResolver createSdkPathResolver(String sdkSummaryPath, String sdkPath) {
: _createFolderBasedDartSdk(sdkPath);
return new DartUriResolver(sdk);
}
+
+List<String> parseDeclaredVariables(
+ List<String> args, Map<String, String> declaredVars) {
+ var count = args.length;
+ var remainingArgs = <String>[];
+ for (int i = 0; i < count; i++) {
+ var arg = args[i];
+ if (arg == '--') {
+ while (i < count) {
+ remainingArgs.add(args[i++]);
+ }
+ } else if (arg.startsWith("-D")) {
+ // The format for defined variables is:
+ // -D<name>=<value>
+ var parts = arg.substring(2).split('=');
+ declaredVars[parts[0]] = parts.length > 1 ? parts[1] : '';
+ } else {
+ remainingArgs.add(arg);
+ }
+ }
+ return remainingArgs;
+}
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/lib/src/compiler/code_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698