| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } else if (expr is ParenthesizedExpression) { | 362 } else if (expr is ParenthesizedExpression) { |
| 363 _serialize(expr.expression); | 363 _serialize(expr.expression); |
| 364 } else if (expr is IndexExpression) { | 364 } else if (expr is IndexExpression) { |
| 365 isValidConst = false; | 365 isValidConst = false; |
| 366 _serialize(expr.target); | 366 _serialize(expr.target); |
| 367 _serialize(expr.index); | 367 _serialize(expr.index); |
| 368 operations.add(UnlinkedExprOperation.extractIndex); | 368 operations.add(UnlinkedExprOperation.extractIndex); |
| 369 } else if (expr is AssignmentExpression) { | 369 } else if (expr is AssignmentExpression) { |
| 370 _serializeAssignment(expr); | 370 _serializeAssignment(expr); |
| 371 } else if (expr is CascadeExpression) { | 371 } else if (expr is CascadeExpression) { |
| 372 _serializeCascadeExpression(expr); | 372 isValidConst = false; |
| 373 _serialize(expr.target); |
| 373 } else if (expr is FunctionExpression) { | 374 } else if (expr is FunctionExpression) { |
| 374 isValidConst = false; | 375 isValidConst = false; |
| 375 List<int> indices = serializeFunctionExpression(expr); | 376 List<int> indices = serializeFunctionExpression(expr); |
| 376 if (indices != null) { | 377 if (indices != null) { |
| 377 ints.addAll(serializeFunctionExpression(expr)); | 378 ints.addAll(serializeFunctionExpression(expr)); |
| 378 operations.add(UnlinkedExprOperation.pushLocalFunctionReference); | 379 operations.add(UnlinkedExprOperation.pushLocalFunctionReference); |
| 379 } else { | 380 } else { |
| 380 // Invalid expression; just push null. | 381 // Invalid expression; just push null. |
| 381 operations.add(UnlinkedExprOperation.pushNull); | 382 operations.add(UnlinkedExprOperation.pushNull); |
| 382 } | 383 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 operations.add(UnlinkedExprOperation.lessEqual); | 513 operations.add(UnlinkedExprOperation.lessEqual); |
| 513 } else if (operator == TokenType.PERCENT) { | 514 } else if (operator == TokenType.PERCENT) { |
| 514 operations.add(UnlinkedExprOperation.modulo); | 515 operations.add(UnlinkedExprOperation.modulo); |
| 515 } else if (operator == TokenType.QUESTION_QUESTION) { | 516 } else if (operator == TokenType.QUESTION_QUESTION) { |
| 516 operations.add(UnlinkedExprOperation.ifNull); | 517 operations.add(UnlinkedExprOperation.ifNull); |
| 517 } else { | 518 } else { |
| 518 throw new StateError('Unknown operator: $operator'); | 519 throw new StateError('Unknown operator: $operator'); |
| 519 } | 520 } |
| 520 } | 521 } |
| 521 | 522 |
| 522 void _serializeCascadeExpression(CascadeExpression expr) { | |
| 523 _serialize(expr.target); | |
| 524 for (Expression section in expr.cascadeSections) { | |
| 525 operations.add(UnlinkedExprOperation.cascadeSectionBegin); | |
| 526 _serialize(section); | |
| 527 operations.add(UnlinkedExprOperation.cascadeSectionEnd); | |
| 528 } | |
| 529 } | |
| 530 | |
| 531 void _serializeListLiteral(ListLiteral expr) { | 523 void _serializeListLiteral(ListLiteral expr) { |
| 532 List<Expression> elements = expr.elements; | 524 List<Expression> elements = expr.elements; |
| 533 elements.forEach(_serialize); | 525 elements.forEach(_serialize); |
| 534 ints.add(elements.length); | 526 ints.add(elements.length); |
| 535 if (expr.typeArguments != null && | 527 if (expr.typeArguments != null && |
| 536 expr.typeArguments.arguments.length == 1) { | 528 expr.typeArguments.arguments.length == 1) { |
| 537 references.add(serializeTypeName(expr.typeArguments.arguments[0])); | 529 references.add(serializeTypeName(expr.typeArguments.arguments[0])); |
| 538 operations.add(UnlinkedExprOperation.makeTypedList); | 530 operations.add(UnlinkedExprOperation.makeTypedList); |
| 539 } else { | 531 } else { |
| 540 operations.add(UnlinkedExprOperation.makeUntypedList); | 532 operations.add(UnlinkedExprOperation.makeUntypedList); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 if (typeArguments == null) { | 664 if (typeArguments == null) { |
| 673 ints.add(0); | 665 ints.add(0); |
| 674 } else { | 666 } else { |
| 675 ints.add(typeArguments.arguments.length); | 667 ints.add(typeArguments.arguments.length); |
| 676 for (TypeAnnotation type in typeArguments.arguments) { | 668 for (TypeAnnotation type in typeArguments.arguments) { |
| 677 references.add(serializeTypeName(type)); | 669 references.add(serializeTypeName(type)); |
| 678 } | 670 } |
| 679 } | 671 } |
| 680 } | 672 } |
| 681 } | 673 } |
| OLD | NEW |