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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return impactBuilder; | 130 return impactBuilder; |
131 } | 131 } |
132 | 132 |
133 ResolutionImpact buildConstructor(ir.Constructor constructor) { | 133 ResolutionImpact buildConstructor(ir.Constructor constructor) { |
134 handleSignature(constructor.function, checkReturnType: false); | 134 handleSignature(constructor.function, checkReturnType: false); |
135 visitNodes(constructor.initializers); | 135 visitNodes(constructor.initializers); |
136 visitNode(constructor.function.body); | 136 visitNode(constructor.function.body); |
137 return impactBuilder; | 137 return impactBuilder; |
138 } | 138 } |
139 | 139 |
140 ResolutionImpact buildProcedure(ir.Procedure procedure) { | 140 void handleAsyncMarker(ir.AsyncMarker asyncMarker) { |
141 handleSignature(procedure.function); | 141 switch (asyncMarker) { |
142 visitNode(procedure.function.body); | |
143 switch (procedure.function.asyncMarker) { | |
144 case ir.AsyncMarker.Sync: | 142 case ir.AsyncMarker.Sync: |
145 break; | 143 break; |
146 case ir.AsyncMarker.SyncStar: | 144 case ir.AsyncMarker.SyncStar: |
147 impactBuilder.registerFeature(Feature.SYNC_STAR); | 145 impactBuilder.registerFeature(Feature.SYNC_STAR); |
148 break; | 146 break; |
149 case ir.AsyncMarker.Async: | 147 case ir.AsyncMarker.Async: |
150 impactBuilder.registerFeature(Feature.ASYNC); | 148 impactBuilder.registerFeature(Feature.ASYNC); |
151 break; | 149 break; |
152 case ir.AsyncMarker.AsyncStar: | 150 case ir.AsyncMarker.AsyncStar: |
153 impactBuilder.registerFeature(Feature.ASYNC_STAR); | 151 impactBuilder.registerFeature(Feature.ASYNC_STAR); |
154 break; | 152 break; |
155 case ir.AsyncMarker.SyncYielding: | 153 case ir.AsyncMarker.SyncYielding: |
156 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, | 154 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, |
157 "Unexpected async marker: ${procedure.function.asyncMarker}"); | 155 "Unexpected async marker: ${asyncMarker}"); |
158 } | 156 } |
| 157 } |
| 158 |
| 159 ResolutionImpact buildProcedure(ir.Procedure procedure) { |
| 160 handleSignature(procedure.function); |
| 161 visitNode(procedure.function.body); |
| 162 handleAsyncMarker(procedure.function.asyncMarker); |
159 if (procedure.isExternal && | 163 if (procedure.isExternal && |
160 !elementAdapter.isForeignLibrary(procedure.enclosingLibrary)) { | 164 !elementAdapter.isForeignLibrary(procedure.enclosingLibrary)) { |
161 impactBuilder.registerNativeData( | 165 impactBuilder.registerNativeData( |
162 elementAdapter.getNativeBehaviorForMethod(procedure)); | 166 elementAdapter.getNativeBehaviorForMethod(procedure)); |
163 } | 167 } |
164 return impactBuilder; | 168 return impactBuilder; |
165 } | 169 } |
166 | 170 |
167 void visitNode(ir.Node node) => node?.accept(this); | 171 void visitNode(ir.Node node) => node?.accept(this); |
168 | 172 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 impactBuilder.registerFeature(Feature.STRING_INTERPOLATION); | 469 impactBuilder.registerFeature(Feature.STRING_INTERPOLATION); |
466 impactBuilder.registerFeature(Feature.STRING_JUXTAPOSITION); | 470 impactBuilder.registerFeature(Feature.STRING_JUXTAPOSITION); |
467 visitNodes(node.expressions); | 471 visitNodes(node.expressions); |
468 } | 472 } |
469 | 473 |
470 @override | 474 @override |
471 void visitFunctionDeclaration(ir.FunctionDeclaration node) { | 475 void visitFunctionDeclaration(ir.FunctionDeclaration node) { |
472 impactBuilder.registerStaticUse( | 476 impactBuilder.registerStaticUse( |
473 new StaticUse.closure(elementAdapter.getLocalFunction(node))); | 477 new StaticUse.closure(elementAdapter.getLocalFunction(node))); |
474 handleSignature(node.function); | 478 handleSignature(node.function); |
| 479 handleAsyncMarker(node.function.asyncMarker); |
475 visitNode(node.function.body); | 480 visitNode(node.function.body); |
476 } | 481 } |
477 | 482 |
478 @override | 483 @override |
479 void visitFunctionExpression(ir.FunctionExpression node) { | 484 void visitFunctionExpression(ir.FunctionExpression node) { |
480 impactBuilder.registerStaticUse( | 485 impactBuilder.registerStaticUse( |
481 new StaticUse.closure(elementAdapter.getLocalFunction(node))); | 486 new StaticUse.closure(elementAdapter.getLocalFunction(node))); |
482 handleSignature(node.function); | 487 handleSignature(node.function); |
| 488 handleAsyncMarker(node.function.asyncMarker); |
483 visitNode(node.function.body); | 489 visitNode(node.function.body); |
484 } | 490 } |
485 | 491 |
486 @override | 492 @override |
487 void visitVariableDeclaration(ir.VariableDeclaration node) { | 493 void visitVariableDeclaration(ir.VariableDeclaration node) { |
488 checkType(node.type); | 494 checkType(node.type); |
489 if (node.initializer != null) { | 495 if (node.initializer != null) { |
490 visitNode(node.initializer); | 496 visitNode(node.initializer); |
491 } else { | 497 } else { |
492 impactBuilder.registerFeature(Feature.LOCAL_WITHOUT_INITIALIZER); | 498 impactBuilder.registerFeature(Feature.LOCAL_WITHOUT_INITIALIZER); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 ConstructorEntity target = elementAdapter.getConstructor(node.target); | 579 ConstructorEntity target = elementAdapter.getConstructor(node.target); |
574 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( | 580 impactBuilder.registerStaticUse(new StaticUse.superConstructorInvoke( |
575 target, elementAdapter.getCallStructure(node.arguments))); | 581 target, elementAdapter.getCallStructure(node.arguments))); |
576 } | 582 } |
577 | 583 |
578 // TODO(johnniwinther): Make this throw and visit child nodes explicitly | 584 // TODO(johnniwinther): Make this throw and visit child nodes explicitly |
579 // instead to ensure that we don't visit unwanted parts of the ir. | 585 // instead to ensure that we don't visit unwanted parts of the ir. |
580 @override | 586 @override |
581 void defaultNode(ir.Node node) => node.visitChildren(this); | 587 void defaultNode(ir.Node node) => node.visitChildren(this); |
582 } | 588 } |
OLD | NEW |