Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_const_expr.dart

Issue 1642483002: Improve 'length' instance property reference encoding. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) { 95 } else if (expr is PropertyAccess) {
96 // TODO(scheglov) solve ambiguity of `a.b.length` where `a` and `b` are 96 if (expr.target is StringLiteral && expr.propertyName.name == 'length') {
Paul Berry 2016/01/27 16:48:59 I think this should be: if (expr.target is! P
scheglov 2016/01/27 17:55:10 Done.
97 // identifiers
98 if (expr.propertyName.name == 'length') {
99 serialize(expr.target); 97 serialize(expr.target);
100 operations.add(UnlinkedConstOperation.length); 98 operations.add(UnlinkedConstOperation.length);
101 } else { 99 } else {
102 references.add(serializePropertyAccess(expr)); 100 references.add(serializePropertyAccess(expr));
103 operations.add(UnlinkedConstOperation.pushReference); 101 operations.add(UnlinkedConstOperation.pushReference);
104 } 102 }
105 } else if (expr is ParenthesizedExpression) { 103 } else if (expr is ParenthesizedExpression) {
106 serialize(expr.expression); 104 serialize(expr.expression);
107 } else { 105 } else {
108 throw new _ConstExprSerializationError('Unknown expression type: $expr'); 106 throw new _ConstExprSerializationError('Unknown expression type: $expr');
109 } 107 }
110 } 108 }
111 109
112 /** 110 /**
111 * Return [EntityRefBuilder] that corresponds to the given [constructor].
112 */
113 EntityRefBuilder serializeConstructorName(ConstructorName constructor);
114
115 /**
113 * Return [EntityRefBuilder] that corresponds to the given [identifier]. 116 * Return [EntityRefBuilder] that corresponds to the given [identifier].
114 */ 117 */
115 EntityRefBuilder serializeIdentifier(Identifier identifier); 118 EntityRefBuilder serializeIdentifier(Identifier identifier);
116 119
117 /** 120 /**
118 * Return [EntityRefBuilder] that corresponds to the given [access]. 121 * Return [EntityRefBuilder] that corresponds to the given [access].
119 */ 122 */
120 EntityRefBuilder serializePropertyAccess(PropertyAccess access); 123 EntityRefBuilder serializePropertyAccess(PropertyAccess access);
121 124
122 /** 125 /**
123 * Return [EntityRefBuilder] that corresponds to the given [type]. 126 * Return [EntityRefBuilder] that corresponds to the given [type].
124 */ 127 */
125 EntityRefBuilder serializeType(TypeName type); 128 EntityRefBuilder serializeType(TypeName type);
126 129
127 /** 130 /**
128 * Return [EntityRefBuilder] that corresponds to the given [constructor].
129 */
130 EntityRefBuilder serializeConstructorName(ConstructorName constructor);
131
132 /**
133 * Return the [UnlinkedConstBuilder] that corresponds to the state of this 131 * Return the [UnlinkedConstBuilder] that corresponds to the state of this
134 * serializer. 132 * serializer.
135 */ 133 */
136 UnlinkedConstBuilder toBuilder() { 134 UnlinkedConstBuilder toBuilder() {
137 return new UnlinkedConstBuilder( 135 return new UnlinkedConstBuilder(
138 operations: operations, 136 operations: operations,
139 ints: ints, 137 ints: ints,
140 doubles: doubles, 138 doubles: doubles,
141 strings: strings, 139 strings: strings,
142 references: references); 140 references: references);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 * Error that describes a problem during a constant expression serialization. 298 * Error that describes a problem during a constant expression serialization.
301 */ 299 */
302 class _ConstExprSerializationError { 300 class _ConstExprSerializationError {
303 final String message; 301 final String message;
304 302
305 _ConstExprSerializationError(this.message); 303 _ConstExprSerializationError(this.message);
306 304
307 @override 305 @override
308 String toString() => message; 306 String toString() => message;
309 } 307 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698