| 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, Statement, Name, Literal, | 7 import '../js/js.dart' as js show Expression, Statement, Name, Literal, |
| 8 TokenFinalizer; | 8 TokenFinalizer; |
| 9 import '../constants/values.dart' show ConstantValue; | 9 import '../constants/values.dart' show ConstantValue; |
| 10 | 10 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 /// The element should only be used during the transition to the new model. | 362 /// The element should only be used during the transition to the new model. |
| 363 /// Uses indicate missing information in the model. | 363 /// Uses indicate missing information in the model. |
| 364 final Element element; | 364 final Element element; |
| 365 final js.Name name; | 365 final js.Name name; |
| 366 final js.Expression code; | 366 final js.Expression code; |
| 367 | 367 |
| 368 Method(this.element, this.name, this.code); | 368 Method(this.element, this.name, this.code); |
| 369 } | 369 } |
| 370 | 370 |
| 371 /// A method that corresponds to a method in the original Dart program. | 371 /// A method that corresponds to a method in the original Dart program. |
| 372 class DartMethod extends Method { | 372 abstract class DartMethod extends Method { |
| 373 final bool needsTearOff; | 373 final bool needsTearOff; |
| 374 final js.Name tearOffName; | 374 final js.Name tearOffName; |
| 375 final List<ParameterStubMethod> parameterStubs; | 375 final List<ParameterStubMethod> parameterStubs; |
| 376 final bool canBeApplied; | 376 final bool canBeApplied; |
| 377 final bool canBeReflected; | 377 final bool canBeReflected; |
| 378 | 378 |
| 379 // Is non-null if [needsTearOff] or [canBeReflected]. | 379 // Is non-null if [needsTearOff] or [canBeReflected]. |
| 380 // | 380 // |
| 381 // If the type is encoded in the metadata table this field contains an index | 381 // If the type is encoded in the metadata table this field contains an index |
| 382 // into the table. Otherwise the type contains type variables in which case | 382 // into the table. Otherwise the type contains type variables in which case |
| (...skipping 17 matching lines...) Expand all Loading... |
| 400 this.optionalParameterDefaultValues, this.functionType}) | 400 this.optionalParameterDefaultValues, this.functionType}) |
| 401 : super(element, name, code) { | 401 : super(element, name, code) { |
| 402 assert(needsTearOff != null); | 402 assert(needsTearOff != null); |
| 403 assert(!needsTearOff || tearOffName != null); | 403 assert(!needsTearOff || tearOffName != null); |
| 404 assert(canBeApplied != null); | 404 assert(canBeApplied != null); |
| 405 assert(canBeReflected != null); | 405 assert(canBeReflected != null); |
| 406 assert((!canBeReflected && !canBeApplied) || | 406 assert((!canBeReflected && !canBeApplied) || |
| 407 (requiredParameterCount != null && | 407 (requiredParameterCount != null && |
| 408 optionalParameterDefaultValues != null)); | 408 optionalParameterDefaultValues != null)); |
| 409 } | 409 } |
| 410 |
| 411 bool get isStatic; |
| 410 } | 412 } |
| 411 | 413 |
| 412 class InstanceMethod extends DartMethod { | 414 class InstanceMethod extends DartMethod { |
| 413 /// An alternative name for this method. This is used to model calls to | 415 /// An alternative name for this method. This is used to model calls to |
| 414 /// a method via `super`. If [aliasName] is non-null, the emitter has to | 416 /// a method via `super`. If [aliasName] is non-null, the emitter has to |
| 415 /// ensure that this method is registered on the prototype under both [name] | 417 /// ensure that this method is registered on the prototype under both [name] |
| 416 /// and [aliasName]. | 418 /// and [aliasName]. |
| 417 final js.Name aliasName; | 419 final js.Name aliasName; |
| 418 final bool isClosure; | 420 final bool isClosure; |
| 419 | 421 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 433 : super(element, name, code, parameterStubs, callName, | 435 : super(element, name, code, parameterStubs, callName, |
| 434 needsTearOff: needsTearOff, | 436 needsTearOff: needsTearOff, |
| 435 tearOffName: tearOffName, | 437 tearOffName: tearOffName, |
| 436 canBeApplied: canBeApplied, | 438 canBeApplied: canBeApplied, |
| 437 canBeReflected: canBeReflected, | 439 canBeReflected: canBeReflected, |
| 438 requiredParameterCount: requiredParameterCount, | 440 requiredParameterCount: requiredParameterCount, |
| 439 optionalParameterDefaultValues: optionalParameterDefaultValues, | 441 optionalParameterDefaultValues: optionalParameterDefaultValues, |
| 440 functionType: functionType) { | 442 functionType: functionType) { |
| 441 assert(isClosure != null); | 443 assert(isClosure != null); |
| 442 } | 444 } |
| 445 |
| 446 bool get isStatic => false; |
| 443 } | 447 } |
| 444 | 448 |
| 445 /// A method that is generated by the backend and has not direct correspondence | 449 /// A method that is generated by the backend and has not direct correspondence |
| 446 /// to a method in the original Dart program. Examples are getter and setter | 450 /// to a method in the original Dart program. Examples are getter and setter |
| 447 /// stubs and stubs to dispatch calls to methods with optional parameters. | 451 /// stubs and stubs to dispatch calls to methods with optional parameters. |
| 448 class StubMethod extends Method { | 452 class StubMethod extends Method { |
| 449 StubMethod(js.Name name, js.Expression code, | 453 StubMethod(js.Name name, js.Expression code, |
| 450 {Element element}) | 454 {Element element}) |
| 451 : super(element, name, code); | 455 : super(element, name, code); |
| 452 } | 456 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 /* List | Map */ optionalParameterDefaultValues, | 492 /* List | Map */ optionalParameterDefaultValues, |
| 489 js.Expression functionType}) | 493 js.Expression functionType}) |
| 490 : super(element, name, code, parameterStubs, callName, | 494 : super(element, name, code, parameterStubs, callName, |
| 491 needsTearOff: needsTearOff, | 495 needsTearOff: needsTearOff, |
| 492 tearOffName : tearOffName, | 496 tearOffName : tearOffName, |
| 493 canBeApplied : canBeApplied, | 497 canBeApplied : canBeApplied, |
| 494 canBeReflected : canBeReflected, | 498 canBeReflected : canBeReflected, |
| 495 requiredParameterCount: requiredParameterCount, | 499 requiredParameterCount: requiredParameterCount, |
| 496 optionalParameterDefaultValues: optionalParameterDefaultValues, | 500 optionalParameterDefaultValues: optionalParameterDefaultValues, |
| 497 functionType: functionType); | 501 functionType: functionType); |
| 502 |
| 503 bool get isStatic => true; |
| 498 } | 504 } |
| 499 | 505 |
| 500 class StaticStubMethod extends StubMethod implements StaticMethod { | 506 class StaticStubMethod extends StubMethod implements StaticMethod { |
| 501 Holder holder; | 507 Holder holder; |
| 502 StaticStubMethod(js.Name name, this.holder, js.Expression code) | 508 StaticStubMethod(js.Name name, this.holder, js.Expression code) |
| 503 : super(name, code); | 509 : super(name, code); |
| 504 } | 510 } |
| OLD | NEW |