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

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

Issue 1937223002: All initializer expressions are serialized, even if not all of them are constants. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 summary_resynthesizer; 5 library summary_resynthesizer;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 int doublePtr = 0; 279 int doublePtr = 0;
280 int stringPtr = 0; 280 int stringPtr = 0;
281 int refPtr = 0; 281 int refPtr = 0;
282 final List<Expression> stack = <Expression>[]; 282 final List<Expression> stack = <Expression>[];
283 283
284 _ConstExprBuilder(this.resynthesizer, this.uc); 284 _ConstExprBuilder(this.resynthesizer, this.uc);
285 285
286 Expression get expr => stack.single; 286 Expression get expr => stack.single;
287 287
288 Expression build() { 288 Expression build() {
289 if (!uc.isValidConst) {
290 return AstFactory.identifier3(r'$$invalidConstExpr$$');
291 }
292 for (UnlinkedConstOperation operation in uc.operations) { 289 for (UnlinkedConstOperation operation in uc.operations) {
293 switch (operation) { 290 switch (operation) {
294 case UnlinkedConstOperation.pushNull: 291 case UnlinkedConstOperation.pushNull:
295 _push(AstFactory.nullLiteral()); 292 _push(AstFactory.nullLiteral());
296 break; 293 break;
297 // bool 294 // bool
298 case UnlinkedConstOperation.pushFalse: 295 case UnlinkedConstOperation.pushFalse:
299 _push(AstFactory.booleanLiteral(false)); 296 _push(AstFactory.booleanLiteral(false));
300 break; 297 break;
301 case UnlinkedConstOperation.pushTrue: 298 case UnlinkedConstOperation.pushTrue:
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 554
558 void _pushBinary(TokenType operator) { 555 void _pushBinary(TokenType operator) {
559 Expression right = _pop(); 556 Expression right = _pop();
560 Expression left = _pop(); 557 Expression left = _pop();
561 _push(AstFactory.binaryExpression(left, operator, right)); 558 _push(AstFactory.binaryExpression(left, operator, right));
562 } 559 }
563 560
564 void _pushExtractProperty() { 561 void _pushExtractProperty() {
565 Expression target = _pop(); 562 Expression target = _pop();
566 String name = uc.strings[stringPtr++]; 563 String name = uc.strings[stringPtr++];
567 // TODO(scheglov) Only String.length property access is supported. 564 SimpleIdentifier propertyNode = AstFactory.identifier3(name);
568 assert(name == 'length'); 565 // Only String.length property access can be potentially resolved.
569 _push(AstFactory.propertyAccess( 566 if (name == 'length') {
570 target, 567 propertyNode.staticElement = _getStringLengthElement();
571 AstFactory.identifier3('length') 568 }
572 ..staticElement = _getStringLengthElement())); 569 _push(AstFactory.propertyAccess(target, propertyNode));
573 } 570 }
574 571
575 void _pushInstanceCreation() { 572 void _pushInstanceCreation() {
576 EntityRef ref = uc.references[refPtr++]; 573 EntityRef ref = uc.references[refPtr++];
577 _ReferenceInfo info = resynthesizer.referenceInfos[ref.reference]; 574 _ReferenceInfo info = resynthesizer.referenceInfos[ref.reference];
578 // prepare ConstructorElement 575 // prepare ConstructorElement
579 TypeName typeNode; 576 TypeName typeNode;
580 String constructorName; 577 String constructorName;
581 ConstructorElement constructorElement; 578 ConstructorElement constructorElement;
582 if (info.element != null) { 579 if (info.element != null) {
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 static String _getElementIdentifier(String name, ReferenceKind kind) { 2644 static String _getElementIdentifier(String name, ReferenceKind kind) {
2648 if (kind == ReferenceKind.topLevelPropertyAccessor || 2645 if (kind == ReferenceKind.topLevelPropertyAccessor ||
2649 kind == ReferenceKind.propertyAccessor) { 2646 kind == ReferenceKind.propertyAccessor) {
2650 if (!name.endsWith('=')) { 2647 if (!name.endsWith('=')) {
2651 return name + '?'; 2648 return name + '?';
2652 } 2649 }
2653 } 2650 }
2654 return name; 2651 return name;
2655 } 2652 }
2656 } 2653 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698