| 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 '../deferred_load.dart' show OutputUnit; | 10 import '../deferred_load.dart' show OutputUnit; |
| 11 | 11 |
| 12 import '../common.dart'; | 12 import '../common.dart'; |
| 13 | 13 |
| 14 class Program { | 14 class Program { |
| 15 final List<Fragment> fragments; | 15 final List<Fragment> fragments; |
| 16 final bool outputContainsConstantList; | 16 final bool outputContainsConstantList; |
| 17 /// A map from load id to the list of fragments that need to be loaded. | 17 /// A map from load id to the list of fragments that need to be loaded. |
| 18 final Map<String, List<Fragment>> loadMap; | 18 final Map<String, List<Fragment>> loadMap; |
| 19 | 19 |
| 20 Program(this.fragments, this.outputContainsConstantList, this.loadMap); | 20 Program(this.fragments, this.outputContainsConstantList, this.loadMap); |
| 21 |
| 22 bool get isSplit => fragments.length > 1; |
| 23 Iterable<Fragment> get deferredFragments => fragments.skip(1); |
| 21 } | 24 } |
| 22 | 25 |
| 23 /** | 26 /** |
| 24 * This class represents a JavaScript object that contains static state, like | 27 * This class represents a JavaScript object that contains static state, like |
| 25 * classes or functions. | 28 * classes or functions. |
| 26 */ | 29 */ |
| 27 class Holder { | 30 class Holder { |
| 28 final String name; | 31 final String name; |
| 29 final int index; | 32 final int index; |
| 30 Holder(this.name, this.index); | 33 Holder(this.name, this.index); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 bool get needsSetter => setterFlags != 0; | 241 bool get needsSetter => setterFlags != 0; |
| 239 } | 242 } |
| 240 | 243 |
| 241 class Method { | 244 class Method { |
| 242 /// The element should only be used during the transition to the new model. | 245 /// The element should only be used during the transition to the new model. |
| 243 /// Uses indicate missing information in the model. | 246 /// Uses indicate missing information in the model. |
| 244 final Element element; | 247 final Element element; |
| 245 | 248 |
| 246 final String name; | 249 final String name; |
| 247 final js.Expression code; | 250 final js.Expression code; |
| 248 Method(this.element, this.name, this.code); | 251 final bool needsTearOff; |
| 252 |
| 253 Method(this.element, this.name, this.code, {this.needsTearOff}) { |
| 254 assert(needsTearOff != null); |
| 255 } |
| 249 } | 256 } |
| 250 | 257 |
| 251 class StubMethod extends Method { | 258 class StubMethod extends Method { |
| 252 StubMethod(String name, js.Expression code) : super(null, name, code); | 259 StubMethod(String name, js.Expression code, {bool needsTearOff}) |
| 260 : super(null, name, code, needsTearOff: needsTearOff); |
| 253 } | 261 } |
| 254 | 262 |
| 255 class StaticMethod extends Method { | 263 class StaticMethod extends Method { |
| 256 final Holder holder; | 264 final Holder holder; |
| 257 StaticMethod(Element element, String name, this.holder, js.Expression code) | 265 StaticMethod(Element element, String name, this.holder, js.Expression code, |
| 258 : super(element, name, code); | 266 {bool needsTearOff}) |
| 267 : super(element, name, code, needsTearOff: needsTearOff); |
| 259 } | 268 } |
| 260 | 269 |
| 261 class StaticStubMethod extends StaticMethod { | 270 class StaticStubMethod extends StaticMethod { |
| 262 StaticStubMethod(String name, Holder holder, js.Expression code) | 271 StaticStubMethod(String name, Holder holder, js.Expression code, |
| 263 : super(null, name, holder, code); | 272 {bool needsTearOff}) |
| 273 : super(null, name, holder, code, needsTearOff: needsTearOff); |
| 264 } | 274 } |
| OLD | NEW |