| OLD | NEW |
| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 | 247 |
| 248 @override | 248 @override |
| 249 void visitConstructorInvocation(ir.ConstructorInvocation node) { | 249 void visitConstructorInvocation(ir.ConstructorInvocation node) { |
| 250 handleNew(node, node.target, isConst: node.isConst); | 250 handleNew(node, node.target, isConst: node.isConst); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void handleNew(ir.InvocationExpression node, ir.Member target, | 253 void handleNew(ir.InvocationExpression node, ir.Member target, |
| 254 {bool isConst: false}) { | 254 {bool isConst: false}) { |
| 255 _visitArguments(node.arguments); | 255 _visitArguments(node.arguments); |
| 256 FunctionEntity constructor = elementAdapter.getConstructor(target); | 256 ConstructorEntity constructor = elementAdapter.getConstructor(target); |
| 257 InterfaceType type = elementAdapter.createInterfaceType( | 257 InterfaceType type = elementAdapter.createInterfaceType( |
| 258 target.enclosingClass, node.arguments.types); | 258 target.enclosingClass, node.arguments.types); |
| 259 CallStructure callStructure = | 259 CallStructure callStructure = |
| 260 elementAdapter.getCallStructure(node.arguments); | 260 elementAdapter.getCallStructure(node.arguments); |
| 261 impactBuilder.registerStaticUse(isConst | 261 impactBuilder.registerStaticUse(isConst |
| 262 ? new StaticUse.constConstructorInvoke(constructor, callStructure, type) | 262 ? new StaticUse.constConstructorInvoke(constructor, callStructure, type) |
| 263 : new StaticUse.typedConstructorInvoke( | 263 : new StaticUse.typedConstructorInvoke( |
| 264 constructor, callStructure, type)); | 264 constructor, callStructure, type)); |
| 265 if (type.typeArguments.any((DartType type) => !type.isDynamic)) { | 265 if (type.typeArguments.any((DartType type) => !type.isDynamic)) { |
| 266 impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); | 266 impactBuilder.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 @override | 270 @override |
| 271 void visitSuperInitializer(ir.SuperInitializer node) { | 271 void visitSuperInitializer(ir.SuperInitializer node) { |
| 272 FunctionEntity target = elementAdapter.getConstructor(node.target); | 272 ConstructorEntity target = elementAdapter.getConstructor(node.target); |
| 273 _visitArguments(node.arguments); | 273 _visitArguments(node.arguments); |
| 274 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( | 274 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( |
| 275 target, elementAdapter.getCallStructure(node.arguments))); | 275 target, elementAdapter.getCallStructure(node.arguments))); |
| 276 } | 276 } |
| 277 | 277 |
| 278 @override | 278 @override |
| 279 void visitStaticInvocation(ir.StaticInvocation node) { | 279 void visitStaticInvocation(ir.StaticInvocation node) { |
| 280 FunctionEntity target = elementAdapter.getMethod(node.target); | 280 FunctionEntity target = elementAdapter.getMethod(node.target); |
| 281 if (node.target.kind == ir.ProcedureKind.Factory) { | 281 if (node.target.kind == ir.ProcedureKind.Factory) { |
| 282 // TODO(johnniwinther): We should not mark the type as instantiated but | 282 // TODO(johnniwinther): We should not mark the type as instantiated but |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 @override | 552 @override |
| 553 void visitFieldInitializer(ir.FieldInitializer node) { | 553 void visitFieldInitializer(ir.FieldInitializer node) { |
| 554 impactBuilder.registerStaticUse( | 554 impactBuilder.registerStaticUse( |
| 555 new StaticUse.fieldInit(elementAdapter.getField(node.field))); | 555 new StaticUse.fieldInit(elementAdapter.getField(node.field))); |
| 556 visitNode(node.value); | 556 visitNode(node.value); |
| 557 } | 557 } |
| 558 | 558 |
| 559 @override | 559 @override |
| 560 void visitRedirectingInitializer(ir.RedirectingInitializer node) { | 560 void visitRedirectingInitializer(ir.RedirectingInitializer node) { |
| 561 _visitArguments(node.arguments); | 561 _visitArguments(node.arguments); |
| 562 FunctionEntity target = elementAdapter.getConstructor(node.target); | 562 ConstructorEntity target = elementAdapter.getConstructor(node.target); |
| 563 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( | 563 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( |
| 564 target, elementAdapter.getCallStructure(node.arguments))); | 564 target, elementAdapter.getCallStructure(node.arguments))); |
| 565 } | 565 } |
| 566 | 566 |
| 567 // TODO(johnniwinther): Make this throw and visit child nodes explicitly | 567 // TODO(johnniwinther): Make this throw and visit child nodes explicitly |
| 568 // instead to ensure that we don't visit unwanted parts of the ir. | 568 // instead to ensure that we don't visit unwanted parts of the ir. |
| 569 @override | 569 @override |
| 570 void defaultNode(ir.Node node) => node.visitChildren(this); | 570 void defaultNode(ir.Node node) => node.visitChildren(this); |
| 571 } | 571 } |
| OLD | NEW |