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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 js.if_(js('typeof fields == "function"'), [ | 306 js.if_(js('typeof fields == "function"'), [ |
| 307 js('constructor = fields') | 307 js('constructor = fields') |
| 308 ], /* else */ [ | 308 ], /* else */ [ |
| 309 js('var str = "function " + cls + "("'), | 309 js('var str = "function " + cls + "("'), |
| 310 js('var body = ""'), | 310 js('var body = ""'), |
| 311 | 311 |
| 312 js.for_('var i = 0', 'i < fields.length', 'i++', [ | 312 js.for_('var i = 0', 'i < fields.length', 'i++', [ |
| 313 js.if_('i != 0', js('str += ", "')), | 313 js.if_('i != 0', js('str += ", "')), |
| 314 | 314 |
| 315 js('var field = fields[i]'), | 315 js('var field = fields[i]'), |
| 316 js('var parameter = "parameter" + i'), | |
|
sra1
2013/05/16 00:09:31
This would give more readable code when you single
ahe
2013/05/16 12:41:56
Great idea. Done.
| |
| 316 js('field = generateAccessor(field, prototype)'), | 317 js('field = generateAccessor(field, prototype)'), |
| 317 js('str += field'), | 318 js('str += parameter'), |
| 318 js('body += ("this." + field + " = " + field + ";\\n")') | 319 js('body += ("this." + field + " = " + parameter + ";\\n")') |
| 319 ]), | 320 ]), |
| 320 | 321 |
| 321 js('str += (") {" + body + "}\\nreturn " + cls)'), | 322 js('str += (") {" + body + "}\\nreturn " + cls)'), |
| 322 | 323 |
| 323 js('constructor = new Function(str)()') | 324 js('constructor = new Function(str)()') |
| 324 ]), | 325 ]), |
| 325 | 326 |
| 326 js('constructor.prototype = prototype'), | 327 js('constructor.prototype = prototype'), |
| 327 js(r'constructor.builtin$cls = name'), | 328 js(r'constructor.builtin$cls = name'), |
| 328 | 329 |
| (...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3145 """; | 3146 """; |
| 3146 const String HOOKS_API_USAGE = """ | 3147 const String HOOKS_API_USAGE = """ |
| 3147 // The code supports the following hooks: | 3148 // The code supports the following hooks: |
| 3148 // dartPrint(message) - if this function is defined it is called | 3149 // dartPrint(message) - if this function is defined it is called |
| 3149 // instead of the Dart [print] method. | 3150 // instead of the Dart [print] method. |
| 3150 // dartMainRunner(main) - if this function is defined, the Dart [main] | 3151 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 3151 // method will not be invoked directly. | 3152 // method will not be invoked directly. |
| 3152 // Instead, a closure that will invoke [main] is | 3153 // Instead, a closure that will invoke [main] is |
| 3153 // passed to [dartMainRunner]. | 3154 // passed to [dartMainRunner]. |
| 3154 """; | 3155 """; |
| OLD | NEW |