| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 Method(this.element, this.name, this.code); | 327 Method(this.element, this.name, this.code); |
| 328 } | 328 } |
| 329 | 329 |
| 330 /** | 330 /** |
| 331 * A method that corresponds to a method in the original Dart program. | 331 * A method that corresponds to a method in the original Dart program. |
| 332 */ | 332 */ |
| 333 class DartMethod extends Method { | 333 class DartMethod extends Method { |
| 334 final bool needsTearOff; | 334 final bool needsTearOff; |
| 335 final String tearOffName; | 335 final String tearOffName; |
| 336 // TODO(herhut): Directly store stubs instead/ | 336 final List<ParameterStubMethod> parameterStubs; |
| 337 final bool needsStubs; | |
| 338 // TODO(herhut): Directly store aliases instead. | 337 // TODO(herhut): Directly store aliases instead. |
| 339 final bool canBeApplied; | 338 final bool canBeApplied; |
| 340 final bool canBeReflected; | 339 final bool canBeReflected; |
| 341 | 340 |
| 342 DartMethod(Element element, String name, js.Expression code, | 341 DartMethod(Element element, String name, js.Expression code, |
| 343 {this.needsTearOff, this.tearOffName, this.needsStubs, this.canBeApplied, | 342 this.parameterStubs, |
| 344 this.canBeReflected}) | 343 {this.needsTearOff, this.tearOffName, this.canBeApplied, |
| 344 this.canBeReflected}) |
| 345 : super(element, name, code) { | 345 : super(element, name, code) { |
| 346 assert(needsTearOff != null); | 346 assert(needsTearOff != null); |
| 347 assert(!needsTearOff || tearOffName != null); | 347 assert(!needsTearOff || tearOffName != null); |
| 348 assert(canBeApplied != null); | 348 assert(canBeApplied != null); |
| 349 assert(parameterStubs != null); |
| 349 assert(canBeReflected != null); | 350 assert(canBeReflected != null); |
| 350 assert(needsStubs != null); | |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 class InstanceMethod extends DartMethod { | 354 class InstanceMethod extends DartMethod { |
| 355 // TODO(herhut): Directly store aliases instead. | 355 // TODO(herhut): Directly store aliases instead. |
| 356 final bool hasSuperAlias; | 356 final bool hasSuperAlias; |
| 357 final bool isClosure; | 357 final bool isClosure; |
| 358 | 358 |
| 359 InstanceMethod(element, name, code, | 359 InstanceMethod(element, name, code, List<ParameterStubMethod> parameterStubs, |
| 360 {bool needsTearOff, | 360 {bool needsTearOff, |
| 361 String tearOffName, | 361 String tearOffName, |
| 362 this.hasSuperAlias, | 362 this.hasSuperAlias, |
| 363 bool canBeApplied, | 363 bool canBeApplied, |
| 364 bool canBeReflected, | 364 bool canBeReflected, |
| 365 this.isClosure, | 365 this.isClosure}) |
| 366 bool needsStubs}) | 366 : super(element, name, code, parameterStubs, |
| 367 : super(element, name, code, | |
| 368 needsTearOff: needsTearOff, | 367 needsTearOff: needsTearOff, |
| 369 tearOffName: tearOffName, | 368 tearOffName: tearOffName, |
| 370 canBeApplied: canBeApplied, | 369 canBeApplied: canBeApplied, |
| 371 canBeReflected: canBeReflected, | 370 canBeReflected: canBeReflected) { |
| 372 needsStubs: needsStubs) { | |
| 373 assert(hasSuperAlias != null); | 371 assert(hasSuperAlias != null); |
| 374 assert(isClosure != null); | 372 assert(isClosure != null); |
| 375 } | 373 } |
| 376 } | 374 } |
| 377 | 375 |
| 378 /** | 376 /** |
| 379 * A method that is generated by the backend and has not direct correspondence | 377 * A method that is generated by the backend and has not direct correspondence |
| 380 * to a method in the original Dart program. Examples are getter and setter | 378 * to a method in the original Dart program. Examples are getter and setter |
| 381 * stubs and stubs to dispatch calls to methods with optional parameters. | 379 * stubs and stubs to dispatch calls to methods with optional parameters. |
| 382 */ | 380 */ |
| 383 class StubMethod extends Method { | 381 class StubMethod extends Method { |
| 384 StubMethod(String name, js.Expression code, | 382 StubMethod(String name, js.Expression code, |
| 385 {Element element}) | 383 {Element element}) |
| 386 : super(element, name, code); | 384 : super(element, name, code); |
| 387 } | 385 } |
| 388 | 386 |
| 387 /// A method that is generated for the different versions of method calls of |
| 388 /// methods with named parameters, |
| 389 /// |
| 390 /// For example, for a method foo(a, b, {c, d}) that is called as |
| 391 /// foo(1, 2, c: 3), we have the stub |
| 392 /// foo$3$c(a, b, c) => foo$4$c$d(a, b, c, null); |
| 393 class ParameterStubMethod extends StubMethod { |
| 394 final Selector selector; |
| 395 ParameterStubMethod(String name, js.Expression code, this.selector, |
| 396 {Element element}) |
| 397 : super(name, code, element: element); |
| 398 } |
| 399 |
| 389 abstract class StaticMethod implements Method { | 400 abstract class StaticMethod implements Method { |
| 390 Holder get holder; | 401 Holder get holder; |
| 391 } | 402 } |
| 392 | 403 |
| 393 class StaticDartMethod extends DartMethod implements StaticMethod { | 404 class StaticDartMethod extends DartMethod implements StaticMethod { |
| 394 final Holder holder; | 405 final Holder holder; |
| 395 | 406 |
| 396 StaticDartMethod(Element element, String name, this.holder, | 407 StaticDartMethod(Element element, String name, this.holder, |
| 397 js.Expression code, | 408 js.Expression code, parameterStubs, |
| 398 {bool needsTearOff, String tearOffName, bool canBeApplied, | 409 {bool needsTearOff, String tearOffName, bool canBeApplied, |
| 399 bool canBeReflected, bool needsStubs}) | 410 bool canBeReflected}) |
| 400 : super(element, name, code, | 411 : super(element, name, code, parameterStubs, |
| 401 needsTearOff: needsTearOff, | 412 needsTearOff: needsTearOff, |
| 402 tearOffName : tearOffName, | 413 tearOffName : tearOffName, |
| 403 canBeApplied : canBeApplied, | 414 canBeApplied : canBeApplied, |
| 404 canBeReflected : canBeReflected, | 415 canBeReflected : canBeReflected); |
| 405 needsStubs : needsStubs); | |
| 406 } | 416 } |
| 407 | 417 |
| 408 class StaticStubMethod extends StubMethod implements StaticMethod { | 418 class StaticStubMethod extends StubMethod implements StaticMethod { |
| 409 Holder holder; | 419 Holder holder; |
| 410 StaticStubMethod(String name, this.holder, js.Expression code) | 420 StaticStubMethod(String name, this.holder, js.Expression code) |
| 411 : super(name, code); | 421 : super(name, code); |
| 412 } | 422 } |
| OLD | NEW |