Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/model.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/model.dart b/pkg/compiler/lib/src/js_emitter/model.dart |
| index 9b782382a38ea38088330060dfc74b8d43196487..db85886234acf089cb15401404919ccc569440b7 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/model.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/model.dart |
| @@ -327,9 +327,7 @@ abstract class Method { |
| Method(this.element, this.name, this.code); |
| } |
| -/** |
| - * A method that corresponds to a method in the original Dart program. |
| - */ |
| +/// A method that corresponds to a method in the original Dart program. |
| class DartMethod extends Method { |
| final bool needsTearOff; |
| final String tearOffName; |
| @@ -338,15 +336,19 @@ class DartMethod extends Method { |
| final bool canBeApplied; |
| final bool canBeReflected; |
| + // If this method can be torn off, contains the name of the corresponding |
| + // call method. For example, for the member `foo$1$name` it would be |
| + // `call$1$name` (in unminified mode). |
| + final String callName; |
| + |
| DartMethod(Element element, String name, js.Expression code, |
| - this.parameterStubs, |
| + this.parameterStubs, this.callName, |
| {this.needsTearOff, this.tearOffName, this.canBeApplied, |
| this.canBeReflected}) |
| : super(element, name, code) { |
| assert(needsTearOff != null); |
| assert(!needsTearOff || tearOffName != null); |
| assert(canBeApplied != null); |
| - assert(parameterStubs != null); |
| assert(canBeReflected != null); |
| } |
| } |
| @@ -356,14 +358,16 @@ class InstanceMethod extends DartMethod { |
| final bool hasSuperAlias; |
| final bool isClosure; |
| - InstanceMethod(element, name, code, List<ParameterStubMethod> parameterStubs, |
| - {bool needsTearOff, |
| - String tearOffName, |
| - this.hasSuperAlias, |
| - bool canBeApplied, |
| - bool canBeReflected, |
| + InstanceMethod(Element element, String name, js.Expression code, |
| + List<ParameterStubMethod> parameterStubs, |
| + String callName, |
| + {bool needsTearOff, |
| + String tearOffName, |
| + this.hasSuperAlias, |
| + bool canBeApplied, |
| + bool canBeReflected, |
| this.isClosure}) |
| - : super(element, name, code, parameterStubs, |
| + : super(element, name, code, parameterStubs, callName, |
| needsTearOff: needsTearOff, |
| tearOffName: tearOffName, |
| canBeApplied: canBeApplied, |
| @@ -373,28 +377,34 @@ class InstanceMethod extends DartMethod { |
| } |
| } |
| -/** |
| - * A method that is generated by the backend and has not direct correspondence |
| - * to a method in the original Dart program. Examples are getter and setter |
| - * stubs and stubs to dispatch calls to methods with optional parameters. |
| - */ |
| +/// A method that is generated by the backend and has not direct correspondence |
| +/// to a method in the original Dart program. Examples are getter and setter |
| +/// stubs and stubs to dispatch calls to methods with optional parameters. |
| class StubMethod extends Method { |
| StubMethod(String name, js.Expression code, |
| {Element element}) |
| : super(element, name, code); |
| } |
| - /// A method that is generated for the different versions of method calls of |
| - /// methods with named parameters, |
| - /// |
| - /// For example, for a method foo(a, b, {c, d}) that is called as |
| - /// foo(1, 2, c: 3), we have the stub |
| - /// foo$3$c(a, b, c) => foo$4$c$d(a, b, c, null); |
| +/// A stub that adapts and redirects to the main method (the one containing) |
| +/// the actual code. |
| +/// |
| +/// For example, given a method `foo$2(x, [y: 499])` a possible parameter |
| +/// stub-method could be `foo$1(x) => foo$2(x, 499)`. |
| +/// |
| +/// ParameterStubMethods are always attached to (static or instance) methods. |
| class ParameterStubMethod extends StubMethod { |
| - final Selector selector; |
| - ParameterStubMethod(String name, js.Expression code, this.selector, |
| - {Element element}) |
| - : super(name, code, element: element); |
| + /// The `call` name of this stub. |
| + /// |
| + /// When an instance method is torn off, it is invoked as a `call` member and |
| + /// not it's original name anymore. The [callName] provides the stub's |
| + /// name when it is used this way. |
| + /// |
| + /// If an stub's member can not be torn off, the [callName] is `null`. |
|
zarah
2015/01/30 14:07:28
an -> a.
floitsch
2015/01/30 21:48:13
Done.
|
| + String callName; |
| + |
| + ParameterStubMethod(String name, this.callName, js.Expression code) |
| + : super(name, code); |
| } |
| abstract class StaticMethod implements Method { |
| @@ -405,10 +415,11 @@ class StaticDartMethod extends DartMethod implements StaticMethod { |
| final Holder holder; |
| StaticDartMethod(Element element, String name, this.holder, |
| - js.Expression code, parameterStubs, |
| + js.Expression code, List<ParameterStubMethod> parameterStubs, |
| + String callName, |
| {bool needsTearOff, String tearOffName, bool canBeApplied, |
| bool canBeReflected}) |
| - : super(element, name, code, parameterStubs, |
| + : super(element, name, code, parameterStubs, callName, |
| needsTearOff: needsTearOff, |
| tearOffName : tearOffName, |
| canBeApplied : canBeApplied, |