Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Top level generator object for writing code and keeping track of | 6 * Top level generator object for writing code and keeping track of |
| 7 * dependencies. | 7 * dependencies. |
| 8 * | 8 * |
| 9 * Should have two compilation models, but only one implemented so far. | 9 * Should have two compilation models, but only one implemented so far. |
| 10 * | 10 * |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 968 } | 968 } |
| 969 } | 969 } |
| 970 | 970 |
| 971 if (usesBind) world.gen.corejs.ensureBind(); | 971 if (usesBind) world.gen.corejs.ensureBind(); |
| 972 } | 972 } |
| 973 | 973 |
| 974 static bool _maybeGenerateBoundGetter(MethodMember m, CodeWriter defWriter) { | 974 static bool _maybeGenerateBoundGetter(MethodMember m, CodeWriter defWriter) { |
| 975 if (m._provideGetter) { | 975 if (m._provideGetter) { |
| 976 String suffix = world.gen._writePrototypePatch(m.declaringType, | 976 String suffix = world.gen._writePrototypePatch(m.declaringType, |
| 977 'get\$${m.jsname}', 'function() {', defWriter, false); | 977 'get\$${m.jsname}', 'function() {', defWriter, false); |
| 978 defWriter.writeln('return this.${m.jsname}.bind(this);'); | 978 if (m.parameters.some((p) => p.isOptional)) { |
| 979 defWriter.writeln('var \$bound = this.${m.jsname}.bind(this);'); | |
|
sra1
2012/04/21 03:33:14
nit.
$bound could be any name (e.g. 'f') since the
| |
| 980 defWriter.writeln('\$bound.\$optional = this.${m.jsname}.\$optional;'); | |
| 981 defWriter.writeln('return \$bound;'); | |
| 982 } else { | |
| 983 defWriter.writeln('return this.${m.jsname}.bind(this);'); | |
| 984 } | |
| 979 defWriter.exitBlock(suffix); | 985 defWriter.exitBlock(suffix); |
| 980 return true; | 986 return true; |
| 981 } | 987 } |
| 982 return false; | 988 return false; |
| 983 } | 989 } |
| 984 | 990 |
| 985 /** | 991 /** |
| 986 * Generates information about the default/named arguments into the JS code. | 992 * Generates information about the default/named arguments into the JS code. |
| 987 * Only methods that are passed as bound methods to "var" need this. It is | 993 * Only methods that are passed as bound methods to "var" need this. It is |
| 988 * generated to support run time stub creation. | 994 * generated to support run time stub creation. |
| (...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2530 return true; | 2536 return true; |
| 2531 } | 2537 } |
| 2532 | 2538 |
| 2533 } | 2539 } |
| 2534 | 2540 |
| 2535 class ReturnKind { | 2541 class ReturnKind { |
| 2536 static final int IGNORE = 1; | 2542 static final int IGNORE = 1; |
| 2537 static final int POST = 2; | 2543 static final int POST = 2; |
| 2538 static final int PRE = 3; | 2544 static final int PRE = 3; |
| 2539 } | 2545 } |
| OLD | NEW |