| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES); | 48 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES); |
| 49 jsAst.Expression mangledNamesAccess = | 49 jsAst.Expression mangledNamesAccess = |
| 50 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_NAMES); | 50 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_NAMES); |
| 51 jsAst.Expression librariesAccess = | 51 jsAst.Expression librariesAccess = |
| 52 emitter.generateEmbeddedGlobalAccess(embeddedNames.LIBRARIES); | 52 emitter.generateEmbeddedGlobalAccess(embeddedNames.LIBRARIES); |
| 53 jsAst.Expression metadataAccess = | 53 jsAst.Expression metadataAccess = |
| 54 emitter.generateEmbeddedGlobalAccess(embeddedNames.METADATA); | 54 emitter.generateEmbeddedGlobalAccess(embeddedNames.METADATA); |
| 55 | 55 |
| 56 jsAst.Statement processClassData = js.statement('''{ | 56 jsAst.Statement processClassData = js.statement('''{ |
| 57 function processClassData(cls, descriptor, processedClasses) { | 57 function processClassData(cls, descriptor, processedClasses) { |
| 58 var newDesc = {}; | 58 var newDesc = map(); // Use a slow object. |
| 59 var previousProperty; | 59 var previousProperty; |
| 60 var properties = Object.keys(descriptor); | 60 var properties = Object.keys(descriptor); |
| 61 for (var i = 0; i < properties.length; i++) { | 61 for (var i = 0; i < properties.length; i++) { |
| 62 var property = properties[i]; | 62 var property = properties[i]; |
| 63 var firstChar = property.substring(0, 1); | 63 var firstChar = property.substring(0, 1); |
| 64 if (property === "static") { | 64 if (property === "static") { |
| 65 processStatics(#embeddedStatics[cls] = descriptor[property], | 65 processStatics(#embeddedStatics[cls] = descriptor[property], |
| 66 processedClasses); | 66 processedClasses); |
| 67 } else if (firstChar === "+") { | 67 } else if (firstChar === "+") { |
| 68 mangledNames[previousProperty] = property.substring(1); | 68 mangledNames[previousProperty] = property.substring(1); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 if (!#statics) #statics = map(); | 292 if (!#statics) #statics = map(); |
| 293 if (!#typeInformation) #typeInformation = map(); | 293 if (!#typeInformation) #typeInformation = map(); |
| 294 if (!#globalFunctions) #globalFunctions = map(); | 294 if (!#globalFunctions) #globalFunctions = map(); |
| 295 if (#enabledInvokeOn) | 295 if (#enabledInvokeOn) |
| 296 if (!#interceptedNames) #interceptedNames = #interceptedNamesSet; | 296 if (!#interceptedNames) #interceptedNames = #interceptedNamesSet; |
| 297 var libraries = #libraries; | 297 var libraries = #libraries; |
| 298 var mangledNames = #mangledNames; | 298 var mangledNames = #mangledNames; |
| 299 var mangledGlobalNames = #mangledGlobalNames; | 299 var mangledGlobalNames = #mangledGlobalNames; |
| 300 var hasOwnProperty = Object.prototype.hasOwnProperty; | 300 var hasOwnProperty = Object.prototype.hasOwnProperty; |
| 301 var length = reflectionData.length; | 301 var length = reflectionData.length; |
| 302 var processedClasses = Object.create(null); | 302 var processedClasses = map(); |
| 303 processedClasses.collected = Object.create(null); | 303 processedClasses.collected = map(); |
| 304 processedClasses.pending = Object.create(null); | 304 processedClasses.pending = map(); |
| 305 if (#notInCspMode) { | 305 if (#notInCspMode) { |
| 306 processedClasses.constructorsList = []; | 306 processedClasses.constructorsList = []; |
| 307 // For every class processed [processedClasses.combinedConstructorFunction] | 307 // For every class processed [processedClasses.combinedConstructorFunction] |
| 308 // will be updated with the corresponding constructor function. | 308 // will be updated with the corresponding constructor function. |
| 309 processedClasses.combinedConstructorFunction = | 309 processedClasses.combinedConstructorFunction = |
| 310 "function \$reflectable(fn){fn.$reflectableField=1;return fn};\\n"+ | 310 "function \$reflectable(fn){fn.$reflectableField=1;return fn};\\n"+ |
| 311 "var \$desc;\\n"; | 311 "var \$desc;\\n"; |
| 312 } | 312 } |
| 313 for (var i = 0; i < length; i++) { | 313 for (var i = 0; i < length; i++) { |
| 314 var data = reflectionData[i]; | 314 var data = reflectionData[i]; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 (function() { | 484 (function() { |
| 485 var result = $array[$index]; | 485 var result = $array[$index]; |
| 486 if ($check) { | 486 if ($check) { |
| 487 throw new Error( | 487 throw new Error( |
| 488 name + ": expected value of type \'$type\' at index " + ($index) + | 488 name + ": expected value of type \'$type\' at index " + ($index) + |
| 489 " but got " + (typeof result)); | 489 " but got " + (typeof result)); |
| 490 } | 490 } |
| 491 return result; | 491 return result; |
| 492 })()'''; | 492 })()'''; |
| 493 } | 493 } |
| OLD | NEW |