Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/element_helpers.dart

Issue 2571363002: fixes #27385, implement virtual fields in DDC (Closed)
Patch Set: format Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:collection';
6
5 /// Helpers for Analyzer's Element model and corelib model. 7 /// Helpers for Analyzer's Element model and corelib model.
6 8
7 import 'package:analyzer/dart/ast/ast.dart' 9 import 'package:analyzer/dart/ast/ast.dart'
8 show 10 show
9 ConstructorDeclaration, 11 ConstructorDeclaration,
10 Expression, 12 Expression,
11 FunctionBody, 13 FunctionBody,
12 FunctionExpression, 14 FunctionExpression,
13 MethodDeclaration, 15 MethodDeclaration,
14 MethodInvocation, 16 MethodInvocation,
15 SimpleIdentifier; 17 SimpleIdentifier;
16 import 'package:analyzer/dart/element/element.dart' 18 import 'package:analyzer/dart/element/element.dart'
17 show Element, ExecutableElement, FunctionElement; 19 show ClassElement, Element, ExecutableElement, FunctionElement;
18 import 'package:analyzer/dart/element/type.dart' 20 import 'package:analyzer/dart/element/type.dart'
19 show DartType, InterfaceType, ParameterizedType; 21 show DartType, InterfaceType, ParameterizedType;
20 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; 22 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl;
21 import 'package:analyzer/src/generated/constant.dart' 23 import 'package:analyzer/src/generated/constant.dart'
22 show DartObject, DartObjectImpl; 24 show DartObject, DartObjectImpl;
23 25
24 class Tuple2<T0, T1> { 26 class Tuple2<T0, T1> {
25 final T0 e0; 27 final T0 e0;
26 final T1 e1; 28 final T1 e1;
27 Tuple2(this.e0, this.e1); 29 Tuple2(this.e0, this.e1);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 /// const MyAnnotation(this.name/*, ... other params ... */); 115 /// const MyAnnotation(this.name/*, ... other params ... */);
114 /// } 116 /// }
115 /// 117 ///
116 /// @MyAnnotation('FooBar') 118 /// @MyAnnotation('FooBar')
117 /// main() { ... } 119 /// main() { ... }
118 /// 120 ///
119 /// If we match the annotation for the `@MyAnnotation('FooBar')` this will 121 /// If we match the annotation for the `@MyAnnotation('FooBar')` this will
120 /// return the string 'FooBar'. 122 /// return the string 'FooBar'.
121 String getAnnotationName(Element element, bool match(DartObjectImpl value)) => 123 String getAnnotationName(Element element, bool match(DartObjectImpl value)) =>
122 findAnnotation(element, match)?.getField('name')?.toStringValue(); 124 findAnnotation(element, match)?.getField('name')?.toStringValue();
125
126 List<ClassElement> getSuperclasses(ClassElement cls) {
127 var result = <ClassElement>[];
128 var visited = new HashSet<ClassElement>();
129 while (cls != null && visited.add(cls)) {
130 for (var mixinType in cls.mixins.reversed) {
131 var mixin = mixinType.element;
132 if (mixin != null) result.add(mixin);
133 }
134 var supertype = cls.supertype;
135 if (supertype == null) break;
136
137 cls = supertype.element;
138 result.add(cls);
139 }
140 return result;
141 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/code_generator.dart ('k') | pkg/dev_compiler/lib/src/compiler/js_field_storage.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698