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

Side by Side Diff: pkg/kernel/test/treeshaker_check.dart

Issue 2918593003: Pass ClassHierarchy instead of creating it. (Closed)
Patch Set: Created 3 years, 6 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library kernel.treeshaker_check; 4 library kernel.treeshaker_check;
5 5
6 import 'dart:io';
7
8 import 'package:kernel/class_hierarchy.dart';
6 import 'package:kernel/core_types.dart'; 9 import 'package:kernel/core_types.dart';
7 import 'package:kernel/kernel.dart'; 10 import 'package:kernel/kernel.dart';
8 import 'package:kernel/transformations/treeshaker.dart'; 11 import 'package:kernel/transformations/treeshaker.dart';
9 import 'dart:io';
10 12
11 String usage = ''' 13 String usage = '''
12 Usage: treeshaker_check FILE.dill 14 Usage: treeshaker_check FILE.dill
13 15
14 Run the tree shaker on FILE.dill and perform some internal sanity checks. 16 Run the tree shaker on FILE.dill and perform some internal sanity checks.
15 '''; 17 ''';
16 18
17 main(List<String> args) { 19 main(List<String> args) {
18 if (args.length == 0) { 20 if (args.length == 0) {
19 print(usage); 21 print(usage);
20 exit(1); 22 exit(1);
21 } 23 }
22 var program = loadProgramFromBinary(args[0]); 24 var program = loadProgramFromBinary(args[0]);
23 var coreTypes = new CoreTypes(program); 25 var coreTypes = new CoreTypes(program);
24 var shaker = new TreeShaker(coreTypes, program); 26 var hierarchy = new ClosedWorldClassHierarchy(program);
27 var shaker = new TreeShaker(coreTypes, hierarchy, program);
25 shaker.transform(program); 28 shaker.transform(program);
26 new TreeShakingSanityCheck(shaker).visit(program); 29 new TreeShakingSanityCheck(shaker).visit(program);
27 } 30 }
28 31
29 class TreeShakingSanityCheck extends RecursiveVisitor { 32 class TreeShakingSanityCheck extends RecursiveVisitor {
30 final TreeShaker shaker; 33 final TreeShaker shaker;
31 bool isInCoreLibrary = false; 34 bool isInCoreLibrary = false;
32 35
33 TreeShakingSanityCheck(this.shaker); 36 TreeShakingSanityCheck(this.shaker);
34 37
(...skipping 13 matching lines...) Expand all
48 throw 'Unused member $member was not removed'; 51 throw 'Unused member $member was not removed';
49 } 52 }
50 } 53 }
51 54
52 defaultMemberReference(Member target) { 55 defaultMemberReference(Member target) {
53 if (!shaker.isMemberUsed(target)) { 56 if (!shaker.isMemberUsed(target)) {
54 throw 'Found reference to $target'; 57 throw 'Found reference to $target';
55 } 58 }
56 } 59 }
57 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698