| 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 library serialization.summarize_ast; | 5 library serialization.summarize_ast; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/src/generated/utilities_dart.dart'; | 10 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 'Unexpected identifier type: ${identifier.runtimeType}'); | 86 'Unexpected identifier type: ${identifier.runtimeType}'); |
| 87 } | 87 } |
| 88 return b; | 88 return b; |
| 89 } | 89 } |
| 90 | 90 |
| 91 @override | 91 @override |
| 92 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { | 92 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { |
| 93 Expression target = access.target; | 93 Expression target = access.target; |
| 94 if (target is Identifier) { | 94 if (target is Identifier) { |
| 95 EntityRefBuilder targetRef = serializeIdentifier(target); | 95 EntityRefBuilder targetRef = serializeIdentifier(target); |
| 96 return new EntityRefBuilder(reference: visitor.serializeReference( | 96 return new EntityRefBuilder( |
| 97 targetRef.reference, access.propertyName.name)); | 97 reference: visitor.serializeReference( |
| 98 targetRef.reference, access.propertyName.name)); |
| 98 } else { | 99 } else { |
| 99 // TODO(scheglov) should we handle other targets in malformed constants? | 100 // TODO(scheglov) should we handle other targets in malformed constants? |
| 100 throw new StateError('Unexpected target type: ${target.runtimeType}'); | 101 throw new StateError('Unexpected target type: ${target.runtimeType}'); |
| 101 } | 102 } |
| 102 } | 103 } |
| 103 | 104 |
| 104 @override | 105 @override |
| 105 EntityRefBuilder serializeType(TypeName node) { | 106 EntityRefBuilder serializeType(TypeName node) { |
| 106 return visitor.serializeTypeName(node); | 107 return visitor.serializeTypeName(node); |
| 107 } | 108 } |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 * [UnlinkedExecutableBuilder], otherwise return `null`. | 582 * [UnlinkedExecutableBuilder], otherwise return `null`. |
| 582 */ | 583 */ |
| 583 UnlinkedExecutableBuilder serializeInitializerFunction( | 584 UnlinkedExecutableBuilder serializeInitializerFunction( |
| 584 Expression expression) { | 585 Expression expression) { |
| 585 if (expression == null) { | 586 if (expression == null) { |
| 586 return null; | 587 return null; |
| 587 } | 588 } |
| 588 UnlinkedExecutableBuilder initializer = | 589 UnlinkedExecutableBuilder initializer = |
| 589 new UnlinkedExecutableBuilder(nameOffset: expression.offset); | 590 new UnlinkedExecutableBuilder(nameOffset: expression.offset); |
| 590 serializeFunctionBody(initializer, expression); | 591 serializeFunctionBody(initializer, expression); |
| 592 initializer.inferredReturnTypeSlot = assignTypeSlot(); |
| 591 return initializer; | 593 return initializer; |
| 592 } | 594 } |
| 593 | 595 |
| 594 /** | 596 /** |
| 595 * Serialize a [FieldFormalParameter], [FunctionTypedFormalParameter], or | 597 * Serialize a [FieldFormalParameter], [FunctionTypedFormalParameter], or |
| 596 * [SimpleFormalParameter] into an [UnlinkedParam]. | 598 * [SimpleFormalParameter] into an [UnlinkedParam]. |
| 597 */ | 599 */ |
| 598 UnlinkedParamBuilder serializeParameter(NormalFormalParameter node) { | 600 UnlinkedParamBuilder serializeParameter(NormalFormalParameter node) { |
| 599 UnlinkedParamBuilder b = new UnlinkedParamBuilder(); | 601 UnlinkedParamBuilder b = new UnlinkedParamBuilder(); |
| 600 b.name = node.identifier.name; | 602 b.name = node.identifier.name; |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 /** | 1101 /** |
| 1100 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. | 1102 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. |
| 1101 */ | 1103 */ |
| 1102 class _TypeParameterScope extends _Scope { | 1104 class _TypeParameterScope extends _Scope { |
| 1103 /** | 1105 /** |
| 1104 * Get the number of [_ScopedTypeParameter]s defined in this | 1106 * Get the number of [_ScopedTypeParameter]s defined in this |
| 1105 * [_TypeParameterScope]. | 1107 * [_TypeParameterScope]. |
| 1106 */ | 1108 */ |
| 1107 int get length => _definedNames.length; | 1109 int get length => _definedNames.length; |
| 1108 } | 1110 } |
| OLD | NEW |