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

Side by Side Diff: tests/compiler/dart2js/kernel/helper.dart

Issue 2989453002: Add support for compiling Dart via the FE in dart2js. (Closed)
Patch Set: update status Created 3 years, 5 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 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
11 show JavaScriptBackend; 11 show JavaScriptBackend;
12 import 'package:compiler/src/commandline_options.dart' show Flags; 12 import 'package:compiler/src/commandline_options.dart' show Flags;
13 import 'package:test/test.dart'; 13 import 'package:test/test.dart';
14 14
15 import '../memory_compiler.dart'; 15 import '../memory_compiler.dart';
16 16
17 Future<String> compile(String code, 17 Future<String> compile(String code,
18 {dynamic lookup: 'main', 18 {dynamic lookup: 'main',
19 bool useKernel: true, 19 bool useKernelInSsa: true,
20 bool disableTypeInference: true, 20 bool disableTypeInference: true,
21 List<String> extraOptions: const <String>[]}) async { 21 List<String> extraOptions: const <String>[]}) async {
22 List<String> options = <String>[ 22 List<String> options = <String>[
23 Flags.disableInlining, 23 Flags.disableInlining,
24 ]; 24 ];
25 if (disableTypeInference) options.add(Flags.disableTypeInference); 25 if (disableTypeInference) options.add(Flags.disableTypeInference);
26 if (useKernel) options.add(Flags.useKernel); 26 if (useKernelInSsa) options.add(Flags.useKernelInSsa);
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 = 36 LibraryElement mainApp =
(...skipping 14 matching lines...) Expand all
51 /// The function to check at the end is given by [lookup]. If [lookup] is a 51 /// The function to check at the end is given by [lookup]. If [lookup] is a
52 /// String, then the generated code for a top-level element named [lookup] is 52 /// String, then the generated code for a top-level element named [lookup] is
53 /// checked. Otherwise, [lookup] is a function that takes a [Compiler] and 53 /// checked. Otherwise, [lookup] is a function that takes a [Compiler] and
54 /// returns an [Element], and the returned [Element] is checked. 54 /// returns an [Element], and the returned [Element] is checked.
55 Future check(String code, 55 Future check(String code,
56 {dynamic lookup: 'main', 56 {dynamic lookup: 'main',
57 bool disableTypeInference: true, 57 bool disableTypeInference: true,
58 List<String> extraOptions: const <String>[]}) async { 58 List<String> extraOptions: const <String>[]}) async {
59 var original = await compile(code, 59 var original = await compile(code,
60 lookup: lookup, 60 lookup: lookup,
61 useKernel: false, 61 useKernelInSsa: false,
62 disableTypeInference: disableTypeInference, 62 disableTypeInference: disableTypeInference,
63 extraOptions: extraOptions); 63 extraOptions: extraOptions);
64 var kernel = await compile(code, 64 var kernel = await compile(code,
65 lookup: lookup, 65 lookup: lookup,
66 useKernel: true, 66 useKernelInSsa: true,
67 disableTypeInference: disableTypeInference, 67 disableTypeInference: disableTypeInference,
68 extraOptions: extraOptions); 68 extraOptions: extraOptions);
69 expect(kernel, original); 69 expect(kernel, original);
70 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698