| OLD | NEW |
| 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 library dart2js.new_js_emitter.model; | 5 library dart2js.new_js_emitter.model; |
| 6 | 6 |
| 7 import '../js/js.dart' as js show Expression; | 7 import '../js/js.dart' as js show Expression; |
| 8 import '../constants/values.dart' show ConstantValue; | 8 import '../constants/values.dart' show ConstantValue; |
| 9 | 9 |
| 10 import '../common.dart'; |
| 11 |
| 10 class Program { | 12 class Program { |
| 11 final List<Output> outputs; | 13 final List<Output> outputs; |
| 12 final bool outputContainsConstantList; | 14 final bool outputContainsConstantList; |
| 13 /// A map from load id to the list of outputs that need to be loaded. | 15 /// A map from load id to the list of outputs that need to be loaded. |
| 14 final Map<String, List<Output>> loadMap; | 16 final Map<String, List<Output>> loadMap; |
| 15 | 17 |
| 16 Program(this.outputs, this.outputContainsConstantList, this.loadMap); | 18 Program(this.outputs, this.outputContainsConstantList, this.loadMap); |
| 17 } | 19 } |
| 18 | 20 |
| 19 /** | 21 /** |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 104 |
| 103 class Constant { | 105 class Constant { |
| 104 final String name; | 106 final String name; |
| 105 final Holder holder; | 107 final Holder holder; |
| 106 final ConstantValue value; | 108 final ConstantValue value; |
| 107 | 109 |
| 108 Constant(this.name, this.holder, this.value); | 110 Constant(this.name, this.holder, this.value); |
| 109 } | 111 } |
| 110 | 112 |
| 111 class Library { | 113 class Library { |
| 114 /// The element should only be used during the transition to the new model. |
| 115 /// Uses indicate missing information in the model. |
| 116 final Element element; |
| 117 |
| 112 final String uri; | 118 final String uri; |
| 113 final List<StaticMethod> statics; | 119 final List<StaticMethod> statics; |
| 114 final List<Class> classes; | 120 final List<Class> classes; |
| 115 | 121 |
| 116 Library(this.uri, this.statics, this.classes); | 122 Library(this.element, this.uri, this.statics, this.classes); |
| 117 } | 123 } |
| 118 | 124 |
| 119 class StaticField { | 125 class StaticField { |
| 126 /// The element should only be used during the transition to the new model. |
| 127 /// Uses indicate missing information in the model. |
| 128 final Element element; |
| 129 |
| 120 final String name; | 130 final String name; |
| 121 // TODO(floitsch): the holder for static fields is the isolate object. We | 131 // TODO(floitsch): the holder for static fields is the isolate object. We |
| 122 // could remove this field and use the isolate object directly. | 132 // could remove this field and use the isolate object directly. |
| 123 final Holder holder; | 133 final Holder holder; |
| 124 final js.Expression code; | 134 final js.Expression code; |
| 125 final bool isFinal; | 135 final bool isFinal; |
| 126 final bool isLazy; | 136 final bool isLazy; |
| 127 | 137 |
| 128 StaticField(this.name, this.holder, this.code, | 138 StaticField(this.element, |
| 139 this.name, this.holder, this.code, |
| 129 this.isFinal, this.isLazy); | 140 this.isFinal, this.isLazy); |
| 130 } | 141 } |
| 131 | 142 |
| 132 class Class { | 143 class Class { |
| 144 /// The element should only be used during the transition to the new model. |
| 145 /// Uses indicate missing information in the model. |
| 146 final Element element; |
| 147 |
| 133 final String name; | 148 final String name; |
| 134 final Holder holder; | 149 final Holder holder; |
| 135 Class _superclass; | 150 Class _superclass; |
| 136 final List<Method> methods; | 151 final List<Method> methods; |
| 137 final List<InstanceField> fields; | 152 final List<InstanceField> fields; |
| 138 final bool onlyForRti; | 153 final bool onlyForRti; |
| 139 final bool isDirectlyInstantiated; | 154 final bool isDirectlyInstantiated; |
| 140 | 155 |
| 141 /// Whether the class must be evaluated eagerly. | 156 /// Whether the class must be evaluated eagerly. |
| 142 bool isEager = false; | 157 bool isEager = false; |
| 143 | 158 |
| 144 Class(this.name, this.holder, this.methods, this.fields, | 159 Class(this.element, |
| 160 this.name, this.holder, this.methods, this.fields, |
| 145 {this.onlyForRti, | 161 {this.onlyForRti, |
| 146 this.isDirectlyInstantiated}) { | 162 this.isDirectlyInstantiated}) { |
| 147 assert(onlyForRti != null); | 163 assert(onlyForRti != null); |
| 148 assert(isDirectlyInstantiated != null); | 164 assert(isDirectlyInstantiated != null); |
| 149 } | 165 } |
| 150 | 166 |
| 151 bool get isMixinApplication => false; | 167 bool get isMixinApplication => false; |
| 152 Class get superclass => _superclass; | 168 Class get superclass => _superclass; |
| 153 | 169 |
| 154 void setSuperclass(Class superclass) { | 170 void setSuperclass(Class superclass) { |
| 155 _superclass = superclass; | 171 _superclass = superclass; |
| 156 } | 172 } |
| 157 | 173 |
| 158 String get superclassName | 174 String get superclassName |
| 159 => (superclass == null) ? "" : superclass.name; | 175 => (superclass == null) ? "" : superclass.name; |
| 160 int get superclassHolderIndex | 176 int get superclassHolderIndex |
| 161 => (superclass == null) ? 0 : superclass.holder.index; | 177 => (superclass == null) ? 0 : superclass.holder.index; |
| 162 } | 178 } |
| 163 | 179 |
| 164 class MixinApplication extends Class { | 180 class MixinApplication extends Class { |
| 165 Class _mixinClass; | 181 Class _mixinClass; |
| 166 | 182 |
| 167 MixinApplication(String name, Holder holder, | 183 MixinApplication(Element element, |
| 184 String name, Holder holder, |
| 168 List<Method> methods, | 185 List<Method> methods, |
| 169 List<InstanceField> fields, | 186 List<InstanceField> fields, |
| 170 {bool onlyForRti, | 187 {bool onlyForRti, |
| 171 bool isDirectlyInstantiated}) | 188 bool isDirectlyInstantiated}) |
| 172 : super(name, holder, methods, fields, | 189 : super(element, |
| 190 name, holder, methods, fields, |
| 173 onlyForRti: onlyForRti, | 191 onlyForRti: onlyForRti, |
| 174 isDirectlyInstantiated: isDirectlyInstantiated); | 192 isDirectlyInstantiated: isDirectlyInstantiated); |
| 175 | 193 |
| 176 bool get isMixinApplication => true; | 194 bool get isMixinApplication => true; |
| 177 Class get mixinClass => _mixinClass; | 195 Class get mixinClass => _mixinClass; |
| 178 | 196 |
| 179 void setMixinClass(Class mixinClass) { | 197 void setMixinClass(Class mixinClass) { |
| 180 _mixinClass = mixinClass; | 198 _mixinClass = mixinClass; |
| 181 } | 199 } |
| 182 } | 200 } |
| 183 | 201 |
| 184 class InstanceField { | 202 class InstanceField { |
| 203 /// The element should only be used during the transition to the new model. |
| 204 /// Uses indicate missing information in the model. |
| 205 final Element element; |
| 206 |
| 185 final String name; | 207 final String name; |
| 186 | 208 |
| 187 /// 00: Does not need any getter. | 209 /// 00: Does not need any getter. |
| 188 /// 01: function() { return this.field; } | 210 /// 01: function() { return this.field; } |
| 189 /// 10: function(receiver) { return receiver.field; } | 211 /// 10: function(receiver) { return receiver.field; } |
| 190 /// 11: function(receiver) { return this.field; } | 212 /// 11: function(receiver) { return this.field; } |
| 191 final int getterFlags; | 213 final int getterFlags; |
| 192 | 214 |
| 193 /// 00: Does not need any setter. | 215 /// 00: Does not need any setter. |
| 194 /// 01: function(value) { this.field = value; } | 216 /// 01: function(value) { this.field = value; } |
| 195 /// 10: function(receiver, value) { receiver.field = value; } | 217 /// 10: function(receiver, value) { receiver.field = value; } |
| 196 /// 11: function(receiver, value) { this.field = value; } | 218 /// 11: function(receiver, value) { this.field = value; } |
| 197 final int setterFlags; | 219 final int setterFlags; |
| 198 | 220 |
| 199 // TODO(floitsch): support renamed fields. | 221 // TODO(floitsch): support renamed fields. |
| 200 InstanceField(this.name, this.getterFlags, this.setterFlags); | 222 InstanceField(this.element, this.name, this.getterFlags, this.setterFlags); |
| 201 | 223 |
| 202 bool get needsGetter => getterFlags != 0; | 224 bool get needsGetter => getterFlags != 0; |
| 203 bool get needsSetter => setterFlags != 0; | 225 bool get needsSetter => setterFlags != 0; |
| 204 } | 226 } |
| 205 | 227 |
| 206 class Method { | 228 class Method { |
| 229 /// The element should only be used during the transition to the new model. |
| 230 /// Uses indicate missing information in the model. |
| 231 final Element element; |
| 232 |
| 207 final String name; | 233 final String name; |
| 208 final js.Expression code; | 234 final js.Expression code; |
| 209 Method(this.name, this.code); | 235 Method(this.element, this.name, this.code); |
| 236 } |
| 237 |
| 238 class StubMethod extends Method { |
| 239 StubMethod(String name, js.Expression code) : super(null, name, code); |
| 210 } | 240 } |
| 211 | 241 |
| 212 class StaticMethod extends Method { | 242 class StaticMethod extends Method { |
| 213 final Holder holder; | 243 final Holder holder; |
| 214 StaticMethod(String name, this.holder, js.Expression code) | 244 StaticMethod(Element element, String name, this.holder, js.Expression code) |
| 215 : super(name, code); | 245 : super(element, name, code); |
| 216 } | 246 } |
| 247 |
| 248 class StaticStubMethod extends StaticMethod { |
| 249 StaticStubMethod(String name, Holder holder, js.Expression code) |
| 250 : super(null, name, holder, code); |
| 251 } |
| OLD | NEW |