| 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 |
| 13 Uris; |
| 12 import 'package:compiler/src/constants/expressions.dart'; | 14 import 'package:compiler/src/constants/expressions.dart'; |
| 13 import 'package:compiler/src/diagnostics/messages.dart'; | 15 import 'package:compiler/src/diagnostics/messages.dart'; |
| 14 import 'package:compiler/src/diagnostics/source_span.dart'; | 16 import 'package:compiler/src/diagnostics/source_span.dart'; |
| 15 import 'package:compiler/src/diagnostics/spannable.dart'; | 17 import 'package:compiler/src/diagnostics/spannable.dart'; |
| 16 import 'package:compiler/src/elements/elements.dart'; | 18 import 'package:compiler/src/elements/elements.dart'; |
| 17 import 'package:compiler/src/js_backend/js_backend.dart' | 19 import 'package:compiler/src/js_backend/js_backend.dart' |
| 18 show JavaScriptBackend; | 20 show JavaScriptBackend; |
| 19 import 'package:compiler/src/io/source_file.dart'; | 21 import 'package:compiler/src/io/source_file.dart'; |
| 20 import 'package:compiler/src/resolution/members.dart'; | 22 import 'package:compiler/src/resolution/members.dart'; |
| 21 import 'package:compiler/src/resolution/registry.dart'; | 23 import 'package:compiler/src/resolution/registry.dart'; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 preserveComments: preserveComments, | 105 preserveComments: preserveComments, |
| 104 trustTypeAnnotations: trustTypeAnnotations, | 106 trustTypeAnnotations: trustTypeAnnotations, |
| 105 showPackageWarnings: true, | 107 showPackageWarnings: true, |
| 106 outputProvider: new LegacyCompilerOutput(outputProvider)) { | 108 outputProvider: new LegacyCompilerOutput(outputProvider)) { |
| 107 this.disableInlining = disableInlining; | 109 this.disableInlining = disableInlining; |
| 108 | 110 |
| 109 deferredLoadTask = new MockDeferredLoadTask(this); | 111 deferredLoadTask = new MockDeferredLoadTask(this); |
| 110 | 112 |
| 111 clearMessages(); | 113 clearMessages(); |
| 112 | 114 |
| 113 registerSource(Compiler.DART_CORE, | 115 registerSource(Uris.dart_core, |
| 114 buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource)); | 116 buildLibrarySource(DEFAULT_CORE_LIBRARY, coreSource)); |
| 115 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE); | 117 registerSource(PATCH_CORE, DEFAULT_PATCH_CORE_SOURCE); |
| 116 | 118 |
| 117 registerSource(JavaScriptBackend.DART_JS_HELPER, | 119 registerSource(JavaScriptBackend.DART_JS_HELPER, |
| 118 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY)); | 120 buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY)); |
| 119 registerSource(JavaScriptBackend.DART_FOREIGN_HELPER, | 121 registerSource(JavaScriptBackend.DART_FOREIGN_HELPER, |
| 120 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY)); | 122 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY)); |
| 121 registerSource(JavaScriptBackend.DART_INTERCEPTORS, | 123 registerSource(JavaScriptBackend.DART_INTERCEPTORS, |
| 122 buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY)); | 124 buildLibrarySource(DEFAULT_INTERCEPTORS_LIBRARY)); |
| 123 registerSource(JavaScriptBackend.DART_ISOLATE_HELPER, | 125 registerSource(JavaScriptBackend.DART_ISOLATE_HELPER, |
| 124 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY)); | 126 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY)); |
| 125 registerSource(Compiler.DART_MIRRORS, | 127 registerSource(Uris.dart_mirrors, |
| 126 buildLibrarySource(DEFAULT_MIRRORS_LIBRARY)); | 128 buildLibrarySource(DEFAULT_MIRRORS_LIBRARY)); |
| 127 | 129 |
| 128 Map<String, String> asyncLibrarySource = <String, String>{}; | 130 Map<String, String> asyncLibrarySource = <String, String>{}; |
| 129 asyncLibrarySource.addAll(DEFAULT_ASYNC_LIBRARY); | 131 asyncLibrarySource.addAll(DEFAULT_ASYNC_LIBRARY); |
| 130 if (enableAsyncAwait) { | 132 if (enableAsyncAwait) { |
| 131 asyncLibrarySource.addAll(ASYNC_AWAIT_LIBRARY); | 133 asyncLibrarySource.addAll(ASYNC_AWAIT_LIBRARY); |
| 132 } | 134 } |
| 133 registerSource(Compiler.DART_ASYNC, | 135 registerSource(Uris.dart_async, |
| 134 buildLibrarySource(asyncLibrarySource)); | 136 buildLibrarySource(asyncLibrarySource)); |
| 135 } | 137 } |
| 136 | 138 |
| 137 String get patchVersion { | 139 String get patchVersion { |
| 138 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; | 140 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; |
| 139 } | 141 } |
| 140 | 142 |
| 141 /// Initialize the mock compiler with an empty main library. | 143 /// Initialize the mock compiler with an empty main library. |
| 142 Future<Uri> init([String mainSource = ""]) { | 144 Future<Uri> init([String mainSource = ""]) { |
| 143 Uri uri = new Uri(scheme: "mock"); | 145 Uri uri = new Uri(scheme: "mock"); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 MockElement(Element enclosingElement) | 426 MockElement(Element enclosingElement) |
| 425 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, | 427 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, |
| 426 enclosingElement); | 428 enclosingElement); |
| 427 | 429 |
| 428 get node => null; | 430 get node => null; |
| 429 | 431 |
| 430 parseNode(_) => null; | 432 parseNode(_) => null; |
| 431 | 433 |
| 432 bool get hasNode => false; | 434 bool get hasNode => false; |
| 433 } | 435 } |
| OLD | NEW |