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

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

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'package:expect/expect.dart'; 6 import 'package:expect/expect.dart';
7 7 import 'package:compiler/src/null_compiler_output.dart';
8 import 'memory_source_file_helper.dart'; 8 import 'memory_source_file_helper.dart';
9 9
10 Future<Map<String, String>> generate(String code, 10 Future<Map<String, String>> generate(String code,
11 [List<String> options = const []]) { 11 [List<String> options = const []]) {
12 Uri script = currentDirectory.resolveUri(Platform.script); 12 Uri script = currentDirectory.resolveUri(Platform.script);
13 Uri libraryRoot = script.resolve('../../../sdk/'); 13 Uri libraryRoot = script.resolve('../../../sdk/');
14 Uri packageRoot = script.resolve('./packages/'); 14 Uri packageRoot = script.resolve('./packages/');
15 15
16 var provider = new MemorySourceFileProvider({ 'main.dart': code }); 16 var provider = new MemorySourceFileProvider({ 'main.dart': code });
17 var handler = new FormattingDiagnosticHandler(provider); 17 var handler = new FormattingDiagnosticHandler(provider);
18 18
19 Compiler compiler = new Compiler(provider.readStringFromUri, 19 Compiler compiler = new Compiler(provider,
20 null, 20 const NullCompilerOutput(),
21 handler.diagnosticHandler, 21 handler,
22 libraryRoot, 22 libraryRoot,
23 packageRoot, 23 packageRoot,
24 options, 24 options,
25 {}); 25 {});
26 Uri uri = Uri.parse('memory:main.dart'); 26 Uri uri = Uri.parse('memory:main.dart');
27 return compiler.run(uri).then((success) { 27 return compiler.run(uri).then((success) {
28 Expect.isTrue(success); 28 Expect.isTrue(success);
29 Map<String, String> result = new Map<String, String>(); 29 Map<String, String> result = new Map<String, String>();
30 var backend = compiler.backend; 30 var backend = compiler.backend;
31 for (var element in backend.generatedCode.keys) { 31 for (var element in backend.generatedCode.keys) {
32 if (element.compilationUnit.script.readableUri != uri) continue; 32 if (element.compilationUnit.script.readableUri != uri) continue;
33 var name = element.name; 33 var name = element.name;
34 var code = backend.assembleCode(element); 34 var code = backend.assembleCode(element);
35 result[name] = code; 35 result[name] = code;
36 } 36 }
37 return result; 37 return result;
38 }); 38 });
39 } 39 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/bad_output_io_test.dart ('k') | tests/compiler/dart2js/deferred_custom_element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698