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

Side by Side Diff: pkg/compiler/lib/src/kernel/kelements.dart

Issue 2969013002: Support creating elements from IR nodes in JsKernelToElementMap (Closed)
Patch Set: Updated cf. comments Created 3 years, 5 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 /// Entity model for elements derived from Kernel IR. 5 /// Entity model for elements derived from Kernel IR.
6 6
7 import '../elements/entities.dart'; 7 import '../elements/entities.dart';
8 import '../elements/names.dart'; 8 import '../elements/names.dart';
9 import '../elements/types.dart'; 9 import '../elements/types.dart';
10 import 'elements.dart'; 10 import 'elements.dart';
11 11
12 const String kElementPrefix = 'k';
13
12 class KLibrary implements IndexedLibrary { 14 class KLibrary implements IndexedLibrary {
13 /// Library index used for fast lookup in [KernelWorldBuilder]. 15 /// Library index used for fast lookup in [KernelWorldBuilder].
14 final int libraryIndex; 16 final int libraryIndex;
15 final String name; 17 final String name;
16 final Uri canonicalUri; 18 final Uri canonicalUri;
17 19
18 KLibrary(this.libraryIndex, this.name, this.canonicalUri); 20 KLibrary(this.libraryIndex, this.name, this.canonicalUri);
19 21
20 String toString() => 'library($name)'; 22 String toString() => '${kElementPrefix}library($name)';
21 } 23 }
22 24
23 class KClass implements IndexedClass { 25 class KClass implements IndexedClass {
24 final KLibrary library; 26 final KLibrary library;
25 27
26 /// Class index used for fast lookup in [KernelWorldBuilder]. 28 /// Class index used for fast lookup in [KernelWorldBuilder].
27 final int classIndex; 29 final int classIndex;
28 30
29 final String name; 31 final String name;
30 final bool isAbstract; 32 final bool isAbstract;
31 33
32 KClass(this.library, this.classIndex, this.name, {this.isAbstract}); 34 KClass(this.library, this.classIndex, this.name, {this.isAbstract});
33 35
34 @override 36 @override
35 bool get isClosure => false; 37 bool get isClosure => false;
36 38
37 String toString() => 'class($name)'; 39 String toString() => '${kElementPrefix}class($name)';
38 } 40 }
39 41
40 abstract class KMember implements IndexedMember { 42 abstract class KMember implements IndexedMember {
41 /// Member index used for fast lookup in [KernelWorldBuilder]. 43 /// Member index used for fast lookup in [KernelWorldBuilder].
42 final int memberIndex; 44 final int memberIndex;
43 final KLibrary library; 45 final KLibrary library;
44 final KClass enclosingClass; 46 final KClass enclosingClass;
45 final Name _name; 47 final Name _name;
46 final bool _isStatic; 48 final bool _isStatic;
47 49
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 bool get isInstanceMember => enclosingClass != null && !_isStatic; 83 bool get isInstanceMember => enclosingClass != null && !_isStatic;
82 84
83 @override 85 @override
84 bool get isStatic => enclosingClass != null && _isStatic; 86 bool get isStatic => enclosingClass != null && _isStatic;
85 87
86 @override 88 @override
87 bool get isTopLevel => enclosingClass == null; 89 bool get isTopLevel => enclosingClass == null;
88 90
89 String get _kind; 91 String get _kind;
90 92
91 String toString() => 93 String toString() => '${kElementPrefix}$_kind'
92 '$_kind(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)'; 94 '(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)';
93 } 95 }
94 96
95 abstract class KFunction extends KMember 97 abstract class KFunction extends KMember
96 implements FunctionEntity, IndexedFunction { 98 implements FunctionEntity, IndexedFunction {
97 final ParameterStructure parameterStructure; 99 final ParameterStructure parameterStructure;
98 final bool isExternal; 100 final bool isExternal;
99 final AsyncMarker asyncMarker; 101 final AsyncMarker asyncMarker;
100 102
101 KFunction(int memberIndex, KLibrary library, KClass enclosingClass, Name name, 103 KFunction(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
102 this.parameterStructure, this.asyncMarker, 104 this.parameterStructure, this.asyncMarker,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 String get _kind => 'field'; 228 String get _kind => 'field';
227 } 229 }
228 230
229 class KTypeVariable implements TypeVariableEntity { 231 class KTypeVariable implements TypeVariableEntity {
230 final Entity typeDeclaration; 232 final Entity typeDeclaration;
231 final String name; 233 final String name;
232 final int index; 234 final int index;
233 235
234 KTypeVariable(this.typeDeclaration, this.name, this.index); 236 KTypeVariable(this.typeDeclaration, this.name, this.index);
235 237
236 String toString() => 'type_variable(${typeDeclaration.name}.$name)'; 238 String toString() =>
239 '${kElementPrefix}type_variable(${typeDeclaration.name}.$name)';
237 } 240 }
238 241
239 class KLocalFunction implements Local { 242 class KLocalFunction implements Local {
240 final String name; 243 final String name;
241 final MemberEntity memberContext; 244 final MemberEntity memberContext;
242 final Entity executableContext; 245 final Entity executableContext;
243 final FunctionType functionType; 246 final FunctionType functionType;
244 247
245 KLocalFunction( 248 KLocalFunction(
246 this.name, this.memberContext, this.executableContext, this.functionType); 249 this.name, this.memberContext, this.executableContext, this.functionType);
247 250
248 String toString() => 251 String toString() =>
249 'local_function(${memberContext.name}.${name ?? '<anonymous>'})'; 252 '${kElementPrefix}local_function(${memberContext.name}.${name ?? '<anonymo us>'})';
250 } 253 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/element_map_impl.dart ('k') | pkg/compiler/lib/src/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698