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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/compiler.dart

Issue 2647323006: Reland c9e1b88 and 56726fc with a DDC fix. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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:collection' show HashSet, Queue; 5 import 'dart:collection' show HashSet, Queue;
6 import 'dart:convert' show BASE64, JSON, UTF8; 6 import 'dart:convert' show BASE64, JSON, UTF8;
7 import 'dart:io' show File; 7 import 'dart:io' show File;
8 import 'package:analyzer/dart/element/element.dart' show LibraryElement; 8
9 import 'package:analyzer/analyzer.dart' 9 import 'package:analyzer/analyzer.dart'
10 show AnalysisError, CompilationUnit, ErrorSeverity; 10 show AnalysisError, CompilationUnit, ErrorSeverity;
11 import 'package:analyzer/dart/element/element.dart' show LibraryElement;
11 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider; 12 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider;
12 import 'package:analyzer/file_system/physical_file_system.dart' 13 import 'package:analyzer/file_system/physical_file_system.dart'
13 show PhysicalResourceProvider; 14 show PhysicalResourceProvider;
14 import 'package:analyzer/src/context/builder.dart' show ContextBuilder; 15 import 'package:analyzer/src/context/builder.dart' show ContextBuilder;
15 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; 16 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl;
17 import 'package:analyzer/src/error/codes.dart' show StaticTypeWarningCode;
16 import 'package:analyzer/src/generated/engine.dart' 18 import 'package:analyzer/src/generated/engine.dart'
17 show AnalysisContext, AnalysisEngine; 19 show AnalysisContext, AnalysisEngine;
18 import 'package:analyzer/src/generated/sdk.dart' show DartSdkManager; 20 import 'package:analyzer/src/generated/sdk.dart' show DartSdkManager;
19 import 'package:analyzer/src/generated/source.dart' 21 import 'package:analyzer/src/generated/source.dart'
20 show ContentCache, DartUriResolver; 22 show ContentCache, DartUriResolver;
21 import 'package:analyzer/src/generated/source_io.dart' 23 import 'package:analyzer/src/generated/source_io.dart'
22 show Source, SourceKind, UriResolver; 24 show Source, SourceKind, UriResolver;
23 import 'package:analyzer/src/summary/package_bundle_reader.dart' 25 import 'package:analyzer/src/summary/package_bundle_reader.dart'
24 show InSummarySource, InputPackagesResultProvider, SummaryDataStore; 26 show InSummarySource, InputPackagesResultProvider, SummaryDataStore;
25 import 'package:analyzer/src/error/codes.dart' show StaticTypeWarningCode;
26 import 'package:args/args.dart' show ArgParser, ArgResults; 27 import 'package:args/args.dart' show ArgParser, ArgResults;
27 import 'package:args/src/usage_exception.dart' show UsageException; 28 import 'package:args/src/usage_exception.dart' show UsageException;
28 import 'package:func/func.dart' show Func1; 29 import 'package:func/func.dart' show Func1;
29 import 'package:path/path.dart' as path; 30 import 'package:path/path.dart' as path;
30 import 'package:source_maps/source_maps.dart'; 31 import 'package:source_maps/source_maps.dart';
31 32
32 import '../analyzer/context.dart' show AnalyzerOptions, createSourceFactory; 33 import '../analyzer/context.dart' show AnalyzerOptions, createSourceFactory;
33 import '../js_ast/js_ast.dart' as JS; 34 import '../js_ast/js_ast.dart' as JS;
34 import 'code_generator.dart' show CodeGenerator; 35 import 'code_generator.dart' show CodeGenerator;
35 import 'error_helpers.dart' show errorSeverity, formatError, sortErrors; 36 import 'error_helpers.dart' show errorSeverity, formatError, sortErrors;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 options: options.contextBuilderOptions); 80 options: options.contextBuilderOptions);
80 81
81 var analysisOptions = contextBuilder.getAnalysisOptions(analysisRoot); 82 var analysisOptions = contextBuilder.getAnalysisOptions(analysisRoot);
82 var sdk = contextBuilder.findSdk(null, analysisOptions); 83 var sdk = contextBuilder.findSdk(null, analysisOptions);
83 84
84 var sdkResolver = new DartUriResolver(sdk); 85 var sdkResolver = new DartUriResolver(sdk);
85 86
86 // Read the summaries. 87 // Read the summaries.
87 var summaryData = 88 var summaryData =
88 new SummaryDataStore(options.summaryPaths, recordDependencyInfo: true); 89 new SummaryDataStore(options.summaryPaths, recordDependencyInfo: true);
90 var sdkSummaryBundle = sdk.getLinkedBundle();
vsm 2017/01/24 16:41:41 This logic really needs to be folded in with the r
scheglov 2017/01/24 17:04:33 It is possible. But it does not seem very useful.
vsm 2017/01/24 17:10:35 The current state means bugs like this need to be
scheglov 2017/01/24 17:13:07 Exactly. This code duplication should be solved fo
91 if (sdkSummaryBundle != null) {
92 summaryData.addBundle(null, sdkSummaryBundle);
93 }
89 94
90 var srcFactory = createSourceFactory(options, 95 var srcFactory = createSourceFactory(options,
91 sdkResolver: sdkResolver, 96 sdkResolver: sdkResolver,
92 fileResolvers: fileResolvers, 97 fileResolvers: fileResolvers,
93 summaryData: summaryData, 98 summaryData: summaryData,
94 resourceProvider: resourceProvider); 99 resourceProvider: resourceProvider);
95 100
96 var context = 101 var context =
97 AnalysisEngine.instance.createAnalysisContext() as AnalysisContextImpl; 102 AnalysisEngine.instance.createAnalysisContext() as AnalysisContextImpl;
98 context.analysisOptions = analysisOptions; 103 context.analysisOptions = analysisOptions;
99 context.sourceFactory = srcFactory; 104 context.sourceFactory = srcFactory;
100 context.typeProvider = sdkResolver.dartSdk.context.typeProvider; 105 if (sdkSummaryBundle != null) {
101 context.resultProvider = 106 context.resultProvider =
102 new InputPackagesResultProvider(context, summaryData); 107 new InputPackagesResultProvider(context, summaryData);
108 }
103 options.declaredVariables.forEach(context.declaredVariables.define); 109 options.declaredVariables.forEach(context.declaredVariables.define);
104 context.declaredVariables.define('dart.isVM', 'false'); 110 context.declaredVariables.define('dart.isVM', 'false');
105 111
106 // TODO(vsm): Should this be hardcoded? 112 // TODO(vsm): Should this be hardcoded?
107 context.declaredVariables.define('dart.library.html', 'true'); 113 context.declaredVariables.define('dart.library.html', 'true');
108 context.declaredVariables.define('dart.library.io', 'false'); 114 context.declaredVariables.define('dart.library.io', 'false');
109 115
110 if (!context.analysisOptions.strongMode) { 116 if (!context.analysisOptions.strongMode) {
111 throw new ArgumentError('AnalysisContext must be strong mode'); 117 throw new ArgumentError('AnalysisContext must be strong mode');
112 } 118 }
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // Fall back to a relative path. 577 // Fall back to a relative path.
572 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); 578 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString();
573 } 579 }
574 580
575 for (int i = 0; i < list.length; i++) { 581 for (int i = 0; i < list.length; i++) {
576 list[i] = transformUri(list[i]); 582 list[i] = transformUri(list[i]);
577 } 583 }
578 map['file'] = transformUri(map['file']); 584 map['file'] = transformUri(map['file']);
579 return map; 585 return map;
580 } 586 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/lib/src/driver.dart ('k') | pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698