| 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_const_expr; | 5 library serialization.summarize_const_expr; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/scanner.dart'; | 8 import 'package:analyzer/src/generated/scanner.dart'; |
| 9 import 'package:analyzer/src/summary/format.dart'; | 9 import 'package:analyzer/src/summary/format.dart'; |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 * Return [EntityRefBuilder] that corresponds to the given [identifier]. | 106 * Return [EntityRefBuilder] that corresponds to the given [identifier]. |
| 107 */ | 107 */ |
| 108 EntityRefBuilder serializeIdentifier(Identifier identifier); | 108 EntityRefBuilder serializeIdentifier(Identifier identifier); |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * Return [EntityRefBuilder] that corresponds to the given [type]. | 111 * Return [EntityRefBuilder] that corresponds to the given [type]. |
| 112 */ | 112 */ |
| 113 EntityRefBuilder serializeType(TypeName type); | 113 EntityRefBuilder serializeType(TypeName type); |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * Return [EntityRefBuilder] that corresponds to the given [constructor]. |
| 117 */ |
| 118 EntityRefBuilder serializeConstructorName(ConstructorName constructor); |
| 119 |
| 120 /** |
| 116 * Return the [UnlinkedConstBuilder] that corresponds to the state of this | 121 * Return the [UnlinkedConstBuilder] that corresponds to the state of this |
| 117 * serializer. | 122 * serializer. |
| 118 */ | 123 */ |
| 119 UnlinkedConstBuilder toBuilder() { | 124 UnlinkedConstBuilder toBuilder() { |
| 120 return new UnlinkedConstBuilder( | 125 return new UnlinkedConstBuilder( |
| 121 operations: operations, | 126 operations: operations, |
| 122 ints: ints, | 127 ints: ints, |
| 123 doubles: doubles, | 128 doubles: doubles, |
| 124 strings: strings, | 129 strings: strings, |
| 125 references: references); | 130 references: references); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } else { | 202 } else { |
| 198 serialize(arg); | 203 serialize(arg); |
| 199 } | 204 } |
| 200 }); | 205 }); |
| 201 // Add the op-code and numbers of named and positional arguments. | 206 // Add the op-code and numbers of named and positional arguments. |
| 202 operations.add(UnlinkedConstOperation.invokeConstructor); | 207 operations.add(UnlinkedConstOperation.invokeConstructor); |
| 203 ints.add(argumentNames.length); | 208 ints.add(argumentNames.length); |
| 204 strings.addAll(argumentNames); | 209 strings.addAll(argumentNames); |
| 205 ints.add(arguments.length - argumentNames.length); | 210 ints.add(arguments.length - argumentNames.length); |
| 206 // Serialize the reference. | 211 // Serialize the reference. |
| 207 references.add(serializeType(constructor.type)); | 212 references.add(serializeConstructorName(constructor)); |
| 208 if (constructor.name != null) { | |
| 209 strings.add(constructor.name.name); | |
| 210 } else { | |
| 211 strings.add(''); | |
| 212 } | |
| 213 } | 213 } |
| 214 | 214 |
| 215 void _serializeListLiteral(ListLiteral expr) { | 215 void _serializeListLiteral(ListLiteral expr) { |
| 216 List<Expression> elements = expr.elements; | 216 List<Expression> elements = expr.elements; |
| 217 elements.forEach(serialize); | 217 elements.forEach(serialize); |
| 218 ints.add(elements.length); | 218 ints.add(elements.length); |
| 219 if (expr.typeArguments != null && | 219 if (expr.typeArguments != null && |
| 220 expr.typeArguments.arguments.length == 1) { | 220 expr.typeArguments.arguments.length == 1) { |
| 221 references.add(serializeType(expr.typeArguments.arguments[0])); | 221 references.add(serializeType(expr.typeArguments.arguments[0])); |
| 222 operations.add(UnlinkedConstOperation.makeTypedList); | 222 operations.add(UnlinkedConstOperation.makeTypedList); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 * Error that describes a problem during a constant expression serialization. | 288 * Error that describes a problem during a constant expression serialization. |
| 289 */ | 289 */ |
| 290 class _ConstExprSerializationError { | 290 class _ConstExprSerializationError { |
| 291 final String message; | 291 final String message; |
| 292 | 292 |
| 293 _ConstExprSerializationError(this.message); | 293 _ConstExprSerializationError(this.message); |
| 294 | 294 |
| 295 @override | 295 @override |
| 296 String toString() => message; | 296 String toString() => message; |
| 297 } | 297 } |
| OLD | NEW |