| 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; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 this.getterFlags, this.setterFlags, | 280 this.getterFlags, this.setterFlags, |
| 281 this.needsCheckedSetter); | 281 this.needsCheckedSetter); |
| 282 | 282 |
| 283 bool get needsGetter => getterFlags != 0; | 283 bool get needsGetter => getterFlags != 0; |
| 284 bool get needsUncheckedSetter => setterFlags != 0; | 284 bool get needsUncheckedSetter => setterFlags != 0; |
| 285 | 285 |
| 286 bool get needsInterceptedGetter => getterFlags > 1; | 286 bool get needsInterceptedGetter => getterFlags > 1; |
| 287 bool get needsInterceptedSetter => setterFlags > 1; | 287 bool get needsInterceptedSetter => setterFlags > 1; |
| 288 } | 288 } |
| 289 | 289 |
| 290 class Method { | 290 abstract class Method { |
| 291 /// The element should only be used during the transition to the new model. | 291 /// The element should only be used during the transition to the new model. |
| 292 /// Uses indicate missing information in the model. | 292 /// Uses indicate missing information in the model. |
| 293 final Element element; | 293 final Element element; |
| 294 | |
| 295 final String name; | 294 final String name; |
| 296 final js.Expression code; | 295 final js.Expression code; |
| 296 |
| 297 Method(this.element, this.name, this.code); |
| 298 } |
| 299 |
| 300 /** |
| 301 * A method that corresponds to a method in the original Dart program. |
| 302 */ |
| 303 class DartMethod extends Method { |
| 297 final bool needsTearOff; | 304 final bool needsTearOff; |
| 305 final String tearOffName; |
| 306 // TODO(herhut): Directly store stubs instead/ |
| 307 final bool needsStubs; |
| 308 // TODO(herhut): Directly store aliases instead. |
| 309 final bool canBeApplied; |
| 310 final bool canBeReflected; |
| 298 | 311 |
| 299 Method(this.element, this.name, this.code, {this.needsTearOff}) { | 312 DartMethod(Element element, String name, js.Expression code, |
| 313 {this.needsTearOff, this.tearOffName, this.needsStubs, this.canBeApplied, |
| 314 this.canBeReflected}) |
| 315 : super(element, name, code) { |
| 300 assert(needsTearOff != null); | 316 assert(needsTearOff != null); |
| 317 assert(!needsTearOff || tearOffName != null); |
| 318 assert(canBeApplied != null); |
| 319 assert(canBeReflected != null); |
| 320 assert(needsStubs != null); |
| 301 } | 321 } |
| 302 } | 322 } |
| 303 | 323 |
| 324 class InstanceMethod extends DartMethod { |
| 325 // TODO(herhut): Directly store aliases instead. |
| 326 final bool hasSuperAlias; |
| 327 final bool isClosure; |
| 328 |
| 329 InstanceMethod(element, name, code, |
| 330 {bool needsTearOff, |
| 331 String tearOffName, |
| 332 this.hasSuperAlias, |
| 333 bool canBeApplied, |
| 334 bool canBeReflected, |
| 335 this.isClosure, |
| 336 bool needsStubs}) |
| 337 : super(element, name, code, |
| 338 needsTearOff: needsTearOff, |
| 339 tearOffName: tearOffName, |
| 340 canBeApplied: canBeApplied, |
| 341 canBeReflected: canBeReflected, |
| 342 needsStubs: needsStubs) { |
| 343 assert(hasSuperAlias != null); |
| 344 assert(isClosure != null); |
| 345 } |
| 346 } |
| 347 |
| 348 /** |
| 349 * A method that is generated by the backend and has not direct correspondence |
| 350 * to a method in the original Dart program. Examples are getter and setter |
| 351 * stubs and stubs to dispatch calls to methods with optional parameters. |
| 352 */ |
| 304 class StubMethod extends Method { | 353 class StubMethod extends Method { |
| 305 StubMethod(String name, js.Expression code, | 354 StubMethod(String name, js.Expression code, |
| 306 {bool needsTearOff, Element element }) | 355 {Element element}) |
| 307 : super(element, name, code, needsTearOff: needsTearOff); | 356 : super(element, name, code); |
| 308 } | 357 } |
| 309 | 358 |
| 310 class StaticMethod extends Method { | 359 class StaticMethod extends DartMethod { |
| 311 final Holder holder; | 360 final Holder holder; |
| 312 StaticMethod(Element element, String name, this.holder, js.Expression code, | 361 StaticMethod(Element element, String name, this.holder, js.Expression code, |
| 313 {bool needsTearOff}) | 362 {bool needsTearOff, String tearOffName, bool canBeApplied, |
| 314 : super(element, name, code, needsTearOff: needsTearOff); | 363 bool canBeReflected, bool needsStubs}) |
| 364 : super(element, name, code, |
| 365 needsTearOff: needsTearOff, |
| 366 tearOffName : tearOffName, |
| 367 canBeApplied : canBeApplied, |
| 368 canBeReflected : canBeReflected, |
| 369 needsStubs : needsStubs); |
| 315 } | 370 } |
| 316 | 371 |
| 317 class StaticStubMethod extends StaticMethod { | 372 class StaticStubMethod extends StubMethod { |
| 318 StaticStubMethod(String name, Holder holder, js.Expression code, | 373 Holder holder; |
| 319 {bool needsTearOff}) | 374 StaticStubMethod(String name, this.holder, js.Expression code) |
| 320 : super(null, name, holder, code, needsTearOff: needsTearOff); | 375 : super(name, code); |
| 321 } | 376 } |
| OLD | NEW |