mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:45:06 +00:00
[dart2js] Migrate pkg/compiler/tool to null safety.
Change-Id: I800aa4b5af9b9950ece488ed7e59bf98d2fc1c1b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282980 Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
a560f96987
commit
865421c169
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
library dart2js.profile_many;
|
||||
|
||||
import 'dart:async';
|
||||
|
@ -43,10 +41,10 @@ void main(List<String> args) {
|
|||
};
|
||||
|
||||
Future.forEach(files, (String file) {
|
||||
List subargs = [];
|
||||
List<String> subargs = [];
|
||||
subargs.addAll(options);
|
||||
subargs.add(file);
|
||||
return cmdline.compilerMain(subargs).catchError((e) {});
|
||||
return cmdline.compilerMain(subargs);
|
||||
}).then((_) {
|
||||
print("Done");
|
||||
});
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
library dart2js.stress;
|
||||
|
||||
import 'package:compiler/src/dart2js.dart' as dart2js;
|
||||
|
@ -13,7 +11,7 @@ const ITERATIONS_FLAG_PREFIX = "--iterations=";
|
|||
void main(List<String> args) {
|
||||
Stopwatch sw = new Stopwatch();
|
||||
int count = 0;
|
||||
int maxCount = null;
|
||||
int? maxCount = null;
|
||||
if (args.isNotEmpty && args[0].startsWith(ITERATIONS_FLAG_PREFIX)) {
|
||||
maxCount = int.parse(args[0].substring(ITERATIONS_FLAG_PREFIX.length));
|
||||
args = args.sublist(1);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
import "dart:convert";
|
||||
import "dart:io";
|
||||
import "package:kernel/kernel.dart";
|
||||
|
@ -29,13 +27,11 @@ main(List<String> args) async {
|
|||
/// Visits classes in libraries specified by `libraryFilter`
|
||||
/// and aggregates metrics by class.
|
||||
class MetricsVisitor extends RecursiveVisitor {
|
||||
String currentClass;
|
||||
late String currentClass;
|
||||
List<String> libraryFilter;
|
||||
Map<String, ClassMetrics> classInfo = {};
|
||||
|
||||
MetricsVisitor([filter]) {
|
||||
libraryFilter = filter ?? [];
|
||||
}
|
||||
MetricsVisitor([List<String>? filter]) : libraryFilter = filter ?? [];
|
||||
|
||||
@override
|
||||
void visitComponent(Component node) {
|
||||
|
@ -58,7 +54,7 @@ class MetricsVisitor extends RecursiveVisitor {
|
|||
|
||||
@override
|
||||
void visitProcedure(Procedure node) {
|
||||
classInfo[currentClass].methods.add(ClassMetricsMethod(
|
||||
classInfo[currentClass]!.methods.add(ClassMetricsMethod(
|
||||
node.name.text,
|
||||
node.containsSuperCalls,
|
||||
node.isInstanceMember,
|
||||
|
@ -83,12 +79,12 @@ class MetricsVisitor extends RecursiveVisitor {
|
|||
// Check if Mixed.
|
||||
if (node.superclass?.isAnonymousMixin ?? false) {
|
||||
metrics.mixed = true;
|
||||
metrics.mixins = _filterMixins(node.superclass.demangledName);
|
||||
metrics.mixins = _filterMixins(node.superclass!.demangledName);
|
||||
}
|
||||
|
||||
// Add parents.
|
||||
if (node.superclass != null) {
|
||||
var unmangledParent = _getParent(node.superclass);
|
||||
var unmangledParent = _getParent(node.superclass!);
|
||||
metrics.parent = unmangledParent;
|
||||
}
|
||||
|
||||
|
@ -118,7 +114,7 @@ class MetricsVisitor extends RecursiveVisitor {
|
|||
// and returns parent class name.
|
||||
String _getParent(Class node) {
|
||||
if (node.isAnonymousMixin) {
|
||||
return _getParent(node.superclass);
|
||||
return _getParent(node.superclass!);
|
||||
}
|
||||
|
||||
return node.name;
|
||||
|
@ -139,19 +135,19 @@ class MetricsVisitor extends RecursiveVisitor {
|
|||
// adding child classes and overridden methods from parent.
|
||||
void _processData() {
|
||||
classInfo.keys.forEach((className) {
|
||||
var parentName = classInfo[className].parent;
|
||||
var parentName = classInfo[className]!.parent;
|
||||
if (classInfo[parentName] != null) {
|
||||
classInfo[parentName].inheritedBy.add(className);
|
||||
classInfo[parentName]!.inheritedBy.add(className);
|
||||
|
||||
var notOverridden = <String>[];
|
||||
var parentMethods = classInfo[parentName].methods.map((m) => m.name);
|
||||
var classMethods = classInfo[className].methods.map((m) => m.name);
|
||||
var parentMethods = classInfo[parentName]!.methods.map((m) => m.name);
|
||||
var classMethods = classInfo[className]!.methods.map((m) => m.name);
|
||||
|
||||
parentMethods.forEach((method) =>
|
||||
{if (!classMethods.contains(method)) notOverridden.add(method)});
|
||||
|
||||
// Update Method Info.
|
||||
classInfo[className].notOverriddenMethods = notOverridden;
|
||||
classInfo[className]!.notOverriddenMethods = notOverridden;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -177,7 +173,7 @@ class ClassMetrics {
|
|||
List<String> implementedTypes;
|
||||
List<String> notOverriddenMethods;
|
||||
List<String> inheritedBy;
|
||||
String parent;
|
||||
String? parent;
|
||||
bool mixed;
|
||||
bool containsNativeMember;
|
||||
|
||||
|
@ -185,17 +181,16 @@ class ClassMetrics {
|
|||
{this.mixed = false,
|
||||
this.containsNativeMember = false,
|
||||
this.parent,
|
||||
methods,
|
||||
mixins,
|
||||
notOverridden,
|
||||
implementedTypes,
|
||||
inheritedBy}) {
|
||||
this.methods = methods ?? [];
|
||||
this.mixins = mixins ?? [];
|
||||
this.notOverriddenMethods = notOverridden ?? [];
|
||||
this.implementedTypes = implementedTypes ?? [];
|
||||
this.inheritedBy = inheritedBy ?? [];
|
||||
}
|
||||
List<ClassMetricsMethod>? methods,
|
||||
List<String>? mixins,
|
||||
List<String>? notOverridden,
|
||||
List<String>? implementedTypes,
|
||||
List<String>? inheritedBy})
|
||||
: this.methods = methods ?? [],
|
||||
this.mixins = mixins ?? [],
|
||||
this.notOverriddenMethods = notOverridden ?? [],
|
||||
this.implementedTypes = implementedTypes ?? [],
|
||||
this.inheritedBy = inheritedBy ?? [];
|
||||
|
||||
bool get invokesSuper {
|
||||
if (methods.isNotEmpty) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
import "dart:io";
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
@ -16,58 +14,59 @@ import "../dart_html_metrics_visitor.dart";
|
|||
|
||||
void runTests(MetricsVisitor visitor) {
|
||||
test("Class A does not call super", () {
|
||||
Expect.equals(visitor.classInfo["A"].invokesSuper, false);
|
||||
Expect.equals(visitor.classInfo["A"]!.invokesSuper, false);
|
||||
});
|
||||
|
||||
test("Class B does call super", () {
|
||||
Expect.equals(visitor.classInfo["B"].invokesSuper, true);
|
||||
Expect.equals(visitor.classInfo["B"]!.invokesSuper, true);
|
||||
|
||||
var callingMethod = visitor.classInfo["B"].methods
|
||||
var callingMethod = visitor.classInfo["B"]!.methods
|
||||
.where((m) => m.name == "testSuper")
|
||||
.toList()[0];
|
||||
Expect.equals(callingMethod.invokesSuper, true);
|
||||
});
|
||||
|
||||
test("Class C does not call super", () {
|
||||
Expect.equals(visitor.classInfo["C"].invokesSuper, false);
|
||||
Expect.equals(visitor.classInfo["C"]!.invokesSuper, false);
|
||||
});
|
||||
|
||||
test("Class A inherited by B", () {
|
||||
Expect.equals(visitor.classInfo["A"].inheritedBy.contains("B"), true);
|
||||
Expect.equals(visitor.classInfo["B"].parent, "A");
|
||||
Expect.equals(visitor.classInfo["A"]!.inheritedBy.contains("B"), true);
|
||||
Expect.equals(visitor.classInfo["B"]!.parent, "A");
|
||||
});
|
||||
|
||||
test("Class B inherited by C", () {
|
||||
Expect.equals(visitor.classInfo["B"].inheritedBy.contains("C"), true);
|
||||
Expect.equals(visitor.classInfo["C"].parent, "B");
|
||||
Expect.equals(visitor.classInfo["B"]!.inheritedBy.contains("C"), true);
|
||||
Expect.equals(visitor.classInfo["C"]!.parent, "B");
|
||||
});
|
||||
|
||||
test("Class B inherited by F", () {
|
||||
Expect.equals(visitor.classInfo["B"].inheritedBy.contains("F"), true);
|
||||
Expect.equals(visitor.classInfo["F"].parent, "B");
|
||||
Expect.equals(visitor.classInfo["B"]!.inheritedBy.contains("F"), true);
|
||||
Expect.equals(visitor.classInfo["F"]!.parent, "B");
|
||||
});
|
||||
|
||||
test("Class C inherited by nothing", () {
|
||||
Expect.equals(visitor.classInfo["C"].inheritedBy.length, 0);
|
||||
Expect.equals(visitor.classInfo["C"]!.inheritedBy.length, 0);
|
||||
});
|
||||
|
||||
test("Class D mixed with Mix1 and Mix2", () {
|
||||
Expect.equals(visitor.classInfo["D"].mixed, true);
|
||||
Expect.deepEquals(visitor.classInfo["D"].mixins, ["Mix1", "Mix2"]);
|
||||
Expect.equals(visitor.classInfo["D"]!.mixed, true);
|
||||
Expect.deepEquals(visitor.classInfo["D"]!.mixins, ["Mix1", "Mix2"]);
|
||||
});
|
||||
|
||||
test("Class F mixed with Mix1 and Mix2", () {
|
||||
Expect.equals(visitor.classInfo["F"].mixed, true);
|
||||
Expect.deepEquals(visitor.classInfo["F"].mixins, ["Mix1", "Mix2"]);
|
||||
Expect.equals(visitor.classInfo["F"]!.mixed, true);
|
||||
Expect.deepEquals(visitor.classInfo["F"]!.mixins, ["Mix1", "Mix2"]);
|
||||
});
|
||||
|
||||
test("Class E implements A", () {
|
||||
Expect.equals(visitor.classInfo["E"].implementedTypes.contains("A"), true);
|
||||
Expect.equals(visitor.classInfo["E"]!.implementedTypes.contains("A"), true);
|
||||
});
|
||||
|
||||
test("Class G extends A but fails to override getValue()", () {
|
||||
Expect.equals(
|
||||
visitor.classInfo["G"].notOverriddenMethods.contains("getValue"), true);
|
||||
visitor.classInfo["G"]!.notOverriddenMethods.contains("getValue"),
|
||||
true);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -2,21 +2,19 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:compiler/src/commandline_options.dart';
|
||||
|
||||
main(List<String> args) async {
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
String input;
|
||||
String serializedInput;
|
||||
String? input;
|
||||
String? serializedInput;
|
||||
String output = 'out.js';
|
||||
List<String> arguments = [];
|
||||
int start = 0;
|
||||
int stop = 3;
|
||||
int shards;
|
||||
int? shards;
|
||||
bool enableAssertions = false;
|
||||
for (String arg in args) {
|
||||
if (arg.startsWith('-')) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
/// Test the modular compilation pipeline of dart2js.
|
||||
///
|
||||
/// This is a shell that runs multiple tests, one per folder under `data/`.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
/// Test the modular compilation pipeline of dart2js.
|
||||
///
|
||||
/// This is a shell that runs multiple tests, one per folder under `data/`.
|
||||
|
@ -23,9 +21,9 @@ import 'package:modular_test/src/suite.dart';
|
|||
String packageConfigJsonPath = ".dart_tool/package_config.json";
|
||||
Uri sdkRoot = Platform.script.resolve("../../../");
|
||||
Uri packageConfigUri = sdkRoot.resolve(packageConfigJsonPath);
|
||||
Options _options;
|
||||
String _dart2jsScript;
|
||||
String _kernelWorkerScript;
|
||||
late Options _options;
|
||||
late String _dart2jsScript;
|
||||
late String _kernelWorkerScript;
|
||||
|
||||
const dillSummaryId = DataId("summary.dill");
|
||||
const dillId = DataId("full.dill");
|
||||
|
@ -57,7 +55,7 @@ String getRootScheme(Module module) {
|
|||
|
||||
String sourceToImportUri(Module module, Uri relativeUri) {
|
||||
if (module.isPackage) {
|
||||
var basePath = module.packageBase.path;
|
||||
var basePath = module.packageBase!.path;
|
||||
var packageRelativePath = basePath == "./"
|
||||
? relativeUri.path
|
||||
: relativeUri.path.substring(basePath.length);
|
||||
|
@ -112,7 +110,7 @@ abstract class CFEStep extends IOModularStep {
|
|||
await File.fromUri(platform).copy(destination.toFilePath());
|
||||
return;
|
||||
}
|
||||
sources = requiredLibraries['dart2js'] + ['dart:core'];
|
||||
sources = requiredLibraries['dart2js']! + ['dart:core'];
|
||||
extraArgs += [
|
||||
'--libraries-file',
|
||||
'$rootScheme:///sdk/lib/libraries.json'
|
||||
|
@ -331,7 +329,7 @@ class ConcatenateDillsStep extends IOModularStep {
|
|||
@override
|
||||
bool get onlyOnMain => true;
|
||||
|
||||
ConcatenateDillsStep({this.useModularAnalysis});
|
||||
ConcatenateDillsStep({required this.useModularAnalysis});
|
||||
|
||||
@override
|
||||
Future<void> execute(Module module, Uri root, ModuleDataToRelativeUri toUri,
|
||||
|
@ -380,7 +378,7 @@ class ConcatenateDillsStep extends IOModularStep {
|
|||
class ComputeClosedWorldStep extends IOModularStep {
|
||||
final bool useModularAnalysis;
|
||||
|
||||
ComputeClosedWorldStep({this.useModularAnalysis});
|
||||
ComputeClosedWorldStep({required this.useModularAnalysis});
|
||||
|
||||
List<DataId> get dependencies => [
|
||||
fullDillId,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
/// Test the modular compilation pipeline of dart2js.
|
||||
///
|
||||
/// This is a shell that runs multiple tests, one per folder under `data/`.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
// ignore_for_file: avoid_dynamic_calls
|
||||
|
||||
/// A script to track the high water-mark of memory usage of an application.
|
||||
|
@ -21,7 +19,7 @@ import 'dart:async';
|
|||
import 'dart:convert';
|
||||
|
||||
/// Socket to connect to the vm observatory service.
|
||||
WebSocket socket;
|
||||
late WebSocket socket;
|
||||
|
||||
main(args) async {
|
||||
_printHeader();
|
||||
|
@ -80,8 +78,8 @@ Future _sendMessage(String method, [Map args = const {}]) {
|
|||
}
|
||||
|
||||
/// Handle all responses
|
||||
void _handleResponse(Object s) {
|
||||
var json = jsonDecode(s);
|
||||
void _handleResponse(Object? s) {
|
||||
var json = jsonDecode(s as String);
|
||||
if (json['method'] != 'streamNotify') {
|
||||
var id = json['id'];
|
||||
if (id is String) id = int.parse(id);
|
||||
|
@ -177,7 +175,7 @@ _writeNumber(sb, before, now, {color = false}) {
|
|||
: before > now
|
||||
? _GREEN
|
||||
: '');
|
||||
var string;
|
||||
String string;
|
||||
if (now < 1024) {
|
||||
string = ' ${now}b';
|
||||
} else if (now < mega) {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
import 'package:_fe_analyzer_shared/src/testing/id_testing.dart' as id;
|
||||
|
||||
const List<String> idTests = <String>[
|
||||
|
|
Loading…
Reference in a new issue