mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:45:06 +00:00
[cfe] Updates cf. equivalence visitors comments
Change-Id: Ib5990cf1434ce07019e9602150df66b359476095 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210863 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
6ee9cd0df1
commit
b54269e255
|
@ -1079,7 +1079,7 @@ rpc
|
|||
rs
|
||||
runnable
|
||||
s
|
||||
sand
|
||||
sandboxed
|
||||
sanitizing
|
||||
saw
|
||||
say
|
||||
|
|
|
@ -820,7 +820,7 @@ row
|
|||
rows
|
||||
runtimes
|
||||
rv
|
||||
sand
|
||||
sandboxed
|
||||
saves
|
||||
scans
|
||||
scheduler
|
||||
|
|
|
@ -505,17 +505,24 @@ class AstModel {
|
|||
///
|
||||
/// If [printDump] is `true`, a dump of the model printed to stdout.
|
||||
Future<AstModel> deriveAstModel(Uri repoDir, {bool printDump: false}) async {
|
||||
bool errorsFound = false;
|
||||
CompilerOptions options = new CompilerOptions();
|
||||
options.sdkRoot = computePlatformBinariesLocation(forceBuildDir: true);
|
||||
options.packagesFileUri = computePackageConfig(repoDir);
|
||||
options.onDiagnostic = (DiagnosticMessage message) {
|
||||
printDiagnosticMessage(message, print);
|
||||
if (message.severity == Severity.error) {
|
||||
errorsFound = true;
|
||||
}
|
||||
};
|
||||
|
||||
InternalCompilerResult compilerResult = (await kernelForProgramInternal(
|
||||
astLibraryUri, options,
|
||||
retainDataForTesting: true,
|
||||
requireMain: false)) as InternalCompilerResult;
|
||||
if (errorsFound) {
|
||||
throw 'Errors found';
|
||||
}
|
||||
ClassHierarchy classHierarchy = compilerResult.classHierarchy!;
|
||||
CoreTypes coreTypes = compilerResult.coreTypes!;
|
||||
TypeEnvironment typeEnvironment =
|
||||
|
@ -524,7 +531,6 @@ Future<AstModel> deriveAstModel(Uri repoDir, {bool printDump: false}) async {
|
|||
Library astLibrary = compilerResult.component!.libraries
|
||||
.singleWhere((library) => library.importUri == astLibraryUri);
|
||||
|
||||
bool errorsFound = false;
|
||||
void reportError(String message) {
|
||||
print(message);
|
||||
errorsFound = true;
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
// 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.
|
||||
|
||||
/// Implementation of a union-find algorithm.
|
||||
///
|
||||
/// See https://en.wikipedia.org/wiki/Disjoint-set_data_structure
|
||||
|
||||
import 'dart:collection';
|
||||
|
||||
class UnionFindNode<T> {
|
||||
|
@ -46,6 +50,7 @@ class UnionFind<T> {
|
|||
|
||||
UnionFindNode<T> findNode(UnionFindNode<T> node) {
|
||||
if (node.parent != null) {
|
||||
// Perform path compression by updating to the effective target.
|
||||
return node.parent = findNode(node.parent!);
|
||||
}
|
||||
return node;
|
||||
|
|
|
@ -67,23 +67,22 @@ Values true and false are not equivalent
|
|||
'''),
|
||||
Test(component1, component2),
|
||||
Test(component1.libraries[0], component2.libraries[0]),
|
||||
Test(component1.libraries[0], component2.libraries[0]),
|
||||
Test(component1.libraries[0], component2.libraries[1], inequivalence: '''
|
||||
Inequivalent nodes
|
||||
1: library file://uri1/
|
||||
2: library file://uri2/
|
||||
1: library import://uri1
|
||||
2: library import://uri2
|
||||
.root
|
||||
'''),
|
||||
Test(component1.libraries[1], component2.libraries[2], inequivalence: '''
|
||||
Inequivalent nodes
|
||||
1: library file://uri2/
|
||||
2: library file://uri3/
|
||||
1: library import://uri2
|
||||
2: library import://uri3
|
||||
.root
|
||||
'''),
|
||||
Test(component1.libraries[1], component2.libraries[3], inequivalence: '''
|
||||
Values file://uri2/ and file://uri3/ are not equivalent
|
||||
.root
|
||||
Library(library file://uri2/).fileUri
|
||||
Library(library import://uri2).fileUri
|
||||
'''),
|
||||
Test(component1.libraries[0].procedures[0],
|
||||
component2.libraries[0].procedures[1],
|
||||
|
@ -173,31 +172,34 @@ class IgnoreIntLiteralValue extends EquivalenceStrategy {
|
|||
|
||||
Component createComponent() {
|
||||
Component component = new Component();
|
||||
Uri uri1 = Uri.parse('file://uri1');
|
||||
Uri uri2 = Uri.parse('file://uri2');
|
||||
Uri uri3 = Uri.parse('file://uri3');
|
||||
Library library1 = new Library(uri1, fileUri: uri1);
|
||||
Uri fileUri1 = Uri.parse('file://uri1');
|
||||
Uri fileUri2 = Uri.parse('file://uri2');
|
||||
Uri fileUri3 = Uri.parse('file://uri3');
|
||||
Uri importUri1 = Uri.parse('import://uri1');
|
||||
Uri importUri2 = Uri.parse('import://uri2');
|
||||
Uri importUri3 = Uri.parse('import://uri3');
|
||||
Library library1 = new Library(importUri1, fileUri: fileUri1);
|
||||
component.libraries.add(library1);
|
||||
Procedure procedure1foo = new Procedure(
|
||||
new Name('foo'), ProcedureKind.Method, new FunctionNode(null),
|
||||
fileUri: uri1);
|
||||
fileUri: fileUri1);
|
||||
library1.addProcedure(procedure1foo);
|
||||
Procedure procedure1bar = new Procedure(
|
||||
new Name('bar'), ProcedureKind.Method, new FunctionNode(null),
|
||||
fileUri: uri1);
|
||||
fileUri: fileUri1);
|
||||
library1.addProcedure(procedure1bar);
|
||||
|
||||
Library library2 = new Library(uri2, fileUri: uri2);
|
||||
Library library2 = new Library(importUri2, fileUri: fileUri2);
|
||||
component.libraries.add(library2);
|
||||
|
||||
Library library3 = new Library(uri3, fileUri: uri2);
|
||||
Library library3 = new Library(importUri3, fileUri: fileUri2);
|
||||
component.libraries.add(library3);
|
||||
Procedure procedure3foo = new Procedure(
|
||||
new Name('foo'), ProcedureKind.Method, new FunctionNode(null),
|
||||
fileUri: uri1);
|
||||
fileUri: fileUri1);
|
||||
library3.addProcedure(procedure3foo);
|
||||
|
||||
Library library4 = new Library(uri2, fileUri: uri3);
|
||||
Library library4 = new Library(importUri2, fileUri: fileUri3);
|
||||
component.libraries.add(library4);
|
||||
|
||||
return component;
|
||||
|
|
Loading…
Reference in a new issue