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

Side by Side Diff: tests/compiler/dart2js/mock_compiler.dart

Issue 2760923004: Eliminate multi-callback structure for LibraryLoader. (Closed)
Patch Set: . Created 3 years, 9 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 library mock_compiler; 5 library mock_compiler;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:compiler/compiler_new.dart' as api; 10 import 'package:compiler/compiler_new.dart' as api;
11 import 'package:compiler/src/common/names.dart' show Uris; 11 import 'package:compiler/src/common/names.dart' show Uris;
12 import 'package:compiler/src/constants/expressions.dart'; 12 import 'package:compiler/src/constants/expressions.dart';
13 import 'package:compiler/src/elements/resolution_types.dart' 13 import 'package:compiler/src/elements/resolution_types.dart'
14 show ResolutionDartType; 14 show ResolutionDartType;
15 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; 15 import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
16 import 'package:compiler/src/diagnostics/source_span.dart'; 16 import 'package:compiler/src/diagnostics/source_span.dart';
17 import 'package:compiler/src/diagnostics/spannable.dart'; 17 import 'package:compiler/src/diagnostics/spannable.dart';
18 import 'package:compiler/src/elements/elements.dart'; 18 import 'package:compiler/src/elements/elements.dart';
19 import 'package:compiler/src/elements/visitor.dart'; 19 import 'package:compiler/src/elements/visitor.dart';
20 import 'package:compiler/src/library_loader.dart' show LoadedLibraries;
20 import 'package:compiler/src/js_backend/backend_helpers.dart' 21 import 'package:compiler/src/js_backend/backend_helpers.dart'
21 show BackendHelpers; 22 show BackendHelpers;
22 import 'package:compiler/src/js_backend/lookup_map_analysis.dart' 23 import 'package:compiler/src/js_backend/lookup_map_analysis.dart'
23 show LookupMapResolutionAnalysis; 24 show LookupMapResolutionAnalysis;
24 import 'package:compiler/src/io/source_file.dart'; 25 import 'package:compiler/src/io/source_file.dart';
25 import 'package:compiler/src/options.dart' show CompilerOptions; 26 import 'package:compiler/src/options.dart' show CompilerOptions;
26 import 'package:compiler/src/resolution/members.dart'; 27 import 'package:compiler/src/resolution/members.dart';
27 import 'package:compiler/src/resolution/registry.dart'; 28 import 'package:compiler/src/resolution/registry.dart';
28 import 'package:compiler/src/resolution/scope.dart'; 29 import 'package:compiler/src/resolution/scope.dart';
29 import 'package:compiler/src/resolution/tree_elements.dart'; 30 import 'package:compiler/src/resolution/tree_elements.dart';
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 138
138 String get patchVersion { 139 String get patchVersion {
139 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; 140 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion;
140 } 141 }
141 142
142 /// Initialize the mock compiler with an empty main library. 143 /// Initialize the mock compiler with an empty main library.
143 Future<Uri> init([String mainSource = ""]) { 144 Future<Uri> init([String mainSource = ""]) {
144 Uri uri = new Uri(scheme: "mock"); 145 Uri uri = new Uri(scheme: "mock");
145 registerSource(uri, mainSource); 146 registerSource(uri, mainSource);
146 return libraryLoader.loadLibrary(uri).then((LibraryElement library) { 147 return libraryLoader
147 mainApp = library; 148 .loadLibrary(uri)
149 .then((LoadedLibraries loadedLibraries) {
150 processLoadedLibraries(loadedLibraries);
151 mainApp = loadedLibraries.rootLibrary;
148 startResolution(); 152 startResolution();
149 // We need to make sure the Object class is resolved. When registering a 153 // We need to make sure the Object class is resolved. When registering a
150 // dynamic invocation the ArgumentTypesRegistry eventually iterates over 154 // dynamic invocation the ArgumentTypesRegistry eventually iterates over
151 // the interfaces of the Object class which would be 'null' if the class 155 // the interfaces of the Object class which would be 'null' if the class
152 // wasn't resolved. 156 // wasn't resolved.
153 ClassElement objectClass = commonElements.objectClass; 157 ClassElement objectClass = commonElements.objectClass;
154 objectClass.ensureResolved(resolution); 158 objectClass.ensureResolved(resolution);
155 }).then((_) => uri); 159 }).then((_) => uri);
156 } 160 }
157 161
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 trustTypeAnnotations: trustTypeAnnotations, 398 trustTypeAnnotations: trustTypeAnnotations,
395 enableTypeAssertions: enableTypeAssertions, 399 enableTypeAssertions: enableTypeAssertions,
396 enableUserAssertions: enableUserAssertions, 400 enableUserAssertions: enableUserAssertions,
397 expectedErrors: expectedErrors, 401 expectedErrors: expectedErrors,
398 expectedWarnings: expectedWarnings, 402 expectedWarnings: expectedWarnings,
399 outputProvider: outputProvider); 403 outputProvider: outputProvider);
400 compiler.registerSource(uri, code); 404 compiler.registerSource(uri, code);
401 compiler.diagnosticHandler = createHandler(compiler, code); 405 compiler.diagnosticHandler = createHandler(compiler, code);
402 return compiler; 406 return compiler;
403 } 407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698