| 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/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 _pushMap(null); | 432 _pushMap(null); |
| 433 break; | 433 break; |
| 434 case UnlinkedConstOperation.makeTypedMap: | 434 case UnlinkedConstOperation.makeTypedMap: |
| 435 TypeName keyType = _newTypeName(); | 435 TypeName keyType = _newTypeName(); |
| 436 TypeName valueType = _newTypeName(); | 436 TypeName valueType = _newTypeName(); |
| 437 _pushMap(AstFactory.typeArgumentList(<TypeName>[keyType, valueType])); | 437 _pushMap(AstFactory.typeArgumentList(<TypeName>[keyType, valueType])); |
| 438 break; | 438 break; |
| 439 case UnlinkedConstOperation.pushReference: | 439 case UnlinkedConstOperation.pushReference: |
| 440 EntityRef ref = uc.references[refPtr++]; | 440 EntityRef ref = uc.references[refPtr++]; |
| 441 _ReferenceInfo info = resynthesizer.referenceInfos[ref.reference]; | 441 _ReferenceInfo info = resynthesizer.referenceInfos[ref.reference]; |
| 442 if (info.element != null) { | 442 SimpleIdentifier node = AstFactory.identifier3(info.name); |
| 443 SimpleIdentifier node = AstFactory.identifier3(info.name); | 443 node.staticElement = info.element; |
| 444 node.staticElement = info.element; | 444 _push(node); |
| 445 _push(node); | |
| 446 } else { | |
| 447 throw new StateError('Unsupported reference ${ref.toMap()}'); | |
| 448 } | |
| 449 break; | 445 break; |
| 450 case UnlinkedConstOperation.invokeConstructor: | 446 case UnlinkedConstOperation.invokeConstructor: |
| 451 _pushInstanceCreation(); | 447 _pushInstanceCreation(); |
| 452 break; | 448 break; |
| 453 case UnlinkedConstOperation.length: | 449 case UnlinkedConstOperation.length: |
| 454 Expression target = _pop(); | 450 Expression target = _pop(); |
| 455 SimpleIdentifier property = AstFactory.identifier3('length'); | 451 SimpleIdentifier property = AstFactory.identifier3('length'); |
| 456 property.staticElement = | 452 property.staticElement = |
| 457 resynthesizer._buildStringLengthPropertyAccessorElement(); | 453 resynthesizer._buildStringLengthPropertyAccessorElement(); |
| 458 _push(AstFactory.propertyAccess(target, property)); | 454 _push(AstFactory.propertyAccess(target, property)); |
| (...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 containingReference = unlinkedUnit.references[i].prefixReference; | 1833 containingReference = unlinkedUnit.references[i].prefixReference; |
| 1838 } else { | 1834 } else { |
| 1839 name = linkedUnit.references[i].name; | 1835 name = linkedUnit.references[i].name; |
| 1840 containingReference = linkedUnit.references[i].containingReference; | 1836 containingReference = linkedUnit.references[i].containingReference; |
| 1841 } | 1837 } |
| 1842 Element element; | 1838 Element element; |
| 1843 DartType type; | 1839 DartType type; |
| 1844 int numTypeParameters = linkedReference.numTypeParameters; | 1840 int numTypeParameters = linkedReference.numTypeParameters; |
| 1845 if (linkedReference.kind == ReferenceKind.unresolved) { | 1841 if (linkedReference.kind == ReferenceKind.unresolved) { |
| 1846 type = summaryResynthesizer.typeProvider.undefinedType; | 1842 type = summaryResynthesizer.typeProvider.undefinedType; |
| 1847 element = type.element; | 1843 element = null; |
| 1848 } else if (name == 'dynamic') { | 1844 } else if (name == 'dynamic') { |
| 1849 type = summaryResynthesizer.typeProvider.dynamicType; | 1845 type = summaryResynthesizer.typeProvider.dynamicType; |
| 1850 element = type.element; | 1846 element = type.element; |
| 1851 } else if (name == 'void') { | 1847 } else if (name == 'void') { |
| 1852 type = VoidTypeImpl.instance; | 1848 type = VoidTypeImpl.instance; |
| 1853 element = type.element; | 1849 element = type.element; |
| 1854 } else { | 1850 } else { |
| 1855 List<String> locationComponents; | 1851 List<String> locationComponents; |
| 1856 if (containingReference != 0 && | 1852 if (containingReference != 0 && |
| 1857 referenceInfos[containingReference].element is ClassElement) { | 1853 referenceInfos[containingReference].element is ClassElement) { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 } | 2178 } |
| 2183 : () => this.element; | 2179 : () => this.element; |
| 2184 // TODO(paulberry): Is it a bug that we have to pass `false` for | 2180 // TODO(paulberry): Is it a bug that we have to pass `false` for |
| 2185 // isInstantiated? | 2181 // isInstantiated? |
| 2186 return new DeferredFunctionTypeImpl(computer, null, typeArguments, false); | 2182 return new DeferredFunctionTypeImpl(computer, null, typeArguments, false); |
| 2187 } else { | 2183 } else { |
| 2188 return null; | 2184 return null; |
| 2189 } | 2185 } |
| 2190 } | 2186 } |
| 2191 } | 2187 } |
| OLD | NEW |