Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /// Entity model for elements derived from Kernel IR. | |
| 6 | |
| 7 import '../elements/elements.dart'; | |
| 8 import '../elements/entities.dart'; | |
| 9 | |
| 10 class KLibrary implements LibraryEntity { | |
| 11 /// Library index used for fast lookup in [KernelWorldBuilder]. | |
| 12 final int libraryIndex; | |
| 13 final String name; | |
|
Siggi Cherem (dart-lang)
2017/01/30 20:31:36
do you expect we'll eventually have a field here d
Johnni Winther
2017/01/31 09:27:25
I want to avoid it. I would like to be able to flu
| |
| 14 final String libraryName; | |
| 15 | |
| 16 KLibrary(this.libraryIndex, this.name, this.libraryName); | |
| 17 | |
| 18 String toString() => 'library($name)'; | |
| 19 } | |
| 20 | |
| 21 class KClass implements ClassEntity { | |
| 22 final String name; | |
| 23 | |
| 24 KClass(this.name); | |
| 25 | |
| 26 @override | |
| 27 bool get isClosure => false; | |
| 28 | |
| 29 String toString() => 'class($name)'; | |
| 30 } | |
| 31 | |
| 32 abstract class KMember implements MemberEntity { | |
| 33 final KClass enclosingClass; | |
| 34 final Name _name; | |
| 35 final bool _isStatic; | |
| 36 | |
| 37 KMember(this.enclosingClass, this._name, {bool isStatic: false}) | |
| 38 : _isStatic = isStatic; | |
| 39 | |
| 40 String get name => _name.text; | |
| 41 | |
| 42 @override | |
| 43 bool get isAssignable => false; | |
| 44 | |
| 45 @override | |
| 46 bool get isSetter => false; | |
| 47 | |
| 48 @override | |
| 49 bool get isGetter => false; | |
| 50 | |
| 51 @override | |
| 52 bool get isFunction => false; | |
| 53 | |
| 54 @override | |
| 55 bool get isField => false; | |
| 56 | |
| 57 @override | |
| 58 bool get isConstructor => false; | |
| 59 | |
| 60 @override | |
| 61 bool get isInstanceMember => enclosingClass != null && !_isStatic; | |
| 62 | |
| 63 @override | |
| 64 bool get isStatic => enclosingClass != null && _isStatic; | |
| 65 | |
| 66 @override | |
| 67 bool get isTopLevel => enclosingClass == null; | |
| 68 | |
| 69 String get _kind; | |
| 70 | |
| 71 String toString() => | |
| 72 '$_kind(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)'; | |
| 73 } | |
| 74 | |
| 75 abstract class KFunction extends KMember implements FunctionEntity { | |
| 76 KFunction(KClass enclosingClass, Name name, {bool isStatic: false}) | |
| 77 : super(enclosingClass, name, isStatic: isStatic); | |
| 78 } | |
| 79 | |
| 80 abstract class KConstructor extends KFunction implements ConstructorEntity { | |
| 81 KConstructor(KClass enclosingClass, Name name) : super(enclosingClass, name); | |
| 82 | |
| 83 @override | |
| 84 bool get isConstructor => true; | |
| 85 | |
| 86 @override | |
| 87 bool get isInstanceMember => false; | |
| 88 | |
| 89 @override | |
| 90 bool get isStatic => false; | |
| 91 | |
| 92 @override | |
| 93 bool get isTopLevel => false; | |
| 94 | |
| 95 String get _kind => 'constructor'; | |
| 96 } | |
| 97 | |
| 98 class KGenerativeConstructor extends KConstructor { | |
| 99 KGenerativeConstructor(KClass enclosingClass, Name name) | |
| 100 : super(enclosingClass, name); | |
| 101 | |
| 102 @override | |
| 103 bool get isFactoryConstructor => false; | |
| 104 | |
| 105 @override | |
| 106 bool get isGenerativeConstructor => true; | |
| 107 } | |
| 108 | |
| 109 class KFactoryConstructor extends KConstructor { | |
| 110 KFactoryConstructor(KClass enclosingClass, Name name) | |
| 111 : super(enclosingClass, name); | |
| 112 | |
| 113 @override | |
| 114 bool get isFactoryConstructor => true; | |
| 115 | |
| 116 @override | |
| 117 bool get isGenerativeConstructor => false; | |
| 118 } | |
| 119 | |
| 120 class KMethod extends KFunction { | |
| 121 KMethod(KClass enclosingClass, Name name, {bool isStatic}) | |
| 122 : super(enclosingClass, name, isStatic: isStatic); | |
| 123 | |
| 124 @override | |
| 125 bool get isFunction => true; | |
| 126 | |
| 127 String get _kind => 'method'; | |
| 128 } | |
| 129 | |
| 130 class KGetter extends KFunction { | |
| 131 KGetter(KClass enclosingClass, Name name, {bool isStatic}) | |
| 132 : super(enclosingClass, name, isStatic: isStatic); | |
| 133 | |
| 134 @override | |
| 135 bool get isGetter => true; | |
| 136 | |
| 137 String get _kind => 'getter'; | |
| 138 } | |
| 139 | |
| 140 class KSetter extends KFunction { | |
| 141 KSetter(KClass enclosingClass, Name name, {bool isStatic}) | |
| 142 : super(enclosingClass, name, isStatic: isStatic); | |
| 143 | |
| 144 @override | |
| 145 bool get isAssignable => true; | |
| 146 | |
| 147 @override | |
| 148 bool get isSetter => true; | |
| 149 | |
| 150 String get _kind => 'setter'; | |
| 151 } | |
| 152 | |
| 153 class KField extends KMember implements FieldEntity { | |
| 154 final bool isAssignable; | |
| 155 | |
| 156 KField(KClass enclosingClass, Name name, {bool isStatic, this.isAssignable}) | |
| 157 : super(enclosingClass, name, isStatic: isStatic); | |
| 158 | |
| 159 @override | |
| 160 bool get isField => true; | |
| 161 | |
| 162 String get _kind => 'field'; | |
| 163 } | |
| 164 | |
| 165 class KTypeVariable implements TypeVariableEntity { | |
| 166 final Entity typeDeclaration; | |
| 167 final String name; | |
| 168 final int index; | |
| 169 | |
| 170 KTypeVariable(this.typeDeclaration, this.name, this.index); | |
| 171 } | |
| 172 | |
| 173 class KLocalFunction implements Local { | |
| 174 final String name; | |
| 175 final MemberEntity memberContext; | |
| 176 final Entity executableContext; | |
| 177 | |
| 178 KLocalFunction(this.name, this.memberContext, this.executableContext); | |
| 179 } | |
| OLD | NEW |