| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 if (constructor.name != null) { | 208 if (constructor.name != null) { |
| 209 strings.add(constructor.name.name); | 209 strings.add(constructor.name.name); |
| 210 } else { | 210 } else { |
| 211 strings.add(''); | 211 strings.add(''); |
| 212 } | 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 TypeName typeArgument; | 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 typeArgument = expr.typeArguments.arguments[0]; | 221 references.add(serializeType(expr.typeArguments.arguments[0])); |
| 222 operations.add(UnlinkedConstOperation.makeTypedList); |
| 223 } else { |
| 224 operations.add(UnlinkedConstOperation.makeUntypedList); |
| 222 } | 225 } |
| 223 references.add(serializeType(typeArgument)); | |
| 224 ints.add(elements.length); | |
| 225 operations.add(UnlinkedConstOperation.makeList); | |
| 226 } | 226 } |
| 227 | 227 |
| 228 void _serializeMapLiteral(MapLiteral expr) { | 228 void _serializeMapLiteral(MapLiteral expr) { |
| 229 for (MapLiteralEntry entry in expr.entries) { | 229 for (MapLiteralEntry entry in expr.entries) { |
| 230 serialize(entry.key); | 230 serialize(entry.key); |
| 231 serialize(entry.value); | 231 serialize(entry.value); |
| 232 } | 232 } |
| 233 TypeName keyTypeArgument; | 233 ints.add(expr.entries.length); |
| 234 TypeName valueTypeArgument; | |
| 235 if (expr.typeArguments != null && | 234 if (expr.typeArguments != null && |
| 236 expr.typeArguments.arguments.length == 2) { | 235 expr.typeArguments.arguments.length == 2) { |
| 237 keyTypeArgument = expr.typeArguments.arguments[0]; | 236 references.add(serializeType(expr.typeArguments.arguments[0])); |
| 238 valueTypeArgument = expr.typeArguments.arguments[1]; | 237 references.add(serializeType(expr.typeArguments.arguments[1])); |
| 238 operations.add(UnlinkedConstOperation.makeTypedMap); |
| 239 } else { |
| 240 operations.add(UnlinkedConstOperation.makeUntypedMap); |
| 239 } | 241 } |
| 240 references.add(serializeType(keyTypeArgument)); | |
| 241 references.add(serializeType(valueTypeArgument)); | |
| 242 ints.add(expr.entries.length); | |
| 243 operations.add(UnlinkedConstOperation.makeMap); | |
| 244 } | 242 } |
| 245 | 243 |
| 246 void _serializePrefixExpression(PrefixExpression expr) { | 244 void _serializePrefixExpression(PrefixExpression expr) { |
| 247 serialize(expr.operand); | 245 serialize(expr.operand); |
| 248 TokenType operator = expr.operator.type; | 246 TokenType operator = expr.operator.type; |
| 249 if (operator == TokenType.BANG) { | 247 if (operator == TokenType.BANG) { |
| 250 operations.add(UnlinkedConstOperation.not); | 248 operations.add(UnlinkedConstOperation.not); |
| 251 } else if (operator == TokenType.MINUS) { | 249 } else if (operator == TokenType.MINUS) { |
| 252 operations.add(UnlinkedConstOperation.negate); | 250 operations.add(UnlinkedConstOperation.negate); |
| 253 } else if (operator == TokenType.TILDE) { | 251 } else if (operator == TokenType.TILDE) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 * Error that describes a problem during a constant expression serialization. | 288 * Error that describes a problem during a constant expression serialization. |
| 291 */ | 289 */ |
| 292 class _ConstExprSerializationError { | 290 class _ConstExprSerializationError { |
| 293 final String message; | 291 final String message; |
| 294 | 292 |
| 295 _ConstExprSerializationError(this.message); | 293 _ConstExprSerializationError(this.message); |
| 296 | 294 |
| 297 @override | 295 @override |
| 298 String toString() => message; | 296 String toString() => message; |
| 299 } | 297 } |
| OLD | NEW |