Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 // TODO(ahe): Share these with js_helper.dart. | 7 // TODO(ahe): Share these with js_helper.dart. |
| 8 const FUNCTION_INDEX = 0; | 8 const FUNCTION_INDEX = 0; |
| 9 const NAME_INDEX = 1; | 9 const NAME_INDEX = 1; |
| 10 const CALL_NAME_INDEX = 2; | 10 const CALL_NAME_INDEX = 2; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 ''', [typeInformationAccess, globalFunctionsAccess, staticsAccess]); | 136 ''', [typeInformationAccess, globalFunctionsAccess, staticsAccess]); |
| 137 | 137 |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * See [dart2js.js_emitter.ContainerBuilder.addMemberMethod] for format of | 140 * See [dart2js.js_emitter.ContainerBuilder.addMemberMethod] for format of |
| 141 * [array]. | 141 * [array]. |
| 142 */ | 142 */ |
| 143 jsAst.Statement addStubs = js.statement(''' | 143 jsAst.Statement addStubs = js.statement(''' |
| 144 function addStubs(descriptor, array, name, isStatic, | 144 function addStubs(descriptor, array, name, isStatic, |
| 145 originalDescriptor, functions) { | 145 originalDescriptor, functions) { |
| 146 var f, funcs = | 146 var index = $FUNCTION_INDEX, alias = array[index], |
| 147 [originalDescriptor[name] = | 147 f = typeof alias == "string" ? array[++index] |
|
floitsch
2014/11/25 14:25:13
Use an if. The "?" gets too complicated.
herhut
2014/11/26 09:41:36
Done.
| |
| 148 descriptor[name] = f = ${readFunction("array", "$FUNCTION_INDEX")}]; | 148 : (alias = name, array[index]), |
| 149 funcs = | |
| 150 [originalDescriptor[name] = | |
| 151 descriptor[name] = descriptor[alias] = f]; | |
|
floitsch
2014/11/25 14:25:13
indentation.
herhut
2014/11/26 09:41:36
Done.
| |
| 149 f.\$stubName = name; | 152 f.\$stubName = name; |
| 150 functions.push(name); | 153 functions.push(name); |
| 151 for (var index = $FUNCTION_INDEX; index < array.length; index += 2) { | 154 for (; index < array.length; index += 2) { |
| 152 f = array[index + 1]; | 155 f = array[index + 1]; |
| 153 if (typeof f != "function") break; | 156 if (typeof f != "function") break; |
| 154 f.\$stubName = ${readString("array", "index + 2")}; | 157 f.\$stubName = ${readString("array", "index + 2")}; |
| 155 funcs.push(f); | 158 funcs.push(f); |
| 156 if (f.\$stubName) { | 159 if (f.\$stubName) { |
| 157 originalDescriptor[f.\$stubName] = descriptor[f.\$stubName] = f; | 160 originalDescriptor[f.\$stubName] = descriptor[f.\$stubName] = f; |
| 158 functions.push(f.\$stubName); | 161 functions.push(f.\$stubName); |
| 159 } | 162 } |
| 160 } | 163 } |
| 161 for (var i = 0; i < funcs.length; index++, i++) { | 164 for (var i = 0; i < funcs.length; index++, i++) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 (function() { | 403 (function() { |
| 401 var result = $array[$index]; | 404 var result = $array[$index]; |
| 402 if ($check) { | 405 if ($check) { |
| 403 throw new Error( | 406 throw new Error( |
| 404 name + ": expected value of type \'$type\' at index " + ($index) + | 407 name + ": expected value of type \'$type\' at index " + ($index) + |
| 405 " but got " + (typeof result)); | 408 " but got " + (typeof result)); |
| 406 } | 409 } |
| 407 return result; | 410 return result; |
| 408 })()'''; | 411 })()'''; |
| 409 } | 412 } |
| OLD | NEW |