| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 case UnlinkedConstOperation.makeUntypedList: | 396 case UnlinkedConstOperation.makeUntypedList: |
| 397 int count = uc.ints[intPtr++]; |
| 398 List<Expression> elements = <Expression>[]; |
| 399 for (int i= 0; i < count; i++) { |
| 400 elements.insert(0, _pop()); |
| 401 } |
| 402 _push(AstFactory.listLiteral2(Keyword.CONST, null, elements)); |
| 403 break; |
| 404 case UnlinkedConstOperation.makeUntypedMap: |
| 405 int count = uc.ints[intPtr++]; |
| 406 List<MapLiteralEntry> entries = <MapLiteralEntry>[]; |
| 407 for (int i= 0; i < count; i++) { |
| 408 Expression value = _pop(); |
| 409 Expression key = _pop(); |
| 410 entries.insert(0, AstFactory.mapLiteralEntry2(key, value)); |
| 411 } |
| 412 _push(AstFactory.mapLiteral(Keyword.CONST, null, entries)); |
| 413 break; |
| 397 case UnlinkedConstOperation.makeTypedList: | 414 case UnlinkedConstOperation.makeTypedList: |
| 398 case UnlinkedConstOperation.makeUntypedMap: | |
| 399 case UnlinkedConstOperation.makeTypedMap: | 415 case UnlinkedConstOperation.makeTypedMap: |
| 400 case UnlinkedConstOperation.pushReference: | 416 case UnlinkedConstOperation.pushReference: |
| 401 case UnlinkedConstOperation.invokeConstructor: | 417 case UnlinkedConstOperation.invokeConstructor: |
| 402 case UnlinkedConstOperation.length: | 418 case UnlinkedConstOperation.length: |
| 403 return AstFactory.nullLiteral(); | 419 return AstFactory.nullLiteral(); |
| 404 // throw new StateError('Unsupported constant operation $operation'); | 420 // throw new StateError('Unsupported constant operation $operation'); |
| 405 } | 421 } |
| 406 } | 422 } |
| 407 return stack.single; | 423 return stack.single; |
| 408 } | 424 } |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 return new InterfaceTypeImpl.elementWithNameAndArgs( | 1605 return new InterfaceTypeImpl.elementWithNameAndArgs( |
| 1590 element, name, typeArguments); | 1606 element, name, typeArguments); |
| 1591 } else if (element is FunctionTypeAliasElementHandle) { | 1607 } else if (element is FunctionTypeAliasElementHandle) { |
| 1592 return new FunctionTypeImpl.elementWithNameAndArgs( | 1608 return new FunctionTypeImpl.elementWithNameAndArgs( |
| 1593 element, name, typeArguments, typeArguments.isNotEmpty); | 1609 element, name, typeArguments, typeArguments.isNotEmpty); |
| 1594 } else { | 1610 } else { |
| 1595 return null; | 1611 return null; |
| 1596 } | 1612 } |
| 1597 } | 1613 } |
| 1598 } | 1614 } |
| OLD | NEW |