| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ResolutionImpact buildField(ir.Field field) { | 106 ResolutionImpact buildField(ir.Field field) { |
| 107 checkType(field.type); | 107 checkType(field.type); |
| 108 if (field.initializer != null) { | 108 if (field.initializer != null) { |
| 109 visitNode(field.initializer); | 109 visitNode(field.initializer); |
| 110 if (!field.isInstanceMember && !field.isConst) { | 110 if (!field.isInstanceMember && !field.isConst) { |
| 111 impactBuilder.registerFeature(Feature.LAZY_FIELD); | 111 impactBuilder.registerFeature(Feature.LAZY_FIELD); |
| 112 } | 112 } |
| 113 } else { | 113 } else { |
| 114 impactBuilder.registerFeature(Feature.FIELD_WITHOUT_INITIALIZER); | 114 impactBuilder.registerFeature(Feature.FIELD_WITHOUT_INITIALIZER); |
| 115 } | 115 } |
| 116 if (field.isInstanceMember && astAdapter.isNative(field.enclosingClass)) { |
| 117 impactBuilder |
| 118 .registerNativeData(astAdapter.getNativeBehaviorForFieldLoad(field)); |
| 119 impactBuilder |
| 120 .registerNativeData(astAdapter.getNativeBehaviorForFieldStore(field)); |
| 121 } |
| 116 return impactBuilder; | 122 return impactBuilder; |
| 117 } | 123 } |
| 118 | 124 |
| 119 ResolutionImpact buildConstructor(ir.Constructor constructor) { | 125 ResolutionImpact buildConstructor(ir.Constructor constructor) { |
| 120 handleSignature(constructor.function, checkReturnType: false); | 126 handleSignature(constructor.function, checkReturnType: false); |
| 121 visitNodes(constructor.initializers); | 127 visitNodes(constructor.initializers); |
| 122 visitNode(constructor.function.body); | 128 visitNode(constructor.function.body); |
| 123 return impactBuilder; | 129 return impactBuilder; |
| 124 } | 130 } |
| 125 | 131 |
| 126 ResolutionImpact buildProcedure(ir.Procedure procedure) { | 132 ResolutionImpact buildProcedure(ir.Procedure procedure) { |
| 127 handleSignature(procedure.function); | 133 handleSignature(procedure.function); |
| 128 visitNode(procedure.function.body); | 134 visitNode(procedure.function.body); |
| 129 switch (procedure.function.asyncMarker) { | 135 switch (procedure.function.asyncMarker) { |
| 130 case ir.AsyncMarker.Sync: | 136 case ir.AsyncMarker.Sync: |
| 131 break; | 137 break; |
| 132 case ir.AsyncMarker.SyncStar: | 138 case ir.AsyncMarker.SyncStar: |
| 133 impactBuilder.registerFeature(Feature.SYNC_STAR); | 139 impactBuilder.registerFeature(Feature.SYNC_STAR); |
| 134 break; | 140 break; |
| 135 case ir.AsyncMarker.Async: | 141 case ir.AsyncMarker.Async: |
| 136 impactBuilder.registerFeature(Feature.ASYNC); | 142 impactBuilder.registerFeature(Feature.ASYNC); |
| 137 break; | 143 break; |
| 138 case ir.AsyncMarker.AsyncStar: | 144 case ir.AsyncMarker.AsyncStar: |
| 139 impactBuilder.registerFeature(Feature.ASYNC_STAR); | 145 impactBuilder.registerFeature(Feature.ASYNC_STAR); |
| 140 break; | 146 break; |
| 141 case ir.AsyncMarker.SyncYielding: | 147 case ir.AsyncMarker.SyncYielding: |
| 142 compiler.reporter.internalError(resolvedAst.element, | 148 compiler.reporter.internalError(resolvedAst.element, |
| 143 "Unexpected async marker: ${procedure.function.asyncMarker}"); | 149 "Unexpected async marker: ${procedure.function.asyncMarker}"); |
| 144 } | 150 } |
| 151 if (procedure.isExternal && |
| 152 !astAdapter.isForeignLibrary(procedure.enclosingLibrary)) { |
| 153 impactBuilder |
| 154 .registerNativeData(astAdapter.getNativeBehaviorForMethod(procedure)); |
| 155 } |
| 145 return impactBuilder; | 156 return impactBuilder; |
| 146 } | 157 } |
| 147 | 158 |
| 148 void visitNode(ir.Node node) => node?.accept(this); | 159 void visitNode(ir.Node node) => node?.accept(this); |
| 149 | 160 |
| 150 void visitNodes(Iterable<ir.Node> nodes) { | 161 void visitNodes(Iterable<ir.Node> nodes) { |
| 151 nodes.forEach(visitNode); | 162 nodes.forEach(visitNode); |
| 152 } | 163 } |
| 153 | 164 |
| 154 @override | 165 @override |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 Element target = astAdapter.getElement(node.target).declaration; | 568 Element target = astAdapter.getElement(node.target).declaration; |
| 558 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( | 569 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( |
| 559 target, astAdapter.getCallStructure(node.arguments))); | 570 target, astAdapter.getCallStructure(node.arguments))); |
| 560 } | 571 } |
| 561 | 572 |
| 562 // TODO(johnniwinther): Make this throw and visit child nodes explicitly | 573 // TODO(johnniwinther): Make this throw and visit child nodes explicitly |
| 563 // instead to ensure that we don't visit unwanted parts of the ir. | 574 // instead to ensure that we don't visit unwanted parts of the ir. |
| 564 @override | 575 @override |
| 565 void defaultNode(ir.Node node) => node.visitChildren(this); | 576 void defaultNode(ir.Node node) => node.visitChildren(this); |
| 566 } | 577 } |
| OLD | NEW |