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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 } | 134 } |
| 135 } | 135 } |
| 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, nameTag, isStatic, |
| 145 originalDescriptor, functions) { | 145 originalDescriptor, functions) { |
| 146 // The name could be an aliased method, which is only resolved later in | |
| 147 // finishClasses. We need to use the actual name for the generated stubs. | |
| 148 // Note that no getter for the alias is needed, as getter sends via super | |
| 149 // are handled via the prototype chain and not using the alias. | |
| 150 var name = nameTag.split(':')[0]; | |
|
floitsch
2014/11/24 10:47:52
Ideally this code would also be together with the
herhut
2014/11/25 14:03:20
Removed.
| |
| 146 var f, funcs = | 151 var f, funcs = |
| 147 [originalDescriptor[name] = | 152 [originalDescriptor[nameTag] = |
| 148 descriptor[name] = f = ${readFunction("array", "$FUNCTION_INDEX")}]; | 153 descriptor[nameTag] = f = ${readFunction("array", "$FUNCTION_INDEX")}]; |
| 149 f.\$stubName = name; | 154 f.\$stubName = name; |
| 150 functions.push(name); | 155 functions.push(name); |
| 151 for (var index = $FUNCTION_INDEX; index < array.length; index += 2) { | 156 for (var index = $FUNCTION_INDEX; index < array.length; index += 2) { |
| 152 f = array[index + 1]; | 157 f = array[index + 1]; |
| 153 if (typeof f != "function") break; | 158 if (typeof f != "function") break; |
| 154 f.\$stubName = ${readString("array", "index + 2")}; | 159 f.\$stubName = ${readString("array", "index + 2")}; |
| 155 funcs.push(f); | 160 funcs.push(f); |
| 156 if (f.\$stubName) { | 161 if (f.\$stubName) { |
| 157 originalDescriptor[f.\$stubName] = descriptor[f.\$stubName] = f; | 162 originalDescriptor[f.\$stubName] = descriptor[f.\$stubName] = f; |
| 158 functions.push(f.\$stubName); | 163 functions.push(f.\$stubName); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 172 var optionalParameterCount = optionalParameterInfo >> 1; | 177 var optionalParameterCount = optionalParameterInfo >> 1; |
| 173 var optionalParametersAreNamed = (optionalParameterInfo & 1) === 1; | 178 var optionalParametersAreNamed = (optionalParameterInfo & 1) === 1; |
| 174 var isIntercepted = | 179 var isIntercepted = |
| 175 requiredParameterCount + optionalParameterCount != funcs[0].length; | 180 requiredParameterCount + optionalParameterCount != funcs[0].length; |
| 176 var functionTypeIndex = ${readFunctionType("array", "2")}; | 181 var functionTypeIndex = ${readFunctionType("array", "2")}; |
| 177 var unmangledNameIndex = $unmangledNameIndex; | 182 var unmangledNameIndex = $unmangledNameIndex; |
| 178 var isReflectable = array.length > unmangledNameIndex; | 183 var isReflectable = array.length > unmangledNameIndex; |
| 179 | 184 |
| 180 if (getterStubName) { | 185 if (getterStubName) { |
| 181 f = tearOff(funcs, array, isStatic, name, isIntercepted); | 186 f = tearOff(funcs, array, isStatic, name, isIntercepted); |
| 182 descriptor[name].\$getter = f; | 187 descriptor[nameTag].\$getter = f; |
| 183 f.\$getterStub = true; | 188 f.\$getterStub = true; |
| 184 // Used to create an isolate using spawnFunction. | 189 // Used to create an isolate using spawnFunction. |
| 185 if (isStatic) #[name] = f; // embedded globalFunctions. | 190 if (isStatic) #[name] = f; // embedded globalFunctions. |
| 186 originalDescriptor[getterStubName] = descriptor[getterStubName] = f; | 191 originalDescriptor[getterStubName] = descriptor[getterStubName] = f; |
| 187 funcs.push(f); | 192 funcs.push(f); |
| 188 if (getterStubName) functions.push(getterStubName); | 193 if (getterStubName) functions.push(getterStubName); |
| 189 f.\$stubName = getterStubName; | 194 f.\$stubName = getterStubName; |
| 190 f.\$callName = null; | 195 f.\$callName = null; |
| 191 if (isIntercepted) #[getterStubName] = true; // embedded interceptedNames. | 196 if (isIntercepted) #[getterStubName] = true; // embedded interceptedNames. |
| 192 } | 197 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 (function() { | 405 (function() { |
| 401 var result = $array[$index]; | 406 var result = $array[$index]; |
| 402 if ($check) { | 407 if ($check) { |
| 403 throw new Error( | 408 throw new Error( |
| 404 name + ": expected value of type \'$type\' at index " + ($index) + | 409 name + ": expected value of type \'$type\' at index " + ($index) + |
| 405 " but got " + (typeof result)); | 410 " but got " + (typeof result)); |
| 406 } | 411 } |
| 407 return result; | 412 return result; |
| 408 })()'''; | 413 })()'''; |
| 409 } | 414 } |
| OLD | NEW |