| 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 FieldElementImpl valuesField = new FieldElementImpl("values", -1); | 3734 ConstFieldElementImpl valuesField = new ConstFieldElementImpl.con2("values",
-1); |
| 3735 valuesField.static = true; | 3735 valuesField.static = true; |
| 3736 valuesField.const3 = true; | 3736 valuesField.const3 = true; |
| 3737 valuesField.synthetic = true; | 3737 valuesField.synthetic = true; |
| 3738 valuesField.type = _typeProvider.listType.substitute4(<DartType>[enumType]); | 3738 valuesField.type = _typeProvider.listType.substitute4(<DartType>[enumType]); |
| 3739 fields.add(valuesField); | 3739 fields.add(valuesField); |
| 3740 getters.add(_createGetter(valuesField)); | 3740 getters.add(_createGetter(valuesField)); |
| 3741 // | 3741 // |
| 3742 // Build the enum constants. | 3742 // Build the enum constants. |
| 3743 // | 3743 // |
| 3744 NodeList<EnumConstantDeclaration> constants = node.constants; | 3744 NodeList<EnumConstantDeclaration> constants = node.constants; |
| 3745 List<DartObjectImpl> constantValues = new List<DartObjectImpl>(); |
| 3745 int constantCount = constants.length; | 3746 int constantCount = constants.length; |
| 3746 for (int i = 0; i < constantCount; i++) { | 3747 for (int i = 0; i < constantCount; i++) { |
| 3747 SimpleIdentifier constantName = constants[i].name; | 3748 SimpleIdentifier constantName = constants[i].name; |
| 3748 FieldElementImpl constantField = | 3749 FieldElementImpl constantField = |
| 3749 new ConstFieldElementImpl.con1(constantName); | 3750 new ConstFieldElementImpl.con1(constantName); |
| 3750 constantField.static = true; | 3751 constantField.static = true; |
| 3751 constantField.const3 = true; | 3752 constantField.const3 = true; |
| 3752 constantField.type = enumType; | 3753 constantField.type = enumType; |
| 3753 // | 3754 // |
| 3754 // Create a value for the constant. | 3755 // Create a value for the constant. |
| 3755 // | 3756 // |
| 3756 HashMap<String, DartObjectImpl> fieldMap = | 3757 HashMap<String, DartObjectImpl> fieldMap = |
| 3757 new HashMap<String, DartObjectImpl>(); | 3758 new HashMap<String, DartObjectImpl>(); |
| 3758 fieldMap[indexFieldName] = new DartObjectImpl(intType, new IntState(i)); | 3759 fieldMap[indexFieldName] = new DartObjectImpl(intType, new IntState(i)); |
| 3759 DartObjectImpl value = | 3760 DartObjectImpl value = |
| 3760 new DartObjectImpl(enumType, new GenericState(fieldMap)); | 3761 new DartObjectImpl(enumType, new GenericState(fieldMap)); |
| 3762 constantValues.add(value); |
| 3761 constantField.evaluationResult = new EvaluationResultImpl.con1(value); | 3763 constantField.evaluationResult = new EvaluationResultImpl.con1(value); |
| 3762 fields.add(constantField); | 3764 fields.add(constantField); |
| 3763 getters.add(_createGetter(constantField)); | 3765 getters.add(_createGetter(constantField)); |
| 3764 constantName.staticElement = constantField; | 3766 constantName.staticElement = constantField; |
| 3765 } | 3767 } |
| 3766 // | 3768 // |
| 3769 // Build the value of the 'values' field. |
| 3770 // |
| 3771 valuesField.evaluationResult = new EvaluationResultImpl.con1(new DartObjectI
mpl(valuesField.type, new ListState(constantValues))); |
| 3772 // |
| 3767 // Finish building the enum. | 3773 // Finish building the enum. |
| 3768 // | 3774 // |
| 3769 enumElement.fields = fields; | 3775 enumElement.fields = fields; |
| 3770 enumElement.accessors = getters; | 3776 enumElement.accessors = getters; |
| 3771 // Client code isn't allowed to invoke the constructor, so we do not model | 3777 // Client code isn't allowed to invoke the constructor, so we do not model |
| 3772 // it. | 3778 // it. |
| 3773 return super.visitEnumDeclaration(node); | 3779 return super.visitEnumDeclaration(node); |
| 3774 } | 3780 } |
| 3775 | 3781 |
| 3776 /** | 3782 /** |
| (...skipping 11587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15364 * library. | 15370 * library. |
| 15365 */ | 15371 */ |
| 15366 final HashSet<String> members = new HashSet<String>(); | 15372 final HashSet<String> members = new HashSet<String>(); |
| 15367 | 15373 |
| 15368 /** | 15374 /** |
| 15369 * Names of resolved or unresolved class members that are read in the | 15375 * Names of resolved or unresolved class members that are read in the |
| 15370 * library. | 15376 * library. |
| 15371 */ | 15377 */ |
| 15372 final HashSet<String> readMembers = new HashSet<String>(); | 15378 final HashSet<String> readMembers = new HashSet<String>(); |
| 15373 } | 15379 } |
| OLD | NEW |