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

Side by Side Diff: pkg/compiler/lib/src/core_types.dart

Issue 2653203002: Use entities in CommonElements interface. (Closed)
Patch Set: Created 3 years, 11 months 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) 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 // TODO(sigmund): rename and move to common/elements.dart 5 // TODO(sigmund): rename and move to common/elements.dart
6 library dart2js.type_system; 6 library dart2js.type_system;
7 7
8 import 'elements/resolution_types.dart'; 8 import 'elements/types.dart';
9 import 'elements/elements.dart' 9 import 'elements/entities.dart';
10 show 10 import 'elements/elements.dart' show Entity;
11 ClassElement,
12 ConstructorElement,
13 FunctionElement,
14 LibraryElement,
15 Element;
16 11
17 /// The common elements and types in Dart. 12 /// The common elements and types in Dart.
18 abstract class CommonElements { 13 abstract class CommonElements {
19 /// The `Object` class defined in 'dart:core'. 14 /// The `Object` class defined in 'dart:core'.
20 ClassElement get objectClass; 15 ClassEntity get objectClass;
21 16
22 /// The `bool` class defined in 'dart:core'. 17 /// The `bool` class defined in 'dart:core'.
23 ClassElement get boolClass; 18 ClassEntity get boolClass;
24 19
25 /// The `num` class defined in 'dart:core'. 20 /// The `num` class defined in 'dart:core'.
26 ClassElement get numClass; 21 ClassEntity get numClass;
27 22
28 /// The `int` class defined in 'dart:core'. 23 /// The `int` class defined in 'dart:core'.
29 ClassElement get intClass; 24 ClassEntity get intClass;
30 25
31 /// The `double` class defined in 'dart:core'. 26 /// The `double` class defined in 'dart:core'.
32 ClassElement get doubleClass; 27 ClassEntity get doubleClass;
33 28
34 /// The `Resource` class defined in 'dart:core'. 29 /// The `Resource` class defined in 'dart:core'.
35 ClassElement get resourceClass; 30 ClassEntity get resourceClass;
36 31
37 /// The `String` class defined in 'dart:core'. 32 /// The `String` class defined in 'dart:core'.
38 ClassElement get stringClass; 33 ClassEntity get stringClass;
39 34
40 /// The `Symbol` class defined in 'dart:core'. 35 /// The `Symbol` class defined in 'dart:core'.
41 ClassElement get symbolClass; 36 ClassEntity get symbolClass;
42 37
43 /// The `Function` class defined in 'dart:core'. 38 /// The `Function` class defined in 'dart:core'.
44 ClassElement get functionClass; 39 ClassEntity get functionClass;
45 40
46 /// The `Null` class defined in 'dart:core'. 41 /// The `Null` class defined in 'dart:core'.
47 ClassElement get nullClass; 42 ClassEntity get nullClass;
48 43
49 /// The `Type` class defined in 'dart:core'. 44 /// The `Type` class defined in 'dart:core'.
50 ClassElement get typeClass; 45 ClassEntity get typeClass;
51 46
52 /// The `StackTrace` class defined in 'dart:core'; 47 /// The `StackTrace` class defined in 'dart:core';
53 ClassElement get stackTraceClass; 48 ClassEntity get stackTraceClass;
54 49
55 /// The `List` class defined in 'dart:core'; 50 /// The `List` class defined in 'dart:core';
56 ClassElement get listClass; 51 ClassEntity get listClass;
57 52
58 /// The `Map` class defined in 'dart:core'; 53 /// The `Map` class defined in 'dart:core';
59 ClassElement get mapClass; 54 ClassEntity get mapClass;
60 55
61 /// The `Iterable` class defined in 'dart:core'; 56 /// The `Iterable` class defined in 'dart:core';
62 ClassElement get iterableClass; 57 ClassEntity get iterableClass;
63 58
64 /// The `Future` class defined in 'async';. 59 /// The `Future` class defined in 'async';.
65 ClassElement get futureClass; 60 ClassEntity get futureClass;
66 61
67 /// The `Stream` class defined in 'async'; 62 /// The `Stream` class defined in 'async';
68 ClassElement get streamClass; 63 ClassEntity get streamClass;
69 64
70 /// The dart:core library. 65 /// The dart:core library.
71 LibraryElement get coreLibrary; 66 LibraryEntity get coreLibrary;
72 67
73 /// The dart:async library. 68 /// The dart:async library.
74 LibraryElement get asyncLibrary; 69 LibraryEntity get asyncLibrary;
75 70
76 /// The dart:mirrors library. Null if the program doesn't access dart:mirrors. 71 /// The dart:mirrors library. Null if the program doesn't access dart:mirrors.
77 LibraryElement get mirrorsLibrary; 72 LibraryEntity get mirrorsLibrary;
78 73
79 /// The dart:typed_data library. 74 /// The dart:typed_data library.
80 LibraryElement get typedDataLibrary; 75 LibraryEntity get typedDataLibrary;
81 76
82 /// The `NativeTypedData` class from dart:typed_data. 77 /// The `NativeTypedData` class from dart:typed_data.
83 ClassElement get typedDataClass; 78 ClassEntity get typedDataClass;
84 79
85 // TODO(johnniwinther): Move this to the JavaScriptBackend. 80 // TODO(johnniwinther): Move this to the JavaScriptBackend.
86 /// The class for patch annotation defined in dart:_js_helper. 81 /// The class for patch annotation defined in dart:_js_helper.
87 ClassElement get patchAnnotationClass; 82 ClassEntity get patchAnnotationClass;
88 83
89 // TODO(johnniwinther): Move this to the JavaScriptBackend. 84 // TODO(johnniwinther): Move this to the JavaScriptBackend.
90 ClassElement get nativeAnnotationClass; 85 ClassEntity get nativeAnnotationClass;
91 86
92 /// Constructor of the `Symbol` class. This getter will ensure that `Symbol` 87 /// Constructor of the `Symbol` class. This getter will ensure that `Symbol`
93 /// is resolved and lookup the constructor on demand. 88 /// is resolved and lookup the constructor on demand.
94 ConstructorElement get symbolConstructor; 89 FunctionEntity get symbolConstructor;
95 90
96 /// Whether [element] is the same as [symbolConstructor]. Used to check 91 /// Whether [element] is the same as [symbolConstructor]. Used to check
97 /// for the constructor without computing it until it is likely to be seen. 92 /// for the constructor without computing it until it is likely to be seen.
98 bool isSymbolConstructor(Element e); 93 bool isSymbolConstructor(Entity e);
99 94
100 /// The `MirrorSystem` class in dart:mirrors. 95 /// The `MirrorSystem` class in dart:mirrors.
101 ClassElement get mirrorSystemClass; 96 ClassEntity get mirrorSystemClass;
102 97
103 /// Whether [element] is `MirrorClass.getName`. Used to check for the use of 98 /// Whether [element] is `MirrorClass.getName`. Used to check for the use of
104 /// that static method without forcing the resolution of the `MirrorSystem` 99 /// that static method without forcing the resolution of the `MirrorSystem`
105 /// class until it is necessary. 100 /// class until it is necessary.
106 bool isMirrorSystemGetNameFunction(Element element); 101 bool isMirrorSystemGetNameFunction(MemberEntity element);
107 102
108 /// The `MirrorsUsed` annotation in dart:mirrors. 103 /// The `MirrorsUsed` annotation in dart:mirrors.
109 ClassElement get mirrorsUsedClass; 104 ClassEntity get mirrorsUsedClass;
110 105
111 /// Whether [element] is the constructor of the `MirrorsUsed` class. Used to 106 /// Whether [element] is the constructor of the `MirrorsUsed` class. Used to
112 /// check for the constructor without forcing the resolution of the 107 /// check for the constructor without forcing the resolution of the
113 /// `MirrorsUsed` class until it is necessary. 108 /// `MirrorsUsed` class until it is necessary.
114 bool isMirrorsUsedConstructor(ConstructorElement element); 109 bool isMirrorsUsedConstructor(FunctionEntity element);
115 110
116 /// The `DeferredLibrary` annotation in dart:async that was used before the 111 /// The `DeferredLibrary` annotation in dart:async that was used before the
117 /// deferred import syntax was introduced. 112 /// deferred import syntax was introduced.
118 // TODO(sigmund): drop support for this old syntax? 113 // TODO(sigmund): drop support for this old syntax?
119 ClassElement get deferredLibraryClass; 114 ClassEntity get deferredLibraryClass;
120 115
121 /// The function `identical` in dart:core. 116 /// The function `identical` in dart:core.
122 FunctionElement get identicalFunction; 117 FunctionEntity get identicalFunction;
123 118
124 /// The method `Function.apply`. 119 /// The method `Function.apply`.
125 FunctionElement get functionApplyMethod; 120 FunctionEntity get functionApplyMethod;
126 121
127 /// Whether [element] is the same as [functionApplyMethod]. This will not 122 /// Whether [element] is the same as [functionApplyMethod]. This will not
128 /// resolve the apply method if it hasn't been seen yet during compilation. 123 /// resolve the apply method if it hasn't been seen yet during compilation.
129 bool isFunctionApplyMethod(Element element); 124 bool isFunctionApplyMethod(MemberEntity element);
130 125
131 /// The unnamed constructor of `List`. 126 /// The unnamed constructor of `List`.
132 ConstructorElement get unnamedListConstructor; 127 FunctionEntity get unnamedListConstructor;
133 128
134 /// The 'filled' constructor of `List`. 129 /// The 'filled' constructor of `List`.
135 ConstructorElement get filledListConstructor; 130 FunctionEntity get filledListConstructor;
136 131
137 /// The `dynamic` type. 132 /// The `dynamic` type.
138 ResolutionDynamicType get dynamicType; 133 DynamicType get dynamicType;
139 134
140 /// The `Object` type defined in 'dart:core'. 135 /// The `Object` type defined in 'dart:core'.
141 ResolutionInterfaceType get objectType; 136 InterfaceType get objectType;
142 137
143 /// The `bool` type defined in 'dart:core'. 138 /// The `bool` type defined in 'dart:core'.
144 ResolutionInterfaceType get boolType; 139 InterfaceType get boolType;
145 140
146 /// The `num` type defined in 'dart:core'. 141 /// The `num` type defined in 'dart:core'.
147 ResolutionInterfaceType get numType; 142 InterfaceType get numType;
148 143
149 /// The `int` type defined in 'dart:core'. 144 /// The `int` type defined in 'dart:core'.
150 ResolutionInterfaceType get intType; 145 InterfaceType get intType;
151 146
152 /// The `double` type defined in 'dart:core'. 147 /// The `double` type defined in 'dart:core'.
153 ResolutionInterfaceType get doubleType; 148 InterfaceType get doubleType;
154 149
155 /// The `Resource` type defined in 'dart:core'. 150 /// The `Resource` type defined in 'dart:core'.
156 ResolutionInterfaceType get resourceType; 151 InterfaceType get resourceType;
157 152
158 /// The `String` type defined in 'dart:core'. 153 /// The `String` type defined in 'dart:core'.
159 ResolutionInterfaceType get stringType; 154 InterfaceType get stringType;
160 155
161 /// The `Symbol` type defined in 'dart:core'. 156 /// The `Symbol` type defined in 'dart:core'.
162 ResolutionInterfaceType get symbolType; 157 InterfaceType get symbolType;
163 158
164 /// The `Function` type defined in 'dart:core'. 159 /// The `Function` type defined in 'dart:core'.
165 ResolutionInterfaceType get functionType; 160 InterfaceType get functionType;
166 161
167 /// The `Null` type defined in 'dart:core'. 162 /// The `Null` type defined in 'dart:core'.
168 ResolutionInterfaceType get nullType; 163 InterfaceType get nullType;
169 164
170 /// The `Type` type defined in 'dart:core'. 165 /// The `Type` type defined in 'dart:core'.
171 ResolutionInterfaceType get typeType; 166 InterfaceType get typeType;
172 167
173 /// The `StackTrace` type defined in 'dart:core'; 168 /// The `StackTrace` type defined in 'dart:core';
174 ResolutionInterfaceType get stackTraceType; 169 InterfaceType get stackTraceType;
175 170
176 /// Returns an instance of the `List` type defined in 'dart:core' with 171 /// Returns an instance of the `List` type defined in 'dart:core' with
177 /// [elementType] as its type argument. 172 /// [elementType] as its type argument.
178 /// 173 ///
179 /// If no type argument is provided, the canonical raw type is returned. 174 /// If no type argument is provided, the canonical raw type is returned.
180 ResolutionInterfaceType listType([ResolutionDartType elementType]); 175 InterfaceType listType([DartType elementType]);
181 176
182 /// Returns an instance of the `Map` type defined in 'dart:core' with 177 /// Returns an instance of the `Map` type defined in 'dart:core' with
183 /// [keyType] and [valueType] as its type arguments. 178 /// [keyType] and [valueType] as its type arguments.
184 /// 179 ///
185 /// If no type arguments are provided, the canonical raw type is returned. 180 /// If no type arguments are provided, the canonical raw type is returned.
186 ResolutionInterfaceType mapType( 181 InterfaceType mapType([DartType keyType, DartType valueType]);
187 [ResolutionDartType keyType, ResolutionDartType valueType]);
188 182
189 /// Returns an instance of the `Iterable` type defined in 'dart:core' with 183 /// Returns an instance of the `Iterable` type defined in 'dart:core' with
190 /// [elementType] as its type argument. 184 /// [elementType] as its type argument.
191 /// 185 ///
192 /// If no type argument is provided, the canonical raw type is returned. 186 /// If no type argument is provided, the canonical raw type is returned.
193 ResolutionInterfaceType iterableType([ResolutionDartType elementType]); 187 InterfaceType iterableType([DartType elementType]);
194 188
195 /// Returns an instance of the `Future` type defined in 'dart:async' with 189 /// Returns an instance of the `Future` type defined in 'dart:async' with
196 /// [elementType] as its type argument. 190 /// [elementType] as its type argument.
197 /// 191 ///
198 /// If no type argument is provided, the canonical raw type is returned. 192 /// If no type argument is provided, the canonical raw type is returned.
199 ResolutionInterfaceType futureType([ResolutionDartType elementType]); 193 InterfaceType futureType([DartType elementType]);
200 194
201 /// Returns an instance of the `Stream` type defined in 'dart:async' with 195 /// Returns an instance of the `Stream` type defined in 'dart:async' with
202 /// [elementType] as its type argument. 196 /// [elementType] as its type argument.
203 /// 197 ///
204 /// If no type argument is provided, the canonical raw type is returned. 198 /// If no type argument is provided, the canonical raw type is returned.
205 ResolutionInterfaceType streamType([ResolutionDartType elementType]); 199 InterfaceType streamType([DartType elementType]);
206 200
207 /// Returns `true` if [element] is a superclass of `String` or `num`. 201 /// Returns `true` if [element] is a superclass of `String` or `num`.
208 bool isNumberOrStringSupertype(ClassElement element); 202 bool isNumberOrStringSupertype(ClassEntity element);
209 203
210 /// Returns `true` if [element] is a superclass of `String`. 204 /// Returns `true` if [element] is a superclass of `String`.
211 bool isStringOnlySupertype(ClassElement element); 205 bool isStringOnlySupertype(ClassEntity element);
212 206
213 /// Returns `true` if [element] is a superclass of `List`. 207 /// Returns `true` if [element] is a superclass of `List`.
214 bool isListSupertype(ClassElement element); 208 bool isListSupertype(ClassEntity element);
215 } 209 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/constants/expressions.dart ('k') | pkg/compiler/lib/src/elements/resolution_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698