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

Unified Diff: pkg/compiler/samples/jsonify/jsonify.dart

Issue 1420843008: Add .platform files to jsonify. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/samples/jsonify/jsonify.dart
diff --git a/pkg/compiler/samples/jsonify/jsonify.dart b/pkg/compiler/samples/jsonify/jsonify.dart
index 7638ca59b121882a266e448786c1ba5ab1e544b7..152f39efeb1ff99f02df22f4e81024b44d2c5895 100644
--- a/pkg/compiler/samples/jsonify/jsonify.dart
+++ b/pkg/compiler/samples/jsonify/jsonify.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:async';
import 'dart:io';
import 'dart:convert';
@@ -65,30 +66,39 @@ main(List<String> arguments) {
jsonify(MirrorSystem mirrors) {
var map = <String, String>{};
+ List<Future> futures = <Future>[];
+
+ Future mapUri(Uri uri) {
+ String filename = relativize(sdkRoot, uri, false);
+ return handler.provider.readStringFromUri(uri).then((contents) {
+ map['sdk:/$filename'] = contents;
+ });
+ }
mirrors.libraries.forEach((_, LibraryMirror library) {
BackDoor.compilationUnitsOf(library).forEach((compilationUnit) {
- Uri uri = compilationUnit.uri;
- String filename = relativize(sdkRoot, uri, false);
- SourceFile file = handler.provider.sourceFiles[uri];
- map['sdk:/$filename'] = file.slowText();
+ futures.add(mapUri(compilationUnit.uri));
});
});
libraries.forEach((name, info) {
var patch = info.dart2jsPatchPath;
if (patch != null) {
- Uri uri = sdkRoot.resolve('sdk/lib/$patch');
- String filename = relativize(sdkRoot, uri, false);
- SourceFile file = handler.provider.sourceFiles[uri];
- map['sdk:/$filename'] = file.slowText();
+ futures.add(mapUri(sdkRoot.resolve('sdk/lib/$patch')));
}
});
- if (outputJson) {
- output.writeStringSync(JSON.encode(map));
- } else {
- output.writeStringSync('''
+ for (String filename in ["dart_client.platform",
+ "dart_server.platform",
+ "dart_shared.platform"]) {
+ futures.add(mapUri(sdkRoot.resolve('sdk/lib/$filename')));
+ }
+
+ Future.wait(futures).then((_) {
+ if (outputJson) {
+ output.writeStringSync(JSON.encode(map));
+ } else {
+ output.writeStringSync('''
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -99,8 +109,9 @@ jsonify(MirrorSystem mirrors) {
library dart.sdk_sources;
const Map<String, String> SDK_SOURCES = const <String, String>''');
- output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$'));
- output.writeStringSync(';\n');
- }
- output.closeSync();
+ output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$'));
+ output.writeStringSync(';\n');
+ }
+ output.closeSync();
+ });
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698