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

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

Issue 1642993003: Resynthesize untyped List / Map. (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) 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/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 int doublePtr = 0; 256 int doublePtr = 0;
257 int stringPtr = 0; 257 int stringPtr = 0;
258 int refPtr = 0; 258 int refPtr = 0;
259 final List<Expression> stack = <Expression>[]; 259 final List<Expression> stack = <Expression>[];
260 260
261 _ConstExprBuilder(this.resynthesizer, this.uc); 261 _ConstExprBuilder(this.resynthesizer, this.uc);
262 262
263 Expression get expr => stack.single; 263 Expression get expr => stack.single;
264 264
265 Expression build() { 265 Expression build() {
266 // TODO(scheglov) complete implementation
266 for (UnlinkedConstOperation operation in uc.operations) { 267 for (UnlinkedConstOperation operation in uc.operations) {
267 switch (operation) { 268 switch (operation) {
268 case UnlinkedConstOperation.pushNull: 269 case UnlinkedConstOperation.pushNull:
269 _push(AstFactory.nullLiteral()); 270 _push(AstFactory.nullLiteral());
270 break; 271 break;
271 // bool 272 // bool
272 case UnlinkedConstOperation.pushFalse: 273 case UnlinkedConstOperation.pushFalse:
273 _push(AstFactory.booleanLiteral(false)); 274 _push(AstFactory.booleanLiteral(false));
274 break; 275 break;
275 case UnlinkedConstOperation.pushTrue: 276 case UnlinkedConstOperation.pushTrue:
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 _push( 386 _push(
386 AstFactory.conditionalExpression(condition, thenExpr, elseExpr)); 387 AstFactory.conditionalExpression(condition, thenExpr, elseExpr));
387 break; 388 break;
388 // identical 389 // identical
389 case UnlinkedConstOperation.identical: 390 case UnlinkedConstOperation.identical:
390 Expression second = _pop(); 391 Expression second = _pop();
391 Expression first = _pop(); 392 Expression first = _pop();
392 _push(AstFactory.methodInvocation( 393 _push(AstFactory.methodInvocation(
393 null, 'identical', <Expression>[first, second])); 394 null, 'identical', <Expression>[first, second]));
394 break; 395 break;
395 // TODO(scheglov) complete implementation 396 // untyped containers
396 case UnlinkedConstOperation.makeUntypedList: 397 case UnlinkedConstOperation.makeUntypedList:
398 int count = uc.ints[intPtr++];
399 List<Expression> elements = <Expression>[];
400 for (int i= 0; i < count; i++) {
401 elements.insert(0, _pop());
402 }
403 _push(AstFactory.listLiteral2(Keyword.CONST, null, elements));
404 break;
405 case UnlinkedConstOperation.makeUntypedMap:
406 int count = uc.ints[intPtr++];
407 List<MapLiteralEntry> entries = <MapLiteralEntry>[];
408 for (int i= 0; i < count; i++) {
409 Expression value = _pop();
410 Expression key = _pop();
411 entries.insert(0, AstFactory.mapLiteralEntry2(key, value));
412 }
413 _push(AstFactory.mapLiteral(Keyword.CONST, null, entries));
414 break;
397 case UnlinkedConstOperation.makeTypedList: 415 case UnlinkedConstOperation.makeTypedList:
398 case UnlinkedConstOperation.makeUntypedMap:
399 case UnlinkedConstOperation.makeTypedMap: 416 case UnlinkedConstOperation.makeTypedMap:
400 case UnlinkedConstOperation.pushReference: 417 case UnlinkedConstOperation.pushReference:
401 case UnlinkedConstOperation.invokeConstructor: 418 case UnlinkedConstOperation.invokeConstructor:
402 case UnlinkedConstOperation.length: 419 case UnlinkedConstOperation.length:
403 return AstFactory.nullLiteral(); 420 return AstFactory.nullLiteral();
404 // throw new StateError('Unsupported constant operation $operation'); 421 // throw new StateError('Unsupported constant operation $operation');
405 } 422 }
406 } 423 }
407 return stack.single; 424 return stack.single;
408 } 425 }
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 for (PropertyAccessorElementImpl accessor in unit.accessors) { 1497 for (PropertyAccessorElementImpl accessor in unit.accessors) {
1481 elementMap[accessor.identifier] = accessor; 1498 elementMap[accessor.identifier] = accessor;
1482 } 1499 }
1483 resummarizedElements[absoluteUri] = elementMap; 1500 resummarizedElements[absoluteUri] = elementMap;
1484 unitHolder = null; 1501 unitHolder = null;
1485 linkedUnit = null; 1502 linkedUnit = null;
1486 unlinkedUnit = null; 1503 unlinkedUnit = null;
1487 linkedTypeMap = null; 1504 linkedTypeMap = null;
1488 } 1505 }
1489 } 1506 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698