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

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: Improve using 'UnlinkedConstOperation.length'. Created 4 years, 11 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! PrefixedIdentifier &&
97 // identifiers 97 expr.propertyName.name == 'length') {
98 if (expr.propertyName.name == 'length') {
99 serialize(expr.target); 98 serialize(expr.target);
100 operations.add(UnlinkedConstOperation.length); 99 operations.add(UnlinkedConstOperation.length);
101 } else { 100 } else {
102 references.add(serializePropertyAccess(expr)); 101 references.add(serializePropertyAccess(expr));
103 operations.add(UnlinkedConstOperation.pushReference); 102 operations.add(UnlinkedConstOperation.pushReference);
104 } 103 }
105 } else if (expr is ParenthesizedExpression) { 104 } else if (expr is ParenthesizedExpression) {
106 serialize(expr.expression); 105 serialize(expr.expression);
107 } else { 106 } else {
108 throw new _ConstExprSerializationError('Unknown expression type: $expr'); 107 throw new _ConstExprSerializationError('Unknown expression type: $expr');
109 } 108 }
110 } 109 }
111 110
112 /** 111 /**
112 * Return [EntityRefBuilder] that corresponds to the given [constructor].
113 */
114 EntityRefBuilder serializeConstructorName(ConstructorName constructor);
115
116 /**
113 * Return [EntityRefBuilder] that corresponds to the given [identifier]. 117 * Return [EntityRefBuilder] that corresponds to the given [identifier].
114 */ 118 */
115 EntityRefBuilder serializeIdentifier(Identifier identifier); 119 EntityRefBuilder serializeIdentifier(Identifier identifier);
116 120
117 /** 121 /**
118 * Return [EntityRefBuilder] that corresponds to the given [access]. 122 * Return [EntityRefBuilder] that corresponds to the given [access].
119 */ 123 */
120 EntityRefBuilder serializePropertyAccess(PropertyAccess access); 124 EntityRefBuilder serializePropertyAccess(PropertyAccess access);
121 125
122 /** 126 /**
123 * Return [EntityRefBuilder] that corresponds to the given [type]. 127 * Return [EntityRefBuilder] that corresponds to the given [type].
124 */ 128 */
125 EntityRefBuilder serializeType(TypeName type); 129 EntityRefBuilder serializeType(TypeName type);
126 130
127 /** 131 /**
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 132 * Return the [UnlinkedConstBuilder] that corresponds to the state of this
134 * serializer. 133 * serializer.
135 */ 134 */
136 UnlinkedConstBuilder toBuilder() { 135 UnlinkedConstBuilder toBuilder() {
137 return new UnlinkedConstBuilder( 136 return new UnlinkedConstBuilder(
138 operations: operations, 137 operations: operations,
139 ints: ints, 138 ints: ints,
140 doubles: doubles, 139 doubles: doubles,
141 strings: strings, 140 strings: strings,
142 references: references); 141 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. 299 * Error that describes a problem during a constant expression serialization.
301 */ 300 */
302 class _ConstExprSerializationError { 301 class _ConstExprSerializationError {
303 final String message; 302 final String message;
304 303
305 _ConstExprSerializationError(this.message); 304 _ConstExprSerializationError(this.message);
306 305
307 @override 306 @override
308 String toString() => message; 307 String toString() => message;
309 } 308 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/prelink.dart ('k') | pkg/analyzer/lib/src/summary/summarize_elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698