OLD | NEW |
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:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:compiler/src/compiler.dart' show Compiler; | 7 import 'package:compiler/src/compiler.dart' show Compiler; |
8 import 'package:compiler/src/elements/elements.dart' | 8 import 'package:compiler/src/elements/elements.dart' |
9 show Element, LibraryElement; | 9 show Element, LibraryElement; |
10 import 'package:compiler/src/js_backend/backend.dart' as js | 10 import 'package:compiler/src/js_backend/backend.dart' as js |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (useKernel) options.add(Flags.useKernel); | 26 if (useKernel) options.add(Flags.useKernel); |
27 options.addAll(extraOptions); | 27 options.addAll(extraOptions); |
28 | 28 |
29 if (lookup is String && lookup != 'main' && !code.contains('main')) { | 29 if (lookup is String && lookup != 'main' && !code.contains('main')) { |
30 code = "$code\n\nmain() => $lookup;"; | 30 code = "$code\n\nmain() => $lookup;"; |
31 } | 31 } |
32 CompilationResult result = await runCompiler( | 32 CompilationResult result = await runCompiler( |
33 memorySourceFiles: {'main.dart': code}, options: options); | 33 memorySourceFiles: {'main.dart': code}, options: options); |
34 expect(result.isSuccess, isTrue); | 34 expect(result.isSuccess, isTrue); |
35 Compiler compiler = result.compiler; | 35 Compiler compiler = result.compiler; |
36 LibraryElement mainApp = compiler.mainApp; | 36 LibraryElement mainApp = |
| 37 compiler.frontendStrategy.elementEnvironment.mainLibrary; |
37 Element element; | 38 Element element; |
38 if (lookup is String) { | 39 if (lookup is String) { |
39 element = mainApp.find(lookup); | 40 element = mainApp.find(lookup); |
40 } else { | 41 } else { |
41 element = lookup(compiler); | 42 element = lookup(compiler); |
42 } | 43 } |
43 js.JavaScriptBackend backend = compiler.backend; | 44 js.JavaScriptBackend backend = compiler.backend; |
44 return backend.getGeneratedCode(element); | 45 return backend.getGeneratedCode(element); |
45 } | 46 } |
46 | 47 |
(...skipping 13 matching lines...) Expand all Loading... |
60 useKernel: false, | 61 useKernel: false, |
61 disableTypeInference: disableTypeInference, | 62 disableTypeInference: disableTypeInference, |
62 extraOptions: extraOptions); | 63 extraOptions: extraOptions); |
63 var kernel = await compile(code, | 64 var kernel = await compile(code, |
64 lookup: lookup, | 65 lookup: lookup, |
65 useKernel: true, | 66 useKernel: true, |
66 disableTypeInference: disableTypeInference, | 67 disableTypeInference: disableTypeInference, |
67 extraOptions: extraOptions); | 68 extraOptions: extraOptions); |
68 expect(kernel, original); | 69 expect(kernel, original); |
69 } | 70 } |
OLD | NEW |