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

Side by Side Diff: pkg/kernel/lib/transformations/method_call.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 4
5 library kernel.transformations.method_call; 5 library kernel.transformations.method_call;
6 6
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 8
9 import '../ast.dart'; 9 import '../ast.dart';
10 import '../class_hierarchy.dart'; 10 import '../class_hierarchy.dart';
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 /// } 46 /// }
47 /// 47 ///
48 /// class B extends A { 48 /// class B extends A {
49 /// foo(required1) => print("Hello from class B"); 49 /// foo(required1) => print("Hello from class B");
50 /// } 50 /// }
51 /// 51 ///
52 /// main() { 52 /// main() {
53 /// var b = new B(); 53 /// var b = new B();
54 /// b.foo(499, named1: 88); 54 /// b.foo(499, named1: 88);
55 /// } 55 /// }
56 Program transformProgram(CoreTypes coreTypes, Program program, 56 Program transformProgram(
57 CoreTypes coreTypes, ClassHierarchy hierarchy, Program program,
57 [debug = false]) { 58 [debug = false]) {
58 new MethodCallTransformer(coreTypes, debug).visitProgram(program); 59 new MethodCallTransformer(coreTypes, hierarchy, debug).visitProgram(program);
59 return program; 60 return program;
60 } 61 }
61 62
62 class MethodCallTransformer extends Transformer { 63 class MethodCallTransformer extends Transformer {
63 final CoreTypes coreTypes; 64 final CoreTypes coreTypes;
64 65
65 /// Keep track of "visited" procedures and constructors to not visit already 66 /// Keep track of "visited" procedures and constructors to not visit already
66 /// visited stuff, nor visit newly created stubs. 67 /// visited stuff, nor visit newly created stubs.
67 Set<Member> _visited = new Set<Member>(); 68 Set<Member> _visited = new Set<Member>();
68 69
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 105
105 /// Whether in debug mode, i.e. if we can insert extra print statements for 106 /// Whether in debug mode, i.e. if we can insert extra print statements for
106 /// debugging purposes. 107 /// debugging purposes.
107 bool _debug; 108 bool _debug;
108 109
109 /// For noSuchMethod calls. 110 /// For noSuchMethod calls.
110 ClassHierarchy hierarchy; 111 ClassHierarchy hierarchy;
111 Constructor _invocationMirrorConstructor; // cached 112 Constructor _invocationMirrorConstructor; // cached
112 Procedure _listFrom; // cached 113 Procedure _listFrom; // cached
113 114
114 MethodCallTransformer(this.coreTypes, this._debug); 115 MethodCallTransformer(this.coreTypes, this.hierarchy, this._debug);
115 116
116 @override 117 @override
117 TreeNode visitProgram(Program node) { 118 TreeNode visitProgram(Program node) {
118 hierarchy = new ClassHierarchy(node);
119
120 // First move body of all procedures that takes optional positional or named 119 // First move body of all procedures that takes optional positional or named
121 // parameters and record which non-static procedure names have optional 120 // parameters and record which non-static procedure names have optional
122 // positional arguments. 121 // positional arguments.
123 // Do the same for constructors. Then also rewrite constructor initializers 122 // Do the same for constructors. Then also rewrite constructor initializers
124 // using LocalInitializer and sort named arguments in those initializers 123 // using LocalInitializer and sort named arguments in those initializers
125 for (final library in node.libraries) { 124 for (final library in node.libraries) {
126 for (final procedure in new List<Procedure>.from(library.procedures)) { 125 for (final procedure in new List<Procedure>.from(library.procedures)) {
127 _moveAndTransformProcedure(procedure); 126 _moveAndTransformProcedure(procedure);
128 } 127 }
129 128
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 return printStackTrace; 1306 return printStackTrace;
1308 } 1307 }
1309 } 1308 }
1310 1309
1311 class _Pair<K, V> { 1310 class _Pair<K, V> {
1312 final K key; 1311 final K key;
1313 final V value; 1312 final V value;
1314 1313
1315 _Pair(this.key, this.value); 1314 _Pair(this.key, this.value);
1316 } 1315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698