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/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/element/type.dart' show DartType; | 9 import 'package:analyzer/dart/element/type.dart' show DartType; |
10 import 'package:analyzer/src/summary/format.dart'; | 10 import 'package:analyzer/src/summary/format.dart'; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 * Instances of this class keep track of intermediate state during | 59 * Instances of this class keep track of intermediate state during |
60 * serialization of a single constant [Expression]. | 60 * serialization of a single constant [Expression]. |
61 */ | 61 */ |
62 abstract class AbstractConstExprSerializer { | 62 abstract class AbstractConstExprSerializer { |
63 /** | 63 /** |
64 * See [UnlinkedExprBuilder.isValidConst]. | 64 * See [UnlinkedExprBuilder.isValidConst]. |
65 */ | 65 */ |
66 bool isValidConst = true; | 66 bool isValidConst = true; |
67 | 67 |
68 /** | 68 /** |
69 * See [UnlinkedExprBuilder.nmae]. | 69 * See [UnlinkedExprBuilder.name]. |
70 */ | 70 */ |
71 String name = null; | 71 String name = null; |
72 | 72 |
73 /** | 73 /** |
74 * See [UnlinkedExprBuilder.operations]. | 74 * See [UnlinkedExprBuilder.operations]. |
75 */ | 75 */ |
76 final List<UnlinkedExprOperation> operations = <UnlinkedExprOperation>[]; | 76 final List<UnlinkedExprOperation> operations = <UnlinkedExprOperation>[]; |
77 | 77 |
78 /** | 78 /** |
79 * See [UnlinkedExprBuilder.assignmentOperators]. | 79 * See [UnlinkedExprBuilder.assignmentOperators]. |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 operations.add(UnlinkedExprOperation.typeCast); | 373 operations.add(UnlinkedExprOperation.typeCast); |
374 } else if (expr is IsExpression) { | 374 } else if (expr is IsExpression) { |
375 isValidConst = false; | 375 isValidConst = false; |
376 _serialize(expr.expression); | 376 _serialize(expr.expression); |
377 references.add(serializeTypeName(expr.type)); | 377 references.add(serializeTypeName(expr.type)); |
378 operations.add(UnlinkedExprOperation.typeCheck); | 378 operations.add(UnlinkedExprOperation.typeCheck); |
379 } else if (expr is ThrowExpression) { | 379 } else if (expr is ThrowExpression) { |
380 isValidConst = false; | 380 isValidConst = false; |
381 _serialize(expr.expression); | 381 _serialize(expr.expression); |
382 operations.add(UnlinkedExprOperation.throwException); | 382 operations.add(UnlinkedExprOperation.throwException); |
| 383 } else if (expr is AwaitExpression) { |
| 384 isValidConst = false; |
| 385 _serialize(expr.expression); |
| 386 operations.add(UnlinkedExprOperation.await); |
383 } else { | 387 } else { |
384 throw new StateError('Unknown expression type: $expr'); | 388 throw new StateError('Unknown expression type: $expr'); |
385 } | 389 } |
386 } | 390 } |
387 | 391 |
388 void _serializeArguments(ArgumentList argumentList) { | 392 void _serializeArguments(ArgumentList argumentList) { |
389 List<Expression> arguments = argumentList.arguments; | 393 List<Expression> arguments = argumentList.arguments; |
390 // Serialize the arguments. | 394 // Serialize the arguments. |
391 List<String> argumentNames = <String>[]; | 395 List<String> argumentNames = <String>[]; |
392 arguments.forEach((arg) { | 396 arguments.forEach((arg) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 if (typeArguments == null) { | 648 if (typeArguments == null) { |
645 ints.add(0); | 649 ints.add(0); |
646 } else { | 650 } else { |
647 ints.add(typeArguments.arguments.length); | 651 ints.add(typeArguments.arguments.length); |
648 for (TypeName typeName in typeArguments.arguments) { | 652 for (TypeName typeName in typeArguments.arguments) { |
649 references.add(serializeTypeName(typeName)); | 653 references.add(serializeTypeName(typeName)); |
650 } | 654 } |
651 } | 655 } |
652 } | 656 } |
653 } | 657 } |
OLD | NEW |