| 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], f; |
| 147 [originalDescriptor[name] = | 147 if (typeof alias == "string") { |
| 148 descriptor[name] = f = ${readFunction("array", "$FUNCTION_INDEX")}]; | 148 f = array[++index]; |
| 149 } else { |
| 150 f = alias; |
| 151 alias = name; |
| 152 } |
| 153 var funcs = [originalDescriptor[name] = descriptor[name] = |
| 154 descriptor[alias] = f]; |
| 149 f.\$stubName = name; | 155 f.\$stubName = name; |
| 150 functions.push(name); | 156 functions.push(name); |
| 151 for (var index = $FUNCTION_INDEX; index < array.length; index += 2) { | 157 for (; index < array.length; index += 2) { |
| 152 f = array[index + 1]; | 158 f = array[index + 1]; |
| 153 if (typeof f != "function") break; | 159 if (typeof f != "function") break; |
| 154 f.\$stubName = ${readString("array", "index + 2")}; | 160 f.\$stubName = ${readString("array", "index + 2")}; |
| 155 funcs.push(f); | 161 funcs.push(f); |
| 156 if (f.\$stubName) { | 162 if (f.\$stubName) { |
| 157 originalDescriptor[f.\$stubName] = descriptor[f.\$stubName] = f; | 163 originalDescriptor[f.\$stubName] = descriptor[f.\$stubName] = f; |
| 158 functions.push(f.\$stubName); | 164 functions.push(f.\$stubName); |
| 159 } | 165 } |
| 160 } | 166 } |
| 161 for (var i = 0; i < funcs.length; index++, i++) { | 167 for (var i = 0; i < funcs.length; index++, i++) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 (function() { | 406 (function() { |
| 401 var result = $array[$index]; | 407 var result = $array[$index]; |
| 402 if ($check) { | 408 if ($check) { |
| 403 throw new Error( | 409 throw new Error( |
| 404 name + ": expected value of type \'$type\' at index " + ($index) + | 410 name + ": expected value of type \'$type\' at index " + ($index) + |
| 405 " but got " + (typeof result)); | 411 " but got " + (typeof result)); |
| 406 } | 412 } |
| 407 return result; | 413 return result; |
| 408 })()'''; | 414 })()'''; |
| 409 } | 415 } |
| OLD | NEW |