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

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

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
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 'package:expect/expect.dart'; 6 import 'package:expect/expect.dart';
6 7
7 import 'memory_source_file_helper.dart'; 8 import 'memory_source_file_helper.dart';
8 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart" 9 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart"
9 show SourceString; 10 show SourceString;
10 11
11 Map<String, String> generate(String code, [List<String> options = const []]) { 12 Future<Map<String, String>> generate(String code,
13 [List<String> options = const []]) {
12 Uri script = currentDirectory.resolve(nativeToUriPath(new Options().script)); 14 Uri script = currentDirectory.resolve(nativeToUriPath(new Options().script));
13 Uri libraryRoot = script.resolve('../../../sdk/'); 15 Uri libraryRoot = script.resolve('../../../sdk/');
14 Uri packageRoot = script.resolve('./packages/'); 16 Uri packageRoot = script.resolve('./packages/');
15 17
16 MemorySourceFileProvider.MEMORY_SOURCE_FILES = { 'main.dart': code }; 18 MemorySourceFileProvider.MEMORY_SOURCE_FILES = { 'main.dart': code };
17 var provider = new MemorySourceFileProvider(); 19 var provider = new MemorySourceFileProvider();
18 var handler = new FormattingDiagnosticHandler(provider); 20 var handler = new FormattingDiagnosticHandler(provider);
19 21
20 Compiler compiler = new Compiler(provider.readStringFromUri, 22 Compiler compiler = new Compiler(provider.readStringFromUri,
21 null, 23 null,
22 handler.diagnosticHandler, 24 handler.diagnosticHandler,
23 libraryRoot, 25 libraryRoot,
24 packageRoot, 26 packageRoot,
25 options); 27 options);
26 Uri uri = Uri.parse('memory:main.dart'); 28 Uri uri = Uri.parse('memory:main.dart');
27 Expect.isTrue(compiler.run(uri)); 29 return compiler.run(uri).then((success) {
28 Map<String, String> result = new Map<String, String>(); 30 Expect.isTrue(success);
29 for (var element in compiler.backend.generatedCode.keys) { 31 Map<String, String> result = new Map<String, String>();
30 if (element.getCompilationUnit().script.uri != uri) continue; 32 for (var element in compiler.backend.generatedCode.keys) {
31 var name = element.name.slowToString(); 33 if (element.getCompilationUnit().script.uri != uri) continue;
32 var code = compiler.backend.assembleCode(element); 34 var name = element.name.slowToString();
33 result[name] = code; 35 var code = compiler.backend.assembleCode(element);
34 } 36 result[name] = code;
35 return result; 37 }
38 return result;
39 });
36 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698