| OLD | NEW |
| 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 mock_compiler; | 5 library mock_compiler; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 | 10 |
| 11 import 'package:compiler/compiler.dart' as api; | 11 import 'package:compiler/compiler.dart' as api; |
| 12 import 'package:compiler/src/common/names.dart' show | 12 import 'package:compiler/src/common/names.dart' show |
| 13 Uris; | 13 Uris; |
| 14 import 'package:compiler/src/constants/expressions.dart'; | 14 import 'package:compiler/src/constants/expressions.dart'; |
| 15 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; | 15 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; |
| 16 import 'package:compiler/src/diagnostics/messages.dart'; | 16 import 'package:compiler/src/diagnostics/messages.dart'; |
| 17 import 'package:compiler/src/diagnostics/source_span.dart'; | 17 import 'package:compiler/src/diagnostics/source_span.dart'; |
| 18 import 'package:compiler/src/diagnostics/spannable.dart'; | 18 import 'package:compiler/src/diagnostics/spannable.dart'; |
| 19 import 'package:compiler/src/elements/elements.dart'; | 19 import 'package:compiler/src/elements/elements.dart'; |
| 20 import 'package:compiler/src/js_backend/js_backend.dart' | 20 import 'package:compiler/src/js_backend/backend_helpers.dart' |
| 21 show JavaScriptBackend; | 21 show BackendHelpers; |
| 22 import 'package:compiler/src/js_backend/lookup_map_analysis.dart' |
| 23 show LookupMapAnalysis; |
| 22 import 'package:compiler/src/io/source_file.dart'; | 24 import 'package:compiler/src/io/source_file.dart'; |
| 23 import 'package:compiler/src/resolution/members.dart'; | 25 import 'package:compiler/src/resolution/members.dart'; |
| 24 import 'package:compiler/src/resolution/registry.dart'; | 26 import 'package:compiler/src/resolution/registry.dart'; |
| 25 import 'package:compiler/src/resolution/scope.dart'; | 27 import 'package:compiler/src/resolution/scope.dart'; |
| 26 import 'package:compiler/src/resolution/tree_elements.dart'; | 28 import 'package:compiler/src/resolution/tree_elements.dart'; |
| 27 import 'package:compiler/src/script.dart'; | 29 import 'package:compiler/src/script.dart'; |
| 28 import 'package:compiler/src/tree/tree.dart'; | 30 import 'package:compiler/src/tree/tree.dart'; |
| 29 import 'package:compiler/src/old_to_new_api.dart'; | 31 import 'package:compiler/src/old_to_new_api.dart'; |
| 30 import 'parser_helper.dart'; | 32 import 'parser_helper.dart'; |
| 31 | 33 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 this.disableInlining = disableInlining; | 114 this.disableInlining = disableInlining; |
| 113 | 115 |
| 114 deferredLoadTask = new MockDeferredLoadTask(this); | 116 deferredLoadTask = new MockDeferredLoadTask(this); |
| 115 | 117 |
| 116 clearMessages(); | 118 clearMessages(); |
| 117 | 119 |
| 118 registerSource(Uris.dart_core, | 120 registerSource(Uris.dart_core, |
| 119 buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource)); | 121 buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource)); |
| 120 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE); | 122 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE); |
| 121 | 123 |
| 122 registerSource(JavaScriptBackend.DART_JS_HELPER, | 124 registerSource(BackendHelpers.DART_JS_HELPER, |
| 123 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY)); | 125 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY)); |
| 124 registerSource(JavaScriptBackend.DART_FOREIGN_HELPER, | 126 registerSource(BackendHelpers.DART_FOREIGN_HELPER, |
| 125 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY)); | 127 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY)); |
| 126 registerSource(JavaScriptBackend.DART_INTERCEPTORS, | 128 registerSource(BackendHelpers.DART_INTERCEPTORS, |
| 127 buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY)); | 129 buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY)); |
| 128 registerSource(JavaScriptBackend.DART_ISOLATE_HELPER, | 130 registerSource(BackendHelpers.DART_ISOLATE_HELPER, |
| 129 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY)); | 131 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY)); |
| 130 registerSource(Uris.dart_mirrors, DEFAULT_MIRRORS_SOURCE); | 132 registerSource(Uris.dart_mirrors, DEFAULT_MIRRORS_SOURCE); |
| 131 registerSource(JavaScriptBackend.DART_JS_MIRRORS, | 133 registerSource(BackendHelpers.DART_JS_MIRRORS, |
| 132 DEFAULT_JS_MIRRORS_SOURCE); | 134 DEFAULT_JS_MIRRORS_SOURCE); |
| 133 | 135 |
| 134 Map<String, String> asyncLibrarySource = <String, String>{}; | 136 Map<String, String> asyncLibrarySource = <String, String>{}; |
| 135 asyncLibrarySource.addAll(DEFAULT_ASYNC_LIBRARY); | 137 asyncLibrarySource.addAll(DEFAULT_ASYNC_LIBRARY); |
| 136 if (enableAsyncAwait) { | 138 if (enableAsyncAwait) { |
| 137 asyncLibrarySource.addAll(ASYNC_AWAIT_LIBRARY); | 139 asyncLibrarySource.addAll(ASYNC_AWAIT_LIBRARY); |
| 138 } | 140 } |
| 139 registerSource(Uris.dart_async, | 141 registerSource(Uris.dart_async, |
| 140 buildLibrarySource(asyncLibrarySource)); | 142 buildLibrarySource(asyncLibrarySource)); |
| 141 registerSource(JavaScriptBackend.PACKAGE_LOOKUP_MAP, | 143 registerSource(LookupMapAnalysis.PACKAGE_LOOKUP_MAP, |
| 142 buildLibrarySource(DEFAULT_LOOKUP_MAP_LIBRARY)); | 144 buildLibrarySource(DEFAULT_LOOKUP_MAP_LIBRARY)); |
| 143 } | 145 } |
| 144 | 146 |
| 145 String get patchVersion { | 147 String get patchVersion { |
| 146 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; | 148 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; |
| 147 } | 149 } |
| 148 | 150 |
| 149 /// Initialize the mock compiler with an empty main library. | 151 /// Initialize the mock compiler with an empty main library. |
| 150 Future<Uri> init([String mainSource = ""]) { | 152 Future<Uri> init([String mainSource = ""]) { |
| 151 Uri uri = new Uri(scheme: "mock"); | 153 Uri uri = new Uri(scheme: "mock"); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 trustTypeAnnotations: trustTypeAnnotations, | 470 trustTypeAnnotations: trustTypeAnnotations, |
| 469 enableTypeAssertions: enableTypeAssertions, | 471 enableTypeAssertions: enableTypeAssertions, |
| 470 enableUserAssertions: enableUserAssertions, | 472 enableUserAssertions: enableUserAssertions, |
| 471 expectedErrors: expectedErrors, | 473 expectedErrors: expectedErrors, |
| 472 expectedWarnings: expectedWarnings, | 474 expectedWarnings: expectedWarnings, |
| 473 outputProvider: outputProvider); | 475 outputProvider: outputProvider); |
| 474 compiler.registerSource(uri, code); | 476 compiler.registerSource(uri, code); |
| 475 compiler.diagnosticHandler = createHandler(compiler, code); | 477 compiler.diagnosticHandler = createHandler(compiler, code); |
| 476 return compiler; | 478 return compiler; |
| 477 } | 479 } |
| OLD | NEW |