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

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

Issue 1949603003: Finer grain control over specifying which variables have invalid constant initializers. (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 }
289 for (UnlinkedConstOperation operation in uc.operations) { 292 for (UnlinkedConstOperation operation in uc.operations) {
290 switch (operation) { 293 switch (operation) {
291 case UnlinkedConstOperation.pushNull: 294 case UnlinkedConstOperation.pushNull:
292 _push(AstFactory.nullLiteral()); 295 _push(AstFactory.nullLiteral());
293 break; 296 break;
294 // bool 297 // bool
295 case UnlinkedConstOperation.pushFalse: 298 case UnlinkedConstOperation.pushFalse:
296 _push(AstFactory.booleanLiteral(false)); 299 _push(AstFactory.booleanLiteral(false));
297 break; 300 break;
298 case UnlinkedConstOperation.pushTrue: 301 case UnlinkedConstOperation.pushTrue:
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 case UnlinkedConstOperation.assignToRef: 455 case UnlinkedConstOperation.assignToRef:
453 case UnlinkedConstOperation.assignToProperty: 456 case UnlinkedConstOperation.assignToProperty:
454 case UnlinkedConstOperation.assignToIndex: 457 case UnlinkedConstOperation.assignToIndex:
455 case UnlinkedConstOperation.extractIndex: 458 case UnlinkedConstOperation.extractIndex:
456 case UnlinkedConstOperation.invokeMethod: 459 case UnlinkedConstOperation.invokeMethod:
457 case UnlinkedConstOperation.cascadeSectionBegin: 460 case UnlinkedConstOperation.cascadeSectionBegin:
458 case UnlinkedConstOperation.cascadeSectionEnd: 461 case UnlinkedConstOperation.cascadeSectionEnd:
459 case UnlinkedConstOperation.typeCast: 462 case UnlinkedConstOperation.typeCast:
460 case UnlinkedConstOperation.typeCheck: 463 case UnlinkedConstOperation.typeCheck:
461 case UnlinkedConstOperation.throwException: 464 case UnlinkedConstOperation.throwException:
462 return AstFactory.identifier3(r'$notConst$'); 465 throw new UnimplementedError(
466 'Unexpected $operation in a constant expression.');
463 } 467 }
464 } 468 }
465 return stack.single; 469 return stack.single;
466 } 470 }
467 471
468 List<Expression> _buildArguments() { 472 List<Expression> _buildArguments() {
469 List<Expression> arguments; 473 List<Expression> arguments;
470 { 474 {
471 int numNamedArgs = uc.ints[intPtr++]; 475 int numNamedArgs = uc.ints[intPtr++];
472 int numPositionalArgs = uc.ints[intPtr++]; 476 int numPositionalArgs = uc.ints[intPtr++];
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 static String _getElementIdentifier(String name, ReferenceKind kind) { 2650 static String _getElementIdentifier(String name, ReferenceKind kind) {
2647 if (kind == ReferenceKind.topLevelPropertyAccessor || 2651 if (kind == ReferenceKind.topLevelPropertyAccessor ||
2648 kind == ReferenceKind.propertyAccessor) { 2652 kind == ReferenceKind.propertyAccessor) {
2649 if (!name.endsWith('=')) { 2653 if (!name.endsWith('=')) {
2650 return name + '?'; 2654 return name + '?';
2651 } 2655 }
2652 } 2656 }
2653 return name; 2657 return name;
2654 } 2658 }
2655 } 2659 }
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