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

Side by Side Diff: pkg/kernel/lib/transformations/mixin_full_resolution.dart

Issue 2927613002: Improve NSM handling. (Closed)
Patch Set: Address review comments. 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
« no previous file with comments | « pkg/kernel/lib/target/vm.dart ('k') | runtime/lib/errors_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.transformations.mixin_full_resolution; 4 library kernel.transformations.mixin_full_resolution;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../class_hierarchy.dart'; 7 import '../class_hierarchy.dart';
8 import '../clone.dart'; 8 import '../clone.dart';
9 import '../core_types.dart'; 9 import '../core_types.dart';
10 import '../target/targets.dart' show Target; 10 import '../target/targets.dart' show Target;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 name: superclassConstructor.name, 193 name: superclassConstructor.name,
194 initializers: <Initializer>[superInitializer]); 194 initializers: <Initializer>[superInitializer]);
195 } 195 }
196 } 196 }
197 197
198 class SuperCallResolutionTransformer extends Transformer { 198 class SuperCallResolutionTransformer extends Transformer {
199 final ClassHierarchy hierarchy; 199 final ClassHierarchy hierarchy;
200 final CoreTypes coreTypes; 200 final CoreTypes coreTypes;
201 final Class lookupClass; 201 final Class lookupClass;
202 final Target targetInfo; 202 final Target targetInfo;
203 Constructor _invocationMirrorConstructor; // cached
204 203
205 SuperCallResolutionTransformer( 204 SuperCallResolutionTransformer(
206 this.hierarchy, this.coreTypes, this.lookupClass, this.targetInfo); 205 this.hierarchy, this.coreTypes, this.lookupClass, this.targetInfo);
207 206
208 TreeNode visit(TreeNode node) => node.accept(this); 207 TreeNode visit(TreeNode node) => node.accept(this);
209 208
210 visitSuperPropertyGet(SuperPropertyGet node) { 209 visitSuperPropertyGet(SuperPropertyGet node) {
211 Member target = hierarchy.getDispatchTarget(lookupClass, node.name); 210 Member target = hierarchy.getDispatchTarget(lookupClass, node.name);
212 if (target != null) { 211 if (target != null) {
213 return new DirectPropertyGet(new ThisExpression(), target) 212 return new DirectPropertyGet(new ThisExpression(), target)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 new Arguments([invocation]), false, new ThisExpression()); 288 new Arguments([invocation]), false, new ThisExpression());
290 return new DirectMethodInvocation( 289 return new DirectMethodInvocation(
291 new ThisExpression(), noSuchMethod, new Arguments([invocationPrime])) 290 new ThisExpression(), noSuchMethod, new Arguments([invocationPrime]))
292 ..fileOffset = node.fileOffset; 291 ..fileOffset = node.fileOffset;
293 } 292 }
294 } 293 }
295 294
296 /// Creates an "new _InvocationMirror(...)" invocation. 295 /// Creates an "new _InvocationMirror(...)" invocation.
297 ConstructorInvocation _createInvocation(String methodName, 296 ConstructorInvocation _createInvocation(String methodName,
298 Arguments callArguments, bool isSuperInvocation, Expression receiver) { 297 Arguments callArguments, bool isSuperInvocation, Expression receiver) {
299 if (_invocationMirrorConstructor == null) { 298 return targetInfo.instantiateInvocation(
300 Class clazz = coreTypes.invocationMirrorClass; 299 coreTypes, receiver, methodName, callArguments, -1, isSuperInvocation);
301 _invocationMirrorConstructor = clazz.constructors[0];
302 }
303
304 return targetInfo.instantiateInvocation(_invocationMirrorConstructor,
305 receiver, methodName, callArguments, -1, isSuperInvocation);
306 } 300 }
307 301
308 /// Check that a call to the targetFunction is legal given the arguments. 302 /// Check that a call to the targetFunction is legal given the arguments.
309 /// 303 ///
310 /// I.e. check that the number of positional parameters and the names of the 304 /// I.e. check that the number of positional parameters and the names of the
311 /// given named parameters represents a valid call to the function. 305 /// given named parameters represents a valid call to the function.
312 bool _callIsLegal(FunctionNode targetFunction, Arguments arguments) { 306 bool _callIsLegal(FunctionNode targetFunction, Arguments arguments) {
313 if ((targetFunction.requiredParameterCount > arguments.positional.length) || 307 if ((targetFunction.requiredParameterCount > arguments.positional.length) ||
314 (targetFunction.positionalParameters.length < 308 (targetFunction.positionalParameters.length <
315 arguments.positional.length)) { 309 arguments.positional.length)) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 return null; 344 return null;
351 } 345 }
352 } 346 }
353 347
354 throw new Exception( 348 throw new Exception(
355 'Could not find a generative constructor named "${constructor.name}" ' 349 'Could not find a generative constructor named "${constructor.name}" '
356 'in lookup class "${lookupClass.name}"!'); 350 'in lookup class "${lookupClass.name}"!');
357 } 351 }
358 } 352 }
359 } 353 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/target/vm.dart ('k') | runtime/lib/errors_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698