4d3d70af23
Kernel sdk version was bumped from 3.6 to 3.12 in https://dart-review.googlesource.com/c/sdk/+/487542 (and to `^3.12.0-0` in https://dart-review.googlesource.com/c/sdk/+/487880) but the source was never formatted. This is, if nothing else, bad for reviews, where editing a file changes the file in lots of places because of new formatting. This CL is the result of running ``` out/ReleaseX64/dart-sdk/bin/dart format pkg/kernel/ ``` but also updates the formatter version used by a source generator (`pkg/front_end/tool/visitor_generator.dart`) so things agree. Change-Id: I66e35d4f1e2d08cecc30fb314546cae78b49e99b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490082 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
57 lines
1.5 KiB
Dart
Executable File
57 lines
1.5 KiB
Dart
Executable File
#!/usr/bin/env dart
|
|
// Copyright (c) 2018, 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.
|
|
|
|
import 'dart:io';
|
|
import 'package:kernel/kernel.dart';
|
|
import 'package:kernel/src/tool/command_line_util.dart';
|
|
|
|
void usage() {
|
|
print("Enumerates the different node types in the provided dill file");
|
|
print("and counts them.");
|
|
print("");
|
|
print("Usage: dart <script> dillFile.dill");
|
|
print("The given argument should be an existing file");
|
|
print("that is valid to load as a dill file.");
|
|
exit(1);
|
|
}
|
|
|
|
void main(List<String> args) {
|
|
CommandLineHelper.requireExactlyOneArgument(
|
|
args,
|
|
usage,
|
|
requireFileExists: true,
|
|
);
|
|
Component component = CommandLineHelper.tryLoadDill(args[0]);
|
|
TypeCounter counter = new TypeCounter();
|
|
component.accept(counter);
|
|
counter.printStats();
|
|
}
|
|
|
|
class TypeCounter extends RecursiveVisitor {
|
|
Map<String, int> _typeCounts = <String, int>{};
|
|
|
|
@override
|
|
void defaultNode(Node node) {
|
|
String key = node.runtimeType.toString();
|
|
_typeCounts[key] = (_typeCounts[key] ??= 0) + 1;
|
|
super.defaultNode(node);
|
|
}
|
|
|
|
void printStats() {
|
|
List<List<Object>> data = [];
|
|
_typeCounts.forEach((type, count) {
|
|
data.add([type, count]);
|
|
});
|
|
data.sort((a, b) {
|
|
int aCount = a[1] as int;
|
|
int bCount = b[1] as int;
|
|
return bCount - aCount;
|
|
});
|
|
for (var entry in data) {
|
|
print("${entry[0]}: ${entry[1]}");
|
|
}
|
|
}
|
|
}
|