Chromium Code Reviews| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 operations.add(UnlinkedConstOperation.identical); | 85 operations.add(UnlinkedConstOperation.identical); |
| 86 } else if (expr is BinaryExpression) { | 86 } else if (expr is BinaryExpression) { |
| 87 _serializeBinaryExpression(expr); | 87 _serializeBinaryExpression(expr); |
| 88 } else if (expr is ConditionalExpression) { | 88 } else if (expr is ConditionalExpression) { |
| 89 serialize(expr.condition); | 89 serialize(expr.condition); |
| 90 serialize(expr.thenExpression); | 90 serialize(expr.thenExpression); |
| 91 serialize(expr.elseExpression); | 91 serialize(expr.elseExpression); |
| 92 operations.add(UnlinkedConstOperation.conditional); | 92 operations.add(UnlinkedConstOperation.conditional); |
| 93 } else if (expr is PrefixExpression) { | 93 } else if (expr is PrefixExpression) { |
| 94 _serializePrefixExpression(expr); | 94 _serializePrefixExpression(expr); |
| 95 } else if (expr is PropertyAccess && expr.propertyName.name == 'length') { | 95 } else if (expr is PropertyAccess) { |
| 96 serialize(expr.target); | 96 if (expr.propertyName.name == 'length') { |
| 97 operations.add(UnlinkedConstOperation.length); | 97 serialize(expr.target); |
|
Paul Berry
2016/01/26 20:52:49
There's two ambiguities with `length` that I think
scheglov
2016/01/26 21:02:29
I added TODO and will fix it soon.
| |
| 98 operations.add(UnlinkedConstOperation.length); | |
| 99 } else { | |
| 100 references.add(serializePropertyAccess(expr)); | |
| 101 operations.add(UnlinkedConstOperation.pushReference); | |
| 102 } | |
| 98 } else if (expr is ParenthesizedExpression) { | 103 } else if (expr is ParenthesizedExpression) { |
| 99 serialize(expr.expression); | 104 serialize(expr.expression); |
| 100 } else { | 105 } else { |
| 101 throw new _ConstExprSerializationError('Unknown expression type: $expr'); | 106 throw new _ConstExprSerializationError('Unknown expression type: $expr'); |
| 102 } | 107 } |
| 103 } | 108 } |
| 104 | 109 |
| 105 /** | 110 /** |
| 106 * Return [EntityRefBuilder] that corresponds to the given [identifier]. | 111 * Return [EntityRefBuilder] that corresponds to the given [identifier]. |
| 107 */ | 112 */ |
| 108 EntityRefBuilder serializeIdentifier(Identifier identifier); | 113 EntityRefBuilder serializeIdentifier(Identifier identifier); |
| 109 | 114 |
| 110 /** | 115 /** |
| 116 * Return [EntityRefBuilder] that corresponds to the given [access]. | |
| 117 */ | |
| 118 EntityRefBuilder serializePropertyAccess(PropertyAccess access); | |
| 119 | |
| 120 /** | |
| 111 * Return [EntityRefBuilder] that corresponds to the given [type]. | 121 * Return [EntityRefBuilder] that corresponds to the given [type]. |
| 112 */ | 122 */ |
| 113 EntityRefBuilder serializeType(TypeName type); | 123 EntityRefBuilder serializeType(TypeName type); |
| 114 | 124 |
| 115 /** | 125 /** |
| 116 * Return [EntityRefBuilder] that corresponds to the given [constructor]. | 126 * Return [EntityRefBuilder] that corresponds to the given [constructor]. |
| 117 */ | 127 */ |
| 118 EntityRefBuilder serializeConstructorName(ConstructorName constructor); | 128 EntityRefBuilder serializeConstructorName(ConstructorName constructor); |
| 119 | 129 |
| 120 /** | 130 /** |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 * Error that describes a problem during a constant expression serialization. | 298 * Error that describes a problem during a constant expression serialization. |
| 289 */ | 299 */ |
| 290 class _ConstExprSerializationError { | 300 class _ConstExprSerializationError { |
| 291 final String message; | 301 final String message; |
| 292 | 302 |
| 293 _ConstExprSerializationError(this.message); | 303 _ConstExprSerializationError(this.message); |
| 294 | 304 |
| 295 @override | 305 @override |
| 296 String toString() => message; | 306 String toString() => message; |
| 297 } | 307 } |
| OLD | NEW |