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

Side by Side Diff: pkg/compiler/lib/src/ssa/kernel_impact.dart

Issue 2392943003: Handle const constructor invocation in kernel_impact. (Closed)
Patch Set: Created 4 years, 2 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 4
5 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart'; 8 import '../common/names.dart';
9 import '../compiler.dart'; 9 import '../compiler.dart';
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 215
216 @override 216 @override
217 void visitConstructorInvocation(ir.ConstructorInvocation node) { 217 void visitConstructorInvocation(ir.ConstructorInvocation node) {
218 handleNew(node, node.target); 218 handleNew(node, node.target);
219 } 219 }
220 220
221 void handleNew(ir.InvocationExpression node, ir.Member target) { 221 void handleNew(ir.InvocationExpression node, ir.Member target) {
222 _visitArguments(node.arguments); 222 _visitArguments(node.arguments);
223 Element element = astAdapter.getElement(target).declaration; 223 Element element = astAdapter.getElement(target).declaration;
224 impactBuilder.registerStaticUse(new StaticUse.constructorInvoke(
225 element, astAdapter.getCallStructure(node.arguments)));
226 ClassElement cls = astAdapter.getElement(target.enclosingClass); 224 ClassElement cls = astAdapter.getElement(target.enclosingClass);
227 List<DartType> typeArguments = 225 List<DartType> typeArguments =
228 astAdapter.getDartTypes(node.arguments.types); 226 astAdapter.getDartTypes(node.arguments.types);
229 impactBuilder.registerTypeUse( 227 InterfaceType type = new InterfaceType(cls, typeArguments);
230 new TypeUse.instantiation(new InterfaceType(cls, typeArguments))); 228 impactBuilder.registerStaticUse(new StaticUse.typedConstructorInvoke(
229 element, astAdapter.getCallStructure(node.arguments), type));
231 if (typeArguments.any((DartType type) => !type.isDynamic)) { 230 if (typeArguments.any((DartType type) => !type.isDynamic)) {
232 impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); 231 impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK);
233 } 232 }
234 } 233 }
235 234
236 @override 235 @override
237 void visitStaticInvocation(ir.StaticInvocation node) { 236 void visitStaticInvocation(ir.StaticInvocation node) {
238 Element target = astAdapter.getElement(node.target).declaration; 237 Element target = astAdapter.getElement(node.target).declaration;
239 if (target.isFactoryConstructor) { 238 if (target.isFactoryConstructor) {
240 // TODO(johnniwinther): We should not mark the type as instantiated but 239 // TODO(johnniwinther): We should not mark the type as instantiated but
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 void visitTryFinally(ir.TryFinally node) { 413 void visitTryFinally(ir.TryFinally node) {
415 visitNode(node.body); 414 visitNode(node.body);
416 visitNode(node.finalizer); 415 visitNode(node.finalizer);
417 } 416 }
418 417
419 // TODO(johnniwinther): Make this throw and visit child nodes explicitly 418 // TODO(johnniwinther): Make this throw and visit child nodes explicitly
420 // instead to ensure that we don't visit unwanted parts of the ir. 419 // instead to ensure that we don't visit unwanted parts of the ir.
421 @override 420 @override
422 void defaultNode(ir.Node node) => node.visitChildren(this); 421 void defaultNode(ir.Node node) => node.visitChildren(this);
423 } 422 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698