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

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

Issue 1648783002: Repalce shiftOr with pushLongInt, tweak makeSymbol. (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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } else if (expr is BooleanLiteral) { 50 } else if (expr is BooleanLiteral) {
51 if (expr.value) { 51 if (expr.value) {
52 operations.add(UnlinkedConstOperation.pushTrue); 52 operations.add(UnlinkedConstOperation.pushTrue);
53 } else { 53 } else {
54 operations.add(UnlinkedConstOperation.pushFalse); 54 operations.add(UnlinkedConstOperation.pushFalse);
55 } 55 }
56 } else if (expr is StringLiteral) { 56 } else if (expr is StringLiteral) {
57 _serializeString(expr); 57 _serializeString(expr);
58 } else if (expr is SymbolLiteral) { 58 } else if (expr is SymbolLiteral) {
59 strings.add(expr.components.map((token) => token.lexeme).join('.')); 59 strings.add(expr.components.map((token) => token.lexeme).join('.'));
60 operations.add(UnlinkedConstOperation.pushString);
61 operations.add(UnlinkedConstOperation.makeSymbol); 60 operations.add(UnlinkedConstOperation.makeSymbol);
62 } else if (expr is NullLiteral) { 61 } else if (expr is NullLiteral) {
63 operations.add(UnlinkedConstOperation.pushNull); 62 operations.add(UnlinkedConstOperation.pushNull);
64 } else if (expr is Identifier) { 63 } else if (expr is Identifier) {
65 references.add(serializeIdentifier(expr)); 64 references.add(serializeIdentifier(expr));
66 operations.add(UnlinkedConstOperation.pushReference); 65 operations.add(UnlinkedConstOperation.pushReference);
67 } else if (expr is InstanceCreationExpression) { 66 } else if (expr is InstanceCreationExpression) {
68 _serializeInstanceCreation(expr); 67 _serializeInstanceCreation(expr);
69 } else if (expr is ListLiteral) { 68 } else if (expr is ListLiteral) {
70 _serializeListLiteral(expr); 69 _serializeListLiteral(expr);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 operations: operations, 136 operations: operations,
138 ints: ints, 137 ints: ints,
139 doubles: doubles, 138 doubles: doubles,
140 strings: strings, 139 strings: strings,
141 references: references); 140 references: references);
142 } 141 }
143 142
144 void _pushInt(int value) { 143 void _pushInt(int value) {
145 assert(value >= 0); 144 assert(value >= 0);
146 if (value >= (1 << 32)) { 145 if (value >= (1 << 32)) {
147 _pushInt(value >> 32); 146 int numOfComponents = 0;
148 operations.add(UnlinkedConstOperation.shiftOr); 147 ints.add(numOfComponents);
149 ints.add(value & 0xFFFFFFFF); 148 void pushComponents(int value) {
149 if (value >= (1 << 32)) {
150 pushComponents(value >> 32);
151 }
152 numOfComponents++;
153 ints.add(value & 0xFFFFFFFF);
154 }
155 pushComponents(value);
156 ints[ints.length - 1 - numOfComponents] = numOfComponents;
157 operations.add(UnlinkedConstOperation.pushLongInt);
150 } else { 158 } else {
151 operations.add(UnlinkedConstOperation.pushInt); 159 operations.add(UnlinkedConstOperation.pushInt);
152 ints.add(value); 160 ints.add(value);
153 } 161 }
154 } 162 }
155 163
156 void _serializeBinaryExpression(BinaryExpression expr) { 164 void _serializeBinaryExpression(BinaryExpression expr) {
157 serialize(expr.leftOperand); 165 serialize(expr.leftOperand);
158 serialize(expr.rightOperand); 166 serialize(expr.rightOperand);
159 TokenType operator = expr.operator.type; 167 TokenType operator = expr.operator.type;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 * Error that describes a problem during a constant expression serialization. 307 * Error that describes a problem during a constant expression serialization.
300 */ 308 */
301 class _ConstExprSerializationError { 309 class _ConstExprSerializationError {
302 final String message; 310 final String message;
303 311
304 _ConstExprSerializationError(this.message); 312 _ConstExprSerializationError(this.message);
305 313
306 @override 314 @override
307 String toString() => message; 315 String toString() => message;
308 } 316 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698