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

Side by Side Diff: pkg/kernel/bin/transform.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 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:args/args.dart'; 9 import 'package:args/args.dart';
10 import 'package:kernel/class_hierarchy.dart';
10 import 'package:kernel/core_types.dart'; 11 import 'package:kernel/core_types.dart';
11 import 'package:kernel/kernel.dart'; 12 import 'package:kernel/kernel.dart';
12 import 'package:kernel/target/targets.dart'; 13 import 'package:kernel/target/targets.dart';
13 import 'package:kernel/transformations/closure_conversion.dart' as closures; 14 import 'package:kernel/transformations/closure_conversion.dart' as closures;
14 import 'package:kernel/transformations/continuation.dart' as cont; 15 import 'package:kernel/transformations/continuation.dart' as cont;
15 import 'package:kernel/transformations/empty.dart' as empty; 16 import 'package:kernel/transformations/empty.dart' as empty;
16 import 'package:kernel/transformations/method_call.dart' as method_call; 17 import 'package:kernel/transformations/method_call.dart' as method_call;
17 import 'package:kernel/transformations/mixin_full_resolution.dart' as mix; 18 import 'package:kernel/transformations/mixin_full_resolution.dart' as mix;
18 import 'package:kernel/transformations/treeshaker.dart' as treeshaker; 19 import 'package:kernel/transformations/treeshaker.dart' as treeshaker;
19 import 'package:kernel/verifier.dart'; 20 import 'package:kernel/verifier.dart';
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 output = '${input.substring(0, input.lastIndexOf('.'))}.transformed.dill'; 71 output = '${input.substring(0, input.lastIndexOf('.'))}.transformed.dill';
71 } 72 }
72 73
73 List<String> embedderEntryPointManifests = 74 List<String> embedderEntryPointManifests =
74 options['embedder-entry-points-manifest'] as List<String>; 75 options['embedder-entry-points-manifest'] as List<String>;
75 List<treeshaker.ProgramRoot> programRoots = 76 List<treeshaker.ProgramRoot> programRoots =
76 parseProgramRoots(embedderEntryPointManifests); 77 parseProgramRoots(embedderEntryPointManifests);
77 78
78 var program = loadProgramFromBinary(input); 79 var program = loadProgramFromBinary(input);
79 var coreTypes = new CoreTypes(program); 80 var coreTypes = new CoreTypes(program);
81 var hierarchy = new ClosedWorldClassHierarchy(program);
80 switch (options['transformation']) { 82 switch (options['transformation']) {
81 case 'continuation': 83 case 'continuation':
82 program = cont.transformProgram(coreTypes, program); 84 program = cont.transformProgram(coreTypes, program);
83 break; 85 break;
84 case 'resolve-mixins': 86 case 'resolve-mixins':
85 mix.transformLibraries( 87 mix.transformLibraries(
86 new NoneTarget(null), coreTypes, program.libraries); 88 new NoneTarget(null), coreTypes, hierarchy, program.libraries);
87 break; 89 break;
88 case 'closures': 90 case 'closures':
89 program = closures.transformProgram(coreTypes, program); 91 program = closures.transformProgram(coreTypes, program);
90 break; 92 break;
91 case 'treeshake': 93 case 'treeshake':
92 program = treeshaker.transformProgram(coreTypes, program, 94 program = treeshaker.transformProgram(coreTypes, hierarchy, program,
93 programRoots: programRoots); 95 programRoots: programRoots);
94 break; 96 break;
95 case 'methodcall': 97 case 'methodcall':
96 program = method_call.transformProgram(coreTypes, program); 98 program = method_call.transformProgram(coreTypes, hierarchy, program);
97 break; 99 break;
98 case 'empty': 100 case 'empty':
99 program = empty.transformProgram(program); 101 program = empty.transformProgram(program);
100 break; 102 break;
101 default: 103 default:
102 throw 'Unknown transformation'; 104 throw 'Unknown transformation';
103 } 105 }
104 106
105 verifyProgram(program); 107 verifyProgram(program);
106 108
107 if (format == 'text') { 109 if (format == 'text') {
108 writeProgramToText(program, path: output); 110 writeProgramToText(program, path: output);
109 } else { 111 } else {
110 assert(format == 'bin'); 112 assert(format == 'bin');
111 await writeProgramToBinary(program, output); 113 await writeProgramToBinary(program, output);
112 } 114 }
113 115
114 if (verbose) { 116 if (verbose) {
115 writeLibraryToText(program.mainMethod.parent as Library); 117 writeLibraryToText(program.mainMethod.parent as Library);
116 } 118 }
117 119
118 return CompilerOutcome.Ok; 120 return CompilerOutcome.Ok;
119 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698