| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 engine.resolver; | 5 library engine.resolver; |
| 6 | 6 |
| 7 import "dart:math" as math; | 7 import "dart:math" as math; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/utilities_collection.dart'; | 10 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| (...skipping 3713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3724 List<FieldElement> fields = new List<FieldElement>(); | 3724 List<FieldElement> fields = new List<FieldElement>(); |
| 3725 List<PropertyAccessorElement> getters = new List<PropertyAccessorElement>(); | 3725 List<PropertyAccessorElement> getters = new List<PropertyAccessorElement>(); |
| 3726 InterfaceType intType = _typeProvider.intType; | 3726 InterfaceType intType = _typeProvider.intType; |
| 3727 String indexFieldName = "index"; | 3727 String indexFieldName = "index"; |
| 3728 FieldElementImpl indexField = new FieldElementImpl(indexFieldName, -1); | 3728 FieldElementImpl indexField = new FieldElementImpl(indexFieldName, -1); |
| 3729 indexField.final2 = true; | 3729 indexField.final2 = true; |
| 3730 indexField.synthetic = true; | 3730 indexField.synthetic = true; |
| 3731 indexField.type = intType; | 3731 indexField.type = intType; |
| 3732 fields.add(indexField); | 3732 fields.add(indexField); |
| 3733 getters.add(_createGetter(indexField)); | 3733 getters.add(_createGetter(indexField)); |
| 3734 ConstFieldElementImpl valuesField = new ConstFieldElementImpl.con2("values",
-1); | 3734 ConstFieldElementImpl valuesField = |
| 3735 new ConstFieldElementImpl.con2("values", -1); |
| 3735 valuesField.static = true; | 3736 valuesField.static = true; |
| 3736 valuesField.const3 = true; | 3737 valuesField.const3 = true; |
| 3737 valuesField.synthetic = true; | 3738 valuesField.synthetic = true; |
| 3738 valuesField.type = _typeProvider.listType.substitute4(<DartType>[enumType]); | 3739 valuesField.type = _typeProvider.listType.substitute4(<DartType>[enumType]); |
| 3739 fields.add(valuesField); | 3740 fields.add(valuesField); |
| 3740 getters.add(_createGetter(valuesField)); | 3741 getters.add(_createGetter(valuesField)); |
| 3741 // | 3742 // |
| 3742 // Build the enum constants. | 3743 // Build the enum constants. |
| 3743 // | 3744 // |
| 3744 NodeList<EnumConstantDeclaration> constants = node.constants; | 3745 NodeList<EnumConstantDeclaration> constants = node.constants; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3761 new DartObjectImpl(enumType, new GenericState(fieldMap)); | 3762 new DartObjectImpl(enumType, new GenericState(fieldMap)); |
| 3762 constantValues.add(value); | 3763 constantValues.add(value); |
| 3763 constantField.evaluationResult = new EvaluationResultImpl.con1(value); | 3764 constantField.evaluationResult = new EvaluationResultImpl.con1(value); |
| 3764 fields.add(constantField); | 3765 fields.add(constantField); |
| 3765 getters.add(_createGetter(constantField)); | 3766 getters.add(_createGetter(constantField)); |
| 3766 constantName.staticElement = constantField; | 3767 constantName.staticElement = constantField; |
| 3767 } | 3768 } |
| 3768 // | 3769 // |
| 3769 // Build the value of the 'values' field. | 3770 // Build the value of the 'values' field. |
| 3770 // | 3771 // |
| 3771 valuesField.evaluationResult = new EvaluationResultImpl.con1(new DartObjectI
mpl(valuesField.type, new ListState(constantValues))); | 3772 valuesField.evaluationResult = new EvaluationResultImpl.con1( |
| 3773 new DartObjectImpl(valuesField.type, new ListState(constantValues))); |
| 3772 // | 3774 // |
| 3773 // Finish building the enum. | 3775 // Finish building the enum. |
| 3774 // | 3776 // |
| 3775 enumElement.fields = fields; | 3777 enumElement.fields = fields; |
| 3776 enumElement.accessors = getters; | 3778 enumElement.accessors = getters; |
| 3777 // Client code isn't allowed to invoke the constructor, so we do not model | 3779 // Client code isn't allowed to invoke the constructor, so we do not model |
| 3778 // it. | 3780 // it. |
| 3779 return super.visitEnumDeclaration(node); | 3781 return super.visitEnumDeclaration(node); |
| 3780 } | 3782 } |
| 3781 | 3783 |
| (...skipping 9607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13389 * The type representing the built-in type 'Type'. | 13391 * The type representing the built-in type 'Type'. |
| 13390 */ | 13392 */ |
| 13391 InterfaceType _typeType; | 13393 InterfaceType _typeType; |
| 13392 | 13394 |
| 13393 /** | 13395 /** |
| 13394 * The type representing typenames that can't be resolved. | 13396 * The type representing typenames that can't be resolved. |
| 13395 */ | 13397 */ |
| 13396 DartType _undefinedType; | 13398 DartType _undefinedType; |
| 13397 | 13399 |
| 13398 /** | 13400 /** |
| 13399 * Initialize a newly created type provider to provide the types defined in th
e given library. | 13401 * Initialize a newly created type provider to provide the types defined in |
| 13400 * | 13402 * the given [coreLibrary] and [asyncLibrary]. |
| 13401 * @param coreLibrary the element representing the core library (dart:core). | |
| 13402 */ | 13403 */ |
| 13403 TypeProviderImpl(LibraryElement coreLibrary, LibraryElement asyncLibrary) { | 13404 TypeProviderImpl(LibraryElement coreLibrary, LibraryElement asyncLibrary) { |
| 13404 _initializeFrom(coreLibrary, asyncLibrary); | 13405 Namespace coreNamespace = |
| 13406 new NamespaceBuilder().createPublicNamespaceForLibrary(coreLibrary); |
| 13407 Namespace asyncNamespace = |
| 13408 new NamespaceBuilder().createPublicNamespaceForLibrary(asyncLibrary); |
| 13409 _initializeFrom(coreNamespace, asyncNamespace); |
| 13410 } |
| 13411 |
| 13412 /** |
| 13413 * Initialize a newly created type provider to provide the types defined in |
| 13414 * the given [Namespace]s. |
| 13415 */ |
| 13416 TypeProviderImpl.forNamespaces( |
| 13417 Namespace coreNamespace, Namespace asyncNamespace) { |
| 13418 _initializeFrom(coreNamespace, asyncNamespace); |
| 13405 } | 13419 } |
| 13406 | 13420 |
| 13407 @override | 13421 @override |
| 13408 InterfaceType get boolType => _boolType; | 13422 InterfaceType get boolType => _boolType; |
| 13409 | 13423 |
| 13410 @override | 13424 @override |
| 13411 DartType get bottomType => _bottomType; | 13425 DartType get bottomType => _bottomType; |
| 13412 | 13426 |
| 13413 @override | 13427 @override |
| 13414 InterfaceType get deprecatedType => _deprecatedType; | 13428 InterfaceType get deprecatedType => _deprecatedType; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13488 Element element = namespace.get(typeName); | 13502 Element element = namespace.get(typeName); |
| 13489 if (element == null) { | 13503 if (element == null) { |
| 13490 AnalysisEngine.instance.logger | 13504 AnalysisEngine.instance.logger |
| 13491 .logInformation("No definition of type $typeName"); | 13505 .logInformation("No definition of type $typeName"); |
| 13492 return null; | 13506 return null; |
| 13493 } | 13507 } |
| 13494 return (element as ClassElement).type; | 13508 return (element as ClassElement).type; |
| 13495 } | 13509 } |
| 13496 | 13510 |
| 13497 /** | 13511 /** |
| 13498 * Initialize the types provided by this type provider from the given library. | 13512 * Initialize the types provided by this type provider from the given |
| 13499 * | 13513 * [Namespace]s. |
| 13500 * @param library the library containing the definitions of the core types | |
| 13501 */ | 13514 */ |
| 13502 void _initializeFrom( | 13515 void _initializeFrom(Namespace coreNamespace, Namespace asyncNamespace) { |
| 13503 LibraryElement coreLibrary, LibraryElement asyncLibrary) { | |
| 13504 Namespace coreNamespace = | |
| 13505 new NamespaceBuilder().createPublicNamespaceForLibrary(coreLibrary); | |
| 13506 Namespace asyncNamespace = | |
| 13507 new NamespaceBuilder().createPublicNamespaceForLibrary(asyncLibrary); | |
| 13508 _boolType = _getType(coreNamespace, "bool"); | 13516 _boolType = _getType(coreNamespace, "bool"); |
| 13509 _bottomType = BottomTypeImpl.instance; | 13517 _bottomType = BottomTypeImpl.instance; |
| 13510 _deprecatedType = _getType(coreNamespace, "Deprecated"); | 13518 _deprecatedType = _getType(coreNamespace, "Deprecated"); |
| 13511 _doubleType = _getType(coreNamespace, "double"); | 13519 _doubleType = _getType(coreNamespace, "double"); |
| 13512 _dynamicType = DynamicTypeImpl.instance; | 13520 _dynamicType = DynamicTypeImpl.instance; |
| 13513 _functionType = _getType(coreNamespace, "Function"); | 13521 _functionType = _getType(coreNamespace, "Function"); |
| 13514 _futureType = _getType(asyncNamespace, "Future"); | 13522 _futureType = _getType(asyncNamespace, "Future"); |
| 13515 _intType = _getType(coreNamespace, "int"); | 13523 _intType = _getType(coreNamespace, "int"); |
| 13516 _iterableType = _getType(coreNamespace, "Iterable"); | 13524 _iterableType = _getType(coreNamespace, "Iterable"); |
| 13517 _listType = _getType(coreNamespace, "List"); | 13525 _listType = _getType(coreNamespace, "List"); |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15370 * library. | 15378 * library. |
| 15371 */ | 15379 */ |
| 15372 final HashSet<String> members = new HashSet<String>(); | 15380 final HashSet<String> members = new HashSet<String>(); |
| 15373 | 15381 |
| 15374 /** | 15382 /** |
| 15375 * Names of resolved or unresolved class members that are read in the | 15383 * Names of resolved or unresolved class members that are read in the |
| 15376 * library. | 15384 * library. |
| 15377 */ | 15385 */ |
| 15378 final HashSet<String> readMembers = new HashSet<String>(); | 15386 final HashSet<String> readMembers = new HashSet<String>(); |
| 15379 } | 15387 } |
| OLD | NEW |