935103fd0f
Note: the current implementation broke when we changed the encoding. Change-Id: I48d9e5fedad3f3be85fc1e73dd5dd091bb7278b0 Reviewed-on: https://dart-review.googlesource.com/c/84881 Commit-Queue: Sigmund Cherem <sigmund@google.com> Commit-Queue: Stephen Adams <sra@google.com> Auto-Submit: Sigmund Cherem <sigmund@google.com> Reviewed-by: Stephen Adams <sra@google.com>
26 lines
894 B
Dart
26 lines
894 B
Dart
import 'dart:io';
|
|
import 'dart:convert';
|
|
import 'package:source_maps/source_maps.dart';
|
|
import 'package:dart2js_tools/src/dart2js_mapping.dart';
|
|
|
|
main(List<String> args) {
|
|
if (args.length < 2) {
|
|
print('usage: read.dart <source-map-file> <name>');
|
|
exit(1);
|
|
}
|
|
var name = args[1];
|
|
|
|
var sourcemapFile = new File.fromUri(Uri.base.resolve(args[0]));
|
|
if (!sourcemapFile.existsSync()) {
|
|
print('Error: no such file: $sourcemapFile');
|
|
exit(1);
|
|
}
|
|
var json = jsonDecode(sourcemapFile.readAsStringSync());
|
|
Dart2jsMapping mapping = Dart2jsMapping(parseJson(json), json);
|
|
var global = mapping.globalNames[name];
|
|
if (global != null) print('$name => $global (a global name)');
|
|
var instance = mapping.instanceNames[name];
|
|
if (instance != null) print('$name => $instance (an instance name)');
|
|
if (global == null && instance == null) print('Name \'$name\' not found.');
|
|
}
|