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 dev_compiler.src.codegen.js_field_storage; | 5 library dev_compiler.src.codegen.js_field_storage; |
6 | 6 |
7 import 'dart:collection' show HashMap, HashSet; | 7 import 'dart:collection' show HashMap, HashSet; |
8 import 'package:analyzer/src/generated/ast.dart' show Identifier; | 8 import 'package:analyzer/src/generated/ast.dart' show Identifier; |
9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 found = true; | 49 found = true; |
50 // Record that the super property is overridden. | 50 // Record that the super property is overridden. |
51 if (superprop.library == library) overrides.add(superprop); | 51 if (superprop.library == library) overrides.add(superprop); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 // If this we found a super property, then this property overrides it. | 55 // If this we found a super property, then this property overrides it. |
56 if (found) overrides.add(field); | 56 if (found) overrides.add(field); |
57 } | 57 } |
58 | 58 |
59 PropertyInducingElement getProperty( | 59 FieldElement getProperty( |
60 ClassElement cls, LibraryElement fromLibrary, String name) { | 60 ClassElement cls, LibraryElement fromLibrary, String name) { |
61 // Properties from a different library are not accessible. | 61 // Properties from a different library are not accessible. |
62 if (Identifier.isPrivateName(name) && cls.library != fromLibrary) { | 62 if (Identifier.isPrivateName(name) && cls.library != fromLibrary) { |
63 return null; | 63 return null; |
64 } | 64 } |
65 for (var accessor in cls.accessors) { | 65 for (var accessor in cls.accessors) { |
66 var prop = accessor.variable; | 66 var prop = accessor.variable; |
67 if (prop.name == name) return prop; | 67 if (prop.name == name) return prop; |
68 } | 68 } |
69 return null; | 69 return null; |
70 } | 70 } |
71 | 71 |
72 List<ClassElement> getSuperclasses(ClassElement cls) { | 72 List<ClassElement> getSuperclasses(ClassElement cls) { |
73 var result = <ClassElement>[]; | 73 var result = <ClassElement>[]; |
74 var visited = new HashSet<ClassElement>(); | 74 var visited = new HashSet<ClassElement>(); |
75 while (cls != null && visited.add(cls)) { | 75 while (cls != null && visited.add(cls)) { |
76 for (var mixinType in cls.mixins.reversed) { | 76 for (var mixinType in cls.mixins.reversed) { |
77 var mixin = mixinType.element; | 77 var mixin = mixinType.element; |
78 if (mixin != null) result.add(mixin); | 78 if (mixin != null) result.add(mixin); |
79 } | 79 } |
80 var supertype = cls.supertype; | 80 var supertype = cls.supertype; |
81 if (supertype == null) break; | 81 if (supertype == null) break; |
82 | 82 |
83 cls = supertype.element; | 83 cls = supertype.element; |
84 result.add(cls); | 84 result.add(cls); |
85 } | 85 } |
86 return result; | 86 return result; |
87 } | 87 } |
OLD | NEW |