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

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

Issue 2685573002: Replace Backend with JavaScriptBackend. (Closed)
Patch Set: Updated cf. comment 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
« no previous file with comments | « pkg/compiler/lib/src/common/resolution.dart ('k') | pkg/compiler/lib/src/deferred_load.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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 library dart2js.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show EventSink, Future; 7 import 'dart:async' show EventSink, Future;
8 8
9 import '../compiler_new.dart' as api; 9 import '../compiler_new.dart' as api;
10 import 'closure.dart' as closureMapping show ClosureTask; 10 import 'closure.dart' as closureMapping show ClosureTask;
11 import 'common/backend_api.dart' show Backend;
12 import 'common/names.dart' show Selectors; 11 import 'common/names.dart' show Selectors;
13 import 'common/names.dart' show Identifiers, Uris; 12 import 'common/names.dart' show Identifiers, Uris;
14 import 'common/resolution.dart' 13 import 'common/resolution.dart'
15 show 14 show
16 ParsingContext, 15 ParsingContext,
17 Resolution, 16 Resolution,
18 ResolutionWorkItem, 17 ResolutionWorkItem,
19 ResolutionImpact, 18 ResolutionImpact,
20 Target; 19 Target;
21 import 'common/tasks.dart' show CompilerTask, GenericTask, Measurer; 20 import 'common/tasks.dart' show CompilerTask, GenericTask, Measurer;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 import 'types/types.dart' show GlobalTypeInferenceTask; 73 import 'types/types.dart' show GlobalTypeInferenceTask;
75 import 'universe/selector.dart' show Selector; 74 import 'universe/selector.dart' show Selector;
76 import 'universe/world_builder.dart' 75 import 'universe/world_builder.dart'
77 show ResolutionWorldBuilder, CodegenWorldBuilder; 76 show ResolutionWorldBuilder, CodegenWorldBuilder;
78 import 'universe/use.dart' show StaticUse, TypeUse; 77 import 'universe/use.dart' show StaticUse, TypeUse;
79 import 'universe/world_impact.dart' 78 import 'universe/world_impact.dart'
80 show ImpactStrategy, WorldImpact, WorldImpactBuilderImpl; 79 show ImpactStrategy, WorldImpact, WorldImpactBuilderImpl;
81 import 'util/util.dart' show Link, Setlet; 80 import 'util/util.dart' show Link, Setlet;
82 import 'world.dart' show ClosedWorld, ClosedWorldRefiner, ClosedWorldImpl; 81 import 'world.dart' show ClosedWorld, ClosedWorldRefiner, ClosedWorldImpl;
83 82
84 typedef Backend MakeBackendFunction(Compiler compiler);
85
86 typedef CompilerDiagnosticReporter MakeReporterFunction( 83 typedef CompilerDiagnosticReporter MakeReporterFunction(
87 Compiler compiler, CompilerOptions options); 84 Compiler compiler, CompilerOptions options);
88 85
89 abstract class Compiler implements LibraryLoaderListener { 86 abstract class Compiler implements LibraryLoaderListener {
90 Measurer get measurer; 87 Measurer get measurer;
91 88
92 final IdGenerator idGenerator = new IdGenerator(); 89 final IdGenerator idGenerator = new IdGenerator();
93 Types types; 90 Types types;
94 _CompilerCommonElements _commonElements; 91 _CompilerCommonElements _commonElements;
95 _CompilerElementEnvironment _elementEnvironment; 92 _CompilerElementEnvironment _elementEnvironment;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ScannerTask scanner; 153 ScannerTask scanner;
157 DietParserTask dietParser; 154 DietParserTask dietParser;
158 ParserTask parser; 155 ParserTask parser;
159 PatchParserTask patchParser; 156 PatchParserTask patchParser;
160 LibraryLoaderTask libraryLoader; 157 LibraryLoaderTask libraryLoader;
161 SerializationTask serialization; 158 SerializationTask serialization;
162 ResolverTask resolver; 159 ResolverTask resolver;
163 closureMapping.ClosureTask closureToClassMapper; 160 closureMapping.ClosureTask closureToClassMapper;
164 TypeCheckerTask checker; 161 TypeCheckerTask checker;
165 GlobalTypeInferenceTask globalInference; 162 GlobalTypeInferenceTask globalInference;
166 Backend backend; 163 js_backend.JavaScriptBackend backend;
167 164
168 GenericTask selfTask; 165 GenericTask selfTask;
169 166
170 /// The constant environment for the frontend interpretation of compile-time 167 /// The constant environment for the frontend interpretation of compile-time
171 /// constants. 168 /// constants.
172 ConstantEnvironment constants; 169 ConstantEnvironment constants;
173 170
174 EnqueueTask enqueuer; 171 EnqueueTask enqueuer;
175 DeferredLoadTask deferredLoadTask; 172 DeferredLoadTask deferredLoadTask;
176 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; 173 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask;
(...skipping 12 matching lines...) Expand all
189 static const int PHASE_DONE_RESOLVING = 2; 186 static const int PHASE_DONE_RESOLVING = 2;
190 static const int PHASE_COMPILING = 3; 187 static const int PHASE_COMPILING = 3;
191 int phase; 188 int phase;
192 189
193 bool compilationFailed = false; 190 bool compilationFailed = false;
194 191
195 Compiler( 192 Compiler(
196 {CompilerOptions options, 193 {CompilerOptions options,
197 api.CompilerOutput outputProvider, 194 api.CompilerOutput outputProvider,
198 this.environment: const _EmptyEnvironment(), 195 this.environment: const _EmptyEnvironment(),
199 MakeBackendFunction makeBackend,
200 MakeReporterFunction makeReporter}) 196 MakeReporterFunction makeReporter})
201 : this.options = options, 197 : this.options = options,
202 this.userOutputProvider = outputProvider == null 198 this.userOutputProvider = outputProvider == null
203 ? const NullCompilerOutput() 199 ? const NullCompilerOutput()
204 : outputProvider { 200 : outputProvider {
205 if (makeReporter != null) { 201 if (makeReporter != null) {
206 _reporter = makeReporter(this, options); 202 _reporter = makeReporter(this, options);
207 } else { 203 } else {
208 _reporter = new CompilerDiagnosticReporter(this, options); 204 _reporter = new CompilerDiagnosticReporter(this, options);
209 } 205 }
210 _resolution = createResolution(); 206 _resolution = createResolution();
211 _elementEnvironment = new _CompilerElementEnvironment(this); 207 _elementEnvironment = new _CompilerElementEnvironment(this);
212 _commonElements = 208 _commonElements =
213 new _CompilerCommonElements(_elementEnvironment, _resolution, reporter); 209 new _CompilerCommonElements(_elementEnvironment, _resolution, reporter);
214 types = new Types(_resolution); 210 types = new Types(_resolution);
215 211
216 if (options.verbose) { 212 if (options.verbose) {
217 progress = new Stopwatch()..start(); 213 progress = new Stopwatch()..start();
218 } 214 }
219 215
220 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing 216 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing
221 // for global dependencies. 217 // for global dependencies.
222 globalDependencies = new GlobalDependencyRegistry(); 218 globalDependencies = new GlobalDependencyRegistry();
223 219
224 if (makeBackend != null) { 220 backend = createBackend();
225 backend = makeBackend(this);
226 } else {
227 backend = createBackend();
228 }
229 enqueuer = backend.makeEnqueuer(); 221 enqueuer = backend.makeEnqueuer();
230 222
231 tasks = [ 223 tasks = [
232 dietParser = new DietParserTask(idGenerator, backend, reporter, measurer), 224 dietParser = new DietParserTask(idGenerator, backend, reporter, measurer),
233 scanner = createScannerTask(), 225 scanner = createScannerTask(),
234 serialization = new SerializationTask(this), 226 serialization = new SerializationTask(this),
235 libraryLoader = new LibraryLoaderTask( 227 libraryLoader = new LibraryLoaderTask(
236 resolvedUriTranslator, 228 resolvedUriTranslator,
237 options.compileOnly 229 options.compileOnly
238 ? new _NoScriptLoader(this) 230 ? new _NoScriptLoader(this)
(...skipping 25 matching lines...) Expand all
264 256
265 _parsingContext = 257 _parsingContext =
266 new ParsingContext(reporter, parser, scanner, patchParser, backend); 258 new ParsingContext(reporter, parser, scanner, patchParser, backend);
267 259
268 tasks.addAll(backend.tasks); 260 tasks.addAll(backend.tasks);
269 } 261 }
270 262
271 /// Creates the backend. 263 /// Creates the backend.
272 /// 264 ///
273 /// Override this to mock the backend for testing. 265 /// Override this to mock the backend for testing.
274 Backend createBackend() { 266 js_backend.JavaScriptBackend createBackend() {
275 return new js_backend.JavaScriptBackend(this, 267 return new js_backend.JavaScriptBackend(this,
276 generateSourceMap: options.generateSourceMap, 268 generateSourceMap: options.generateSourceMap,
277 useStartupEmitter: options.useStartupEmitter, 269 useStartupEmitter: options.useStartupEmitter,
278 useNewSourceInfo: options.useNewSourceInfo, 270 useNewSourceInfo: options.useNewSourceInfo,
279 useKernel: options.useKernel); 271 useKernel: options.useKernel);
280 } 272 }
281 273
282 /// Creates the scanner task. 274 /// Creates the scanner task.
283 /// 275 ///
284 /// Override this to mock the scanner for testing. 276 /// Override this to mock the scanner for testing.
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 if (library != null && library.isSynthesized) { 2090 if (library != null && library.isSynthesized) {
2099 return null; 2091 return null;
2100 } 2092 }
2101 if (library == null && required) { 2093 if (library == null && required) {
2102 throw new SpannableAssertionFailure( 2094 throw new SpannableAssertionFailure(
2103 library, "The library '${uri}' was not found."); 2095 library, "The library '${uri}' was not found.");
2104 } 2096 }
2105 return library; 2097 return library;
2106 } 2098 }
2107 } 2099 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common/resolution.dart ('k') | pkg/compiler/lib/src/deferred_load.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698