| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 var optionalMethods = descriptor.$methodsWithOptionalArgumentsField; | 167 var optionalMethods = descriptor.$methodsWithOptionalArgumentsField; |
| 168 if (!optionalMethods) { | 168 if (!optionalMethods) { |
| 169 descriptor.$methodsWithOptionalArgumentsField = optionalMethods = {} | 169 descriptor.$methodsWithOptionalArgumentsField = optionalMethods = {} |
| 170 } | 170 } |
| 171 optionalMethods[property] = previousProperty; | 171 optionalMethods[property] = previousProperty; |
| 172 } else if (typeof element === "function") { | 172 } else if (typeof element === "function") { |
| 173 globalObject[previousProperty = property] = element; | 173 globalObject[previousProperty = property] = element; |
| 174 functions.push(property); | 174 functions.push(property); |
| 175 #globalFunctions[property] = element; | 175 #globalFunctions[property] = element; |
| 176 } else if (element.constructor === Array) { | 176 } else if (element.constructor === Array) { |
| 177 if (#needsArrayInitializerSupport) { | 177 if (#needsStructuredMemberInfo) { |
| 178 addStubs(globalObject, element, property, | 178 addStubs(globalObject, element, property, |
| 179 true, descriptor, functions); | 179 true, descriptor, functions); |
| 180 } | 180 } |
| 181 } else { | 181 } else { |
| 182 // We will not enter this case if no classes are defined. | 182 // We will not enter this case if no classes are defined. |
| 183 if (#hasClasses) { | 183 if (#hasClasses) { |
| 184 previousProperty = property; | 184 previousProperty = property; |
| 185 processClassData(property, element, processedClasses); | 185 processClassData(property, element, processedClasses); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 ''', {'typeInformation': typeInformationAccess, | 190 ''', {'typeInformation': typeInformationAccess, |
| 191 'globalFunctions': globalFunctionsAccess, | 191 'globalFunctions': globalFunctionsAccess, |
| 192 'hasClasses': oldEmitter.needsClassSupport, | 192 'hasClasses': oldEmitter.needsClassSupport, |
| 193 'needsArrayInitializerSupport': oldEmitter.needsArrayInitializerSupport}); | 193 'needsStructuredMemberInfo': oldEmitter.needsStructuredMemberInfo}); |
| 194 | 194 |
| 195 | 195 |
| 196 /** | 196 /** |
| 197 * See [dart2js.js_emitter.ContainerBuilder.addMemberMethod] for format of | 197 * See [dart2js.js_emitter.ContainerBuilder.addMemberMethod] for format of |
| 198 * [array]. | 198 * [array]. |
| 199 */ | 199 */ |
| 200 jsAst.Statement addStubs = js.statement(''' | 200 jsAst.Statement addStubs = js.statement(''' |
| 201 function addStubs(descriptor, array, name, isStatic, | 201 function addStubs(descriptor, array, name, isStatic, |
| 202 originalDescriptor, functions) { | 202 originalDescriptor, functions) { |
| 203 var index = $FUNCTION_INDEX, alias = array[index], f; | 203 var index = $FUNCTION_INDEX, alias = array[index], f; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 function $parseReflectionDataName(reflectionData) { | 434 function $parseReflectionDataName(reflectionData) { |
| 435 "use strict"; | 435 "use strict"; |
| 436 #header; | 436 #header; |
| 437 if (#needsClassSupport) { | 437 if (#needsClassSupport) { |
| 438 #defineClass; | 438 #defineClass; |
| 439 #inheritFrom; | 439 #inheritFrom; |
| 440 #finishClasses; | 440 #finishClasses; |
| 441 #processClassData; | 441 #processClassData; |
| 442 } | 442 } |
| 443 #processStatics; | 443 #processStatics; |
| 444 if (#needsArrayInitializerSupport) { | 444 if (#needsStructuredMemberInfo) { |
| 445 #addStubs; | 445 #addStubs; |
| 446 #tearOffCode; | 446 #tearOffCode; |
| 447 } | 447 } |
| 448 #incrementalSupport; | 448 #incrementalSupport; |
| 449 #init; | 449 #init; |
| 450 }''', { | 450 }''', { |
| 451 'header': header, | 451 'header': header, |
| 452 'defineClass': oldEmitter.defineClassFunction, | 452 'defineClass': oldEmitter.defineClassFunction, |
| 453 'inheritFrom': oldEmitter.buildInheritFrom(), | 453 'inheritFrom': oldEmitter.buildInheritFrom(), |
| 454 'processClassData': processClassData, | 454 'processClassData': processClassData, |
| 455 'processStatics': processStatics, | 455 'processStatics': processStatics, |
| 456 'incrementalSupport': incrementalSupport, | 456 'incrementalSupport': incrementalSupport, |
| 457 'addStubs': addStubs, | 457 'addStubs': addStubs, |
| 458 'tearOffCode': tearOffCode, | 458 'tearOffCode': tearOffCode, |
| 459 'init': init, | 459 'init': init, |
| 460 'finishClasses': finishClasses, | 460 'finishClasses': finishClasses, |
| 461 'needsClassSupport': oldEmitter.needsClassSupport, | 461 'needsClassSupport': oldEmitter.needsClassSupport, |
| 462 'needsArrayInitializerSupport': oldEmitter.needsArrayInitializerSupport}); | 462 'needsStructuredMemberInfo': oldEmitter.needsStructuredMemberInfo}); |
| 463 } | 463 } |
| 464 | 464 |
| 465 | 465 |
| 466 List<jsAst.Statement> buildTearOffCode(JavaScriptBackend backend) { | 466 List<jsAst.Statement> buildTearOffCode(JavaScriptBackend backend) { |
| 467 Namer namer = backend.namer; | 467 Namer namer = backend.namer; |
| 468 Compiler compiler = backend.compiler; | 468 Compiler compiler = backend.compiler; |
| 469 | 469 |
| 470 Element closureFromTearOff = backend.findHelper('closureFromTearOff'); | 470 Element closureFromTearOff = backend.findHelper('closureFromTearOff'); |
| 471 String tearOffAccessText; | 471 String tearOffAccessText; |
| 472 jsAst.Expression tearOffAccessExpression; | 472 jsAst.Expression tearOffAccessExpression; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 (function() { | 574 (function() { |
| 575 var result = $array[$index]; | 575 var result = $array[$index]; |
| 576 if ($check) { | 576 if ($check) { |
| 577 throw new Error( | 577 throw new Error( |
| 578 name + ": expected value of type \'$type\' at index " + ($index) + | 578 name + ": expected value of type \'$type\' at index " + ($index) + |
| 579 " but got " + (typeof result)); | 579 " but got " + (typeof result)); |
| 580 } | 580 } |
| 581 return result; | 581 return result; |
| 582 })()'''; | 582 })()'''; |
| 583 } | 583 } |
| OLD | NEW |